blob: ebcabec824b8619e39f2fe138d3a6a9de8758bf5 [file] [log] [blame]
Reid Spencer3fae7ba2007-03-14 23:13:06 +00001/* A Bison parser, made by GNU Bison 2.1. */
Reid Spencere7c3c602006-11-30 06:36:44 +00002
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003/* Skeleton parser for Yacc-like parsing with Bison,
4 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
Reid Spencere7c3c602006-11-30 06:36:44 +00005
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
Reid Spencere7c3c602006-11-30 06:36:44 +000010
Reid Spencer3fae7ba2007-03-14 23:13:06 +000011 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA. */
20
21/* As a special exception, when this file is copied by Bison into a
22 Bison output file, you may use that output file without restriction.
23 This special exception was added by the Free Software Foundation
24 in version 1.24 of Bison. */
25
26/* Written by Richard Stallman by simplifying the original so called
27 ``semantic'' parser. */
28
29/* All symbols defined below should begin with yy or YY, to avoid
30 infringing on user name space. This should be done even for local
31 variables, as they might otherwise be expanded by user macros.
32 There are some unavoidable exceptions within include files to
33 define necessary library symbols; they are noted "INFRINGES ON
34 USER NAME SPACE" below. */
35
36/* Identify Bison output. */
37#define YYBISON 1
38
39/* Bison version. */
40#define YYBISON_VERSION "2.1"
41
42/* Skeleton name. */
43#define YYSKELETON_NAME "yacc.c"
44
45/* Pure parsers. */
46#define YYPURE 0
47
48/* Using locations. */
49#define YYLSP_NEEDED 0
50
51/* Substitute the variable and function names. */
Reid Spencere7c3c602006-11-30 06:36:44 +000052#define yyparse Upgradeparse
Reid Spencer3fae7ba2007-03-14 23:13:06 +000053#define yylex Upgradelex
Reid Spencere7c3c602006-11-30 06:36:44 +000054#define yyerror Upgradeerror
Reid Spencer3fae7ba2007-03-14 23:13:06 +000055#define yylval Upgradelval
56#define yychar Upgradechar
Reid Spencere7c3c602006-11-30 06:36:44 +000057#define yydebug Upgradedebug
58#define yynerrs Upgradenerrs
59
Reid Spencer3fae7ba2007-03-14 23:13:06 +000060
61/* Tokens. */
62#ifndef YYTOKENTYPE
63# define YYTOKENTYPE
64 /* Put the tokens into the symbol table, so that GDB and other debuggers
65 know about them. */
66 enum yytokentype {
67 ESINT64VAL = 258,
68 EUINT64VAL = 259,
69 SINTVAL = 260,
70 UINTVAL = 261,
71 FPVAL = 262,
72 VOID = 263,
73 BOOL = 264,
74 SBYTE = 265,
75 UBYTE = 266,
76 SHORT = 267,
77 USHORT = 268,
78 INT = 269,
79 UINT = 270,
80 LONG = 271,
81 ULONG = 272,
82 FLOAT = 273,
83 DOUBLE = 274,
84 TYPE = 275,
85 LABEL = 276,
86 VAR_ID = 277,
87 LABELSTR = 278,
88 STRINGCONSTANT = 279,
89 IMPLEMENTATION = 280,
90 ZEROINITIALIZER = 281,
91 TRUETOK = 282,
92 FALSETOK = 283,
93 BEGINTOK = 284,
94 ENDTOK = 285,
95 DECLARE = 286,
96 GLOBAL = 287,
97 CONSTANT = 288,
98 SECTION = 289,
99 VOLATILE = 290,
100 TO = 291,
101 DOTDOTDOT = 292,
102 NULL_TOK = 293,
103 UNDEF = 294,
104 CONST = 295,
105 INTERNAL = 296,
106 LINKONCE = 297,
107 WEAK = 298,
108 APPENDING = 299,
109 DLLIMPORT = 300,
110 DLLEXPORT = 301,
111 EXTERN_WEAK = 302,
112 OPAQUE = 303,
113 NOT = 304,
114 EXTERNAL = 305,
115 TARGET = 306,
116 TRIPLE = 307,
117 ENDIAN = 308,
118 POINTERSIZE = 309,
119 LITTLE = 310,
120 BIG = 311,
121 ALIGN = 312,
122 DEPLIBS = 313,
123 CALL = 314,
124 TAIL = 315,
125 ASM_TOK = 316,
126 MODULE = 317,
127 SIDEEFFECT = 318,
128 CC_TOK = 319,
129 CCC_TOK = 320,
130 CSRETCC_TOK = 321,
131 FASTCC_TOK = 322,
132 COLDCC_TOK = 323,
133 X86_STDCALLCC_TOK = 324,
134 X86_FASTCALLCC_TOK = 325,
135 DATALAYOUT = 326,
136 RET = 327,
137 BR = 328,
138 SWITCH = 329,
139 INVOKE = 330,
140 UNREACHABLE = 331,
141 UNWIND = 332,
142 EXCEPT = 333,
143 ADD = 334,
144 SUB = 335,
145 MUL = 336,
146 DIV = 337,
147 UDIV = 338,
148 SDIV = 339,
149 FDIV = 340,
150 REM = 341,
151 UREM = 342,
152 SREM = 343,
153 FREM = 344,
154 AND = 345,
155 OR = 346,
156 XOR = 347,
157 SHL = 348,
158 SHR = 349,
159 ASHR = 350,
160 LSHR = 351,
161 SETLE = 352,
162 SETGE = 353,
163 SETLT = 354,
164 SETGT = 355,
165 SETEQ = 356,
166 SETNE = 357,
167 ICMP = 358,
168 FCMP = 359,
169 MALLOC = 360,
170 ALLOCA = 361,
171 FREE = 362,
172 LOAD = 363,
173 STORE = 364,
174 GETELEMENTPTR = 365,
175 PHI_TOK = 366,
176 SELECT = 367,
177 VAARG = 368,
178 EXTRACTELEMENT = 369,
179 INSERTELEMENT = 370,
180 SHUFFLEVECTOR = 371,
181 VAARG_old = 372,
182 VANEXT_old = 373,
183 EQ = 374,
184 NE = 375,
185 SLT = 376,
186 SGT = 377,
187 SLE = 378,
188 SGE = 379,
189 ULT = 380,
190 UGT = 381,
191 ULE = 382,
192 UGE = 383,
193 OEQ = 384,
194 ONE = 385,
195 OLT = 386,
196 OGT = 387,
197 OLE = 388,
198 OGE = 389,
199 ORD = 390,
200 UNO = 391,
201 UEQ = 392,
202 UNE = 393,
203 CAST = 394,
204 TRUNC = 395,
205 ZEXT = 396,
206 SEXT = 397,
207 FPTRUNC = 398,
208 FPEXT = 399,
209 FPTOUI = 400,
210 FPTOSI = 401,
211 UITOFP = 402,
212 SITOFP = 403,
213 PTRTOINT = 404,
214 INTTOPTR = 405,
215 BITCAST = 406
216 };
217#endif
218/* Tokens. */
219#define ESINT64VAL 258
220#define EUINT64VAL 259
221#define SINTVAL 260
222#define UINTVAL 261
223#define FPVAL 262
224#define VOID 263
225#define BOOL 264
226#define SBYTE 265
227#define UBYTE 266
228#define SHORT 267
229#define USHORT 268
230#define INT 269
231#define UINT 270
232#define LONG 271
233#define ULONG 272
234#define FLOAT 273
235#define DOUBLE 274
236#define TYPE 275
237#define LABEL 276
238#define VAR_ID 277
239#define LABELSTR 278
240#define STRINGCONSTANT 279
241#define IMPLEMENTATION 280
242#define ZEROINITIALIZER 281
243#define TRUETOK 282
244#define FALSETOK 283
245#define BEGINTOK 284
246#define ENDTOK 285
247#define DECLARE 286
248#define GLOBAL 287
249#define CONSTANT 288
250#define SECTION 289
251#define VOLATILE 290
252#define TO 291
253#define DOTDOTDOT 292
254#define NULL_TOK 293
255#define UNDEF 294
256#define CONST 295
257#define INTERNAL 296
258#define LINKONCE 297
259#define WEAK 298
260#define APPENDING 299
261#define DLLIMPORT 300
262#define DLLEXPORT 301
263#define EXTERN_WEAK 302
264#define OPAQUE 303
265#define NOT 304
266#define EXTERNAL 305
267#define TARGET 306
268#define TRIPLE 307
269#define ENDIAN 308
270#define POINTERSIZE 309
271#define LITTLE 310
272#define BIG 311
273#define ALIGN 312
274#define DEPLIBS 313
275#define CALL 314
276#define TAIL 315
277#define ASM_TOK 316
278#define MODULE 317
279#define SIDEEFFECT 318
280#define CC_TOK 319
281#define CCC_TOK 320
282#define CSRETCC_TOK 321
283#define FASTCC_TOK 322
284#define COLDCC_TOK 323
285#define X86_STDCALLCC_TOK 324
286#define X86_FASTCALLCC_TOK 325
287#define DATALAYOUT 326
288#define RET 327
289#define BR 328
290#define SWITCH 329
291#define INVOKE 330
292#define UNREACHABLE 331
293#define UNWIND 332
294#define EXCEPT 333
295#define ADD 334
296#define SUB 335
297#define MUL 336
298#define DIV 337
299#define UDIV 338
300#define SDIV 339
301#define FDIV 340
302#define REM 341
303#define UREM 342
304#define SREM 343
305#define FREM 344
306#define AND 345
307#define OR 346
308#define XOR 347
309#define SHL 348
310#define SHR 349
311#define ASHR 350
312#define LSHR 351
313#define SETLE 352
314#define SETGE 353
315#define SETLT 354
316#define SETGT 355
317#define SETEQ 356
318#define SETNE 357
319#define ICMP 358
320#define FCMP 359
321#define MALLOC 360
322#define ALLOCA 361
323#define FREE 362
324#define LOAD 363
325#define STORE 364
326#define GETELEMENTPTR 365
327#define PHI_TOK 366
328#define SELECT 367
329#define VAARG 368
330#define EXTRACTELEMENT 369
331#define INSERTELEMENT 370
332#define SHUFFLEVECTOR 371
333#define VAARG_old 372
334#define VANEXT_old 373
335#define EQ 374
336#define NE 375
337#define SLT 376
338#define SGT 377
339#define SLE 378
340#define SGE 379
341#define ULT 380
342#define UGT 381
343#define ULE 382
344#define UGE 383
345#define OEQ 384
346#define ONE 385
347#define OLT 386
348#define OGT 387
349#define OLE 388
350#define OGE 389
351#define ORD 390
352#define UNO 391
353#define UEQ 392
354#define UNE 393
355#define CAST 394
356#define TRUNC 395
357#define ZEXT 396
358#define SEXT 397
359#define FPTRUNC 398
360#define FPEXT 399
361#define FPTOUI 400
362#define FPTOSI 401
363#define UITOFP 402
364#define SITOFP 403
365#define PTRTOINT 404
366#define INTTOPTR 405
367#define BITCAST 406
368
369
370
371
372/* Copy the first part of user declarations. */
Reid Spencerbaba98a2007-04-11 12:10:58 +0000373#line 14 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer319a7302007-01-05 17:20:02 +0000374
375#include "UpgradeInternals.h"
Reid Spencer950bf602007-01-26 08:19:09 +0000376#include "llvm/CallingConv.h"
377#include "llvm/InlineAsm.h"
378#include "llvm/Instructions.h"
379#include "llvm/Module.h"
Reid Spencer7b5d4662007-04-09 06:16:21 +0000380#include "llvm/ParameterAttributes.h"
Reid Spenceref9b9a72007-02-05 20:47:22 +0000381#include "llvm/ValueSymbolTable.h"
Reid Spencer950bf602007-01-26 08:19:09 +0000382#include "llvm/Support/GetElementPtrTypeIterator.h"
383#include "llvm/ADT/STLExtras.h"
384#include "llvm/Support/MathExtras.h"
Reid Spencere7c3c602006-11-30 06:36:44 +0000385#include <algorithm>
Reid Spencere7c3c602006-11-30 06:36:44 +0000386#include <iostream>
Chris Lattner8adde282007-02-11 21:40:10 +0000387#include <map>
Reid Spencer950bf602007-01-26 08:19:09 +0000388#include <list>
389#include <utility>
390
391// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
392// relating to upreferences in the input stream.
393//
394//#define DEBUG_UPREFS 1
395#ifdef DEBUG_UPREFS
396#define UR_OUT(X) std::cerr << X
397#else
398#define UR_OUT(X)
399#endif
Reid Spencere7c3c602006-11-30 06:36:44 +0000400
Reid Spencere77e35e2006-12-01 20:26:20 +0000401#define YYERROR_VERBOSE 1
Reid Spencer96839be2006-11-30 16:50:26 +0000402#define YYINCLUDED_STDLIB_H
Reid Spencere77e35e2006-12-01 20:26:20 +0000403#define YYDEBUG 1
Reid Spencere7c3c602006-11-30 06:36:44 +0000404
Reid Spencer950bf602007-01-26 08:19:09 +0000405int yylex();
Reid Spencere7c3c602006-11-30 06:36:44 +0000406int yyparse();
407
Reid Spencer950bf602007-01-26 08:19:09 +0000408int yyerror(const char*);
409static void warning(const std::string& WarningMsg);
410
411namespace llvm {
412
Reid Spencer950bf602007-01-26 08:19:09 +0000413std::istream* LexInput;
Reid Spencere7c3c602006-11-30 06:36:44 +0000414static std::string CurFilename;
Reid Spencer96839be2006-11-30 16:50:26 +0000415
Reid Spencer71d2ec92006-12-31 06:02:26 +0000416// This bool controls whether attributes are ever added to function declarations
417// definitions and calls.
418static bool AddAttributes = false;
419
Reid Spencer950bf602007-01-26 08:19:09 +0000420static Module *ParserResult;
421static bool ObsoleteVarArgs;
422static bool NewVarArgs;
423static BasicBlock *CurBB;
424static GlobalVariable *CurGV;
Reid Spencera50d5962006-12-02 04:11:07 +0000425
Reid Spencer950bf602007-01-26 08:19:09 +0000426// This contains info used when building the body of a function. It is
427// destroyed when the function is completed.
428//
429typedef std::vector<Value *> ValueList; // Numbered defs
430
Reid Spencerbb1fd572007-03-21 17:15:50 +0000431typedef std::pair<std::string,TypeInfo> RenameMapKey;
Reid Spencer950bf602007-01-26 08:19:09 +0000432typedef std::map<RenameMapKey,std::string> RenameMapType;
433
434static void
435ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
436 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
437
438static struct PerModuleInfo {
439 Module *CurrentModule;
440 std::map<const Type *, ValueList> Values; // Module level numbered definitions
441 std::map<const Type *,ValueList> LateResolveValues;
Reid Spencerbb1fd572007-03-21 17:15:50 +0000442 std::vector<PATypeHolder> Types;
443 std::vector<Signedness> TypeSigns;
444 std::map<std::string,Signedness> NamedTypeSigns;
445 std::map<std::string,Signedness> NamedValueSigns;
Reid Spencer950bf602007-01-26 08:19:09 +0000446 std::map<ValID, PATypeHolder> LateResolveTypes;
447 static Module::Endianness Endian;
448 static Module::PointerSize PointerSize;
449 RenameMapType RenameMap;
450
451 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
452 /// how they were referenced and on which line of the input they came from so
453 /// that we can resolve them later and print error messages as appropriate.
454 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
455
456 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
457 // references to global values. Global values may be referenced before they
458 // are defined, and if so, the temporary object that they represent is held
459 // here. This is used for forward references of GlobalValues.
460 //
461 typedef std::map<std::pair<const PointerType *, ValID>, GlobalValue*>
462 GlobalRefsType;
463 GlobalRefsType GlobalRefs;
464
465 void ModuleDone() {
466 // If we could not resolve some functions at function compilation time
467 // (calls to functions before they are defined), resolve them now... Types
468 // are resolved when the constant pool has been completely parsed.
469 //
470 ResolveDefinitions(LateResolveValues);
471
472 // Check to make sure that all global value forward references have been
473 // resolved!
474 //
475 if (!GlobalRefs.empty()) {
476 std::string UndefinedReferences = "Unresolved global references exist:\n";
477
478 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
479 I != E; ++I) {
480 UndefinedReferences += " " + I->first.first->getDescription() + " " +
481 I->first.second.getName() + "\n";
482 }
483 error(UndefinedReferences);
484 return;
485 }
486
487 if (CurrentModule->getDataLayout().empty()) {
488 std::string dataLayout;
489 if (Endian != Module::AnyEndianness)
490 dataLayout.append(Endian == Module::BigEndian ? "E" : "e");
491 if (PointerSize != Module::AnyPointerSize) {
492 if (!dataLayout.empty())
493 dataLayout += "-";
494 dataLayout.append(PointerSize == Module::Pointer64 ?
495 "p:64:64" : "p:32:32");
496 }
497 CurrentModule->setDataLayout(dataLayout);
498 }
499
500 Values.clear(); // Clear out function local definitions
501 Types.clear();
Reid Spencerbb1fd572007-03-21 17:15:50 +0000502 TypeSigns.clear();
503 NamedTypeSigns.clear();
504 NamedValueSigns.clear();
Reid Spencer950bf602007-01-26 08:19:09 +0000505 CurrentModule = 0;
506 }
507
508 // GetForwardRefForGlobal - Check to see if there is a forward reference
509 // for this global. If so, remove it from the GlobalRefs map and return it.
510 // If not, just return null.
511 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
512 // Check to see if there is a forward reference to this global variable...
513 // if there is, eliminate it and patch the reference to use the new def'n.
514 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
515 GlobalValue *Ret = 0;
516 if (I != GlobalRefs.end()) {
517 Ret = I->second;
518 GlobalRefs.erase(I);
519 }
520 return Ret;
521 }
522 void setEndianness(Module::Endianness E) { Endian = E; }
523 void setPointerSize(Module::PointerSize sz) { PointerSize = sz; }
524} CurModule;
525
526Module::Endianness PerModuleInfo::Endian = Module::AnyEndianness;
527Module::PointerSize PerModuleInfo::PointerSize = Module::AnyPointerSize;
528
529static struct PerFunctionInfo {
530 Function *CurrentFunction; // Pointer to current function being created
531
532 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
533 std::map<const Type*, ValueList> LateResolveValues;
534 bool isDeclare; // Is this function a forward declararation?
535 GlobalValue::LinkageTypes Linkage;// Linkage for forward declaration.
536
537 /// BBForwardRefs - When we see forward references to basic blocks, keep
538 /// track of them here.
539 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
540 std::vector<BasicBlock*> NumberedBlocks;
541 RenameMapType RenameMap;
Reid Spencer950bf602007-01-26 08:19:09 +0000542 unsigned NextBBNum;
543
544 inline PerFunctionInfo() {
545 CurrentFunction = 0;
546 isDeclare = false;
547 Linkage = GlobalValue::ExternalLinkage;
548 }
549
550 inline void FunctionStart(Function *M) {
551 CurrentFunction = M;
552 NextBBNum = 0;
553 }
554
555 void FunctionDone() {
556 NumberedBlocks.clear();
557
558 // Any forward referenced blocks left?
559 if (!BBForwardRefs.empty()) {
560 error("Undefined reference to label " +
561 BBForwardRefs.begin()->first->getName());
562 return;
563 }
564
565 // Resolve all forward references now.
566 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
567
568 Values.clear(); // Clear out function local definitions
569 RenameMap.clear();
Reid Spencer950bf602007-01-26 08:19:09 +0000570 CurrentFunction = 0;
571 isDeclare = false;
572 Linkage = GlobalValue::ExternalLinkage;
573 }
574} CurFun; // Info for the current function...
575
576static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
577
Reid Spencerbb1fd572007-03-21 17:15:50 +0000578/// This function is just a utility to make a Key value for the rename map.
579/// The Key is a combination of the name, type, Signedness of the original
580/// value (global/function). This just constructs the key and ensures that
581/// named Signedness values are resolved to the actual Signedness.
582/// @brief Make a key for the RenameMaps
583static RenameMapKey makeRenameMapKey(const std::string &Name, const Type* Ty,
584 const Signedness &Sign) {
585 TypeInfo TI;
586 TI.T = Ty;
587 if (Sign.isNamed())
588 // Don't allow Named Signedness nodes because they won't match. The actual
589 // Signedness must be looked up in the NamedTypeSigns map.
590 TI.S.copy(CurModule.NamedTypeSigns[Sign.getName()]);
591 else
592 TI.S.copy(Sign);
593 return std::make_pair(Name, TI);
594}
595
Reid Spencer950bf602007-01-26 08:19:09 +0000596
597//===----------------------------------------------------------------------===//
598// Code to handle definitions of all the types
599//===----------------------------------------------------------------------===//
600
601static int InsertValue(Value *V,
602 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
603 if (V->hasName()) return -1; // Is this a numbered definition?
604
605 // Yes, insert the value into the value table...
606 ValueList &List = ValueTab[V->getType()];
607 List.push_back(V);
608 return List.size()-1;
609}
610
Reid Spencerd7c4f8c2007-01-26 19:59:25 +0000611static const Type *getType(const ValID &D, bool DoNotImprovise = false) {
Reid Spencer950bf602007-01-26 08:19:09 +0000612 switch (D.Type) {
613 case ValID::NumberVal: // Is it a numbered definition?
614 // Module constants occupy the lowest numbered slots...
615 if ((unsigned)D.Num < CurModule.Types.size()) {
616 return CurModule.Types[(unsigned)D.Num];
617 }
618 break;
619 case ValID::NameVal: // Is it a named definition?
620 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
Reid Spencer950bf602007-01-26 08:19:09 +0000621 return N;
622 }
623 break;
624 default:
625 error("Internal parser error: Invalid symbol type reference");
626 return 0;
627 }
628
629 // If we reached here, we referenced either a symbol that we don't know about
630 // or an id number that hasn't been read yet. We may be referencing something
631 // forward, so just create an entry to be resolved later and get to it...
632 //
633 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
634
Reid Spencer950bf602007-01-26 08:19:09 +0000635 if (inFunctionScope()) {
636 if (D.Type == ValID::NameVal) {
637 error("Reference to an undefined type: '" + D.getName() + "'");
638 return 0;
639 } else {
640 error("Reference to an undefined type: #" + itostr(D.Num));
641 return 0;
642 }
643 }
644
645 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
646 if (I != CurModule.LateResolveTypes.end())
647 return I->second;
648
649 Type *Typ = OpaqueType::get();
650 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
651 return Typ;
Reid Spencerbb1fd572007-03-21 17:15:50 +0000652}
653
654/// This is like the getType method except that instead of looking up the type
655/// for a given ID, it looks up that type's sign.
656/// @brief Get the signedness of a referenced type
657static Signedness getTypeSign(const ValID &D) {
658 switch (D.Type) {
659 case ValID::NumberVal: // Is it a numbered definition?
660 // Module constants occupy the lowest numbered slots...
661 if ((unsigned)D.Num < CurModule.TypeSigns.size()) {
662 return CurModule.TypeSigns[(unsigned)D.Num];
663 }
664 break;
665 case ValID::NameVal: { // Is it a named definition?
666 std::map<std::string,Signedness>::const_iterator I =
667 CurModule.NamedTypeSigns.find(D.Name);
668 if (I != CurModule.NamedTypeSigns.end())
669 return I->second;
670 // Perhaps its a named forward .. just cache the name
671 Signedness S;
672 S.makeNamed(D.Name);
673 return S;
674 }
675 default:
676 break;
677 }
678 // If we don't find it, its signless
679 Signedness S;
680 S.makeSignless();
681 return S;
682}
683
684/// This function is analagous to getElementType in LLVM. It provides the same
685/// function except that it looks up the Signedness instead of the type. This is
686/// used when processing GEP instructions that need to extract the type of an
687/// indexed struct/array/ptr member.
688/// @brief Look up an element's sign.
689static Signedness getElementSign(const ValueInfo& VI,
690 const std::vector<Value*> &Indices) {
691 const Type *Ptr = VI.V->getType();
692 assert(isa<PointerType>(Ptr) && "Need pointer type");
693
694 unsigned CurIdx = 0;
695 Signedness S(VI.S);
696 while (const CompositeType *CT = dyn_cast<CompositeType>(Ptr)) {
697 if (CurIdx == Indices.size())
698 break;
699
700 Value *Index = Indices[CurIdx++];
701 assert(!isa<PointerType>(CT) || CurIdx == 1 && "Invalid type");
702 Ptr = CT->getTypeAtIndex(Index);
703 if (const Type* Ty = Ptr->getForwardedType())
704 Ptr = Ty;
705 assert(S.isComposite() && "Bad Signedness type");
706 if (isa<StructType>(CT)) {
707 S = S.get(cast<ConstantInt>(Index)->getZExtValue());
708 } else {
709 S = S.get(0UL);
710 }
711 if (S.isNamed())
712 S = CurModule.NamedTypeSigns[S.getName()];
713 }
714 Signedness Result;
715 Result.makeComposite(S);
716 return Result;
717}
718
719/// This function just translates a ConstantInfo into a ValueInfo and calls
720/// getElementSign(ValueInfo,...). Its just a convenience.
721/// @brief ConstantInfo version of getElementSign.
722static Signedness getElementSign(const ConstInfo& CI,
723 const std::vector<Constant*> &Indices) {
724 ValueInfo VI;
725 VI.V = CI.C;
726 VI.S.copy(CI.S);
727 std::vector<Value*> Idx;
728 for (unsigned i = 0; i < Indices.size(); ++i)
729 Idx.push_back(Indices[i]);
730 Signedness result = getElementSign(VI, Idx);
731 VI.destroy();
732 return result;
733}
Reid Spencer950bf602007-01-26 08:19:09 +0000734
Reid Spencered96d1e2007-02-08 09:08:52 +0000735/// This function determines if two function types differ only in their use of
736/// the sret parameter attribute in the first argument. If they are identical
737/// in all other respects, it returns true. Otherwise, it returns false.
Reid Spencerbb1fd572007-03-21 17:15:50 +0000738static bool FuncTysDifferOnlyBySRet(const FunctionType *F1,
739 const FunctionType *F2) {
Reid Spencered96d1e2007-02-08 09:08:52 +0000740 if (F1->getReturnType() != F2->getReturnType() ||
Reid Spencer7b5d4662007-04-09 06:16:21 +0000741 F1->getNumParams() != F2->getNumParams())
Reid Spencered96d1e2007-02-08 09:08:52 +0000742 return false;
Reid Spencer7b5d4662007-04-09 06:16:21 +0000743 ParamAttrsList PAL1;
744 if (F1->getParamAttrs())
745 PAL1 = *F1->getParamAttrs();
746 ParamAttrsList PAL2;
747 if (F2->getParamAttrs())
748 PAL2 = *F2->getParamAttrs();
749 if (PAL1.getParamAttrs(0) != PAL2.getParamAttrs(0))
750 return false;
Reid Spencer18da0722007-04-11 02:44:20 +0000751 unsigned SRetMask = ~unsigned(ParamAttr::StructRet);
Reid Spencered96d1e2007-02-08 09:08:52 +0000752 for (unsigned i = 0; i < F1->getNumParams(); ++i) {
753 if (F1->getParamType(i) != F2->getParamType(i) ||
Reid Spencer7b5d4662007-04-09 06:16:21 +0000754 unsigned(PAL1.getParamAttrs(i+1)) & SRetMask !=
755 unsigned(PAL2.getParamAttrs(i+1)) & SRetMask)
Reid Spencered96d1e2007-02-08 09:08:52 +0000756 return false;
757 }
758 return true;
759}
760
Reid Spencerbb1fd572007-03-21 17:15:50 +0000761/// This function determines if the type of V and Ty differ only by the SRet
762/// parameter attribute. This is a more generalized case of
763/// FuncTysDIfferOnlyBySRet since it doesn't require FunctionType arguments.
764static bool TypesDifferOnlyBySRet(Value *V, const Type* Ty) {
765 if (V->getType() == Ty)
766 return true;
767 const PointerType *PF1 = dyn_cast<PointerType>(Ty);
768 const PointerType *PF2 = dyn_cast<PointerType>(V->getType());
769 if (PF1 && PF2) {
770 const FunctionType* FT1 = dyn_cast<FunctionType>(PF1->getElementType());
771 const FunctionType* FT2 = dyn_cast<FunctionType>(PF2->getElementType());
772 if (FT1 && FT2)
773 return FuncTysDifferOnlyBySRet(FT1, FT2);
774 }
775 return false;
776}
777
Reid Spencered96d1e2007-02-08 09:08:52 +0000778// The upgrade of csretcc to sret param attribute may have caused a function
779// to not be found because the param attribute changed the type of the called
780// function. This helper function, used in getExistingValue, detects that
Reid Spencerbb1fd572007-03-21 17:15:50 +0000781// situation and bitcasts the function to the correct type.
Reid Spencered96d1e2007-02-08 09:08:52 +0000782static Value* handleSRetFuncTypeMerge(Value *V, const Type* Ty) {
783 // Handle degenerate cases
784 if (!V)
785 return 0;
786 if (V->getType() == Ty)
787 return V;
788
Reid Spencered96d1e2007-02-08 09:08:52 +0000789 const PointerType *PF1 = dyn_cast<PointerType>(Ty);
790 const PointerType *PF2 = dyn_cast<PointerType>(V->getType());
791 if (PF1 && PF2) {
Reid Spencerbb1fd572007-03-21 17:15:50 +0000792 const FunctionType *FT1 = dyn_cast<FunctionType>(PF1->getElementType());
793 const FunctionType *FT2 = dyn_cast<FunctionType>(PF2->getElementType());
Reid Spencer7b5d4662007-04-09 06:16:21 +0000794 if (FT1 && FT2 && FuncTysDifferOnlyBySRet(FT1, FT2)) {
795 const ParamAttrsList *PAL2 = FT2->getParamAttrs();
Reid Spencer18da0722007-04-11 02:44:20 +0000796 if (PAL2 && PAL2->paramHasAttr(1, ParamAttr::StructRet))
Reid Spencerbb1fd572007-03-21 17:15:50 +0000797 return V;
Reid Spencered96d1e2007-02-08 09:08:52 +0000798 else if (Constant *C = dyn_cast<Constant>(V))
Reid Spencerbb1fd572007-03-21 17:15:50 +0000799 return ConstantExpr::getBitCast(C, PF1);
Reid Spencered96d1e2007-02-08 09:08:52 +0000800 else
Reid Spencerbb1fd572007-03-21 17:15:50 +0000801 return new BitCastInst(V, PF1, "upgrd.cast", CurBB);
Reid Spencer7b5d4662007-04-09 06:16:21 +0000802 }
Reid Spencerbb1fd572007-03-21 17:15:50 +0000803
Reid Spencered96d1e2007-02-08 09:08:52 +0000804 }
Reid Spencerbb1fd572007-03-21 17:15:50 +0000805 return 0;
Reid Spencered96d1e2007-02-08 09:08:52 +0000806}
807
Reid Spencer950bf602007-01-26 08:19:09 +0000808// getExistingValue - Look up the value specified by the provided type and
809// the provided ValID. If the value exists and has already been defined, return
810// it. Otherwise return null.
811//
812static Value *getExistingValue(const Type *Ty, const ValID &D) {
813 if (isa<FunctionType>(Ty)) {
814 error("Functions are not values and must be referenced as pointers");
815 }
816
817 switch (D.Type) {
818 case ValID::NumberVal: { // Is it a numbered definition?
819 unsigned Num = (unsigned)D.Num;
820
821 // Module constants occupy the lowest numbered slots...
822 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
823 if (VI != CurModule.Values.end()) {
824 if (Num < VI->second.size())
825 return VI->second[Num];
826 Num -= VI->second.size();
827 }
828
829 // Make sure that our type is within bounds
830 VI = CurFun.Values.find(Ty);
831 if (VI == CurFun.Values.end()) return 0;
832
833 // Check that the number is within bounds...
834 if (VI->second.size() <= Num) return 0;
835
836 return VI->second[Num];
837 }
838
839 case ValID::NameVal: { // Is it a named definition?
840 // Get the name out of the ID
Reid Spencerbb1fd572007-03-21 17:15:50 +0000841 RenameMapKey Key = makeRenameMapKey(D.Name, Ty, D.S);
842 Value *V = 0;
Reid Spencer950bf602007-01-26 08:19:09 +0000843 if (inFunctionScope()) {
844 // See if the name was renamed
845 RenameMapType::const_iterator I = CurFun.RenameMap.find(Key);
846 std::string LookupName;
847 if (I != CurFun.RenameMap.end())
848 LookupName = I->second;
849 else
Reid Spencerbb1fd572007-03-21 17:15:50 +0000850 LookupName = D.Name;
Reid Spenceref9b9a72007-02-05 20:47:22 +0000851 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
852 V = SymTab.lookup(LookupName);
Reid Spencerbb1fd572007-03-21 17:15:50 +0000853 if (V && V->getType() != Ty)
854 V = handleSRetFuncTypeMerge(V, Ty);
855 assert((!V || TypesDifferOnlyBySRet(V, Ty)) && "Found wrong type");
Reid Spencer950bf602007-01-26 08:19:09 +0000856 }
857 if (!V) {
858 RenameMapType::const_iterator I = CurModule.RenameMap.find(Key);
859 std::string LookupName;
860 if (I != CurModule.RenameMap.end())
861 LookupName = I->second;
862 else
Reid Spencerbb1fd572007-03-21 17:15:50 +0000863 LookupName = D.Name;
Reid Spenceref9b9a72007-02-05 20:47:22 +0000864 V = CurModule.CurrentModule->getValueSymbolTable().lookup(LookupName);
Reid Spencerbb1fd572007-03-21 17:15:50 +0000865 if (V && V->getType() != Ty)
866 V = handleSRetFuncTypeMerge(V, Ty);
867 assert((!V || TypesDifferOnlyBySRet(V, Ty)) && "Found wrong type");
Reid Spencer950bf602007-01-26 08:19:09 +0000868 }
Reid Spenceref9b9a72007-02-05 20:47:22 +0000869 if (!V)
Reid Spencer950bf602007-01-26 08:19:09 +0000870 return 0;
871
872 D.destroy(); // Free old strdup'd memory...
873 return V;
874 }
875
876 // Check to make sure that "Ty" is an integral type, and that our
877 // value will fit into the specified type...
878 case ValID::ConstSIntVal: // Is it a constant pool reference??
879 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
880 error("Signed integral constant '" + itostr(D.ConstPool64) +
881 "' is invalid for type '" + Ty->getDescription() + "'");
882 }
883 return ConstantInt::get(Ty, D.ConstPool64);
884
885 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
886 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
887 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64))
888 error("Integral constant '" + utostr(D.UConstPool64) +
889 "' is invalid or out of range");
890 else // This is really a signed reference. Transmogrify.
891 return ConstantInt::get(Ty, D.ConstPool64);
892 } else
893 return ConstantInt::get(Ty, D.UConstPool64);
894
895 case ValID::ConstFPVal: // Is it a floating point const pool reference?
896 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
897 error("FP constant invalid for type");
898 return ConstantFP::get(Ty, D.ConstPoolFP);
899
900 case ValID::ConstNullVal: // Is it a null value?
901 if (!isa<PointerType>(Ty))
902 error("Cannot create a a non pointer null");
903 return ConstantPointerNull::get(cast<PointerType>(Ty));
904
905 case ValID::ConstUndefVal: // Is it an undef value?
906 return UndefValue::get(Ty);
907
908 case ValID::ConstZeroVal: // Is it a zero value?
909 return Constant::getNullValue(Ty);
910
911 case ValID::ConstantVal: // Fully resolved constant?
912 if (D.ConstantValue->getType() != Ty)
913 error("Constant expression type different from required type");
914 return D.ConstantValue;
915
916 case ValID::InlineAsmVal: { // Inline asm expression
917 const PointerType *PTy = dyn_cast<PointerType>(Ty);
918 const FunctionType *FTy =
919 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
920 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints))
921 error("Invalid type for asm constraint string");
922 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
923 D.IAD->HasSideEffects);
924 D.destroy(); // Free InlineAsmDescriptor.
925 return IA;
926 }
927 default:
928 assert(0 && "Unhandled case");
929 return 0;
930 } // End of switch
931
932 assert(0 && "Unhandled case");
933 return 0;
934}
935
936// getVal - This function is identical to getExistingValue, except that if a
937// value is not already defined, it "improvises" by creating a placeholder var
938// that looks and acts just like the requested variable. When the value is
939// defined later, all uses of the placeholder variable are replaced with the
940// real thing.
941//
942static Value *getVal(const Type *Ty, const ValID &ID) {
943 if (Ty == Type::LabelTy)
944 error("Cannot use a basic block here");
945
946 // See if the value has already been defined.
947 Value *V = getExistingValue(Ty, ID);
948 if (V) return V;
949
950 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
951 error("Invalid use of a composite type");
952
953 // If we reached here, we referenced either a symbol that we don't know about
954 // or an id number that hasn't been read yet. We may be referencing something
955 // forward, so just create an entry to be resolved later and get to it...
Reid Spencer950bf602007-01-26 08:19:09 +0000956 V = new Argument(Ty);
957
958 // Remember where this forward reference came from. FIXME, shouldn't we try
959 // to recycle these things??
960 CurModule.PlaceHolderInfo.insert(
Reid Spenceref9b9a72007-02-05 20:47:22 +0000961 std::make_pair(V, std::make_pair(ID, Upgradelineno)));
Reid Spencer950bf602007-01-26 08:19:09 +0000962
963 if (inFunctionScope())
964 InsertValue(V, CurFun.LateResolveValues);
965 else
966 InsertValue(V, CurModule.LateResolveValues);
967 return V;
968}
969
Reid Spencered96d1e2007-02-08 09:08:52 +0000970/// @brief This just makes any name given to it unique, up to MAX_UINT times.
971static std::string makeNameUnique(const std::string& Name) {
972 static unsigned UniqueNameCounter = 1;
973 std::string Result(Name);
974 Result += ".upgrd." + llvm::utostr(UniqueNameCounter++);
975 return Result;
976}
977
Reid Spencer950bf602007-01-26 08:19:09 +0000978/// getBBVal - This is used for two purposes:
979/// * If isDefinition is true, a new basic block with the specified ID is being
980/// defined.
981/// * If isDefinition is true, this is a reference to a basic block, which may
982/// or may not be a forward reference.
983///
984static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
985 assert(inFunctionScope() && "Can't get basic block at global scope");
986
987 std::string Name;
988 BasicBlock *BB = 0;
989 switch (ID.Type) {
990 default:
991 error("Illegal label reference " + ID.getName());
992 break;
993 case ValID::NumberVal: // Is it a numbered definition?
994 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
995 CurFun.NumberedBlocks.resize(ID.Num+1);
996 BB = CurFun.NumberedBlocks[ID.Num];
997 break;
998 case ValID::NameVal: // Is it a named definition?
999 Name = ID.Name;
Reid Spencerbb1fd572007-03-21 17:15:50 +00001000 if (Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name)) {
Reid Spencered96d1e2007-02-08 09:08:52 +00001001 if (N->getType() != Type::LabelTy) {
1002 // Register names didn't use to conflict with basic block names
1003 // because of type planes. Now they all have to be unique. So, we just
1004 // rename the register and treat this name as if no basic block
1005 // had been found.
Reid Spencerbb1fd572007-03-21 17:15:50 +00001006 RenameMapKey Key = makeRenameMapKey(ID.Name, N->getType(), ID.S);
Reid Spencered96d1e2007-02-08 09:08:52 +00001007 N->setName(makeNameUnique(N->getName()));
1008 CurModule.RenameMap[Key] = N->getName();
1009 BB = 0;
1010 } else {
1011 BB = cast<BasicBlock>(N);
1012 }
Reid Spencer950bf602007-01-26 08:19:09 +00001013 }
1014 break;
1015 }
1016
1017 // See if the block has already been defined.
1018 if (BB) {
1019 // If this is the definition of the block, make sure the existing value was
1020 // just a forward reference. If it was a forward reference, there will be
1021 // an entry for it in the PlaceHolderInfo map.
1022 if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
1023 // The existing value was a definition, not a forward reference.
1024 error("Redefinition of label " + ID.getName());
1025
1026 ID.destroy(); // Free strdup'd memory.
1027 return BB;
1028 }
1029
1030 // Otherwise this block has not been seen before.
1031 BB = new BasicBlock("", CurFun.CurrentFunction);
1032 if (ID.Type == ValID::NameVal) {
1033 BB->setName(ID.Name);
1034 } else {
1035 CurFun.NumberedBlocks[ID.Num] = BB;
1036 }
1037
1038 // If this is not a definition, keep track of it so we can use it as a forward
1039 // reference.
1040 if (!isDefinition) {
1041 // Remember where this forward reference came from.
1042 CurFun.BBForwardRefs[BB] = std::make_pair(ID, Upgradelineno);
1043 } else {
1044 // The forward declaration could have been inserted anywhere in the
1045 // function: insert it into the correct place now.
1046 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
1047 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
1048 }
1049 ID.destroy();
1050 return BB;
1051}
1052
1053
1054//===----------------------------------------------------------------------===//
1055// Code to handle forward references in instructions
1056//===----------------------------------------------------------------------===//
1057//
1058// This code handles the late binding needed with statements that reference
1059// values not defined yet... for example, a forward branch, or the PHI node for
1060// a loop body.
1061//
1062// This keeps a table (CurFun.LateResolveValues) of all such forward references
1063// and back patchs after we are done.
1064//
1065
1066// ResolveDefinitions - If we could not resolve some defs at parsing
1067// time (forward branches, phi functions for loops, etc...) resolve the
1068// defs now...
1069//
1070static void
1071ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
1072 std::map<const Type*,ValueList> *FutureLateResolvers) {
Reid Spencered96d1e2007-02-08 09:08:52 +00001073
Reid Spencer950bf602007-01-26 08:19:09 +00001074 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
1075 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
1076 E = LateResolvers.end(); LRI != E; ++LRI) {
Reid Spencered96d1e2007-02-08 09:08:52 +00001077 const Type* Ty = LRI->first;
Reid Spencer950bf602007-01-26 08:19:09 +00001078 ValueList &List = LRI->second;
1079 while (!List.empty()) {
1080 Value *V = List.back();
1081 List.pop_back();
1082
1083 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
1084 CurModule.PlaceHolderInfo.find(V);
1085 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error");
1086
1087 ValID &DID = PHI->second.first;
1088
Reid Spencered96d1e2007-02-08 09:08:52 +00001089 Value *TheRealValue = getExistingValue(Ty, DID);
Reid Spencer950bf602007-01-26 08:19:09 +00001090 if (TheRealValue) {
1091 V->replaceAllUsesWith(TheRealValue);
1092 delete V;
1093 CurModule.PlaceHolderInfo.erase(PHI);
1094 } else if (FutureLateResolvers) {
1095 // Functions have their unresolved items forwarded to the module late
1096 // resolver table
1097 InsertValue(V, *FutureLateResolvers);
1098 } else {
1099 if (DID.Type == ValID::NameVal) {
Reid Spencered96d1e2007-02-08 09:08:52 +00001100 error("Reference to an invalid definition: '" + DID.getName() +
1101 "' of type '" + V->getType()->getDescription() + "'",
1102 PHI->second.second);
Reid Spencer7de2e012007-01-29 19:08:46 +00001103 return;
Reid Spencer950bf602007-01-26 08:19:09 +00001104 } else {
1105 error("Reference to an invalid definition: #" +
1106 itostr(DID.Num) + " of type '" +
1107 V->getType()->getDescription() + "'", PHI->second.second);
1108 return;
1109 }
1110 }
1111 }
1112 }
1113
1114 LateResolvers.clear();
1115}
1116
Reid Spencerbb1fd572007-03-21 17:15:50 +00001117/// This function is used for type resolution and upref handling. When a type
1118/// becomes concrete, this function is called to adjust the signedness for the
1119/// concrete type.
1120static void ResolveTypeSign(const Type* oldTy, const Signedness &Sign) {
1121 std::string TyName = CurModule.CurrentModule->getTypeName(oldTy);
1122 if (!TyName.empty())
1123 CurModule.NamedTypeSigns[TyName] = Sign;
1124}
1125
1126/// ResolveTypeTo - A brand new type was just declared. This means that (if
1127/// name is not null) things referencing Name can be resolved. Otherwise,
1128/// things refering to the number can be resolved. Do this now.
1129static void ResolveTypeTo(char *Name, const Type *ToTy, const Signedness& Sign){
Reid Spencer950bf602007-01-26 08:19:09 +00001130 ValID D;
Reid Spencerbb1fd572007-03-21 17:15:50 +00001131 if (Name)
1132 D = ValID::create(Name);
1133 else
1134 D = ValID::create((int)CurModule.Types.size());
1135 D.S.copy(Sign);
1136
Reid Spencerbaba98a2007-04-11 12:10:58 +00001137 if (Name)
1138 CurModule.NamedTypeSigns[Name] = Sign;
Reid Spencer950bf602007-01-26 08:19:09 +00001139
1140 std::map<ValID, PATypeHolder>::iterator I =
1141 CurModule.LateResolveTypes.find(D);
1142 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencerbb1fd572007-03-21 17:15:50 +00001143 const Type *OldTy = I->second.get();
1144 ((DerivedType*)OldTy)->refineAbstractTypeTo(ToTy);
Reid Spencer950bf602007-01-26 08:19:09 +00001145 CurModule.LateResolveTypes.erase(I);
1146 }
1147}
1148
Anton Korobeynikovce13b852007-01-28 15:25:24 +00001149/// This is the implementation portion of TypeHasInteger. It traverses the
1150/// type given, avoiding recursive types, and returns true as soon as it finds
1151/// an integer type. If no integer type is found, it returns false.
1152static bool TypeHasIntegerI(const Type *Ty, std::vector<const Type*> Stack) {
1153 // Handle some easy cases
1154 if (Ty->isPrimitiveType() || (Ty->getTypeID() == Type::OpaqueTyID))
1155 return false;
1156 if (Ty->isInteger())
1157 return true;
1158 if (const SequentialType *STy = dyn_cast<SequentialType>(Ty))
1159 return STy->getElementType()->isInteger();
1160
1161 // Avoid type structure recursion
1162 for (std::vector<const Type*>::iterator I = Stack.begin(), E = Stack.end();
1163 I != E; ++I)
1164 if (Ty == *I)
1165 return false;
1166
1167 // Push us on the type stack
1168 Stack.push_back(Ty);
1169
1170 if (const FunctionType *FTy = dyn_cast<FunctionType>(Ty)) {
1171 if (TypeHasIntegerI(FTy->getReturnType(), Stack))
1172 return true;
1173 FunctionType::param_iterator I = FTy->param_begin();
1174 FunctionType::param_iterator E = FTy->param_end();
1175 for (; I != E; ++I)
1176 if (TypeHasIntegerI(*I, Stack))
1177 return true;
1178 return false;
1179 } else if (const StructType *STy = dyn_cast<StructType>(Ty)) {
1180 StructType::element_iterator I = STy->element_begin();
1181 StructType::element_iterator E = STy->element_end();
1182 for (; I != E; ++I) {
1183 if (TypeHasIntegerI(*I, Stack))
1184 return true;
1185 }
1186 return false;
1187 }
1188 // There shouldn't be anything else, but its definitely not integer
1189 assert(0 && "What type is this?");
1190 return false;
1191}
1192
1193/// This is the interface to TypeHasIntegerI. It just provides the type stack,
1194/// to avoid recursion, and then calls TypeHasIntegerI.
1195static inline bool TypeHasInteger(const Type *Ty) {
1196 std::vector<const Type*> TyStack;
1197 return TypeHasIntegerI(Ty, TyStack);
1198}
1199
Reid Spencer950bf602007-01-26 08:19:09 +00001200// setValueName - Set the specified value to the name given. The name may be
1201// null potentially, in which case this is a noop. The string passed in is
1202// assumed to be a malloc'd string buffer, and is free'd by this function.
1203//
Reid Spencerbb1fd572007-03-21 17:15:50 +00001204static void setValueName(const ValueInfo &V, char *NameStr) {
Reid Spencer950bf602007-01-26 08:19:09 +00001205 if (NameStr) {
1206 std::string Name(NameStr); // Copy string
1207 free(NameStr); // Free old string
1208
Reid Spencerbb1fd572007-03-21 17:15:50 +00001209 if (V.V->getType() == Type::VoidTy) {
Reid Spencer950bf602007-01-26 08:19:09 +00001210 error("Can't assign name '" + Name + "' to value with void type");
1211 return;
1212 }
1213
Reid Spencer950bf602007-01-26 08:19:09 +00001214 assert(inFunctionScope() && "Must be in function scope");
1215
1216 // Search the function's symbol table for an existing value of this name
Reid Spenceref9b9a72007-02-05 20:47:22 +00001217 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1218 Value* Existing = ST.lookup(Name);
Reid Spencer950bf602007-01-26 08:19:09 +00001219 if (Existing) {
Anton Korobeynikovce13b852007-01-28 15:25:24 +00001220 // An existing value of the same name was found. This might have happened
1221 // because of the integer type planes collapsing in LLVM 2.0.
Reid Spencerbb1fd572007-03-21 17:15:50 +00001222 if (Existing->getType() == V.V->getType() &&
Anton Korobeynikovce13b852007-01-28 15:25:24 +00001223 !TypeHasInteger(Existing->getType())) {
1224 // If the type does not contain any integers in them then this can't be
1225 // a type plane collapsing issue. It truly is a redefinition and we
1226 // should error out as the assembly is invalid.
1227 error("Redefinition of value named '" + Name + "' of type '" +
Reid Spencerbb1fd572007-03-21 17:15:50 +00001228 V.V->getType()->getDescription() + "'");
Anton Korobeynikovce13b852007-01-28 15:25:24 +00001229 return;
Reid Spencer950bf602007-01-26 08:19:09 +00001230 }
1231 // In LLVM 2.0 we don't allow names to be re-used for any values in a
1232 // function, regardless of Type. Previously re-use of names was okay as
1233 // long as they were distinct types. With type planes collapsing because
1234 // of the signedness change and because of PR411, this can no longer be
1235 // supported. We must search the entire symbol table for a conflicting
1236 // name and make the name unique. No warning is needed as this can't
1237 // cause a problem.
1238 std::string NewName = makeNameUnique(Name);
1239 // We're changing the name but it will probably be used by other
1240 // instructions as operands later on. Consequently we have to retain
1241 // a mapping of the renaming that we're doing.
Reid Spencerbb1fd572007-03-21 17:15:50 +00001242 RenameMapKey Key = makeRenameMapKey(Name, V.V->getType(), V.S);
Reid Spencer950bf602007-01-26 08:19:09 +00001243 CurFun.RenameMap[Key] = NewName;
1244 Name = NewName;
1245 }
1246
1247 // Set the name.
Reid Spencerbb1fd572007-03-21 17:15:50 +00001248 V.V->setName(Name);
Reid Spencer950bf602007-01-26 08:19:09 +00001249 }
1250}
1251
1252/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1253/// this is a declaration, otherwise it is a definition.
1254static GlobalVariable *
1255ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
1256 bool isConstantGlobal, const Type *Ty,
Reid Spencerbb1fd572007-03-21 17:15:50 +00001257 Constant *Initializer,
1258 const Signedness &Sign) {
Reid Spencer950bf602007-01-26 08:19:09 +00001259 if (isa<FunctionType>(Ty))
1260 error("Cannot declare global vars of function type");
1261
1262 const PointerType *PTy = PointerType::get(Ty);
1263
1264 std::string Name;
1265 if (NameStr) {
1266 Name = NameStr; // Copy string
1267 free(NameStr); // Free old string
1268 }
1269
1270 // See if this global value was forward referenced. If so, recycle the
1271 // object.
1272 ValID ID;
1273 if (!Name.empty()) {
Reid Spencer5eb77c72007-03-15 03:26:42 +00001274 ID = ValID::create((char*)Name.c_str());
Reid Spencer950bf602007-01-26 08:19:09 +00001275 } else {
Reid Spencer5eb77c72007-03-15 03:26:42 +00001276 ID = ValID::create((int)CurModule.Values[PTy].size());
Reid Spencer950bf602007-01-26 08:19:09 +00001277 }
Reid Spencerbb1fd572007-03-21 17:15:50 +00001278 ID.S.makeComposite(Sign);
Reid Spencer950bf602007-01-26 08:19:09 +00001279
1280 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1281 // Move the global to the end of the list, from whereever it was
1282 // previously inserted.
1283 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1284 CurModule.CurrentModule->getGlobalList().remove(GV);
1285 CurModule.CurrentModule->getGlobalList().push_back(GV);
1286 GV->setInitializer(Initializer);
1287 GV->setLinkage(Linkage);
1288 GV->setConstant(isConstantGlobal);
1289 InsertValue(GV, CurModule.Values);
1290 return GV;
1291 }
1292
1293 // If this global has a name, check to see if there is already a definition
1294 // of this global in the module and emit warnings if there are conflicts.
1295 if (!Name.empty()) {
1296 // The global has a name. See if there's an existing one of the same name.
1297 if (CurModule.CurrentModule->getNamedGlobal(Name)) {
1298 // We found an existing global ov the same name. This isn't allowed
1299 // in LLVM 2.0. Consequently, we must alter the name of the global so it
1300 // can at least compile. This can happen because of type planes
1301 // There is alread a global of the same name which means there is a
1302 // conflict. Let's see what we can do about it.
1303 std::string NewName(makeNameUnique(Name));
Reid Spencerbb1fd572007-03-21 17:15:50 +00001304 if (Linkage != GlobalValue::InternalLinkage) {
Reid Spencer950bf602007-01-26 08:19:09 +00001305 // The linkage of this gval is external so we can't reliably rename
1306 // it because it could potentially create a linking problem.
1307 // However, we can't leave the name conflict in the output either or
1308 // it won't assemble with LLVM 2.0. So, all we can do is rename
1309 // this one to something unique and emit a warning about the problem.
1310 warning("Renaming global variable '" + Name + "' to '" + NewName +
1311 "' may cause linkage errors");
1312 }
1313
1314 // Put the renaming in the global rename map
Reid Spencerbb1fd572007-03-21 17:15:50 +00001315 RenameMapKey Key = makeRenameMapKey(Name, PointerType::get(Ty), ID.S);
Reid Spencer950bf602007-01-26 08:19:09 +00001316 CurModule.RenameMap[Key] = NewName;
1317
1318 // Rename it
1319 Name = NewName;
1320 }
1321 }
1322
1323 // Otherwise there is no existing GV to use, create one now.
1324 GlobalVariable *GV =
1325 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
1326 CurModule.CurrentModule);
1327 InsertValue(GV, CurModule.Values);
Reid Spencerbb1fd572007-03-21 17:15:50 +00001328 // Remember the sign of this global.
1329 CurModule.NamedValueSigns[Name] = ID.S;
Reid Spencer950bf602007-01-26 08:19:09 +00001330 return GV;
1331}
1332
1333// setTypeName - Set the specified type to the name given. The name may be
1334// null potentially, in which case this is a noop. The string passed in is
1335// assumed to be a malloc'd string buffer, and is freed by this function.
1336//
1337// This function returns true if the type has already been defined, but is
1338// allowed to be redefined in the specified context. If the name is a new name
1339// for the type plane, it is inserted and false is returned.
Reid Spencerbb1fd572007-03-21 17:15:50 +00001340static bool setTypeName(const PATypeInfo& TI, char *NameStr) {
Reid Spencer950bf602007-01-26 08:19:09 +00001341 assert(!inFunctionScope() && "Can't give types function-local names");
1342 if (NameStr == 0) return false;
1343
1344 std::string Name(NameStr); // Copy string
1345 free(NameStr); // Free old string
1346
Reid Spencerbb1fd572007-03-21 17:15:50 +00001347 const Type* Ty = TI.PAT->get();
1348
Reid Spencer950bf602007-01-26 08:19:09 +00001349 // We don't allow assigning names to void type
Reid Spencerbb1fd572007-03-21 17:15:50 +00001350 if (Ty == Type::VoidTy) {
Reid Spencer950bf602007-01-26 08:19:09 +00001351 error("Can't assign name '" + Name + "' to the void type");
1352 return false;
1353 }
1354
1355 // Set the type name, checking for conflicts as we do so.
Reid Spencerbb1fd572007-03-21 17:15:50 +00001356 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, Ty);
1357
1358 // Save the sign information for later use
1359 CurModule.NamedTypeSigns[Name] = TI.S;
Reid Spencer950bf602007-01-26 08:19:09 +00001360
1361 if (AlreadyExists) { // Inserting a name that is already defined???
1362 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
1363 assert(Existing && "Conflict but no matching type?");
1364
1365 // There is only one case where this is allowed: when we are refining an
1366 // opaque type. In this case, Existing will be an opaque type.
1367 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1368 // We ARE replacing an opaque type!
Reid Spencerbb1fd572007-03-21 17:15:50 +00001369 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(Ty);
Reid Spencer950bf602007-01-26 08:19:09 +00001370 return true;
1371 }
1372
1373 // Otherwise, this is an attempt to redefine a type. That's okay if
1374 // the redefinition is identical to the original. This will be so if
1375 // Existing and T point to the same Type object. In this one case we
1376 // allow the equivalent redefinition.
Reid Spencerbb1fd572007-03-21 17:15:50 +00001377 if (Existing == Ty) return true; // Yes, it's equal.
Reid Spencer950bf602007-01-26 08:19:09 +00001378
1379 // Any other kind of (non-equivalent) redefinition is an error.
1380 error("Redefinition of type named '" + Name + "' in the '" +
Reid Spencerbb1fd572007-03-21 17:15:50 +00001381 Ty->getDescription() + "' type plane");
Reid Spencer950bf602007-01-26 08:19:09 +00001382 }
1383
1384 return false;
1385}
1386
1387//===----------------------------------------------------------------------===//
1388// Code for handling upreferences in type names...
1389//
1390
1391// TypeContains - Returns true if Ty directly contains E in it.
1392//
1393static bool TypeContains(const Type *Ty, const Type *E) {
1394 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1395 E) != Ty->subtype_end();
1396}
1397
1398namespace {
1399 struct UpRefRecord {
1400 // NestingLevel - The number of nesting levels that need to be popped before
1401 // this type is resolved.
1402 unsigned NestingLevel;
1403
1404 // LastContainedTy - This is the type at the current binding level for the
1405 // type. Every time we reduce the nesting level, this gets updated.
1406 const Type *LastContainedTy;
1407
1408 // UpRefTy - This is the actual opaque type that the upreference is
1409 // represented with.
1410 OpaqueType *UpRefTy;
1411
1412 UpRefRecord(unsigned NL, OpaqueType *URTy)
Reid Spencerbb1fd572007-03-21 17:15:50 +00001413 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) { }
Reid Spencer950bf602007-01-26 08:19:09 +00001414 };
1415}
1416
1417// UpRefs - A list of the outstanding upreferences that need to be resolved.
1418static std::vector<UpRefRecord> UpRefs;
1419
1420/// HandleUpRefs - Every time we finish a new layer of types, this function is
1421/// called. It loops through the UpRefs vector, which is a list of the
1422/// currently active types. For each type, if the up reference is contained in
1423/// the newly completed type, we decrement the level count. When the level
1424/// count reaches zero, the upreferenced type is the type that is passed in:
1425/// thus we can complete the cycle.
1426///
Reid Spencerbb1fd572007-03-21 17:15:50 +00001427static PATypeHolder HandleUpRefs(const Type *ty, const Signedness& Sign) {
Reid Spencer950bf602007-01-26 08:19:09 +00001428 // If Ty isn't abstract, or if there are no up-references in it, then there is
1429 // nothing to resolve here.
1430 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1431
1432 PATypeHolder Ty(ty);
1433 UR_OUT("Type '" << Ty->getDescription() <<
1434 "' newly formed. Resolving upreferences.\n" <<
1435 UpRefs.size() << " upreferences active!\n");
1436
1437 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1438 // to zero), we resolve them all together before we resolve them to Ty. At
1439 // the end of the loop, if there is anything to resolve to Ty, it will be in
1440 // this variable.
1441 OpaqueType *TypeToResolve = 0;
1442
Reid Spencerbb1fd572007-03-21 17:15:50 +00001443 unsigned i = 0;
1444 for (; i != UpRefs.size(); ++i) {
Reid Spencer950bf602007-01-26 08:19:09 +00001445 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
Reid Spencerbb1fd572007-03-21 17:15:50 +00001446 << UpRefs[i].UpRefTy->getDescription() << ") = "
1447 << (TypeContains(Ty, UpRefs[i].UpRefTy) ? "true" : "false") << "\n");
Reid Spencer950bf602007-01-26 08:19:09 +00001448 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1449 // Decrement level of upreference
1450 unsigned Level = --UpRefs[i].NestingLevel;
1451 UpRefs[i].LastContainedTy = Ty;
1452 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1453 if (Level == 0) { // Upreference should be resolved!
1454 if (!TypeToResolve) {
1455 TypeToResolve = UpRefs[i].UpRefTy;
1456 } else {
1457 UR_OUT(" * Resolving upreference for "
Reid Spencerbb1fd572007-03-21 17:15:50 +00001458 << UpRefs[i].UpRefTy->getDescription() << "\n";
1459 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1460 ResolveTypeSign(UpRefs[i].UpRefTy, Sign);
Reid Spencer950bf602007-01-26 08:19:09 +00001461 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1462 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1463 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1464 }
1465 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1466 --i; // Do not skip the next element...
1467 }
1468 }
1469 }
1470
1471 if (TypeToResolve) {
1472 UR_OUT(" * Resolving upreference for "
Reid Spencerbb1fd572007-03-21 17:15:50 +00001473 << UpRefs[i].UpRefTy->getDescription() << "\n";
Reid Spencer950bf602007-01-26 08:19:09 +00001474 std::string OldName = TypeToResolve->getDescription());
Reid Spencerbb1fd572007-03-21 17:15:50 +00001475 ResolveTypeSign(TypeToResolve, Sign);
Reid Spencer950bf602007-01-26 08:19:09 +00001476 TypeToResolve->refineAbstractTypeTo(Ty);
1477 }
1478
1479 return Ty;
1480}
1481
Reid Spencerbb1fd572007-03-21 17:15:50 +00001482bool Signedness::operator<(const Signedness &that) const {
1483 if (isNamed()) {
1484 if (that.isNamed())
1485 return *(this->name) < *(that.name);
1486 else
1487 return CurModule.NamedTypeSigns[*name] < that;
1488 } else if (that.isNamed()) {
1489 return *this < CurModule.NamedTypeSigns[*that.name];
1490 }
1491
1492 if (isComposite() && that.isComposite()) {
1493 if (sv->size() == that.sv->size()) {
1494 SignVector::const_iterator thisI = sv->begin(), thisE = sv->end();
1495 SignVector::const_iterator thatI = that.sv->begin(),
1496 thatE = that.sv->end();
1497 for (; thisI != thisE; ++thisI, ++thatI) {
1498 if (*thisI < *thatI)
1499 return true;
1500 else if (!(*thisI == *thatI))
1501 return false;
1502 }
1503 return false;
1504 }
1505 return sv->size() < that.sv->size();
1506 }
1507 return kind < that.kind;
1508}
1509
1510bool Signedness::operator==(const Signedness &that) const {
1511 if (isNamed())
1512 if (that.isNamed())
1513 return *(this->name) == *(that.name);
1514 else
1515 return CurModule.NamedTypeSigns[*(this->name)] == that;
1516 else if (that.isNamed())
1517 return *this == CurModule.NamedTypeSigns[*(that.name)];
1518 if (isComposite() && that.isComposite()) {
1519 if (sv->size() == that.sv->size()) {
1520 SignVector::const_iterator thisI = sv->begin(), thisE = sv->end();
1521 SignVector::const_iterator thatI = that.sv->begin(),
1522 thatE = that.sv->end();
1523 for (; thisI != thisE; ++thisI, ++thatI) {
1524 if (!(*thisI == *thatI))
1525 return false;
1526 }
1527 return true;
1528 }
1529 return false;
1530 }
1531 return kind == that.kind;
1532}
1533
1534void Signedness::copy(const Signedness &that) {
1535 if (that.isNamed()) {
1536 kind = Named;
1537 name = new std::string(*that.name);
1538 } else if (that.isComposite()) {
1539 kind = Composite;
1540 sv = new SignVector();
1541 *sv = *that.sv;
1542 } else {
1543 kind = that.kind;
1544 sv = 0;
1545 }
1546}
1547
1548void Signedness::destroy() {
1549 if (isNamed()) {
1550 delete name;
1551 } else if (isComposite()) {
1552 delete sv;
1553 }
1554}
1555
Evan Cheng2b484202007-03-22 07:43:51 +00001556#ifndef NDEBUG
Reid Spencerbb1fd572007-03-21 17:15:50 +00001557void Signedness::dump() const {
1558 if (isComposite()) {
1559 if (sv->size() == 1) {
1560 (*sv)[0].dump();
1561 std::cerr << "*";
1562 } else {
1563 std::cerr << "{ " ;
1564 for (unsigned i = 0; i < sv->size(); ++i) {
1565 if (i != 0)
1566 std::cerr << ", ";
1567 (*sv)[i].dump();
1568 }
1569 std::cerr << "} " ;
1570 }
1571 } else if (isNamed()) {
1572 std::cerr << *name;
1573 } else if (isSigned()) {
1574 std::cerr << "S";
1575 } else if (isUnsigned()) {
1576 std::cerr << "U";
1577 } else
1578 std::cerr << ".";
1579}
Evan Cheng2b484202007-03-22 07:43:51 +00001580#endif
Reid Spencerbb1fd572007-03-21 17:15:50 +00001581
Reid Spencer950bf602007-01-26 08:19:09 +00001582static inline Instruction::TermOps
1583getTermOp(TermOps op) {
1584 switch (op) {
1585 default : assert(0 && "Invalid OldTermOp");
1586 case RetOp : return Instruction::Ret;
1587 case BrOp : return Instruction::Br;
1588 case SwitchOp : return Instruction::Switch;
1589 case InvokeOp : return Instruction::Invoke;
1590 case UnwindOp : return Instruction::Unwind;
1591 case UnreachableOp: return Instruction::Unreachable;
1592 }
1593}
1594
1595static inline Instruction::BinaryOps
Reid Spencerbb1fd572007-03-21 17:15:50 +00001596getBinaryOp(BinaryOps op, const Type *Ty, const Signedness& Sign) {
Reid Spencer950bf602007-01-26 08:19:09 +00001597 switch (op) {
1598 default : assert(0 && "Invalid OldBinaryOps");
1599 case SetEQ :
1600 case SetNE :
1601 case SetLE :
1602 case SetGE :
1603 case SetLT :
1604 case SetGT : assert(0 && "Should use getCompareOp");
1605 case AddOp : return Instruction::Add;
1606 case SubOp : return Instruction::Sub;
1607 case MulOp : return Instruction::Mul;
1608 case DivOp : {
1609 // This is an obsolete instruction so we must upgrade it based on the
1610 // types of its operands.
1611 bool isFP = Ty->isFloatingPoint();
Reid Spencer9d6565a2007-02-15 02:26:10 +00001612 if (const VectorType* PTy = dyn_cast<VectorType>(Ty))
Chris Lattner4227bdb2007-02-19 07:34:02 +00001613 // If its a vector type we want to use the element type
Reid Spencer950bf602007-01-26 08:19:09 +00001614 isFP = PTy->getElementType()->isFloatingPoint();
1615 if (isFP)
1616 return Instruction::FDiv;
Reid Spencerbb1fd572007-03-21 17:15:50 +00001617 else if (Sign.isSigned())
Reid Spencer950bf602007-01-26 08:19:09 +00001618 return Instruction::SDiv;
1619 return Instruction::UDiv;
1620 }
1621 case UDivOp : return Instruction::UDiv;
1622 case SDivOp : return Instruction::SDiv;
1623 case FDivOp : return Instruction::FDiv;
1624 case RemOp : {
1625 // This is an obsolete instruction so we must upgrade it based on the
1626 // types of its operands.
1627 bool isFP = Ty->isFloatingPoint();
Reid Spencer9d6565a2007-02-15 02:26:10 +00001628 if (const VectorType* PTy = dyn_cast<VectorType>(Ty))
Chris Lattner4227bdb2007-02-19 07:34:02 +00001629 // If its a vector type we want to use the element type
Reid Spencer950bf602007-01-26 08:19:09 +00001630 isFP = PTy->getElementType()->isFloatingPoint();
1631 // Select correct opcode
1632 if (isFP)
1633 return Instruction::FRem;
Reid Spencerbb1fd572007-03-21 17:15:50 +00001634 else if (Sign.isSigned())
Reid Spencer950bf602007-01-26 08:19:09 +00001635 return Instruction::SRem;
1636 return Instruction::URem;
1637 }
1638 case URemOp : return Instruction::URem;
1639 case SRemOp : return Instruction::SRem;
1640 case FRemOp : return Instruction::FRem;
Reid Spencer832254e2007-02-02 02:16:23 +00001641 case LShrOp : return Instruction::LShr;
1642 case AShrOp : return Instruction::AShr;
1643 case ShlOp : return Instruction::Shl;
1644 case ShrOp :
Reid Spencerbb1fd572007-03-21 17:15:50 +00001645 if (Sign.isSigned())
Reid Spencer832254e2007-02-02 02:16:23 +00001646 return Instruction::AShr;
1647 return Instruction::LShr;
Reid Spencer950bf602007-01-26 08:19:09 +00001648 case AndOp : return Instruction::And;
1649 case OrOp : return Instruction::Or;
1650 case XorOp : return Instruction::Xor;
1651 }
1652}
1653
1654static inline Instruction::OtherOps
1655getCompareOp(BinaryOps op, unsigned short &predicate, const Type* &Ty,
Reid Spencerbb1fd572007-03-21 17:15:50 +00001656 const Signedness &Sign) {
1657 bool isSigned = Sign.isSigned();
Reid Spencer950bf602007-01-26 08:19:09 +00001658 bool isFP = Ty->isFloatingPoint();
1659 switch (op) {
1660 default : assert(0 && "Invalid OldSetCC");
1661 case SetEQ :
1662 if (isFP) {
1663 predicate = FCmpInst::FCMP_OEQ;
1664 return Instruction::FCmp;
1665 } else {
1666 predicate = ICmpInst::ICMP_EQ;
1667 return Instruction::ICmp;
1668 }
1669 case SetNE :
1670 if (isFP) {
1671 predicate = FCmpInst::FCMP_UNE;
1672 return Instruction::FCmp;
1673 } else {
1674 predicate = ICmpInst::ICMP_NE;
1675 return Instruction::ICmp;
1676 }
1677 case SetLE :
1678 if (isFP) {
1679 predicate = FCmpInst::FCMP_OLE;
1680 return Instruction::FCmp;
1681 } else {
1682 if (isSigned)
1683 predicate = ICmpInst::ICMP_SLE;
1684 else
1685 predicate = ICmpInst::ICMP_ULE;
1686 return Instruction::ICmp;
1687 }
1688 case SetGE :
1689 if (isFP) {
1690 predicate = FCmpInst::FCMP_OGE;
1691 return Instruction::FCmp;
1692 } else {
1693 if (isSigned)
1694 predicate = ICmpInst::ICMP_SGE;
1695 else
1696 predicate = ICmpInst::ICMP_UGE;
1697 return Instruction::ICmp;
1698 }
1699 case SetLT :
1700 if (isFP) {
1701 predicate = FCmpInst::FCMP_OLT;
1702 return Instruction::FCmp;
1703 } else {
1704 if (isSigned)
1705 predicate = ICmpInst::ICMP_SLT;
1706 else
1707 predicate = ICmpInst::ICMP_ULT;
1708 return Instruction::ICmp;
1709 }
1710 case SetGT :
1711 if (isFP) {
1712 predicate = FCmpInst::FCMP_OGT;
1713 return Instruction::FCmp;
1714 } else {
1715 if (isSigned)
1716 predicate = ICmpInst::ICMP_SGT;
1717 else
1718 predicate = ICmpInst::ICMP_UGT;
1719 return Instruction::ICmp;
1720 }
1721 }
1722}
1723
1724static inline Instruction::MemoryOps getMemoryOp(MemoryOps op) {
1725 switch (op) {
1726 default : assert(0 && "Invalid OldMemoryOps");
1727 case MallocOp : return Instruction::Malloc;
1728 case FreeOp : return Instruction::Free;
1729 case AllocaOp : return Instruction::Alloca;
1730 case LoadOp : return Instruction::Load;
1731 case StoreOp : return Instruction::Store;
1732 case GetElementPtrOp : return Instruction::GetElementPtr;
1733 }
1734}
1735
1736static inline Instruction::OtherOps
Reid Spencerbb1fd572007-03-21 17:15:50 +00001737getOtherOp(OtherOps op, const Signedness &Sign) {
Reid Spencer950bf602007-01-26 08:19:09 +00001738 switch (op) {
1739 default : assert(0 && "Invalid OldOtherOps");
1740 case PHIOp : return Instruction::PHI;
1741 case CallOp : return Instruction::Call;
Reid Spencer950bf602007-01-26 08:19:09 +00001742 case SelectOp : return Instruction::Select;
1743 case UserOp1 : return Instruction::UserOp1;
1744 case UserOp2 : return Instruction::UserOp2;
1745 case VAArg : return Instruction::VAArg;
1746 case ExtractElementOp : return Instruction::ExtractElement;
1747 case InsertElementOp : return Instruction::InsertElement;
1748 case ShuffleVectorOp : return Instruction::ShuffleVector;
1749 case ICmpOp : return Instruction::ICmp;
1750 case FCmpOp : return Instruction::FCmp;
Reid Spencer950bf602007-01-26 08:19:09 +00001751 };
1752}
1753
1754static inline Value*
Reid Spencerbb1fd572007-03-21 17:15:50 +00001755getCast(CastOps op, Value *Src, const Signedness &SrcSign, const Type *DstTy,
1756 const Signedness &DstSign, bool ForceInstruction = false) {
Reid Spencer950bf602007-01-26 08:19:09 +00001757 Instruction::CastOps Opcode;
1758 const Type* SrcTy = Src->getType();
1759 if (op == CastOp) {
1760 if (SrcTy->isFloatingPoint() && isa<PointerType>(DstTy)) {
1761 // fp -> ptr cast is no longer supported but we must upgrade this
1762 // by doing a double cast: fp -> int -> ptr
1763 SrcTy = Type::Int64Ty;
1764 Opcode = Instruction::IntToPtr;
1765 if (isa<Constant>(Src)) {
1766 Src = ConstantExpr::getCast(Instruction::FPToUI,
1767 cast<Constant>(Src), SrcTy);
1768 } else {
1769 std::string NewName(makeNameUnique(Src->getName()));
1770 Src = new FPToUIInst(Src, SrcTy, NewName, CurBB);
1771 }
1772 } else if (isa<IntegerType>(DstTy) &&
1773 cast<IntegerType>(DstTy)->getBitWidth() == 1) {
1774 // cast type %x to bool was previously defined as setne type %x, null
1775 // The cast semantic is now to truncate, not compare so we must retain
1776 // the original intent by replacing the cast with a setne
1777 Constant* Null = Constant::getNullValue(SrcTy);
1778 Instruction::OtherOps Opcode = Instruction::ICmp;
1779 unsigned short predicate = ICmpInst::ICMP_NE;
1780 if (SrcTy->isFloatingPoint()) {
1781 Opcode = Instruction::FCmp;
1782 predicate = FCmpInst::FCMP_ONE;
1783 } else if (!SrcTy->isInteger() && !isa<PointerType>(SrcTy)) {
1784 error("Invalid cast to bool");
1785 }
1786 if (isa<Constant>(Src) && !ForceInstruction)
1787 return ConstantExpr::getCompare(predicate, cast<Constant>(Src), Null);
1788 else
1789 return CmpInst::create(Opcode, predicate, Src, Null);
1790 }
1791 // Determine the opcode to use by calling CastInst::getCastOpcode
1792 Opcode =
Reid Spencerbb1fd572007-03-21 17:15:50 +00001793 CastInst::getCastOpcode(Src, SrcSign.isSigned(), DstTy,
1794 DstSign.isSigned());
Reid Spencer950bf602007-01-26 08:19:09 +00001795
1796 } else switch (op) {
1797 default: assert(0 && "Invalid cast token");
1798 case TruncOp: Opcode = Instruction::Trunc; break;
1799 case ZExtOp: Opcode = Instruction::ZExt; break;
1800 case SExtOp: Opcode = Instruction::SExt; break;
1801 case FPTruncOp: Opcode = Instruction::FPTrunc; break;
1802 case FPExtOp: Opcode = Instruction::FPExt; break;
1803 case FPToUIOp: Opcode = Instruction::FPToUI; break;
1804 case FPToSIOp: Opcode = Instruction::FPToSI; break;
1805 case UIToFPOp: Opcode = Instruction::UIToFP; break;
1806 case SIToFPOp: Opcode = Instruction::SIToFP; break;
1807 case PtrToIntOp: Opcode = Instruction::PtrToInt; break;
1808 case IntToPtrOp: Opcode = Instruction::IntToPtr; break;
1809 case BitCastOp: Opcode = Instruction::BitCast; break;
1810 }
1811
1812 if (isa<Constant>(Src) && !ForceInstruction)
1813 return ConstantExpr::getCast(Opcode, cast<Constant>(Src), DstTy);
1814 return CastInst::create(Opcode, Src, DstTy);
1815}
1816
1817static Instruction *
1818upgradeIntrinsicCall(const Type* RetTy, const ValID &ID,
1819 std::vector<Value*>& Args) {
1820
1821 std::string Name = ID.Type == ValID::NameVal ? ID.Name : "";
Reid Spencer41b213e2007-04-02 01:14:00 +00001822 switch (Name[5]) {
1823 case 'i':
1824 if (Name == "llvm.isunordered.f32" || Name == "llvm.isunordered.f64") {
1825 if (Args.size() != 2)
1826 error("Invalid prototype for " + Name);
1827 return new FCmpInst(FCmpInst::FCMP_UNO, Args[0], Args[1]);
1828 }
1829 break;
1830 case 'b':
1831 if (Name.length() == 14 && !memcmp(&Name[5], "bswap.i", 7)) {
1832 const Type* ArgTy = Args[0]->getType();
1833 Name += ".i" + utostr(cast<IntegerType>(ArgTy)->getBitWidth());
1834 Function *F = cast<Function>(
1835 CurModule.CurrentModule->getOrInsertFunction(Name, RetTy, ArgTy,
1836 (void*)0));
1837 return new CallInst(F, Args[0]);
1838 }
1839 break;
Reid Spencer8166a6c2007-04-02 02:08:35 +00001840 case 'c':
1841 if ((Name.length() <= 14 && !memcmp(&Name[5], "ctpop.i", 7)) ||
1842 (Name.length() <= 13 && !memcmp(&Name[5], "ctlz.i", 6)) ||
1843 (Name.length() <= 13 && !memcmp(&Name[5], "cttz.i", 6))) {
1844 // These intrinsics changed their result type.
1845 const Type* ArgTy = Args[0]->getType();
1846 Function *OldF = CurModule.CurrentModule->getFunction(Name);
1847 if (OldF)
1848 OldF->setName("upgrd.rm." + Name);
1849
1850 Function *NewF = cast<Function>(
1851 CurModule.CurrentModule->getOrInsertFunction(Name, Type::Int32Ty,
1852 ArgTy, (void*)0));
1853
1854 Instruction *Call = new CallInst(NewF, Args[0], "", CurBB);
1855 return CastInst::createIntegerCast(Call, RetTy, false);
1856 }
1857 break;
1858
Reid Spencer41b213e2007-04-02 01:14:00 +00001859 case 'v' : {
1860 const Type* PtrTy = PointerType::get(Type::Int8Ty);
1861 std::vector<const Type*> Params;
1862 if (Name == "llvm.va_start" || Name == "llvm.va_end") {
1863 if (Args.size() != 1)
1864 error("Invalid prototype for " + Name + " prototype");
1865 Params.push_back(PtrTy);
1866 const FunctionType *FTy =
1867 FunctionType::get(Type::VoidTy, Params, false);
1868 const PointerType *PFTy = PointerType::get(FTy);
1869 Value* Func = getVal(PFTy, ID);
1870 Args[0] = new BitCastInst(Args[0], PtrTy, makeNameUnique("va"), CurBB);
1871 return new CallInst(Func, &Args[0], Args.size());
1872 } else if (Name == "llvm.va_copy") {
1873 if (Args.size() != 2)
1874 error("Invalid prototype for " + Name + " prototype");
1875 Params.push_back(PtrTy);
1876 Params.push_back(PtrTy);
1877 const FunctionType *FTy =
1878 FunctionType::get(Type::VoidTy, Params, false);
1879 const PointerType *PFTy = PointerType::get(FTy);
1880 Value* Func = getVal(PFTy, ID);
1881 std::string InstName0(makeNameUnique("va0"));
1882 std::string InstName1(makeNameUnique("va1"));
1883 Args[0] = new BitCastInst(Args[0], PtrTy, InstName0, CurBB);
1884 Args[1] = new BitCastInst(Args[1], PtrTy, InstName1, CurBB);
1885 return new CallInst(Func, &Args[0], Args.size());
1886 }
Reid Spencer950bf602007-01-26 08:19:09 +00001887 }
1888 }
1889 return 0;
1890}
1891
1892const Type* upgradeGEPIndices(const Type* PTy,
1893 std::vector<ValueInfo> *Indices,
1894 std::vector<Value*> &VIndices,
1895 std::vector<Constant*> *CIndices = 0) {
1896 // Traverse the indices with a gep_type_iterator so we can build the list
1897 // of constant and value indices for use later. Also perform upgrades
1898 VIndices.clear();
1899 if (CIndices) CIndices->clear();
1900 for (unsigned i = 0, e = Indices->size(); i != e; ++i)
1901 VIndices.push_back((*Indices)[i].V);
1902 generic_gep_type_iterator<std::vector<Value*>::iterator>
1903 GTI = gep_type_begin(PTy, VIndices.begin(), VIndices.end()),
1904 GTE = gep_type_end(PTy, VIndices.begin(), VIndices.end());
1905 for (unsigned i = 0, e = Indices->size(); i != e && GTI != GTE; ++i, ++GTI) {
1906 Value *Index = VIndices[i];
1907 if (CIndices && !isa<Constant>(Index))
1908 error("Indices to constant getelementptr must be constants");
1909 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte
1910 // struct indices to i32 struct indices with ZExt for compatibility.
1911 else if (isa<StructType>(*GTI)) { // Only change struct indices
1912 if (ConstantInt *CUI = dyn_cast<ConstantInt>(Index))
1913 if (CUI->getType()->getBitWidth() == 8)
1914 Index =
1915 ConstantExpr::getCast(Instruction::ZExt, CUI, Type::Int32Ty);
1916 } else {
1917 // Make sure that unsigned SequentialType indices are zext'd to
1918 // 64-bits if they were smaller than that because LLVM 2.0 will sext
1919 // all indices for SequentialType elements. We must retain the same
1920 // semantic (zext) for unsigned types.
1921 if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType()))
Reid Spencerbb1fd572007-03-21 17:15:50 +00001922 if (Ity->getBitWidth() < 64 && (*Indices)[i].S.isUnsigned()) {
Reid Spencer950bf602007-01-26 08:19:09 +00001923 if (CIndices)
1924 Index = ConstantExpr::getCast(Instruction::ZExt,
1925 cast<Constant>(Index), Type::Int64Ty);
1926 else
1927 Index = CastInst::create(Instruction::ZExt, Index, Type::Int64Ty,
Reid Spencer832254e2007-02-02 02:16:23 +00001928 makeNameUnique("gep"), CurBB);
Reid Spencer38f682b2007-01-26 20:31:18 +00001929 VIndices[i] = Index;
1930 }
Reid Spencer950bf602007-01-26 08:19:09 +00001931 }
1932 // Add to the CIndices list, if requested.
1933 if (CIndices)
1934 CIndices->push_back(cast<Constant>(Index));
1935 }
1936
1937 const Type *IdxTy =
Chris Lattner1bc3fa62007-02-12 22:58:38 +00001938 GetElementPtrInst::getIndexedType(PTy, &VIndices[0], VIndices.size(), true);
Reid Spencer950bf602007-01-26 08:19:09 +00001939 if (!IdxTy)
1940 error("Index list invalid for constant getelementptr");
1941 return IdxTy;
1942}
1943
Reid Spencerb7046c72007-01-29 05:41:34 +00001944unsigned upgradeCallingConv(unsigned CC) {
1945 switch (CC) {
1946 case OldCallingConv::C : return CallingConv::C;
1947 case OldCallingConv::CSRet : return CallingConv::C;
1948 case OldCallingConv::Fast : return CallingConv::Fast;
1949 case OldCallingConv::Cold : return CallingConv::Cold;
1950 case OldCallingConv::X86_StdCall : return CallingConv::X86_StdCall;
1951 case OldCallingConv::X86_FastCall: return CallingConv::X86_FastCall;
1952 default:
1953 return CC;
1954 }
1955}
1956
Reid Spencer950bf602007-01-26 08:19:09 +00001957Module* UpgradeAssembly(const std::string &infile, std::istream& in,
1958 bool debug, bool addAttrs)
Reid Spencere7c3c602006-11-30 06:36:44 +00001959{
1960 Upgradelineno = 1;
1961 CurFilename = infile;
Reid Spencer96839be2006-11-30 16:50:26 +00001962 LexInput = &in;
Reid Spencere77e35e2006-12-01 20:26:20 +00001963 yydebug = debug;
Reid Spencer71d2ec92006-12-31 06:02:26 +00001964 AddAttributes = addAttrs;
Reid Spencer950bf602007-01-26 08:19:09 +00001965 ObsoleteVarArgs = false;
1966 NewVarArgs = false;
Reid Spencere7c3c602006-11-30 06:36:44 +00001967
Reid Spencer950bf602007-01-26 08:19:09 +00001968 CurModule.CurrentModule = new Module(CurFilename);
1969
1970 // Check to make sure the parser succeeded
Reid Spencere7c3c602006-11-30 06:36:44 +00001971 if (yyparse()) {
Reid Spencer950bf602007-01-26 08:19:09 +00001972 if (ParserResult)
1973 delete ParserResult;
Reid Spencer30d0c582007-01-15 00:26:18 +00001974 std::cerr << "llvm-upgrade: parse failed.\n";
Reid Spencer30d0c582007-01-15 00:26:18 +00001975 return 0;
1976 }
1977
Reid Spencer950bf602007-01-26 08:19:09 +00001978 // Check to make sure that parsing produced a result
1979 if (!ParserResult) {
1980 std::cerr << "llvm-upgrade: no parse result.\n";
1981 return 0;
Reid Spencer30d0c582007-01-15 00:26:18 +00001982 }
1983
Reid Spencer950bf602007-01-26 08:19:09 +00001984 // Reset ParserResult variable while saving its value for the result.
1985 Module *Result = ParserResult;
1986 ParserResult = 0;
Reid Spencer30d0c582007-01-15 00:26:18 +00001987
Reid Spencer950bf602007-01-26 08:19:09 +00001988 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
Reid Spencer30d0c582007-01-15 00:26:18 +00001989 {
Reid Spencer950bf602007-01-26 08:19:09 +00001990 Function* F;
Reid Spencer688b0492007-02-05 21:19:13 +00001991 if ((F = Result->getFunction("llvm.va_start"))
Reid Spencer950bf602007-01-26 08:19:09 +00001992 && F->getFunctionType()->getNumParams() == 0)
1993 ObsoleteVarArgs = true;
Reid Spencer688b0492007-02-05 21:19:13 +00001994 if((F = Result->getFunction("llvm.va_copy"))
Reid Spencer950bf602007-01-26 08:19:09 +00001995 && F->getFunctionType()->getNumParams() == 1)
1996 ObsoleteVarArgs = true;
Reid Spencer280d8012006-12-01 23:40:53 +00001997 }
Reid Spencer319a7302007-01-05 17:20:02 +00001998
Reid Spencer950bf602007-01-26 08:19:09 +00001999 if (ObsoleteVarArgs && NewVarArgs) {
2000 error("This file is corrupt: it uses both new and old style varargs");
2001 return 0;
Reid Spencer319a7302007-01-05 17:20:02 +00002002 }
Reid Spencer319a7302007-01-05 17:20:02 +00002003
Reid Spencer950bf602007-01-26 08:19:09 +00002004 if(ObsoleteVarArgs) {
Reid Spencer688b0492007-02-05 21:19:13 +00002005 if(Function* F = Result->getFunction("llvm.va_start")) {
Reid Spencer950bf602007-01-26 08:19:09 +00002006 if (F->arg_size() != 0) {
2007 error("Obsolete va_start takes 0 argument");
Reid Spencer319a7302007-01-05 17:20:02 +00002008 return 0;
2009 }
Reid Spencer950bf602007-01-26 08:19:09 +00002010
2011 //foo = va_start()
2012 // ->
2013 //bar = alloca typeof(foo)
2014 //va_start(bar)
2015 //foo = load bar
Reid Spencer319a7302007-01-05 17:20:02 +00002016
Reid Spencer950bf602007-01-26 08:19:09 +00002017 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
2018 const Type* ArgTy = F->getFunctionType()->getReturnType();
2019 const Type* ArgTyPtr = PointerType::get(ArgTy);
2020 Function* NF = cast<Function>(Result->getOrInsertFunction(
2021 "llvm.va_start", RetTy, ArgTyPtr, (Type *)0));
2022
2023 while (!F->use_empty()) {
2024 CallInst* CI = cast<CallInst>(F->use_back());
2025 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
2026 new CallInst(NF, bar, "", CI);
2027 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
2028 CI->replaceAllUsesWith(foo);
2029 CI->getParent()->getInstList().erase(CI);
Reid Spencerf8383de2007-01-06 06:04:32 +00002030 }
Reid Spencer950bf602007-01-26 08:19:09 +00002031 Result->getFunctionList().erase(F);
Reid Spencerf8383de2007-01-06 06:04:32 +00002032 }
Reid Spencer950bf602007-01-26 08:19:09 +00002033
Reid Spencer688b0492007-02-05 21:19:13 +00002034 if(Function* F = Result->getFunction("llvm.va_end")) {
Reid Spencer950bf602007-01-26 08:19:09 +00002035 if(F->arg_size() != 1) {
2036 error("Obsolete va_end takes 1 argument");
2037 return 0;
Reid Spencerf8383de2007-01-06 06:04:32 +00002038 }
Reid Spencerf8383de2007-01-06 06:04:32 +00002039
Reid Spencer950bf602007-01-26 08:19:09 +00002040 //vaend foo
2041 // ->
2042 //bar = alloca 1 of typeof(foo)
2043 //vaend bar
2044 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
2045 const Type* ArgTy = F->getFunctionType()->getParamType(0);
2046 const Type* ArgTyPtr = PointerType::get(ArgTy);
2047 Function* NF = cast<Function>(Result->getOrInsertFunction(
2048 "llvm.va_end", RetTy, ArgTyPtr, (Type *)0));
Reid Spencerf8383de2007-01-06 06:04:32 +00002049
Reid Spencer950bf602007-01-26 08:19:09 +00002050 while (!F->use_empty()) {
2051 CallInst* CI = cast<CallInst>(F->use_back());
2052 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
2053 new StoreInst(CI->getOperand(1), bar, CI);
2054 new CallInst(NF, bar, "", CI);
2055 CI->getParent()->getInstList().erase(CI);
Reid Spencere77e35e2006-12-01 20:26:20 +00002056 }
Reid Spencer950bf602007-01-26 08:19:09 +00002057 Result->getFunctionList().erase(F);
Reid Spencere77e35e2006-12-01 20:26:20 +00002058 }
Reid Spencer950bf602007-01-26 08:19:09 +00002059
Reid Spencer688b0492007-02-05 21:19:13 +00002060 if(Function* F = Result->getFunction("llvm.va_copy")) {
Reid Spencer950bf602007-01-26 08:19:09 +00002061 if(F->arg_size() != 1) {
2062 error("Obsolete va_copy takes 1 argument");
2063 return 0;
Reid Spencere77e35e2006-12-01 20:26:20 +00002064 }
Reid Spencer950bf602007-01-26 08:19:09 +00002065 //foo = vacopy(bar)
2066 // ->
2067 //a = alloca 1 of typeof(foo)
2068 //b = alloca 1 of typeof(foo)
2069 //store bar -> b
2070 //vacopy(a, b)
2071 //foo = load a
2072
2073 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
2074 const Type* ArgTy = F->getFunctionType()->getReturnType();
2075 const Type* ArgTyPtr = PointerType::get(ArgTy);
2076 Function* NF = cast<Function>(Result->getOrInsertFunction(
2077 "llvm.va_copy", RetTy, ArgTyPtr, ArgTyPtr, (Type *)0));
Reid Spencere77e35e2006-12-01 20:26:20 +00002078
Reid Spencer950bf602007-01-26 08:19:09 +00002079 while (!F->use_empty()) {
2080 CallInst* CI = cast<CallInst>(F->use_back());
2081 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
2082 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
2083 new StoreInst(CI->getOperand(1), b, CI);
2084 new CallInst(NF, a, b, "", CI);
2085 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
2086 CI->replaceAllUsesWith(foo);
2087 CI->getParent()->getInstList().erase(CI);
2088 }
2089 Result->getFunctionList().erase(F);
Reid Spencer319a7302007-01-05 17:20:02 +00002090 }
2091 }
2092
Reid Spencer52402b02007-01-02 05:45:11 +00002093 return Result;
2094}
2095
Reid Spencer950bf602007-01-26 08:19:09 +00002096} // end llvm namespace
Reid Spencer319a7302007-01-05 17:20:02 +00002097
Reid Spencer950bf602007-01-26 08:19:09 +00002098using namespace llvm;
Reid Spencer30d0c582007-01-15 00:26:18 +00002099
2100
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002101
2102/* Enabling traces. */
2103#ifndef YYDEBUG
2104# define YYDEBUG 0
2105#endif
2106
2107/* Enabling verbose error messages. */
2108#ifdef YYERROR_VERBOSE
2109# undef YYERROR_VERBOSE
2110# define YYERROR_VERBOSE 1
2111#else
2112# define YYERROR_VERBOSE 0
2113#endif
2114
2115/* Enabling the token table. */
2116#ifndef YYTOKEN_TABLE
2117# define YYTOKEN_TABLE 0
2118#endif
2119
2120#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
Reid Spencerbaba98a2007-04-11 12:10:58 +00002121#line 1742 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002122typedef union YYSTYPE {
Reid Spencer950bf602007-01-26 08:19:09 +00002123 llvm::Module *ModuleVal;
2124 llvm::Function *FunctionVal;
2125 std::pair<llvm::PATypeInfo, char*> *ArgVal;
2126 llvm::BasicBlock *BasicBlockVal;
Reid Spencerbb1fd572007-03-21 17:15:50 +00002127 llvm::TermInstInfo TermInstVal;
Reid Spencer950bf602007-01-26 08:19:09 +00002128 llvm::InstrInfo InstVal;
2129 llvm::ConstInfo ConstVal;
2130 llvm::ValueInfo ValueVal;
2131 llvm::PATypeInfo TypeVal;
2132 llvm::TypeInfo PrimType;
2133 llvm::PHIListInfo PHIList;
2134 std::list<llvm::PATypeInfo> *TypeList;
2135 std::vector<llvm::ValueInfo> *ValueList;
2136 std::vector<llvm::ConstInfo> *ConstVector;
2137
2138
2139 std::vector<std::pair<llvm::PATypeInfo,char*> > *ArgList;
2140 // Represent the RHS of PHI node
2141 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
2142
2143 llvm::GlobalValue::LinkageTypes Linkage;
2144 int64_t SInt64Val;
2145 uint64_t UInt64Val;
2146 int SIntVal;
2147 unsigned UIntVal;
2148 double FPVal;
2149 bool BoolVal;
2150
2151 char *StrVal; // This memory is strdup'd!
2152 llvm::ValID ValIDVal; // strdup'd memory maybe!
2153
2154 llvm::BinaryOps BinaryOpVal;
2155 llvm::TermOps TermOpVal;
2156 llvm::MemoryOps MemOpVal;
2157 llvm::OtherOps OtherOpVal;
2158 llvm::CastOps CastOpVal;
2159 llvm::ICmpInst::Predicate IPred;
2160 llvm::FCmpInst::Predicate FPred;
2161 llvm::Module::Endianness Endianness;
Chris Lattnercf3d0612007-02-13 06:04:17 +00002162} YYSTYPE;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002163/* Line 196 of yacc.c. */
Reid Spencerbaba98a2007-04-11 12:10:58 +00002164#line 2165 "UpgradeParser.tab.c"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002165# define yystype YYSTYPE /* obsolescent; will be withdrawn */
2166# define YYSTYPE_IS_DECLARED 1
2167# define YYSTYPE_IS_TRIVIAL 1
Reid Spencere7c3c602006-11-30 06:36:44 +00002168#endif
2169
Reid Spencer950bf602007-01-26 08:19:09 +00002170
Reid Spencere7c3c602006-11-30 06:36:44 +00002171
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002172/* Copy the second part of user declarations. */
Reid Spencere7c3c602006-11-30 06:36:44 +00002173
2174
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002175/* Line 219 of yacc.c. */
Reid Spencerbaba98a2007-04-11 12:10:58 +00002176#line 2177 "UpgradeParser.tab.c"
Reid Spencer950bf602007-01-26 08:19:09 +00002177
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002178#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
2179# define YYSIZE_T __SIZE_TYPE__
2180#endif
2181#if ! defined (YYSIZE_T) && defined (size_t)
2182# define YYSIZE_T size_t
2183#endif
2184#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
2185# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
2186# define YYSIZE_T size_t
2187#endif
2188#if ! defined (YYSIZE_T)
2189# define YYSIZE_T unsigned int
2190#endif
Chris Lattnercf3d0612007-02-13 06:04:17 +00002191
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002192#ifndef YY_
2193# if YYENABLE_NLS
2194# if ENABLE_NLS
2195# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
2196# define YY_(msgid) dgettext ("bison-runtime", msgid)
2197# endif
2198# endif
2199# ifndef YY_
2200# define YY_(msgid) msgid
2201# endif
2202#endif
2203
2204#if ! defined (yyoverflow) || YYERROR_VERBOSE
2205
2206/* The parser invokes alloca or malloc; define the necessary symbols. */
2207
2208# ifdef YYSTACK_USE_ALLOCA
2209# if YYSTACK_USE_ALLOCA
2210# ifdef __GNUC__
2211# define YYSTACK_ALLOC __builtin_alloca
2212# else
2213# define YYSTACK_ALLOC alloca
2214# if defined (__STDC__) || defined (__cplusplus)
2215# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
2216# define YYINCLUDED_STDLIB_H
2217# endif
2218# endif
2219# endif
2220# endif
2221
2222# ifdef YYSTACK_ALLOC
2223 /* Pacify GCC's `empty if-body' warning. */
2224# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
2225# ifndef YYSTACK_ALLOC_MAXIMUM
2226 /* The OS might guarantee only one guard page at the bottom of the stack,
2227 and a page size can be as small as 4096 bytes. So we cannot safely
2228 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
2229 to allow for a few compiler-allocated temporary stack slots. */
2230# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
2231# endif
2232# else
2233# define YYSTACK_ALLOC YYMALLOC
2234# define YYSTACK_FREE YYFREE
2235# ifndef YYSTACK_ALLOC_MAXIMUM
2236# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
2237# endif
2238# ifdef __cplusplus
2239extern "C" {
2240# endif
2241# ifndef YYMALLOC
2242# define YYMALLOC malloc
2243# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
2244 && (defined (__STDC__) || defined (__cplusplus)))
2245void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
2246# endif
2247# endif
2248# ifndef YYFREE
2249# define YYFREE free
2250# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
2251 && (defined (__STDC__) || defined (__cplusplus)))
2252void free (void *); /* INFRINGES ON USER NAME SPACE */
2253# endif
2254# endif
2255# ifdef __cplusplus
2256}
2257# endif
2258# endif
2259#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
2260
2261
2262#if (! defined (yyoverflow) \
2263 && (! defined (__cplusplus) \
2264 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
2265
2266/* A type that is properly aligned for any stack member. */
2267union yyalloc
2268{
2269 short int yyss;
2270 YYSTYPE yyvs;
2271 };
2272
2273/* The size of the maximum gap between one aligned stack and the next. */
2274# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
2275
2276/* The size of an array large to enough to hold all stacks, each with
2277 N elements. */
2278# define YYSTACK_BYTES(N) \
2279 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
2280 + YYSTACK_GAP_MAXIMUM)
2281
2282/* Copy COUNT objects from FROM to TO. The source and destination do
2283 not overlap. */
2284# ifndef YYCOPY
2285# if defined (__GNUC__) && 1 < __GNUC__
2286# define YYCOPY(To, From, Count) \
2287 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
2288# else
2289# define YYCOPY(To, From, Count) \
2290 do \
2291 { \
2292 YYSIZE_T yyi; \
2293 for (yyi = 0; yyi < (Count); yyi++) \
2294 (To)[yyi] = (From)[yyi]; \
2295 } \
2296 while (0)
2297# endif
2298# endif
2299
2300/* Relocate STACK from its old location to the new one. The
2301 local variables YYSIZE and YYSTACKSIZE give the old and new number of
2302 elements in the stack, and YYPTR gives the new location of the
2303 stack. Advance YYPTR to a properly aligned location for the next
2304 stack. */
2305# define YYSTACK_RELOCATE(Stack) \
2306 do \
2307 { \
2308 YYSIZE_T yynewbytes; \
2309 YYCOPY (&yyptr->Stack, Stack, yysize); \
2310 Stack = &yyptr->Stack; \
2311 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
2312 yyptr += yynewbytes / sizeof (*yyptr); \
2313 } \
2314 while (0)
Chris Lattnercf3d0612007-02-13 06:04:17 +00002315
Reid Spencere7c3c602006-11-30 06:36:44 +00002316#endif
2317
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002318#if defined (__STDC__) || defined (__cplusplus)
2319 typedef signed char yysigned_char;
Reid Spencerb7046c72007-01-29 05:41:34 +00002320#else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002321 typedef short int yysigned_char;
Reid Spencerb7046c72007-01-29 05:41:34 +00002322#endif
2323
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002324/* YYFINAL -- State number of the termination state. */
2325#define YYFINAL 4
2326/* YYLAST -- Last index in YYTABLE. */
Reid Spencerd2920cd2007-03-21 17:27:53 +00002327#define YYLAST 1630
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002328
2329/* YYNTOKENS -- Number of terminals. */
2330#define YYNTOKENS 166
2331/* YYNNTS -- Number of nonterminals. */
Reid Spencerd2920cd2007-03-21 17:27:53 +00002332#define YYNNTS 81
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002333/* YYNRULES -- Number of rules. */
Reid Spencerd2920cd2007-03-21 17:27:53 +00002334#define YYNRULES 310
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002335/* YYNRULES -- Number of states. */
Reid Spencerd2920cd2007-03-21 17:27:53 +00002336#define YYNSTATES 606
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002337
2338/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
2339#define YYUNDEFTOK 2
2340#define YYMAXUTOK 406
2341
2342#define YYTRANSLATE(YYX) \
2343 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
2344
2345/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
2346static const unsigned char yytranslate[] =
2347{
2348 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2349 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2350 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2351 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2352 155, 156, 164, 2, 153, 2, 2, 2, 2, 2,
2353 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2354 160, 152, 161, 2, 2, 2, 2, 2, 2, 2,
2355 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2356 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2357 2, 157, 154, 159, 2, 2, 2, 2, 2, 165,
2358 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2359 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2360 158, 2, 2, 162, 2, 163, 2, 2, 2, 2,
2361 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2362 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2363 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2364 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2365 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2366 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2367 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2368 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2369 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2370 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2371 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2372 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2373 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
2374 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
2375 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
2376 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
2377 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
2378 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
2379 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
2380 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
2381 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2382 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
2383 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
2384 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
2385 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
2386 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
2387 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
2388 145, 146, 147, 148, 149, 150, 151
2389};
2390
2391#if YYDEBUG
2392/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
2393 YYRHS. */
2394static const unsigned short int yyprhs[] =
2395{
2396 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
2397 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
2398 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
2399 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
2400 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
2401 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
2402 119, 121, 123, 125, 127, 129, 131, 133, 135, 137,
2403 139, 141, 143, 145, 147, 149, 151, 153, 155, 157,
2404 159, 161, 164, 165, 167, 169, 171, 173, 175, 177,
2405 179, 180, 181, 183, 185, 187, 189, 191, 193, 196,
2406 197, 200, 201, 205, 208, 209, 211, 212, 216, 218,
2407 221, 223, 225, 227, 229, 231, 233, 235, 237, 239,
2408 241, 243, 245, 247, 249, 251, 253, 255, 257, 259,
2409 261, 264, 269, 275, 281, 285, 288, 294, 299, 302,
2410 304, 308, 310, 314, 316, 317, 322, 326, 330, 335,
2411 340, 344, 351, 357, 360, 363, 366, 369, 372, 375,
2412 378, 381, 384, 387, 394, 400, 409, 416, 423, 430,
2413 438, 446, 453, 460, 469, 478, 482, 484, 486, 488,
2414 490, 493, 496, 501, 504, 506, 511, 514, 519, 520,
2415 528, 529, 537, 538, 546, 547, 555, 559, 564, 565,
2416 567, 569, 571, 575, 579, 583, 587, 591, 595, 597,
2417 598, 600, 602, 604, 605, 608, 612, 614, 616, 620,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002418 622, 623, 632, 634, 636, 637, 642, 644, 646, 649,
2419 650, 652, 654, 655, 656, 662, 663, 665, 667, 669,
2420 671, 673, 675, 677, 679, 681, 685, 687, 693, 695,
2421 697, 699, 701, 704, 707, 710, 714, 717, 718, 720,
2422 722, 724, 727, 730, 734, 744, 754, 763, 777, 779,
2423 781, 788, 794, 797, 804, 812, 814, 818, 820, 821,
2424 824, 826, 832, 838, 844, 851, 858, 861, 866, 871,
2425 878, 883, 888, 893, 898, 905, 912, 915, 923, 925,
2426 928, 929, 931, 932, 936, 943, 947, 954, 957, 962,
2427 969
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002428};
2429
2430/* YYRHS -- A `-1'-separated list of the rules' RHS. */
2431static const short int yyrhs[] =
2432{
2433 200, 0, -1, 5, -1, 6, -1, 3, -1, 4,
2434 -1, 79, -1, 80, -1, 81, -1, 82, -1, 83,
2435 -1, 84, -1, 85, -1, 86, -1, 87, -1, 88,
2436 -1, 89, -1, 90, -1, 91, -1, 92, -1, 97,
2437 -1, 98, -1, 99, -1, 100, -1, 101, -1, 102,
2438 -1, 119, -1, 120, -1, 121, -1, 122, -1, 123,
2439 -1, 124, -1, 125, -1, 126, -1, 127, -1, 128,
2440 -1, 129, -1, 130, -1, 131, -1, 132, -1, 133,
2441 -1, 134, -1, 135, -1, 136, -1, 137, -1, 138,
2442 -1, 125, -1, 126, -1, 127, -1, 128, -1, 27,
2443 -1, 28, -1, 93, -1, 94, -1, 95, -1, 96,
2444 -1, 140, -1, 141, -1, 142, -1, 143, -1, 144,
2445 -1, 145, -1, 146, -1, 147, -1, 148, -1, 149,
2446 -1, 150, -1, 151, -1, 139, -1, 16, -1, 14,
2447 -1, 12, -1, 10, -1, 17, -1, 15, -1, 13,
2448 -1, 11, -1, 176, -1, 177, -1, 18, -1, 19,
2449 -1, 212, 152, -1, -1, 41, -1, 42, -1, 43,
2450 -1, 44, -1, 45, -1, 46, -1, 47, -1, -1,
2451 -1, 65, -1, 66, -1, 67, -1, 68, -1, 69,
2452 -1, 70, -1, 64, 4, -1, -1, 57, 4, -1,
2453 -1, 153, 57, 4, -1, 34, 24, -1, -1, 185,
2454 -1, -1, 153, 188, 187, -1, 185, -1, 57, 4,
2455 -1, 191, -1, 8, -1, 193, -1, 8, -1, 193,
2456 -1, 9, -1, 10, -1, 11, -1, 12, -1, 13,
2457 -1, 14, -1, 15, -1, 16, -1, 17, -1, 18,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002458 -1, 19, -1, 21, -1, 192, -1, 48, -1, 229,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002459 -1, 154, 4, -1, 190, 155, 195, 156, -1, 157,
2460 4, 158, 193, 159, -1, 160, 4, 158, 193, 161,
2461 -1, 162, 194, 163, -1, 162, 163, -1, 160, 162,
2462 194, 163, 161, -1, 160, 162, 163, 161, -1, 193,
2463 164, -1, 193, -1, 194, 153, 193, -1, 194, -1,
2464 194, 153, 37, -1, 37, -1, -1, 191, 157, 198,
2465 159, -1, 191, 157, 159, -1, 191, 165, 24, -1,
2466 191, 160, 198, 161, -1, 191, 162, 198, 163, -1,
2467 191, 162, 163, -1, 191, 160, 162, 198, 163, 161,
2468 -1, 191, 160, 162, 163, 161, -1, 191, 38, -1,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002469 191, 39, -1, 191, 229, -1, 191, 197, -1, 191,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002470 26, -1, 176, 168, -1, 177, 4, -1, 9, 27,
2471 -1, 9, 28, -1, 179, 7, -1, 175, 155, 196,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002472 36, 191, 156, -1, 110, 155, 196, 244, 156, -1,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002473 112, 155, 196, 153, 196, 153, 196, 156, -1, 169,
2474 155, 196, 153, 196, 156, -1, 170, 155, 196, 153,
2475 196, 156, -1, 171, 155, 196, 153, 196, 156, -1,
2476 103, 172, 155, 196, 153, 196, 156, -1, 104, 173,
2477 155, 196, 153, 196, 156, -1, 174, 155, 196, 153,
2478 196, 156, -1, 114, 155, 196, 153, 196, 156, -1,
2479 115, 155, 196, 153, 196, 153, 196, 156, -1, 116,
2480 155, 196, 153, 196, 153, 196, 156, -1, 198, 153,
2481 196, -1, 196, -1, 32, -1, 33, -1, 201, -1,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002482 201, 222, -1, 201, 224, -1, 201, 62, 61, 207,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002483 -1, 201, 25, -1, 202, -1, 202, 180, 20, 189,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002484 -1, 202, 224, -1, 202, 62, 61, 207, -1, -1,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002485 202, 180, 181, 199, 196, 203, 187, -1, -1, 202,
2486 180, 50, 199, 191, 204, 187, -1, -1, 202, 180,
2487 45, 199, 191, 205, 187, -1, -1, 202, 180, 47,
2488 199, 191, 206, 187, -1, 202, 51, 209, -1, 202,
2489 58, 152, 210, -1, -1, 24, -1, 56, -1, 55,
2490 -1, 53, 152, 208, -1, 54, 152, 4, -1, 52,
2491 152, 24, -1, 71, 152, 24, -1, 157, 211, 159,
2492 -1, 211, 153, 24, -1, 24, -1, -1, 22, -1,
2493 24, -1, 212, -1, -1, 191, 213, -1, 215, 153,
2494 214, -1, 214, -1, 215, -1, 215, 153, 37, -1,
2495 37, -1, -1, 182, 189, 212, 155, 216, 156, 186,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002496 183, -1, 29, -1, 162, -1, -1, 181, 220, 217,
2497 218, -1, 30, -1, 163, -1, 232, 221, -1, -1,
2498 45, -1, 47, -1, -1, -1, 31, 225, 223, 226,
2499 217, -1, -1, 63, -1, 3, -1, 4, -1, 7,
2500 -1, 27, -1, 28, -1, 38, -1, 39, -1, 26,
2501 -1, 160, 198, 161, -1, 197, -1, 61, 227, 24,
2502 153, 24, -1, 167, -1, 212, -1, 229, -1, 228,
2503 -1, 191, 230, -1, 232, 233, -1, 219, 233, -1,
2504 234, 180, 236, -1, 234, 238, -1, -1, 23, -1,
2505 77, -1, 78, -1, 72, 231, -1, 72, 8, -1,
2506 73, 21, 230, -1, 73, 9, 230, 153, 21, 230,
2507 153, 21, 230, -1, 74, 178, 230, 153, 21, 230,
2508 157, 237, 159, -1, 74, 178, 230, 153, 21, 230,
2509 157, 159, -1, 75, 182, 189, 230, 155, 241, 156,
2510 36, 21, 230, 235, 21, 230, -1, 235, -1, 76,
2511 -1, 237, 178, 228, 153, 21, 230, -1, 178, 228,
2512 153, 21, 230, -1, 180, 243, -1, 191, 157, 230,
2513 153, 230, 159, -1, 239, 153, 157, 230, 153, 230,
2514 159, -1, 231, -1, 240, 153, 231, -1, 240, -1,
2515 -1, 60, 59, -1, 59, -1, 169, 191, 230, 153,
2516 230, -1, 170, 191, 230, 153, 230, -1, 171, 191,
2517 230, 153, 230, -1, 103, 172, 191, 230, 153, 230,
2518 -1, 104, 173, 191, 230, 153, 230, -1, 49, 231,
2519 -1, 174, 231, 153, 231, -1, 175, 231, 36, 191,
2520 -1, 112, 231, 153, 231, 153, 231, -1, 113, 231,
2521 153, 191, -1, 117, 231, 153, 191, -1, 118, 231,
2522 153, 191, -1, 114, 231, 153, 231, -1, 115, 231,
2523 153, 231, 153, 231, -1, 116, 231, 153, 231, 153,
2524 231, -1, 111, 239, -1, 242, 182, 189, 230, 155,
2525 241, 156, -1, 246, -1, 153, 240, -1, -1, 35,
2526 -1, -1, 105, 191, 184, -1, 105, 191, 153, 15,
2527 230, 184, -1, 106, 191, 184, -1, 106, 191, 153,
2528 15, 230, 184, -1, 107, 231, -1, 245, 108, 191,
2529 230, -1, 245, 109, 231, 153, 191, 230, -1, 110,
2530 191, 230, 244, -1
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002531};
2532
2533/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
2534static const unsigned short int yyrline[] =
2535{
Reid Spencerbaba98a2007-04-11 12:10:58 +00002536 0, 1882, 1882, 1883, 1891, 1892, 1902, 1902, 1902, 1902,
2537 1902, 1902, 1902, 1902, 1902, 1902, 1902, 1906, 1906, 1906,
2538 1910, 1910, 1910, 1910, 1910, 1910, 1914, 1914, 1915, 1915,
2539 1916, 1916, 1917, 1917, 1918, 1918, 1922, 1922, 1923, 1923,
2540 1924, 1924, 1925, 1925, 1926, 1926, 1927, 1927, 1928, 1928,
2541 1929, 1930, 1933, 1933, 1933, 1933, 1937, 1937, 1937, 1937,
2542 1937, 1937, 1937, 1938, 1938, 1938, 1938, 1938, 1938, 1944,
2543 1944, 1944, 1944, 1948, 1948, 1948, 1948, 1952, 1952, 1956,
2544 1956, 1961, 1964, 1969, 1970, 1971, 1972, 1973, 1974, 1975,
2545 1976, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1997,
2546 1998, 2006, 2007, 2015, 2024, 2025, 2032, 2033, 2037, 2041,
2547 2057, 2058, 2065, 2066, 2073, 2081, 2081, 2081, 2081, 2081,
2548 2081, 2081, 2082, 2082, 2082, 2082, 2082, 2087, 2091, 2095,
2549 2100, 2109, 2127, 2133, 2146, 2157, 2161, 2174, 2178, 2192,
2550 2196, 2203, 2204, 2210, 2217, 2229, 2259, 2272, 2295, 2323,
2551 2345, 2356, 2378, 2389, 2398, 2403, 2462, 2469, 2477, 2484,
2552 2491, 2495, 2499, 2508, 2523, 2536, 2545, 2573, 2586, 2595,
2553 2601, 2607, 2618, 2624, 2630, 2641, 2642, 2651, 2652, 2664,
2554 2673, 2674, 2675, 2676, 2677, 2693, 2713, 2715, 2717, 2717,
2555 2724, 2724, 2732, 2732, 2740, 2740, 2749, 2751, 2753, 2758,
2556 2772, 2773, 2777, 2780, 2788, 2792, 2799, 2803, 2807, 2811,
2557 2819, 2819, 2823, 2824, 2828, 2836, 2841, 2849, 2850, 2857,
2558 2864, 2868, 3050, 3050, 3054, 3054, 3064, 3064, 3068, 3073,
2559 3074, 3075, 3079, 3080, 3079, 3092, 3093, 3098, 3099, 3100,
2560 3101, 3105, 3109, 3110, 3111, 3112, 3133, 3137, 3151, 3152,
2561 3157, 3157, 3165, 3175, 3178, 3187, 3198, 3203, 3212, 3223,
2562 3223, 3226, 3230, 3234, 3239, 3249, 3267, 3276, 3346, 3350,
2563 3357, 3369, 3384, 3414, 3424, 3434, 3438, 3445, 3446, 3450,
2564 3453, 3459, 3478, 3496, 3512, 3526, 3540, 3551, 3569, 3578,
2565 3587, 3594, 3615, 3639, 3645, 3651, 3657, 3673, 3763, 3771,
2566 3772, 3776, 3777, 3781, 3787, 3794, 3800, 3807, 3814, 3827,
2567 3853
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002568};
2569#endif
2570
2571#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
2572/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
2573 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
2574static const char *const yytname[] =
2575{
2576 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL",
2577 "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT",
2578 "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL",
2579 "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION",
2580 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
2581 "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO",
2582 "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE",
2583 "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
2584 "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE",
2585 "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE",
2586 "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK",
2587 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
2588 "RET", "BR", "SWITCH", "INVOKE", "UNREACHABLE", "UNWIND", "EXCEPT",
2589 "ADD", "SUB", "MUL", "DIV", "UDIV", "SDIV", "FDIV", "REM", "UREM",
2590 "SREM", "FREM", "AND", "OR", "XOR", "SHL", "SHR", "ASHR", "LSHR",
2591 "SETLE", "SETGE", "SETLT", "SETGT", "SETEQ", "SETNE", "ICMP", "FCMP",
2592 "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR", "PHI_TOK",
2593 "SELECT", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR",
2594 "VAARG_old", "VANEXT_old", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT",
2595 "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD",
2596 "UNO", "UEQ", "UNE", "CAST", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT",
2597 "FPTOUI", "FPTOSI", "UITOFP", "SITOFP", "PTRTOINT", "INTTOPTR",
2598 "BITCAST", "'='", "','", "'\\\\'", "'('", "')'", "'['", "'x'", "']'",
2599 "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept", "INTVAL",
2600 "EINT64VAL", "ArithmeticOps", "LogicalOps", "SetCondOps", "IPredicates",
2601 "FPredicates", "ShiftOps", "CastOps", "SIntType", "UIntType", "IntType",
2602 "FPType", "OptAssign", "OptLinkage", "OptCallingConv", "OptAlign",
2603 "OptCAlign", "SectionString", "OptSection", "GlobalVarAttributes",
2604 "GlobalVarAttribute", "TypesV", "UpRTypesV", "Types", "PrimType",
2605 "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal", "ConstExpr",
2606 "ConstVector", "GlobalType", "Module", "FunctionList", "ConstPool", "@1",
2607 "@2", "@3", "@4", "AsmBlock", "BigOrLittle", "TargetDefinition",
2608 "LibrariesDefinition", "LibList", "Name", "OptName", "ArgVal",
2609 "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader",
Reid Spencerd2920cd2007-03-21 17:27:53 +00002610 "@5", "END", "Function", "FnDeclareLinkage", "FunctionProto", "@6", "@7",
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002611 "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef",
2612 "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList",
2613 "Unwind", "BBTerminatorInst", "JumpTable", "Inst", "PHIList",
2614 "ValueRefList", "ValueRefListE", "OptTailCall", "InstVal", "IndexList",
2615 "OptVolatile", "MemoryInst", 0
2616};
2617#endif
2618
2619# ifdef YYPRINT
2620/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
2621 token YYLEX-NUM. */
2622static const unsigned short int yytoknum[] =
2623{
2624 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
2625 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
2626 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
2627 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
2628 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
2629 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
2630 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
2631 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
2632 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
2633 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
2634 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
2635 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
2636 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
2637 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
2638 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
2639 405, 406, 61, 44, 92, 40, 41, 91, 120, 93,
2640 60, 62, 123, 125, 42, 99
2641};
2642# endif
2643
2644/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
2645static const unsigned char yyr1[] =
2646{
2647 0, 166, 167, 167, 168, 168, 169, 169, 169, 169,
2648 169, 169, 169, 169, 169, 169, 169, 170, 170, 170,
2649 171, 171, 171, 171, 171, 171, 172, 172, 172, 172,
2650 172, 172, 172, 172, 172, 172, 173, 173, 173, 173,
2651 173, 173, 173, 173, 173, 173, 173, 173, 173, 173,
2652 173, 173, 174, 174, 174, 174, 175, 175, 175, 175,
2653 175, 175, 175, 175, 175, 175, 175, 175, 175, 176,
2654 176, 176, 176, 177, 177, 177, 177, 178, 178, 179,
2655 179, 180, 180, 181, 181, 181, 181, 181, 181, 181,
2656 181, 182, 182, 182, 182, 182, 182, 182, 182, 183,
2657 183, 184, 184, 185, 186, 186, 187, 187, 188, 188,
2658 189, 189, 190, 190, 191, 192, 192, 192, 192, 192,
2659 192, 192, 192, 192, 192, 192, 192, 193, 193, 193,
2660 193, 193, 193, 193, 193, 193, 193, 193, 193, 194,
2661 194, 195, 195, 195, 195, 196, 196, 196, 196, 196,
2662 196, 196, 196, 196, 196, 196, 196, 196, 196, 196,
2663 196, 196, 196, 197, 197, 197, 197, 197, 197, 197,
2664 197, 197, 197, 197, 197, 198, 198, 199, 199, 200,
2665 201, 201, 201, 201, 201, 202, 202, 202, 203, 202,
2666 204, 202, 205, 202, 206, 202, 202, 202, 202, 207,
2667 208, 208, 209, 209, 209, 209, 210, 211, 211, 211,
2668 212, 212, 213, 213, 214, 215, 215, 216, 216, 216,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002669 216, 217, 218, 218, 220, 219, 221, 221, 222, 223,
2670 223, 223, 225, 226, 224, 227, 227, 228, 228, 228,
2671 228, 228, 228, 228, 228, 228, 228, 228, 229, 229,
2672 230, 230, 231, 232, 232, 233, 234, 234, 234, 235,
2673 235, 236, 236, 236, 236, 236, 236, 236, 236, 236,
2674 237, 237, 238, 239, 239, 240, 240, 241, 241, 242,
2675 242, 243, 243, 243, 243, 243, 243, 243, 243, 243,
2676 243, 243, 243, 243, 243, 243, 243, 243, 243, 244,
2677 244, 245, 245, 246, 246, 246, 246, 246, 246, 246,
2678 246
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002679};
2680
2681/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
2682static const unsigned char yyr2[] =
2683{
2684 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
2685 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2686 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2687 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2688 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2689 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2690 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2691 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2692 1, 2, 0, 1, 1, 1, 1, 1, 1, 1,
2693 0, 0, 1, 1, 1, 1, 1, 1, 2, 0,
2694 2, 0, 3, 2, 0, 1, 0, 3, 1, 2,
2695 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2696 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2697 2, 4, 5, 5, 3, 2, 5, 4, 2, 1,
2698 3, 1, 3, 1, 0, 4, 3, 3, 4, 4,
2699 3, 6, 5, 2, 2, 2, 2, 2, 2, 2,
2700 2, 2, 2, 6, 5, 8, 6, 6, 6, 7,
2701 7, 6, 6, 8, 8, 3, 1, 1, 1, 1,
2702 2, 2, 4, 2, 1, 4, 2, 4, 0, 7,
2703 0, 7, 0, 7, 0, 7, 3, 4, 0, 1,
2704 1, 1, 3, 3, 3, 3, 3, 3, 1, 0,
2705 1, 1, 1, 0, 2, 3, 1, 1, 3, 1,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002706 0, 8, 1, 1, 0, 4, 1, 1, 2, 0,
2707 1, 1, 0, 0, 5, 0, 1, 1, 1, 1,
2708 1, 1, 1, 1, 1, 3, 1, 5, 1, 1,
2709 1, 1, 2, 2, 2, 3, 2, 0, 1, 1,
2710 1, 2, 2, 3, 9, 9, 8, 13, 1, 1,
2711 6, 5, 2, 6, 7, 1, 3, 1, 0, 2,
2712 1, 5, 5, 5, 6, 6, 2, 4, 4, 6,
2713 4, 4, 4, 4, 6, 6, 2, 7, 1, 2,
2714 0, 1, 0, 3, 6, 3, 6, 2, 4, 6,
2715 4
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002716};
2717
2718/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
2719 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
2720 means the default is an error. */
2721static const unsigned short int yydefact[] =
2722{
Reid Spencerd2920cd2007-03-21 17:27:53 +00002723 198, 0, 90, 184, 1, 183, 232, 83, 84, 85,
2724 86, 87, 88, 89, 0, 224, 257, 180, 181, 257,
2725 210, 211, 0, 0, 0, 90, 0, 186, 229, 0,
2726 91, 258, 254, 82, 226, 227, 228, 253, 0, 0,
2727 0, 0, 196, 0, 0, 0, 0, 0, 0, 0,
2728 81, 230, 231, 233, 199, 182, 0, 92, 93, 94,
2729 95, 96, 97, 0, 0, 302, 256, 0, 0, 0,
2730 0, 209, 197, 187, 2, 3, 111, 115, 116, 117,
2731 118, 119, 120, 121, 122, 123, 124, 125, 126, 128,
2732 0, 0, 0, 0, 248, 185, 0, 110, 127, 114,
2733 249, 129, 177, 178, 0, 0, 0, 0, 91, 98,
2734 0, 222, 223, 225, 301, 0, 280, 0, 0, 0,
2735 0, 91, 269, 259, 260, 6, 7, 8, 9, 10,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002736 11, 12, 13, 14, 15, 16, 17, 18, 19, 52,
2737 53, 54, 55, 20, 21, 22, 23, 24, 25, 0,
2738 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2739 0, 0, 0, 68, 56, 57, 58, 59, 60, 61,
2740 62, 63, 64, 65, 66, 67, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002741 0, 268, 255, 91, 272, 0, 298, 204, 201, 200,
2742 202, 203, 205, 208, 0, 130, 0, 0, 0, 113,
2743 135, 139, 0, 144, 138, 192, 194, 190, 115, 116,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002744 117, 118, 119, 120, 121, 122, 123, 124, 125, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002745 0, 0, 0, 188, 234, 0, 0, 286, 279, 262,
2746 261, 0, 0, 72, 76, 71, 75, 70, 74, 69,
2747 73, 77, 78, 0, 0, 26, 27, 28, 29, 30,
2748 31, 32, 33, 34, 35, 0, 50, 51, 46, 47,
2749 48, 49, 36, 37, 38, 39, 40, 41, 42, 43,
2750 44, 45, 0, 101, 101, 307, 0, 0, 296, 0,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002751 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002752 0, 0, 0, 0, 0, 206, 0, 0, 0, 0,
2753 0, 134, 143, 141, 0, 106, 106, 106, 160, 161,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002754 4, 5, 158, 159, 162, 157, 153, 154, 0, 0,
2755 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002756 0, 0, 0, 0, 156, 155, 106, 220, 237, 238,
2757 239, 244, 240, 241, 242, 243, 235, 0, 246, 251,
2758 250, 252, 0, 263, 0, 0, 0, 0, 0, 303,
2759 0, 305, 300, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002760 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002761 207, 112, 112, 137, 0, 140, 0, 131, 0, 193,
2762 195, 191, 0, 0, 0, 0, 0, 0, 0, 146,
2763 176, 0, 0, 0, 150, 0, 147, 0, 0, 0,
2764 0, 0, 189, 219, 213, 216, 217, 0, 236, 0,
2765 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2766 310, 0, 0, 0, 290, 293, 0, 0, 291, 292,
2767 0, 0, 0, 287, 288, 0, 308, 0, 132, 133,
2768 136, 142, 0, 0, 108, 106, 0, 0, 300, 0,
2769 0, 0, 0, 0, 145, 135, 114, 0, 148, 149,
2770 0, 0, 0, 0, 0, 212, 214, 0, 104, 0,
2771 245, 0, 0, 278, 0, 0, 101, 102, 101, 275,
2772 299, 0, 0, 0, 0, 0, 281, 282, 283, 278,
2773 0, 103, 109, 107, 0, 0, 0, 0, 0, 0,
2774 0, 175, 152, 0, 0, 0, 0, 0, 0, 218,
2775 215, 105, 99, 0, 0, 0, 277, 0, 284, 285,
2776 0, 304, 306, 0, 0, 0, 289, 294, 295, 0,
2777 309, 0, 0, 164, 0, 0, 0, 0, 151, 0,
2778 0, 0, 0, 0, 0, 221, 247, 0, 0, 0,
2779 276, 273, 0, 297, 0, 0, 0, 172, 0, 0,
2780 166, 167, 168, 171, 163, 100, 0, 266, 0, 0,
2781 0, 274, 169, 170, 0, 0, 0, 264, 0, 265,
2782 0, 0, 165, 173, 174, 0, 0, 0, 0, 0,
2783 0, 271, 0, 0, 270, 267
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002784};
2785
2786/* YYDEFGOTO[NTERM-NUM]. */
2787static const short int yydefgoto[] =
2788{
Reid Spencerd2920cd2007-03-21 17:27:53 +00002789 -1, 94, 312, 329, 330, 331, 255, 272, 332, 333,
2790 219, 220, 243, 221, 25, 15, 63, 555, 359, 454,
2791 522, 389, 455, 95, 96, 222, 98, 99, 202, 304,
2792 400, 348, 401, 104, 1, 2, 3, 336, 307, 305,
2793 306, 55, 190, 42, 72, 194, 100, 476, 415, 416,
2794 417, 64, 113, 16, 30, 36, 17, 53, 18, 28,
2795 108, 419, 349, 101, 351, 489, 19, 32, 33, 181,
2796 182, 579, 66, 278, 526, 527, 183, 184, 430, 185,
2797 186
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002798};
2799
2800/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2801 STATE-NUM. */
Reid Spencerd2920cd2007-03-21 17:27:53 +00002802#define YYPACT_NINF -542
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002803static const short int yypact[] =
2804{
Reid Spencerd2920cd2007-03-21 17:27:53 +00002805 -542, 13, 162, 567, -542, -542, -542, -542, -542, -542,
2806 -542, -542, -542, -542, 83, -542, 19, -542, -542, -14,
2807 -542, -542, 50, -87, 87, 233, 27, -542, 123, 141,
2808 175, -542, -542, 98, -542, -542, -542, -542, 33, 40,
2809 66, 68, -542, 14, 141, 1265, 156, 156, 156, 156,
2810 -542, -542, -542, -542, -542, -542, 221, -542, -542, -542,
2811 -542, -542, -542, 1265, -19, 1479, -542, 204, 135, 226,
2812 227, 235, -542, -542, -542, -542, 81, -542, -542, -542,
2813 -542, -542, -542, -542, -542, -542, -542, -542, -542, -542,
2814 256, 257, 4, 15, -542, -542, 108, -542, -542, 12,
2815 -542, -542, -542, -542, 1306, 1306, 1306, 1326, 175, -542,
2816 98, -542, -542, -542, -542, 1306, -542, 205, 1367, 116,
2817 479, 175, -542, -542, -542, -542, -542, -542, -542, -542,
2818 -542, -542, -542, -542, -542, -542, -542, -542, -542, -542,
2819 -542, -542, -542, -542, -542, -542, -542, -542, -542, 355,
2820 429, 1306, 1306, 1306, 1306, 1306, 1306, 1306, 1306, 1306,
2821 1306, 1306, 1306, -542, -542, -542, -542, -542, -542, -542,
2822 -542, -542, -542, -542, -542, -542, 1306, 1306, 1306, 1306,
2823 1306, -542, -542, 175, -542, 86, -542, -542, -542, -542,
2824 -542, -542, -542, -542, -13, -542, 110, 111, 75, -542,
2825 -542, 12, -81, 1046, -542, -542, -542, -542, 174, 208,
2826 266, 210, 267, 212, 268, 230, 277, 275, 278, 246,
2827 280, 279, 566, -542, -542, 136, 766, -542, -542, 81,
2828 -542, 766, 766, -542, -542, -542, -542, -542, -542, -542,
2829 -542, -542, -542, 766, 1265, -542, -542, -542, -542, -542,
2830 -542, -542, -542, -542, -542, 1306, -542, -542, -542, -542,
2831 -542, -542, -542, -542, -542, -542, -542, -542, -542, -542,
2832 -542, -542, 1306, 137, 145, -542, 766, 132, 146, 147,
2833 148, 149, 151, 152, 158, 160, 766, 766, 766, 161,
2834 281, 1265, 1306, 1306, 291, -542, 1306, 1306, 155, -27,
2835 1306, -542, -542, 165, 163, 176, 176, 176, -542, -542,
2836 -542, -542, -542, -542, -542, -542, -542, -542, 355, 429,
2837 172, 177, 178, 179, 182, 1087, 1387, 529, 311, 184,
2838 185, 186, 188, 189, -542, -542, 176, 1107, -542, -542,
2839 -542, -542, -542, -542, -542, -542, 282, 1326, -542, -542,
2840 -542, -542, 193, -542, 194, 766, 766, 766, 7, -542,
2841 20, -542, 195, 766, 192, 1306, 1306, 1306, 1306, 1306,
2842 1306, 1306, 200, 201, 206, 1306, 1306, 766, 766, 207,
2843 -542, -59, -149, -542, 196, 12, 1148, -542, 44, -542,
2844 -542, -542, 203, 211, 1326, 1326, 1326, 1326, 1326, -542,
2845 -542, -8, 741, -82, -542, 10, -542, 1326, 1326, 1326,
2846 1326, 1326, -542, -542, 98, -542, 214, 209, -542, 337,
2847 -34, 342, 348, 215, 218, 219, 766, 371, 766, 1306,
2848 -542, 223, 766, 224, -542, -542, 225, 234, -542, -542,
2849 766, 766, 766, -542, -542, 228, -542, 1306, -542, -542,
2850 -542, -542, 362, 375, -542, 176, 1326, 1326, 195, 236,
2851 237, 240, 243, 1326, -542, 238, -25, 11, -542, -542,
2852 244, 245, 247, 250, 352, -542, -542, 1205, 370, 252,
2853 -542, 766, 766, 1306, 766, 766, 258, -542, 258, -542,
2854 259, 766, 264, 1306, 1306, 1306, -542, -542, -542, 1306,
2855 766, -542, -542, -542, 270, 271, 263, 1326, 1326, 1326,
2856 1326, -542, -542, 260, 1326, 1326, 1326, 1326, 1306, -542,
2857 -542, -542, 368, 402, 274, 276, 259, 287, -542, -542,
2858 374, -542, -542, 1306, 285, 766, -542, -542, -542, 290,
2859 -542, 1326, 1326, -542, 283, 295, 284, 294, -542, 296,
2860 297, 299, 302, 303, 430, -542, -542, 414, 41, 425,
2861 -542, -542, 305, -542, 306, 310, 1326, -542, 1326, 1326,
2862 -542, -542, -542, -542, -542, -542, 766, -542, 893, 144,
2863 448, -542, -542, -542, 314, 315, 316, -542, 331, -542,
2864 893, 766, -542, -542, -542, 464, 334, 180, 766, 481,
2865 482, -542, 766, 766, -542, -542
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002866};
2867
2868/* YYPGOTO[NTERM-NUM]. */
2869static const short int yypgoto[] =
2870{
Reid Spencerd2920cd2007-03-21 17:27:53 +00002871 -542, -542, -542, 435, 439, 441, 191, 197, 442, 445,
2872 -119, -116, -541, -542, 478, 489, -107, -542, -267, 37,
2873 -542, -238, -542, -60, -542, -45, -542, -74, -51, -542,
2874 -101, 300, -252, 134, -542, -542, -542, -542, -542, -542,
2875 -542, 473, -542, -542, -542, -542, 8, -542, 46, -542,
2876 -542, 410, -542, -542, -542, -542, -542, -542, 518, -542,
2877 -542, -542, -528, 142, -90, -113, -542, 505, -542, -72,
2878 -542, -542, -542, -542, 97, 28, -542, -542, 70, -542,
2879 -542
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002880};
2881
2882/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2883 positive, shift that token. If negative, reduce the rule which
2884 number is the opposite. If zero, do what YYDEFACT says.
2885 If YYTABLE_NINF, syntax error. */
2886#define YYTABLE_NINF -180
2887static const short int yytable[] =
2888{
Reid Spencerd2920cd2007-03-21 17:27:53 +00002889 97, 241, 227, 110, 242, 230, 223, 361, 197, 31,
2890 111, 26, 449, 4, 244, 204, 34, 578, 97, 201,
2891 74, 75, 426, 199, 77, 78, 79, 80, 81, 82,
2892 83, 84, 85, 86, 87, 428, 88, 20, 590, 21,
2893 275, 26, 31, 279, 280, 281, 282, 283, 284, 285,
2894 588, 233, 234, 235, 236, 237, 238, 239, 240, 205,
2895 206, 207, 596, 89, 427, 43, 289, 290, 390, 391,
2896 226, 463, 300, 226, 403, 405, 291, 427, 452, 468,
2897 74, 75, 301, 199, 77, 78, 79, 80, 81, 82,
2898 83, 84, 85, 86, 87, 420, 88, 20, 412, 21,
2899 448, 453, 38, 39, 40, 204, 273, 274, 226, 276,
2900 277, 226, 226, 226, 226, 226, 226, 226, 225, 463,
2901 20, 41, 21, 89, 201, 231, 300, 480, -139, 201,
2902 -112, 286, 287, 288, 226, 226, 384, 232, -139, 204,
2903 294, 352, 353, 112, 29, 463, 295, 299, 44, 35,
2904 467, 464, 303, 354, 233, 234, 235, 236, 237, 238,
2905 239, 240, -179, 463, 463, 54, 198, -112, 51, 90,
2906 52, 71, 91, 469, 513, 92, 204, 93, 200, 50,
2907 379, 105, 106, 107, 355, 67, 362, 5, 102, 103,
2908 188, 189, 68, 6, 292, 293, 372, 373, 374, 97,
2909 577, 308, 309, 7, 8, 9, 10, 11, 12, 13,
2910 356, -72, -72, -71, -71, -70, -70, 503, 69, 531,
2911 70, 532, 381, 382, 14, 109, 385, 357, 187, 90,
2912 191, 377, 91, -69, -69, 92, -113, 93, 298, 56,
2913 57, 58, 59, 60, 61, 62, 97, 378, 226, 310,
2914 311, 192, 433, 45, 435, 436, 437, 123, 124, 193,
2915 195, 196, 443, 203, 228, 423, 424, 425, 296, 297,
2916 -76, -75, -74, 431, 7, 8, 9, 10, 46, 12,
2917 47, -73, -79, 48, 313, -80, 314, 445, 446, 363,
2918 358, 337, 414, 458, 459, 460, 461, 462, 360, 364,
2919 365, 366, 367, 589, 368, 369, 470, 471, 472, 473,
2920 474, 370, 385, 371, 375, 380, 383, 376, 386, 387,
2921 226, 434, 226, 226, 226, 438, 439, 394, 466, 388,
2922 226, 444, 395, 396, 397, 406, 486, 398, 488, 407,
2923 408, 409, 492, 410, 411, 418, 421, 422, 429, 432,
2924 496, 497, 498, 440, 441, 504, 505, 450, 456, 442,
2925 447, 479, 511, 481, 335, 478, 457, 477, 350, 482,
2926 483, 484, 485, 350, 350, 487, 491, 493, 494, 502,
2927 536, 537, 538, 499, 226, 350, 501, 495, 518, 507,
2928 508, 524, 525, 509, 528, 529, 510, 514, 515, 512,
2929 516, 534, 500, 517, 452, 523, 544, 545, 546, 547,
2930 540, 530, 533, 549, 550, 551, 552, 535, 350, 543,
2931 560, 548, 475, 541, 542, 554, 556, 557, 350, 350,
2932 350, 427, 414, 558, 575, 576, 566, 568, 226, 241,
2933 564, 565, 242, 559, 561, 562, 563, 569, 226, 226,
2934 226, 567, 570, 571, 226, 572, 256, 257, 573, 574,
2935 241, 580, 582, 242, 581, 584, 583, 585, 586, 591,
2936 592, 593, 594, 553, 245, 246, 247, 248, 249, 250,
2937 251, 252, 253, 254, 595, 598, 587, 599, 226, 233,
2938 234, 235, 236, 237, 238, 239, 240, 350, 350, 350,
2939 176, 597, 602, 603, 177, 350, 178, 179, 601, 392,
2940 180, 65, 604, 605, 49, 521, 393, 73, 224, 350,
2941 350, 27, 334, 520, 37, 600, 490, 539, 506, 0,
2942 0, 0, 0, 0, 74, 75, 0, 199, 208, 209,
2943 210, 211, 212, 213, 214, 215, 216, 217, 218, 0,
2944 88, 20, 0, 21, 258, 259, 260, 261, 262, 263,
2945 264, 265, 266, 267, 268, 269, 270, 271, 350, 0,
2946 350, 74, 75, 0, 350, 0, 0, 89, 0, 0,
2947 0, 0, 350, 350, 350, 0, 0, -82, 20, 20,
2948 21, 21, 315, 0, 0, 0, 0, 0, 6, -82,
2949 -82, 0, 0, 0, 316, 317, 0, 0, -82, -82,
2950 -82, -82, -82, -82, -82, 0, 0, -82, 22, 0,
2951 0, 0, 0, 350, 350, 23, 350, 350, 0, 24,
2952 0, 0, 0, 350, 0, 0, 0, 0, 0, 0,
2953 0, 0, 350, 0, 0, 125, 126, 127, 128, 129,
2954 130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
2955 140, 141, 142, 143, 144, 145, 146, 147, 148, 318,
2956 319, 0, 0, 0, 0, 0, 320, 350, 321, 0,
2957 322, 323, 324, 90, 0, 0, 91, 0, 0, 92,
2958 0, 93, 404, 0, 0, 0, 0, 0, 0, 0,
2959 0, 0, 0, 0, 0, 163, 164, 165, 166, 167,
2960 168, 169, 170, 171, 172, 173, 174, 175, 350, 0,
2961 0, 0, 0, 325, 0, 0, 326, 0, 327, 0,
2962 0, 328, 0, 350, 0, 0, 0, 0, 0, 0,
2963 350, 0, 0, 0, 350, 350, 74, 75, 0, 199,
2964 208, 209, 210, 211, 212, 213, 214, 215, 216, 217,
2965 218, 0, 88, 20, 0, 21, 0, 0, 0, 338,
2966 339, 74, 75, 340, 0, 0, 0, 0, 0, 0,
2967 0, 0, 0, 0, 0, 0, 0, 0, 20, 89,
2968 21, 0, 341, 342, 343, 0, 0, 0, 0, 0,
2969 0, 0, 0, 0, 344, 345, 0, 0, 0, 0,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002970 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002971 0, 0, 0, 0, 0, 0, 0, 346, 0, 0,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002972 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002973 0, 0, 0, 0, 0, 125, 126, 127, 128, 129,
2974 130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
2975 140, 141, 142, 143, 144, 145, 146, 147, 148, 318,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002976 319, 0, 0, 0, 0, 0, 320, 0, 321, 0,
2977 322, 323, 324, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002978 0, 0, 0, 0, 0, 90, 338, 339, 91, 0,
2979 340, 92, 0, 93, 465, 163, 164, 165, 166, 167,
2980 168, 169, 170, 171, 172, 173, 174, 175, 0, 341,
2981 342, 343, 0, 0, 0, 0, 347, 0, 0, 0,
2982 0, 344, 345, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00002983 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00002984 0, 0, 0, 0, 346, 0, 0, 0, 0, 0,
2985 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2986 0, 0, 125, 126, 127, 128, 129, 130, 131, 132,
2987 133, 134, 135, 136, 137, 138, 139, 140, 141, 142,
2988 143, 144, 145, 146, 147, 148, 318, 319, 0, 0,
2989 0, 0, 0, 320, 0, 321, 0, 322, 323, 324,
2990 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2991 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2992 0, 0, 163, 164, 165, 166, 167, 168, 169, 170,
2993 171, 172, 173, 174, 175, 0, 0, 0, 0, 0,
2994 0, 74, 75, 347, 199, 77, 78, 79, 80, 81,
2995 82, 83, 84, 85, 86, 87, 0, 88, 20, 0,
2996 21, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2997 0, 0, 0, 302, 0, 0, 0, 0, 0, 0,
2998 0, 0, 74, 75, 89, 199, 208, 209, 210, 211,
2999 212, 213, 214, 215, 216, 217, 218, 0, 88, 20,
3000 0, 21, 74, 75, 0, 199, 77, 78, 79, 80,
3001 81, 82, 83, 84, 85, 86, 87, 0, 88, 20,
3002 0, 21, 0, 0, 0, 89, 0, 0, 0, 0,
3003 0, 0, 0, 0, 413, 0, 0, 0, 0, 0,
3004 0, 0, 0, 74, 75, 89, 199, 77, 78, 79,
3005 80, 81, 82, 83, 84, 85, 86, 87, 0, 88,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003006 20, 0, 21, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003007 0, 0, 0, 0, 0, 451, 0, 0, 0, 0,
3008 0, 0, 0, 0, 0, 0, 89, 0, 0, 0,
3009 90, 0, 0, 91, 0, 0, 92, 0, 93, 0,
3010 74, 75, 0, 199, 77, 78, 79, 80, 81, 82,
3011 83, 84, 85, 86, 87, 0, 88, 20, 0, 21,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003012 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003013 0, 90, 519, 0, 91, 0, 399, 92, 0, 93,
3014 0, 0, 0, 89, 0, 0, 0, 0, 0, 0,
3015 0, 90, 0, 0, 91, 0, 0, 92, 0, 93,
3016 74, 75, 0, 76, 77, 78, 79, 80, 81, 82,
3017 83, 84, 85, 86, 87, 0, 88, 20, 0, 21,
3018 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3019 0, 0, 90, 0, 0, 91, 0, 0, 92, 0,
3020 93, 74, 75, 89, 199, 77, 78, 79, 80, 81,
3021 82, 83, 84, 85, 86, 87, 0, 88, 20, 0,
3022 21, 74, 75, 0, 199, 208, 209, 210, 211, 212,
3023 213, 214, 215, 216, 217, 218, 0, 88, 20, 0,
3024 21, 0, 0, 0, 89, 0, 0, 0, 0, 90,
3025 0, 0, 91, 0, 0, 92, 0, 93, 0, 0,
3026 0, 0, 74, 75, 89, 229, 77, 78, 79, 80,
3027 81, 82, 83, 84, 85, 86, 87, 0, 88, 20,
3028 0, 21, 74, 75, 0, 199, 208, 209, 210, 211,
3029 212, 213, 214, 215, 216, 217, 218, 0, 88, 20,
3030 0, 21, 0, 0, 0, 89, 0, 0, 0, 90,
3031 0, 0, 91, 0, 0, 92, 0, 93, 0, 0,
3032 0, 0, 0, 0, 0, 89, 0, 0, 0, 0,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003033 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3034 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003035 90, 0, 0, 91, 0, 0, 92, 0, 93, 0,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003036 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003037 90, 0, 0, 91, 0, 0, 92, 0, 93, 0,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003038 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3039 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003040 0, 0, 0, 0, 114, 0, 0, 0, 0, 0,
3041 0, 90, 0, 0, 91, 0, 0, 92, 115, 93,
3042 0, 0, 0, 0, 0, 0, 0, 0, 116, 117,
3043 0, 90, 0, 0, 91, 0, 0, 92, 0, 402,
3044 0, 118, 119, 120, 121, 122, 123, 124, 125, 126,
3045 127, 128, 129, 130, 131, 132, 133, 134, 135, 136,
3046 137, 138, 139, 140, 141, 142, 143, 144, 145, 146,
3047 147, 148, 149, 150, 151, 152, 153, 0, 0, 154,
3048 155, 156, 157, 158, 159, 160, 161, 162, 0, 0,
3049 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3050 0, 0, 0, 0, 0, 0, 0, 0, 163, 164,
3051 165, 166, 167, 168, 169, 170, 171, 172, 173, 174,
3052 175
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003053};
3054
3055static const short int yycheck[] =
3056{
Reid Spencerd2920cd2007-03-21 17:27:53 +00003057 45, 120, 115, 63, 120, 118, 107, 274, 4, 23,
3058 29, 3, 161, 0, 121, 164, 30, 558, 63, 93,
3059 5, 6, 15, 8, 9, 10, 11, 12, 13, 14,
3060 15, 16, 17, 18, 19, 15, 21, 22, 579, 24,
3061 153, 33, 23, 156, 157, 158, 159, 160, 161, 162,
3062 578, 10, 11, 12, 13, 14, 15, 16, 17, 104,
3063 105, 106, 590, 48, 57, 152, 179, 180, 306, 307,
3064 115, 153, 153, 118, 326, 327, 183, 57, 34, 161,
3065 5, 6, 163, 8, 9, 10, 11, 12, 13, 14,
3066 15, 16, 17, 18, 19, 347, 21, 22, 336, 24,
3067 159, 57, 52, 53, 54, 164, 151, 152, 153, 154,
3068 155, 156, 157, 158, 159, 160, 161, 162, 110, 153,
3069 22, 71, 24, 48, 198, 9, 153, 161, 153, 203,
3070 155, 176, 177, 178, 179, 180, 163, 21, 163, 164,
3071 153, 231, 232, 162, 61, 153, 159, 198, 61, 163,
3072 402, 159, 203, 243, 10, 11, 12, 13, 14, 15,
3073 16, 17, 0, 153, 153, 24, 162, 155, 45, 154,
3074 47, 157, 157, 163, 163, 160, 164, 162, 163, 152,
3075 293, 47, 48, 49, 244, 152, 276, 25, 32, 33,
3076 55, 56, 152, 31, 108, 109, 286, 287, 288, 244,
3077 159, 27, 28, 41, 42, 43, 44, 45, 46, 47,
3078 255, 3, 4, 3, 4, 3, 4, 455, 152, 486,
3079 152, 488, 296, 297, 62, 4, 300, 272, 24, 154,
3080 4, 291, 157, 3, 4, 160, 155, 162, 163, 64,
3081 65, 66, 67, 68, 69, 70, 291, 292, 293, 3,
3082 4, 24, 365, 20, 367, 368, 369, 77, 78, 24,
3083 4, 4, 375, 155, 59, 355, 356, 357, 158, 158,
3084 4, 4, 4, 363, 41, 42, 43, 44, 45, 46,
3085 47, 4, 7, 50, 4, 7, 7, 377, 378, 157,
3086 153, 155, 337, 394, 395, 396, 397, 398, 153, 153,
3087 153, 153, 153, 159, 153, 153, 407, 408, 409, 410,
3088 411, 153, 386, 153, 153, 24, 161, 36, 153, 156,
3089 365, 366, 367, 368, 369, 370, 371, 155, 402, 153,
3090 375, 376, 155, 155, 155, 24, 426, 155, 428, 155,
3091 155, 155, 432, 155, 155, 63, 153, 153, 153, 157,
3092 440, 441, 442, 153, 153, 456, 457, 161, 155, 153,
3093 153, 24, 463, 21, 222, 156, 155, 153, 226, 21,
3094 155, 153, 153, 231, 232, 4, 153, 153, 153, 4,
3095 493, 494, 495, 155, 429, 243, 24, 153, 36, 153,
3096 153, 481, 482, 153, 484, 485, 153, 153, 153, 161,
3097 153, 491, 447, 153, 34, 153, 507, 508, 509, 510,
3098 500, 153, 153, 514, 515, 516, 517, 153, 276, 156,
3099 533, 161, 414, 153, 153, 57, 24, 153, 286, 287,
3100 288, 57, 477, 157, 4, 21, 153, 153, 483, 558,
3101 541, 542, 558, 156, 159, 535, 156, 153, 493, 494,
3102 495, 156, 156, 156, 499, 156, 27, 28, 156, 156,
3103 579, 36, 156, 579, 159, 566, 156, 568, 569, 21,
3104 156, 156, 156, 518, 119, 120, 121, 122, 123, 124,
3105 125, 126, 127, 128, 153, 21, 576, 153, 533, 10,
3106 11, 12, 13, 14, 15, 16, 17, 355, 356, 357,
3107 65, 591, 21, 21, 65, 363, 65, 65, 598, 318,
3108 65, 33, 602, 603, 25, 478, 319, 44, 108, 377,
3109 378, 3, 222, 477, 19, 597, 429, 499, 458, -1,
3110 -1, -1, -1, -1, 5, 6, -1, 8, 9, 10,
3111 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
3112 21, 22, -1, 24, 125, 126, 127, 128, 129, 130,
3113 131, 132, 133, 134, 135, 136, 137, 138, 426, -1,
3114 428, 5, 6, -1, 432, -1, -1, 48, -1, -1,
3115 -1, -1, 440, 441, 442, -1, -1, 20, 22, 22,
3116 24, 24, 26, -1, -1, -1, -1, -1, 31, 32,
3117 33, -1, -1, -1, 38, 39, -1, -1, 41, 42,
3118 43, 44, 45, 46, 47, -1, -1, 50, 51, -1,
3119 -1, -1, -1, 481, 482, 58, 484, 485, -1, 62,
3120 -1, -1, -1, 491, -1, -1, -1, -1, -1, -1,
3121 -1, -1, 500, -1, -1, 79, 80, 81, 82, 83,
3122 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
3123 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
3124 104, -1, -1, -1, -1, -1, 110, 535, 112, -1,
3125 114, 115, 116, 154, -1, -1, 157, -1, -1, 160,
3126 -1, 162, 163, -1, -1, -1, -1, -1, -1, -1,
3127 -1, -1, -1, -1, -1, 139, 140, 141, 142, 143,
3128 144, 145, 146, 147, 148, 149, 150, 151, 576, -1,
3129 -1, -1, -1, 157, -1, -1, 160, -1, 162, -1,
3130 -1, 165, -1, 591, -1, -1, -1, -1, -1, -1,
3131 598, -1, -1, -1, 602, 603, 5, 6, -1, 8,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003132 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003133 19, -1, 21, 22, -1, 24, -1, -1, -1, 3,
3134 4, 5, 6, 7, -1, -1, -1, -1, -1, -1,
3135 -1, -1, -1, -1, -1, -1, -1, -1, 22, 48,
3136 24, -1, 26, 27, 28, -1, -1, -1, -1, -1,
3137 -1, -1, -1, -1, 38, 39, -1, -1, -1, -1,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003138 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3139 -1, -1, -1, -1, -1, -1, -1, 61, -1, -1,
3140 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3141 -1, -1, -1, -1, -1, 79, 80, 81, 82, 83,
3142 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
3143 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
3144 104, -1, -1, -1, -1, -1, 110, -1, 112, -1,
3145 114, 115, 116, -1, -1, -1, -1, -1, -1, -1,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003146 -1, -1, -1, -1, -1, 154, 3, 4, 157, -1,
3147 7, 160, -1, 162, 163, 139, 140, 141, 142, 143,
3148 144, 145, 146, 147, 148, 149, 150, 151, -1, 26,
3149 27, 28, -1, -1, -1, -1, 160, -1, -1, -1,
3150 -1, 38, 39, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003151 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003152 -1, -1, -1, -1, 61, -1, -1, -1, -1, -1,
3153 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3154 -1, -1, 79, 80, 81, 82, 83, 84, 85, 86,
3155 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
3156 97, 98, 99, 100, 101, 102, 103, 104, -1, -1,
3157 -1, -1, -1, 110, -1, 112, -1, 114, 115, 116,
3158 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3159 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3160 -1, -1, 139, 140, 141, 142, 143, 144, 145, 146,
3161 147, 148, 149, 150, 151, -1, -1, -1, -1, -1,
3162 -1, 5, 6, 160, 8, 9, 10, 11, 12, 13,
3163 14, 15, 16, 17, 18, 19, -1, 21, 22, -1,
3164 24, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3165 -1, -1, -1, 37, -1, -1, -1, -1, -1, -1,
3166 -1, -1, 5, 6, 48, 8, 9, 10, 11, 12,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003167 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003168 -1, 24, 5, 6, -1, 8, 9, 10, 11, 12,
3169 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
3170 -1, 24, -1, -1, -1, 48, -1, -1, -1, -1,
3171 -1, -1, -1, -1, 37, -1, -1, -1, -1, -1,
3172 -1, -1, -1, 5, 6, 48, 8, 9, 10, 11,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003173 12, 13, 14, 15, 16, 17, 18, 19, -1, 21,
3174 22, -1, 24, -1, -1, -1, -1, -1, -1, -1,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003175 -1, -1, -1, -1, -1, 37, -1, -1, -1, -1,
3176 -1, -1, -1, -1, -1, -1, 48, -1, -1, -1,
3177 154, -1, -1, 157, -1, -1, 160, -1, 162, -1,
3178 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
3179 15, 16, 17, 18, 19, -1, 21, 22, -1, 24,
3180 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3181 -1, 154, 37, -1, 157, -1, 159, 160, -1, 162,
3182 -1, -1, -1, 48, -1, -1, -1, -1, -1, -1,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003183 -1, 154, -1, -1, 157, -1, -1, 160, -1, 162,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003184 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
3185 15, 16, 17, 18, 19, -1, 21, 22, -1, 24,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003186 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003187 -1, -1, 154, -1, -1, 157, -1, -1, 160, -1,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003188 162, 5, 6, 48, 8, 9, 10, 11, 12, 13,
3189 14, 15, 16, 17, 18, 19, -1, 21, 22, -1,
3190 24, 5, 6, -1, 8, 9, 10, 11, 12, 13,
3191 14, 15, 16, 17, 18, 19, -1, 21, 22, -1,
3192 24, -1, -1, -1, 48, -1, -1, -1, -1, 154,
3193 -1, -1, 157, -1, -1, 160, -1, 162, -1, -1,
3194 -1, -1, 5, 6, 48, 8, 9, 10, 11, 12,
3195 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
3196 -1, 24, 5, 6, -1, 8, 9, 10, 11, 12,
3197 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
3198 -1, 24, -1, -1, -1, 48, -1, -1, -1, 154,
3199 -1, -1, 157, -1, -1, 160, -1, 162, -1, -1,
3200 -1, -1, -1, -1, -1, 48, -1, -1, -1, -1,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003201 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3202 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003203 154, -1, -1, 157, -1, -1, 160, -1, 162, -1,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003204 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003205 154, -1, -1, 157, -1, -1, 160, -1, 162, -1,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003206 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3207 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003208 -1, -1, -1, -1, 35, -1, -1, -1, -1, -1,
3209 -1, 154, -1, -1, 157, -1, -1, 160, 49, 162,
3210 -1, -1, -1, -1, -1, -1, -1, -1, 59, 60,
3211 -1, 154, -1, -1, 157, -1, -1, 160, -1, 162,
3212 -1, 72, 73, 74, 75, 76, 77, 78, 79, 80,
3213 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
3214 91, 92, 93, 94, 95, 96, 97, 98, 99, 100,
3215 101, 102, 103, 104, 105, 106, 107, -1, -1, 110,
3216 111, 112, 113, 114, 115, 116, 117, 118, -1, -1,
3217 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
3218 -1, -1, -1, -1, -1, -1, -1, -1, 139, 140,
3219 141, 142, 143, 144, 145, 146, 147, 148, 149, 150,
3220 151
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003221};
3222
3223/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
3224 symbol of state STATE-NUM. */
3225static const unsigned char yystos[] =
3226{
3227 0, 200, 201, 202, 0, 25, 31, 41, 42, 43,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003228 44, 45, 46, 47, 62, 181, 219, 222, 224, 232,
3229 22, 24, 51, 58, 62, 180, 212, 224, 225, 61,
3230 220, 23, 233, 234, 30, 163, 221, 233, 52, 53,
3231 54, 71, 209, 152, 61, 20, 45, 47, 50, 181,
3232 152, 45, 47, 223, 24, 207, 64, 65, 66, 67,
3233 68, 69, 70, 182, 217, 180, 238, 152, 152, 152,
3234 152, 157, 210, 207, 5, 6, 8, 9, 10, 11,
3235 12, 13, 14, 15, 16, 17, 18, 19, 21, 48,
3236 154, 157, 160, 162, 167, 189, 190, 191, 192, 193,
3237 212, 229, 32, 33, 199, 199, 199, 199, 226, 4,
3238 189, 29, 162, 218, 35, 49, 59, 60, 72, 73,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003239 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
3240 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
3241 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
3242 104, 105, 106, 107, 110, 111, 112, 113, 114, 115,
3243 116, 117, 118, 139, 140, 141, 142, 143, 144, 145,
3244 146, 147, 148, 149, 150, 151, 169, 170, 171, 174,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003245 175, 235, 236, 242, 243, 245, 246, 24, 55, 56,
3246 208, 4, 24, 24, 211, 4, 4, 4, 162, 8,
3247 163, 193, 194, 155, 164, 191, 191, 191, 9, 10,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003248 11, 12, 13, 14, 15, 16, 17, 18, 19, 176,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003249 177, 179, 191, 196, 217, 212, 191, 231, 59, 8,
3250 231, 9, 21, 10, 11, 12, 13, 14, 15, 16,
3251 17, 176, 177, 178, 182, 119, 120, 121, 122, 123,
3252 124, 125, 126, 127, 128, 172, 27, 28, 125, 126,
3253 127, 128, 129, 130, 131, 132, 133, 134, 135, 136,
3254 137, 138, 173, 191, 191, 231, 191, 191, 239, 231,
3255 231, 231, 231, 231, 231, 231, 191, 191, 191, 231,
3256 231, 182, 108, 109, 153, 159, 158, 158, 163, 194,
3257 153, 163, 37, 194, 195, 205, 206, 204, 27, 28,
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003258 3, 4, 168, 4, 7, 26, 38, 39, 103, 104,
3259 110, 112, 114, 115, 116, 157, 160, 162, 165, 169,
Reid Spencerd2920cd2007-03-21 17:27:53 +00003260 170, 171, 174, 175, 197, 229, 203, 155, 3, 4,
3261 7, 26, 27, 28, 38, 39, 61, 160, 197, 228,
3262 229, 230, 230, 230, 230, 189, 191, 191, 153, 184,
3263 153, 184, 230, 157, 153, 153, 153, 153, 153, 153,
3264 153, 153, 230, 230, 230, 153, 36, 189, 191, 231,
3265 24, 193, 193, 161, 163, 193, 153, 156, 153, 187,
3266 187, 187, 172, 173, 155, 155, 155, 155, 155, 159,
3267 196, 198, 162, 198, 163, 198, 24, 155, 155, 155,
3268 155, 155, 187, 37, 191, 214, 215, 216, 63, 227,
3269 198, 153, 153, 230, 230, 230, 15, 57, 15, 153,
3270 244, 230, 157, 231, 191, 231, 231, 231, 191, 191,
3271 153, 153, 153, 231, 191, 230, 230, 153, 159, 161,
3272 161, 37, 34, 57, 185, 188, 155, 155, 196, 196,
3273 196, 196, 196, 153, 159, 163, 193, 198, 161, 163,
3274 196, 196, 196, 196, 196, 212, 213, 153, 156, 24,
3275 161, 21, 21, 155, 153, 153, 230, 4, 230, 231,
3276 240, 153, 230, 153, 153, 153, 230, 230, 230, 155,
3277 191, 24, 4, 187, 196, 196, 244, 153, 153, 153,
3278 153, 196, 161, 163, 153, 153, 153, 153, 36, 37,
3279 214, 185, 186, 153, 230, 230, 240, 241, 230, 230,
3280 153, 184, 184, 153, 230, 153, 231, 231, 231, 241,
3281 230, 153, 153, 156, 196, 196, 196, 196, 161, 196,
3282 196, 196, 196, 191, 57, 183, 24, 153, 157, 156,
3283 231, 159, 230, 156, 196, 196, 153, 156, 153, 153,
3284 156, 156, 156, 156, 156, 4, 21, 159, 178, 237,
3285 36, 159, 156, 156, 196, 196, 196, 230, 228, 159,
3286 178, 21, 156, 156, 156, 153, 228, 230, 21, 153,
3287 235, 230, 21, 21, 230, 230
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003288};
Reid Spencere7c3c602006-11-30 06:36:44 +00003289
3290#define yyerrok (yyerrstatus = 0)
3291#define yyclearin (yychar = YYEMPTY)
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003292#define YYEMPTY (-2)
Reid Spencere7c3c602006-11-30 06:36:44 +00003293#define YYEOF 0
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003294
Reid Spencere7c3c602006-11-30 06:36:44 +00003295#define YYACCEPT goto yyacceptlab
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003296#define YYABORT goto yyabortlab
3297#define YYERROR goto yyerrorlab
3298
3299
3300/* Like YYERROR except do call yyerror. This remains here temporarily
3301 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencere7c3c602006-11-30 06:36:44 +00003302 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003303
Reid Spencere7c3c602006-11-30 06:36:44 +00003304#define YYFAIL goto yyerrlab
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003305
Reid Spencere7c3c602006-11-30 06:36:44 +00003306#define YYRECOVERING() (!!yyerrstatus)
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003307
3308#define YYBACKUP(Token, Value) \
Reid Spencere7c3c602006-11-30 06:36:44 +00003309do \
3310 if (yychar == YYEMPTY && yylen == 1) \
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003311 { \
3312 yychar = (Token); \
3313 yylval = (Value); \
3314 yytoken = YYTRANSLATE (yychar); \
Chris Lattnercf3d0612007-02-13 06:04:17 +00003315 YYPOPSTACK; \
Reid Spencere7c3c602006-11-30 06:36:44 +00003316 goto yybackup; \
3317 } \
3318 else \
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003319 { \
3320 yyerror (YY_("syntax error: cannot back up")); \
3321 YYERROR; \
3322 } \
Chris Lattnercf3d0612007-02-13 06:04:17 +00003323while (0)
Reid Spencere7c3c602006-11-30 06:36:44 +00003324
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003325
Reid Spencere7c3c602006-11-30 06:36:44 +00003326#define YYTERROR 1
3327#define YYERRCODE 256
3328
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003329
3330/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
3331 If N is 0, then set CURRENT to the empty location which ends
3332 the previous symbol: RHS[0] (always defined). */
3333
3334#define YYRHSLOC(Rhs, K) ((Rhs)[K])
3335#ifndef YYLLOC_DEFAULT
3336# define YYLLOC_DEFAULT(Current, Rhs, N) \
3337 do \
3338 if (N) \
3339 { \
3340 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
3341 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
3342 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
3343 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
3344 } \
3345 else \
3346 { \
3347 (Current).first_line = (Current).last_line = \
3348 YYRHSLOC (Rhs, 0).last_line; \
3349 (Current).first_column = (Current).last_column = \
3350 YYRHSLOC (Rhs, 0).last_column; \
3351 } \
3352 while (0)
Reid Spencere7c3c602006-11-30 06:36:44 +00003353#endif
3354
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003355
3356/* YY_LOCATION_PRINT -- Print the location on the stream.
3357 This macro was not mandated originally: define only if we know
3358 we won't break user code: when these are the locations we know. */
3359
3360#ifndef YY_LOCATION_PRINT
3361# if YYLTYPE_IS_TRIVIAL
3362# define YY_LOCATION_PRINT(File, Loc) \
3363 fprintf (File, "%d.%d-%d.%d", \
3364 (Loc).first_line, (Loc).first_column, \
3365 (Loc).last_line, (Loc).last_column)
3366# else
3367# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
3368# endif
3369#endif
3370
3371
3372/* YYLEX -- calling `yylex' with the right arguments. */
3373
Reid Spencer950bf602007-01-26 08:19:09 +00003374#ifdef YYLEX_PARAM
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003375# define YYLEX yylex (YYLEX_PARAM)
Reid Spencer950bf602007-01-26 08:19:09 +00003376#else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003377# define YYLEX yylex ()
Chris Lattner4227bdb2007-02-19 07:34:02 +00003378#endif
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003379
3380/* Enable debugging if requested. */
3381#if YYDEBUG
3382
3383# ifndef YYFPRINTF
3384# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
3385# define YYFPRINTF fprintf
3386# endif
3387
3388# define YYDPRINTF(Args) \
3389do { \
3390 if (yydebug) \
3391 YYFPRINTF Args; \
3392} while (0)
3393
3394# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
3395do { \
3396 if (yydebug) \
3397 { \
3398 YYFPRINTF (stderr, "%s ", Title); \
3399 yysymprint (stderr, \
3400 Type, Value); \
3401 YYFPRINTF (stderr, "\n"); \
3402 } \
3403} while (0)
3404
3405/*------------------------------------------------------------------.
3406| yy_stack_print -- Print the state stack from its BOTTOM up to its |
3407| TOP (included). |
3408`------------------------------------------------------------------*/
3409
3410#if defined (__STDC__) || defined (__cplusplus)
3411static void
3412yy_stack_print (short int *bottom, short int *top)
Chris Lattner4227bdb2007-02-19 07:34:02 +00003413#else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003414static void
3415yy_stack_print (bottom, top)
3416 short int *bottom;
3417 short int *top;
Chris Lattner4227bdb2007-02-19 07:34:02 +00003418#endif
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003419{
3420 YYFPRINTF (stderr, "Stack now");
3421 for (/* Nothing. */; bottom <= top; ++bottom)
3422 YYFPRINTF (stderr, " %d", *bottom);
3423 YYFPRINTF (stderr, "\n");
3424}
3425
3426# define YY_STACK_PRINT(Bottom, Top) \
3427do { \
3428 if (yydebug) \
3429 yy_stack_print ((Bottom), (Top)); \
3430} while (0)
3431
3432
3433/*------------------------------------------------.
3434| Report that the YYRULE is going to be reduced. |
3435`------------------------------------------------*/
3436
3437#if defined (__STDC__) || defined (__cplusplus)
3438static void
3439yy_reduce_print (int yyrule)
3440#else
3441static void
3442yy_reduce_print (yyrule)
3443 int yyrule;
Chris Lattnercf3d0612007-02-13 06:04:17 +00003444#endif
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003445{
3446 int yyi;
3447 unsigned long int yylno = yyrline[yyrule];
3448 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
3449 yyrule - 1, yylno);
3450 /* Print the symbols being reduced, and their result. */
3451 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
3452 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
3453 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
3454}
Reid Spencer9d6565a2007-02-15 02:26:10 +00003455
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003456# define YY_REDUCE_PRINT(Rule) \
3457do { \
3458 if (yydebug) \
3459 yy_reduce_print (Rule); \
3460} while (0)
Reid Spencer9d6565a2007-02-15 02:26:10 +00003461
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003462/* Nonzero means print parse trace. It is left uninitialized so that
3463 multiple parsers can coexist. */
3464int yydebug;
3465#else /* !YYDEBUG */
3466# define YYDPRINTF(Args)
3467# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
3468# define YY_STACK_PRINT(Bottom, Top)
3469# define YY_REDUCE_PRINT(Rule)
3470#endif /* !YYDEBUG */
Reid Spencer9d6565a2007-02-15 02:26:10 +00003471
Reid Spencer9d6565a2007-02-15 02:26:10 +00003472
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003473/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003474#ifndef YYINITDEPTH
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003475# define YYINITDEPTH 200
Reid Spencere7c3c602006-11-30 06:36:44 +00003476#endif
3477
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003478/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
3479 if the built-in stack extension method is used).
Reid Spencere7c3c602006-11-30 06:36:44 +00003480
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003481 Do not make this value too large; the results are undefined if
3482 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
3483 evaluated with infinite-precision integer arithmetic. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003484
3485#ifndef YYMAXDEPTH
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003486# define YYMAXDEPTH 10000
Reid Spencere7c3c602006-11-30 06:36:44 +00003487#endif
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003488
Reid Spencere7c3c602006-11-30 06:36:44 +00003489
3490
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003491#if YYERROR_VERBOSE
Reid Spencere7c3c602006-11-30 06:36:44 +00003492
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003493# ifndef yystrlen
3494# if defined (__GLIBC__) && defined (_STRING_H)
3495# define yystrlen strlen
3496# else
3497/* Return the length of YYSTR. */
3498static YYSIZE_T
3499# if defined (__STDC__) || defined (__cplusplus)
3500yystrlen (const char *yystr)
3501# else
3502yystrlen (yystr)
3503 const char *yystr;
3504# endif
Chris Lattner4227bdb2007-02-19 07:34:02 +00003505{
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003506 const char *yys = yystr;
Chris Lattner4227bdb2007-02-19 07:34:02 +00003507
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003508 while (*yys++ != '\0')
3509 continue;
3510
3511 return yys - yystr - 1;
Chris Lattner4227bdb2007-02-19 07:34:02 +00003512}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003513# endif
3514# endif
Chris Lattner4227bdb2007-02-19 07:34:02 +00003515
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003516# ifndef yystpcpy
3517# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
3518# define yystpcpy stpcpy
3519# else
3520/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
3521 YYDEST. */
3522static char *
3523# if defined (__STDC__) || defined (__cplusplus)
3524yystpcpy (char *yydest, const char *yysrc)
3525# else
3526yystpcpy (yydest, yysrc)
3527 char *yydest;
3528 const char *yysrc;
3529# endif
Chris Lattner4227bdb2007-02-19 07:34:02 +00003530{
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003531 char *yyd = yydest;
3532 const char *yys = yysrc;
Chris Lattner4227bdb2007-02-19 07:34:02 +00003533
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003534 while ((*yyd++ = *yys++) != '\0')
3535 continue;
3536
3537 return yyd - 1;
Chris Lattner4227bdb2007-02-19 07:34:02 +00003538}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003539# endif
3540# endif
Chris Lattner4227bdb2007-02-19 07:34:02 +00003541
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003542# ifndef yytnamerr
3543/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
3544 quotes and backslashes, so that it's suitable for yyerror. The
3545 heuristic is that double-quoting is unnecessary unless the string
3546 contains an apostrophe, a comma, or backslash (other than
3547 backslash-backslash). YYSTR is taken from yytname. If YYRES is
3548 null, do not copy; instead, return the length of what the result
3549 would have been. */
3550static YYSIZE_T
3551yytnamerr (char *yyres, const char *yystr)
3552{
3553 if (*yystr == '"')
3554 {
3555 size_t yyn = 0;
3556 char const *yyp = yystr;
3557
3558 for (;;)
3559 switch (*++yyp)
3560 {
3561 case '\'':
3562 case ',':
3563 goto do_not_strip_quotes;
3564
3565 case '\\':
3566 if (*++yyp != '\\')
3567 goto do_not_strip_quotes;
3568 /* Fall through. */
3569 default:
3570 if (yyres)
3571 yyres[yyn] = *yyp;
3572 yyn++;
3573 break;
3574
3575 case '"':
3576 if (yyres)
3577 yyres[yyn] = '\0';
3578 return yyn;
3579 }
3580 do_not_strip_quotes: ;
3581 }
3582
3583 if (! yyres)
3584 return yystrlen (yystr);
3585
3586 return yystpcpy (yyres, yystr) - yyres;
3587}
3588# endif
3589
3590#endif /* YYERROR_VERBOSE */
3591
Reid Spencer9d6565a2007-02-15 02:26:10 +00003592
3593
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003594#if YYDEBUG
3595/*--------------------------------.
3596| Print this symbol on YYOUTPUT. |
3597`--------------------------------*/
Reid Spencer9d6565a2007-02-15 02:26:10 +00003598
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003599#if defined (__STDC__) || defined (__cplusplus)
3600static void
3601yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
Chris Lattner4227bdb2007-02-19 07:34:02 +00003602#else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003603static void
3604yysymprint (yyoutput, yytype, yyvaluep)
3605 FILE *yyoutput;
3606 int yytype;
3607 YYSTYPE *yyvaluep;
3608#endif
3609{
3610 /* Pacify ``unused variable'' warnings. */
3611 (void) yyvaluep;
3612
3613 if (yytype < YYNTOKENS)
3614 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
3615 else
3616 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
3617
3618
3619# ifdef YYPRINT
3620 if (yytype < YYNTOKENS)
3621 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
3622# endif
3623 switch (yytype)
3624 {
3625 default:
3626 break;
3627 }
3628 YYFPRINTF (yyoutput, ")");
3629}
3630
3631#endif /* ! YYDEBUG */
3632/*-----------------------------------------------.
3633| Release the memory associated to this symbol. |
3634`-----------------------------------------------*/
3635
3636#if defined (__STDC__) || defined (__cplusplus)
3637static void
3638yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
3639#else
3640static void
3641yydestruct (yymsg, yytype, yyvaluep)
3642 const char *yymsg;
3643 int yytype;
3644 YYSTYPE *yyvaluep;
3645#endif
3646{
3647 /* Pacify ``unused variable'' warnings. */
3648 (void) yyvaluep;
3649
3650 if (!yymsg)
3651 yymsg = "Deleting";
3652 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
3653
3654 switch (yytype)
3655 {
3656
3657 default:
3658 break;
3659 }
3660}
3661
3662
3663/* Prevent warnings from -Wmissing-prototypes. */
3664
3665#ifdef YYPARSE_PARAM
3666# if defined (__STDC__) || defined (__cplusplus)
3667int yyparse (void *YYPARSE_PARAM);
3668# else
3669int yyparse ();
3670# endif
3671#else /* ! YYPARSE_PARAM */
3672#if defined (__STDC__) || defined (__cplusplus)
Reid Spencere7c3c602006-11-30 06:36:44 +00003673int yyparse (void);
Chris Lattner4227bdb2007-02-19 07:34:02 +00003674#else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003675int yyparse ();
3676#endif
3677#endif /* ! YYPARSE_PARAM */
3678
3679
3680
3681/* The look-ahead symbol. */
3682int yychar;
3683
3684/* The semantic value of the look-ahead symbol. */
3685YYSTYPE yylval;
3686
3687/* Number of syntax errors so far. */
3688int yynerrs;
3689
3690
3691
3692/*----------.
3693| yyparse. |
3694`----------*/
3695
3696#ifdef YYPARSE_PARAM
3697# if defined (__STDC__) || defined (__cplusplus)
3698int yyparse (void *YYPARSE_PARAM)
3699# else
3700int yyparse (YYPARSE_PARAM)
3701 void *YYPARSE_PARAM;
3702# endif
3703#else /* ! YYPARSE_PARAM */
3704#if defined (__STDC__) || defined (__cplusplus)
3705int
3706yyparse (void)
3707#else
3708int
3709yyparse ()
3710
3711#endif
3712#endif
3713{
3714
3715 int yystate;
3716 int yyn;
3717 int yyresult;
3718 /* Number of tokens to shift before error messages enabled. */
3719 int yyerrstatus;
3720 /* Look-ahead token as an internal (translated) token number. */
3721 int yytoken = 0;
3722
3723 /* Three stacks and their tools:
3724 `yyss': related to states,
3725 `yyvs': related to semantic values,
3726 `yyls': related to locations.
3727
3728 Refer to the stacks thru separate pointers, to allow yyoverflow
3729 to reallocate them elsewhere. */
3730
3731 /* The state stack. */
3732 short int yyssa[YYINITDEPTH];
3733 short int *yyss = yyssa;
3734 short int *yyssp;
3735
3736 /* The semantic value stack. */
3737 YYSTYPE yyvsa[YYINITDEPTH];
3738 YYSTYPE *yyvs = yyvsa;
3739 YYSTYPE *yyvsp;
3740
3741
3742
Chris Lattnercf3d0612007-02-13 06:04:17 +00003743#define YYPOPSTACK (yyvsp--, yyssp--)
Reid Spencere7c3c602006-11-30 06:36:44 +00003744
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003745 YYSIZE_T yystacksize = YYINITDEPTH;
Chris Lattner1bc3fa62007-02-12 22:58:38 +00003746
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003747 /* The variables used to return semantic value and location from the
3748 action routines. */
3749 YYSTYPE yyval;
Chris Lattner1bc3fa62007-02-12 22:58:38 +00003750
Chris Lattner1bc3fa62007-02-12 22:58:38 +00003751
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003752 /* When reducing, the number of symbols on the RHS of the reduced
3753 rule. */
Chris Lattnercf3d0612007-02-13 06:04:17 +00003754 int yylen;
Chris Lattner1bc3fa62007-02-12 22:58:38 +00003755
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003756 YYDPRINTF ((stderr, "Starting parse\n"));
Chris Lattner1bc3fa62007-02-12 22:58:38 +00003757
Reid Spencere7c3c602006-11-30 06:36:44 +00003758 yystate = 0;
3759 yyerrstatus = 0;
3760 yynerrs = 0;
3761 yychar = YYEMPTY; /* Cause a token to be read. */
3762
3763 /* Initialize stack pointers.
3764 Waste one element of value and location stack
3765 so that they stay on the same level as the state stack.
3766 The wasted elements are never initialized. */
3767
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003768 yyssp = yyss;
Reid Spencere7c3c602006-11-30 06:36:44 +00003769 yyvsp = yyvs;
3770
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003771 goto yysetstate;
Reid Spencere7c3c602006-11-30 06:36:44 +00003772
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003773/*------------------------------------------------------------.
3774| yynewstate -- Push a new state, which is found in yystate. |
3775`------------------------------------------------------------*/
3776 yynewstate:
3777 /* In all cases, when you get here, the value and location stacks
3778 have just been pushed. so pushing a state here evens the stacks.
3779 */
3780 yyssp++;
Reid Spencere7c3c602006-11-30 06:36:44 +00003781
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003782 yysetstate:
3783 *yyssp = yystate;
3784
3785 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00003786 {
3787 /* Get the current used size of the three stacks, in elements. */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003788 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencere7c3c602006-11-30 06:36:44 +00003789
3790#ifdef yyoverflow
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003791 {
3792 /* Give user a chance to reallocate the stack. Use copies of
3793 these so that the &'s don't force the real ones into
3794 memory. */
3795 YYSTYPE *yyvs1 = yyvs;
3796 short int *yyss1 = yyss;
Reid Spencere7c3c602006-11-30 06:36:44 +00003797
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003798
3799 /* Each stack pointer address is followed by the size of the
3800 data in use in that stack, in bytes. This used to be a
3801 conditional around just the two extra args, but that might
3802 be undefined if yyoverflow is a macro. */
3803 yyoverflow (YY_("memory exhausted"),
3804 &yyss1, yysize * sizeof (*yyssp),
3805 &yyvs1, yysize * sizeof (*yyvsp),
3806
3807 &yystacksize);
3808
3809 yyss = yyss1;
3810 yyvs = yyvs1;
3811 }
Reid Spencere7c3c602006-11-30 06:36:44 +00003812#else /* no yyoverflow */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003813# ifndef YYSTACK_RELOCATE
3814 goto yyexhaustedlab;
3815# else
Reid Spencere7c3c602006-11-30 06:36:44 +00003816 /* Extend the stack our own way. */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003817 if (YYMAXDEPTH <= yystacksize)
3818 goto yyexhaustedlab;
Reid Spencere7c3c602006-11-30 06:36:44 +00003819 yystacksize *= 2;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003820 if (YYMAXDEPTH < yystacksize)
Reid Spencere7c3c602006-11-30 06:36:44 +00003821 yystacksize = YYMAXDEPTH;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003822
3823 {
3824 short int *yyss1 = yyss;
3825 union yyalloc *yyptr =
3826 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3827 if (! yyptr)
3828 goto yyexhaustedlab;
3829 YYSTACK_RELOCATE (yyss);
3830 YYSTACK_RELOCATE (yyvs);
3831
3832# undef YYSTACK_RELOCATE
3833 if (yyss1 != yyssa)
3834 YYSTACK_FREE (yyss1);
3835 }
3836# endif
Reid Spencere7c3c602006-11-30 06:36:44 +00003837#endif /* no yyoverflow */
3838
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003839 yyssp = yyss + yysize - 1;
3840 yyvsp = yyvs + yysize - 1;
Reid Spencere7c3c602006-11-30 06:36:44 +00003841
3842
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003843 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3844 (unsigned long int) yystacksize));
3845
3846 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00003847 YYABORT;
3848 }
3849
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003850 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencere7c3c602006-11-30 06:36:44 +00003851
3852 goto yybackup;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003853
3854/*-----------.
3855| yybackup. |
3856`-----------*/
3857yybackup:
Reid Spencere7c3c602006-11-30 06:36:44 +00003858
Chris Lattnercf3d0612007-02-13 06:04:17 +00003859/* Do appropriate processing given the current state. */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003860/* Read a look-ahead token if we need one and don't already have one. */
Chris Lattnercf3d0612007-02-13 06:04:17 +00003861/* yyresume: */
Reid Spencere7c3c602006-11-30 06:36:44 +00003862
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003863 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencerb7046c72007-01-29 05:41:34 +00003864
Reid Spencere7c3c602006-11-30 06:36:44 +00003865 yyn = yypact[yystate];
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003866 if (yyn == YYPACT_NINF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003867 goto yydefault;
3868
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003869 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003870
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003871 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003872 if (yychar == YYEMPTY)
3873 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003874 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencere7c3c602006-11-30 06:36:44 +00003875 yychar = YYLEX;
3876 }
3877
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003878 if (yychar <= YYEOF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003879 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003880 yychar = yytoken = YYEOF;
3881 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencere7c3c602006-11-30 06:36:44 +00003882 }
3883 else
3884 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003885 yytoken = YYTRANSLATE (yychar);
3886 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencere7c3c602006-11-30 06:36:44 +00003887 }
3888
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003889 /* If the proper action on seeing token YYTOKEN is to reduce or to
3890 detect an error, take that action. */
3891 yyn += yytoken;
3892 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencere7c3c602006-11-30 06:36:44 +00003893 goto yydefault;
3894 yyn = yytable[yyn];
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003895 if (yyn <= 0)
Reid Spencere7c3c602006-11-30 06:36:44 +00003896 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003897 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencere7c3c602006-11-30 06:36:44 +00003898 goto yyerrlab;
3899 yyn = -yyn;
3900 goto yyreduce;
3901 }
3902
3903 if (yyn == YYFINAL)
3904 YYACCEPT;
3905
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003906 /* Shift the look-ahead token. */
3907 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Reid Spencerb7046c72007-01-29 05:41:34 +00003908
Chris Lattnercf3d0612007-02-13 06:04:17 +00003909 /* Discard the token being shifted unless it is eof. */
Reid Spencerb7046c72007-01-29 05:41:34 +00003910 if (yychar != YYEOF)
3911 yychar = YYEMPTY;
3912
Chris Lattner1bc3fa62007-02-12 22:58:38 +00003913 *++yyvsp = yylval;
3914
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003915
3916 /* Count tokens shifted since error; after three, turn off error
3917 status. */
3918 if (yyerrstatus)
3919 yyerrstatus--;
Chris Lattnercf3d0612007-02-13 06:04:17 +00003920
3921 yystate = yyn;
Reid Spencere7c3c602006-11-30 06:36:44 +00003922 goto yynewstate;
3923
Chris Lattner4227bdb2007-02-19 07:34:02 +00003924
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003925/*-----------------------------------------------------------.
3926| yydefault -- do the default action for the current state. |
3927`-----------------------------------------------------------*/
3928yydefault:
Reid Spencere7c3c602006-11-30 06:36:44 +00003929 yyn = yydefact[yystate];
3930 if (yyn == 0)
3931 goto yyerrlab;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003932 goto yyreduce;
Reid Spencere7c3c602006-11-30 06:36:44 +00003933
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003934
3935/*-----------------------------.
3936| yyreduce -- Do a reduction. |
3937`-----------------------------*/
Reid Spencere7c3c602006-11-30 06:36:44 +00003938yyreduce:
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003939 /* yyn is the number of a rule to reduce with. */
Reid Spencere7c3c602006-11-30 06:36:44 +00003940 yylen = yyr2[yyn];
3941
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003942 /* If YYLEN is nonzero, implement the default value of the action:
3943 `$$ = $1'.
3944
3945 Otherwise, the following line sets YYVAL to garbage.
3946 This behavior is undocumented and Bison
3947 users should not rely upon it. Assigning to YYVAL
3948 unconditionally makes the parser a bit smaller, and it avoids a
3949 GCC warning that YYVAL may be used uninitialized. */
3950 yyval = yyvsp[1-yylen];
3951
3952
3953 YY_REDUCE_PRINT (yyn);
3954 switch (yyn)
Reid Spencere7c3c602006-11-30 06:36:44 +00003955 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003956 case 3:
Reid Spencerbaba98a2007-04-11 12:10:58 +00003957#line 1883 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003958 {
3959 if ((yyvsp[0].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range!
Reid Spencer950bf602007-01-26 08:19:09 +00003960 error("Value too large for type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003961 (yyval.SIntVal) = (int32_t)(yyvsp[0].UIntVal);
3962 ;}
3963 break;
3964
3965 case 5:
Reid Spencerbaba98a2007-04-11 12:10:58 +00003966#line 1892 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003967 {
3968 if ((yyvsp[0].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range!
Reid Spencer950bf602007-01-26 08:19:09 +00003969 error("Value too large for type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003970 (yyval.SInt64Val) = (int64_t)(yyvsp[0].UInt64Val);
3971 ;}
3972 break;
3973
3974 case 26:
Reid Spencerbaba98a2007-04-11 12:10:58 +00003975#line 1914 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003976 { (yyval.IPred) = ICmpInst::ICMP_EQ; ;}
3977 break;
3978
3979 case 27:
Reid Spencerbaba98a2007-04-11 12:10:58 +00003980#line 1914 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003981 { (yyval.IPred) = ICmpInst::ICMP_NE; ;}
3982 break;
3983
3984 case 28:
Reid Spencerbaba98a2007-04-11 12:10:58 +00003985#line 1915 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003986 { (yyval.IPred) = ICmpInst::ICMP_SLT; ;}
3987 break;
3988
3989 case 29:
Reid Spencerbaba98a2007-04-11 12:10:58 +00003990#line 1915 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003991 { (yyval.IPred) = ICmpInst::ICMP_SGT; ;}
3992 break;
3993
3994 case 30:
Reid Spencerbaba98a2007-04-11 12:10:58 +00003995#line 1916 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00003996 { (yyval.IPred) = ICmpInst::ICMP_SLE; ;}
3997 break;
3998
3999 case 31:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004000#line 1916 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004001 { (yyval.IPred) = ICmpInst::ICMP_SGE; ;}
4002 break;
4003
4004 case 32:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004005#line 1917 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004006 { (yyval.IPred) = ICmpInst::ICMP_ULT; ;}
4007 break;
4008
4009 case 33:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004010#line 1917 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004011 { (yyval.IPred) = ICmpInst::ICMP_UGT; ;}
4012 break;
4013
4014 case 34:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004015#line 1918 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004016 { (yyval.IPred) = ICmpInst::ICMP_ULE; ;}
4017 break;
4018
4019 case 35:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004020#line 1918 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004021 { (yyval.IPred) = ICmpInst::ICMP_UGE; ;}
4022 break;
4023
4024 case 36:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004025#line 1922 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004026 { (yyval.FPred) = FCmpInst::FCMP_OEQ; ;}
4027 break;
4028
4029 case 37:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004030#line 1922 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004031 { (yyval.FPred) = FCmpInst::FCMP_ONE; ;}
4032 break;
4033
4034 case 38:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004035#line 1923 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004036 { (yyval.FPred) = FCmpInst::FCMP_OLT; ;}
4037 break;
4038
4039 case 39:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004040#line 1923 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004041 { (yyval.FPred) = FCmpInst::FCMP_OGT; ;}
4042 break;
4043
4044 case 40:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004045#line 1924 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004046 { (yyval.FPred) = FCmpInst::FCMP_OLE; ;}
4047 break;
4048
4049 case 41:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004050#line 1924 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004051 { (yyval.FPred) = FCmpInst::FCMP_OGE; ;}
4052 break;
4053
4054 case 42:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004055#line 1925 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004056 { (yyval.FPred) = FCmpInst::FCMP_ORD; ;}
4057 break;
4058
4059 case 43:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004060#line 1925 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004061 { (yyval.FPred) = FCmpInst::FCMP_UNO; ;}
4062 break;
4063
4064 case 44:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004065#line 1926 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004066 { (yyval.FPred) = FCmpInst::FCMP_UEQ; ;}
4067 break;
4068
4069 case 45:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004070#line 1926 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004071 { (yyval.FPred) = FCmpInst::FCMP_UNE; ;}
4072 break;
4073
4074 case 46:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004075#line 1927 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004076 { (yyval.FPred) = FCmpInst::FCMP_ULT; ;}
4077 break;
4078
4079 case 47:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004080#line 1927 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004081 { (yyval.FPred) = FCmpInst::FCMP_UGT; ;}
4082 break;
4083
4084 case 48:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004085#line 1928 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004086 { (yyval.FPred) = FCmpInst::FCMP_ULE; ;}
4087 break;
4088
4089 case 49:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004090#line 1928 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004091 { (yyval.FPred) = FCmpInst::FCMP_UGE; ;}
4092 break;
4093
4094 case 50:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004095#line 1929 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004096 { (yyval.FPred) = FCmpInst::FCMP_TRUE; ;}
4097 break;
4098
4099 case 51:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004100#line 1930 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004101 { (yyval.FPred) = FCmpInst::FCMP_FALSE; ;}
4102 break;
4103
4104 case 81:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004105#line 1961 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004106 {
4107 (yyval.StrVal) = (yyvsp[-1].StrVal);
4108 ;}
4109 break;
4110
4111 case 82:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004112#line 1964 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004113 {
4114 (yyval.StrVal) = 0;
4115 ;}
4116 break;
4117
4118 case 83:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004119#line 1969 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004120 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
4121 break;
4122
4123 case 84:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004124#line 1970 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004125 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
4126 break;
4127
4128 case 85:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004129#line 1971 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004130 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
4131 break;
4132
4133 case 86:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004134#line 1972 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004135 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
4136 break;
4137
4138 case 87:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004139#line 1973 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004140 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
4141 break;
4142
4143 case 88:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004144#line 1974 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004145 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
4146 break;
4147
4148 case 89:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004149#line 1975 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004150 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
4151 break;
4152
4153 case 90:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004154#line 1976 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004155 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
4156 break;
4157
4158 case 91:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004159#line 1980 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004160 { (yyval.UIntVal) = OldCallingConv::C; ;}
4161 break;
4162
4163 case 92:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004164#line 1981 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004165 { (yyval.UIntVal) = OldCallingConv::C; ;}
4166 break;
4167
4168 case 93:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004169#line 1982 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004170 { (yyval.UIntVal) = OldCallingConv::CSRet; ;}
4171 break;
4172
4173 case 94:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004174#line 1983 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004175 { (yyval.UIntVal) = OldCallingConv::Fast; ;}
4176 break;
4177
4178 case 95:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004179#line 1984 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004180 { (yyval.UIntVal) = OldCallingConv::Cold; ;}
4181 break;
4182
4183 case 96:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004184#line 1985 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004185 { (yyval.UIntVal) = OldCallingConv::X86_StdCall; ;}
4186 break;
4187
4188 case 97:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004189#line 1986 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004190 { (yyval.UIntVal) = OldCallingConv::X86_FastCall; ;}
4191 break;
4192
4193 case 98:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004194#line 1987 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004195 {
4196 if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val))
Reid Spencer950bf602007-01-26 08:19:09 +00004197 error("Calling conv too large");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004198 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
4199 ;}
4200 break;
4201
4202 case 99:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004203#line 1997 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004204 { (yyval.UIntVal) = 0; ;}
4205 break;
4206
4207 case 100:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004208#line 1998 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004209 {
4210 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
4211 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencer950bf602007-01-26 08:19:09 +00004212 error("Alignment must be a power of two");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004213 ;}
4214 break;
4215
4216 case 101:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004217#line 2006 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004218 { (yyval.UIntVal) = 0; ;}
4219 break;
4220
4221 case 102:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004222#line 2007 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004223 {
4224 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
4225 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencer950bf602007-01-26 08:19:09 +00004226 error("Alignment must be a power of two");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004227 ;}
4228 break;
4229
4230 case 103:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004231#line 2015 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004232 {
4233 for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i)
4234 if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\')
Reid Spencer950bf602007-01-26 08:19:09 +00004235 error("Invalid character in section name");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004236 (yyval.StrVal) = (yyvsp[0].StrVal);
4237 ;}
4238 break;
4239
4240 case 104:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004241#line 2024 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004242 { (yyval.StrVal) = 0; ;}
4243 break;
4244
4245 case 105:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004246#line 2025 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004247 { (yyval.StrVal) = (yyvsp[0].StrVal); ;}
4248 break;
4249
4250 case 106:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004251#line 2032 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004252 {;}
4253 break;
4254
4255 case 107:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004256#line 2033 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004257 {;}
4258 break;
4259
4260 case 108:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004261#line 2037 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004262 {
4263 CurGV->setSection((yyvsp[0].StrVal));
4264 free((yyvsp[0].StrVal));
4265 ;}
4266 break;
4267
4268 case 109:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004269#line 2041 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004270 {
4271 if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00004272 error("Alignment must be a power of two");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004273 CurGV->setAlignment((yyvsp[0].UInt64Val));
Reid Spencer950bf602007-01-26 08:19:09 +00004274
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004275 ;}
4276 break;
4277
4278 case 111:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004279#line 2058 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004280 {
4281 (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[0].PrimType).T);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004282 (yyval.TypeVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004283 ;}
4284 break;
4285
4286 case 113:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004287#line 2066 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004288 {
4289 (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[0].PrimType).T);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004290 (yyval.TypeVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004291 ;}
4292 break;
4293
4294 case 114:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004295#line 2073 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004296 {
Reid Spencer950bf602007-01-26 08:19:09 +00004297 if (!UpRefs.empty())
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004298 error("Invalid upreference in type: " + (*(yyvsp[0].TypeVal).PAT)->getDescription());
4299 (yyval.TypeVal) = (yyvsp[0].TypeVal);
4300 ;}
4301 break;
4302
4303 case 127:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004304#line 2087 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004305 {
4306 (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[0].PrimType).T);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004307 (yyval.TypeVal).S.copy((yyvsp[0].PrimType).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004308 ;}
4309 break;
4310
4311 case 128:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004312#line 2091 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004313 {
4314 (yyval.TypeVal).PAT = new PATypeHolder(OpaqueType::get());
Reid Spencerbb1fd572007-03-21 17:15:50 +00004315 (yyval.TypeVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004316 ;}
4317 break;
4318
4319 case 129:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004320#line 2095 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004321 { // Named types are also simple types...
Reid Spencerbb1fd572007-03-21 17:15:50 +00004322 (yyval.TypeVal).S.copy(getTypeSign((yyvsp[0].ValIDVal)));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004323 const Type* tmp = getType((yyvsp[0].ValIDVal));
4324 (yyval.TypeVal).PAT = new PATypeHolder(tmp);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004325 ;}
4326 break;
4327
4328 case 130:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004329#line 2100 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004330 { // Type UpReference
4331 if ((yyvsp[0].UInt64Val) > (uint64_t)~0U)
Reid Spencer950bf602007-01-26 08:19:09 +00004332 error("Value out of range");
4333 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004334 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector...
4335 (yyval.TypeVal).PAT = new PATypeHolder(OT);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004336 (yyval.TypeVal).S.makeSignless();
Reid Spencer950bf602007-01-26 08:19:09 +00004337 UR_OUT("New Upreference!\n");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004338 ;}
4339 break;
4340
4341 case 131:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004342#line 2109 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004343 { // Function derived type?
Reid Spencerbb1fd572007-03-21 17:15:50 +00004344 (yyval.TypeVal).S.makeComposite((yyvsp[-3].TypeVal).S);
Reid Spencer950bf602007-01-26 08:19:09 +00004345 std::vector<const Type*> Params;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004346 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-1].TypeList)->begin(),
4347 E = (yyvsp[-1].TypeList)->end(); I != E; ++I) {
Reid Spencered96d1e2007-02-08 09:08:52 +00004348 Params.push_back(I->PAT->get());
Reid Spencerbb1fd572007-03-21 17:15:50 +00004349 (yyval.TypeVal).S.add(I->S);
Reid Spencer52402b02007-01-02 05:45:11 +00004350 }
Reid Spencer950bf602007-01-26 08:19:09 +00004351 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4352 if (isVarArg) Params.pop_back();
4353
Reid Spencer7b5d4662007-04-09 06:16:21 +00004354 const FunctionType *FTy =
4355 FunctionType::get((yyvsp[-3].TypeVal).PAT->get(), Params, isVarArg, 0);
4356
4357 (yyval.TypeVal).PAT = new PATypeHolder( HandleUpRefs(FTy, (yyval.TypeVal).S) );
Reid Spencerbb1fd572007-03-21 17:15:50 +00004358 delete (yyvsp[-3].TypeVal).PAT; // Delete the return type handle
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004359 delete (yyvsp[-1].TypeList); // Delete the argument list
4360 ;}
4361 break;
4362
4363 case 132:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004364#line 2127 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004365 { // Sized array type?
Reid Spencerbb1fd572007-03-21 17:15:50 +00004366 (yyval.TypeVal).S.makeComposite((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004367 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(ArrayType::get((yyvsp[-1].TypeVal).PAT->get(),
Reid Spencerbb1fd572007-03-21 17:15:50 +00004368 (unsigned)(yyvsp[-3].UInt64Val)), (yyval.TypeVal).S));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004369 delete (yyvsp[-1].TypeVal).PAT;
4370 ;}
4371 break;
4372
4373 case 133:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004374#line 2133 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004375 { // Vector type?
Reid Spencerbb1fd572007-03-21 17:15:50 +00004376 const llvm::Type* ElemTy = (yyvsp[-1].TypeVal).PAT->get();
4377 if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val))
4378 error("Unsigned result not equal to signed result");
4379 if (!(ElemTy->isInteger() || ElemTy->isFloatingPoint()))
4380 error("Elements of a VectorType must be integer or floating point");
4381 if (!isPowerOf2_32((yyvsp[-3].UInt64Val)))
4382 error("VectorType length should be a power of 2");
4383 (yyval.TypeVal).S.makeComposite((yyvsp[-1].TypeVal).S);
4384 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(VectorType::get(ElemTy,
4385 (unsigned)(yyvsp[-3].UInt64Val)), (yyval.TypeVal).S));
4386 delete (yyvsp[-1].TypeVal).PAT;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004387 ;}
4388 break;
4389
4390 case 134:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004391#line 2146 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004392 { // Structure type?
Reid Spencer950bf602007-01-26 08:19:09 +00004393 std::vector<const Type*> Elements;
Reid Spencerbb1fd572007-03-21 17:15:50 +00004394 (yyval.TypeVal).S.makeComposite();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004395 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-1].TypeList)->begin(),
Reid Spencerbb1fd572007-03-21 17:15:50 +00004396 E = (yyvsp[-1].TypeList)->end(); I != E; ++I) {
Reid Spencered96d1e2007-02-08 09:08:52 +00004397 Elements.push_back(I->PAT->get());
Reid Spencerbb1fd572007-03-21 17:15:50 +00004398 (yyval.TypeVal).S.add(I->S);
4399 }
4400 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements), (yyval.TypeVal).S));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004401 delete (yyvsp[-1].TypeList);
4402 ;}
4403 break;
4404
4405 case 135:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004406#line 2157 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004407 { // Empty structure type?
4408 (yyval.TypeVal).PAT = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencerbb1fd572007-03-21 17:15:50 +00004409 (yyval.TypeVal).S.makeComposite();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004410 ;}
4411 break;
4412
4413 case 136:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004414#line 2161 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004415 { // Packed Structure type?
Reid Spencerbb1fd572007-03-21 17:15:50 +00004416 (yyval.TypeVal).S.makeComposite();
Reid Spencer950bf602007-01-26 08:19:09 +00004417 std::vector<const Type*> Elements;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004418 for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-2].TypeList)->begin(),
4419 E = (yyvsp[-2].TypeList)->end(); I != E; ++I) {
Reid Spencered96d1e2007-02-08 09:08:52 +00004420 Elements.push_back(I->PAT->get());
Reid Spencerbb1fd572007-03-21 17:15:50 +00004421 (yyval.TypeVal).S.add(I->S);
Reid Spencered96d1e2007-02-08 09:08:52 +00004422 delete I->PAT;
Reid Spencer52402b02007-01-02 05:45:11 +00004423 }
Reid Spencerbb1fd572007-03-21 17:15:50 +00004424 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true),
4425 (yyval.TypeVal).S));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004426 delete (yyvsp[-2].TypeList);
4427 ;}
4428 break;
4429
4430 case 137:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004431#line 2174 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004432 { // Empty packed structure type?
4433 (yyval.TypeVal).PAT = new PATypeHolder(StructType::get(std::vector<const Type*>(),true));
Reid Spencerbb1fd572007-03-21 17:15:50 +00004434 (yyval.TypeVal).S.makeComposite();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004435 ;}
4436 break;
4437
4438 case 138:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004439#line 2178 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004440 { // Pointer type?
4441 if ((yyvsp[-1].TypeVal).PAT->get() == Type::LabelTy)
Reid Spencer950bf602007-01-26 08:19:09 +00004442 error("Cannot form a pointer to a basic block");
Reid Spencerbb1fd572007-03-21 17:15:50 +00004443 (yyval.TypeVal).S.makeComposite((yyvsp[-1].TypeVal).S);
4444 (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(PointerType::get((yyvsp[-1].TypeVal).PAT->get()),
4445 (yyval.TypeVal).S));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004446 delete (yyvsp[-1].TypeVal).PAT;
4447 ;}
4448 break;
4449
4450 case 139:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004451#line 2192 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004452 {
4453 (yyval.TypeList) = new std::list<PATypeInfo>();
4454 (yyval.TypeList)->push_back((yyvsp[0].TypeVal));
4455 ;}
4456 break;
4457
4458 case 140:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004459#line 2196 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004460 {
4461 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back((yyvsp[0].TypeVal));
4462 ;}
4463 break;
4464
4465 case 142:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004466#line 2204 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004467 {
Reid Spencer950bf602007-01-26 08:19:09 +00004468 PATypeInfo VoidTI;
Reid Spencered96d1e2007-02-08 09:08:52 +00004469 VoidTI.PAT = new PATypeHolder(Type::VoidTy);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004470 VoidTI.S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004471 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(VoidTI);
4472 ;}
4473 break;
4474
4475 case 143:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004476#line 2210 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004477 {
4478 (yyval.TypeList) = new std::list<PATypeInfo>();
Reid Spencer950bf602007-01-26 08:19:09 +00004479 PATypeInfo VoidTI;
Reid Spencered96d1e2007-02-08 09:08:52 +00004480 VoidTI.PAT = new PATypeHolder(Type::VoidTy);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004481 VoidTI.S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004482 (yyval.TypeList)->push_back(VoidTI);
4483 ;}
4484 break;
4485
4486 case 144:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004487#line 2217 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004488 {
4489 (yyval.TypeList) = new std::list<PATypeInfo>();
4490 ;}
4491 break;
4492
4493 case 145:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004494#line 2229 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004495 { // Nonempty unsized arr
4496 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004497 if (ATy == 0)
4498 error("Cannot make array constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004499 (yyvsp[-3].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004500 const Type *ETy = ATy->getElementType();
4501 int NumElements = ATy->getNumElements();
4502
4503 // Verify that we have the correct size...
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004504 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Reid Spencer950bf602007-01-26 08:19:09 +00004505 error("Type mismatch: constant sized array initialized with " +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004506 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer950bf602007-01-26 08:19:09 +00004507 itostr(NumElements) + "");
4508
4509 // Verify all elements are correct type!
4510 std::vector<Constant*> Elems;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004511 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4512 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004513 const Type* ValTy = C->getType();
4514 if (ETy != ValTy)
4515 error("Element #" + utostr(i) + " is not of type '" +
4516 ETy->getDescription() +"' as required!\nIt is of type '"+
4517 ValTy->getDescription() + "'");
4518 Elems.push_back(C);
4519 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004520 (yyval.ConstVal).C = ConstantArray::get(ATy, Elems);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004521 (yyval.ConstVal).S.copy((yyvsp[-3].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004522 delete (yyvsp[-3].TypeVal).PAT;
4523 delete (yyvsp[-1].ConstVector);
4524 ;}
4525 break;
4526
4527 case 146:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004528#line 2259 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004529 {
4530 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004531 if (ATy == 0)
4532 error("Cannot make array constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004533 (yyvsp[-2].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004534 int NumElements = ATy->getNumElements();
4535 if (NumElements != -1 && NumElements != 0)
4536 error("Type mismatch: constant sized array initialized with 0"
4537 " arguments, but has size of " + itostr(NumElements) +"");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004538 (yyval.ConstVal).C = ConstantArray::get(ATy, std::vector<Constant*>());
Reid Spencerbb1fd572007-03-21 17:15:50 +00004539 (yyval.ConstVal).S.copy((yyvsp[-2].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004540 delete (yyvsp[-2].TypeVal).PAT;
4541 ;}
4542 break;
4543
4544 case 147:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004545#line 2272 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004546 {
4547 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004548 if (ATy == 0)
4549 error("Cannot make array constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004550 (yyvsp[-2].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004551 int NumElements = ATy->getNumElements();
4552 const Type *ETy = dyn_cast<IntegerType>(ATy->getElementType());
4553 if (!ETy || cast<IntegerType>(ETy)->getBitWidth() != 8)
4554 error("String arrays require type i8, not '" + ETy->getDescription() +
4555 "'");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004556 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4557 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal)))
Reid Spencer950bf602007-01-26 08:19:09 +00004558 error("Can't build string constant of size " +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004559 itostr((int)(EndStr-(yyvsp[0].StrVal))) + " when array has size " +
Reid Spencer950bf602007-01-26 08:19:09 +00004560 itostr(NumElements) + "");
4561 std::vector<Constant*> Vals;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004562 for (char *C = (char *)(yyvsp[0].StrVal); C != (char *)EndStr; ++C)
Reid Spencer950bf602007-01-26 08:19:09 +00004563 Vals.push_back(ConstantInt::get(ETy, *C));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004564 free((yyvsp[0].StrVal));
4565 (yyval.ConstVal).C = ConstantArray::get(ATy, Vals);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004566 (yyval.ConstVal).S.copy((yyvsp[-2].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004567 delete (yyvsp[-2].TypeVal).PAT;
4568 ;}
4569 break;
4570
4571 case 148:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004572#line 2295 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004573 { // Nonempty unsized arr
4574 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[-3].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004575 if (PTy == 0)
4576 error("Cannot make packed constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004577 (yyvsp[-3].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004578 const Type *ETy = PTy->getElementType();
4579 int NumElements = PTy->getNumElements();
4580 // Verify that we have the correct size...
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004581 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Reid Spencer950bf602007-01-26 08:19:09 +00004582 error("Type mismatch: constant sized packed initialized with " +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004583 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer950bf602007-01-26 08:19:09 +00004584 itostr(NumElements) + "");
4585 // Verify all elements are correct type!
4586 std::vector<Constant*> Elems;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004587 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4588 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004589 const Type* ValTy = C->getType();
4590 if (ETy != ValTy)
4591 error("Element #" + utostr(i) + " is not of type '" +
4592 ETy->getDescription() +"' as required!\nIt is of type '"+
4593 ValTy->getDescription() + "'");
4594 Elems.push_back(C);
4595 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004596 (yyval.ConstVal).C = ConstantVector::get(PTy, Elems);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004597 (yyval.ConstVal).S.copy((yyvsp[-3].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004598 delete (yyvsp[-3].TypeVal).PAT;
4599 delete (yyvsp[-1].ConstVector);
4600 ;}
4601 break;
4602
4603 case 149:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004604#line 2323 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004605 {
4606 const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004607 if (STy == 0)
4608 error("Cannot make struct constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004609 (yyvsp[-3].TypeVal).PAT->get()->getDescription() + "'");
4610 if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencer950bf602007-01-26 08:19:09 +00004611 error("Illegal number of initializers for structure type");
4612
4613 // Check to ensure that constants are compatible with the type initializer!
4614 std::vector<Constant*> Fields;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004615 for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i) {
4616 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004617 if (C->getType() != STy->getElementType(i))
4618 error("Expected type '" + STy->getElementType(i)->getDescription() +
4619 "' for element #" + utostr(i) + " of structure initializer");
4620 Fields.push_back(C);
4621 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004622 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004623 (yyval.ConstVal).S.copy((yyvsp[-3].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004624 delete (yyvsp[-3].TypeVal).PAT;
4625 delete (yyvsp[-1].ConstVector);
4626 ;}
4627 break;
4628
4629 case 150:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004630#line 2345 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004631 {
4632 const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004633 if (STy == 0)
4634 error("Cannot make struct constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004635 (yyvsp[-2].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004636 if (STy->getNumContainedTypes() != 0)
4637 error("Illegal number of initializers for structure type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004638 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
Reid Spencerbb1fd572007-03-21 17:15:50 +00004639 (yyval.ConstVal).S.copy((yyvsp[-2].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004640 delete (yyvsp[-2].TypeVal).PAT;
4641 ;}
4642 break;
4643
4644 case 151:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004645#line 2356 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004646 {
4647 const StructType *STy = dyn_cast<StructType>((yyvsp[-5].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004648 if (STy == 0)
4649 error("Cannot make packed struct constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004650 (yyvsp[-5].TypeVal).PAT->get()->getDescription() + "'");
4651 if ((yyvsp[-2].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencer950bf602007-01-26 08:19:09 +00004652 error("Illegal number of initializers for packed structure type");
4653
4654 // Check to ensure that constants are compatible with the type initializer!
4655 std::vector<Constant*> Fields;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004656 for (unsigned i = 0, e = (yyvsp[-2].ConstVector)->size(); i != e; ++i) {
4657 Constant *C = (*(yyvsp[-2].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00004658 if (C->getType() != STy->getElementType(i))
4659 error("Expected type '" + STy->getElementType(i)->getDescription() +
4660 "' for element #" + utostr(i) + " of packed struct initializer");
4661 Fields.push_back(C);
4662 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004663 (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004664 (yyval.ConstVal).S.copy((yyvsp[-5].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004665 delete (yyvsp[-5].TypeVal).PAT;
4666 delete (yyvsp[-2].ConstVector);
4667 ;}
4668 break;
4669
4670 case 152:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004671#line 2378 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004672 {
4673 const StructType *STy = dyn_cast<StructType>((yyvsp[-4].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004674 if (STy == 0)
4675 error("Cannot make packed struct constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004676 (yyvsp[-4].TypeVal).PAT->get()->getDescription() + "'");
Reid Spencer950bf602007-01-26 08:19:09 +00004677 if (STy->getNumContainedTypes() != 0)
4678 error("Illegal number of initializers for packed structure type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004679 (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
Reid Spencerbb1fd572007-03-21 17:15:50 +00004680 (yyval.ConstVal).S.copy((yyvsp[-4].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004681 delete (yyvsp[-4].TypeVal).PAT;
4682 ;}
4683 break;
4684
4685 case 153:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004686#line 2389 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004687 {
4688 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004689 if (PTy == 0)
4690 error("Cannot make null pointer constant with type: '" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004691 (yyvsp[-1].TypeVal).PAT->get()->getDescription() + "'");
4692 (yyval.ConstVal).C = ConstantPointerNull::get(PTy);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004693 (yyval.ConstVal).S.copy((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004694 delete (yyvsp[-1].TypeVal).PAT;
4695 ;}
4696 break;
4697
4698 case 154:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004699#line 2398 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004700 {
4701 (yyval.ConstVal).C = UndefValue::get((yyvsp[-1].TypeVal).PAT->get());
Reid Spencerbb1fd572007-03-21 17:15:50 +00004702 (yyval.ConstVal).S.copy((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004703 delete (yyvsp[-1].TypeVal).PAT;
4704 ;}
4705 break;
4706
4707 case 155:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004708#line 2403 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004709 {
4710 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal).PAT->get());
Reid Spencer950bf602007-01-26 08:19:09 +00004711 if (Ty == 0)
4712 error("Global const reference must be a pointer type, not" +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004713 (yyvsp[-1].TypeVal).PAT->get()->getDescription());
Reid Spencer950bf602007-01-26 08:19:09 +00004714
4715 // ConstExprs can exist in the body of a function, thus creating
4716 // GlobalValues whenever they refer to a variable. Because we are in
4717 // the context of a function, getExistingValue will search the functions
4718 // symbol table instead of the module symbol table for the global symbol,
4719 // which throws things all off. To get around this, we just tell
4720 // getExistingValue that we are at global scope here.
4721 //
4722 Function *SavedCurFn = CurFun.CurrentFunction;
4723 CurFun.CurrentFunction = 0;
Reid Spencerbb1fd572007-03-21 17:15:50 +00004724 (yyvsp[0].ValIDVal).S.copy((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004725 Value *V = getExistingValue(Ty, (yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00004726 CurFun.CurrentFunction = SavedCurFn;
4727
4728 // If this is an initializer for a constant pointer, which is referencing a
4729 // (currently) undefined variable, create a stub now that shall be replaced
4730 // in the future with the right type of variable.
4731 //
4732 if (V == 0) {
4733 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers");
4734 const PointerType *PT = cast<PointerType>(Ty);
4735
4736 // First check to see if the forward references value is already created!
4737 PerModuleInfo::GlobalRefsType::iterator I =
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004738 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00004739
4740 if (I != CurModule.GlobalRefs.end()) {
4741 V = I->second; // Placeholder already exists, use it...
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004742 (yyvsp[0].ValIDVal).destroy();
Reid Spencer950bf602007-01-26 08:19:09 +00004743 } else {
4744 std::string Name;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004745 if ((yyvsp[0].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[0].ValIDVal).Name;
Reid Spencer950bf602007-01-26 08:19:09 +00004746
4747 // Create the forward referenced global.
4748 GlobalValue *GV;
4749 if (const FunctionType *FTy =
4750 dyn_cast<FunctionType>(PT->getElementType())) {
4751 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
4752 CurModule.CurrentModule);
4753 } else {
4754 GV = new GlobalVariable(PT->getElementType(), false,
4755 GlobalValue::ExternalLinkage, 0,
4756 Name, CurModule.CurrentModule);
4757 }
4758
4759 // Keep track of the fact that we have a forward ref to recycle it
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004760 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV));
Reid Spencer950bf602007-01-26 08:19:09 +00004761 V = GV;
4762 }
4763 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004764 (yyval.ConstVal).C = cast<GlobalValue>(V);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004765 (yyval.ConstVal).S.copy((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004766 delete (yyvsp[-1].TypeVal).PAT; // Free the type handle
4767 ;}
4768 break;
4769
4770 case 156:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004771#line 2462 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004772 {
4773 if ((yyvsp[-1].TypeVal).PAT->get() != (yyvsp[0].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004774 error("Mismatched types for constant expression");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004775 (yyval.ConstVal) = (yyvsp[0].ConstVal);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004776 (yyval.ConstVal).S.copy((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004777 delete (yyvsp[-1].TypeVal).PAT;
4778 ;}
4779 break;
4780
4781 case 157:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004782#line 2469 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004783 {
4784 const Type *Ty = (yyvsp[-1].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00004785 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4786 error("Cannot create a null initialized value of this type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004787 (yyval.ConstVal).C = Constant::getNullValue(Ty);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004788 (yyval.ConstVal).S.copy((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004789 delete (yyvsp[-1].TypeVal).PAT;
4790 ;}
4791 break;
4792
4793 case 158:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004794#line 2477 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004795 { // integral constants
4796 const Type *Ty = (yyvsp[-1].PrimType).T;
4797 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[0].SInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00004798 error("Constant value doesn't fit in type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004799 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[0].SInt64Val));
Reid Spencerbb1fd572007-03-21 17:15:50 +00004800 (yyval.ConstVal).S.makeSigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004801 ;}
4802 break;
4803
4804 case 159:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004805#line 2484 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004806 { // integral constants
4807 const Type *Ty = (yyvsp[-1].PrimType).T;
4808 if (!ConstantInt::isValueValidForType(Ty, (yyvsp[0].UInt64Val)))
Reid Spencer950bf602007-01-26 08:19:09 +00004809 error("Constant value doesn't fit in type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004810 (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[0].UInt64Val));
Reid Spencerbb1fd572007-03-21 17:15:50 +00004811 (yyval.ConstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004812 ;}
4813 break;
4814
4815 case 160:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004816#line 2491 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004817 { // Boolean constants
4818 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, true);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004819 (yyval.ConstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004820 ;}
4821 break;
4822
4823 case 161:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004824#line 2495 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004825 { // Boolean constants
4826 (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, false);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004827 (yyval.ConstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004828 ;}
4829 break;
4830
4831 case 162:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004832#line 2499 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004833 { // Float & Double constants
4834 if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType).T, (yyvsp[0].FPVal)))
Reid Spencer950bf602007-01-26 08:19:09 +00004835 error("Floating point constant invalid for type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004836 (yyval.ConstVal).C = ConstantFP::get((yyvsp[-1].PrimType).T, (yyvsp[0].FPVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00004837 (yyval.ConstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004838 ;}
4839 break;
4840
4841 case 163:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004842#line 2508 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004843 {
4844 const Type* SrcTy = (yyvsp[-3].ConstVal).C->getType();
4845 const Type* DstTy = (yyvsp[-1].TypeVal).PAT->get();
Reid Spencerbb1fd572007-03-21 17:15:50 +00004846 Signedness SrcSign((yyvsp[-3].ConstVal).S);
4847 Signedness DstSign((yyvsp[-1].TypeVal).S);
Reid Spencer950bf602007-01-26 08:19:09 +00004848 if (!SrcTy->isFirstClassType())
4849 error("cast constant expression from a non-primitive type: '" +
4850 SrcTy->getDescription() + "'");
4851 if (!DstTy->isFirstClassType())
4852 error("cast constant expression to a non-primitive type: '" +
4853 DstTy->getDescription() + "'");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004854 (yyval.ConstVal).C = cast<Constant>(getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal).C, SrcSign, DstTy, DstSign));
Reid Spencerbb1fd572007-03-21 17:15:50 +00004855 (yyval.ConstVal).S.copy(DstSign);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004856 delete (yyvsp[-1].TypeVal).PAT;
4857 ;}
4858 break;
4859
4860 case 164:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004861#line 2523 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004862 {
4863 const Type *Ty = (yyvsp[-2].ConstVal).C->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00004864 if (!isa<PointerType>(Ty))
4865 error("GetElementPtr requires a pointer operand");
4866
4867 std::vector<Value*> VIndices;
4868 std::vector<Constant*> CIndices;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004869 upgradeGEPIndices((yyvsp[-2].ConstVal).C->getType(), (yyvsp[-1].ValueList), VIndices, &CIndices);
Reid Spencer950bf602007-01-26 08:19:09 +00004870
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004871 delete (yyvsp[-1].ValueList);
4872 (yyval.ConstVal).C = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal).C, &CIndices[0], CIndices.size());
Reid Spencerbb1fd572007-03-21 17:15:50 +00004873 (yyval.ConstVal).S.copy(getElementSign((yyvsp[-2].ConstVal), CIndices));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004874 ;}
4875 break;
4876
4877 case 165:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004878#line 2536 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004879 {
4880 if (!(yyvsp[-5].ConstVal).C->getType()->isInteger() ||
4881 cast<IntegerType>((yyvsp[-5].ConstVal).C->getType())->getBitWidth() != 1)
Reid Spencer950bf602007-01-26 08:19:09 +00004882 error("Select condition must be bool type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004883 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004884 error("Select operand types must match");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004885 (yyval.ConstVal).C = ConstantExpr::getSelect((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004886 (yyval.ConstVal).S.copy((yyvsp[-3].ConstVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004887 ;}
4888 break;
4889
4890 case 166:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004891#line 2545 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004892 {
4893 const Type *Ty = (yyvsp[-3].ConstVal).C->getType();
4894 if (Ty != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004895 error("Binary operator types must match");
4896 // First, make sure we're dealing with the right opcode by upgrading from
4897 // obsolete versions.
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004898 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S);
Reid Spencer950bf602007-01-26 08:19:09 +00004899
4900 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
4901 // To retain backward compatibility with these early compilers, we emit a
4902 // cast to the appropriate integer type automatically if we are in the
4903 // broken case. See PR424 for more information.
4904 if (!isa<PointerType>(Ty)) {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004905 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencer950bf602007-01-26 08:19:09 +00004906 } else {
4907 const Type *IntPtrTy = 0;
4908 switch (CurModule.CurrentModule->getPointerSize()) {
4909 case Module::Pointer32: IntPtrTy = Type::Int32Ty; break;
4910 case Module::Pointer64: IntPtrTy = Type::Int64Ty; break;
4911 default: error("invalid pointer binary constant expr");
4912 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004913 (yyval.ConstVal).C = ConstantExpr::get(Opcode,
4914 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[-3].ConstVal).C, IntPtrTy),
4915 ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[-1].ConstVal).C, IntPtrTy));
4916 (yyval.ConstVal).C = ConstantExpr::getCast(Instruction::IntToPtr, (yyval.ConstVal).C, Ty);
Reid Spencer950bf602007-01-26 08:19:09 +00004917 }
Reid Spencerbb1fd572007-03-21 17:15:50 +00004918 (yyval.ConstVal).S.copy((yyvsp[-3].ConstVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004919 ;}
4920 break;
4921
4922 case 167:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004923#line 2573 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004924 {
4925 const Type* Ty = (yyvsp[-3].ConstVal).C->getType();
4926 if (Ty != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004927 error("Logical operator types must match");
4928 if (!Ty->isInteger()) {
Reid Spencer9d6565a2007-02-15 02:26:10 +00004929 if (!isa<VectorType>(Ty) ||
4930 !cast<VectorType>(Ty)->getElementType()->isInteger())
Reid Spencer950bf602007-01-26 08:19:09 +00004931 error("Logical operator requires integer operands");
4932 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004933 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S);
4934 (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004935 (yyval.ConstVal).S.copy((yyvsp[-3].ConstVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004936 ;}
4937 break;
4938
4939 case 168:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004940#line 2586 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004941 {
4942 const Type* Ty = (yyvsp[-3].ConstVal).C->getType();
4943 if (Ty != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004944 error("setcc operand types must match");
4945 unsigned short pred;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004946 Instruction::OtherOps Opcode = getCompareOp((yyvsp[-5].BinaryOpVal), pred, Ty, (yyvsp[-3].ConstVal).S);
4947 (yyval.ConstVal).C = ConstantExpr::getCompare(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004948 (yyval.ConstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004949 ;}
4950 break;
4951
4952 case 169:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004953#line 2595 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004954 {
4955 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004956 error("icmp operand types must match");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004957 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[-5].IPred), (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004958 (yyval.ConstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004959 ;}
4960 break;
4961
4962 case 170:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004963#line 2601 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004964 {
4965 if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00004966 error("fcmp operand types must match");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004967 (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[-5].FPred), (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004968 (yyval.ConstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004969 ;}
4970 break;
4971
4972 case 171:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004973#line 2607 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004974 {
4975 if (!(yyvsp[-1].ConstVal).C->getType()->isInteger() ||
4976 cast<IntegerType>((yyvsp[-1].ConstVal).C->getType())->getBitWidth() != 8)
Reid Spencer950bf602007-01-26 08:19:09 +00004977 error("Shift count for shift constant must be unsigned byte");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004978 const Type* Ty = (yyvsp[-3].ConstVal).C->getType();
4979 if (!(yyvsp[-3].ConstVal).C->getType()->isInteger())
Reid Spencer950bf602007-01-26 08:19:09 +00004980 error("Shift constant expression requires integer operand");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004981 Constant *ShiftAmt = ConstantExpr::getZExt((yyvsp[-1].ConstVal).C, Ty);
4982 (yyval.ConstVal).C = ConstantExpr::get(getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S), (yyvsp[-3].ConstVal).C, ShiftAmt);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004983 (yyval.ConstVal).S.copy((yyvsp[-3].ConstVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004984 ;}
4985 break;
4986
4987 case 172:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004988#line 2618 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004989 {
4990 if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
Reid Spencer950bf602007-01-26 08:19:09 +00004991 error("Invalid extractelement operands");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004992 (yyval.ConstVal).C = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencerbb1fd572007-03-21 17:15:50 +00004993 (yyval.ConstVal).S.copy((yyvsp[-3].ConstVal).S.get(0));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004994 ;}
4995 break;
4996
4997 case 173:
Reid Spencerbaba98a2007-04-11 12:10:58 +00004998#line 2624 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00004999 {
5000 if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
Reid Spencer950bf602007-01-26 08:19:09 +00005001 error("Invalid insertelement operands");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005002 (yyval.ConstVal).C = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005003 (yyval.ConstVal).S.copy((yyvsp[-5].ConstVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005004 ;}
5005 break;
5006
5007 case 174:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005008#line 2630 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005009 {
5010 if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C))
Reid Spencer950bf602007-01-26 08:19:09 +00005011 error("Invalid shufflevector operands");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005012 (yyval.ConstVal).C = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005013 (yyval.ConstVal).S.copy((yyvsp[-5].ConstVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005014 ;}
5015 break;
5016
5017 case 175:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005018#line 2641 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005019 { ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal)); ;}
5020 break;
5021
5022 case 176:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005023#line 2642 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005024 {
5025 (yyval.ConstVector) = new std::vector<ConstInfo>();
5026 (yyval.ConstVector)->push_back((yyvsp[0].ConstVal));
5027 ;}
5028 break;
5029
5030 case 177:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005031#line 2651 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005032 { (yyval.BoolVal) = false; ;}
5033 break;
5034
5035 case 178:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005036#line 2652 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005037 { (yyval.BoolVal) = true; ;}
5038 break;
5039
5040 case 179:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005041#line 2664 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005042 {
5043 (yyval.ModuleVal) = ParserResult = (yyvsp[0].ModuleVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005044 CurModule.ModuleDone();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005045 ;}
5046 break;
5047
5048 case 180:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005049#line 2673 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005050 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); CurFun.FunctionDone(); ;}
5051 break;
5052
5053 case 181:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005054#line 2674 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005055 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); ;}
5056 break;
5057
5058 case 182:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005059#line 2675 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005060 { (yyval.ModuleVal) = (yyvsp[-3].ModuleVal); ;}
5061 break;
5062
5063 case 183:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005064#line 2676 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005065 { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); ;}
5066 break;
5067
5068 case 184:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005069#line 2677 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005070 {
5071 (yyval.ModuleVal) = CurModule.CurrentModule;
Reid Spencer950bf602007-01-26 08:19:09 +00005072 // Emit an error if there are any unresolved types left.
5073 if (!CurModule.LateResolveTypes.empty()) {
5074 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
5075 if (DID.Type == ValID::NameVal) {
5076 error("Reference to an undefined type: '"+DID.getName() + "'");
5077 } else {
5078 error("Reference to an undefined type: #" + itostr(DID.Num));
5079 }
5080 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005081 ;}
5082 break;
5083
5084 case 185:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005085#line 2693 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005086 {
Reid Spencer950bf602007-01-26 08:19:09 +00005087 // Eagerly resolve types. This is not an optimization, this is a
5088 // requirement that is due to the fact that we could have this:
5089 //
5090 // %list = type { %list * }
5091 // %list = type { %list * } ; repeated type decl
5092 //
5093 // If types are not resolved eagerly, then the two types will not be
5094 // determined to be the same type!
5095 //
Reid Spencerbb1fd572007-03-21 17:15:50 +00005096 ResolveTypeTo((yyvsp[-2].StrVal), (yyvsp[0].TypeVal).PAT->get(), (yyvsp[0].TypeVal).S);
Reid Spencer950bf602007-01-26 08:19:09 +00005097
Reid Spencerbb1fd572007-03-21 17:15:50 +00005098 if (!setTypeName((yyvsp[0].TypeVal), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
5099 // If this is a numbered type that is not a redefinition, add it to the
5100 // slot table.
5101 CurModule.Types.push_back((yyvsp[0].TypeVal).PAT->get());
5102 CurModule.TypeSigns.push_back((yyvsp[0].TypeVal).S);
Reid Spencera50d5962006-12-02 04:11:07 +00005103 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005104 delete (yyvsp[0].TypeVal).PAT;
5105 ;}
5106 break;
5107
5108 case 186:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005109#line 2713 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005110 { // Function prototypes can be in const pool
5111 ;}
5112 break;
5113
5114 case 187:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005115#line 2715 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005116 { // Asm blocks can be in the const pool
5117 ;}
5118 break;
5119
5120 case 188:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005121#line 2717 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005122 {
5123 if ((yyvsp[0].ConstVal).C == 0)
Reid Spencer950bf602007-01-26 08:19:09 +00005124 error("Global value initializer is not a constant");
Reid Spencerbb1fd572007-03-21 17:15:50 +00005125 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), (yyvsp[-2].Linkage), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal).C->getType(), (yyvsp[0].ConstVal).C, (yyvsp[0].ConstVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005126 ;}
5127 break;
5128
5129 case 189:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005130#line 2721 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005131 {
Reid Spencer950bf602007-01-26 08:19:09 +00005132 CurGV = 0;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005133 ;}
5134 break;
5135
5136 case 190:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005137#line 2724 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005138 {
5139 const Type *Ty = (yyvsp[0].TypeVal).PAT->get();
Reid Spencerbb1fd572007-03-21 17:15:50 +00005140 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage, (yyvsp[-1].BoolVal), Ty, 0,
5141 (yyvsp[0].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005142 delete (yyvsp[0].TypeVal).PAT;
5143 ;}
5144 break;
5145
5146 case 191:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005147#line 2729 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005148 {
Reid Spencer950bf602007-01-26 08:19:09 +00005149 CurGV = 0;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005150 ;}
5151 break;
5152
5153 case 192:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005154#line 2732 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005155 {
5156 const Type *Ty = (yyvsp[0].TypeVal).PAT->get();
Reid Spencerbb1fd572007-03-21 17:15:50 +00005157 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[-1].BoolVal), Ty, 0,
5158 (yyvsp[0].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005159 delete (yyvsp[0].TypeVal).PAT;
5160 ;}
5161 break;
5162
5163 case 193:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005164#line 2737 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005165 {
Reid Spencer950bf602007-01-26 08:19:09 +00005166 CurGV = 0;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005167 ;}
5168 break;
5169
5170 case 194:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005171#line 2740 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005172 {
5173 const Type *Ty = (yyvsp[0].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005174 CurGV =
Reid Spencerbb1fd572007-03-21 17:15:50 +00005175 ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[-1].BoolVal), Ty, 0,
5176 (yyvsp[0].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005177 delete (yyvsp[0].TypeVal).PAT;
5178 ;}
5179 break;
5180
5181 case 195:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005182#line 2746 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005183 {
Reid Spencer950bf602007-01-26 08:19:09 +00005184 CurGV = 0;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005185 ;}
5186 break;
5187
5188 case 196:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005189#line 2749 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005190 {
5191 ;}
5192 break;
5193
5194 case 197:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005195#line 2751 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005196 {
5197 ;}
5198 break;
5199
5200 case 198:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005201#line 2753 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005202 {
5203 ;}
5204 break;
5205
5206 case 199:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005207#line 2758 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005208 {
Reid Spencer950bf602007-01-26 08:19:09 +00005209 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005210 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
5211 std::string NewAsm((yyvsp[0].StrVal), EndStr);
5212 free((yyvsp[0].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005213
5214 if (AsmSoFar.empty())
5215 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
5216 else
5217 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005218 ;}
5219 break;
5220
5221 case 200:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005222#line 2772 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005223 { (yyval.Endianness) = Module::BigEndian; ;}
5224 break;
5225
5226 case 201:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005227#line 2773 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005228 { (yyval.Endianness) = Module::LittleEndian; ;}
5229 break;
5230
5231 case 202:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005232#line 2777 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005233 {
5234 CurModule.setEndianness((yyvsp[0].Endianness));
5235 ;}
5236 break;
5237
5238 case 203:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005239#line 2780 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005240 {
5241 if ((yyvsp[0].UInt64Val) == 32)
Reid Spencer950bf602007-01-26 08:19:09 +00005242 CurModule.setPointerSize(Module::Pointer32);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005243 else if ((yyvsp[0].UInt64Val) == 64)
Reid Spencer950bf602007-01-26 08:19:09 +00005244 CurModule.setPointerSize(Module::Pointer64);
5245 else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005246 error("Invalid pointer size: '" + utostr((yyvsp[0].UInt64Val)) + "'");
5247 ;}
5248 break;
Reid Spencer9d6565a2007-02-15 02:26:10 +00005249
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005250 case 204:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005251#line 2788 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005252 {
5253 CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal));
5254 free((yyvsp[0].StrVal));
5255 ;}
5256 break;
5257
5258 case 205:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005259#line 2792 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005260 {
5261 CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal));
5262 free((yyvsp[0].StrVal));
5263 ;}
5264 break;
5265
5266 case 207:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005267#line 2803 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005268 {
5269 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
5270 free((yyvsp[0].StrVal));
5271 ;}
5272 break;
5273
5274 case 208:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005275#line 2807 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005276 {
5277 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
5278 free((yyvsp[0].StrVal));
5279 ;}
5280 break;
5281
5282 case 209:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005283#line 2811 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005284 { ;}
5285 break;
5286
5287 case 213:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005288#line 2824 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005289 { (yyval.StrVal) = 0; ;}
5290 break;
5291
5292 case 214:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005293#line 2828 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005294 {
5295 if ((yyvsp[-1].TypeVal).PAT->get() == Type::VoidTy)
5296 error("void typed arguments are invalid");
5297 (yyval.ArgVal) = new std::pair<PATypeInfo, char*>((yyvsp[-1].TypeVal), (yyvsp[0].StrVal));
5298 ;}
5299 break;
5300
5301 case 215:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005302#line 2836 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005303 {
5304 (yyval.ArgList) = (yyvsp[-2].ArgList);
5305 (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal));
5306 delete (yyvsp[0].ArgVal);
5307 ;}
5308 break;
5309
5310 case 216:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005311#line 2841 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005312 {
5313 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
5314 (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal));
5315 delete (yyvsp[0].ArgVal);
5316 ;}
5317 break;
5318
5319 case 217:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005320#line 2849 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005321 { (yyval.ArgList) = (yyvsp[0].ArgList); ;}
5322 break;
5323
5324 case 218:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005325#line 2850 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005326 {
5327 (yyval.ArgList) = (yyvsp[-2].ArgList);
5328 PATypeInfo VoidTI;
5329 VoidTI.PAT = new PATypeHolder(Type::VoidTy);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005330 VoidTI.S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005331 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
5332 ;}
5333 break;
5334
5335 case 219:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005336#line 2857 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005337 {
5338 (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
5339 PATypeInfo VoidTI;
5340 VoidTI.PAT = new PATypeHolder(Type::VoidTy);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005341 VoidTI.S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005342 (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
5343 ;}
5344 break;
5345
5346 case 220:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005347#line 2864 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005348 { (yyval.ArgList) = 0; ;}
5349 break;
5350
5351 case 221:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005352#line 2868 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005353 {
5354 UnEscapeLexed((yyvsp[-5].StrVal));
5355 std::string FunctionName((yyvsp[-5].StrVal));
5356 free((yyvsp[-5].StrVal)); // Free strdup'd memory!
5357
5358 const Type* RetTy = (yyvsp[-6].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00005359
5360 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
5361 error("LLVM functions cannot return aggregate types");
5362
Reid Spencerbb1fd572007-03-21 17:15:50 +00005363 Signedness FTySign;
5364 FTySign.makeComposite((yyvsp[-6].TypeVal).S);
Reid Spenceref9b9a72007-02-05 20:47:22 +00005365 std::vector<const Type*> ParamTyList;
Reid Spencer950bf602007-01-26 08:19:09 +00005366
5367 // In LLVM 2.0 the signatures of three varargs intrinsics changed to take
5368 // i8*. We check here for those names and override the parameter list
5369 // types to ensure the prototype is correct.
5370 if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005371 ParamTyList.push_back(PointerType::get(Type::Int8Ty));
Reid Spencer950bf602007-01-26 08:19:09 +00005372 } else if (FunctionName == "llvm.va_copy") {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005373 ParamTyList.push_back(PointerType::get(Type::Int8Ty));
5374 ParamTyList.push_back(PointerType::get(Type::Int8Ty));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005375 } else if ((yyvsp[-3].ArgList)) { // If there are arguments...
Reid Spencer950bf602007-01-26 08:19:09 +00005376 for (std::vector<std::pair<PATypeInfo,char*> >::iterator
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005377 I = (yyvsp[-3].ArgList)->begin(), E = (yyvsp[-3].ArgList)->end(); I != E; ++I) {
Reid Spencered96d1e2007-02-08 09:08:52 +00005378 const Type *Ty = I->first.PAT->get();
Reid Spenceref9b9a72007-02-05 20:47:22 +00005379 ParamTyList.push_back(Ty);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005380 FTySign.add(I->first.S);
Reid Spencer950bf602007-01-26 08:19:09 +00005381 }
5382 }
5383
Reid Spenceref9b9a72007-02-05 20:47:22 +00005384 bool isVarArg = ParamTyList.size() && ParamTyList.back() == Type::VoidTy;
5385 if (isVarArg)
5386 ParamTyList.pop_back();
Reid Spencer950bf602007-01-26 08:19:09 +00005387
Reid Spencerb7046c72007-01-29 05:41:34 +00005388 // Convert the CSRet calling convention into the corresponding parameter
5389 // attribute.
Reid Spencer7b5d4662007-04-09 06:16:21 +00005390 ParamAttrsList *ParamAttrs = 0;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005391 if ((yyvsp[-7].UIntVal) == OldCallingConv::CSRet) {
Reid Spencer7b5d4662007-04-09 06:16:21 +00005392 ParamAttrs = new ParamAttrsList();
Reid Spencer18da0722007-04-11 02:44:20 +00005393 ParamAttrs->addAttributes(0, ParamAttr::None); // result
5394 ParamAttrs->addAttributes(1, ParamAttr::StructRet); // first arg
Reid Spencerb7046c72007-01-29 05:41:34 +00005395 }
5396
Reid Spencer7b5d4662007-04-09 06:16:21 +00005397 const FunctionType *FT =
5398 FunctionType::get(RetTy, ParamTyList, isVarArg, ParamAttrs);
Reid Spencer950bf602007-01-26 08:19:09 +00005399 const PointerType *PFT = PointerType::get(FT);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005400 delete (yyvsp[-6].TypeVal).PAT;
Reid Spencer950bf602007-01-26 08:19:09 +00005401
5402 ValID ID;
5403 if (!FunctionName.empty()) {
Reid Spencer5eb77c72007-03-15 03:26:42 +00005404 ID = ValID::create((char*)FunctionName.c_str());
Reid Spencer950bf602007-01-26 08:19:09 +00005405 } else {
Reid Spencer5eb77c72007-03-15 03:26:42 +00005406 ID = ValID::create((int)CurModule.Values[PFT].size());
Reid Spencer950bf602007-01-26 08:19:09 +00005407 }
Reid Spencerbb1fd572007-03-21 17:15:50 +00005408 ID.S.makeComposite(FTySign);
Reid Spencer950bf602007-01-26 08:19:09 +00005409
5410 Function *Fn = 0;
Reid Spencered96d1e2007-02-08 09:08:52 +00005411 Module* M = CurModule.CurrentModule;
5412
Reid Spencer950bf602007-01-26 08:19:09 +00005413 // See if this function was forward referenced. If so, recycle the object.
5414 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
5415 // Move the function to the end of the list, from whereever it was
5416 // previously inserted.
5417 Fn = cast<Function>(FWRef);
Reid Spencered96d1e2007-02-08 09:08:52 +00005418 M->getFunctionList().remove(Fn);
5419 M->getFunctionList().push_back(Fn);
5420 } else if (!FunctionName.empty()) {
5421 GlobalValue *Conflict = M->getFunction(FunctionName);
5422 if (!Conflict)
5423 Conflict = M->getNamedGlobal(FunctionName);
5424 if (Conflict && PFT == Conflict->getType()) {
5425 if (!CurFun.isDeclare && !Conflict->isDeclaration()) {
5426 // We have two function definitions that conflict, same type, same
5427 // name. We should really check to make sure that this is the result
5428 // of integer type planes collapsing and generate an error if it is
5429 // not, but we'll just rename on the assumption that it is. However,
5430 // let's do it intelligently and rename the internal linkage one
5431 // if there is one.
5432 std::string NewName(makeNameUnique(FunctionName));
5433 if (Conflict->hasInternalLinkage()) {
5434 Conflict->setName(NewName);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005435 RenameMapKey Key =
5436 makeRenameMapKey(FunctionName, Conflict->getType(), ID.S);
Reid Spencered96d1e2007-02-08 09:08:52 +00005437 CurModule.RenameMap[Key] = NewName;
5438 Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
5439 InsertValue(Fn, CurModule.Values);
5440 } else {
5441 Fn = new Function(FT, CurFun.Linkage, NewName, M);
5442 InsertValue(Fn, CurModule.Values);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005443 RenameMapKey Key =
5444 makeRenameMapKey(FunctionName, PFT, ID.S);
Reid Spencered96d1e2007-02-08 09:08:52 +00005445 CurModule.RenameMap[Key] = NewName;
5446 }
5447 } else {
5448 // If they are not both definitions, then just use the function we
5449 // found since the types are the same.
5450 Fn = cast<Function>(Conflict);
Reid Spenceref9b9a72007-02-05 20:47:22 +00005451
Reid Spencered96d1e2007-02-08 09:08:52 +00005452 // Make sure to strip off any argument names so we can't get
5453 // conflicts.
5454 if (Fn->isDeclaration())
5455 for (Function::arg_iterator AI = Fn->arg_begin(),
5456 AE = Fn->arg_end(); AI != AE; ++AI)
5457 AI->setName("");
5458 }
5459 } else if (Conflict) {
5460 // We have two globals with the same name and different types.
5461 // Previously, this was permitted because the symbol table had
5462 // "type planes" and names only needed to be distinct within a
5463 // type plane. After PR411 was fixed, this is no loner the case.
5464 // To resolve this we must rename one of the two.
5465 if (Conflict->hasInternalLinkage()) {
Reid Spencerbb1fd572007-03-21 17:15:50 +00005466 // We can safely rename the Conflict.
5467 RenameMapKey Key =
5468 makeRenameMapKey(Conflict->getName(), Conflict->getType(),
5469 CurModule.NamedValueSigns[Conflict->getName()]);
Reid Spencered96d1e2007-02-08 09:08:52 +00005470 Conflict->setName(makeNameUnique(Conflict->getName()));
Reid Spencered96d1e2007-02-08 09:08:52 +00005471 CurModule.RenameMap[Key] = Conflict->getName();
5472 Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
5473 InsertValue(Fn, CurModule.Values);
Reid Spencerd2920cd2007-03-21 17:27:53 +00005474 } else {
Reid Spencered96d1e2007-02-08 09:08:52 +00005475 // We can't quietly rename either of these things, but we must
Reid Spencerd2920cd2007-03-21 17:27:53 +00005476 // rename one of them. Only if the function's linkage is internal can
5477 // we forgo a warning message about the renamed function.
Reid Spencered96d1e2007-02-08 09:08:52 +00005478 std::string NewName = makeNameUnique(FunctionName);
Reid Spencerd2920cd2007-03-21 17:27:53 +00005479 if (CurFun.Linkage != GlobalValue::InternalLinkage) {
5480 warning("Renaming function '" + FunctionName + "' as '" + NewName +
5481 "' may cause linkage errors");
5482 }
5483 // Elect to rename the thing we're now defining.
Reid Spencered96d1e2007-02-08 09:08:52 +00005484 Fn = new Function(FT, CurFun.Linkage, NewName, M);
5485 InsertValue(Fn, CurModule.Values);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005486 RenameMapKey Key = makeRenameMapKey(FunctionName, PFT, ID.S);
Reid Spencered96d1e2007-02-08 09:08:52 +00005487 CurModule.RenameMap[Key] = NewName;
Reid Spencerd2920cd2007-03-21 17:27:53 +00005488 }
Reid Spenceref9b9a72007-02-05 20:47:22 +00005489 } else {
Reid Spencered96d1e2007-02-08 09:08:52 +00005490 // There's no conflict, just define the function
5491 Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
5492 InsertValue(Fn, CurModule.Values);
Reid Spenceref9b9a72007-02-05 20:47:22 +00005493 }
Reid Spencer950bf602007-01-26 08:19:09 +00005494 }
5495
5496 CurFun.FunctionStart(Fn);
5497
5498 if (CurFun.isDeclare) {
5499 // If we have declaration, always overwrite linkage. This will allow us
5500 // to correctly handle cases, when pointer to function is passed as
5501 // argument to another function.
5502 Fn->setLinkage(CurFun.Linkage);
5503 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005504 Fn->setCallingConv(upgradeCallingConv((yyvsp[-7].UIntVal)));
5505 Fn->setAlignment((yyvsp[0].UIntVal));
5506 if ((yyvsp[-1].StrVal)) {
5507 Fn->setSection((yyvsp[-1].StrVal));
5508 free((yyvsp[-1].StrVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005509 }
5510
5511 // Add all of the arguments we parsed to the function...
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005512 if ((yyvsp[-3].ArgList)) { // Is null if empty...
Reid Spencer950bf602007-01-26 08:19:09 +00005513 if (isVarArg) { // Nuke the last entry
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005514 assert((yyvsp[-3].ArgList)->back().first.PAT->get() == Type::VoidTy &&
5515 (yyvsp[-3].ArgList)->back().second == 0 && "Not a varargs marker");
5516 delete (yyvsp[-3].ArgList)->back().first.PAT;
5517 (yyvsp[-3].ArgList)->pop_back(); // Delete the last entry
Reid Spencer950bf602007-01-26 08:19:09 +00005518 }
5519 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00005520 Function::arg_iterator ArgEnd = Fn->arg_end();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005521 std::vector<std::pair<PATypeInfo,char*> >::iterator I = (yyvsp[-3].ArgList)->begin();
5522 std::vector<std::pair<PATypeInfo,char*> >::iterator E = (yyvsp[-3].ArgList)->end();
Reid Spenceref9b9a72007-02-05 20:47:22 +00005523 for ( ; I != E && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencered96d1e2007-02-08 09:08:52 +00005524 delete I->first.PAT; // Delete the typeholder...
Reid Spencerbb1fd572007-03-21 17:15:50 +00005525 ValueInfo VI; VI.V = ArgIt; VI.S.copy(I->first.S);
5526 setValueName(VI, I->second); // Insert arg into symtab...
Reid Spencer950bf602007-01-26 08:19:09 +00005527 InsertValue(ArgIt);
5528 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005529 delete (yyvsp[-3].ArgList); // We're now done with the argument list
Reid Spencer950bf602007-01-26 08:19:09 +00005530 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005531 ;}
5532 break;
5533
5534 case 224:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005535#line 3054 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerd2920cd2007-03-21 17:27:53 +00005536 { CurFun.Linkage = (yyvsp[0].Linkage); ;}
5537 break;
5538
5539 case 225:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005540#line 3054 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005541 {
5542 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer950bf602007-01-26 08:19:09 +00005543
5544 // Make sure that we keep track of the linkage type even if there was a
5545 // previous "declare".
Reid Spencerd2920cd2007-03-21 17:27:53 +00005546 (yyval.FunctionVal)->setLinkage((yyvsp[-3].Linkage));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005547 ;}
5548 break;
5549
Reid Spencerd2920cd2007-03-21 17:27:53 +00005550 case 228:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005551#line 3068 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005552 {
5553 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
5554 ;}
5555 break;
5556
Reid Spencerd2920cd2007-03-21 17:27:53 +00005557 case 229:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005558#line 3073 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005559 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
5560 break;
5561
Reid Spencerd2920cd2007-03-21 17:27:53 +00005562 case 230:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005563#line 3074 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005564 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
5565 break;
5566
Reid Spencerd2920cd2007-03-21 17:27:53 +00005567 case 231:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005568#line 3075 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005569 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
5570 break;
5571
Reid Spencerd2920cd2007-03-21 17:27:53 +00005572 case 232:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005573#line 3079 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005574 { CurFun.isDeclare = true; ;}
5575 break;
5576
Reid Spencerd2920cd2007-03-21 17:27:53 +00005577 case 233:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005578#line 3080 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005579 { CurFun.Linkage = (yyvsp[0].Linkage); ;}
5580 break;
5581
Reid Spencerd2920cd2007-03-21 17:27:53 +00005582 case 234:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005583#line 3080 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005584 {
5585 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer950bf602007-01-26 08:19:09 +00005586 CurFun.FunctionDone();
5587
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005588 ;}
5589 break;
5590
Reid Spencerd2920cd2007-03-21 17:27:53 +00005591 case 235:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005592#line 3092 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005593 { (yyval.BoolVal) = false; ;}
5594 break;
5595
Reid Spencerd2920cd2007-03-21 17:27:53 +00005596 case 236:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005597#line 3093 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005598 { (yyval.BoolVal) = true; ;}
5599 break;
5600
Reid Spencerd2920cd2007-03-21 17:27:53 +00005601 case 237:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005602#line 3098 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerbb1fd572007-03-21 17:15:50 +00005603 { (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val)); ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005604 break;
5605
Reid Spencerd2920cd2007-03-21 17:27:53 +00005606 case 238:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005607#line 3099 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005608 { (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val)); ;}
5609 break;
5610
Reid Spencerd2920cd2007-03-21 17:27:53 +00005611 case 239:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005612#line 3100 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005613 { (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal)); ;}
5614 break;
5615
Reid Spencerd2920cd2007-03-21 17:27:53 +00005616 case 240:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005617#line 3101 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerbb1fd572007-03-21 17:15:50 +00005618 {
5619 (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, true));
5620 (yyval.ValIDVal).S.makeUnsigned();
5621 ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005622 break;
5623
Reid Spencerd2920cd2007-03-21 17:27:53 +00005624 case 241:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005625#line 3105 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerbb1fd572007-03-21 17:15:50 +00005626 {
5627 (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, false));
5628 (yyval.ValIDVal).S.makeUnsigned();
5629 ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005630 break;
5631
Reid Spencerd2920cd2007-03-21 17:27:53 +00005632 case 242:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005633#line 3109 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005634 { (yyval.ValIDVal) = ValID::createNull(); ;}
5635 break;
5636
Reid Spencerd2920cd2007-03-21 17:27:53 +00005637 case 243:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005638#line 3110 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005639 { (yyval.ValIDVal) = ValID::createUndef(); ;}
5640 break;
5641
Reid Spencerd2920cd2007-03-21 17:27:53 +00005642 case 244:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005643#line 3111 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005644 { (yyval.ValIDVal) = ValID::createZeroInit(); ;}
5645 break;
5646
Reid Spencerd2920cd2007-03-21 17:27:53 +00005647 case 245:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005648#line 3112 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005649 { // Nonempty unsized packed vector
5650 const Type *ETy = (*(yyvsp[-1].ConstVector))[0].C->getType();
5651 int NumElements = (yyvsp[-1].ConstVector)->size();
Reid Spencer9d6565a2007-02-15 02:26:10 +00005652 VectorType* pt = VectorType::get(ETy, NumElements);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005653 (yyval.ValIDVal).S.makeComposite((*(yyvsp[-1].ConstVector))[0].S);
5654 PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(pt, (yyval.ValIDVal).S));
Reid Spencer950bf602007-01-26 08:19:09 +00005655
5656 // Verify all elements are correct type!
5657 std::vector<Constant*> Elems;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005658 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
5659 Constant *C = (*(yyvsp[-1].ConstVector))[i].C;
Reid Spencer950bf602007-01-26 08:19:09 +00005660 const Type *CTy = C->getType();
5661 if (ETy != CTy)
5662 error("Element #" + utostr(i) + " is not of type '" +
5663 ETy->getDescription() +"' as required!\nIt is of type '" +
5664 CTy->getDescription() + "'");
5665 Elems.push_back(C);
Reid Spencere77e35e2006-12-01 20:26:20 +00005666 }
Reid Spencer5eb77c72007-03-15 03:26:42 +00005667 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, Elems));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005668 delete PTy; delete (yyvsp[-1].ConstVector);
5669 ;}
5670 break;
5671
Reid Spencerd2920cd2007-03-21 17:27:53 +00005672 case 246:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005673#line 3133 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005674 {
Reid Spencer5eb77c72007-03-15 03:26:42 +00005675 (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal).C);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005676 (yyval.ValIDVal).S.copy((yyvsp[0].ConstVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005677 ;}
5678 break;
5679
Reid Spencerd2920cd2007-03-21 17:27:53 +00005680 case 247:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005681#line 3137 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005682 {
5683 char *End = UnEscapeLexed((yyvsp[-2].StrVal), true);
5684 std::string AsmStr = std::string((yyvsp[-2].StrVal), End);
5685 End = UnEscapeLexed((yyvsp[0].StrVal), true);
5686 std::string Constraints = std::string((yyvsp[0].StrVal), End);
5687 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal));
5688 free((yyvsp[-2].StrVal));
5689 free((yyvsp[0].StrVal));
5690 ;}
5691 break;
5692
Reid Spencerd2920cd2007-03-21 17:27:53 +00005693 case 248:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005694#line 3151 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerbb1fd572007-03-21 17:15:50 +00005695 { (yyval.ValIDVal) = ValID::create((yyvsp[0].SIntVal)); (yyval.ValIDVal).S.makeSignless(); ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005696 break;
5697
Reid Spencerd2920cd2007-03-21 17:27:53 +00005698 case 249:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005699#line 3152 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencerbb1fd572007-03-21 17:15:50 +00005700 { (yyval.ValIDVal) = ValID::create((yyvsp[0].StrVal)); (yyval.ValIDVal).S.makeSignless(); ;}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005701 break;
5702
Reid Spencerd2920cd2007-03-21 17:27:53 +00005703 case 252:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005704#line 3165 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005705 {
5706 const Type *Ty = (yyvsp[-1].TypeVal).PAT->get();
Reid Spencerbb1fd572007-03-21 17:15:50 +00005707 (yyvsp[0].ValIDVal).S.copy((yyvsp[-1].TypeVal).S);
Reid Spencer5eb77c72007-03-15 03:26:42 +00005708 (yyval.ValueVal).V = getVal(Ty, (yyvsp[0].ValIDVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00005709 (yyval.ValueVal).S.copy((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005710 delete (yyvsp[-1].TypeVal).PAT;
5711 ;}
5712 break;
5713
Reid Spencerd2920cd2007-03-21 17:27:53 +00005714 case 253:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005715#line 3175 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005716 {
5717 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
5718 ;}
5719 break;
5720
Reid Spencerd2920cd2007-03-21 17:27:53 +00005721 case 254:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005722#line 3178 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005723 { // Do not allow functions with 0 basic blocks
5724 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
5725 ;}
5726 break;
5727
Reid Spencerd2920cd2007-03-21 17:27:53 +00005728 case 255:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005729#line 3187 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005730 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00005731 ValueInfo VI; VI.V = (yyvsp[0].TermInstVal).TI; VI.S.copy((yyvsp[0].TermInstVal).S);
5732 setValueName(VI, (yyvsp[-1].StrVal));
5733 InsertValue((yyvsp[0].TermInstVal).TI);
5734 (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal).TI);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005735 InsertValue((yyvsp[-2].BasicBlockVal));
5736 (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal);
5737 ;}
5738 break;
5739
Reid Spencerd2920cd2007-03-21 17:27:53 +00005740 case 256:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005741#line 3198 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005742 {
5743 if ((yyvsp[0].InstVal).I)
5744 (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal).I);
5745 (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal);
5746 ;}
5747 break;
5748
Reid Spencerd2920cd2007-03-21 17:27:53 +00005749 case 257:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005750#line 3203 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005751 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00005752 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++),true);
Reid Spencer950bf602007-01-26 08:19:09 +00005753 // Make sure to move the basic block to the correct location in the
5754 // function, instead of leaving it inserted wherever it was first
5755 // referenced.
5756 Function::BasicBlockListType &BBL =
5757 CurFun.CurrentFunction->getBasicBlockList();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005758 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5759 ;}
5760 break;
5761
Reid Spencerd2920cd2007-03-21 17:27:53 +00005762 case 258:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005763#line 3212 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005764 {
Reid Spencer5eb77c72007-03-15 03:26:42 +00005765 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[0].StrVal)), true);
Reid Spencer950bf602007-01-26 08:19:09 +00005766 // Make sure to move the basic block to the correct location in the
5767 // function, instead of leaving it inserted wherever it was first
5768 // referenced.
5769 Function::BasicBlockListType &BBL =
5770 CurFun.CurrentFunction->getBasicBlockList();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005771 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
5772 ;}
5773 break;
5774
Reid Spencerd2920cd2007-03-21 17:27:53 +00005775 case 261:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005776#line 3226 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005777 { // Return with a result...
Reid Spencerbb1fd572007-03-21 17:15:50 +00005778 (yyval.TermInstVal).TI = new ReturnInst((yyvsp[0].ValueVal).V);
5779 (yyval.TermInstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005780 ;}
5781 break;
5782
Reid Spencerd2920cd2007-03-21 17:27:53 +00005783 case 262:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005784#line 3230 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005785 { // Return with no result...
Reid Spencerbb1fd572007-03-21 17:15:50 +00005786 (yyval.TermInstVal).TI = new ReturnInst();
5787 (yyval.TermInstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005788 ;}
5789 break;
5790
Reid Spencerd2920cd2007-03-21 17:27:53 +00005791 case 263:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005792#line 3234 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005793 { // Unconditional Branch...
5794 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00005795 (yyval.TermInstVal).TI = new BranchInst(tmpBB);
5796 (yyval.TermInstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005797 ;}
5798 break;
5799
Reid Spencerd2920cd2007-03-21 17:27:53 +00005800 case 264:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005801#line 3239 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005802 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00005803 (yyvsp[-3].ValIDVal).S.makeSignless();
5804 (yyvsp[0].ValIDVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005805 BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal));
5806 BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00005807 (yyvsp[-6].ValIDVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005808 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[-6].ValIDVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00005809 (yyval.TermInstVal).TI = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5810 (yyval.TermInstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005811 ;}
5812 break;
5813
Reid Spencerd2920cd2007-03-21 17:27:53 +00005814 case 265:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005815#line 3249 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005816 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00005817 (yyvsp[-6].ValIDVal).S.copy((yyvsp[-7].PrimType).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005818 Value* tmpVal = getVal((yyvsp[-7].PrimType).T, (yyvsp[-6].ValIDVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00005819 (yyvsp[-3].ValIDVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005820 BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal));
5821 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size());
Reid Spencerbb1fd572007-03-21 17:15:50 +00005822 (yyval.TermInstVal).TI = S;
5823 (yyval.TermInstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005824 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(),
5825 E = (yyvsp[-1].JumpTable)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00005826 for (; I != E; ++I) {
5827 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5828 S->addCase(CI, I->second);
5829 else
5830 error("Switch case is constant, but not a simple integer");
5831 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005832 delete (yyvsp[-1].JumpTable);
5833 ;}
5834 break;
5835
Reid Spencerd2920cd2007-03-21 17:27:53 +00005836 case 266:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005837#line 3267 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005838 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00005839 (yyvsp[-5].ValIDVal).S.copy((yyvsp[-6].PrimType).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005840 Value* tmpVal = getVal((yyvsp[-6].PrimType).T, (yyvsp[-5].ValIDVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00005841 (yyvsp[-2].ValIDVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005842 BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005843 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005844 (yyval.TermInstVal).TI = S;
5845 (yyval.TermInstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005846 ;}
5847 break;
5848
Reid Spencerd2920cd2007-03-21 17:27:53 +00005849 case 267:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005850#line 3277 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005851 {
Reid Spencer950bf602007-01-26 08:19:09 +00005852 const PointerType *PFTy;
5853 const FunctionType *Ty;
Reid Spencerbb1fd572007-03-21 17:15:50 +00005854 Signedness FTySign;
Reid Spencer950bf602007-01-26 08:19:09 +00005855
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005856 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-10].TypeVal).PAT->get())) ||
Reid Spencer950bf602007-01-26 08:19:09 +00005857 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5858 // Pull out the types of all of the arguments...
5859 std::vector<const Type*> ParamTypes;
Reid Spencerbb1fd572007-03-21 17:15:50 +00005860 FTySign.makeComposite((yyvsp[-10].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005861 if ((yyvsp[-7].ValueList)) {
5862 for (std::vector<ValueInfo>::iterator I = (yyvsp[-7].ValueList)->begin(), E = (yyvsp[-7].ValueList)->end();
Reid Spencerbb1fd572007-03-21 17:15:50 +00005863 I != E; ++I) {
Reid Spencer950bf602007-01-26 08:19:09 +00005864 ParamTypes.push_back((*I).V->getType());
Reid Spencerbb1fd572007-03-21 17:15:50 +00005865 FTySign.add(I->S);
5866 }
Reid Spencer950bf602007-01-26 08:19:09 +00005867 }
Reid Spencer7b5d4662007-04-09 06:16:21 +00005868 ParamAttrsList *ParamAttrs = 0;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005869 if ((yyvsp[-11].UIntVal) == OldCallingConv::CSRet) {
Reid Spencer7b5d4662007-04-09 06:16:21 +00005870 ParamAttrs = new ParamAttrsList();
Reid Spencer18da0722007-04-11 02:44:20 +00005871 ParamAttrs->addAttributes(0, ParamAttr::None); // Function result
5872 ParamAttrs->addAttributes(1, ParamAttr::StructRet); // first param
Reid Spencerb7046c72007-01-29 05:41:34 +00005873 }
Reid Spencer950bf602007-01-26 08:19:09 +00005874 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
5875 if (isVarArg) ParamTypes.pop_back();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005876 Ty = FunctionType::get((yyvsp[-10].TypeVal).PAT->get(), ParamTypes, isVarArg, ParamAttrs);
Reid Spencer950bf602007-01-26 08:19:09 +00005877 PFTy = PointerType::get(Ty);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005878 (yyval.TermInstVal).S.copy((yyvsp[-10].TypeVal).S);
5879 } else {
5880 FTySign = (yyvsp[-10].TypeVal).S;
Reid Spencera3b12dd2007-04-07 16:14:01 +00005881 // Get the signedness of the result type. $3 is the pointer to the
5882 // function type so we get the 0th element to extract the function type,
5883 // and then the 0th element again to get the result type.
5884 (yyval.TermInstVal).S.copy((yyvsp[-10].TypeVal).S.get(0).get(0));
Reid Spencer950bf602007-01-26 08:19:09 +00005885 }
Reid Spencer7b5d4662007-04-09 06:16:21 +00005886
Reid Spencerbb1fd572007-03-21 17:15:50 +00005887 (yyvsp[-9].ValIDVal).S.makeComposite(FTySign);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005888 Value *V = getVal(PFTy, (yyvsp[-9].ValIDVal)); // Get the function we're calling...
5889 BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal));
5890 BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00005891
5892 // Create the call node...
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005893 if (!(yyvsp[-7].ValueList)) { // Has no arguments?
Reid Spencerbb1fd572007-03-21 17:15:50 +00005894 (yyval.TermInstVal).TI = new InvokeInst(V, Normal, Except, 0, 0);
Reid Spencer950bf602007-01-26 08:19:09 +00005895 } else { // Has arguments?
5896 // Loop through FunctionType's arguments and ensure they are specified
5897 // correctly!
5898 //
5899 FunctionType::param_iterator I = Ty->param_begin();
5900 FunctionType::param_iterator E = Ty->param_end();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005901 std::vector<ValueInfo>::iterator ArgI = (yyvsp[-7].ValueList)->begin(), ArgE = (yyvsp[-7].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00005902
5903 std::vector<Value*> Args;
5904 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5905 if ((*ArgI).V->getType() != *I)
5906 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
5907 (*I)->getDescription() + "'");
5908 Args.push_back((*ArgI).V);
5909 }
5910
5911 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
5912 error("Invalid number of parameters detected");
5913
Reid Spencerbb1fd572007-03-21 17:15:50 +00005914 (yyval.TermInstVal).TI = new InvokeInst(V, Normal, Except, &Args[0], Args.size());
Reid Spencer950bf602007-01-26 08:19:09 +00005915 }
Reid Spencerbb1fd572007-03-21 17:15:50 +00005916 cast<InvokeInst>((yyval.TermInstVal).TI)->setCallingConv(upgradeCallingConv((yyvsp[-11].UIntVal)));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005917 delete (yyvsp[-10].TypeVal).PAT;
5918 delete (yyvsp[-7].ValueList);
5919 ;}
5920 break;
5921
Reid Spencerd2920cd2007-03-21 17:27:53 +00005922 case 268:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005923#line 3346 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005924 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00005925 (yyval.TermInstVal).TI = new UnwindInst();
5926 (yyval.TermInstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005927 ;}
5928 break;
5929
Reid Spencerd2920cd2007-03-21 17:27:53 +00005930 case 269:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005931#line 3350 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005932 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00005933 (yyval.TermInstVal).TI = new UnreachableInst();
5934 (yyval.TermInstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005935 ;}
5936 break;
5937
Reid Spencerd2920cd2007-03-21 17:27:53 +00005938 case 270:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005939#line 3357 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005940 {
5941 (yyval.JumpTable) = (yyvsp[-5].JumpTable);
Reid Spencerbb1fd572007-03-21 17:15:50 +00005942 (yyvsp[-3].ValIDVal).S.copy((yyvsp[-4].PrimType).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005943 Constant *V = cast<Constant>(getExistingValue((yyvsp[-4].PrimType).T, (yyvsp[-3].ValIDVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00005944
5945 if (V == 0)
5946 error("May only switch on a constant pool value");
5947
Reid Spencerbb1fd572007-03-21 17:15:50 +00005948 (yyvsp[0].ValIDVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005949 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
5950 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5951 ;}
5952 break;
5953
Reid Spencerd2920cd2007-03-21 17:27:53 +00005954 case 271:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005955#line 3369 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005956 {
5957 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
Reid Spencerbb1fd572007-03-21 17:15:50 +00005958 (yyvsp[-3].ValIDVal).S.copy((yyvsp[-4].PrimType).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005959 Constant *V = cast<Constant>(getExistingValue((yyvsp[-4].PrimType).T, (yyvsp[-3].ValIDVal)));
Reid Spencer950bf602007-01-26 08:19:09 +00005960
5961 if (V == 0)
5962 error("May only switch on a constant pool value");
5963
Reid Spencerbb1fd572007-03-21 17:15:50 +00005964 (yyvsp[0].ValIDVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005965 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
5966 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5967 ;}
5968 break;
5969
Reid Spencerd2920cd2007-03-21 17:27:53 +00005970 case 272:
Reid Spencerbaba98a2007-04-11 12:10:58 +00005971#line 3384 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005972 {
Reid Spencer950bf602007-01-26 08:19:09 +00005973 bool omit = false;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005974 if ((yyvsp[-1].StrVal))
5975 if (BitCastInst *BCI = dyn_cast<BitCastInst>((yyvsp[0].InstVal).I))
Reid Spencer950bf602007-01-26 08:19:09 +00005976 if (BCI->getSrcTy() == BCI->getDestTy() &&
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005977 BCI->getOperand(0)->getName() == (yyvsp[-1].StrVal))
Reid Spencer950bf602007-01-26 08:19:09 +00005978 // This is a useless bit cast causing a name redefinition. It is
5979 // a bit cast from a type to the same type of an operand with the
5980 // same name as the name we would give this instruction. Since this
5981 // instruction results in no code generation, it is safe to omit
5982 // the instruction. This situation can occur because of collapsed
5983 // type planes. For example:
5984 // %X = add int %Y, %Z
5985 // %X = cast int %Y to uint
5986 // After upgrade, this looks like:
5987 // %X = add i32 %Y, %Z
5988 // %X = bitcast i32 to i32
5989 // The bitcast is clearly useless so we omit it.
5990 omit = true;
5991 if (omit) {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005992 (yyval.InstVal).I = 0;
Reid Spencerbb1fd572007-03-21 17:15:50 +00005993 (yyval.InstVal).S.makeSignless();
Reid Spencer950bf602007-01-26 08:19:09 +00005994 } else {
Reid Spencerbb1fd572007-03-21 17:15:50 +00005995 ValueInfo VI; VI.V = (yyvsp[0].InstVal).I; VI.S.copy((yyvsp[0].InstVal).S);
5996 setValueName(VI, (yyvsp[-1].StrVal));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00005997 InsertValue((yyvsp[0].InstVal).I);
5998 (yyval.InstVal) = (yyvsp[0].InstVal);
Reid Spencer950bf602007-01-26 08:19:09 +00005999 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006000 ;}
6001 break;
6002
Reid Spencerd2920cd2007-03-21 17:27:53 +00006003 case 273:
Reid Spencerbaba98a2007-04-11 12:10:58 +00006004#line 3414 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006005 { // Used for PHI nodes
6006 (yyval.PHIList).P = new std::list<std::pair<Value*, BasicBlock*> >();
Reid Spencerbb1fd572007-03-21 17:15:50 +00006007 (yyval.PHIList).S.copy((yyvsp[-5].TypeVal).S);
6008 (yyvsp[-3].ValIDVal).S.copy((yyvsp[-5].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006009 Value* tmpVal = getVal((yyvsp[-5].TypeVal).PAT->get(), (yyvsp[-3].ValIDVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00006010 (yyvsp[-1].ValIDVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006011 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
6012 (yyval.PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
6013 delete (yyvsp[-5].TypeVal).PAT;
6014 ;}
6015 break;
6016
Reid Spencerd2920cd2007-03-21 17:27:53 +00006017 case 274:
Reid Spencerbaba98a2007-04-11 12:10:58 +00006018#line 3424 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006019 {
6020 (yyval.PHIList) = (yyvsp[-6].PHIList);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006021 (yyvsp[-3].ValIDVal).S.copy((yyvsp[-6].PHIList).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006022 Value* tmpVal = getVal((yyvsp[-6].PHIList).P->front().first->getType(), (yyvsp[-3].ValIDVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00006023 (yyvsp[-1].ValIDVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006024 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
6025 (yyvsp[-6].PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
6026 ;}
6027 break;
6028
Reid Spencerd2920cd2007-03-21 17:27:53 +00006029 case 275:
Reid Spencerbaba98a2007-04-11 12:10:58 +00006030#line 3434 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006031 { // Used for call statements, and memory insts...
6032 (yyval.ValueList) = new std::vector<ValueInfo>();
6033 (yyval.ValueList)->push_back((yyvsp[0].ValueVal));
6034 ;}
6035 break;
6036
Reid Spencerd2920cd2007-03-21 17:27:53 +00006037 case 276:
Reid Spencerbaba98a2007-04-11 12:10:58 +00006038#line 3438 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006039 {
6040 (yyval.ValueList) = (yyvsp[-2].ValueList);
6041 (yyvsp[-2].ValueList)->push_back((yyvsp[0].ValueVal));
6042 ;}
6043 break;
6044
Reid Spencerd2920cd2007-03-21 17:27:53 +00006045 case 278:
Reid Spencerbaba98a2007-04-11 12:10:58 +00006046#line 3446 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006047 { (yyval.ValueList) = 0; ;}
6048 break;
6049
Reid Spencerd2920cd2007-03-21 17:27:53 +00006050 case 279:
Reid Spencerbaba98a2007-04-11 12:10:58 +00006051#line 3450 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006052 {
6053 (yyval.BoolVal) = true;
6054 ;}
6055 break;
6056
Reid Spencerd2920cd2007-03-21 17:27:53 +00006057 case 280:
Reid Spencerbaba98a2007-04-11 12:10:58 +00006058#line 3453 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006059 {
6060 (yyval.BoolVal) = false;
6061 ;}
6062 break;
6063
Reid Spencerd2920cd2007-03-21 17:27:53 +00006064 case 281:
Reid Spencerbaba98a2007-04-11 12:10:58 +00006065#line 3459 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006066 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00006067 (yyvsp[-2].ValIDVal).S.copy((yyvsp[-3].TypeVal).S);
6068 (yyvsp[0].ValIDVal).S.copy((yyvsp[-3].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006069 const Type* Ty = (yyvsp[-3].TypeVal).PAT->get();
Reid Spencer9d6565a2007-02-15 02:26:10 +00006070 if (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa<VectorType>(Ty))
Reid Spencer950bf602007-01-26 08:19:09 +00006071 error("Arithmetic operator requires integer, FP, or packed operands");
Reid Spencer9d6565a2007-02-15 02:26:10 +00006072 if (isa<VectorType>(Ty) &&
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006073 ((yyvsp[-4].BinaryOpVal) == URemOp || (yyvsp[-4].BinaryOpVal) == SRemOp || (yyvsp[-4].BinaryOpVal) == FRemOp || (yyvsp[-4].BinaryOpVal) == RemOp))
Chris Lattner4227bdb2007-02-19 07:34:02 +00006074 error("Remainder not supported on vector types");
Reid Spencer950bf602007-01-26 08:19:09 +00006075 // Upgrade the opcode from obsolete versions before we do anything with it.
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006076 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-4].BinaryOpVal), Ty, (yyvsp[-3].TypeVal).S);
6077 Value* val1 = getVal(Ty, (yyvsp[-2].ValIDVal));
6078 Value* val2 = getVal(Ty, (yyvsp[0].ValIDVal));
6079 (yyval.InstVal).I = BinaryOperator::create(Opcode, val1, val2);
6080 if ((yyval.InstVal).I == 0)
Reid Spencer950bf602007-01-26 08:19:09 +00006081 error("binary operator returned null");
Reid Spencerbb1fd572007-03-21 17:15:50 +00006082 (yyval.InstVal).S.copy((yyvsp[-3].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006083 delete (yyvsp[-3].TypeVal).PAT;
6084 ;}
6085 break;
6086
Reid Spencerd2920cd2007-03-21 17:27:53 +00006087 case 282:
Reid Spencerbaba98a2007-04-11 12:10:58 +00006088#line 3478 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006089 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00006090 (yyvsp[-2].ValIDVal).S.copy((yyvsp[-3].TypeVal).S);
6091 (yyvsp[0].ValIDVal).S.copy((yyvsp[-3].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006092 const Type *Ty = (yyvsp[-3].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006093 if (!Ty->isInteger()) {
Reid Spencer9d6565a2007-02-15 02:26:10 +00006094 if (!isa<VectorType>(Ty) ||
6095 !cast<VectorType>(Ty)->getElementType()->isInteger())
Reid Spencer950bf602007-01-26 08:19:09 +00006096 error("Logical operator requires integral operands");
6097 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006098 Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-4].BinaryOpVal), Ty, (yyvsp[-3].TypeVal).S);
6099 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
6100 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
6101 (yyval.InstVal).I = BinaryOperator::create(Opcode, tmpVal1, tmpVal2);
6102 if ((yyval.InstVal).I == 0)
Reid Spencer950bf602007-01-26 08:19:09 +00006103 error("binary operator returned null");
Reid Spencerbb1fd572007-03-21 17:15:50 +00006104 (yyval.InstVal).S.copy((yyvsp[-3].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006105 delete (yyvsp[-3].TypeVal).PAT;
6106 ;}
6107 break;
6108
Reid Spencerd2920cd2007-03-21 17:27:53 +00006109 case 283:
Reid Spencerbaba98a2007-04-11 12:10:58 +00006110#line 3496 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006111 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00006112 (yyvsp[-2].ValIDVal).S.copy((yyvsp[-3].TypeVal).S);
6113 (yyvsp[0].ValIDVal).S.copy((yyvsp[-3].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006114 const Type* Ty = (yyvsp[-3].TypeVal).PAT->get();
Reid Spencer9d6565a2007-02-15 02:26:10 +00006115 if(isa<VectorType>(Ty))
6116 error("VectorTypes currently not supported in setcc instructions");
Reid Spencer950bf602007-01-26 08:19:09 +00006117 unsigned short pred;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006118 Instruction::OtherOps Opcode = getCompareOp((yyvsp[-4].BinaryOpVal), pred, Ty, (yyvsp[-3].TypeVal).S);
6119 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
6120 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
6121 (yyval.InstVal).I = CmpInst::create(Opcode, pred, tmpVal1, tmpVal2);
6122 if ((yyval.InstVal).I == 0)
Reid Spencer950bf602007-01-26 08:19:09 +00006123 error("binary operator returned null");
Reid Spencerbb1fd572007-03-21 17:15:50 +00006124 (yyval.InstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006125 delete (yyvsp[-3].TypeVal).PAT;
6126 ;}
6127 break;
6128
Reid Spencerd2920cd2007-03-21 17:27:53 +00006129 case 284:
Reid Spencerbaba98a2007-04-11 12:10:58 +00006130#line 3512 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006131 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00006132 (yyvsp[-2].ValIDVal).S.copy((yyvsp[-3].TypeVal).S);
6133 (yyvsp[0].ValIDVal).S.copy((yyvsp[-3].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006134 const Type *Ty = (yyvsp[-3].TypeVal).PAT->get();
Reid Spencer9d6565a2007-02-15 02:26:10 +00006135 if (isa<VectorType>(Ty))
6136 error("VectorTypes currently not supported in icmp instructions");
Reid Spencer950bf602007-01-26 08:19:09 +00006137 else if (!Ty->isInteger() && !isa<PointerType>(Ty))
6138 error("icmp requires integer or pointer typed operands");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006139 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
6140 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
6141 (yyval.InstVal).I = new ICmpInst((yyvsp[-4].IPred), tmpVal1, tmpVal2);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006142 (yyval.InstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006143 delete (yyvsp[-3].TypeVal).PAT;
6144 ;}
6145 break;
6146
Reid Spencerd2920cd2007-03-21 17:27:53 +00006147 case 285:
Reid Spencerbaba98a2007-04-11 12:10:58 +00006148#line 3526 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006149 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00006150 (yyvsp[-2].ValIDVal).S.copy((yyvsp[-3].TypeVal).S);
6151 (yyvsp[0].ValIDVal).S.copy((yyvsp[-3].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006152 const Type *Ty = (yyvsp[-3].TypeVal).PAT->get();
Reid Spencer9d6565a2007-02-15 02:26:10 +00006153 if (isa<VectorType>(Ty))
6154 error("VectorTypes currently not supported in fcmp instructions");
Reid Spencer950bf602007-01-26 08:19:09 +00006155 else if (!Ty->isFloatingPoint())
6156 error("fcmp instruction requires floating point operands");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006157 Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal));
6158 Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal));
6159 (yyval.InstVal).I = new FCmpInst((yyvsp[-4].FPred), tmpVal1, tmpVal2);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006160 (yyval.InstVal).S.makeUnsigned();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006161 delete (yyvsp[-3].TypeVal).PAT;
6162 ;}
6163 break;
6164
Reid Spencerd2920cd2007-03-21 17:27:53 +00006165 case 286:
Reid Spencerbaba98a2007-04-11 12:10:58 +00006166#line 3540 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006167 {
Reid Spencer950bf602007-01-26 08:19:09 +00006168 warning("Use of obsolete 'not' instruction: Replacing with 'xor");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006169 const Type *Ty = (yyvsp[0].ValueVal).V->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00006170 Value *Ones = ConstantInt::getAllOnesValue(Ty);
6171 if (Ones == 0)
6172 error("Expected integral type for not instruction");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006173 (yyval.InstVal).I = BinaryOperator::create(Instruction::Xor, (yyvsp[0].ValueVal).V, Ones);
6174 if ((yyval.InstVal).I == 0)
Reid Spencer950bf602007-01-26 08:19:09 +00006175 error("Could not create a xor instruction");
Reid Spencerbb1fd572007-03-21 17:15:50 +00006176 (yyval.InstVal).S.copy((yyvsp[0].ValueVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006177 ;}
6178 break;
6179
Reid Spencerd2920cd2007-03-21 17:27:53 +00006180 case 287:
Reid Spencerbaba98a2007-04-11 12:10:58 +00006181#line 3551 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006182 {
6183 if (!(yyvsp[0].ValueVal).V->getType()->isInteger() ||
6184 cast<IntegerType>((yyvsp[0].ValueVal).V->getType())->getBitWidth() != 8)
Reid Spencer950bf602007-01-26 08:19:09 +00006185 error("Shift amount must be int8");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006186 const Type* Ty = (yyvsp[-2].ValueVal).V->getType();
Reid Spencer832254e2007-02-02 02:16:23 +00006187 if (!Ty->isInteger())
Reid Spencer950bf602007-01-26 08:19:09 +00006188 error("Shift constant expression requires integer operand");
Reid Spencer832254e2007-02-02 02:16:23 +00006189 Value* ShiftAmt = 0;
6190 if (cast<IntegerType>(Ty)->getBitWidth() > Type::Int8Ty->getBitWidth())
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006191 if (Constant *C = dyn_cast<Constant>((yyvsp[0].ValueVal).V))
Reid Spencer832254e2007-02-02 02:16:23 +00006192 ShiftAmt = ConstantExpr::getZExt(C, Ty);
6193 else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006194 ShiftAmt = new ZExtInst((yyvsp[0].ValueVal).V, Ty, makeNameUnique("shift"), CurBB);
Reid Spencer832254e2007-02-02 02:16:23 +00006195 else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006196 ShiftAmt = (yyvsp[0].ValueVal).V;
6197 (yyval.InstVal).I = BinaryOperator::create(getBinaryOp((yyvsp[-3].BinaryOpVal), Ty, (yyvsp[-2].ValueVal).S), (yyvsp[-2].ValueVal).V, ShiftAmt);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006198 (yyval.InstVal).S.copy((yyvsp[-2].ValueVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006199 ;}
6200 break;
6201
Reid Spencerd2920cd2007-03-21 17:27:53 +00006202 case 288:
Reid Spencerbaba98a2007-04-11 12:10:58 +00006203#line 3569 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006204 {
6205 const Type *DstTy = (yyvsp[0].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006206 if (!DstTy->isFirstClassType())
6207 error("cast instruction to a non-primitive type: '" +
6208 DstTy->getDescription() + "'");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006209 (yyval.InstVal).I = cast<Instruction>(getCast((yyvsp[-3].CastOpVal), (yyvsp[-2].ValueVal).V, (yyvsp[-2].ValueVal).S, DstTy, (yyvsp[0].TypeVal).S, true));
Reid Spencerbb1fd572007-03-21 17:15:50 +00006210 (yyval.InstVal).S.copy((yyvsp[0].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006211 delete (yyvsp[0].TypeVal).PAT;
6212 ;}
6213 break;
6214
Reid Spencerd2920cd2007-03-21 17:27:53 +00006215 case 289:
Reid Spencerbaba98a2007-04-11 12:10:58 +00006216#line 3578 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006217 {
6218 if (!(yyvsp[-4].ValueVal).V->getType()->isInteger() ||
6219 cast<IntegerType>((yyvsp[-4].ValueVal).V->getType())->getBitWidth() != 1)
Reid Spencer950bf602007-01-26 08:19:09 +00006220 error("select condition must be bool");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006221 if ((yyvsp[-2].ValueVal).V->getType() != (yyvsp[0].ValueVal).V->getType())
Reid Spencer950bf602007-01-26 08:19:09 +00006222 error("select value types should match");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006223 (yyval.InstVal).I = new SelectInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006224 (yyval.InstVal).S.copy((yyvsp[-2].ValueVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006225 ;}
6226 break;
6227
Reid Spencerd2920cd2007-03-21 17:27:53 +00006228 case 290:
Reid Spencerbaba98a2007-04-11 12:10:58 +00006229#line 3587 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006230 {
6231 const Type *Ty = (yyvsp[0].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006232 NewVarArgs = true;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006233 (yyval.InstVal).I = new VAArgInst((yyvsp[-2].ValueVal).V, Ty);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006234 (yyval.InstVal).S.copy((yyvsp[0].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006235 delete (yyvsp[0].TypeVal).PAT;
6236 ;}
6237 break;
6238
Reid Spencerd2920cd2007-03-21 17:27:53 +00006239 case 291:
Reid Spencerbaba98a2007-04-11 12:10:58 +00006240#line 3594 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006241 {
6242 const Type* ArgTy = (yyvsp[-2].ValueVal).V->getType();
6243 const Type* DstTy = (yyvsp[0].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006244 ObsoleteVarArgs = true;
6245 Function* NF = cast<Function>(CurModule.CurrentModule->
6246 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
6247
6248 //b = vaarg a, t ->
6249 //foo = alloca 1 of t
6250 //bar = vacopy a
6251 //store bar -> foo
6252 //b = vaarg foo, t
6253 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
6254 CurBB->getInstList().push_back(foo);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006255 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal).V);
Reid Spencer950bf602007-01-26 08:19:09 +00006256 CurBB->getInstList().push_back(bar);
6257 CurBB->getInstList().push_back(new StoreInst(bar, foo));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006258 (yyval.InstVal).I = new VAArgInst(foo, DstTy);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006259 (yyval.InstVal).S.copy((yyvsp[0].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006260 delete (yyvsp[0].TypeVal).PAT;
6261 ;}
6262 break;
6263
Reid Spencerd2920cd2007-03-21 17:27:53 +00006264 case 292:
Reid Spencerbaba98a2007-04-11 12:10:58 +00006265#line 3615 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006266 {
6267 const Type* ArgTy = (yyvsp[-2].ValueVal).V->getType();
6268 const Type* DstTy = (yyvsp[0].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006269 ObsoleteVarArgs = true;
6270 Function* NF = cast<Function>(CurModule.CurrentModule->
6271 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
6272
6273 //b = vanext a, t ->
6274 //foo = alloca 1 of t
6275 //bar = vacopy a
6276 //store bar -> foo
6277 //tmp = vaarg foo, t
6278 //b = load foo
6279 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
6280 CurBB->getInstList().push_back(foo);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006281 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal).V);
Reid Spencer950bf602007-01-26 08:19:09 +00006282 CurBB->getInstList().push_back(bar);
6283 CurBB->getInstList().push_back(new StoreInst(bar, foo));
6284 Instruction* tmp = new VAArgInst(foo, DstTy);
6285 CurBB->getInstList().push_back(tmp);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006286 (yyval.InstVal).I = new LoadInst(foo);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006287 (yyval.InstVal).S.copy((yyvsp[0].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006288 delete (yyvsp[0].TypeVal).PAT;
6289 ;}
6290 break;
6291
Reid Spencerd2920cd2007-03-21 17:27:53 +00006292 case 293:
Reid Spencerbaba98a2007-04-11 12:10:58 +00006293#line 3639 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006294 {
6295 if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
Reid Spencer950bf602007-01-26 08:19:09 +00006296 error("Invalid extractelement operands");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006297 (yyval.InstVal).I = new ExtractElementInst((yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006298 (yyval.InstVal).S.copy((yyvsp[-2].ValueVal).S.get(0));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006299 ;}
6300 break;
6301
Reid Spencerd2920cd2007-03-21 17:27:53 +00006302 case 294:
Reid Spencerbaba98a2007-04-11 12:10:58 +00006303#line 3645 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006304 {
6305 if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
Reid Spencer950bf602007-01-26 08:19:09 +00006306 error("Invalid insertelement operands");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006307 (yyval.InstVal).I = new InsertElementInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006308 (yyval.InstVal).S.copy((yyvsp[-4].ValueVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006309 ;}
6310 break;
6311
Reid Spencerd2920cd2007-03-21 17:27:53 +00006312 case 295:
Reid Spencerbaba98a2007-04-11 12:10:58 +00006313#line 3651 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006314 {
6315 if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V))
Reid Spencer950bf602007-01-26 08:19:09 +00006316 error("Invalid shufflevector operands");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006317 (yyval.InstVal).I = new ShuffleVectorInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006318 (yyval.InstVal).S.copy((yyvsp[-4].ValueVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006319 ;}
6320 break;
6321
Reid Spencerd2920cd2007-03-21 17:27:53 +00006322 case 296:
Reid Spencerbaba98a2007-04-11 12:10:58 +00006323#line 3657 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006324 {
6325 const Type *Ty = (yyvsp[0].PHIList).P->front().first->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00006326 if (!Ty->isFirstClassType())
6327 error("PHI node operands must be of first class type");
6328 PHINode *PHI = new PHINode(Ty);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006329 PHI->reserveOperandSpace((yyvsp[0].PHIList).P->size());
6330 while ((yyvsp[0].PHIList).P->begin() != (yyvsp[0].PHIList).P->end()) {
6331 if ((yyvsp[0].PHIList).P->front().first->getType() != Ty)
Reid Spencer950bf602007-01-26 08:19:09 +00006332 error("All elements of a PHI node must be of the same type");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006333 PHI->addIncoming((yyvsp[0].PHIList).P->front().first, (yyvsp[0].PHIList).P->front().second);
6334 (yyvsp[0].PHIList).P->pop_front();
Reid Spencer950bf602007-01-26 08:19:09 +00006335 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006336 (yyval.InstVal).I = PHI;
Reid Spencerbb1fd572007-03-21 17:15:50 +00006337 (yyval.InstVal).S.copy((yyvsp[0].PHIList).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006338 delete (yyvsp[0].PHIList).P; // Free the list...
6339 ;}
6340 break;
Reid Spencer950bf602007-01-26 08:19:09 +00006341
Reid Spencerd2920cd2007-03-21 17:27:53 +00006342 case 297:
Reid Spencerbaba98a2007-04-11 12:10:58 +00006343#line 3673 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006344 {
Reid Spencer950bf602007-01-26 08:19:09 +00006345 // Handle the short call syntax
6346 const PointerType *PFTy;
6347 const FunctionType *FTy;
Reid Spencerbb1fd572007-03-21 17:15:50 +00006348 Signedness FTySign;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006349 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-4].TypeVal).PAT->get())) ||
Reid Spencer950bf602007-01-26 08:19:09 +00006350 !(FTy = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6351 // Pull out the types of all of the arguments...
6352 std::vector<const Type*> ParamTypes;
Reid Spencerbb1fd572007-03-21 17:15:50 +00006353 FTySign.makeComposite((yyvsp[-4].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006354 if ((yyvsp[-1].ValueList)) {
6355 for (std::vector<ValueInfo>::iterator I = (yyvsp[-1].ValueList)->begin(), E = (yyvsp[-1].ValueList)->end();
Reid Spencerbb1fd572007-03-21 17:15:50 +00006356 I != E; ++I) {
Reid Spencer950bf602007-01-26 08:19:09 +00006357 ParamTypes.push_back((*I).V->getType());
Reid Spencerbb1fd572007-03-21 17:15:50 +00006358 FTySign.add(I->S);
6359 }
Reid Spencer950bf602007-01-26 08:19:09 +00006360 }
6361
6362 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
6363 if (isVarArg) ParamTypes.pop_back();
6364
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006365 const Type *RetTy = (yyvsp[-4].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006366 if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
6367 error("Functions cannot return aggregate types");
6368
Reid Spencer7b5d4662007-04-09 06:16:21 +00006369 // Deal with CSRetCC
6370 ParamAttrsList *ParamAttrs = 0;
6371 if ((yyvsp[-5].UIntVal) == OldCallingConv::CSRet) {
6372 ParamAttrs = new ParamAttrsList();
Reid Spencer18da0722007-04-11 02:44:20 +00006373 ParamAttrs->addAttributes(0, ParamAttr::None); // function result
6374 ParamAttrs->addAttributes(1, ParamAttr::StructRet); // first parameter
Reid Spencer7b5d4662007-04-09 06:16:21 +00006375 }
6376
Reid Spencerb7046c72007-01-29 05:41:34 +00006377 FTy = FunctionType::get(RetTy, ParamTypes, isVarArg, ParamAttrs);
Reid Spencer950bf602007-01-26 08:19:09 +00006378 PFTy = PointerType::get(FTy);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006379 (yyval.InstVal).S.copy((yyvsp[-4].TypeVal).S);
6380 } else {
6381 FTySign = (yyvsp[-4].TypeVal).S;
Reid Spencera3b12dd2007-04-07 16:14:01 +00006382 // Get the signedness of the result type. $3 is the pointer to the
6383 // function type so we get the 0th element to extract the function type,
6384 // and then the 0th element again to get the result type.
6385 (yyval.InstVal).S.copy((yyvsp[-4].TypeVal).S.get(0).get(0));
Reid Spencer950bf602007-01-26 08:19:09 +00006386 }
Reid Spencerbb1fd572007-03-21 17:15:50 +00006387 (yyvsp[-3].ValIDVal).S.makeComposite(FTySign);
Reid Spencer950bf602007-01-26 08:19:09 +00006388
6389 // First upgrade any intrinsic calls.
6390 std::vector<Value*> Args;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006391 if ((yyvsp[-1].ValueList))
6392 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i < e; ++i)
6393 Args.push_back((*(yyvsp[-1].ValueList))[i].V);
Reid Spencer41b213e2007-04-02 01:14:00 +00006394 Instruction *Inst = upgradeIntrinsicCall(FTy->getReturnType(), (yyvsp[-3].ValIDVal), Args);
Reid Spencer950bf602007-01-26 08:19:09 +00006395
6396 // If we got an upgraded intrinsic
6397 if (Inst) {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006398 (yyval.InstVal).I = Inst;
Reid Spencer950bf602007-01-26 08:19:09 +00006399 } else {
6400 // Get the function we're calling
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006401 Value *V = getVal(PFTy, (yyvsp[-3].ValIDVal));
Reid Spencer950bf602007-01-26 08:19:09 +00006402
6403 // Check the argument values match
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006404 if (!(yyvsp[-1].ValueList)) { // Has no arguments?
Reid Spencer950bf602007-01-26 08:19:09 +00006405 // Make sure no arguments is a good thing!
6406 if (FTy->getNumParams() != 0)
6407 error("No arguments passed to a function that expects arguments");
6408 } else { // Has arguments?
6409 // Loop through FunctionType's arguments and ensure they are specified
6410 // correctly!
6411 //
6412 FunctionType::param_iterator I = FTy->param_begin();
6413 FunctionType::param_iterator E = FTy->param_end();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006414 std::vector<ValueInfo>::iterator ArgI = (yyvsp[-1].ValueList)->begin(), ArgE = (yyvsp[-1].ValueList)->end();
Reid Spencer950bf602007-01-26 08:19:09 +00006415
6416 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
6417 if ((*ArgI).V->getType() != *I)
6418 error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
6419 (*I)->getDescription() + "'");
6420
6421 if (I != E || (ArgI != ArgE && !FTy->isVarArg()))
6422 error("Invalid number of parameters detected");
6423 }
6424
6425 // Create the call instruction
Chris Lattnercf3d0612007-02-13 06:04:17 +00006426 CallInst *CI = new CallInst(V, &Args[0], Args.size());
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006427 CI->setTailCall((yyvsp[-6].BoolVal));
6428 CI->setCallingConv(upgradeCallingConv((yyvsp[-5].UIntVal)));
6429 (yyval.InstVal).I = CI;
Reid Spencer950bf602007-01-26 08:19:09 +00006430 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006431 delete (yyvsp[-4].TypeVal).PAT;
6432 delete (yyvsp[-1].ValueList);
6433 ;}
6434 break;
6435
Reid Spencerd2920cd2007-03-21 17:27:53 +00006436 case 298:
Reid Spencerbaba98a2007-04-11 12:10:58 +00006437#line 3763 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006438 {
6439 (yyval.InstVal) = (yyvsp[0].InstVal);
6440 ;}
6441 break;
6442
Reid Spencerd2920cd2007-03-21 17:27:53 +00006443 case 299:
Reid Spencerbaba98a2007-04-11 12:10:58 +00006444#line 3771 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006445 { (yyval.ValueList) = (yyvsp[0].ValueList); ;}
6446 break;
6447
Reid Spencerd2920cd2007-03-21 17:27:53 +00006448 case 300:
Reid Spencerbaba98a2007-04-11 12:10:58 +00006449#line 3772 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006450 { (yyval.ValueList) = new std::vector<ValueInfo>(); ;}
6451 break;
6452
Reid Spencerd2920cd2007-03-21 17:27:53 +00006453 case 301:
Reid Spencerbaba98a2007-04-11 12:10:58 +00006454#line 3776 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006455 { (yyval.BoolVal) = true; ;}
6456 break;
6457
Reid Spencerd2920cd2007-03-21 17:27:53 +00006458 case 302:
Reid Spencerbaba98a2007-04-11 12:10:58 +00006459#line 3777 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006460 { (yyval.BoolVal) = false; ;}
6461 break;
6462
Reid Spencerd2920cd2007-03-21 17:27:53 +00006463 case 303:
Reid Spencerbaba98a2007-04-11 12:10:58 +00006464#line 3781 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006465 {
6466 const Type *Ty = (yyvsp[-1].TypeVal).PAT->get();
Reid Spencerbb1fd572007-03-21 17:15:50 +00006467 (yyval.InstVal).S.makeComposite((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006468 (yyval.InstVal).I = new MallocInst(Ty, 0, (yyvsp[0].UIntVal));
6469 delete (yyvsp[-1].TypeVal).PAT;
6470 ;}
6471 break;
6472
Reid Spencerd2920cd2007-03-21 17:27:53 +00006473 case 304:
Reid Spencerbaba98a2007-04-11 12:10:58 +00006474#line 3787 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006475 {
6476 const Type *Ty = (yyvsp[-4].TypeVal).PAT->get();
Reid Spencerbb1fd572007-03-21 17:15:50 +00006477 (yyvsp[-1].ValIDVal).S.makeUnsigned();
6478 (yyval.InstVal).S.makeComposite((yyvsp[-4].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006479 (yyval.InstVal).I = new MallocInst(Ty, getVal((yyvsp[-2].PrimType).T, (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal));
6480 delete (yyvsp[-4].TypeVal).PAT;
6481 ;}
6482 break;
6483
Reid Spencerd2920cd2007-03-21 17:27:53 +00006484 case 305:
Reid Spencerbaba98a2007-04-11 12:10:58 +00006485#line 3794 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006486 {
6487 const Type *Ty = (yyvsp[-1].TypeVal).PAT->get();
Reid Spencerbb1fd572007-03-21 17:15:50 +00006488 (yyval.InstVal).S.makeComposite((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006489 (yyval.InstVal).I = new AllocaInst(Ty, 0, (yyvsp[0].UIntVal));
6490 delete (yyvsp[-1].TypeVal).PAT;
6491 ;}
6492 break;
6493
Reid Spencerd2920cd2007-03-21 17:27:53 +00006494 case 306:
Reid Spencerbaba98a2007-04-11 12:10:58 +00006495#line 3800 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006496 {
6497 const Type *Ty = (yyvsp[-4].TypeVal).PAT->get();
Reid Spencerbb1fd572007-03-21 17:15:50 +00006498 (yyvsp[-1].ValIDVal).S.makeUnsigned();
6499 (yyval.InstVal).S.makeComposite((yyvsp[-2].PrimType).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006500 (yyval.InstVal).I = new AllocaInst(Ty, getVal((yyvsp[-2].PrimType).T, (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal));
6501 delete (yyvsp[-4].TypeVal).PAT;
6502 ;}
6503 break;
6504
Reid Spencerd2920cd2007-03-21 17:27:53 +00006505 case 307:
Reid Spencerbaba98a2007-04-11 12:10:58 +00006506#line 3807 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006507 {
6508 const Type *PTy = (yyvsp[0].ValueVal).V->getType();
Reid Spencer950bf602007-01-26 08:19:09 +00006509 if (!isa<PointerType>(PTy))
6510 error("Trying to free nonpointer type '" + PTy->getDescription() + "'");
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006511 (yyval.InstVal).I = new FreeInst((yyvsp[0].ValueVal).V);
Reid Spencerbb1fd572007-03-21 17:15:50 +00006512 (yyval.InstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006513 ;}
6514 break;
6515
Reid Spencerd2920cd2007-03-21 17:27:53 +00006516 case 308:
Reid Spencerbaba98a2007-04-11 12:10:58 +00006517#line 3814 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006518 {
6519 const Type* Ty = (yyvsp[-1].TypeVal).PAT->get();
Reid Spencerbb1fd572007-03-21 17:15:50 +00006520 (yyvsp[0].ValIDVal).S.copy((yyvsp[-1].TypeVal).S);
Reid Spencer950bf602007-01-26 08:19:09 +00006521 if (!isa<PointerType>(Ty))
6522 error("Can't load from nonpointer type: " + Ty->getDescription());
6523 if (!cast<PointerType>(Ty)->getElementType()->isFirstClassType())
6524 error("Can't load from pointer of non-first-class type: " +
6525 Ty->getDescription());
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006526 Value* tmpVal = getVal(Ty, (yyvsp[0].ValIDVal));
6527 (yyval.InstVal).I = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00006528 (yyval.InstVal).S.copy((yyvsp[-1].TypeVal).S.get(0));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006529 delete (yyvsp[-1].TypeVal).PAT;
6530 ;}
6531 break;
6532
Reid Spencerd2920cd2007-03-21 17:27:53 +00006533 case 309:
Reid Spencerbaba98a2007-04-11 12:10:58 +00006534#line 3827 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006535 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00006536 (yyvsp[0].ValIDVal).S.copy((yyvsp[-1].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006537 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal).PAT->get());
Reid Spencered96d1e2007-02-08 09:08:52 +00006538 if (!PTy)
6539 error("Can't store to a nonpointer type: " +
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006540 (yyvsp[-1].TypeVal).PAT->get()->getDescription());
Reid Spencered96d1e2007-02-08 09:08:52 +00006541 const Type *ElTy = PTy->getElementType();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006542 Value *StoreVal = (yyvsp[-3].ValueVal).V;
6543 Value* tmpVal = getVal(PTy, (yyvsp[0].ValIDVal));
6544 if (ElTy != (yyvsp[-3].ValueVal).V->getType()) {
6545 StoreVal = handleSRetFuncTypeMerge((yyvsp[-3].ValueVal).V, ElTy);
Reid Spencered96d1e2007-02-08 09:08:52 +00006546 if (!StoreVal)
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006547 error("Can't store '" + (yyvsp[-3].ValueVal).V->getType()->getDescription() +
Reid Spencered96d1e2007-02-08 09:08:52 +00006548 "' into space of type '" + ElTy->getDescription() + "'");
6549 else {
6550 PTy = PointerType::get(StoreVal->getType());
6551 if (Constant *C = dyn_cast<Constant>(tmpVal))
6552 tmpVal = ConstantExpr::getBitCast(C, PTy);
6553 else
6554 tmpVal = new BitCastInst(tmpVal, PTy, "upgrd.cast", CurBB);
6555 }
6556 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006557 (yyval.InstVal).I = new StoreInst(StoreVal, tmpVal, (yyvsp[-5].BoolVal));
Reid Spencerbb1fd572007-03-21 17:15:50 +00006558 (yyval.InstVal).S.makeSignless();
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006559 delete (yyvsp[-1].TypeVal).PAT;
6560 ;}
6561 break;
6562
Reid Spencerd2920cd2007-03-21 17:27:53 +00006563 case 310:
Reid Spencerbaba98a2007-04-11 12:10:58 +00006564#line 3853 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006565 {
Reid Spencerbb1fd572007-03-21 17:15:50 +00006566 (yyvsp[-1].ValIDVal).S.copy((yyvsp[-2].TypeVal).S);
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006567 const Type* Ty = (yyvsp[-2].TypeVal).PAT->get();
Reid Spencer950bf602007-01-26 08:19:09 +00006568 if (!isa<PointerType>(Ty))
6569 error("getelementptr insn requires pointer operand");
6570
6571 std::vector<Value*> VIndices;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006572 upgradeGEPIndices(Ty, (yyvsp[0].ValueList), VIndices);
Reid Spencer950bf602007-01-26 08:19:09 +00006573
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006574 Value* tmpVal = getVal(Ty, (yyvsp[-1].ValIDVal));
6575 (yyval.InstVal).I = new GetElementPtrInst(tmpVal, &VIndices[0], VIndices.size());
Reid Spencerbb1fd572007-03-21 17:15:50 +00006576 ValueInfo VI; VI.V = tmpVal; VI.S.copy((yyvsp[-2].TypeVal).S);
6577 (yyval.InstVal).S.copy(getElementSign(VI, VIndices));
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006578 delete (yyvsp[-2].TypeVal).PAT;
6579 delete (yyvsp[0].ValueList);
6580 ;}
6581 break;
6582
6583
6584 default: break;
6585 }
6586
6587/* Line 1126 of yacc.c. */
Reid Spencerbaba98a2007-04-11 12:10:58 +00006588#line 6589 "UpgradeParser.tab.c"
Chris Lattnercf3d0612007-02-13 06:04:17 +00006589
6590 yyvsp -= yylen;
6591 yyssp -= yylen;
Reid Spencerb7046c72007-01-29 05:41:34 +00006592
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006593
6594 YY_STACK_PRINT (yyss, yyssp);
Reid Spencere7c3c602006-11-30 06:36:44 +00006595
6596 *++yyvsp = yyval;
6597
6598
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006599 /* Now `shift' the result of the reduction. Determine what state
6600 that goes to, based on the state we popped back to and the rule
6601 number reduced by. */
Reid Spencere7c3c602006-11-30 06:36:44 +00006602
6603 yyn = yyr1[yyn];
6604
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006605 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
6606 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencere7c3c602006-11-30 06:36:44 +00006607 yystate = yytable[yystate];
6608 else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006609 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencere7c3c602006-11-30 06:36:44 +00006610
6611 goto yynewstate;
6612
6613
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006614/*------------------------------------.
6615| yyerrlab -- here on detecting error |
6616`------------------------------------*/
6617yyerrlab:
6618 /* If not already recovering from an error, report this error. */
6619 if (!yyerrstatus)
Reid Spencere7c3c602006-11-30 06:36:44 +00006620 {
6621 ++yynerrs;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006622#if YYERROR_VERBOSE
Chris Lattnercf3d0612007-02-13 06:04:17 +00006623 yyn = yypact[yystate];
6624
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006625 if (YYPACT_NINF < yyn && yyn < YYLAST)
Chris Lattnercf3d0612007-02-13 06:04:17 +00006626 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006627 int yytype = YYTRANSLATE (yychar);
6628 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
6629 YYSIZE_T yysize = yysize0;
6630 YYSIZE_T yysize1;
6631 int yysize_overflow = 0;
6632 char *yymsg = 0;
6633# define YYERROR_VERBOSE_ARGS_MAXIMUM 5
6634 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
6635 int yyx;
Chris Lattnercf3d0612007-02-13 06:04:17 +00006636
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006637#if 0
6638 /* This is so xgettext sees the translatable formats that are
6639 constructed on the fly. */
6640 YY_("syntax error, unexpected %s");
6641 YY_("syntax error, unexpected %s, expecting %s");
6642 YY_("syntax error, unexpected %s, expecting %s or %s");
6643 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
6644 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
6645#endif
6646 char *yyfmt;
6647 char const *yyf;
6648 static char const yyunexpected[] = "syntax error, unexpected %s";
6649 static char const yyexpecting[] = ", expecting %s";
6650 static char const yyor[] = " or %s";
6651 char yyformat[sizeof yyunexpected
6652 + sizeof yyexpecting - 1
6653 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
6654 * (sizeof yyor - 1))];
6655 char const *yyprefix = yyexpecting;
6656
6657 /* Start YYX at -YYN if negative to avoid negative indexes in
6658 YYCHECK. */
6659 int yyxbegin = yyn < 0 ? -yyn : 0;
6660
6661 /* Stay within bounds of both yycheck and yytname. */
6662 int yychecklim = YYLAST - yyn;
6663 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
6664 int yycount = 1;
6665
6666 yyarg[0] = yytname[yytype];
6667 yyfmt = yystpcpy (yyformat, yyunexpected);
6668
6669 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
6670 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
6671 {
6672 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
6673 {
6674 yycount = 1;
6675 yysize = yysize0;
6676 yyformat[sizeof yyunexpected - 1] = '\0';
6677 break;
6678 }
6679 yyarg[yycount++] = yytname[yyx];
6680 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
6681 yysize_overflow |= yysize1 < yysize;
6682 yysize = yysize1;
6683 yyfmt = yystpcpy (yyfmt, yyprefix);
6684 yyprefix = yyor;
6685 }
6686
6687 yyf = YY_(yyformat);
6688 yysize1 = yysize + yystrlen (yyf);
6689 yysize_overflow |= yysize1 < yysize;
6690 yysize = yysize1;
6691
6692 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
6693 yymsg = (char *) YYSTACK_ALLOC (yysize);
6694 if (yymsg)
Chris Lattnercf3d0612007-02-13 06:04:17 +00006695 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006696 /* Avoid sprintf, as that infringes on the user's name space.
6697 Don't have undefined behavior even if the translation
6698 produced a string with the wrong number of "%s"s. */
6699 char *yyp = yymsg;
6700 int yyi = 0;
6701 while ((*yyp = *yyf))
Chris Lattnercf3d0612007-02-13 06:04:17 +00006702 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006703 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
6704 {
6705 yyp += yytnamerr (yyp, yyarg[yyi++]);
6706 yyf += 2;
6707 }
6708 else
6709 {
6710 yyp++;
6711 yyf++;
6712 }
Chris Lattnercf3d0612007-02-13 06:04:17 +00006713 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006714 yyerror (yymsg);
6715 YYSTACK_FREE (yymsg);
Chris Lattnercf3d0612007-02-13 06:04:17 +00006716 }
6717 else
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006718 {
6719 yyerror (YY_("syntax error"));
6720 goto yyexhaustedlab;
6721 }
Chris Lattnercf3d0612007-02-13 06:04:17 +00006722 }
6723 else
6724#endif /* YYERROR_VERBOSE */
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006725 yyerror (YY_("syntax error"));
Reid Spencere7c3c602006-11-30 06:36:44 +00006726 }
Reid Spencer950bf602007-01-26 08:19:09 +00006727
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006728
Reid Spencer950bf602007-01-26 08:19:09 +00006729
6730 if (yyerrstatus == 3)
6731 {
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006732 /* If just tried and failed to reuse look-ahead token after an
6733 error, discard it. */
Reid Spencer950bf602007-01-26 08:19:09 +00006734
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006735 if (yychar <= YYEOF)
6736 {
6737 /* Return failure if at end of input. */
6738 if (yychar == YYEOF)
6739 YYABORT;
6740 }
6741 else
6742 {
6743 yydestruct ("Error: discarding", yytoken, &yylval);
6744 yychar = YYEMPTY;
6745 }
6746 }
6747
6748 /* Else will try to reuse look-ahead token after shifting the error
6749 token. */
6750 goto yyerrlab1;
6751
6752
6753/*---------------------------------------------------.
6754| yyerrorlab -- error raised explicitly by YYERROR. |
6755`---------------------------------------------------*/
6756yyerrorlab:
6757
6758 /* Pacify compilers like GCC when the user code never invokes
6759 YYERROR and the label yyerrorlab therefore never appears in user
6760 code. */
6761 if (0)
6762 goto yyerrorlab;
6763
6764yyvsp -= yylen;
6765 yyssp -= yylen;
6766 yystate = *yyssp;
6767 goto yyerrlab1;
6768
6769
6770/*-------------------------------------------------------------.
6771| yyerrlab1 -- common code for both syntax error and YYERROR. |
6772`-------------------------------------------------------------*/
6773yyerrlab1:
6774 yyerrstatus = 3; /* Each real token shifted decrements this. */
6775
6776 for (;;)
6777 {
6778 yyn = yypact[yystate];
6779 if (yyn != YYPACT_NINF)
6780 {
6781 yyn += YYTERROR;
6782 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6783 {
6784 yyn = yytable[yyn];
6785 if (0 < yyn)
6786 break;
6787 }
6788 }
6789
6790 /* Pop the current state because it cannot handle the error token. */
6791 if (yyssp == yyss)
Reid Spencere7c3c602006-11-30 06:36:44 +00006792 YYABORT;
6793
6794
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006795 yydestruct ("Error: popping", yystos[yystate], yyvsp);
6796 YYPOPSTACK;
6797 yystate = *yyssp;
6798 YY_STACK_PRINT (yyss, yyssp);
Reid Spencere7c3c602006-11-30 06:36:44 +00006799 }
6800
6801 if (yyn == YYFINAL)
6802 YYACCEPT;
6803
6804 *++yyvsp = yylval;
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006805
6806
6807 /* Shift the error token. */
6808 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spencer950bf602007-01-26 08:19:09 +00006809
Reid Spencere7c3c602006-11-30 06:36:44 +00006810 yystate = yyn;
6811 goto yynewstate;
6812
Chris Lattner4227bdb2007-02-19 07:34:02 +00006813
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006814/*-------------------------------------.
6815| yyacceptlab -- YYACCEPT comes here. |
6816`-------------------------------------*/
6817yyacceptlab:
6818 yyresult = 0;
6819 goto yyreturn;
6820
6821/*-----------------------------------.
6822| yyabortlab -- YYABORT comes here. |
6823`-----------------------------------*/
6824yyabortlab:
6825 yyresult = 1;
6826 goto yyreturn;
6827
6828#ifndef yyoverflow
6829/*-------------------------------------------------.
6830| yyexhaustedlab -- memory exhaustion comes here. |
6831`-------------------------------------------------*/
6832yyexhaustedlab:
6833 yyerror (YY_("memory exhausted"));
6834 yyresult = 2;
6835 /* Fall through. */
Chris Lattner4227bdb2007-02-19 07:34:02 +00006836#endif
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006837
6838yyreturn:
6839 if (yychar != YYEOF && yychar != YYEMPTY)
6840 yydestruct ("Cleanup: discarding lookahead",
6841 yytoken, &yylval);
6842 while (yyssp != yyss)
6843 {
6844 yydestruct ("Cleanup: popping",
6845 yystos[*yyssp], yyvsp);
6846 YYPOPSTACK;
Chris Lattner4227bdb2007-02-19 07:34:02 +00006847 }
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006848#ifndef yyoverflow
6849 if (yyss != yyssa)
6850 YYSTACK_FREE (yyss);
6851#endif
6852 return yyresult;
Reid Spencere7c3c602006-11-30 06:36:44 +00006853}
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006854
6855
Reid Spencerbaba98a2007-04-11 12:10:58 +00006856#line 3871 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y"
Reid Spencere7c3c602006-11-30 06:36:44 +00006857
6858
6859int yyerror(const char *ErrorMsg) {
6860 std::string where
6861 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
Reid Spencered96d1e2007-02-08 09:08:52 +00006862 + ":" + llvm::utostr((unsigned) Upgradelineno) + ": ";
Reid Spencer950bf602007-01-26 08:19:09 +00006863 std::string errMsg = where + "error: " + std::string(ErrorMsg);
6864 if (yychar != YYEMPTY && yychar != 0)
6865 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6866 "'.";
Reid Spencer71d2ec92006-12-31 06:02:26 +00006867 std::cerr << "llvm-upgrade: " << errMsg << '\n';
Reid Spencer950bf602007-01-26 08:19:09 +00006868 std::cout << "llvm-upgrade: parse failed.\n";
Reid Spencere7c3c602006-11-30 06:36:44 +00006869 exit(1);
6870}
Reid Spencer319a7302007-01-05 17:20:02 +00006871
Reid Spencer30d0c582007-01-15 00:26:18 +00006872void warning(const std::string& ErrorMsg) {
Reid Spencer319a7302007-01-05 17:20:02 +00006873 std::string where
6874 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
Reid Spencered96d1e2007-02-08 09:08:52 +00006875 + ":" + llvm::utostr((unsigned) Upgradelineno) + ": ";
Reid Spencer950bf602007-01-26 08:19:09 +00006876 std::string errMsg = where + "warning: " + std::string(ErrorMsg);
6877 if (yychar != YYEMPTY && yychar != 0)
6878 errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
6879 "'.";
Reid Spencer319a7302007-01-05 17:20:02 +00006880 std::cerr << "llvm-upgrade: " << errMsg << '\n';
6881}
6882
Reid Spencer950bf602007-01-26 08:19:09 +00006883void error(const std::string& ErrorMsg, int LineNo) {
6884 if (LineNo == -1) LineNo = Upgradelineno;
6885 Upgradelineno = LineNo;
6886 yyerror(ErrorMsg.c_str());
6887}
6888
Reid Spencer3fae7ba2007-03-14 23:13:06 +00006889