blob: 981ca534478e17d9c38efbe7dcd06da1a9d4b510 [file] [log] [blame]
Reid Spencer3822ff52006-11-08 06:47:33 +00001/* A Bison parser, made by GNU Bison 2.1. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002
Reid Spencer3822ff52006-11-08 06:47:33 +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 Spencer68a24bd2005-08-27 18:50:39 +00005
Reid Spencer3822ff52006-11-08 06:47:33 +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.
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +000010
Reid Spencer3822ff52006-11-08 06:47:33 +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 Spencer68a24bd2005-08-27 18:50:39 +000052#define yyparse llvmAsmparse
Reid Spencer3822ff52006-11-08 06:47:33 +000053#define yylex llvmAsmlex
Reid Spencer68a24bd2005-08-27 18:50:39 +000054#define yyerror llvmAsmerror
Reid Spencer3822ff52006-11-08 06:47:33 +000055#define yylval llvmAsmlval
56#define yychar llvmAsmchar
Reid Spencer68a24bd2005-08-27 18:50:39 +000057#define yydebug llvmAsmdebug
58#define yynerrs llvmAsmnerrs
59
Reid Spencer3822ff52006-11-08 06:47:33 +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 UNWIND = 331,
141 UNREACHABLE = 332,
142 ADD = 333,
143 SUB = 334,
144 MUL = 335,
145 UDIV = 336,
146 SDIV = 337,
147 FDIV = 338,
148 UREM = 339,
149 SREM = 340,
150 FREM = 341,
151 AND = 342,
152 OR = 343,
153 XOR = 344,
154 SETLE = 345,
155 SETGE = 346,
156 SETLT = 347,
157 SETGT = 348,
158 SETEQ = 349,
159 SETNE = 350,
Reid Spencera132e042006-12-03 05:46:11 +0000160 ICMP = 351,
161 FCMP = 352,
162 EQ = 353,
163 NE = 354,
164 SLT = 355,
165 SGT = 356,
166 SLE = 357,
167 SGE = 358,
168 ULT = 359,
169 UGT = 360,
170 ULE = 361,
171 UGE = 362,
Reid Spencer6e18b7d2006-12-03 06:59:29 +0000172 OEQ = 363,
173 ONE = 364,
174 OLT = 365,
175 OGT = 366,
176 OLE = 367,
177 OGE = 368,
Reid Spencera132e042006-12-03 05:46:11 +0000178 ORD = 369,
179 UNO = 370,
Reid Spencer6e18b7d2006-12-03 06:59:29 +0000180 UEQ = 371,
181 UNE = 372,
182 MALLOC = 373,
183 ALLOCA = 374,
184 FREE = 375,
185 LOAD = 376,
186 STORE = 377,
187 GETELEMENTPTR = 378,
188 TRUNC = 379,
189 ZEXT = 380,
190 SEXT = 381,
191 FPTRUNC = 382,
192 FPEXT = 383,
193 BITCAST = 384,
194 UITOFP = 385,
195 SITOFP = 386,
196 FPTOUI = 387,
197 FPTOSI = 388,
198 INTTOPTR = 389,
199 PTRTOINT = 390,
200 PHI_TOK = 391,
201 SELECT = 392,
202 SHL = 393,
203 LSHR = 394,
204 ASHR = 395,
205 VAARG = 396,
206 EXTRACTELEMENT = 397,
207 INSERTELEMENT = 398,
208 SHUFFLEVECTOR = 399,
209 VAARG_old = 400,
210 VANEXT_old = 401
Reid Spencer3822ff52006-11-08 06:47:33 +0000211 };
212#endif
213/* Tokens. */
214#define ESINT64VAL 258
215#define EUINT64VAL 259
216#define SINTVAL 260
217#define UINTVAL 261
218#define FPVAL 262
219#define VOID 263
220#define BOOL 264
221#define SBYTE 265
222#define UBYTE 266
223#define SHORT 267
224#define USHORT 268
225#define INT 269
226#define UINT 270
227#define LONG 271
228#define ULONG 272
229#define FLOAT 273
230#define DOUBLE 274
231#define TYPE 275
232#define LABEL 276
233#define VAR_ID 277
234#define LABELSTR 278
235#define STRINGCONSTANT 279
236#define IMPLEMENTATION 280
237#define ZEROINITIALIZER 281
238#define TRUETOK 282
239#define FALSETOK 283
240#define BEGINTOK 284
241#define ENDTOK 285
242#define DECLARE 286
243#define GLOBAL 287
244#define CONSTANT 288
245#define SECTION 289
246#define VOLATILE 290
247#define TO 291
248#define DOTDOTDOT 292
249#define NULL_TOK 293
250#define UNDEF 294
251#define CONST 295
252#define INTERNAL 296
253#define LINKONCE 297
254#define WEAK 298
255#define APPENDING 299
256#define DLLIMPORT 300
257#define DLLEXPORT 301
258#define EXTERN_WEAK 302
259#define OPAQUE 303
260#define NOT 304
261#define EXTERNAL 305
262#define TARGET 306
263#define TRIPLE 307
264#define ENDIAN 308
265#define POINTERSIZE 309
266#define LITTLE 310
267#define BIG 311
268#define ALIGN 312
269#define DEPLIBS 313
270#define CALL 314
271#define TAIL 315
272#define ASM_TOK 316
273#define MODULE 317
274#define SIDEEFFECT 318
275#define CC_TOK 319
276#define CCC_TOK 320
277#define CSRETCC_TOK 321
278#define FASTCC_TOK 322
279#define COLDCC_TOK 323
280#define X86_STDCALLCC_TOK 324
281#define X86_FASTCALLCC_TOK 325
282#define DATALAYOUT 326
283#define RET 327
284#define BR 328
285#define SWITCH 329
286#define INVOKE 330
287#define UNWIND 331
288#define UNREACHABLE 332
289#define ADD 333
290#define SUB 334
291#define MUL 335
292#define UDIV 336
293#define SDIV 337
294#define FDIV 338
295#define UREM 339
296#define SREM 340
297#define FREM 341
298#define AND 342
299#define OR 343
300#define XOR 344
301#define SETLE 345
302#define SETGE 346
303#define SETLT 347
304#define SETGT 348
305#define SETEQ 349
306#define SETNE 350
Reid Spencera132e042006-12-03 05:46:11 +0000307#define ICMP 351
308#define FCMP 352
309#define EQ 353
310#define NE 354
311#define SLT 355
312#define SGT 356
313#define SLE 357
314#define SGE 358
315#define ULT 359
316#define UGT 360
317#define ULE 361
318#define UGE 362
Reid Spencer6e18b7d2006-12-03 06:59:29 +0000319#define OEQ 363
320#define ONE 364
321#define OLT 365
322#define OGT 366
323#define OLE 367
324#define OGE 368
Reid Spencera132e042006-12-03 05:46:11 +0000325#define ORD 369
326#define UNO 370
Reid Spencer6e18b7d2006-12-03 06:59:29 +0000327#define UEQ 371
328#define UNE 372
329#define MALLOC 373
330#define ALLOCA 374
331#define FREE 375
332#define LOAD 376
333#define STORE 377
334#define GETELEMENTPTR 378
335#define TRUNC 379
336#define ZEXT 380
337#define SEXT 381
338#define FPTRUNC 382
339#define FPEXT 383
340#define BITCAST 384
341#define UITOFP 385
342#define SITOFP 386
343#define FPTOUI 387
344#define FPTOSI 388
345#define INTTOPTR 389
346#define PTRTOINT 390
347#define PHI_TOK 391
348#define SELECT 392
349#define SHL 393
350#define LSHR 394
351#define ASHR 395
352#define VAARG 396
353#define EXTRACTELEMENT 397
354#define INSERTELEMENT 398
355#define SHUFFLEVECTOR 399
356#define VAARG_old 400
357#define VANEXT_old 401
Reid Spencer3822ff52006-11-08 06:47:33 +0000358
359
360
361
362/* Copy the first part of user declarations. */
Reid Spencer861d9d62006-11-28 07:29:44 +0000363#line 14 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000364
365#include "ParserInternals.h"
366#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000367#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000368#include "llvm/Instructions.h"
369#include "llvm/Module.h"
370#include "llvm/SymbolTable.h"
Reid Spencer0b118202006-01-16 21:12:35 +0000371#include "llvm/Assembly/AutoUpgrade.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000372#include "llvm/Support/GetElementPtrTypeIterator.h"
373#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000374#include "llvm/Support/MathExtras.h"
Reid Spencer481169e2006-12-01 00:33:46 +0000375#include "llvm/Support/Streams.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000376#include <algorithm>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000377#include <list>
378#include <utility>
379
Reid Spencere4f47592006-08-18 17:32:55 +0000380// The following is a gross hack. In order to rid the libAsmParser library of
381// exceptions, we have to have a way of getting the yyparse function to go into
382// an error situation. So, whenever we want an error to occur, the GenerateError
383// function (see bottom of file) sets TriggerError. Then, at the end of each
384// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
385// (a goto) to put YACC in error state. Furthermore, several calls to
386// GenerateError are made from inside productions and they must simulate the
387// previous exception behavior by exiting the production immediately. We have
388// replaced these with the GEN_ERROR macro which calls GeneratError and then
389// immediately invokes YYERROR. This would be so much cleaner if it was a
390// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000391static bool TriggerError = false;
Reid Spencerf63697d2006-10-09 17:36:59 +0000392#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000393#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
394
Reid Spencer68a24bd2005-08-27 18:50:39 +0000395int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
396int yylex(); // declaration" of xxx warnings.
397int yyparse();
398
399namespace llvm {
400 std::string CurFilename;
401}
402using namespace llvm;
403
404static Module *ParserResult;
405
406// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
407// relating to upreferences in the input stream.
408//
409//#define DEBUG_UPREFS 1
410#ifdef DEBUG_UPREFS
Reid Spencer481169e2006-12-01 00:33:46 +0000411#define UR_OUT(X) llvm_cerr << X
Reid Spencer68a24bd2005-08-27 18:50:39 +0000412#else
413#define UR_OUT(X)
414#endif
415
416#define YYERROR_VERBOSE 1
417
418static bool ObsoleteVarArgs;
419static bool NewVarArgs;
Chris Lattnerb475c422005-11-12 18:22:38 +0000420static BasicBlock *CurBB;
421static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000422
423
424// This contains info used when building the body of a function. It is
425// destroyed when the function is completed.
426//
427typedef std::vector<Value *> ValueList; // Numbered defs
428static void
429ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
430 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
431
432static struct PerModuleInfo {
433 Module *CurrentModule;
434 std::map<const Type *, ValueList> Values; // Module level numbered definitions
435 std::map<const Type *,ValueList> LateResolveValues;
Reid Spencer861d9d62006-11-28 07:29:44 +0000436 std::vector<PATypeHolder> Types;
437 std::map<ValID, PATypeHolder> LateResolveTypes;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000438
439 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000440 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000441 /// that we can resolve them later and print error messages as appropriate.
442 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
443
444 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
445 // references to global values. Global values may be referenced before they
446 // are defined, and if so, the temporary object that they represent is held
447 // here. This is used for forward references of GlobalValues.
448 //
449 typedef std::map<std::pair<const PointerType *,
450 ValID>, GlobalValue*> GlobalRefsType;
451 GlobalRefsType GlobalRefs;
452
453 void ModuleDone() {
454 // If we could not resolve some functions at function compilation time
455 // (calls to functions before they are defined), resolve them now... Types
456 // are resolved when the constant pool has been completely parsed.
457 //
458 ResolveDefinitions(LateResolveValues);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000459 if (TriggerError)
460 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000461
462 // Check to make sure that all global value forward references have been
463 // resolved!
464 //
465 if (!GlobalRefs.empty()) {
466 std::string UndefinedReferences = "Unresolved global references exist:\n";
467
468 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
469 I != E; ++I) {
470 UndefinedReferences += " " + I->first.first->getDescription() + " " +
471 I->first.second.getName() + "\n";
472 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000473 GenerateError(UndefinedReferences);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000474 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000475 }
476
477 Values.clear(); // Clear out function local definitions
478 Types.clear();
479 CurrentModule = 0;
480 }
481
Reid Spencer68a24bd2005-08-27 18:50:39 +0000482 // GetForwardRefForGlobal - Check to see if there is a forward reference
483 // for this global. If so, remove it from the GlobalRefs map and return it.
484 // If not, just return null.
485 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
486 // Check to see if there is a forward reference to this global variable...
487 // if there is, eliminate it and patch the reference to use the new def'n.
488 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
489 GlobalValue *Ret = 0;
490 if (I != GlobalRefs.end()) {
491 Ret = I->second;
492 GlobalRefs.erase(I);
493 }
494 return Ret;
495 }
496} CurModule;
497
498static struct PerFunctionInfo {
499 Function *CurrentFunction; // Pointer to current function being created
500
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000501 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
Reid Spencer68a24bd2005-08-27 18:50:39 +0000502 std::map<const Type*, ValueList> LateResolveValues;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000503 bool isDeclare; // Is this function a forward declararation?
504 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Reid Spencer68a24bd2005-08-27 18:50:39 +0000505
506 /// BBForwardRefs - When we see forward references to basic blocks, keep
507 /// track of them here.
508 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
509 std::vector<BasicBlock*> NumberedBlocks;
510 unsigned NextBBNum;
511
512 inline PerFunctionInfo() {
513 CurrentFunction = 0;
514 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000515 Linkage = GlobalValue::ExternalLinkage;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000516 }
517
518 inline void FunctionStart(Function *M) {
519 CurrentFunction = M;
520 NextBBNum = 0;
521 }
522
523 void FunctionDone() {
524 NumberedBlocks.clear();
525
526 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000527 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000528 GenerateError("Undefined reference to label " +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000529 BBForwardRefs.begin()->first->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000530 return;
531 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000532
533 // Resolve all forward references now.
534 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
535
536 Values.clear(); // Clear out function local definitions
537 CurrentFunction = 0;
538 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000539 Linkage = GlobalValue::ExternalLinkage;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000540 }
541} CurFun; // Info for the current function...
542
543static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
544
545
546//===----------------------------------------------------------------------===//
547// Code to handle definitions of all the types
548//===----------------------------------------------------------------------===//
549
550static int InsertValue(Value *V,
551 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
552 if (V->hasName()) return -1; // Is this a numbered definition?
553
554 // Yes, insert the value into the value table...
555 ValueList &List = ValueTab[V->getType()];
556 List.push_back(V);
557 return List.size()-1;
558}
559
560static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
561 switch (D.Type) {
562 case ValID::NumberVal: // Is it a numbered definition?
563 // Module constants occupy the lowest numbered slots...
564 if ((unsigned)D.Num < CurModule.Types.size())
Reid Spencer861d9d62006-11-28 07:29:44 +0000565 return CurModule.Types[(unsigned)D.Num];
Reid Spencer68a24bd2005-08-27 18:50:39 +0000566 break;
567 case ValID::NameVal: // Is it a named definition?
568 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
569 D.destroy(); // Free old strdup'd memory...
570 return N;
571 }
572 break;
573 default:
Reid Spencer61c83e02006-08-18 08:43:06 +0000574 GenerateError("Internal parser error: Invalid symbol type reference!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000575 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000576 }
577
578 // If we reached here, we referenced either a symbol that we don't know about
579 // or an id number that hasn't been read yet. We may be referencing something
580 // forward, so just create an entry to be resolved later and get to it...
581 //
582 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
583
584
585 if (inFunctionScope()) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000586 if (D.Type == ValID::NameVal) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000587 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000588 return 0;
589 } else {
Reid Spencer61c83e02006-08-18 08:43:06 +0000590 GenerateError("Reference to an undefined type: #" + itostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000591 return 0;
592 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000593 }
594
Reid Spencer861d9d62006-11-28 07:29:44 +0000595 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000596 if (I != CurModule.LateResolveTypes.end())
Reid Spencer861d9d62006-11-28 07:29:44 +0000597 return I->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000598
Reid Spencer861d9d62006-11-28 07:29:44 +0000599 Type *Typ = OpaqueType::get();
600 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
601 return Typ;
Reid Spencera132e042006-12-03 05:46:11 +0000602 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000603
604static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
605 SymbolTable &SymTab =
606 inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() :
607 CurModule.CurrentModule->getSymbolTable();
608 return SymTab.lookup(Ty, Name);
609}
610
611// getValNonImprovising - Look up the value specified by the provided type and
612// the provided ValID. If the value exists and has already been defined, return
613// it. Otherwise return null.
614//
615static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000616 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000617 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000618 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000619 return 0;
620 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000621
622 switch (D.Type) {
623 case ValID::NumberVal: { // Is it a numbered definition?
624 unsigned Num = (unsigned)D.Num;
625
626 // Module constants occupy the lowest numbered slots...
627 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
628 if (VI != CurModule.Values.end()) {
629 if (Num < VI->second.size())
630 return VI->second[Num];
631 Num -= VI->second.size();
632 }
633
634 // Make sure that our type is within bounds
635 VI = CurFun.Values.find(Ty);
636 if (VI == CurFun.Values.end()) return 0;
637
638 // Check that the number is within bounds...
639 if (VI->second.size() <= Num) return 0;
640
641 return VI->second[Num];
642 }
643
644 case ValID::NameVal: { // Is it a named definition?
645 Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
646 if (N == 0) return 0;
647
648 D.destroy(); // Free old strdup'd memory...
649 return N;
650 }
651
652 // Check to make sure that "Ty" is an integral type, and that our
653 // value will fit into the specified type...
654 case ValID::ConstSIntVal: // Is it a constant pool reference??
Reid Spencerb83eb642006-10-20 07:07:24 +0000655 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000656 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000657 itostr(D.ConstPool64) + "' is invalid for type '" +
658 Ty->getDescription() + "'!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000659 return 0;
660 }
Reid Spencerb83eb642006-10-20 07:07:24 +0000661 return ConstantInt::get(Ty, D.ConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000662
663 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Reid Spencerb83eb642006-10-20 07:07:24 +0000664 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
665 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000666 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000667 "' is invalid or out of range!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000668 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000669 } else { // This is really a signed reference. Transmogrify.
Reid Spencerb83eb642006-10-20 07:07:24 +0000670 return ConstantInt::get(Ty, D.ConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000671 }
672 } else {
Reid Spencerb83eb642006-10-20 07:07:24 +0000673 return ConstantInt::get(Ty, D.UConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000674 }
675
676 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000677 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000678 GenerateError("FP constant invalid for type!!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000679 return 0;
680 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000681 return ConstantFP::get(Ty, D.ConstPoolFP);
682
683 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000684 if (!isa<PointerType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000685 GenerateError("Cannot create a a non pointer null!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000686 return 0;
687 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000688 return ConstantPointerNull::get(cast<PointerType>(Ty));
689
690 case ValID::ConstUndefVal: // Is it an undef value?
691 return UndefValue::get(Ty);
692
Chris Lattner7aa61892005-12-21 17:53:23 +0000693 case ValID::ConstZeroVal: // Is it a zero value?
694 return Constant::getNullValue(Ty);
695
Reid Spencer68a24bd2005-08-27 18:50:39 +0000696 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000697 if (D.ConstantValue->getType() != Ty) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000698 GenerateError("Constant expression type different from required type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000699 return 0;
700 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000701 return D.ConstantValue;
702
Chris Lattner0e9c3762006-01-25 22:27:16 +0000703 case ValID::InlineAsmVal: { // Inline asm expression
704 const PointerType *PTy = dyn_cast<PointerType>(Ty);
705 const FunctionType *FTy =
706 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000707 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000708 GenerateError("Invalid type for asm constraint string!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000709 return 0;
710 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000711 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
712 D.IAD->HasSideEffects);
713 D.destroy(); // Free InlineAsmDescriptor.
714 return IA;
715 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000716 default:
717 assert(0 && "Unhandled case!");
718 return 0;
719 } // End of switch
720
721 assert(0 && "Unhandled case!");
722 return 0;
723}
724
725// getVal - This function is identical to getValNonImprovising, except that if a
726// value is not already defined, it "improvises" by creating a placeholder var
727// that looks and acts just like the requested variable. When the value is
728// defined later, all uses of the placeholder variable are replaced with the
729// real thing.
730//
731static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000732 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000733 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000734 return 0;
735 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000736
737 // See if the value has already been defined.
738 Value *V = getValNonImprovising(Ty, ID);
739 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000740 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000741
Reid Spencer5b7e7532006-09-28 19:28:24 +0000742 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000743 GenerateError("Invalid use of a composite type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000744 return 0;
745 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000746
747 // If we reached here, we referenced either a symbol that we don't know about
748 // or an id number that hasn't been read yet. We may be referencing something
749 // forward, so just create an entry to be resolved later and get to it...
750 //
751 V = new Argument(Ty);
752
753 // Remember where this forward reference came from. FIXME, shouldn't we try
754 // to recycle these things??
755 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
756 llvmAsmlineno)));
757
758 if (inFunctionScope())
759 InsertValue(V, CurFun.LateResolveValues);
760 else
761 InsertValue(V, CurModule.LateResolveValues);
762 return V;
763}
764
765/// getBBVal - This is used for two purposes:
766/// * If isDefinition is true, a new basic block with the specified ID is being
767/// defined.
768/// * If isDefinition is true, this is a reference to a basic block, which may
769/// or may not be a forward reference.
770///
771static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
772 assert(inFunctionScope() && "Can't get basic block at global scope!");
773
774 std::string Name;
775 BasicBlock *BB = 0;
776 switch (ID.Type) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000777 default:
778 GenerateError("Illegal label reference " + ID.getName());
779 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000780 case ValID::NumberVal: // Is it a numbered definition?
781 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
782 CurFun.NumberedBlocks.resize(ID.Num+1);
783 BB = CurFun.NumberedBlocks[ID.Num];
784 break;
785 case ValID::NameVal: // Is it a named definition?
786 Name = ID.Name;
787 if (Value *N = CurFun.CurrentFunction->
788 getSymbolTable().lookup(Type::LabelTy, Name))
789 BB = cast<BasicBlock>(N);
790 break;
791 }
792
793 // See if the block has already been defined.
794 if (BB) {
795 // If this is the definition of the block, make sure the existing value was
796 // just a forward reference. If it was a forward reference, there will be
797 // an entry for it in the PlaceHolderInfo map.
Reid Spencer5b7e7532006-09-28 19:28:24 +0000798 if (isDefinition && !CurFun.BBForwardRefs.erase(BB)) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000799 // The existing value was a definition, not a forward reference.
Reid Spencer61c83e02006-08-18 08:43:06 +0000800 GenerateError("Redefinition of label " + ID.getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000801 return 0;
802 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000803
804 ID.destroy(); // Free strdup'd memory.
805 return BB;
806 }
807
808 // Otherwise this block has not been seen before.
809 BB = new BasicBlock("", CurFun.CurrentFunction);
810 if (ID.Type == ValID::NameVal) {
811 BB->setName(ID.Name);
812 } else {
813 CurFun.NumberedBlocks[ID.Num] = BB;
814 }
815
816 // If this is not a definition, keep track of it so we can use it as a forward
817 // reference.
818 if (!isDefinition) {
819 // Remember where this forward reference came from.
820 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
821 } else {
822 // The forward declaration could have been inserted anywhere in the
823 // function: insert it into the correct place now.
824 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
825 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
826 }
827 ID.destroy();
828 return BB;
829}
830
831
832//===----------------------------------------------------------------------===//
833// Code to handle forward references in instructions
834//===----------------------------------------------------------------------===//
835//
836// This code handles the late binding needed with statements that reference
837// values not defined yet... for example, a forward branch, or the PHI node for
838// a loop body.
839//
840// This keeps a table (CurFun.LateResolveValues) of all such forward references
841// and back patchs after we are done.
842//
843
844// ResolveDefinitions - If we could not resolve some defs at parsing
845// time (forward branches, phi functions for loops, etc...) resolve the
846// defs now...
847//
848static void
849ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
850 std::map<const Type*,ValueList> *FutureLateResolvers) {
851 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
852 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
853 E = LateResolvers.end(); LRI != E; ++LRI) {
854 ValueList &List = LRI->second;
855 while (!List.empty()) {
856 Value *V = List.back();
857 List.pop_back();
858
859 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
860 CurModule.PlaceHolderInfo.find(V);
861 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
862
863 ValID &DID = PHI->second.first;
864
865 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000866 if (TriggerError)
867 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000868 if (TheRealValue) {
869 V->replaceAllUsesWith(TheRealValue);
870 delete V;
871 CurModule.PlaceHolderInfo.erase(PHI);
872 } else if (FutureLateResolvers) {
873 // Functions have their unresolved items forwarded to the module late
874 // resolver table
875 InsertValue(V, *FutureLateResolvers);
876 } else {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000877 if (DID.Type == ValID::NameVal) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000878 GenerateError("Reference to an invalid definition: '" +DID.getName()+
Reid Spencer68a24bd2005-08-27 18:50:39 +0000879 "' of type '" + V->getType()->getDescription() + "'",
880 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000881 return;
882 } else {
Reid Spencer61c83e02006-08-18 08:43:06 +0000883 GenerateError("Reference to an invalid definition: #" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000884 itostr(DID.Num) + " of type '" +
885 V->getType()->getDescription() + "'",
886 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000887 return;
888 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000889 }
890 }
891 }
892
893 LateResolvers.clear();
894}
895
896// ResolveTypeTo - A brand new type was just declared. This means that (if
897// name is not null) things referencing Name can be resolved. Otherwise, things
898// refering to the number can be resolved. Do this now.
899//
900static void ResolveTypeTo(char *Name, const Type *ToTy) {
901 ValID D;
902 if (Name) D = ValID::create(Name);
903 else D = ValID::create((int)CurModule.Types.size());
904
Reid Spencer861d9d62006-11-28 07:29:44 +0000905 std::map<ValID, PATypeHolder>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +0000906 CurModule.LateResolveTypes.find(D);
907 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer861d9d62006-11-28 07:29:44 +0000908 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000909 CurModule.LateResolveTypes.erase(I);
910 }
911}
912
913// setValueName - Set the specified value to the name given. The name may be
914// null potentially, in which case this is a noop. The string passed in is
915// assumed to be a malloc'd string buffer, and is free'd by this function.
916//
917static void setValueName(Value *V, char *NameStr) {
918 if (NameStr) {
919 std::string Name(NameStr); // Copy string
920 free(NameStr); // Free old string
921
Reid Spencer5b7e7532006-09-28 19:28:24 +0000922 if (V->getType() == Type::VoidTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000923 GenerateError("Can't assign name '" + Name+"' to value with void type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000924 return;
925 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000926
927 assert(inFunctionScope() && "Must be in function scope!");
928 SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable();
Reid Spencer5b7e7532006-09-28 19:28:24 +0000929 if (ST.lookup(V->getType(), Name)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000930 GenerateError("Redefinition of value named '" + Name + "' in the '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000931 V->getType()->getDescription() + "' type plane!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000932 return;
933 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000934
935 // Set the name.
936 V->setName(Name);
937 }
938}
939
940/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
941/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +0000942static GlobalVariable *
943ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
944 bool isConstantGlobal, const Type *Ty,
945 Constant *Initializer) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000946 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000947 GenerateError("Cannot declare global vars of function type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000948 return 0;
949 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000950
951 const PointerType *PTy = PointerType::get(Ty);
952
953 std::string Name;
954 if (NameStr) {
955 Name = NameStr; // Copy string
956 free(NameStr); // Free old string
957 }
958
959 // See if this global value was forward referenced. If so, recycle the
960 // object.
961 ValID ID;
962 if (!Name.empty()) {
963 ID = ValID::create((char*)Name.c_str());
964 } else {
965 ID = ValID::create((int)CurModule.Values[PTy].size());
966 }
967
968 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
969 // Move the global to the end of the list, from whereever it was
970 // previously inserted.
971 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
972 CurModule.CurrentModule->getGlobalList().remove(GV);
973 CurModule.CurrentModule->getGlobalList().push_back(GV);
974 GV->setInitializer(Initializer);
975 GV->setLinkage(Linkage);
976 GV->setConstant(isConstantGlobal);
977 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000978 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000979 }
980
981 // If this global has a name, check to see if there is already a definition
982 // of this global in the module. If so, merge as appropriate. Note that
983 // this is really just a hack around problems in the CFE. :(
984 if (!Name.empty()) {
985 // We are a simple redefinition of a value, check to see if it is defined
986 // the same as the old one.
987 if (GlobalVariable *EGV =
988 CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
989 // We are allowed to redefine a global variable in two circumstances:
990 // 1. If at least one of the globals is uninitialized or
991 // 2. If both initializers have the same value.
992 //
993 if (!EGV->hasInitializer() || !Initializer ||
994 EGV->getInitializer() == Initializer) {
995
996 // Make sure the existing global version gets the initializer! Make
997 // sure that it also gets marked const if the new version is.
998 if (Initializer && !EGV->hasInitializer())
999 EGV->setInitializer(Initializer);
1000 if (isConstantGlobal)
1001 EGV->setConstant(true);
1002 EGV->setLinkage(Linkage);
Chris Lattnerb475c422005-11-12 18:22:38 +00001003 return EGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001004 }
1005
Reid Spencer61c83e02006-08-18 08:43:06 +00001006 GenerateError("Redefinition of global variable named '" + Name +
Reid Spencer68a24bd2005-08-27 18:50:39 +00001007 "' in the '" + Ty->getDescription() + "' type plane!");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001008 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001009 }
1010 }
1011
1012 // Otherwise there is no existing GV to use, create one now.
1013 GlobalVariable *GV =
1014 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
1015 CurModule.CurrentModule);
1016 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001017 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001018}
1019
1020// setTypeName - Set the specified type to the name given. The name may be
1021// null potentially, in which case this is a noop. The string passed in is
1022// assumed to be a malloc'd string buffer, and is freed by this function.
1023//
1024// This function returns true if the type has already been defined, but is
1025// allowed to be redefined in the specified context. If the name is a new name
1026// for the type plane, it is inserted and false is returned.
1027static bool setTypeName(const Type *T, char *NameStr) {
1028 assert(!inFunctionScope() && "Can't give types function-local names!");
1029 if (NameStr == 0) return false;
1030
1031 std::string Name(NameStr); // Copy string
1032 free(NameStr); // Free old string
1033
1034 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +00001035 if (T == Type::VoidTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +00001036 GenerateError("Can't assign name '" + Name + "' to the void type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001037 return false;
1038 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001039
1040 // Set the type name, checking for conflicts as we do so.
1041 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1042
1043 if (AlreadyExists) { // Inserting a name that is already defined???
1044 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
1045 assert(Existing && "Conflict but no matching type?");
1046
1047 // There is only one case where this is allowed: when we are refining an
1048 // opaque type. In this case, Existing will be an opaque type.
1049 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1050 // We ARE replacing an opaque type!
1051 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1052 return true;
1053 }
1054
1055 // Otherwise, this is an attempt to redefine a type. That's okay if
1056 // the redefinition is identical to the original. This will be so if
1057 // Existing and T point to the same Type object. In this one case we
1058 // allow the equivalent redefinition.
1059 if (Existing == T) return true; // Yes, it's equal.
1060
1061 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer61c83e02006-08-18 08:43:06 +00001062 GenerateError("Redefinition of type named '" + Name + "' in the '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00001063 T->getDescription() + "' type plane!");
1064 }
1065
1066 return false;
1067}
1068
1069//===----------------------------------------------------------------------===//
1070// Code for handling upreferences in type names...
1071//
1072
1073// TypeContains - Returns true if Ty directly contains E in it.
1074//
1075static bool TypeContains(const Type *Ty, const Type *E) {
1076 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1077 E) != Ty->subtype_end();
1078}
1079
1080namespace {
1081 struct UpRefRecord {
1082 // NestingLevel - The number of nesting levels that need to be popped before
1083 // this type is resolved.
1084 unsigned NestingLevel;
1085
1086 // LastContainedTy - This is the type at the current binding level for the
1087 // type. Every time we reduce the nesting level, this gets updated.
1088 const Type *LastContainedTy;
1089
1090 // UpRefTy - This is the actual opaque type that the upreference is
1091 // represented with.
1092 OpaqueType *UpRefTy;
1093
1094 UpRefRecord(unsigned NL, OpaqueType *URTy)
1095 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1096 };
1097}
1098
1099// UpRefs - A list of the outstanding upreferences that need to be resolved.
1100static std::vector<UpRefRecord> UpRefs;
1101
1102/// HandleUpRefs - Every time we finish a new layer of types, this function is
1103/// called. It loops through the UpRefs vector, which is a list of the
1104/// currently active types. For each type, if the up reference is contained in
1105/// the newly completed type, we decrement the level count. When the level
1106/// count reaches zero, the upreferenced type is the type that is passed in:
1107/// thus we can complete the cycle.
1108///
1109static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001110 // If Ty isn't abstract, or if there are no up-references in it, then there is
1111 // nothing to resolve here.
1112 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1113
Reid Spencer68a24bd2005-08-27 18:50:39 +00001114 PATypeHolder Ty(ty);
1115 UR_OUT("Type '" << Ty->getDescription() <<
1116 "' newly formed. Resolving upreferences.\n" <<
1117 UpRefs.size() << " upreferences active!\n");
1118
1119 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1120 // to zero), we resolve them all together before we resolve them to Ty. At
1121 // the end of the loop, if there is anything to resolve to Ty, it will be in
1122 // this variable.
1123 OpaqueType *TypeToResolve = 0;
1124
1125 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1126 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1127 << UpRefs[i].second->getDescription() << ") = "
1128 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1129 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1130 // Decrement level of upreference
1131 unsigned Level = --UpRefs[i].NestingLevel;
1132 UpRefs[i].LastContainedTy = Ty;
1133 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1134 if (Level == 0) { // Upreference should be resolved!
1135 if (!TypeToResolve) {
1136 TypeToResolve = UpRefs[i].UpRefTy;
1137 } else {
1138 UR_OUT(" * Resolving upreference for "
1139 << UpRefs[i].second->getDescription() << "\n";
1140 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1141 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1142 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1143 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1144 }
1145 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1146 --i; // Do not skip the next element...
1147 }
1148 }
1149 }
1150
1151 if (TypeToResolve) {
1152 UR_OUT(" * Resolving upreference for "
1153 << UpRefs[i].second->getDescription() << "\n";
1154 std::string OldName = TypeToResolve->getDescription());
1155 TypeToResolve->refineAbstractTypeTo(Ty);
1156 }
1157
1158 return Ty;
1159}
1160
Reid Spencer68a24bd2005-08-27 18:50:39 +00001161// common code from the two 'RunVMAsmParser' functions
Reid Spencer5b7e7532006-09-28 19:28:24 +00001162static Module* RunParser(Module * M) {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001163
1164 llvmAsmlineno = 1; // Reset the current line number...
1165 ObsoleteVarArgs = false;
1166 NewVarArgs = false;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001167 CurModule.CurrentModule = M;
Reid Spencerf63697d2006-10-09 17:36:59 +00001168
1169 // Check to make sure the parser succeeded
1170 if (yyparse()) {
1171 if (ParserResult)
1172 delete ParserResult;
1173 return 0;
1174 }
1175
1176 // Check to make sure that parsing produced a result
Reid Spencer61c83e02006-08-18 08:43:06 +00001177 if (!ParserResult)
1178 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001179
Reid Spencerf63697d2006-10-09 17:36:59 +00001180 // Reset ParserResult variable while saving its value for the result.
Reid Spencer68a24bd2005-08-27 18:50:39 +00001181 Module *Result = ParserResult;
1182 ParserResult = 0;
1183
1184 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
1185 {
1186 Function* F;
1187 if ((F = Result->getNamedFunction("llvm.va_start"))
1188 && F->getFunctionType()->getNumParams() == 0)
1189 ObsoleteVarArgs = true;
1190 if((F = Result->getNamedFunction("llvm.va_copy"))
1191 && F->getFunctionType()->getNumParams() == 1)
1192 ObsoleteVarArgs = true;
1193 }
1194
Reid Spencer5b7e7532006-09-28 19:28:24 +00001195 if (ObsoleteVarArgs && NewVarArgs) {
1196 GenerateError(
1197 "This file is corrupt: it uses both new and old style varargs");
1198 return 0;
1199 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001200
1201 if(ObsoleteVarArgs) {
1202 if(Function* F = Result->getNamedFunction("llvm.va_start")) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001203 if (F->arg_size() != 0) {
Reid Spencer61c83e02006-08-18 08:43:06 +00001204 GenerateError("Obsolete va_start takes 0 argument!");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001205 return 0;
1206 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001207
1208 //foo = va_start()
1209 // ->
1210 //bar = alloca typeof(foo)
1211 //va_start(bar)
1212 //foo = load bar
1213
1214 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1215 const Type* ArgTy = F->getFunctionType()->getReturnType();
1216 const Type* ArgTyPtr = PointerType::get(ArgTy);
1217 Function* NF = Result->getOrInsertFunction("llvm.va_start",
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001218 RetTy, ArgTyPtr, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001219
1220 while (!F->use_empty()) {
1221 CallInst* CI = cast<CallInst>(F->use_back());
1222 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
1223 new CallInst(NF, bar, "", CI);
1224 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
1225 CI->replaceAllUsesWith(foo);
1226 CI->getParent()->getInstList().erase(CI);
1227 }
1228 Result->getFunctionList().erase(F);
1229 }
1230
1231 if(Function* F = Result->getNamedFunction("llvm.va_end")) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001232 if(F->arg_size() != 1) {
Reid Spencer61c83e02006-08-18 08:43:06 +00001233 GenerateError("Obsolete va_end takes 1 argument!");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001234 return 0;
1235 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001236
1237 //vaend foo
1238 // ->
1239 //bar = alloca 1 of typeof(foo)
1240 //vaend bar
1241 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1242 const Type* ArgTy = F->getFunctionType()->getParamType(0);
1243 const Type* ArgTyPtr = PointerType::get(ArgTy);
1244 Function* NF = Result->getOrInsertFunction("llvm.va_end",
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001245 RetTy, ArgTyPtr, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001246
1247 while (!F->use_empty()) {
1248 CallInst* CI = cast<CallInst>(F->use_back());
1249 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
1250 new StoreInst(CI->getOperand(1), bar, CI);
1251 new CallInst(NF, bar, "", CI);
1252 CI->getParent()->getInstList().erase(CI);
1253 }
1254 Result->getFunctionList().erase(F);
1255 }
1256
1257 if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001258 if(F->arg_size() != 1) {
Reid Spencer61c83e02006-08-18 08:43:06 +00001259 GenerateError("Obsolete va_copy takes 1 argument!");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001260 return 0;
1261 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001262 //foo = vacopy(bar)
1263 // ->
1264 //a = alloca 1 of typeof(foo)
1265 //b = alloca 1 of typeof(foo)
1266 //store bar -> b
1267 //vacopy(a, b)
1268 //foo = load a
1269
1270 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1271 const Type* ArgTy = F->getFunctionType()->getReturnType();
1272 const Type* ArgTyPtr = PointerType::get(ArgTy);
1273 Function* NF = Result->getOrInsertFunction("llvm.va_copy",
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001274 RetTy, ArgTyPtr, ArgTyPtr,
1275 (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001276
1277 while (!F->use_empty()) {
1278 CallInst* CI = cast<CallInst>(F->use_back());
1279 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
1280 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
1281 new StoreInst(CI->getOperand(1), b, CI);
1282 new CallInst(NF, a, b, "", CI);
1283 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
1284 CI->replaceAllUsesWith(foo);
1285 CI->getParent()->getInstList().erase(CI);
1286 }
1287 Result->getFunctionList().erase(F);
1288 }
1289 }
1290
1291 return Result;
Reid Spencer5b7e7532006-09-28 19:28:24 +00001292}
Reid Spencer68a24bd2005-08-27 18:50:39 +00001293
1294//===----------------------------------------------------------------------===//
1295// RunVMAsmParser - Define an interface to this parser
1296//===----------------------------------------------------------------------===//
1297//
1298Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1299 set_scan_file(F);
1300
1301 CurFilename = Filename;
1302 return RunParser(new Module(CurFilename));
1303}
1304
1305Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1306 set_scan_string(AsmString);
1307
1308 CurFilename = "from_memory";
1309 if (M == NULL) {
1310 return RunParser(new Module (CurFilename));
1311 } else {
1312 return RunParser(M);
1313 }
1314}
1315
1316
Reid Spencer3822ff52006-11-08 06:47:33 +00001317
1318/* Enabling traces. */
1319#ifndef YYDEBUG
1320# define YYDEBUG 0
1321#endif
1322
1323/* Enabling verbose error messages. */
1324#ifdef YYERROR_VERBOSE
1325# undef YYERROR_VERBOSE
1326# define YYERROR_VERBOSE 1
1327#else
1328# define YYERROR_VERBOSE 0
1329#endif
1330
1331/* Enabling the token table. */
1332#ifndef YYTOKEN_TABLE
1333# define YYTOKEN_TABLE 0
1334#endif
1335
1336#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
Reid Spencera132e042006-12-03 05:46:11 +00001337#line 968 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00001338typedef union YYSTYPE {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001339 llvm::Module *ModuleVal;
1340 llvm::Function *FunctionVal;
Reid Spencera132e042006-12-03 05:46:11 +00001341 std::pair<llvm::PATypeHolder*, char*> *ArgVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001342 llvm::BasicBlock *BasicBlockVal;
1343 llvm::TerminatorInst *TermInstVal;
1344 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001345 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001346
Reid Spencera132e042006-12-03 05:46:11 +00001347 const llvm::Type *PrimType;
1348 llvm::PATypeHolder *TypeVal;
1349 llvm::Value *ValueVal;
1350
1351 std::vector<std::pair<llvm::PATypeHolder*,char*> > *ArgList;
1352 std::vector<llvm::Value*> *ValueList;
1353 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001354 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001355 std::list<std::pair<llvm::Value*,
1356 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001357 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001358 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001359
1360 llvm::GlobalValue::LinkageTypes Linkage;
1361 int64_t SInt64Val;
1362 uint64_t UInt64Val;
1363 int SIntVal;
1364 unsigned UIntVal;
1365 double FPVal;
1366 bool BoolVal;
1367
1368 char *StrVal; // This memory is strdup'd!
Reid Spencer1628cec2006-10-26 06:15:43 +00001369 llvm::ValID ValIDVal; // strdup'd memory maybe!
Reid Spencer68a24bd2005-08-27 18:50:39 +00001370
Reid Spencera132e042006-12-03 05:46:11 +00001371 llvm::Instruction::BinaryOps BinaryOpVal;
1372 llvm::Instruction::TermOps TermOpVal;
1373 llvm::Instruction::MemoryOps MemOpVal;
1374 llvm::Instruction::CastOps CastOpVal;
1375 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencer1628cec2006-10-26 06:15:43 +00001376 llvm::Module::Endianness Endianness;
Reid Spencera132e042006-12-03 05:46:11 +00001377 llvm::ICmpInst::Predicate IPredicate;
1378 llvm::FCmpInst::Predicate FPredicate;
Reid Spencer5b7e7532006-09-28 19:28:24 +00001379} YYSTYPE;
Reid Spencer3822ff52006-11-08 06:47:33 +00001380/* Line 196 of yacc.c. */
Reid Spencer6e18b7d2006-12-03 06:59:29 +00001381#line 1382 "llvmAsmParser.tab.c"
Reid Spencer3822ff52006-11-08 06:47:33 +00001382# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1383# define YYSTYPE_IS_DECLARED 1
1384# define YYSTYPE_IS_TRIVIAL 1
Reid Spencer68a24bd2005-08-27 18:50:39 +00001385#endif
1386
1387
1388
Reid Spencer3822ff52006-11-08 06:47:33 +00001389/* Copy the second part of user declarations. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001390
1391
Reid Spencer3822ff52006-11-08 06:47:33 +00001392/* Line 219 of yacc.c. */
Reid Spencer6e18b7d2006-12-03 06:59:29 +00001393#line 1394 "llvmAsmParser.tab.c"
Reid Spencer68a24bd2005-08-27 18:50:39 +00001394
Reid Spencer3822ff52006-11-08 06:47:33 +00001395#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
1396# define YYSIZE_T __SIZE_TYPE__
1397#endif
1398#if ! defined (YYSIZE_T) && defined (size_t)
1399# define YYSIZE_T size_t
1400#endif
1401#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
1402# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1403# define YYSIZE_T size_t
1404#endif
1405#if ! defined (YYSIZE_T)
1406# define YYSIZE_T unsigned int
1407#endif
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00001408
Reid Spencer3822ff52006-11-08 06:47:33 +00001409#ifndef YY_
1410# if YYENABLE_NLS
1411# if ENABLE_NLS
1412# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1413# define YY_(msgid) dgettext ("bison-runtime", msgid)
1414# endif
1415# endif
1416# ifndef YY_
1417# define YY_(msgid) msgid
1418# endif
1419#endif
1420
1421#if ! defined (yyoverflow) || YYERROR_VERBOSE
1422
1423/* The parser invokes alloca or malloc; define the necessary symbols. */
1424
1425# ifdef YYSTACK_USE_ALLOCA
1426# if YYSTACK_USE_ALLOCA
1427# ifdef __GNUC__
1428# define YYSTACK_ALLOC __builtin_alloca
1429# else
1430# define YYSTACK_ALLOC alloca
1431# if defined (__STDC__) || defined (__cplusplus)
1432# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1433# define YYINCLUDED_STDLIB_H
1434# endif
1435# endif
1436# endif
1437# endif
1438
1439# ifdef YYSTACK_ALLOC
1440 /* Pacify GCC's `empty if-body' warning. */
1441# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
1442# ifndef YYSTACK_ALLOC_MAXIMUM
1443 /* The OS might guarantee only one guard page at the bottom of the stack,
1444 and a page size can be as small as 4096 bytes. So we cannot safely
1445 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1446 to allow for a few compiler-allocated temporary stack slots. */
1447# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
1448# endif
1449# else
1450# define YYSTACK_ALLOC YYMALLOC
1451# define YYSTACK_FREE YYFREE
1452# ifndef YYSTACK_ALLOC_MAXIMUM
1453# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
1454# endif
1455# ifdef __cplusplus
1456extern "C" {
1457# endif
1458# ifndef YYMALLOC
1459# define YYMALLOC malloc
1460# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
1461 && (defined (__STDC__) || defined (__cplusplus)))
1462void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1463# endif
1464# endif
1465# ifndef YYFREE
1466# define YYFREE free
1467# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
1468 && (defined (__STDC__) || defined (__cplusplus)))
1469void free (void *); /* INFRINGES ON USER NAME SPACE */
1470# endif
1471# endif
1472# ifdef __cplusplus
1473}
1474# endif
1475# endif
1476#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
1477
1478
1479#if (! defined (yyoverflow) \
1480 && (! defined (__cplusplus) \
1481 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
1482
1483/* A type that is properly aligned for any stack member. */
1484union yyalloc
1485{
1486 short int yyss;
1487 YYSTYPE yyvs;
1488 };
1489
1490/* The size of the maximum gap between one aligned stack and the next. */
1491# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1492
1493/* The size of an array large to enough to hold all stacks, each with
1494 N elements. */
1495# define YYSTACK_BYTES(N) \
1496 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
1497 + YYSTACK_GAP_MAXIMUM)
1498
1499/* Copy COUNT objects from FROM to TO. The source and destination do
1500 not overlap. */
1501# ifndef YYCOPY
1502# if defined (__GNUC__) && 1 < __GNUC__
1503# define YYCOPY(To, From, Count) \
1504 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1505# else
1506# define YYCOPY(To, From, Count) \
1507 do \
1508 { \
1509 YYSIZE_T yyi; \
1510 for (yyi = 0; yyi < (Count); yyi++) \
1511 (To)[yyi] = (From)[yyi]; \
1512 } \
1513 while (0)
1514# endif
1515# endif
1516
1517/* Relocate STACK from its old location to the new one. The
1518 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1519 elements in the stack, and YYPTR gives the new location of the
1520 stack. Advance YYPTR to a properly aligned location for the next
1521 stack. */
1522# define YYSTACK_RELOCATE(Stack) \
1523 do \
1524 { \
1525 YYSIZE_T yynewbytes; \
1526 YYCOPY (&yyptr->Stack, Stack, yysize); \
1527 Stack = &yyptr->Stack; \
1528 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1529 yyptr += yynewbytes / sizeof (*yyptr); \
1530 } \
1531 while (0)
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00001532
1533#endif
1534
Reid Spencer3822ff52006-11-08 06:47:33 +00001535#if defined (__STDC__) || defined (__cplusplus)
1536 typedef signed char yysigned_char;
Reid Spencer5b7e7532006-09-28 19:28:24 +00001537#else
Reid Spencer3822ff52006-11-08 06:47:33 +00001538 typedef short int yysigned_char;
Reid Spencer5b7e7532006-09-28 19:28:24 +00001539#endif
1540
Reid Spencer3822ff52006-11-08 06:47:33 +00001541/* YYFINAL -- State number of the termination state. */
1542#define YYFINAL 4
1543/* YYLAST -- Last index in YYTABLE. */
Reid Spencer6e18b7d2006-12-03 06:59:29 +00001544#define YYLAST 1433
Reid Spencer3822ff52006-11-08 06:47:33 +00001545
1546/* YYNTOKENS -- Number of terminals. */
Reid Spencer6e18b7d2006-12-03 06:59:29 +00001547#define YYNTOKENS 161
Reid Spencer3822ff52006-11-08 06:47:33 +00001548/* YYNNTS -- Number of nonterminals. */
Reid Spencera132e042006-12-03 05:46:11 +00001549#define YYNNTS 78
Reid Spencer3822ff52006-11-08 06:47:33 +00001550/* YYNRULES -- Number of rules. */
Reid Spencer6e18b7d2006-12-03 06:59:29 +00001551#define YYNRULES 299
Reid Spencer3822ff52006-11-08 06:47:33 +00001552/* YYNRULES -- Number of states. */
Reid Spencer6e18b7d2006-12-03 06:59:29 +00001553#define YYNSTATES 588
Reid Spencer3822ff52006-11-08 06:47:33 +00001554
1555/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1556#define YYUNDEFTOK 2
Reid Spencer6e18b7d2006-12-03 06:59:29 +00001557#define YYMAXUTOK 401
Reid Spencer3822ff52006-11-08 06:47:33 +00001558
1559#define YYTRANSLATE(YYX) \
1560 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1561
1562/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1563static const unsigned char yytranslate[] =
1564{
1565 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1566 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1567 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1568 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer6e18b7d2006-12-03 06:59:29 +00001569 150, 151, 159, 2, 148, 2, 2, 2, 2, 2,
Reid Spencer3822ff52006-11-08 06:47:33 +00001570 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer6e18b7d2006-12-03 06:59:29 +00001571 155, 147, 156, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer3822ff52006-11-08 06:47:33 +00001572 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1573 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer6e18b7d2006-12-03 06:59:29 +00001574 2, 152, 149, 154, 2, 2, 2, 2, 2, 160,
Reid Spencer3822ff52006-11-08 06:47:33 +00001575 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1576 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer6e18b7d2006-12-03 06:59:29 +00001577 153, 2, 2, 157, 2, 158, 2, 2, 2, 2,
Reid Spencer3822ff52006-11-08 06:47:33 +00001578 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1579 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1580 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1581 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1582 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1583 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1584 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1585 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1586 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1587 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1588 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1589 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1590 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1591 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1592 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1593 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1594 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1595 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1596 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1597 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1598 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1599 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1600 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
Reid Spencer3da59db2006-11-27 01:05:10 +00001601 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
Reid Spencera132e042006-12-03 05:46:11 +00001602 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1603 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
1604 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
Reid Spencer6e18b7d2006-12-03 06:59:29 +00001605 145, 146
Reid Spencer3822ff52006-11-08 06:47:33 +00001606};
1607
1608#if YYDEBUG
1609/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1610 YYRHS. */
1611static const unsigned short int yyprhs[] =
1612{
1613 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1614 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1615 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1616 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
Reid Spencer3da59db2006-11-27 01:05:10 +00001617 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
Reid Spencera132e042006-12-03 05:46:11 +00001618 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
1619 119, 121, 123, 125, 127, 129, 131, 133, 135, 137,
Reid Spencer6e18b7d2006-12-03 06:59:29 +00001620 139, 141, 143, 145, 147, 149, 151, 153, 156, 157,
1621 159, 161, 163, 165, 167, 169, 171, 172, 173, 175,
1622 177, 179, 181, 183, 185, 188, 189, 192, 193, 197,
1623 200, 201, 203, 204, 208, 210, 213, 215, 217, 219,
Reid Spencera132e042006-12-03 05:46:11 +00001624 221, 223, 225, 227, 229, 231, 233, 235, 237, 239,
Reid Spencer6e18b7d2006-12-03 06:59:29 +00001625 241, 243, 245, 247, 249, 251, 253, 255, 258, 263,
1626 269, 275, 279, 282, 285, 287, 291, 293, 297, 299,
1627 300, 305, 309, 313, 318, 323, 327, 330, 333, 336,
1628 339, 342, 345, 348, 351, 354, 357, 364, 370, 379,
1629 386, 393, 400, 409, 418, 425, 432, 441, 450, 454,
1630 456, 458, 460, 462, 465, 468, 473, 476, 478, 483,
1631 486, 491, 492, 500, 501, 509, 510, 518, 519, 527,
1632 531, 536, 537, 539, 541, 543, 547, 551, 555, 559,
1633 563, 567, 569, 570, 572, 574, 576, 577, 580, 584,
1634 586, 588, 592, 594, 595, 604, 606, 608, 612, 614,
1635 616, 619, 620, 622, 624, 625, 630, 631, 633, 635,
1636 637, 639, 641, 643, 645, 647, 649, 653, 655, 661,
1637 663, 665, 667, 669, 672, 675, 678, 682, 685, 686,
1638 688, 691, 694, 698, 708, 718, 727, 741, 743, 745,
1639 752, 758, 761, 768, 776, 778, 782, 784, 785, 788,
1640 790, 796, 802, 808, 815, 822, 825, 830, 835, 842,
1641 847, 852, 857, 862, 869, 876, 879, 887, 889, 892,
1642 893, 895, 896, 900, 907, 911, 918, 921, 926, 933
Reid Spencer3822ff52006-11-08 06:47:33 +00001643};
1644
1645/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1646static const short int yyrhs[] =
1647{
Reid Spencer6e18b7d2006-12-03 06:59:29 +00001648 195, 0, -1, 5, -1, 6, -1, 3, -1, 4,
Reid Spencer3822ff52006-11-08 06:47:33 +00001649 -1, 78, -1, 79, -1, 80, -1, 81, -1, 82,
1650 -1, 83, -1, 84, -1, 85, -1, 86, -1, 87,
1651 -1, 88, -1, 89, -1, 90, -1, 91, -1, 92,
Reid Spencer6e18b7d2006-12-03 06:59:29 +00001652 -1, 93, -1, 94, -1, 95, -1, 124, -1, 125,
1653 -1, 126, -1, 127, -1, 128, -1, 129, -1, 130,
1654 -1, 131, -1, 132, -1, 133, -1, 134, -1, 135,
1655 -1, 138, -1, 139, -1, 140, -1, 98, -1, 99,
Reid Spencera132e042006-12-03 05:46:11 +00001656 -1, 100, -1, 101, -1, 102, -1, 103, -1, 104,
1657 -1, 105, -1, 106, -1, 107, -1, 108, -1, 109,
1658 -1, 110, -1, 111, -1, 112, -1, 113, -1, 114,
Reid Spencer6e18b7d2006-12-03 06:59:29 +00001659 -1, 115, -1, 116, -1, 117, -1, 104, -1, 105,
1660 -1, 106, -1, 107, -1, 27, -1, 28, -1, 16,
1661 -1, 14, -1, 12, -1, 10, -1, 17, -1, 15,
1662 -1, 13, -1, 11, -1, 171, -1, 172, -1, 18,
1663 -1, 19, -1, 207, 147, -1, -1, 41, -1, 42,
1664 -1, 43, -1, 44, -1, 45, -1, 46, -1, 47,
1665 -1, -1, -1, 65, -1, 66, -1, 67, -1, 68,
1666 -1, 69, -1, 70, -1, 64, 4, -1, -1, 57,
1667 4, -1, -1, 148, 57, 4, -1, 34, 24, -1,
1668 -1, 180, -1, -1, 148, 183, 182, -1, 180, -1,
1669 57, 4, -1, 186, -1, 8, -1, 188, -1, 8,
1670 -1, 188, -1, 9, -1, 10, -1, 11, -1, 12,
1671 -1, 13, -1, 14, -1, 15, -1, 16, -1, 17,
1672 -1, 18, -1, 19, -1, 20, -1, 21, -1, 48,
1673 -1, 187, -1, 222, -1, 149, 4, -1, 185, 150,
1674 190, 151, -1, 152, 4, 153, 188, 154, -1, 155,
1675 4, 153, 188, 156, -1, 157, 189, 158, -1, 157,
1676 158, -1, 188, 159, -1, 188, -1, 189, 148, 188,
1677 -1, 189, -1, 189, 148, 37, -1, 37, -1, -1,
1678 186, 152, 193, 154, -1, 186, 152, 154, -1, 186,
1679 160, 24, -1, 186, 155, 193, 156, -1, 186, 157,
1680 193, 158, -1, 186, 157, 158, -1, 186, 38, -1,
1681 186, 39, -1, 186, 222, -1, 186, 192, -1, 186,
1682 26, -1, 171, 163, -1, 172, 4, -1, 9, 27,
1683 -1, 9, 28, -1, 174, 7, -1, 167, 150, 191,
1684 36, 186, 151, -1, 123, 150, 191, 236, 151, -1,
1685 137, 150, 191, 148, 191, 148, 191, 151, -1, 164,
1686 150, 191, 148, 191, 151, -1, 165, 150, 191, 148,
1687 191, 151, -1, 166, 150, 191, 148, 191, 151, -1,
1688 96, 150, 169, 148, 191, 148, 191, 151, -1, 97,
1689 150, 170, 148, 191, 148, 191, 151, -1, 168, 150,
1690 191, 148, 191, 151, -1, 142, 150, 191, 148, 191,
1691 151, -1, 143, 150, 191, 148, 191, 148, 191, 151,
1692 -1, 144, 150, 191, 148, 191, 148, 191, 151, -1,
1693 193, 148, 191, -1, 191, -1, 32, -1, 33, -1,
1694 196, -1, 196, 216, -1, 196, 218, -1, 196, 62,
1695 61, 202, -1, 196, 25, -1, 197, -1, 197, 175,
1696 20, 184, -1, 197, 218, -1, 197, 62, 61, 202,
1697 -1, -1, 197, 175, 176, 194, 191, 198, 182, -1,
1698 -1, 197, 175, 50, 194, 186, 199, 182, -1, -1,
1699 197, 175, 45, 194, 186, 200, 182, -1, -1, 197,
1700 175, 47, 194, 186, 201, 182, -1, 197, 51, 204,
1701 -1, 197, 58, 147, 205, -1, -1, 24, -1, 56,
1702 -1, 55, -1, 53, 147, 203, -1, 54, 147, 4,
1703 -1, 52, 147, 24, -1, 71, 147, 24, -1, 152,
1704 206, 154, -1, 206, 148, 24, -1, 24, -1, -1,
1705 22, -1, 24, -1, 207, -1, -1, 186, 208, -1,
1706 210, 148, 209, -1, 209, -1, 210, -1, 210, 148,
1707 37, -1, 37, -1, -1, 177, 184, 207, 150, 211,
1708 151, 181, 178, -1, 29, -1, 157, -1, 176, 212,
1709 213, -1, 30, -1, 158, -1, 225, 215, -1, -1,
1710 45, -1, 47, -1, -1, 31, 219, 217, 212, -1,
1711 -1, 63, -1, 3, -1, 4, -1, 7, -1, 27,
1712 -1, 28, -1, 38, -1, 39, -1, 26, -1, 155,
1713 193, 156, -1, 192, -1, 61, 220, 24, 148, 24,
1714 -1, 162, -1, 207, -1, 222, -1, 221, -1, 186,
1715 223, -1, 225, 226, -1, 214, 226, -1, 227, 175,
1716 228, -1, 227, 230, -1, -1, 23, -1, 72, 224,
1717 -1, 72, 8, -1, 73, 21, 223, -1, 73, 9,
1718 223, 148, 21, 223, 148, 21, 223, -1, 74, 173,
1719 223, 148, 21, 223, 152, 229, 154, -1, 74, 173,
1720 223, 148, 21, 223, 152, 154, -1, 75, 177, 184,
1721 223, 150, 233, 151, 36, 21, 223, 76, 21, 223,
1722 -1, 76, -1, 77, -1, 229, 173, 221, 148, 21,
1723 223, -1, 173, 221, 148, 21, 223, -1, 175, 235,
1724 -1, 186, 152, 223, 148, 223, 154, -1, 231, 148,
1725 152, 223, 148, 223, 154, -1, 224, -1, 232, 148,
1726 224, -1, 232, -1, -1, 60, 59, -1, 59, -1,
1727 164, 186, 223, 148, 223, -1, 165, 186, 223, 148,
1728 223, -1, 166, 186, 223, 148, 223, -1, 96, 169,
1729 186, 223, 148, 223, -1, 97, 170, 186, 223, 148,
1730 223, -1, 49, 224, -1, 168, 224, 148, 224, -1,
1731 167, 224, 36, 186, -1, 137, 224, 148, 224, 148,
1732 224, -1, 141, 224, 148, 186, -1, 145, 224, 148,
1733 186, -1, 146, 224, 148, 186, -1, 142, 224, 148,
1734 224, -1, 143, 224, 148, 224, 148, 224, -1, 144,
1735 224, 148, 224, 148, 224, -1, 136, 231, -1, 234,
1736 177, 184, 223, 150, 233, 151, -1, 238, -1, 148,
1737 232, -1, -1, 35, -1, -1, 118, 186, 179, -1,
1738 118, 186, 148, 15, 223, 179, -1, 119, 186, 179,
1739 -1, 119, 186, 148, 15, 223, 179, -1, 120, 224,
1740 -1, 237, 121, 186, 223, -1, 237, 122, 224, 148,
1741 186, 223, -1, 123, 186, 223, 236, -1
Reid Spencer3822ff52006-11-08 06:47:33 +00001742};
1743
1744/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1745static const unsigned short int yyrline[] =
1746{
Reid Spencer6e18b7d2006-12-03 06:59:29 +00001747 0, 1104, 1104, 1105, 1113, 1114, 1124, 1124, 1124, 1124,
1748 1124, 1124, 1124, 1124, 1124, 1125, 1125, 1125, 1126, 1126,
1749 1126, 1126, 1126, 1126, 1127, 1127, 1127, 1127, 1127, 1127,
1750 1128, 1128, 1128, 1128, 1128, 1128, 1129, 1129, 1129, 1131,
1751 1131, 1132, 1132, 1133, 1133, 1134, 1134, 1135, 1135, 1139,
1752 1139, 1140, 1140, 1141, 1141, 1142, 1142, 1143, 1143, 1144,
1753 1144, 1145, 1145, 1146, 1147, 1152, 1152, 1152, 1152, 1153,
1754 1153, 1153, 1153, 1154, 1154, 1155, 1155, 1158, 1162, 1167,
1755 1168, 1169, 1170, 1171, 1172, 1173, 1174, 1176, 1177, 1178,
1756 1179, 1180, 1181, 1182, 1183, 1192, 1193, 1199, 1200, 1208,
1757 1216, 1217, 1222, 1223, 1224, 1229, 1243, 1243, 1244, 1244,
1758 1246, 1256, 1256, 1256, 1256, 1256, 1256, 1256, 1257, 1257,
1759 1257, 1257, 1257, 1257, 1258, 1262, 1266, 1274, 1282, 1295,
1760 1300, 1312, 1322, 1326, 1337, 1342, 1348, 1349, 1353, 1357,
1761 1368, 1394, 1408, 1438, 1464, 1485, 1498, 1508, 1513, 1574,
1762 1581, 1589, 1595, 1601, 1605, 1609, 1617, 1629, 1661, 1669,
1763 1693, 1704, 1710, 1715, 1720, 1729, 1735, 1741, 1750, 1754,
1764 1762, 1762, 1772, 1780, 1785, 1789, 1793, 1797, 1812, 1834,
1765 1837, 1840, 1840, 1848, 1848, 1856, 1856, 1864, 1864, 1873,
1766 1876, 1879, 1883, 1896, 1897, 1899, 1903, 1912, 1916, 1921,
1767 1923, 1928, 1933, 1942, 1942, 1943, 1943, 1945, 1952, 1958,
1768 1965, 1969, 1975, 1980, 1985, 2080, 2080, 2082, 2090, 2090,
1769 2092, 2097, 2098, 2099, 2101, 2101, 2111, 2115, 2120, 2124,
1770 2128, 2132, 2136, 2140, 2144, 2148, 2152, 2177, 2181, 2195,
1771 2199, 2205, 2205, 2211, 2216, 2220, 2229, 2240, 2249, 2261,
1772 2274, 2278, 2282, 2287, 2296, 2315, 2324, 2380, 2384, 2391,
1773 2402, 2415, 2424, 2433, 2443, 2447, 2454, 2454, 2456, 2460,
1774 2465, 2484, 2499, 2513, 2524, 2535, 2548, 2557, 2568, 2576,
1775 2582, 2602, 2625, 2631, 2637, 2643, 2658, 2717, 2724, 2727,
1776 2732, 2736, 2743, 2748, 2754, 2759, 2765, 2773, 2785, 2800
Reid Spencer3822ff52006-11-08 06:47:33 +00001777};
1778#endif
1779
1780#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1781/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1782 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1783static const char *const yytname[] =
1784{
1785 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL",
1786 "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT",
1787 "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL",
1788 "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION",
1789 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
1790 "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO",
1791 "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE",
1792 "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
1793 "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE",
1794 "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE",
1795 "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK",
1796 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
1797 "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE", "ADD", "SUB",
1798 "MUL", "UDIV", "SDIV", "FDIV", "UREM", "SREM", "FREM", "AND", "OR",
Reid Spencera132e042006-12-03 05:46:11 +00001799 "XOR", "SETLE", "SETGE", "SETLT", "SETGT", "SETEQ", "SETNE", "ICMP",
1800 "FCMP", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT", "UGT", "ULE",
Reid Spencer6e18b7d2006-12-03 06:59:29 +00001801 "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD", "UNO", "UEQ",
1802 "UNE", "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR",
1803 "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT", "BITCAST", "UITOFP",
1804 "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR", "PTRTOINT", "PHI_TOK",
1805 "SELECT", "SHL", "LSHR", "ASHR", "VAARG", "EXTRACTELEMENT",
1806 "INSERTELEMENT", "SHUFFLEVECTOR", "VAARG_old", "VANEXT_old", "'='",
1807 "','", "'\\\\'", "'('", "')'", "'['", "'x'", "']'", "'<'", "'>'", "'{'",
1808 "'}'", "'*'", "'c'", "$accept", "INTVAL", "EINT64VAL", "ArithmeticOps",
1809 "LogicalOps", "SetCondOps", "CastOps", "ShiftOps", "IPredicates",
1810 "FPredicates", "SIntType", "UIntType", "IntType", "FPType", "OptAssign",
1811 "OptLinkage", "OptCallingConv", "OptAlign", "OptCAlign", "SectionString",
1812 "OptSection", "GlobalVarAttributes", "GlobalVarAttribute", "TypesV",
1813 "UpRTypesV", "Types", "PrimType", "UpRTypes", "TypeListI",
1814 "ArgTypeListI", "ConstVal", "ConstExpr", "ConstVector", "GlobalType",
1815 "Module", "FunctionList", "ConstPool", "@1", "@2", "@3", "@4",
1816 "AsmBlock", "BigOrLittle", "TargetDefinition", "LibrariesDefinition",
1817 "LibList", "Name", "OptName", "ArgVal", "ArgListH", "ArgList",
1818 "FunctionHeaderH", "BEGIN", "FunctionHeader", "END", "Function",
1819 "FnDeclareLinkage", "FunctionProto", "@5", "OptSideEffect",
1820 "ConstValueRef", "SymbolicValueRef", "ValueRef", "ResolvedVal",
1821 "BasicBlockList", "BasicBlock", "InstructionList", "BBTerminatorInst",
1822 "JumpTable", "Inst", "PHIList", "ValueRefList", "ValueRefListE",
1823 "OptTailCall", "InstVal", "IndexList", "OptVolatile", "MemoryInst", 0
Reid Spencer3822ff52006-11-08 06:47:33 +00001824};
1825#endif
1826
1827# ifdef YYPRINT
1828/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1829 token YYLEX-NUM. */
1830static const unsigned short int yytoknum[] =
1831{
1832 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1833 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1834 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1835 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1836 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1837 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1838 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1839 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1840 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1841 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1842 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
Reid Spencer3da59db2006-11-27 01:05:10 +00001843 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
Reid Spencera132e042006-12-03 05:46:11 +00001844 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
1845 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
Reid Spencer6e18b7d2006-12-03 06:59:29 +00001846 395, 396, 397, 398, 399, 400, 401, 61, 44, 92,
1847 40, 41, 91, 120, 93, 60, 62, 123, 125, 42,
1848 99
Reid Spencer3822ff52006-11-08 06:47:33 +00001849};
1850# endif
1851
1852/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1853static const unsigned char yyr1[] =
1854{
Reid Spencer6e18b7d2006-12-03 06:59:29 +00001855 0, 161, 162, 162, 163, 163, 164, 164, 164, 164,
1856 164, 164, 164, 164, 164, 165, 165, 165, 166, 166,
1857 166, 166, 166, 166, 167, 167, 167, 167, 167, 167,
1858 167, 167, 167, 167, 167, 167, 168, 168, 168, 169,
1859 169, 169, 169, 169, 169, 169, 169, 169, 169, 170,
1860 170, 170, 170, 170, 170, 170, 170, 170, 170, 170,
1861 170, 170, 170, 170, 170, 171, 171, 171, 171, 172,
1862 172, 172, 172, 173, 173, 174, 174, 175, 175, 176,
1863 176, 176, 176, 176, 176, 176, 176, 177, 177, 177,
1864 177, 177, 177, 177, 177, 178, 178, 179, 179, 180,
1865 181, 181, 182, 182, 183, 183, 184, 184, 185, 185,
1866 186, 187, 187, 187, 187, 187, 187, 187, 187, 187,
1867 187, 187, 187, 187, 188, 188, 188, 188, 188, 188,
1868 188, 188, 188, 188, 189, 189, 190, 190, 190, 190,
Reid Spencera132e042006-12-03 05:46:11 +00001869 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
Reid Spencer6e18b7d2006-12-03 06:59:29 +00001870 191, 191, 191, 191, 191, 191, 192, 192, 192, 192,
1871 192, 192, 192, 192, 192, 192, 192, 192, 193, 193,
1872 194, 194, 195, 196, 196, 196, 196, 196, 197, 197,
1873 197, 198, 197, 199, 197, 200, 197, 201, 197, 197,
1874 197, 197, 202, 203, 203, 204, 204, 204, 204, 205,
1875 206, 206, 206, 207, 207, 208, 208, 209, 210, 210,
1876 211, 211, 211, 211, 212, 213, 213, 214, 215, 215,
1877 216, 217, 217, 217, 219, 218, 220, 220, 221, 221,
1878 221, 221, 221, 221, 221, 221, 221, 221, 221, 222,
1879 222, 223, 223, 224, 225, 225, 226, 227, 227, 227,
1880 228, 228, 228, 228, 228, 228, 228, 228, 228, 229,
1881 229, 230, 231, 231, 232, 232, 233, 233, 234, 234,
1882 235, 235, 235, 235, 235, 235, 235, 235, 235, 235,
1883 235, 235, 235, 235, 235, 235, 235, 235, 236, 236,
1884 237, 237, 238, 238, 238, 238, 238, 238, 238, 238
Reid Spencer3822ff52006-11-08 06:47:33 +00001885};
1886
1887/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
1888static const unsigned char yyr2[] =
1889{
1890 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1891 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1892 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Reid Spencer3822ff52006-11-08 06:47:33 +00001893 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Reid Spencer3da59db2006-11-27 01:05:10 +00001894 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Reid Spencer3da59db2006-11-27 01:05:10 +00001895 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1896 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Reid Spencer6e18b7d2006-12-03 06:59:29 +00001897 1, 1, 1, 1, 1, 1, 1, 2, 0, 1,
1898 1, 1, 1, 1, 1, 1, 0, 0, 1, 1,
1899 1, 1, 1, 1, 2, 0, 2, 0, 3, 2,
1900 0, 1, 0, 3, 1, 2, 1, 1, 1, 1,
Reid Spencera132e042006-12-03 05:46:11 +00001901 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Reid Spencer6e18b7d2006-12-03 06:59:29 +00001902 1, 1, 1, 1, 1, 1, 1, 2, 4, 5,
1903 5, 3, 2, 2, 1, 3, 1, 3, 1, 0,
1904 4, 3, 3, 4, 4, 3, 2, 2, 2, 2,
1905 2, 2, 2, 2, 2, 2, 6, 5, 8, 6,
1906 6, 6, 8, 8, 6, 6, 8, 8, 3, 1,
1907 1, 1, 1, 2, 2, 4, 2, 1, 4, 2,
1908 4, 0, 7, 0, 7, 0, 7, 0, 7, 3,
1909 4, 0, 1, 1, 1, 3, 3, 3, 3, 3,
1910 3, 1, 0, 1, 1, 1, 0, 2, 3, 1,
1911 1, 3, 1, 0, 8, 1, 1, 3, 1, 1,
1912 2, 0, 1, 1, 0, 4, 0, 1, 1, 1,
1913 1, 1, 1, 1, 1, 1, 3, 1, 5, 1,
1914 1, 1, 1, 2, 2, 2, 3, 2, 0, 1,
1915 2, 2, 3, 9, 9, 8, 13, 1, 1, 6,
1916 5, 2, 6, 7, 1, 3, 1, 0, 2, 1,
1917 5, 5, 5, 6, 6, 2, 4, 4, 6, 4,
1918 4, 4, 4, 6, 6, 2, 7, 1, 2, 0,
1919 1, 0, 3, 6, 3, 6, 2, 4, 6, 4
Reid Spencer3822ff52006-11-08 06:47:33 +00001920};
1921
1922/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
1923 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
1924 means the default is an error. */
1925static const unsigned short int yydefact[] =
1926{
Reid Spencer6e18b7d2006-12-03 06:59:29 +00001927 191, 0, 86, 177, 1, 176, 224, 79, 80, 81,
1928 82, 83, 84, 85, 0, 87, 248, 173, 174, 248,
1929 203, 204, 0, 0, 0, 86, 0, 179, 221, 0,
1930 0, 88, 89, 90, 91, 92, 93, 0, 0, 249,
1931 245, 78, 218, 219, 220, 244, 0, 0, 0, 0,
1932 189, 0, 0, 0, 0, 0, 0, 0, 77, 222,
1933 223, 87, 192, 175, 94, 2, 3, 107, 111, 112,
1934 113, 114, 115, 116, 117, 118, 119, 120, 121, 122,
1935 123, 124, 0, 0, 0, 0, 239, 0, 0, 106,
1936 125, 110, 240, 126, 215, 216, 217, 291, 247, 0,
1937 0, 0, 0, 202, 190, 180, 178, 170, 171, 0,
1938 0, 0, 0, 225, 127, 0, 0, 109, 132, 134,
1939 0, 0, 139, 133, 290, 0, 269, 0, 0, 0,
1940 0, 87, 257, 258, 6, 7, 8, 9, 10, 11,
Reid Spencer3822ff52006-11-08 06:47:33 +00001941 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
Reid Spencera132e042006-12-03 05:46:11 +00001942 22, 23, 0, 0, 0, 0, 0, 0, 24, 25,
1943 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
1944 0, 0, 36, 37, 38, 0, 0, 0, 0, 0,
Reid Spencer6e18b7d2006-12-03 06:59:29 +00001945 0, 0, 0, 0, 0, 0, 246, 87, 261, 0,
1946 287, 197, 194, 193, 195, 196, 198, 201, 0, 185,
1947 187, 183, 111, 112, 113, 114, 115, 116, 117, 118,
1948 119, 120, 121, 0, 0, 0, 0, 181, 0, 0,
1949 0, 131, 213, 138, 136, 0, 0, 275, 268, 251,
1950 250, 0, 0, 68, 72, 67, 71, 66, 70, 65,
1951 69, 73, 74, 0, 0, 39, 40, 41, 42, 43,
1952 44, 45, 46, 47, 48, 0, 63, 64, 59, 60,
1953 61, 62, 49, 50, 51, 52, 53, 54, 55, 56,
1954 57, 58, 0, 97, 97, 296, 0, 0, 285, 0,
Reid Spencer3822ff52006-11-08 06:47:33 +00001955 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer6e18b7d2006-12-03 06:59:29 +00001956 0, 0, 0, 0, 0, 199, 102, 102, 102, 153,
1957 154, 4, 5, 151, 152, 155, 150, 146, 147, 0,
Reid Spencer3822ff52006-11-08 06:47:33 +00001958 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer6e18b7d2006-12-03 06:59:29 +00001959 0, 0, 0, 0, 0, 149, 148, 102, 108, 108,
1960 135, 212, 206, 209, 210, 0, 0, 128, 228, 229,
1961 230, 235, 231, 232, 233, 234, 226, 0, 237, 242,
1962 241, 243, 0, 252, 0, 0, 0, 0, 0, 292,
1963 0, 294, 289, 0, 0, 0, 0, 0, 0, 0,
1964 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1965 200, 0, 186, 188, 184, 0, 0, 0, 0, 0,
1966 0, 0, 141, 169, 0, 0, 145, 0, 142, 0,
1967 0, 0, 0, 0, 182, 129, 130, 205, 207, 0,
1968 100, 137, 227, 0, 0, 0, 0, 0, 0, 0,
1969 0, 0, 0, 0, 299, 0, 0, 0, 279, 282,
1970 0, 0, 280, 281, 0, 0, 0, 277, 276, 0,
1971 297, 0, 0, 0, 104, 102, 0, 0, 289, 0,
1972 0, 0, 0, 0, 140, 143, 144, 0, 0, 0,
1973 0, 0, 211, 208, 101, 95, 0, 236, 0, 0,
1974 267, 0, 0, 97, 98, 97, 264, 288, 0, 0,
1975 0, 0, 0, 270, 271, 272, 267, 0, 99, 105,
1976 103, 0, 0, 0, 0, 0, 0, 0, 168, 0,
1977 0, 0, 0, 0, 0, 214, 0, 0, 0, 266,
1978 0, 273, 274, 0, 293, 295, 0, 0, 0, 278,
1979 283, 284, 0, 298, 0, 0, 157, 0, 0, 0,
1980 0, 0, 0, 0, 0, 0, 96, 238, 0, 0,
1981 0, 265, 262, 0, 286, 0, 0, 0, 165, 0,
1982 0, 159, 160, 161, 156, 164, 0, 255, 0, 0,
1983 0, 263, 0, 0, 0, 0, 0, 253, 0, 254,
1984 0, 0, 162, 163, 158, 166, 167, 0, 0, 0,
1985 0, 0, 0, 260, 0, 0, 259, 256
Reid Spencer3822ff52006-11-08 06:47:33 +00001986};
1987
1988/* YYDEFGOTO[NTERM-NUM]. */
1989static const short int yydefgoto[] =
1990{
Reid Spencer6e18b7d2006-12-03 06:59:29 +00001991 -1, 86, 303, 320, 321, 322, 323, 324, 255, 272,
1992 213, 214, 243, 215, 25, 15, 37, 505, 359, 444,
1993 465, 382, 445, 87, 88, 216, 90, 91, 120, 225,
1994 393, 348, 394, 109, 1, 2, 3, 327, 298, 296,
1995 297, 63, 194, 50, 104, 198, 92, 408, 333, 334,
1996 335, 38, 96, 16, 44, 17, 61, 18, 28, 413,
1997 349, 93, 351, 476, 19, 40, 41, 186, 559, 98,
1998 278, 509, 510, 187, 188, 424, 189, 190
Reid Spencer3822ff52006-11-08 06:47:33 +00001999};
2000
2001/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2002 STATE-NUM. */
Reid Spencer6e18b7d2006-12-03 06:59:29 +00002003#define YYPACT_NINF -542
Reid Spencer3822ff52006-11-08 06:47:33 +00002004static const short int yypact[] =
2005{
Reid Spencer6e18b7d2006-12-03 06:59:29 +00002006 -542, 24, 136, 567, -542, -542, -542, -542, -542, -542,
2007 -542, -542, -542, -542, -5, 144, 56, -542, -542, -9,
2008 -542, -542, 61, -53, 51, 426, -16, -542, 42, 139,
2009 167, -542, -542, -542, -542, -542, -542, 1195, -20, -542,
2010 -542, 162, -542, -542, -542, -542, 19, 28, 50, 57,
2011 -542, 54, 139, 1195, 124, 124, 124, 124, -542, -542,
2012 -542, 144, -542, -542, -542, -542, -542, 66, -542, -542,
2013 -542, -542, -542, -542, -542, -542, -542, -542, -542, -542,
2014 -542, -542, 220, 221, 222, 87, -542, 162, 77, -542,
2015 -542, -81, -542, -542, -542, -542, -542, 425, -542, 204,
2016 132, 228, 209, 223, -542, -542, -542, -542, -542, 1215,
2017 1215, 1215, 1256, -542, -542, 81, 90, -542, -542, -81,
2018 -133, 96, 1000, -542, -542, 1215, -542, 181, 1276, -2,
2019 377, 144, -542, -542, -542, -542, -542, -542, -542, -542,
2020 -542, -542, -542, -542, -542, -542, -542, -542, -542, -542,
2021 -542, -542, 23, 210, 1215, 1215, 1215, 1215, -542, -542,
2022 -542, -542, -542, -542, -542, -542, -542, -542, -542, -542,
2023 1215, 1215, -542, -542, -542, 1215, 1215, 1215, 1215, 1215,
2024 1215, 1215, 1215, 1215, 1215, 1215, -542, 144, -542, 69,
2025 -542, -542, -542, -542, -542, -542, -542, -542, -68, -542,
2026 -542, -542, 165, 192, 245, 196, 249, 198, 253, 216,
2027 254, 255, 258, 219, 256, 261, 568, -542, 1215, 1215,
2028 1215, -542, 1041, -542, 121, 110, 710, -542, -542, 66,
2029 -542, 710, 710, -542, -542, -542, -542, -542, -542, -542,
2030 -542, -542, -542, 710, 1195, -542, -542, -542, -542, -542,
2031 -542, -542, -542, -542, -542, 1215, -542, -542, -542, -542,
2032 -542, -542, -542, -542, -542, -542, -542, -542, -542, -542,
2033 -542, -542, 1215, 122, 126, -542, 710, 120, 127, 129,
2034 130, 131, 133, 135, 137, 140, 710, 710, 710, 244,
2035 141, 1195, 1215, 1215, 260, -542, 142, 142, 142, -542,
2036 -542, -542, -542, -542, -542, -542, -542, -542, -542, 148,
2037 149, 150, 151, 152, 154, 160, 945, 1256, 661, 263,
2038 161, 187, 190, 191, 193, -542, -542, 142, 5, 6,
2039 -81, -542, 162, -542, 164, 194, 1098, -542, -542, -542,
2040 -542, -542, -542, -542, -542, -542, 279, 1256, -542, -542,
2041 -542, -542, 201, -542, 202, 710, 710, 710, 7, -542,
2042 8, -542, 205, 710, 200, 1215, 1215, 1215, 1215, 1215,
2043 1215, 1215, 206, 207, 208, 1215, 1215, 710, 710, 212,
2044 -542, -29, -542, -542, -542, 23, 210, 1256, 1256, 1256,
2045 1256, 1256, -542, -542, -38, -72, -542, -105, -542, 1256,
2046 1256, 1256, 1256, 1256, -542, -542, -542, -542, -542, 1154,
2047 310, -542, -542, 333, -71, 337, 340, 217, 214, 225,
2048 710, 364, 710, 1215, -542, 226, 710, 229, -542, -542,
2049 230, 233, -542, -542, 710, 710, 710, -542, -542, 232,
2050 -542, 1215, 345, 366, -542, 142, 235, 236, 205, 237,
2051 247, 248, 264, 1256, -542, -542, -542, 265, 266, 270,
2052 335, 271, -542, -542, -542, 319, 272, -542, 710, 710,
2053 1215, 710, 710, 273, -542, 273, -542, 274, 710, 276,
2054 1215, 1215, 1215, -542, -542, -542, 1215, 710, -542, -542,
2055 -542, 1256, 1256, 257, 1256, 1256, 1256, 1256, -542, 1256,
2056 1256, 1256, 1215, 1256, 421, -542, 402, 280, 275, 274,
2057 278, -542, -542, 375, -542, -542, 1215, 281, 710, -542,
2058 -542, -542, 283, -542, 288, 291, -542, 292, 290, 294,
2059 299, 297, 303, 306, 307, 308, -542, -542, 429, 20,
2060 427, -542, -542, 312, -542, 1256, 1256, 1256, -542, 1256,
2061 1256, -542, -542, -542, -542, -542, 710, -542, 852, 35,
2062 440, -542, 311, 313, 324, 326, 327, -542, 339, -542,
2063 852, 710, -542, -542, -542, -542, -542, 460, 341, 407,
2064 710, 467, 469, -542, 710, 710, -542, -542
Reid Spencer3822ff52006-11-08 06:47:33 +00002065};
2066
2067/* YYPGOTO[NTERM-NUM]. */
2068static const short int yypgoto[] =
2069{
Reid Spencer6e18b7d2006-12-03 06:59:29 +00002070 -542, -542, -542, 394, 395, 396, 428, 430, 138, 147,
2071 -129, -128, -484, -542, 483, 501, -121, -542, -270, 125,
2072 -542, -285, -542, -50, -542, -37, -542, -65, 408, -542,
2073 -94, 318, -277, 113, -542, -542, -542, -542, -542, -542,
2074 -542, 484, -542, -542, -542, -542, 3, -542, 128, -542,
2075 -542, 478, -542, -542, -542, -542, -542, 537, -542, -542,
2076 -541, 60, -205, -117, -542, 522, -542, -542, -542, -542,
2077 -542, 119, 86, -542, -542, 98, -542, -542
Reid Spencer3822ff52006-11-08 06:47:33 +00002078};
2079
2080/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2081 positive, shift that token. If negative, reduce the rule which
2082 number is the opposite. If zero, do what YYDEFACT says.
2083 If YYTABLE_NINF, syntax error. */
Reid Spencer6e18b7d2006-12-03 06:59:29 +00002084#define YYTABLE_NINF -173
Reid Spencer3822ff52006-11-08 06:47:33 +00002085static const short int yytable[] =
2086{
Reid Spencer6e18b7d2006-12-03 06:59:29 +00002087 89, 241, 242, 106, 361, 442, 26, 231, 227, 94,
2088 244, 230, 383, 384, 39, 220, 89, 568, 217, 232,
2089 119, 42, 420, 422, 4, 221, 352, 353, 443, 578,
2090 233, 234, 235, 236, 237, 238, 239, 240, 354, 275,
2091 395, 397, 404, 453, 26, 233, 234, 235, 236, 237,
2092 238, 239, 240, 456, 279, 558, 29, 119, 280, 281,
2093 282, 283, 284, 285, 421, 421, 291, 289, 290, -108,
2094 414, 362, 199, 200, 201, 570, 453, 453, 123, 39,
2095 294, 372, 373, 374, 455, 467, 295, 59, 226, 60,
2096 121, 226, 65, 66, 51, 117, 68, 69, 70, 71,
2097 72, 73, 74, 75, 76, 77, 78, 79, 80, 20,
2098 453, 21, 52, 46, 47, 48, 454, 273, 274, 226,
2099 276, 245, 246, 247, 248, 249, 250, 251, 252, 253,
2100 254, 58, 49, 277, 226, 81, -172, 95, 226, 226,
2101 226, 226, 226, 226, 286, 287, 288, 226, 226, 43,
2102 417, 418, 419, 328, 329, 330, 107, 108, 425, 405,
2103 490, 5, 406, 62, 123, 123, 99, 6, 110, 111,
2104 112, 64, 439, 440, 557, 100, 379, 7, 8, 9,
2105 10, 11, 12, 13, 20, 332, 21, 192, 193, 569,
2106 292, 293, 299, 300, 355, -68, -68, 101, 14, -67,
2107 -67, -66, -66, 514, 102, 515, 103, 89, 30, 31,
2108 32, 33, 34, 35, 36, 473, -109, 475, 356, -65,
2109 -65, 479, 301, 302, 114, 115, 116, 122, 191, 483,
2110 484, 485, 195, 196, 218, 357, 82, 256, 257, 83,
2111 228, 377, 84, 219, 85, 118, 222, 197, 427, -72,
2112 429, 430, 431, -71, 89, 378, 226, -70, -69, 438,
2113 304, 337, -75, 507, 508, -76, 511, 512, 305, 336,
2114 358, 330, 363, 517, 360, 364, 326, 365, 366, 367,
2115 375, 368, 523, 369, 380, 370, 350, 398, 371, 376,
2116 381, 350, 350, 448, 449, 450, 451, 452, 385, 386,
2117 387, 388, 389, 350, 390, 457, 458, 459, 460, 461,
2118 391, 399, 409, 543, 258, 259, 260, 261, 262, 263,
2119 264, 265, 266, 267, 268, 269, 270, 271, 226, 428,
2120 226, 226, 226, 432, 433, 407, 350, 400, 437, 226,
2121 401, 402, 412, 403, 442, 410, 350, 350, 350, 415,
2122 416, 567, 426, 423, 434, 435, 436, 466, 468, 498,
2123 441, 469, 471, 519, 520, 521, 579, 470, 474, 488,
2124 489, 502, 332, 472, 478, 583, 504, 480, 481, 586,
2125 587, 482, 486, 491, 492, 494, 226, 233, 234, 235,
2126 236, 237, 238, 239, 240, 495, 496, 524, 525, 541,
2127 527, 528, 529, 530, 487, 531, 532, 533, 526, 535,
2128 241, 242, 497, 499, 500, 350, 350, 350, 501, 503,
2129 506, 513, 516, 350, 518, 536, 537, 539, 538, 540,
2130 241, 242, 421, 226, 544, 542, 545, 350, 350, 546,
2131 547, 548, 549, 226, 226, 226, 53, 550, 551, 226,
2132 556, 562, 563, 564, 552, 565, 566, 553, 554, 555,
2133 124, 571, 572, 560, 573, 534, 561, 7, 8, 9,
2134 10, 54, 12, 55, 125, 574, 56, 575, 576, 226,
2135 350, 580, 350, 582, 126, 127, 350, 577, 584, 581,
2136 585, 181, 182, 183, 350, 350, 350, 128, 129, 130,
2137 131, 132, 133, 134, 135, 136, 137, 138, 139, 140,
2138 141, 142, 143, 144, 145, 146, 147, 148, 149, 150,
2139 151, 152, 153, 446, 97, 184, 57, 185, 350, 350,
2140 224, 350, 350, 447, 325, 464, 105, 463, 350, 113,
2141 27, 45, 477, 154, 155, 156, 493, 350, 157, 158,
2142 159, 160, 161, 162, 163, 164, 165, 166, 167, 168,
2143 169, 170, 171, 172, 173, 174, 175, 176, 177, 178,
2144 179, 180, 522, 65, 66, 0, 0, 0, 350, 0,
2145 0, 0, 0, 0, 0, 0, 0, -78, 0, 20,
2146 20, 21, 21, 0, 306, 0, 0, 0, 6, -78,
2147 -78, 0, 0, 0, 0, 0, 307, 308, -78, -78,
2148 -78, -78, -78, -78, -78, 0, 350, -78, 22, 0,
2149 0, 0, 0, 0, 0, 23, 0, 0, 0, 24,
2150 0, 350, 0, 0, 0, 0, 0, 0, 0, 0,
2151 350, 0, 0, 0, 350, 350, 134, 135, 136, 137,
2152 138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
2153 148, 149, 150, 151, 309, 310, 65, 66, 0, 117,
2154 202, 203, 204, 205, 206, 207, 208, 209, 210, 211,
2155 212, 79, 80, 20, 0, 21, 0, 0, 0, 0,
2156 0, 311, 158, 159, 160, 161, 162, 163, 164, 165,
2157 166, 167, 168, 169, 0, 312, 172, 173, 174, 81,
2158 313, 314, 315, 338, 339, 65, 66, 340, 0, 0,
2159 316, 0, 0, 317, 0, 318, 0, 0, 319, 0,
2160 0, 0, 20, 0, 21, 0, 341, 342, 343, 0,
2161 0, 0, 0, 0, 0, 0, 0, 0, 344, 345,
Reid Spencer3da59db2006-11-27 01:05:10 +00002162 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer3da59db2006-11-27 01:05:10 +00002163 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer6e18b7d2006-12-03 06:59:29 +00002164 0, 346, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencera132e042006-12-03 05:46:11 +00002165 0, 0, 0, 0, 0, 0, 0, 0, 134, 135,
2166 136, 137, 138, 139, 140, 141, 142, 143, 144, 145,
Reid Spencer6e18b7d2006-12-03 06:59:29 +00002167 146, 147, 148, 149, 150, 151, 309, 310, 0, 0,
2168 82, 0, 0, 83, 0, 0, 84, 0, 85, 396,
Reid Spencer3da59db2006-11-27 01:05:10 +00002169 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer6e18b7d2006-12-03 06:59:29 +00002170 0, 0, 0, 311, 158, 159, 160, 161, 162, 163,
2171 164, 165, 166, 167, 168, 169, 0, 312, 172, 173,
2172 174, 0, 313, 314, 315, 338, 339, 0, 0, 340,
2173 0, 0, 0, 0, 0, 347, 0, 0, 0, 0,
2174 0, 0, 0, 0, 0, 0, 0, 0, 341, 342,
2175 343, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2176 344, 345, 0, 0, 0, 0, 0, 0, 0, 0,
2177 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2178 0, 0, 0, 346, 0, 0, 0, 0, 0, 0,
2179 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2180 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
2181 144, 145, 146, 147, 148, 149, 150, 151, 309, 310,
2182 65, 66, 0, 117, 202, 203, 204, 205, 206, 207,
2183 208, 209, 210, 211, 212, 79, 80, 20, 0, 21,
2184 0, 0, 0, 0, 0, 311, 158, 159, 160, 161,
2185 162, 163, 164, 165, 166, 167, 168, 169, 0, 312,
2186 172, 173, 174, 81, 313, 314, 315, 0, 0, 0,
2187 0, 0, 0, 0, 0, 65, 66, 347, 117, 68,
2188 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
2189 79, 80, 20, 0, 21, 0, 0, 0, 0, 0,
2190 0, 0, 0, 0, 0, 0, 0, 223, 0, 0,
2191 0, 0, 0, 0, 0, 0, 65, 66, 81, 117,
2192 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2193 78, 79, 80, 20, 0, 21, 0, 0, 0, 0,
2194 0, 0, 0, 0, 0, 0, 0, 0, 331, 0,
2195 0, 0, 0, 0, 0, 0, 0, 0, 0, 81,
2196 0, 0, 0, 0, 82, 0, 0, 83, 0, 392,
2197 84, 0, 85, 65, 66, 0, 117, 68, 69, 70,
2198 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
2199 20, 0, 21, 0, 0, 0, 0, 0, 0, 0,
2200 0, 0, 0, 0, 0, 411, 0, 0, 0, 0,
2201 0, 0, 0, 0, 0, 0, 81, 0, 0, 82,
2202 0, 0, 83, 0, 0, 84, 0, 85, 0, 65,
Reid Spencera132e042006-12-03 05:46:11 +00002203 66, 0, 117, 68, 69, 70, 71, 72, 73, 74,
Reid Spencer3822ff52006-11-08 06:47:33 +00002204 75, 76, 77, 78, 79, 80, 20, 0, 21, 0,
2205 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer6e18b7d2006-12-03 06:59:29 +00002206 82, 462, 0, 83, 0, 0, 84, 0, 85, 0,
2207 65, 66, 81, 67, 68, 69, 70, 71, 72, 73,
2208 74, 75, 76, 77, 78, 79, 80, 20, 0, 21,
2209 65, 66, 0, 117, 68, 69, 70, 71, 72, 73,
2210 74, 75, 76, 77, 78, 79, 80, 20, 0, 21,
2211 0, 0, 0, 81, 0, 0, 0, 82, 0, 0,
2212 83, 0, 0, 84, 0, 85, 0, 0, 0, 0,
2213 0, 65, 66, 81, 117, 202, 203, 204, 205, 206,
2214 207, 208, 209, 210, 211, 212, 79, 80, 20, 0,
2215 21, 65, 66, 0, 229, 68, 69, 70, 71, 72,
2216 73, 74, 75, 76, 77, 78, 79, 80, 20, 0,
2217 21, 0, 0, 82, 81, 0, 83, 0, 0, 84,
Reid Spencera132e042006-12-03 05:46:11 +00002218 0, 85, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer6e18b7d2006-12-03 06:59:29 +00002219 0, 0, 0, 0, 81, 0, 0, 0, 0, 0,
Reid Spencer3da59db2006-11-27 01:05:10 +00002220 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2221 0, 0, 0, 0, 82, 0, 0, 83, 0, 0,
2222 84, 0, 85, 0, 0, 0, 0, 0, 0, 0,
Reid Spencera132e042006-12-03 05:46:11 +00002223 0, 0, 0, 0, 82, 0, 0, 83, 0, 0,
2224 84, 0, 85, 0, 0, 0, 0, 0, 0, 0,
2225 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer6e18b7d2006-12-03 06:59:29 +00002226 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencera132e042006-12-03 05:46:11 +00002227 0, 0, 0, 0, 0, 82, 0, 0, 83, 0,
Reid Spencer6e18b7d2006-12-03 06:59:29 +00002228 0, 84, 0, 85, 0, 0, 0, 0, 0, 0,
2229 0, 0, 0, 0, 0, 82, 0, 0, 83, 0,
2230 0, 84, 0, 85
Reid Spencer3822ff52006-11-08 06:47:33 +00002231};
2232
2233static const short int yycheck[] =
2234{
Reid Spencer6e18b7d2006-12-03 06:59:29 +00002235 37, 130, 130, 53, 274, 34, 3, 9, 125, 29,
2236 131, 128, 297, 298, 23, 148, 53, 558, 112, 21,
2237 85, 30, 15, 15, 0, 158, 231, 232, 57, 570,
2238 10, 11, 12, 13, 14, 15, 16, 17, 243, 156,
2239 317, 318, 327, 148, 41, 10, 11, 12, 13, 14,
2240 15, 16, 17, 158, 171, 539, 61, 122, 175, 176,
2241 177, 178, 179, 180, 57, 57, 187, 184, 185, 150,
2242 347, 276, 109, 110, 111, 559, 148, 148, 159, 23,
2243 148, 286, 287, 288, 156, 156, 154, 45, 125, 47,
2244 87, 128, 5, 6, 147, 8, 9, 10, 11, 12,
2245 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
2246 148, 24, 61, 52, 53, 54, 154, 154, 155, 156,
2247 157, 98, 99, 100, 101, 102, 103, 104, 105, 106,
2248 107, 147, 71, 170, 171, 48, 0, 157, 175, 176,
2249 177, 178, 179, 180, 181, 182, 183, 184, 185, 158,
2250 355, 356, 357, 218, 219, 220, 32, 33, 363, 154,
2251 445, 25, 156, 24, 159, 159, 147, 31, 55, 56,
2252 57, 4, 377, 378, 154, 147, 293, 41, 42, 43,
2253 44, 45, 46, 47, 22, 222, 24, 55, 56, 154,
2254 121, 122, 27, 28, 244, 3, 4, 147, 62, 3,
2255 4, 3, 4, 473, 147, 475, 152, 244, 64, 65,
2256 66, 67, 68, 69, 70, 420, 150, 422, 255, 3,
2257 4, 426, 3, 4, 4, 4, 4, 150, 24, 434,
2258 435, 436, 4, 24, 153, 272, 149, 27, 28, 152,
2259 59, 291, 155, 153, 157, 158, 150, 24, 365, 4,
2260 367, 368, 369, 4, 291, 292, 293, 4, 4, 376,
2261 4, 151, 7, 468, 469, 7, 471, 472, 7, 148,
2262 148, 336, 152, 478, 148, 148, 216, 148, 148, 148,
2263 36, 148, 487, 148, 24, 148, 226, 24, 148, 148,
2264 148, 231, 232, 387, 388, 389, 390, 391, 150, 150,
2265 150, 150, 150, 243, 150, 399, 400, 401, 402, 403,
2266 150, 150, 148, 518, 104, 105, 106, 107, 108, 109,
2267 110, 111, 112, 113, 114, 115, 116, 117, 365, 366,
2268 367, 368, 369, 370, 371, 332, 276, 150, 375, 376,
2269 150, 150, 63, 150, 34, 151, 286, 287, 288, 148,
2270 148, 556, 152, 148, 148, 148, 148, 24, 21, 453,
2271 148, 21, 148, 480, 481, 482, 571, 150, 4, 24,
2272 4, 36, 409, 148, 148, 580, 57, 148, 148, 584,
2273 585, 148, 150, 148, 148, 148, 423, 10, 11, 12,
2274 13, 14, 15, 16, 17, 148, 148, 491, 492, 516,
2275 494, 495, 496, 497, 441, 499, 500, 501, 151, 503,
2276 539, 539, 148, 148, 148, 355, 356, 357, 148, 148,
2277 148, 148, 148, 363, 148, 4, 24, 152, 148, 151,
2278 559, 559, 57, 470, 151, 154, 148, 377, 378, 148,
2279 148, 151, 148, 480, 481, 482, 20, 148, 151, 486,
2280 21, 545, 546, 547, 151, 549, 550, 151, 151, 151,
2281 35, 21, 151, 36, 151, 502, 154, 41, 42, 43,
2282 44, 45, 46, 47, 49, 151, 50, 151, 151, 516,
2283 420, 21, 422, 76, 59, 60, 426, 148, 21, 148,
2284 21, 97, 97, 97, 434, 435, 436, 72, 73, 74,
2285 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2286 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
2287 95, 96, 97, 385, 41, 97, 25, 97, 468, 469,
2288 122, 471, 472, 386, 216, 410, 52, 409, 478, 61,
2289 3, 19, 423, 118, 119, 120, 448, 487, 123, 124,
2290 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
2291 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
2292 145, 146, 486, 5, 6, -1, -1, -1, 518, -1,
2293 -1, -1, -1, -1, -1, -1, -1, 20, -1, 22,
2294 22, 24, 24, -1, 26, -1, -1, -1, 31, 32,
2295 33, -1, -1, -1, -1, -1, 38, 39, 41, 42,
2296 43, 44, 45, 46, 47, -1, 556, 50, 51, -1,
2297 -1, -1, -1, -1, -1, 58, -1, -1, -1, 62,
2298 -1, 571, -1, -1, -1, -1, -1, -1, -1, -1,
2299 580, -1, -1, -1, 584, 585, 78, 79, 80, 81,
2300 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
2301 92, 93, 94, 95, 96, 97, 5, 6, -1, 8,
2302 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
2303 19, 20, 21, 22, -1, 24, -1, -1, -1, -1,
2304 -1, 123, 124, 125, 126, 127, 128, 129, 130, 131,
2305 132, 133, 134, 135, -1, 137, 138, 139, 140, 48,
2306 142, 143, 144, 3, 4, 5, 6, 7, -1, -1,
2307 152, -1, -1, 155, -1, 157, -1, -1, 160, -1,
2308 -1, -1, 22, -1, 24, -1, 26, 27, 28, -1,
Reid Spencera132e042006-12-03 05:46:11 +00002309 -1, -1, -1, -1, -1, -1, -1, -1, 38, 39,
Reid Spencer3da59db2006-11-27 01:05:10 +00002310 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer3da59db2006-11-27 01:05:10 +00002311 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencera132e042006-12-03 05:46:11 +00002312 -1, 61, -1, -1, -1, -1, -1, -1, -1, -1,
2313 -1, -1, -1, -1, -1, -1, -1, -1, 78, 79,
2314 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
2315 90, 91, 92, 93, 94, 95, 96, 97, -1, -1,
Reid Spencer6e18b7d2006-12-03 06:59:29 +00002316 149, -1, -1, 152, -1, -1, 155, -1, 157, 158,
Reid Spencer3da59db2006-11-27 01:05:10 +00002317 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer6e18b7d2006-12-03 06:59:29 +00002318 -1, -1, -1, 123, 124, 125, 126, 127, 128, 129,
2319 130, 131, 132, 133, 134, 135, -1, 137, 138, 139,
2320 140, -1, 142, 143, 144, 3, 4, -1, -1, 7,
2321 -1, -1, -1, -1, -1, 155, -1, -1, -1, -1,
2322 -1, -1, -1, -1, -1, -1, -1, -1, 26, 27,
2323 28, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2324 38, 39, -1, -1, -1, -1, -1, -1, -1, -1,
2325 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2326 -1, -1, -1, 61, -1, -1, -1, -1, -1, -1,
2327 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2328 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
2329 88, 89, 90, 91, 92, 93, 94, 95, 96, 97,
2330 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
2331 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
2332 -1, -1, -1, -1, -1, 123, 124, 125, 126, 127,
2333 128, 129, 130, 131, 132, 133, 134, 135, -1, 137,
2334 138, 139, 140, 48, 142, 143, 144, -1, -1, -1,
2335 -1, -1, -1, -1, -1, 5, 6, 155, 8, 9,
2336 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2337 20, 21, 22, -1, 24, -1, -1, -1, -1, -1,
2338 -1, -1, -1, -1, -1, -1, -1, 37, -1, -1,
2339 -1, -1, -1, -1, -1, -1, 5, 6, 48, 8,
2340 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
2341 19, 20, 21, 22, -1, 24, -1, -1, -1, -1,
2342 -1, -1, -1, -1, -1, -1, -1, -1, 37, -1,
2343 -1, -1, -1, -1, -1, -1, -1, -1, -1, 48,
2344 -1, -1, -1, -1, 149, -1, -1, 152, -1, 154,
2345 155, -1, 157, 5, 6, -1, 8, 9, 10, 11,
2346 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
2347 22, -1, 24, -1, -1, -1, -1, -1, -1, -1,
2348 -1, -1, -1, -1, -1, 37, -1, -1, -1, -1,
2349 -1, -1, -1, -1, -1, -1, 48, -1, -1, 149,
2350 -1, -1, 152, -1, -1, 155, -1, 157, -1, 5,
Reid Spencera132e042006-12-03 05:46:11 +00002351 6, -1, 8, 9, 10, 11, 12, 13, 14, 15,
Reid Spencer3822ff52006-11-08 06:47:33 +00002352 16, 17, 18, 19, 20, 21, 22, -1, 24, -1,
2353 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer6e18b7d2006-12-03 06:59:29 +00002354 149, 37, -1, 152, -1, -1, 155, -1, 157, -1,
2355 5, 6, 48, 8, 9, 10, 11, 12, 13, 14,
2356 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
2357 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
2358 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
2359 -1, -1, -1, 48, -1, -1, -1, 149, -1, -1,
2360 152, -1, -1, 155, -1, 157, -1, -1, -1, -1,
2361 -1, 5, 6, 48, 8, 9, 10, 11, 12, 13,
2362 14, 15, 16, 17, 18, 19, 20, 21, 22, -1,
2363 24, 5, 6, -1, 8, 9, 10, 11, 12, 13,
2364 14, 15, 16, 17, 18, 19, 20, 21, 22, -1,
2365 24, -1, -1, 149, 48, -1, 152, -1, -1, 155,
2366 -1, 157, -1, -1, -1, -1, -1, -1, -1, -1,
2367 -1, -1, -1, -1, 48, -1, -1, -1, -1, -1,
Reid Spencer3da59db2006-11-27 01:05:10 +00002368 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer6e18b7d2006-12-03 06:59:29 +00002369 -1, -1, -1, -1, 149, -1, -1, 152, -1, -1,
2370 155, -1, 157, -1, -1, -1, -1, -1, -1, -1,
2371 -1, -1, -1, -1, 149, -1, -1, 152, -1, -1,
2372 155, -1, 157, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer3da59db2006-11-27 01:05:10 +00002373 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2374 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer6e18b7d2006-12-03 06:59:29 +00002375 -1, -1, -1, -1, -1, 149, -1, -1, 152, -1,
2376 -1, 155, -1, 157, -1, -1, -1, -1, -1, -1,
2377 -1, -1, -1, -1, -1, 149, -1, -1, 152, -1,
2378 -1, 155, -1, 157
Reid Spencer3822ff52006-11-08 06:47:33 +00002379};
2380
2381/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2382 symbol of state STATE-NUM. */
2383static const unsigned char yystos[] =
2384{
Reid Spencer6e18b7d2006-12-03 06:59:29 +00002385 0, 195, 196, 197, 0, 25, 31, 41, 42, 43,
2386 44, 45, 46, 47, 62, 176, 214, 216, 218, 225,
2387 22, 24, 51, 58, 62, 175, 207, 218, 219, 61,
2388 64, 65, 66, 67, 68, 69, 70, 177, 212, 23,
2389 226, 227, 30, 158, 215, 226, 52, 53, 54, 71,
2390 204, 147, 61, 20, 45, 47, 50, 176, 147, 45,
2391 47, 217, 24, 202, 4, 5, 6, 8, 9, 10,
Reid Spencer3822ff52006-11-08 06:47:33 +00002392 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
Reid Spencer6e18b7d2006-12-03 06:59:29 +00002393 21, 48, 149, 152, 155, 157, 162, 184, 185, 186,
2394 187, 188, 207, 222, 29, 157, 213, 175, 230, 147,
2395 147, 147, 147, 152, 205, 202, 184, 32, 33, 194,
2396 194, 194, 194, 212, 4, 4, 4, 8, 158, 188,
2397 189, 207, 150, 159, 35, 49, 59, 60, 72, 73,
Reid Spencer3822ff52006-11-08 06:47:33 +00002398 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2399 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
Reid Spencer6e18b7d2006-12-03 06:59:29 +00002400 94, 95, 96, 97, 118, 119, 120, 123, 124, 125,
2401 126, 127, 128, 129, 130, 131, 132, 133, 134, 135,
2402 136, 137, 138, 139, 140, 141, 142, 143, 144, 145,
2403 146, 164, 165, 166, 167, 168, 228, 234, 235, 237,
2404 238, 24, 55, 56, 203, 4, 24, 24, 206, 186,
2405 186, 186, 9, 10, 11, 12, 13, 14, 15, 16,
2406 17, 18, 19, 171, 172, 174, 186, 191, 153, 153,
2407 148, 158, 150, 37, 189, 190, 186, 224, 59, 8,
2408 224, 9, 21, 10, 11, 12, 13, 14, 15, 16,
2409 17, 171, 172, 173, 177, 98, 99, 100, 101, 102,
2410 103, 104, 105, 106, 107, 169, 27, 28, 104, 105,
2411 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
2412 116, 117, 170, 186, 186, 224, 186, 186, 231, 224,
2413 224, 224, 224, 224, 224, 224, 186, 186, 186, 224,
2414 224, 177, 121, 122, 148, 154, 200, 201, 199, 27,
2415 28, 3, 4, 163, 4, 7, 26, 38, 39, 96,
2416 97, 123, 137, 142, 143, 144, 152, 155, 157, 160,
2417 164, 165, 166, 167, 168, 192, 222, 198, 188, 188,
2418 188, 37, 186, 209, 210, 211, 148, 151, 3, 4,
2419 7, 26, 27, 28, 38, 39, 61, 155, 192, 221,
2420 222, 223, 223, 223, 223, 184, 186, 186, 148, 179,
2421 148, 179, 223, 152, 148, 148, 148, 148, 148, 148,
2422 148, 148, 223, 223, 223, 36, 148, 184, 186, 224,
2423 24, 148, 182, 182, 182, 150, 150, 150, 150, 150,
2424 150, 150, 154, 191, 193, 193, 158, 193, 24, 150,
2425 150, 150, 150, 150, 182, 154, 156, 207, 208, 148,
2426 151, 37, 63, 220, 193, 148, 148, 223, 223, 223,
2427 15, 57, 15, 148, 236, 223, 152, 224, 186, 224,
2428 224, 224, 186, 186, 148, 148, 148, 186, 224, 223,
2429 223, 148, 34, 57, 180, 183, 169, 170, 191, 191,
2430 191, 191, 191, 148, 154, 156, 158, 191, 191, 191,
2431 191, 191, 37, 209, 180, 181, 24, 156, 21, 21,
2432 150, 148, 148, 223, 4, 223, 224, 232, 148, 223,
2433 148, 148, 148, 223, 223, 223, 150, 186, 24, 4,
2434 182, 148, 148, 236, 148, 148, 148, 148, 191, 148,
2435 148, 148, 36, 148, 57, 178, 148, 223, 223, 232,
2436 233, 223, 223, 148, 179, 179, 148, 223, 148, 224,
2437 224, 224, 233, 223, 191, 191, 151, 191, 191, 191,
2438 191, 191, 191, 191, 186, 191, 4, 24, 148, 152,
2439 151, 224, 154, 223, 151, 148, 148, 148, 151, 148,
2440 148, 151, 151, 151, 151, 151, 21, 154, 173, 229,
2441 36, 154, 191, 191, 191, 191, 191, 223, 221, 154,
2442 173, 21, 151, 151, 151, 151, 151, 148, 221, 223,
2443 21, 148, 76, 223, 21, 21, 223, 223
Reid Spencer3822ff52006-11-08 06:47:33 +00002444};
Reid Spencer68a24bd2005-08-27 18:50:39 +00002445
2446#define yyerrok (yyerrstatus = 0)
2447#define yyclearin (yychar = YYEMPTY)
Reid Spencer3822ff52006-11-08 06:47:33 +00002448#define YYEMPTY (-2)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002449#define YYEOF 0
Reid Spencer3822ff52006-11-08 06:47:33 +00002450
Reid Spencer68a24bd2005-08-27 18:50:39 +00002451#define YYACCEPT goto yyacceptlab
Reid Spencer3822ff52006-11-08 06:47:33 +00002452#define YYABORT goto yyabortlab
2453#define YYERROR goto yyerrorlab
2454
2455
2456/* Like YYERROR except do call yyerror. This remains here temporarily
2457 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002458 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer3822ff52006-11-08 06:47:33 +00002459
Reid Spencer68a24bd2005-08-27 18:50:39 +00002460#define YYFAIL goto yyerrlab
Reid Spencer3822ff52006-11-08 06:47:33 +00002461
Reid Spencer68a24bd2005-08-27 18:50:39 +00002462#define YYRECOVERING() (!!yyerrstatus)
Reid Spencer3822ff52006-11-08 06:47:33 +00002463
2464#define YYBACKUP(Token, Value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002465do \
2466 if (yychar == YYEMPTY && yylen == 1) \
Reid Spencer3822ff52006-11-08 06:47:33 +00002467 { \
2468 yychar = (Token); \
2469 yylval = (Value); \
2470 yytoken = YYTRANSLATE (yychar); \
Reid Spencer5b7e7532006-09-28 19:28:24 +00002471 YYPOPSTACK; \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002472 goto yybackup; \
2473 } \
2474 else \
Reid Spencer3822ff52006-11-08 06:47:33 +00002475 { \
2476 yyerror (YY_("syntax error: cannot back up")); \
2477 YYERROR; \
2478 } \
Reid Spencer5b7e7532006-09-28 19:28:24 +00002479while (0)
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002480
Reid Spencer3822ff52006-11-08 06:47:33 +00002481
Reid Spencer68a24bd2005-08-27 18:50:39 +00002482#define YYTERROR 1
2483#define YYERRCODE 256
2484
Reid Spencer3822ff52006-11-08 06:47:33 +00002485
2486/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2487 If N is 0, then set CURRENT to the empty location which ends
2488 the previous symbol: RHS[0] (always defined). */
2489
2490#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2491#ifndef YYLLOC_DEFAULT
2492# define YYLLOC_DEFAULT(Current, Rhs, N) \
2493 do \
2494 if (N) \
2495 { \
2496 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2497 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2498 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2499 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2500 } \
2501 else \
2502 { \
2503 (Current).first_line = (Current).last_line = \
2504 YYRHSLOC (Rhs, 0).last_line; \
2505 (Current).first_column = (Current).last_column = \
2506 YYRHSLOC (Rhs, 0).last_column; \
2507 } \
2508 while (0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002509#endif
2510
Reid Spencer3822ff52006-11-08 06:47:33 +00002511
2512/* YY_LOCATION_PRINT -- Print the location on the stream.
2513 This macro was not mandated originally: define only if we know
2514 we won't break user code: when these are the locations we know. */
2515
2516#ifndef YY_LOCATION_PRINT
2517# if YYLTYPE_IS_TRIVIAL
2518# define YY_LOCATION_PRINT(File, Loc) \
2519 fprintf (File, "%d.%d-%d.%d", \
2520 (Loc).first_line, (Loc).first_column, \
2521 (Loc).last_line, (Loc).last_column)
2522# else
2523# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2524# endif
2525#endif
2526
2527
2528/* YYLEX -- calling `yylex' with the right arguments. */
2529
Reid Spencer68a24bd2005-08-27 18:50:39 +00002530#ifdef YYLEX_PARAM
Reid Spencer3822ff52006-11-08 06:47:33 +00002531# define YYLEX yylex (YYLEX_PARAM)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002532#else
Reid Spencer3822ff52006-11-08 06:47:33 +00002533# define YYLEX yylex ()
Chris Lattnerf49c1762006-11-08 05:58:47 +00002534#endif
Reid Spencer3822ff52006-11-08 06:47:33 +00002535
2536/* Enable debugging if requested. */
2537#if YYDEBUG
2538
2539# ifndef YYFPRINTF
2540# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2541# define YYFPRINTF fprintf
2542# endif
2543
2544# define YYDPRINTF(Args) \
2545do { \
2546 if (yydebug) \
2547 YYFPRINTF Args; \
2548} while (0)
2549
2550# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2551do { \
2552 if (yydebug) \
2553 { \
2554 YYFPRINTF (stderr, "%s ", Title); \
2555 yysymprint (stderr, \
2556 Type, Value); \
2557 YYFPRINTF (stderr, "\n"); \
2558 } \
2559} while (0)
2560
2561/*------------------------------------------------------------------.
2562| yy_stack_print -- Print the state stack from its BOTTOM up to its |
2563| TOP (included). |
2564`------------------------------------------------------------------*/
2565
2566#if defined (__STDC__) || defined (__cplusplus)
2567static void
2568yy_stack_print (short int *bottom, short int *top)
Chris Lattnerf49c1762006-11-08 05:58:47 +00002569#else
Reid Spencer3822ff52006-11-08 06:47:33 +00002570static void
2571yy_stack_print (bottom, top)
2572 short int *bottom;
2573 short int *top;
Chris Lattnerf49c1762006-11-08 05:58:47 +00002574#endif
Reid Spencer3822ff52006-11-08 06:47:33 +00002575{
2576 YYFPRINTF (stderr, "Stack now");
2577 for (/* Nothing. */; bottom <= top; ++bottom)
2578 YYFPRINTF (stderr, " %d", *bottom);
2579 YYFPRINTF (stderr, "\n");
2580}
2581
2582# define YY_STACK_PRINT(Bottom, Top) \
2583do { \
2584 if (yydebug) \
2585 yy_stack_print ((Bottom), (Top)); \
2586} while (0)
2587
2588
2589/*------------------------------------------------.
2590| Report that the YYRULE is going to be reduced. |
2591`------------------------------------------------*/
2592
2593#if defined (__STDC__) || defined (__cplusplus)
2594static void
2595yy_reduce_print (int yyrule)
2596#else
2597static void
2598yy_reduce_print (yyrule)
2599 int yyrule;
Chris Lattner1ae022f2006-10-22 06:08:13 +00002600#endif
Reid Spencer3822ff52006-11-08 06:47:33 +00002601{
2602 int yyi;
2603 unsigned long int yylno = yyrline[yyrule];
2604 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
2605 yyrule - 1, yylno);
2606 /* Print the symbols being reduced, and their result. */
2607 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
2608 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
2609 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
2610}
Reid Spencer21be8652006-10-22 07:03:43 +00002611
Reid Spencer3822ff52006-11-08 06:47:33 +00002612# define YY_REDUCE_PRINT(Rule) \
2613do { \
2614 if (yydebug) \
2615 yy_reduce_print (Rule); \
2616} while (0)
Reid Spencer21be8652006-10-22 07:03:43 +00002617
Reid Spencer3822ff52006-11-08 06:47:33 +00002618/* Nonzero means print parse trace. It is left uninitialized so that
2619 multiple parsers can coexist. */
2620int yydebug;
2621#else /* !YYDEBUG */
2622# define YYDPRINTF(Args)
2623# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
2624# define YY_STACK_PRINT(Bottom, Top)
2625# define YY_REDUCE_PRINT(Rule)
2626#endif /* !YYDEBUG */
Reid Spencer21be8652006-10-22 07:03:43 +00002627
Reid Spencer21be8652006-10-22 07:03:43 +00002628
Reid Spencer3822ff52006-11-08 06:47:33 +00002629/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002630#ifndef YYINITDEPTH
Reid Spencer3822ff52006-11-08 06:47:33 +00002631# define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00002632#endif
2633
Reid Spencer3822ff52006-11-08 06:47:33 +00002634/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2635 if the built-in stack extension method is used).
Reid Spencer68a24bd2005-08-27 18:50:39 +00002636
Reid Spencer3822ff52006-11-08 06:47:33 +00002637 Do not make this value too large; the results are undefined if
2638 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
2639 evaluated with infinite-precision integer arithmetic. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002640
2641#ifndef YYMAXDEPTH
Reid Spencer3822ff52006-11-08 06:47:33 +00002642# define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00002643#endif
Reid Spencer3822ff52006-11-08 06:47:33 +00002644
Reid Spencer68a24bd2005-08-27 18:50:39 +00002645
2646
Reid Spencer3822ff52006-11-08 06:47:33 +00002647#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00002648
Reid Spencer3822ff52006-11-08 06:47:33 +00002649# ifndef yystrlen
2650# if defined (__GLIBC__) && defined (_STRING_H)
2651# define yystrlen strlen
2652# else
2653/* Return the length of YYSTR. */
2654static YYSIZE_T
2655# if defined (__STDC__) || defined (__cplusplus)
2656yystrlen (const char *yystr)
2657# else
2658yystrlen (yystr)
2659 const char *yystr;
2660# endif
Chris Lattnerf49c1762006-11-08 05:58:47 +00002661{
Reid Spencer3822ff52006-11-08 06:47:33 +00002662 const char *yys = yystr;
Chris Lattnerf49c1762006-11-08 05:58:47 +00002663
Reid Spencer3822ff52006-11-08 06:47:33 +00002664 while (*yys++ != '\0')
2665 continue;
2666
2667 return yys - yystr - 1;
Chris Lattnerf49c1762006-11-08 05:58:47 +00002668}
Reid Spencer3822ff52006-11-08 06:47:33 +00002669# endif
2670# endif
Chris Lattnerf49c1762006-11-08 05:58:47 +00002671
Reid Spencer3822ff52006-11-08 06:47:33 +00002672# ifndef yystpcpy
2673# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
2674# define yystpcpy stpcpy
2675# else
2676/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2677 YYDEST. */
2678static char *
2679# if defined (__STDC__) || defined (__cplusplus)
2680yystpcpy (char *yydest, const char *yysrc)
2681# else
2682yystpcpy (yydest, yysrc)
2683 char *yydest;
2684 const char *yysrc;
2685# endif
Chris Lattnerf49c1762006-11-08 05:58:47 +00002686{
Reid Spencer3822ff52006-11-08 06:47:33 +00002687 char *yyd = yydest;
2688 const char *yys = yysrc;
Chris Lattnerf49c1762006-11-08 05:58:47 +00002689
Reid Spencer3822ff52006-11-08 06:47:33 +00002690 while ((*yyd++ = *yys++) != '\0')
2691 continue;
2692
2693 return yyd - 1;
Chris Lattnerf49c1762006-11-08 05:58:47 +00002694}
Reid Spencer3822ff52006-11-08 06:47:33 +00002695# endif
2696# endif
Chris Lattnerf49c1762006-11-08 05:58:47 +00002697
Reid Spencer3822ff52006-11-08 06:47:33 +00002698# ifndef yytnamerr
2699/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
2700 quotes and backslashes, so that it's suitable for yyerror. The
2701 heuristic is that double-quoting is unnecessary unless the string
2702 contains an apostrophe, a comma, or backslash (other than
2703 backslash-backslash). YYSTR is taken from yytname. If YYRES is
2704 null, do not copy; instead, return the length of what the result
2705 would have been. */
2706static YYSIZE_T
2707yytnamerr (char *yyres, const char *yystr)
2708{
2709 if (*yystr == '"')
2710 {
2711 size_t yyn = 0;
2712 char const *yyp = yystr;
2713
2714 for (;;)
2715 switch (*++yyp)
2716 {
2717 case '\'':
2718 case ',':
2719 goto do_not_strip_quotes;
2720
2721 case '\\':
2722 if (*++yyp != '\\')
2723 goto do_not_strip_quotes;
2724 /* Fall through. */
2725 default:
2726 if (yyres)
2727 yyres[yyn] = *yyp;
2728 yyn++;
2729 break;
2730
2731 case '"':
2732 if (yyres)
2733 yyres[yyn] = '\0';
2734 return yyn;
2735 }
2736 do_not_strip_quotes: ;
2737 }
2738
2739 if (! yyres)
2740 return yystrlen (yystr);
2741
2742 return yystpcpy (yyres, yystr) - yyres;
2743}
2744# endif
2745
2746#endif /* YYERROR_VERBOSE */
2747
Reid Spencer21be8652006-10-22 07:03:43 +00002748
2749
Reid Spencer3822ff52006-11-08 06:47:33 +00002750#if YYDEBUG
2751/*--------------------------------.
2752| Print this symbol on YYOUTPUT. |
2753`--------------------------------*/
Reid Spencer21be8652006-10-22 07:03:43 +00002754
Reid Spencer3822ff52006-11-08 06:47:33 +00002755#if defined (__STDC__) || defined (__cplusplus)
2756static void
2757yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
Chris Lattnerf49c1762006-11-08 05:58:47 +00002758#else
Reid Spencer3822ff52006-11-08 06:47:33 +00002759static void
2760yysymprint (yyoutput, yytype, yyvaluep)
2761 FILE *yyoutput;
2762 int yytype;
2763 YYSTYPE *yyvaluep;
2764#endif
2765{
2766 /* Pacify ``unused variable'' warnings. */
2767 (void) yyvaluep;
2768
2769 if (yytype < YYNTOKENS)
2770 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2771 else
2772 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
2773
2774
2775# ifdef YYPRINT
2776 if (yytype < YYNTOKENS)
2777 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2778# endif
2779 switch (yytype)
2780 {
2781 default:
2782 break;
2783 }
2784 YYFPRINTF (yyoutput, ")");
2785}
2786
2787#endif /* ! YYDEBUG */
2788/*-----------------------------------------------.
2789| Release the memory associated to this symbol. |
2790`-----------------------------------------------*/
2791
2792#if defined (__STDC__) || defined (__cplusplus)
2793static void
2794yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
2795#else
2796static void
2797yydestruct (yymsg, yytype, yyvaluep)
2798 const char *yymsg;
2799 int yytype;
2800 YYSTYPE *yyvaluep;
2801#endif
2802{
2803 /* Pacify ``unused variable'' warnings. */
2804 (void) yyvaluep;
2805
2806 if (!yymsg)
2807 yymsg = "Deleting";
2808 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
2809
2810 switch (yytype)
2811 {
2812
2813 default:
2814 break;
2815 }
2816}
2817
2818
2819/* Prevent warnings from -Wmissing-prototypes. */
2820
2821#ifdef YYPARSE_PARAM
2822# if defined (__STDC__) || defined (__cplusplus)
2823int yyparse (void *YYPARSE_PARAM);
2824# else
2825int yyparse ();
2826# endif
2827#else /* ! YYPARSE_PARAM */
2828#if defined (__STDC__) || defined (__cplusplus)
Reid Spencere812fb22006-01-19 01:21:04 +00002829int yyparse (void);
Chris Lattnerf49c1762006-11-08 05:58:47 +00002830#else
Reid Spencer3822ff52006-11-08 06:47:33 +00002831int yyparse ();
2832#endif
2833#endif /* ! YYPARSE_PARAM */
2834
2835
2836
2837/* The look-ahead symbol. */
2838int yychar;
2839
2840/* The semantic value of the look-ahead symbol. */
2841YYSTYPE yylval;
2842
2843/* Number of syntax errors so far. */
2844int yynerrs;
2845
2846
2847
2848/*----------.
2849| yyparse. |
2850`----------*/
2851
2852#ifdef YYPARSE_PARAM
2853# if defined (__STDC__) || defined (__cplusplus)
2854int yyparse (void *YYPARSE_PARAM)
2855# else
2856int yyparse (YYPARSE_PARAM)
2857 void *YYPARSE_PARAM;
2858# endif
2859#else /* ! YYPARSE_PARAM */
2860#if defined (__STDC__) || defined (__cplusplus)
2861int
2862yyparse (void)
2863#else
2864int
2865yyparse ()
2866
2867#endif
2868#endif
2869{
2870
2871 int yystate;
2872 int yyn;
2873 int yyresult;
2874 /* Number of tokens to shift before error messages enabled. */
2875 int yyerrstatus;
2876 /* Look-ahead token as an internal (translated) token number. */
2877 int yytoken = 0;
2878
2879 /* Three stacks and their tools:
2880 `yyss': related to states,
2881 `yyvs': related to semantic values,
2882 `yyls': related to locations.
2883
2884 Refer to the stacks thru separate pointers, to allow yyoverflow
2885 to reallocate them elsewhere. */
2886
2887 /* The state stack. */
2888 short int yyssa[YYINITDEPTH];
2889 short int *yyss = yyssa;
2890 short int *yyssp;
2891
2892 /* The semantic value stack. */
2893 YYSTYPE yyvsa[YYINITDEPTH];
2894 YYSTYPE *yyvs = yyvsa;
2895 YYSTYPE *yyvsp;
2896
2897
2898
Reid Spencer5b7e7532006-09-28 19:28:24 +00002899#define YYPOPSTACK (yyvsp--, yyssp--)
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002900
Reid Spencer3822ff52006-11-08 06:47:33 +00002901 YYSIZE_T yystacksize = YYINITDEPTH;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002902
Reid Spencer3822ff52006-11-08 06:47:33 +00002903 /* The variables used to return semantic value and location from the
2904 action routines. */
2905 YYSTYPE yyval;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002906
2907
Reid Spencer3822ff52006-11-08 06:47:33 +00002908 /* When reducing, the number of symbols on the RHS of the reduced
2909 rule. */
Reid Spencer5b7e7532006-09-28 19:28:24 +00002910 int yylen;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002911
Reid Spencer3822ff52006-11-08 06:47:33 +00002912 YYDPRINTF ((stderr, "Starting parse\n"));
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002913
Reid Spencer68a24bd2005-08-27 18:50:39 +00002914 yystate = 0;
2915 yyerrstatus = 0;
2916 yynerrs = 0;
2917 yychar = YYEMPTY; /* Cause a token to be read. */
2918
2919 /* Initialize stack pointers.
2920 Waste one element of value and location stack
2921 so that they stay on the same level as the state stack.
2922 The wasted elements are never initialized. */
2923
Reid Spencer3822ff52006-11-08 06:47:33 +00002924 yyssp = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002925 yyvsp = yyvs;
2926
Reid Spencer3822ff52006-11-08 06:47:33 +00002927 goto yysetstate;
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002928
Reid Spencer3822ff52006-11-08 06:47:33 +00002929/*------------------------------------------------------------.
2930| yynewstate -- Push a new state, which is found in yystate. |
2931`------------------------------------------------------------*/
2932 yynewstate:
2933 /* In all cases, when you get here, the value and location stacks
2934 have just been pushed. so pushing a state here evens the stacks.
2935 */
2936 yyssp++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002937
Reid Spencer3822ff52006-11-08 06:47:33 +00002938 yysetstate:
2939 *yyssp = yystate;
2940
2941 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002942 {
2943 /* Get the current used size of the three stacks, in elements. */
Reid Spencer3822ff52006-11-08 06:47:33 +00002944 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002945
2946#ifdef yyoverflow
Reid Spencer3822ff52006-11-08 06:47:33 +00002947 {
2948 /* Give user a chance to reallocate the stack. Use copies of
2949 these so that the &'s don't force the real ones into
2950 memory. */
2951 YYSTYPE *yyvs1 = yyvs;
2952 short int *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002953
Reid Spencer3822ff52006-11-08 06:47:33 +00002954
2955 /* Each stack pointer address is followed by the size of the
2956 data in use in that stack, in bytes. This used to be a
2957 conditional around just the two extra args, but that might
2958 be undefined if yyoverflow is a macro. */
2959 yyoverflow (YY_("memory exhausted"),
2960 &yyss1, yysize * sizeof (*yyssp),
2961 &yyvs1, yysize * sizeof (*yyvsp),
2962
2963 &yystacksize);
2964
2965 yyss = yyss1;
2966 yyvs = yyvs1;
2967 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002968#else /* no yyoverflow */
Reid Spencer3822ff52006-11-08 06:47:33 +00002969# ifndef YYSTACK_RELOCATE
2970 goto yyexhaustedlab;
2971# else
Reid Spencer68a24bd2005-08-27 18:50:39 +00002972 /* Extend the stack our own way. */
Reid Spencer3822ff52006-11-08 06:47:33 +00002973 if (YYMAXDEPTH <= yystacksize)
2974 goto yyexhaustedlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002975 yystacksize *= 2;
Reid Spencer3822ff52006-11-08 06:47:33 +00002976 if (YYMAXDEPTH < yystacksize)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002977 yystacksize = YYMAXDEPTH;
Reid Spencer3822ff52006-11-08 06:47:33 +00002978
2979 {
2980 short int *yyss1 = yyss;
2981 union yyalloc *yyptr =
2982 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
2983 if (! yyptr)
2984 goto yyexhaustedlab;
2985 YYSTACK_RELOCATE (yyss);
2986 YYSTACK_RELOCATE (yyvs);
2987
2988# undef YYSTACK_RELOCATE
2989 if (yyss1 != yyssa)
2990 YYSTACK_FREE (yyss1);
2991 }
2992# endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002993#endif /* no yyoverflow */
2994
Reid Spencer3822ff52006-11-08 06:47:33 +00002995 yyssp = yyss + yysize - 1;
2996 yyvsp = yyvs + yysize - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002997
2998
Reid Spencer3822ff52006-11-08 06:47:33 +00002999 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3000 (unsigned long int) yystacksize));
3001
3002 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003003 YYABORT;
3004 }
3005
Reid Spencer3822ff52006-11-08 06:47:33 +00003006 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003007
3008 goto yybackup;
Reid Spencer3822ff52006-11-08 06:47:33 +00003009
3010/*-----------.
3011| yybackup. |
3012`-----------*/
3013yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00003014
Reid Spencer5b7e7532006-09-28 19:28:24 +00003015/* Do appropriate processing given the current state. */
Reid Spencer3822ff52006-11-08 06:47:33 +00003016/* Read a look-ahead token if we need one and don't already have one. */
Reid Spencer5b7e7532006-09-28 19:28:24 +00003017/* yyresume: */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003018
Reid Spencer3822ff52006-11-08 06:47:33 +00003019 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencer5b7e7532006-09-28 19:28:24 +00003020
Reid Spencer68a24bd2005-08-27 18:50:39 +00003021 yyn = yypact[yystate];
Reid Spencer3822ff52006-11-08 06:47:33 +00003022 if (yyn == YYPACT_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003023 goto yydefault;
3024
Reid Spencer3822ff52006-11-08 06:47:33 +00003025 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003026
Reid Spencer3822ff52006-11-08 06:47:33 +00003027 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003028 if (yychar == YYEMPTY)
3029 {
Reid Spencer3822ff52006-11-08 06:47:33 +00003030 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003031 yychar = YYLEX;
3032 }
3033
Reid Spencer3822ff52006-11-08 06:47:33 +00003034 if (yychar <= YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003035 {
Reid Spencer3822ff52006-11-08 06:47:33 +00003036 yychar = yytoken = YYEOF;
3037 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003038 }
3039 else
3040 {
Reid Spencer3822ff52006-11-08 06:47:33 +00003041 yytoken = YYTRANSLATE (yychar);
3042 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003043 }
3044
Reid Spencer3822ff52006-11-08 06:47:33 +00003045 /* If the proper action on seeing token YYTOKEN is to reduce or to
3046 detect an error, take that action. */
3047 yyn += yytoken;
3048 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003049 goto yydefault;
3050 yyn = yytable[yyn];
Reid Spencer3822ff52006-11-08 06:47:33 +00003051 if (yyn <= 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003052 {
Reid Spencer3822ff52006-11-08 06:47:33 +00003053 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003054 goto yyerrlab;
3055 yyn = -yyn;
3056 goto yyreduce;
3057 }
3058
3059 if (yyn == YYFINAL)
3060 YYACCEPT;
3061
Reid Spencer3822ff52006-11-08 06:47:33 +00003062 /* Shift the look-ahead token. */
3063 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Reid Spencer5b7e7532006-09-28 19:28:24 +00003064
3065 /* Discard the token being shifted unless it is eof. */
3066 if (yychar != YYEOF)
3067 yychar = YYEMPTY;
3068
3069 *++yyvsp = yylval;
3070
Reid Spencer3822ff52006-11-08 06:47:33 +00003071
3072 /* Count tokens shifted since error; after three, turn off error
3073 status. */
3074 if (yyerrstatus)
3075 yyerrstatus--;
Chris Lattner224f84f2006-08-18 17:34:45 +00003076
Reid Spencer68a24bd2005-08-27 18:50:39 +00003077 yystate = yyn;
3078 goto yynewstate;
3079
Chris Lattnerf49c1762006-11-08 05:58:47 +00003080
Reid Spencer3822ff52006-11-08 06:47:33 +00003081/*-----------------------------------------------------------.
3082| yydefault -- do the default action for the current state. |
3083`-----------------------------------------------------------*/
3084yydefault:
Reid Spencer68a24bd2005-08-27 18:50:39 +00003085 yyn = yydefact[yystate];
3086 if (yyn == 0)
3087 goto yyerrlab;
Reid Spencer3822ff52006-11-08 06:47:33 +00003088 goto yyreduce;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003089
Reid Spencer3822ff52006-11-08 06:47:33 +00003090
3091/*-----------------------------.
3092| yyreduce -- Do a reduction. |
3093`-----------------------------*/
Reid Spencer68a24bd2005-08-27 18:50:39 +00003094yyreduce:
Reid Spencer3822ff52006-11-08 06:47:33 +00003095 /* yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003096 yylen = yyr2[yyn];
3097
Reid Spencer3822ff52006-11-08 06:47:33 +00003098 /* If YYLEN is nonzero, implement the default value of the action:
3099 `$$ = $1'.
3100
3101 Otherwise, the following line sets YYVAL to garbage.
3102 This behavior is undocumented and Bison
3103 users should not rely upon it. Assigning to YYVAL
3104 unconditionally makes the parser a bit smaller, and it avoids a
3105 GCC warning that YYVAL may be used uninitialized. */
3106 yyval = yyvsp[1-yylen];
3107
3108
3109 YY_REDUCE_PRINT (yyn);
3110 switch (yyn)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003111 {
Reid Spencer3822ff52006-11-08 06:47:33 +00003112 case 3:
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003113#line 1105 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003114 {
3115 if ((yyvsp[0].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range!
Reid Spencer61c83e02006-08-18 08:43:06 +00003116 GEN_ERROR("Value too large for type!");
Reid Spencer3822ff52006-11-08 06:47:33 +00003117 (yyval.SIntVal) = (int32_t)(yyvsp[0].UIntVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003118 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003119;}
3120 break;
3121
3122 case 5:
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003123#line 1114 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003124 {
3125 if ((yyvsp[0].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range!
Reid Spencer61c83e02006-08-18 08:43:06 +00003126 GEN_ERROR("Value too large for type!");
Reid Spencer3822ff52006-11-08 06:47:33 +00003127 (yyval.SInt64Val) = (int64_t)(yyvsp[0].UInt64Val);
Reid Spencer61c83e02006-08-18 08:43:06 +00003128 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003129;}
3130 break;
3131
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003132 case 39:
3133#line 1131 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3134 { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;}
3135 break;
3136
3137 case 40:
3138#line 1131 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3139 { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;}
3140 break;
3141
3142 case 41:
3143#line 1132 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3144 { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;}
3145 break;
3146
3147 case 42:
3148#line 1132 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3149 { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;}
3150 break;
3151
3152 case 43:
3153#line 1133 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3154 { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;}
3155 break;
3156
3157 case 44:
3158#line 1133 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3159 { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;}
3160 break;
3161
3162 case 45:
3163#line 1134 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3164 { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;}
3165 break;
3166
3167 case 46:
3168#line 1134 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3169 { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;}
3170 break;
3171
3172 case 47:
3173#line 1135 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3174 { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;}
3175 break;
3176
3177 case 48:
3178#line 1135 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3179 { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;}
3180 break;
3181
3182 case 49:
3183#line 1139 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3184 { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;}
3185 break;
3186
3187 case 50:
3188#line 1139 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3189 { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;}
3190 break;
3191
3192 case 51:
3193#line 1140 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3194 { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;}
3195 break;
3196
3197 case 52:
3198#line 1140 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3199 { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;}
3200 break;
3201
3202 case 53:
3203#line 1141 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3204 { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;}
3205 break;
3206
3207 case 54:
3208#line 1141 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3209 { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;}
3210 break;
3211
3212 case 55:
3213#line 1142 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3214 { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;}
3215 break;
3216
3217 case 56:
3218#line 1142 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3219 { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;}
3220 break;
3221
3222 case 57:
Reid Spencera132e042006-12-03 05:46:11 +00003223#line 1143 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003224 { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;}
3225 break;
3226
3227 case 58:
3228#line 1143 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3229 { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;}
3230 break;
3231
3232 case 59:
3233#line 1144 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3234 { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;}
3235 break;
3236
3237 case 60:
3238#line 1144 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3239 { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;}
3240 break;
3241
3242 case 61:
3243#line 1145 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3244 { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;}
3245 break;
3246
3247 case 62:
3248#line 1145 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3249 { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;}
3250 break;
3251
3252 case 63:
3253#line 1146 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3254 { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;}
3255 break;
3256
3257 case 64:
3258#line 1147 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3259 { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;}
3260 break;
3261
3262 case 77:
3263#line 1158 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003264 {
3265 (yyval.StrVal) = (yyvsp[-1].StrVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003266 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003267 ;}
3268 break;
3269
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003270 case 78:
3271#line 1162 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003272 {
3273 (yyval.StrVal) = 0;
Reid Spencer61c83e02006-08-18 08:43:06 +00003274 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003275 ;}
3276 break;
3277
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003278 case 79:
3279#line 1167 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003280 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3281 break;
3282
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003283 case 80:
3284#line 1168 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003285 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3286 break;
3287
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003288 case 81:
3289#line 1169 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003290 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3291 break;
3292
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003293 case 82:
3294#line 1170 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003295 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3296 break;
3297
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003298 case 83:
3299#line 1171 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003300 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3301 break;
3302
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003303 case 84:
3304#line 1172 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003305 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3306 break;
3307
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003308 case 85:
3309#line 1173 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003310 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3311 break;
3312
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003313 case 86:
3314#line 1174 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003315 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3316 break;
3317
Reid Spencera132e042006-12-03 05:46:11 +00003318 case 87:
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003319#line 1176 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3320 { (yyval.UIntVal) = CallingConv::C; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003321 break;
3322
Reid Spencera132e042006-12-03 05:46:11 +00003323 case 88:
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003324#line 1177 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3325 { (yyval.UIntVal) = CallingConv::C; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003326 break;
3327
Reid Spencera132e042006-12-03 05:46:11 +00003328 case 89:
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003329#line 1178 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3330 { (yyval.UIntVal) = CallingConv::CSRet; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003331 break;
3332
Reid Spencera132e042006-12-03 05:46:11 +00003333 case 90:
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003334#line 1179 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3335 { (yyval.UIntVal) = CallingConv::Fast; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003336 break;
3337
Reid Spencera132e042006-12-03 05:46:11 +00003338 case 91:
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003339#line 1180 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3340 { (yyval.UIntVal) = CallingConv::Cold; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003341 break;
3342
Reid Spencera132e042006-12-03 05:46:11 +00003343 case 92:
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003344#line 1181 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3345 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
3346 break;
3347
3348 case 93:
3349#line 1182 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3350 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
3351 break;
3352
3353 case 94:
3354#line 1183 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003355 {
3356 if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val))
Reid Spencer61c83e02006-08-18 08:43:06 +00003357 GEN_ERROR("Calling conv too large!");
Reid Spencer3822ff52006-11-08 06:47:33 +00003358 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Reid Spencer61c83e02006-08-18 08:43:06 +00003359 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003360 ;}
3361 break;
3362
Reid Spencera132e042006-12-03 05:46:11 +00003363 case 95:
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003364#line 1192 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003365 { (yyval.UIntVal) = 0; ;}
3366 break;
3367
Reid Spencera132e042006-12-03 05:46:11 +00003368 case 96:
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003369#line 1193 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003370 {
3371 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3372 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencer3ed469c2006-11-02 20:25:50 +00003373 GEN_ERROR("Alignment must be a power of two!");
3374 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003375;}
3376 break;
3377
Reid Spencera132e042006-12-03 05:46:11 +00003378 case 97:
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003379#line 1199 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3380 { (yyval.UIntVal) = 0; ;}
3381 break;
3382
3383 case 98:
3384#line 1200 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3385 {
3386 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3387 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
3388 GEN_ERROR("Alignment must be a power of two!");
3389 CHECK_FOR_ERROR
3390;}
3391 break;
3392
3393 case 99:
3394#line 1208 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003395 {
3396 for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i)
3397 if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\')
Reid Spencer61c83e02006-08-18 08:43:06 +00003398 GEN_ERROR("Invalid character in section name!");
Reid Spencer3822ff52006-11-08 06:47:33 +00003399 (yyval.StrVal) = (yyvsp[0].StrVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003400 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003401;}
3402 break;
3403
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003404 case 100:
3405#line 1216 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003406 { (yyval.StrVal) = 0; ;}
3407 break;
3408
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003409 case 101:
3410#line 1217 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003411 { (yyval.StrVal) = (yyvsp[0].StrVal); ;}
3412 break;
3413
Reid Spencera132e042006-12-03 05:46:11 +00003414 case 102:
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003415#line 1222 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3416 {;}
3417 break;
3418
3419 case 103:
3420#line 1223 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3421 {;}
3422 break;
3423
3424 case 104:
3425#line 1224 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003426 {
3427 CurGV->setSection((yyvsp[0].StrVal));
3428 free((yyvsp[0].StrVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003429 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003430 ;}
3431 break;
3432
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003433 case 105:
3434#line 1229 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003435 {
3436 if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val)))
Reid Spencer61c83e02006-08-18 08:43:06 +00003437 GEN_ERROR("Alignment must be a power of two!");
Reid Spencer3822ff52006-11-08 06:47:33 +00003438 CurGV->setAlignment((yyvsp[0].UInt64Val));
Reid Spencer61c83e02006-08-18 08:43:06 +00003439 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003440 ;}
3441 break;
3442
Reid Spencera132e042006-12-03 05:46:11 +00003443 case 107:
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003444#line 1243 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencera132e042006-12-03 05:46:11 +00003445 { (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType)); ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003446 break;
3447
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003448 case 109:
3449#line 1244 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3450 { (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType)); ;}
3451 break;
3452
3453 case 110:
3454#line 1246 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003455 {
Reid Spencer3da59db2006-11-27 01:05:10 +00003456 if (!UpRefs.empty())
Reid Spencera132e042006-12-03 05:46:11 +00003457 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
Reid Spencer3da59db2006-11-27 01:05:10 +00003458 (yyval.TypeVal) = (yyvsp[0].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003459 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003460 ;}
3461 break;
3462
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003463 case 124:
3464#line 1258 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencera132e042006-12-03 05:46:11 +00003465 {
3466 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
3467 CHECK_FOR_ERROR
3468 ;}
3469 break;
3470
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003471 case 125:
3472#line 1262 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencera132e042006-12-03 05:46:11 +00003473 {
3474 (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType));
3475 CHECK_FOR_ERROR
3476 ;}
3477 break;
3478
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003479 case 126:
3480#line 1266 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3da59db2006-11-27 01:05:10 +00003481 { // Named types are also simple types...
3482 const Type* tmp = getTypeVal((yyvsp[0].ValIDVal));
3483 CHECK_FOR_ERROR
Reid Spencera132e042006-12-03 05:46:11 +00003484 (yyval.TypeVal) = new PATypeHolder(tmp);
Reid Spencer3da59db2006-11-27 01:05:10 +00003485;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003486 break;
3487
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003488 case 127:
3489#line 1274 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3da59db2006-11-27 01:05:10 +00003490 { // Type UpReference
3491 if ((yyvsp[0].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range!");
3492 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
3493 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector...
Reid Spencera132e042006-12-03 05:46:11 +00003494 (yyval.TypeVal) = new PATypeHolder(OT);
Reid Spencer3da59db2006-11-27 01:05:10 +00003495 UR_OUT("New Upreference!\n");
Reid Spencer61c83e02006-08-18 08:43:06 +00003496 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003497 ;}
3498 break;
3499
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003500 case 128:
3501#line 1282 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3da59db2006-11-27 01:05:10 +00003502 { // Function derived type?
3503 std::vector<const Type*> Params;
Reid Spencera132e042006-12-03 05:46:11 +00003504 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-1].TypeList)->begin(),
Reid Spencer3da59db2006-11-27 01:05:10 +00003505 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
Reid Spencera132e042006-12-03 05:46:11 +00003506 Params.push_back(*I);
Reid Spencer3da59db2006-11-27 01:05:10 +00003507 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3508 if (isVarArg) Params.pop_back();
3509
Reid Spencera132e042006-12-03 05:46:11 +00003510 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FunctionType::get(*(yyvsp[-3].TypeVal),Params,isVarArg)));
Reid Spencer3da59db2006-11-27 01:05:10 +00003511 delete (yyvsp[-1].TypeList); // Delete the argument list
Reid Spencera132e042006-12-03 05:46:11 +00003512 delete (yyvsp[-3].TypeVal); // Delete the return type handle
Reid Spencer3da59db2006-11-27 01:05:10 +00003513 CHECK_FOR_ERROR
3514 ;}
3515 break;
3516
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003517 case 129:
3518#line 1295 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3da59db2006-11-27 01:05:10 +00003519 { // Sized array type?
Reid Spencera132e042006-12-03 05:46:11 +00003520 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3521 delete (yyvsp[-1].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00003522 CHECK_FOR_ERROR
3523 ;}
3524 break;
3525
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003526 case 130:
3527#line 1300 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3da59db2006-11-27 01:05:10 +00003528 { // Packed array type?
Reid Spencera132e042006-12-03 05:46:11 +00003529 const llvm::Type* ElemTy = (yyvsp[-1].TypeVal)->get();
3530 if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val))
3531 GEN_ERROR("Unsigned result not equal to signed result");
3532 if (!ElemTy->isPrimitiveType())
3533 GEN_ERROR("Elemental type of a PackedType must be primitive");
3534 if (!isPowerOf2_32((yyvsp[-3].UInt64Val)))
3535 GEN_ERROR("Vector length should be a power of 2!");
3536 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PackedType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3537 delete (yyvsp[-1].TypeVal);
3538 CHECK_FOR_ERROR
Reid Spencer3da59db2006-11-27 01:05:10 +00003539 ;}
3540 break;
3541
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003542 case 131:
3543#line 1312 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3da59db2006-11-27 01:05:10 +00003544 { // Structure type?
3545 std::vector<const Type*> Elements;
Reid Spencera132e042006-12-03 05:46:11 +00003546 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-1].TypeList)->begin(),
Reid Spencer3da59db2006-11-27 01:05:10 +00003547 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
Reid Spencera132e042006-12-03 05:46:11 +00003548 Elements.push_back(*I);
Reid Spencer3da59db2006-11-27 01:05:10 +00003549
Reid Spencera132e042006-12-03 05:46:11 +00003550 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
Reid Spencer3da59db2006-11-27 01:05:10 +00003551 delete (yyvsp[-1].TypeList);
3552 CHECK_FOR_ERROR
3553 ;}
3554 break;
3555
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003556 case 132:
3557#line 1322 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3da59db2006-11-27 01:05:10 +00003558 { // Empty structure type?
Reid Spencera132e042006-12-03 05:46:11 +00003559 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer3da59db2006-11-27 01:05:10 +00003560 CHECK_FOR_ERROR
3561 ;}
3562 break;
3563
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003564 case 133:
3565#line 1326 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3da59db2006-11-27 01:05:10 +00003566 { // Pointer type?
Reid Spencera132e042006-12-03 05:46:11 +00003567 if (*(yyvsp[-1].TypeVal) == Type::LabelTy)
Reid Spencer3da59db2006-11-27 01:05:10 +00003568 GEN_ERROR("Cannot form a pointer to a basic block");
Reid Spencera132e042006-12-03 05:46:11 +00003569 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[-1].TypeVal))));
3570 delete (yyvsp[-1].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00003571 CHECK_FOR_ERROR
3572 ;}
3573 break;
3574
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003575 case 134:
3576#line 1337 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3da59db2006-11-27 01:05:10 +00003577 {
Reid Spencera132e042006-12-03 05:46:11 +00003578 (yyval.TypeList) = new std::list<PATypeHolder>();
3579 (yyval.TypeList)->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00003580 CHECK_FOR_ERROR
3581 ;}
3582 break;
3583
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003584 case 135:
3585#line 1342 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3da59db2006-11-27 01:05:10 +00003586 {
Reid Spencera132e042006-12-03 05:46:11 +00003587 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00003588 CHECK_FOR_ERROR
3589 ;}
3590 break;
3591
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003592 case 137:
3593#line 1349 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3da59db2006-11-27 01:05:10 +00003594 {
Reid Spencera132e042006-12-03 05:46:11 +00003595 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(Type::VoidTy);
Reid Spencer3da59db2006-11-27 01:05:10 +00003596 CHECK_FOR_ERROR
3597 ;}
3598 break;
3599
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003600 case 138:
3601#line 1353 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3da59db2006-11-27 01:05:10 +00003602 {
Reid Spencera132e042006-12-03 05:46:11 +00003603 ((yyval.TypeList) = new std::list<PATypeHolder>())->push_back(Type::VoidTy);
Reid Spencer3da59db2006-11-27 01:05:10 +00003604 CHECK_FOR_ERROR
3605 ;}
3606 break;
3607
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003608 case 139:
3609#line 1357 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3da59db2006-11-27 01:05:10 +00003610 {
Reid Spencera132e042006-12-03 05:46:11 +00003611 (yyval.TypeList) = new std::list<PATypeHolder>();
Reid Spencer3da59db2006-11-27 01:05:10 +00003612 CHECK_FOR_ERROR
3613 ;}
3614 break;
3615
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003616 case 140:
3617#line 1368 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003618 { // Nonempty unsized arr
Reid Spencera132e042006-12-03 05:46:11 +00003619 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003620 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003621 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencera132e042006-12-03 05:46:11 +00003622 (*(yyvsp[-3].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003623 const Type *ETy = ATy->getElementType();
3624 int NumElements = ATy->getNumElements();
3625
3626 // Verify that we have the correct size...
Reid Spencer3822ff52006-11-08 06:47:33 +00003627 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Reid Spencer61c83e02006-08-18 08:43:06 +00003628 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Reid Spencer3822ff52006-11-08 06:47:33 +00003629 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003630 itostr(NumElements) + "!");
3631
3632 // Verify all elements are correct type!
Reid Spencer3822ff52006-11-08 06:47:33 +00003633 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
Reid Spencera132e042006-12-03 05:46:11 +00003634 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003635 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003636 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencera132e042006-12-03 05:46:11 +00003637 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003638 }
3639
Reid Spencera132e042006-12-03 05:46:11 +00003640 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[-1].ConstVector));
3641 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Reid Spencer61c83e02006-08-18 08:43:06 +00003642 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003643 ;}
3644 break;
3645
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003646 case 141:
3647#line 1394 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003648 {
Reid Spencera132e042006-12-03 05:46:11 +00003649 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003650 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003651 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencera132e042006-12-03 05:46:11 +00003652 (*(yyvsp[-2].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003653
3654 int NumElements = ATy->getNumElements();
3655 if (NumElements != -1 && NumElements != 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003656 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003657 " arguments, but has size of " + itostr(NumElements) +"!");
Reid Spencera132e042006-12-03 05:46:11 +00003658 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
3659 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003660 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003661 ;}
3662 break;
3663
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003664 case 142:
3665#line 1408 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003666 {
Reid Spencera132e042006-12-03 05:46:11 +00003667 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003668 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003669 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencera132e042006-12-03 05:46:11 +00003670 (*(yyvsp[-2].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003671
3672 int NumElements = ATy->getNumElements();
3673 const Type *ETy = ATy->getElementType();
Reid Spencer3822ff52006-11-08 06:47:33 +00003674 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
3675 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00003676 GEN_ERROR("Can't build string constant of size " +
Reid Spencer3822ff52006-11-08 06:47:33 +00003677 itostr((int)(EndStr-(yyvsp[0].StrVal))) +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003678 " when array has size " + itostr(NumElements) + "!");
3679 std::vector<Constant*> Vals;
3680 if (ETy == Type::SByteTy) {
Reid Spencer3822ff52006-11-08 06:47:33 +00003681 for (signed char *C = (signed char *)(yyvsp[0].StrVal); C != (signed char *)EndStr; ++C)
Reid Spencerb83eb642006-10-20 07:07:24 +00003682 Vals.push_back(ConstantInt::get(ETy, *C));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003683 } else if (ETy == Type::UByteTy) {
Reid Spencer3822ff52006-11-08 06:47:33 +00003684 for (unsigned char *C = (unsigned char *)(yyvsp[0].StrVal);
Chris Lattner66316012006-01-24 04:14:29 +00003685 C != (unsigned char*)EndStr; ++C)
Reid Spencerb83eb642006-10-20 07:07:24 +00003686 Vals.push_back(ConstantInt::get(ETy, *C));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003687 } else {
Reid Spencer3822ff52006-11-08 06:47:33 +00003688 free((yyvsp[0].StrVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003689 GEN_ERROR("Cannot build string arrays of non byte sized elements!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003690 }
Reid Spencer3822ff52006-11-08 06:47:33 +00003691 free((yyvsp[0].StrVal));
Reid Spencera132e042006-12-03 05:46:11 +00003692 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
3693 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003694 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003695 ;}
3696 break;
3697
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003698 case 143:
3699#line 1438 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003700 { // Nonempty unsized arr
Reid Spencera132e042006-12-03 05:46:11 +00003701 const PackedType *PTy = dyn_cast<PackedType>((yyvsp[-3].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003702 if (PTy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003703 GEN_ERROR("Cannot make packed constant with type: '" +
Reid Spencera132e042006-12-03 05:46:11 +00003704 (*(yyvsp[-3].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003705 const Type *ETy = PTy->getElementType();
3706 int NumElements = PTy->getNumElements();
3707
3708 // Verify that we have the correct size...
Reid Spencer3822ff52006-11-08 06:47:33 +00003709 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Reid Spencer61c83e02006-08-18 08:43:06 +00003710 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Reid Spencer3822ff52006-11-08 06:47:33 +00003711 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003712 itostr(NumElements) + "!");
3713
3714 // Verify all elements are correct type!
Reid Spencer3822ff52006-11-08 06:47:33 +00003715 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
Reid Spencera132e042006-12-03 05:46:11 +00003716 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003717 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003718 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencera132e042006-12-03 05:46:11 +00003719 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003720 }
3721
Reid Spencera132e042006-12-03 05:46:11 +00003722 (yyval.ConstVal) = ConstantPacked::get(PTy, *(yyvsp[-1].ConstVector));
3723 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Reid Spencer61c83e02006-08-18 08:43:06 +00003724 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003725 ;}
3726 break;
3727
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003728 case 144:
3729#line 1464 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003730 {
Reid Spencera132e042006-12-03 05:46:11 +00003731 const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal)->get());
Reid Spencer61c83e02006-08-18 08:43:06 +00003732 if (STy == 0)
3733 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencera132e042006-12-03 05:46:11 +00003734 (*(yyvsp[-3].TypeVal))->getDescription() + "'!");
Reid Spencer61c83e02006-08-18 08:43:06 +00003735
Reid Spencer3822ff52006-11-08 06:47:33 +00003736 if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencer61c83e02006-08-18 08:43:06 +00003737 GEN_ERROR("Illegal number of initializers for structure type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003738
3739 // Check to ensure that constants are compatible with the type initializer!
Reid Spencer3822ff52006-11-08 06:47:33 +00003740 for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i)
Reid Spencera132e042006-12-03 05:46:11 +00003741 if ((*(yyvsp[-1].ConstVector))[i]->getType() != STy->getElementType(i))
Reid Spencer61c83e02006-08-18 08:43:06 +00003742 GEN_ERROR("Expected type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003743 STy->getElementType(i)->getDescription() +
3744 "' for element #" + utostr(i) +
3745 " of structure initializer!");
3746
Reid Spencera132e042006-12-03 05:46:11 +00003747 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-1].ConstVector));
3748 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Reid Spencer61c83e02006-08-18 08:43:06 +00003749 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003750 ;}
3751 break;
3752
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003753 case 145:
3754#line 1485 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003755 {
Reid Spencera132e042006-12-03 05:46:11 +00003756 const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003757 if (STy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003758 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencera132e042006-12-03 05:46:11 +00003759 (*(yyvsp[-2].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003760
3761 if (STy->getNumContainedTypes() != 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003762 GEN_ERROR("Illegal number of initializers for structure type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003763
Reid Spencera132e042006-12-03 05:46:11 +00003764 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
3765 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003766 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003767 ;}
3768 break;
3769
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003770 case 146:
3771#line 1498 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003772 {
Reid Spencera132e042006-12-03 05:46:11 +00003773 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003774 if (PTy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003775 GEN_ERROR("Cannot make null pointer constant with type: '" +
Reid Spencera132e042006-12-03 05:46:11 +00003776 (*(yyvsp[-1].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003777
Reid Spencera132e042006-12-03 05:46:11 +00003778 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
3779 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003780 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003781 ;}
3782 break;
3783
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003784 case 147:
3785#line 1508 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003786 {
Reid Spencera132e042006-12-03 05:46:11 +00003787 (yyval.ConstVal) = UndefValue::get((yyvsp[-1].TypeVal)->get());
3788 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003789 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003790 ;}
3791 break;
3792
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003793 case 148:
3794#line 1513 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003795 {
Reid Spencera132e042006-12-03 05:46:11 +00003796 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003797 if (Ty == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003798 GEN_ERROR("Global const reference must be a pointer type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003799
3800 // ConstExprs can exist in the body of a function, thus creating
3801 // GlobalValues whenever they refer to a variable. Because we are in
3802 // the context of a function, getValNonImprovising will search the functions
3803 // symbol table instead of the module symbol table for the global symbol,
3804 // which throws things all off. To get around this, we just tell
3805 // getValNonImprovising that we are at global scope here.
3806 //
3807 Function *SavedCurFn = CurFun.CurrentFunction;
3808 CurFun.CurrentFunction = 0;
3809
Reid Spencer3822ff52006-11-08 06:47:33 +00003810 Value *V = getValNonImprovising(Ty, (yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00003811 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003812
3813 CurFun.CurrentFunction = SavedCurFn;
3814
3815 // If this is an initializer for a constant pointer, which is referencing a
3816 // (currently) undefined variable, create a stub now that shall be replaced
3817 // in the future with the right type of variable.
3818 //
3819 if (V == 0) {
3820 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
3821 const PointerType *PT = cast<PointerType>(Ty);
3822
3823 // First check to see if the forward references value is already created!
3824 PerModuleInfo::GlobalRefsType::iterator I =
Reid Spencer3822ff52006-11-08 06:47:33 +00003825 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal)));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003826
3827 if (I != CurModule.GlobalRefs.end()) {
3828 V = I->second; // Placeholder already exists, use it...
Reid Spencer3822ff52006-11-08 06:47:33 +00003829 (yyvsp[0].ValIDVal).destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003830 } else {
3831 std::string Name;
Reid Spencer3822ff52006-11-08 06:47:33 +00003832 if ((yyvsp[0].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[0].ValIDVal).Name;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003833
3834 // Create the forward referenced global.
3835 GlobalValue *GV;
3836 if (const FunctionType *FTy =
3837 dyn_cast<FunctionType>(PT->getElementType())) {
3838 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
3839 CurModule.CurrentModule);
3840 } else {
3841 GV = new GlobalVariable(PT->getElementType(), false,
3842 GlobalValue::ExternalLinkage, 0,
3843 Name, CurModule.CurrentModule);
3844 }
3845
3846 // Keep track of the fact that we have a forward ref to recycle it
Reid Spencer3822ff52006-11-08 06:47:33 +00003847 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003848 V = GV;
3849 }
3850 }
3851
Reid Spencera132e042006-12-03 05:46:11 +00003852 (yyval.ConstVal) = cast<GlobalValue>(V);
3853 delete (yyvsp[-1].TypeVal); // Free the type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00003854 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003855 ;}
3856 break;
3857
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003858 case 149:
3859#line 1574 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003860 {
Reid Spencera132e042006-12-03 05:46:11 +00003861 if ((yyvsp[-1].TypeVal)->get() != (yyvsp[0].ConstVal)->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003862 GEN_ERROR("Mismatched types for constant expression!");
Reid Spencer3822ff52006-11-08 06:47:33 +00003863 (yyval.ConstVal) = (yyvsp[0].ConstVal);
Reid Spencera132e042006-12-03 05:46:11 +00003864 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003865 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003866 ;}
3867 break;
3868
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003869 case 150:
3870#line 1581 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003871 {
Reid Spencera132e042006-12-03 05:46:11 +00003872 const Type *Ty = (yyvsp[-1].TypeVal)->get();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003873 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
Reid Spencer61c83e02006-08-18 08:43:06 +00003874 GEN_ERROR("Cannot create a null initialized value of this type!");
Reid Spencera132e042006-12-03 05:46:11 +00003875 (yyval.ConstVal) = Constant::getNullValue(Ty);
3876 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003877 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003878 ;}
3879 break;
3880
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003881 case 151:
3882#line 1589 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003883 { // integral constants
Reid Spencera132e042006-12-03 05:46:11 +00003884 if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val)))
Reid Spencer61c83e02006-08-18 08:43:06 +00003885 GEN_ERROR("Constant value doesn't fit in type!");
Reid Spencera132e042006-12-03 05:46:11 +00003886 (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val));
Reid Spencer61c83e02006-08-18 08:43:06 +00003887 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003888 ;}
3889 break;
3890
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003891 case 152:
3892#line 1595 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003893 { // integral constants
Reid Spencera132e042006-12-03 05:46:11 +00003894 if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val)))
Reid Spencer61c83e02006-08-18 08:43:06 +00003895 GEN_ERROR("Constant value doesn't fit in type!");
Reid Spencera132e042006-12-03 05:46:11 +00003896 (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val));
Reid Spencer61c83e02006-08-18 08:43:06 +00003897 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003898 ;}
3899 break;
3900
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003901 case 153:
3902#line 1601 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003903 { // Boolean constants
Reid Spencera132e042006-12-03 05:46:11 +00003904 (yyval.ConstVal) = ConstantBool::getTrue();
Reid Spencer61c83e02006-08-18 08:43:06 +00003905 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003906 ;}
3907 break;
3908
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003909 case 154:
3910#line 1605 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003911 { // Boolean constants
Reid Spencera132e042006-12-03 05:46:11 +00003912 (yyval.ConstVal) = ConstantBool::getFalse();
Reid Spencer61c83e02006-08-18 08:43:06 +00003913 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003914 ;}
3915 break;
3916
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003917 case 155:
3918#line 1609 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003919 { // Float & Double constants
Reid Spencera132e042006-12-03 05:46:11 +00003920 if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].FPVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00003921 GEN_ERROR("Floating point constant invalid for type!!");
Reid Spencera132e042006-12-03 05:46:11 +00003922 (yyval.ConstVal) = ConstantFP::get((yyvsp[-1].PrimType), (yyvsp[0].FPVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003923 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003924 ;}
3925 break;
3926
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003927 case 156:
3928#line 1617 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003929 {
Reid Spencera132e042006-12-03 05:46:11 +00003930 Constant *Val = (yyvsp[-3].ConstVal);
3931 const Type *Ty = (yyvsp[-1].TypeVal)->get();
Reid Spencer3da59db2006-11-27 01:05:10 +00003932 if (!Val->getType()->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003933 GEN_ERROR("cast constant expression from a non-primitive type: '" +
Reid Spencer3da59db2006-11-27 01:05:10 +00003934 Val->getType()->getDescription() + "'!");
3935 if (!Ty->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003936 GEN_ERROR("cast constant expression to a non-primitive type: '" +
Reid Spencer3da59db2006-11-27 01:05:10 +00003937 Ty->getDescription() + "'!");
Reid Spencera132e042006-12-03 05:46:11 +00003938 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].TypeVal)->get());
3939 delete (yyvsp[-1].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00003940 ;}
3941 break;
3942
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003943 case 157:
3944#line 1629 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003945 {
Reid Spencera132e042006-12-03 05:46:11 +00003946 if (!isa<PointerType>((yyvsp[-2].ConstVal)->getType()))
Reid Spencer61c83e02006-08-18 08:43:06 +00003947 GEN_ERROR("GetElementPtr requires a pointer operand!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003948
Reid Spencera132e042006-12-03 05:46:11 +00003949 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
3950 // indices to uint struct indices for compatibility.
3951 generic_gep_type_iterator<std::vector<Value*>::iterator>
3952 GTI = gep_type_begin((yyvsp[-2].ConstVal)->getType(), (yyvsp[-1].ValueList)->begin(), (yyvsp[-1].ValueList)->end()),
3953 GTE = gep_type_end((yyvsp[-2].ConstVal)->getType(), (yyvsp[-1].ValueList)->begin(), (yyvsp[-1].ValueList)->end());
3954 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e && GTI != GTE; ++i, ++GTI)
3955 if (isa<StructType>(*GTI)) // Only change struct indices
3956 if (ConstantInt *CUI = dyn_cast<ConstantInt>((*(yyvsp[-1].ValueList))[i]))
3957 if (CUI->getType() == Type::UByteTy)
3958 (*(yyvsp[-1].ValueList))[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
3959
3960 const Type *IdxTy =
3961 GetElementPtrInst::getIndexedType((yyvsp[-2].ConstVal)->getType(), *(yyvsp[-1].ValueList), true);
3962 if (!IdxTy)
3963 GEN_ERROR("Index list invalid for constant getelementptr!");
3964
3965 std::vector<Constant*> IdxVec;
3966 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e; ++i)
3967 if (Constant *C = dyn_cast<Constant>((*(yyvsp[-1].ValueList))[i]))
Reid Spencer68a24bd2005-08-27 18:50:39 +00003968 IdxVec.push_back(C);
3969 else
Reid Spencer61c83e02006-08-18 08:43:06 +00003970 GEN_ERROR("Indices to constant getelementptr must be constants!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003971
Reid Spencer3822ff52006-11-08 06:47:33 +00003972 delete (yyvsp[-1].ValueList);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003973
Reid Spencera132e042006-12-03 05:46:11 +00003974 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal), IdxVec);
Reid Spencer61c83e02006-08-18 08:43:06 +00003975 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003976 ;}
3977 break;
3978
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003979 case 158:
3980#line 1661 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003981 {
Reid Spencera132e042006-12-03 05:46:11 +00003982 if ((yyvsp[-5].ConstVal)->getType() != Type::BoolTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00003983 GEN_ERROR("Select condition must be of boolean type!");
Reid Spencera132e042006-12-03 05:46:11 +00003984 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003985 GEN_ERROR("Select operand types must match!");
Reid Spencera132e042006-12-03 05:46:11 +00003986 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003987 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003988 ;}
3989 break;
3990
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003991 case 159:
3992#line 1669 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003993 {
Reid Spencera132e042006-12-03 05:46:11 +00003994 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003995 GEN_ERROR("Binary operator types must match!");
Reid Spencer1628cec2006-10-26 06:15:43 +00003996 CHECK_FOR_ERROR;
3997
Reid Spencer68a24bd2005-08-27 18:50:39 +00003998 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
3999 // To retain backward compatibility with these early compilers, we emit a
4000 // cast to the appropriate integer type automatically if we are in the
4001 // broken case. See PR424 for more information.
Reid Spencera132e042006-12-03 05:46:11 +00004002 if (!isa<PointerType>((yyvsp[-3].ConstVal)->getType())) {
4003 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004004 } else {
4005 const Type *IntPtrTy = 0;
4006 switch (CurModule.CurrentModule->getPointerSize()) {
4007 case Module::Pointer32: IntPtrTy = Type::IntTy; break;
4008 case Module::Pointer64: IntPtrTy = Type::LongTy; break;
Reid Spencer61c83e02006-08-18 08:43:06 +00004009 default: GEN_ERROR("invalid pointer binary constant expr!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004010 }
Reid Spencera132e042006-12-03 05:46:11 +00004011 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), ConstantExpr::getCast((yyvsp[-3].ConstVal), IntPtrTy),
4012 ConstantExpr::getCast((yyvsp[-1].ConstVal), IntPtrTy));
4013 (yyval.ConstVal) = ConstantExpr::getCast((yyval.ConstVal), (yyvsp[-3].ConstVal)->getType());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004014 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004015 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004016 ;}
4017 break;
4018
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004019 case 160:
4020#line 1693 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004021 {
Reid Spencera132e042006-12-03 05:46:11 +00004022 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00004023 GEN_ERROR("Logical operator types must match!");
Reid Spencera132e042006-12-03 05:46:11 +00004024 if (!(yyvsp[-3].ConstVal)->getType()->isIntegral()) {
4025 if (!isa<PackedType>((yyvsp[-3].ConstVal)->getType()) ||
4026 !cast<PackedType>((yyvsp[-3].ConstVal)->getType())->getElementType()->isIntegral())
Reid Spencer61c83e02006-08-18 08:43:06 +00004027 GEN_ERROR("Logical operator requires integral operands!");
Chris Lattner524a1312005-12-21 18:31:50 +00004028 }
Reid Spencera132e042006-12-03 05:46:11 +00004029 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004030 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004031 ;}
4032 break;
4033
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004034 case 161:
4035#line 1704 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004036 {
Reid Spencera132e042006-12-03 05:46:11 +00004037 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencer1628cec2006-10-26 06:15:43 +00004038 GEN_ERROR("setcc operand types must match!");
Reid Spencera132e042006-12-03 05:46:11 +00004039 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer1628cec2006-10-26 06:15:43 +00004040 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004041 ;}
4042 break;
4043
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004044 case 162:
4045#line 1710 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004046 {
Reid Spencera132e042006-12-03 05:46:11 +00004047 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
4048 GEN_ERROR("icmp operand types must match!");
4049 (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[-5].IPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
4050 ;}
4051 break;
4052
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004053 case 163:
4054#line 1715 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencera132e042006-12-03 05:46:11 +00004055 {
4056 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
4057 GEN_ERROR("fcmp operand types must match!");
4058 (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[-5].FPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
4059 ;}
4060 break;
4061
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004062 case 164:
4063#line 1720 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencera132e042006-12-03 05:46:11 +00004064 {
4065 if ((yyvsp[-1].ConstVal)->getType() != Type::UByteTy)
Reid Spencer1628cec2006-10-26 06:15:43 +00004066 GEN_ERROR("Shift count for shift constant must be unsigned byte!");
Reid Spencera132e042006-12-03 05:46:11 +00004067 if (!(yyvsp[-3].ConstVal)->getType()->isInteger())
Reid Spencer1628cec2006-10-26 06:15:43 +00004068 GEN_ERROR("Shift constant expression requires integer operand!");
Reid Spencer3822ff52006-11-08 06:47:33 +00004069 CHECK_FOR_ERROR;
Reid Spencera132e042006-12-03 05:46:11 +00004070 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].OtherOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer1628cec2006-10-26 06:15:43 +00004071 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004072 ;}
4073 break;
4074
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004075 case 165:
4076#line 1729 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004077 {
Reid Spencera132e042006-12-03 05:46:11 +00004078 if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00004079 GEN_ERROR("Invalid extractelement operands!");
Reid Spencera132e042006-12-03 05:46:11 +00004080 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004081 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004082 ;}
4083 break;
4084
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004085 case 166:
4086#line 1735 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004087 {
Reid Spencera132e042006-12-03 05:46:11 +00004088 if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00004089 GEN_ERROR("Invalid insertelement operands!");
Reid Spencera132e042006-12-03 05:46:11 +00004090 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004091 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004092 ;}
4093 break;
4094
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004095 case 167:
4096#line 1741 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004097 {
Reid Spencera132e042006-12-03 05:46:11 +00004098 if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00004099 GEN_ERROR("Invalid shufflevector operands!");
Reid Spencera132e042006-12-03 05:46:11 +00004100 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004101 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004102 ;}
4103 break;
4104
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004105 case 168:
4106#line 1750 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004107 {
4108 ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004109 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004110 ;}
4111 break;
4112
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004113 case 169:
4114#line 1754 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004115 {
Reid Spencera132e042006-12-03 05:46:11 +00004116 (yyval.ConstVector) = new std::vector<Constant*>();
Reid Spencer3822ff52006-11-08 06:47:33 +00004117 (yyval.ConstVector)->push_back((yyvsp[0].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004118 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004119 ;}
4120 break;
4121
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004122 case 170:
4123#line 1762 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004124 { (yyval.BoolVal) = false; ;}
4125 break;
4126
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004127 case 171:
4128#line 1762 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004129 { (yyval.BoolVal) = true; ;}
4130 break;
4131
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004132 case 172:
4133#line 1772 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004134 {
4135 (yyval.ModuleVal) = ParserResult = (yyvsp[0].ModuleVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004136 CurModule.ModuleDone();
Reid Spencerf63697d2006-10-09 17:36:59 +00004137 CHECK_FOR_ERROR;
Reid Spencer3822ff52006-11-08 06:47:33 +00004138;}
4139 break;
4140
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004141 case 173:
4142#line 1780 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004143 {
4144 (yyval.ModuleVal) = (yyvsp[-1].ModuleVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004145 CurFun.FunctionDone();
Reid Spencer61c83e02006-08-18 08:43:06 +00004146 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004147 ;}
4148 break;
4149
Reid Spencera132e042006-12-03 05:46:11 +00004150 case 174:
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004151#line 1785 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004152 {
4153 (yyval.ModuleVal) = (yyvsp[-1].ModuleVal);
Reid Spencer3ed469c2006-11-02 20:25:50 +00004154 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004155 ;}
4156 break;
4157
Reid Spencera132e042006-12-03 05:46:11 +00004158 case 175:
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004159#line 1789 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4160 {
4161 (yyval.ModuleVal) = (yyvsp[-3].ModuleVal);
4162 CHECK_FOR_ERROR
4163 ;}
4164 break;
4165
4166 case 176:
4167#line 1793 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4168 {
4169 (yyval.ModuleVal) = (yyvsp[-1].ModuleVal);
4170 CHECK_FOR_ERROR
4171 ;}
4172 break;
4173
4174 case 177:
4175#line 1797 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004176 {
4177 (yyval.ModuleVal) = CurModule.CurrentModule;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004178 // Emit an error if there are any unresolved types left.
4179 if (!CurModule.LateResolveTypes.empty()) {
4180 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
Reid Spencer61c83e02006-08-18 08:43:06 +00004181 if (DID.Type == ValID::NameVal) {
4182 GEN_ERROR("Reference to an undefined type: '"+DID.getName() + "'");
4183 } else {
4184 GEN_ERROR("Reference to an undefined type: #" + itostr(DID.Num));
4185 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004186 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004187 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004188 ;}
4189 break;
4190
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004191 case 178:
4192#line 1812 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004193 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004194 // Eagerly resolve types. This is not an optimization, this is a
4195 // requirement that is due to the fact that we could have this:
4196 //
4197 // %list = type { %list * }
4198 // %list = type { %list * } ; repeated type decl
4199 //
4200 // If types are not resolved eagerly, then the two types will not be
4201 // determined to be the same type!
4202 //
Reid Spencera132e042006-12-03 05:46:11 +00004203 ResolveTypeTo((yyvsp[-2].StrVal), *(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004204
Reid Spencera132e042006-12-03 05:46:11 +00004205 if (!setTypeName(*(yyvsp[0].TypeVal), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00004206 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004207 // If this is a named type that is not a redefinition, add it to the slot
4208 // table.
Reid Spencera132e042006-12-03 05:46:11 +00004209 CurModule.Types.push_back(*(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004210 }
Reid Spencera132e042006-12-03 05:46:11 +00004211
4212 delete (yyvsp[0].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004213 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004214 ;}
4215 break;
4216
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004217 case 179:
4218#line 1834 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004219 { // Function prototypes can be in const pool
Reid Spencer61c83e02006-08-18 08:43:06 +00004220 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004221 ;}
4222 break;
4223
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004224 case 180:
4225#line 1837 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004226 { // Asm blocks can be in the const pool
Reid Spencer61c83e02006-08-18 08:43:06 +00004227 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004228 ;}
4229 break;
4230
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004231 case 181:
4232#line 1840 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004233 {
Reid Spencera132e042006-12-03 05:46:11 +00004234 if ((yyvsp[0].ConstVal) == 0)
Reid Spencer5b7e7532006-09-28 19:28:24 +00004235 GEN_ERROR("Global value initializer is not a constant!");
Reid Spencera132e042006-12-03 05:46:11 +00004236 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), (yyvsp[-2].Linkage), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal)->getType(), (yyvsp[0].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004237 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004238 ;}
4239 break;
4240
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004241 case 182:
4242#line 1845 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004243 {
Reid Spencer5b7e7532006-09-28 19:28:24 +00004244 CurGV = 0;
Reid Spencer3822ff52006-11-08 06:47:33 +00004245 ;}
4246 break;
4247
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004248 case 183:
4249#line 1848 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004250 {
Reid Spencera132e042006-12-03 05:46:11 +00004251 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage, (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0);
Reid Spencer5b7e7532006-09-28 19:28:24 +00004252 CHECK_FOR_ERROR
Reid Spencera132e042006-12-03 05:46:11 +00004253 delete (yyvsp[0].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00004254 ;}
4255 break;
4256
Reid Spencera132e042006-12-03 05:46:11 +00004257 case 184:
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004258#line 1852 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004259 {
Reid Spencer3ed469c2006-11-02 20:25:50 +00004260 CurGV = 0;
4261 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004262 ;}
4263 break;
4264
Reid Spencera132e042006-12-03 05:46:11 +00004265 case 185:
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004266#line 1856 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4267 {
4268 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0);
4269 CHECK_FOR_ERROR
4270 delete (yyvsp[0].TypeVal);
4271 ;}
4272 break;
4273
4274 case 186:
4275#line 1860 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4276 {
4277 CurGV = 0;
4278 CHECK_FOR_ERROR
4279 ;}
4280 break;
4281
4282 case 187:
4283#line 1864 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004284 {
Reid Spencer5b7e7532006-09-28 19:28:24 +00004285 CurGV =
Reid Spencera132e042006-12-03 05:46:11 +00004286 ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0);
Reid Spencer5b7e7532006-09-28 19:28:24 +00004287 CHECK_FOR_ERROR
Reid Spencera132e042006-12-03 05:46:11 +00004288 delete (yyvsp[0].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00004289 ;}
4290 break;
4291
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004292 case 188:
4293#line 1869 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004294 {
Anton Korobeynikovbcb97702006-09-17 20:25:45 +00004295 CurGV = 0;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004296 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004297 ;}
4298 break;
4299
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004300 case 189:
4301#line 1873 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004302 {
Anton Korobeynikovbcb97702006-09-17 20:25:45 +00004303 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004304 ;}
4305 break;
4306
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004307 case 190:
4308#line 1876 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004309 {
Anton Korobeynikovbcb97702006-09-17 20:25:45 +00004310 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004311 ;}
4312 break;
4313
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004314 case 191:
4315#line 1879 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004316 {
4317 ;}
4318 break;
4319
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004320 case 192:
4321#line 1883 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004322 {
Chris Lattner66316012006-01-24 04:14:29 +00004323 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Reid Spencer3822ff52006-11-08 06:47:33 +00004324 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4325 std::string NewAsm((yyvsp[0].StrVal), EndStr);
4326 free((yyvsp[0].StrVal));
Chris Lattner66316012006-01-24 04:14:29 +00004327
4328 if (AsmSoFar.empty())
4329 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
4330 else
4331 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Reid Spencer61c83e02006-08-18 08:43:06 +00004332 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004333;}
4334 break;
4335
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004336 case 193:
4337#line 1896 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004338 { (yyval.Endianness) = Module::BigEndian; ;}
4339 break;
4340
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004341 case 194:
4342#line 1897 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004343 { (yyval.Endianness) = Module::LittleEndian; ;}
4344 break;
4345
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004346 case 195:
4347#line 1899 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004348 {
4349 CurModule.CurrentModule->setEndianness((yyvsp[0].Endianness));
Reid Spencer61c83e02006-08-18 08:43:06 +00004350 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004351 ;}
4352 break;
4353
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004354 case 196:
4355#line 1903 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004356 {
4357 if ((yyvsp[0].UInt64Val) == 32)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004358 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
Reid Spencer3822ff52006-11-08 06:47:33 +00004359 else if ((yyvsp[0].UInt64Val) == 64)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004360 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
4361 else
Reid Spencer3822ff52006-11-08 06:47:33 +00004362 GEN_ERROR("Invalid pointer size: '" + utostr((yyvsp[0].UInt64Val)) + "'!");
Reid Spencer61c83e02006-08-18 08:43:06 +00004363 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004364 ;}
4365 break;
4366
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004367 case 197:
4368#line 1912 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004369 {
4370 CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal));
4371 free((yyvsp[0].StrVal));
4372 ;}
4373 break;
4374
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004375 case 198:
4376#line 1916 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004377 {
4378 CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal));
4379 free((yyvsp[0].StrVal));
4380 ;}
4381 break;
4382
Reid Spencera132e042006-12-03 05:46:11 +00004383 case 200:
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004384#line 1923 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4385 {
4386 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4387 free((yyvsp[0].StrVal));
4388 CHECK_FOR_ERROR
4389 ;}
4390 break;
4391
4392 case 201:
4393#line 1928 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4394 {
4395 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4396 free((yyvsp[0].StrVal));
4397 CHECK_FOR_ERROR
4398 ;}
4399 break;
4400
4401 case 202:
4402#line 1933 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004403 {
Reid Spencer61c83e02006-08-18 08:43:06 +00004404 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004405 ;}
4406 break;
4407
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004408 case 206:
4409#line 1943 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004410 { (yyval.StrVal) = 0; ;}
4411 break;
4412
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004413 case 207:
4414#line 1945 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004415 {
Reid Spencera132e042006-12-03 05:46:11 +00004416 if (*(yyvsp[-1].TypeVal) == Type::VoidTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00004417 GEN_ERROR("void typed arguments are invalid!");
Reid Spencera132e042006-12-03 05:46:11 +00004418 (yyval.ArgVal) = new std::pair<PATypeHolder*, char*>((yyvsp[-1].TypeVal), (yyvsp[0].StrVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004419 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004420;}
4421 break;
4422
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004423 case 208:
4424#line 1952 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004425 {
4426 (yyval.ArgList) = (yyvsp[-2].ArgList);
4427 (yyvsp[-2].ArgList)->push_back(*(yyvsp[0].ArgVal));
4428 delete (yyvsp[0].ArgVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004429 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004430 ;}
4431 break;
4432
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004433 case 209:
4434#line 1958 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004435 {
Reid Spencera132e042006-12-03 05:46:11 +00004436 (yyval.ArgList) = new std::vector<std::pair<PATypeHolder*,char*> >();
Reid Spencer3822ff52006-11-08 06:47:33 +00004437 (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal));
4438 delete (yyvsp[0].ArgVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004439 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004440 ;}
4441 break;
4442
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004443 case 210:
4444#line 1965 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004445 {
4446 (yyval.ArgList) = (yyvsp[0].ArgList);
Reid Spencer61c83e02006-08-18 08:43:06 +00004447 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004448 ;}
4449 break;
4450
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004451 case 211:
4452#line 1969 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004453 {
4454 (yyval.ArgList) = (yyvsp[-2].ArgList);
Reid Spencera132e042006-12-03 05:46:11 +00004455 (yyval.ArgList)->push_back(std::pair<PATypeHolder*,
4456 char*>(new PATypeHolder(Type::VoidTy), 0));
Reid Spencer61c83e02006-08-18 08:43:06 +00004457 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004458 ;}
4459 break;
4460
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004461 case 212:
4462#line 1975 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004463 {
Reid Spencera132e042006-12-03 05:46:11 +00004464 (yyval.ArgList) = new std::vector<std::pair<PATypeHolder*,char*> >();
4465 (yyval.ArgList)->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0));
Reid Spencer61c83e02006-08-18 08:43:06 +00004466 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004467 ;}
4468 break;
4469
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004470 case 213:
4471#line 1980 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004472 {
4473 (yyval.ArgList) = 0;
Reid Spencer61c83e02006-08-18 08:43:06 +00004474 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004475 ;}
4476 break;
4477
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004478 case 214:
4479#line 1986 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004480 {
4481 UnEscapeLexed((yyvsp[-5].StrVal));
4482 std::string FunctionName((yyvsp[-5].StrVal));
4483 free((yyvsp[-5].StrVal)); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004484
Reid Spencera132e042006-12-03 05:46:11 +00004485 if (!(*(yyvsp[-6].TypeVal))->isFirstClassType() && *(yyvsp[-6].TypeVal) != Type::VoidTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00004486 GEN_ERROR("LLVM functions cannot return aggregate types!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004487
4488 std::vector<const Type*> ParamTypeList;
Reid Spencer3822ff52006-11-08 06:47:33 +00004489 if ((yyvsp[-3].ArgList)) { // If there are arguments...
Reid Spencera132e042006-12-03 05:46:11 +00004490 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = (yyvsp[-3].ArgList)->begin();
Reid Spencer3822ff52006-11-08 06:47:33 +00004491 I != (yyvsp[-3].ArgList)->end(); ++I)
Reid Spencera132e042006-12-03 05:46:11 +00004492 ParamTypeList.push_back(I->first->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004493 }
4494
4495 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
4496 if (isVarArg) ParamTypeList.pop_back();
4497
Reid Spencera132e042006-12-03 05:46:11 +00004498 const FunctionType *FT = FunctionType::get(*(yyvsp[-6].TypeVal), ParamTypeList, isVarArg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004499 const PointerType *PFT = PointerType::get(FT);
Reid Spencera132e042006-12-03 05:46:11 +00004500 delete (yyvsp[-6].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004501
4502 ValID ID;
4503 if (!FunctionName.empty()) {
4504 ID = ValID::create((char*)FunctionName.c_str());
4505 } else {
4506 ID = ValID::create((int)CurModule.Values[PFT].size());
4507 }
4508
4509 Function *Fn = 0;
4510 // See if this function was forward referenced. If so, recycle the object.
4511 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4512 // Move the function to the end of the list, from whereever it was
4513 // previously inserted.
4514 Fn = cast<Function>(FWRef);
4515 CurModule.CurrentModule->getFunctionList().remove(Fn);
4516 CurModule.CurrentModule->getFunctionList().push_back(Fn);
4517 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
4518 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
4519 // If this is the case, either we need to be a forward decl, or it needs
4520 // to be.
4521 if (!CurFun.isDeclare && !Fn->isExternal())
Reid Spencer61c83e02006-08-18 08:43:06 +00004522 GEN_ERROR("Redefinition of function '" + FunctionName + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004523
4524 // Make sure to strip off any argument names so we can't get conflicts.
4525 if (Fn->isExternal())
4526 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
4527 AI != AE; ++AI)
4528 AI->setName("");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004529 } else { // Not already defined?
4530 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
4531 CurModule.CurrentModule);
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004532
Reid Spencer68a24bd2005-08-27 18:50:39 +00004533 InsertValue(Fn, CurModule.Values);
4534 }
4535
4536 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004537
4538 if (CurFun.isDeclare) {
4539 // If we have declaration, always overwrite linkage. This will allow us to
4540 // correctly handle cases, when pointer to function is passed as argument to
4541 // another function.
4542 Fn->setLinkage(CurFun.Linkage);
4543 }
Reid Spencer3822ff52006-11-08 06:47:33 +00004544 Fn->setCallingConv((yyvsp[-7].UIntVal));
4545 Fn->setAlignment((yyvsp[0].UIntVal));
4546 if ((yyvsp[-1].StrVal)) {
4547 Fn->setSection((yyvsp[-1].StrVal));
4548 free((yyvsp[-1].StrVal));
Chris Lattnere869eef2005-11-12 00:11:49 +00004549 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004550
4551 // Add all of the arguments we parsed to the function...
Reid Spencer3822ff52006-11-08 06:47:33 +00004552 if ((yyvsp[-3].ArgList)) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00004553 if (isVarArg) { // Nuke the last entry
Reid Spencera132e042006-12-03 05:46:11 +00004554 assert((yyvsp[-3].ArgList)->back().first->get() == Type::VoidTy && (yyvsp[-3].ArgList)->back().second == 0&&
4555 "Not a varargs marker!");
4556 delete (yyvsp[-3].ArgList)->back().first;
Reid Spencer3822ff52006-11-08 06:47:33 +00004557 (yyvsp[-3].ArgList)->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00004558 }
4559 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spencera132e042006-12-03 05:46:11 +00004560 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = (yyvsp[-3].ArgList)->begin();
Reid Spencer3822ff52006-11-08 06:47:33 +00004561 I != (yyvsp[-3].ArgList)->end(); ++I, ++ArgIt) {
Reid Spencera132e042006-12-03 05:46:11 +00004562 delete I->first; // Delete the typeholder...
4563
Reid Spencer68a24bd2005-08-27 18:50:39 +00004564 setValueName(ArgIt, I->second); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00004565 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004566 InsertValue(ArgIt);
4567 }
Reid Spencera132e042006-12-03 05:46:11 +00004568
Reid Spencer3822ff52006-11-08 06:47:33 +00004569 delete (yyvsp[-3].ArgList); // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00004570 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004571 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004572;}
4573 break;
4574
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004575 case 217:
4576#line 2082 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004577 {
4578 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004579
4580 // Make sure that we keep track of the linkage type even if there was a
4581 // previous "declare".
Reid Spencer3822ff52006-11-08 06:47:33 +00004582 (yyval.FunctionVal)->setLinkage((yyvsp[-2].Linkage));
4583;}
4584 break;
4585
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004586 case 220:
4587#line 2092 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004588 {
4589 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004590 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004591;}
4592 break;
4593
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004594 case 222:
4595#line 2098 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004596 { CurFun.Linkage = GlobalValue::DLLImportLinkage; ;}
4597 break;
4598
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004599 case 223:
4600#line 2099 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer481169e2006-12-01 00:33:46 +00004601 { CurFun.Linkage = GlobalValue::ExternalWeakLinkage; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00004602 break;
4603
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004604 case 224:
4605#line 2101 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004606 { CurFun.isDeclare = true; ;}
4607 break;
4608
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004609 case 225:
4610#line 2101 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004611 {
4612 (yyval.FunctionVal) = CurFun.CurrentFunction;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004613 CurFun.FunctionDone();
Reid Spencer61c83e02006-08-18 08:43:06 +00004614 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004615 ;}
4616 break;
4617
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004618 case 226:
4619#line 2111 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004620 {
4621 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00004622 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004623 ;}
4624 break;
4625
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004626 case 227:
4627#line 2115 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004628 {
4629 (yyval.BoolVal) = true;
Reid Spencer61c83e02006-08-18 08:43:06 +00004630 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004631 ;}
4632 break;
4633
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004634 case 228:
4635#line 2120 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004636 { // A reference to a direct constant
4637 (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val));
Reid Spencer61c83e02006-08-18 08:43:06 +00004638 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004639 ;}
4640 break;
4641
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004642 case 229:
4643#line 2124 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004644 {
4645 (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val));
Reid Spencer61c83e02006-08-18 08:43:06 +00004646 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004647 ;}
4648 break;
4649
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004650 case 230:
4651#line 2128 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004652 { // Perhaps it's an FP constant?
4653 (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004654 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004655 ;}
4656 break;
4657
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004658 case 231:
4659#line 2132 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004660 {
4661 (yyval.ValIDVal) = ValID::create(ConstantBool::getTrue());
Reid Spencer61c83e02006-08-18 08:43:06 +00004662 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004663 ;}
4664 break;
4665
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004666 case 232:
4667#line 2136 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004668 {
4669 (yyval.ValIDVal) = ValID::create(ConstantBool::getFalse());
Reid Spencer61c83e02006-08-18 08:43:06 +00004670 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004671 ;}
4672 break;
4673
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004674 case 233:
4675#line 2140 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004676 {
4677 (yyval.ValIDVal) = ValID::createNull();
Reid Spencer61c83e02006-08-18 08:43:06 +00004678 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004679 ;}
4680 break;
4681
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004682 case 234:
4683#line 2144 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004684 {
4685 (yyval.ValIDVal) = ValID::createUndef();
Reid Spencer61c83e02006-08-18 08:43:06 +00004686 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004687 ;}
4688 break;
4689
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004690 case 235:
4691#line 2148 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004692 { // A vector zero constant.
4693 (yyval.ValIDVal) = ValID::createZeroInit();
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004694 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004695 ;}
4696 break;
4697
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004698 case 236:
4699#line 2152 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004700 { // Nonempty unsized packed vector
Reid Spencera132e042006-12-03 05:46:11 +00004701 const Type *ETy = (*(yyvsp[-1].ConstVector))[0]->getType();
Reid Spencer3822ff52006-11-08 06:47:33 +00004702 int NumElements = (yyvsp[-1].ConstVector)->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004703
4704 PackedType* pt = PackedType::get(ETy, NumElements);
4705 PATypeHolder* PTy = new PATypeHolder(
Reid Spencera132e042006-12-03 05:46:11 +00004706 HandleUpRefs(
4707 PackedType::get(
4708 ETy,
4709 NumElements)
4710 )
4711 );
Reid Spencer68a24bd2005-08-27 18:50:39 +00004712
4713 // Verify all elements are correct type!
Reid Spencer3822ff52006-11-08 06:47:33 +00004714 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
Reid Spencera132e042006-12-03 05:46:11 +00004715 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00004716 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00004717 ETy->getDescription() +"' as required!\nIt is of type '" +
Reid Spencera132e042006-12-03 05:46:11 +00004718 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004719 }
4720
Reid Spencera132e042006-12-03 05:46:11 +00004721 (yyval.ValIDVal) = ValID::create(ConstantPacked::get(pt, *(yyvsp[-1].ConstVector)));
Reid Spencer3822ff52006-11-08 06:47:33 +00004722 delete PTy; delete (yyvsp[-1].ConstVector);
Reid Spencer61c83e02006-08-18 08:43:06 +00004723 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004724 ;}
4725 break;
Reid Spencer21be8652006-10-22 07:03:43 +00004726
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004727 case 237:
4728#line 2177 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004729 {
Reid Spencera132e042006-12-03 05:46:11 +00004730 (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal));
Reid Spencer21be8652006-10-22 07:03:43 +00004731 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004732 ;}
4733 break;
4734
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004735 case 238:
4736#line 2181 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004737 {
4738 char *End = UnEscapeLexed((yyvsp[-2].StrVal), true);
4739 std::string AsmStr = std::string((yyvsp[-2].StrVal), End);
4740 End = UnEscapeLexed((yyvsp[0].StrVal), true);
4741 std::string Constraints = std::string((yyvsp[0].StrVal), End);
4742 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal));
4743 free((yyvsp[-2].StrVal));
4744 free((yyvsp[0].StrVal));
Reid Spencer21be8652006-10-22 07:03:43 +00004745 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004746 ;}
4747 break;
4748
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004749 case 239:
4750#line 2195 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004751 { // Is it an integer reference...?
4752 (yyval.ValIDVal) = ValID::create((yyvsp[0].SIntVal));
4753 CHECK_FOR_ERROR
4754 ;}
4755 break;
4756
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004757 case 240:
4758#line 2199 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004759 { // Is it a named reference...?
4760 (yyval.ValIDVal) = ValID::create((yyvsp[0].StrVal));
4761 CHECK_FOR_ERROR
4762 ;}
4763 break;
4764
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004765 case 243:
4766#line 2211 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004767 {
Reid Spencera132e042006-12-03 05:46:11 +00004768 (yyval.ValueVal) = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal)); delete (yyvsp[-1].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00004769 CHECK_FOR_ERROR
4770 ;}
4771 break;
4772
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004773 case 244:
4774#line 2216 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004775 {
4776 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
4777 CHECK_FOR_ERROR
4778 ;}
4779 break;
4780
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004781 case 245:
4782#line 2220 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004783 { // Do not allow functions with 0 basic blocks
4784 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
4785 CHECK_FOR_ERROR
4786 ;}
4787 break;
4788
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004789 case 246:
4790#line 2229 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004791 {
4792 setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal));
4793 CHECK_FOR_ERROR
4794 InsertValue((yyvsp[0].TermInstVal));
4795
4796 (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal));
4797 InsertValue((yyvsp[-2].BasicBlockVal));
4798 (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal);
4799 CHECK_FOR_ERROR
4800 ;}
4801 break;
4802
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004803 case 247:
4804#line 2240 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004805 {
Reid Spencer3da59db2006-11-27 01:05:10 +00004806 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[0].InstVal)))
4807 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
4808 if (CI2->getParent() == 0)
4809 (yyvsp[-1].BasicBlockVal)->getInstList().push_back(CI2);
Reid Spencer3822ff52006-11-08 06:47:33 +00004810 (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal));
4811 (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal);
4812 CHECK_FOR_ERROR
4813 ;}
4814 break;
4815
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004816 case 248:
4817#line 2249 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004818 {
4819 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
Reid Spencer5b7e7532006-09-28 19:28:24 +00004820 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004821
4822 // Make sure to move the basic block to the correct location in the
4823 // function, instead of leaving it inserted wherever it was first
4824 // referenced.
4825 Function::BasicBlockListType &BBL =
4826 CurFun.CurrentFunction->getBasicBlockList();
Reid Spencer3822ff52006-11-08 06:47:33 +00004827 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004828 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004829 ;}
4830 break;
4831
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004832 case 249:
4833#line 2261 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004834 {
4835 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[0].StrVal)), true);
Reid Spencer5b7e7532006-09-28 19:28:24 +00004836 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004837
4838 // Make sure to move the basic block to the correct location in the
4839 // function, instead of leaving it inserted wherever it was first
4840 // referenced.
4841 Function::BasicBlockListType &BBL =
4842 CurFun.CurrentFunction->getBasicBlockList();
Reid Spencer3822ff52006-11-08 06:47:33 +00004843 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004844 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004845 ;}
4846 break;
Reid Spencer61c83e02006-08-18 08:43:06 +00004847
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004848 case 250:
4849#line 2274 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004850 { // Return with a result...
Reid Spencera132e042006-12-03 05:46:11 +00004851 (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal));
Reid Spencer3822ff52006-11-08 06:47:33 +00004852 CHECK_FOR_ERROR
4853 ;}
4854 break;
4855
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004856 case 251:
4857#line 2278 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004858 { // Return with no result...
4859 (yyval.TermInstVal) = new ReturnInst();
4860 CHECK_FOR_ERROR
4861 ;}
4862 break;
4863
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004864 case 252:
4865#line 2282 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004866 { // Unconditional Branch...
4867 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
4868 CHECK_FOR_ERROR
4869 (yyval.TermInstVal) = new BranchInst(tmpBB);
4870 ;}
4871 break;
4872
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004873 case 253:
4874#line 2287 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004875 {
4876 BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal));
4877 CHECK_FOR_ERROR
4878 BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal));
4879 CHECK_FOR_ERROR
4880 Value* tmpVal = getVal(Type::BoolTy, (yyvsp[-6].ValIDVal));
4881 CHECK_FOR_ERROR
4882 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
4883 ;}
4884 break;
4885
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004886 case 254:
4887#line 2296 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004888 {
Reid Spencera132e042006-12-03 05:46:11 +00004889 Value* tmpVal = getVal((yyvsp[-7].PrimType), (yyvsp[-6].ValIDVal));
Reid Spencer3822ff52006-11-08 06:47:33 +00004890 CHECK_FOR_ERROR
4891 BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal));
4892 CHECK_FOR_ERROR
4893 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size());
4894 (yyval.TermInstVal) = S;
4895
4896 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(),
4897 E = (yyvsp[-1].JumpTable)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004898 for (; I != E; ++I) {
4899 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
4900 S->addCase(CI, I->second);
4901 else
Reid Spencer61c83e02006-08-18 08:43:06 +00004902 GEN_ERROR("Switch case is constant, but not a simple integer!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004903 }
Reid Spencer3822ff52006-11-08 06:47:33 +00004904 delete (yyvsp[-1].JumpTable);
Reid Spencer61c83e02006-08-18 08:43:06 +00004905 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004906 ;}
4907 break;
4908
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004909 case 255:
4910#line 2315 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004911 {
Reid Spencera132e042006-12-03 05:46:11 +00004912 Value* tmpVal = getVal((yyvsp[-6].PrimType), (yyvsp[-5].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004913 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004914 BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004915 CHECK_FOR_ERROR
4916 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Reid Spencer3822ff52006-11-08 06:47:33 +00004917 (yyval.TermInstVal) = S;
Reid Spencer61c83e02006-08-18 08:43:06 +00004918 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004919 ;}
4920 break;
4921
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004922 case 256:
4923#line 2325 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004924 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004925 const PointerType *PFTy;
4926 const FunctionType *Ty;
4927
Reid Spencera132e042006-12-03 05:46:11 +00004928 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-10].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00004929 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4930 // Pull out the types of all of the arguments...
4931 std::vector<const Type*> ParamTypes;
Reid Spencer3822ff52006-11-08 06:47:33 +00004932 if ((yyvsp[-7].ValueList)) {
Reid Spencera132e042006-12-03 05:46:11 +00004933 for (std::vector<Value*>::iterator I = (yyvsp[-7].ValueList)->begin(), E = (yyvsp[-7].ValueList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004934 I != E; ++I)
Reid Spencera132e042006-12-03 05:46:11 +00004935 ParamTypes.push_back((*I)->getType());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004936 }
4937
4938 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
4939 if (isVarArg) ParamTypes.pop_back();
4940
Reid Spencera132e042006-12-03 05:46:11 +00004941 Ty = FunctionType::get((yyvsp[-10].TypeVal)->get(), ParamTypes, isVarArg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004942 PFTy = PointerType::get(Ty);
4943 }
4944
Reid Spencer3822ff52006-11-08 06:47:33 +00004945 Value *V = getVal(PFTy, (yyvsp[-9].ValIDVal)); // Get the function we're calling...
Reid Spencer5b7e7532006-09-28 19:28:24 +00004946 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004947 BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004948 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004949 BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004950 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004951
4952 // Create the call node...
Reid Spencer3822ff52006-11-08 06:47:33 +00004953 if (!(yyvsp[-7].ValueList)) { // Has no arguments?
4954 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, std::vector<Value*>());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004955 } else { // Has arguments?
4956 // Loop through FunctionType's arguments and ensure they are specified
4957 // correctly!
4958 //
4959 FunctionType::param_iterator I = Ty->param_begin();
4960 FunctionType::param_iterator E = Ty->param_end();
Reid Spencera132e042006-12-03 05:46:11 +00004961 std::vector<Value*>::iterator ArgI = (yyvsp[-7].ValueList)->begin(), ArgE = (yyvsp[-7].ValueList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004962
Reid Spencera132e042006-12-03 05:46:11 +00004963 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
4964 if ((*ArgI)->getType() != *I)
4965 GEN_ERROR("Parameter " +(*ArgI)->getName()+ " is not of type '" +
4966 (*I)->getDescription() + "'!");
4967
4968 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
4969 GEN_ERROR("Invalid number of parameters detected!");
4970
4971 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, *(yyvsp[-7].ValueList));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004972 }
Reid Spencer3822ff52006-11-08 06:47:33 +00004973 cast<InvokeInst>((yyval.TermInstVal))->setCallingConv((yyvsp[-11].UIntVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004974
Reid Spencera132e042006-12-03 05:46:11 +00004975 delete (yyvsp[-10].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00004976 delete (yyvsp[-7].ValueList);
Reid Spencer61c83e02006-08-18 08:43:06 +00004977 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004978 ;}
4979 break;
4980
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004981 case 257:
4982#line 2380 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004983 {
4984 (yyval.TermInstVal) = new UnwindInst();
Reid Spencer61c83e02006-08-18 08:43:06 +00004985 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004986 ;}
4987 break;
4988
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004989 case 258:
4990#line 2384 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004991 {
4992 (yyval.TermInstVal) = new UnreachableInst();
Reid Spencer61c83e02006-08-18 08:43:06 +00004993 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004994 ;}
4995 break;
4996
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004997 case 259:
4998#line 2391 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004999 {
5000 (yyval.JumpTable) = (yyvsp[-5].JumpTable);
Reid Spencera132e042006-12-03 05:46:11 +00005001 Constant *V = cast<Constant>(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal)));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005002 CHECK_FOR_ERROR
Reid Spencer61c83e02006-08-18 08:43:06 +00005003 if (V == 0)
5004 GEN_ERROR("May only switch on a constant pool value!");
5005
Reid Spencer3822ff52006-11-08 06:47:33 +00005006 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005007 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005008 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5009 ;}
5010 break;
5011
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005012 case 260:
5013#line 2402 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005014 {
5015 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
Reid Spencera132e042006-12-03 05:46:11 +00005016 Constant *V = cast<Constant>(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal)));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005017 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005018
5019 if (V == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00005020 GEN_ERROR("May only switch on a constant pool value!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005021
Reid Spencer3822ff52006-11-08 06:47:33 +00005022 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005023 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005024 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5025 ;}
5026 break;
5027
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005028 case 261:
5029#line 2415 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005030 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00005031 // Is this definition named?? if so, assign the name...
Reid Spencer3822ff52006-11-08 06:47:33 +00005032 setValueName((yyvsp[0].InstVal), (yyvsp[-1].StrVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005033 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005034 InsertValue((yyvsp[0].InstVal));
5035 (yyval.InstVal) = (yyvsp[0].InstVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005036 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005037;}
5038 break;
5039
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005040 case 262:
5041#line 2424 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005042 { // Used for PHI nodes
5043 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
Reid Spencera132e042006-12-03 05:46:11 +00005044 Value* tmpVal = getVal(*(yyvsp[-5].TypeVal), (yyvsp[-3].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005045 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005046 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005047 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005048 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
Reid Spencera132e042006-12-03 05:46:11 +00005049 delete (yyvsp[-5].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00005050 ;}
5051 break;
5052
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005053 case 263:
5054#line 2433 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005055 {
5056 (yyval.PHIList) = (yyvsp[-6].PHIList);
5057 Value* tmpVal = getVal((yyvsp[-6].PHIList)->front().first->getType(), (yyvsp[-3].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005058 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005059 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005060 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005061 (yyvsp[-6].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5062 ;}
5063 break;
5064
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005065 case 264:
5066#line 2443 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005067 { // Used for call statements, and memory insts...
Reid Spencera132e042006-12-03 05:46:11 +00005068 (yyval.ValueList) = new std::vector<Value*>();
Reid Spencer3822ff52006-11-08 06:47:33 +00005069 (yyval.ValueList)->push_back((yyvsp[0].ValueVal));
5070 ;}
5071 break;
5072
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005073 case 265:
5074#line 2447 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005075 {
5076 (yyval.ValueList) = (yyvsp[-2].ValueList);
5077 (yyvsp[-2].ValueList)->push_back((yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005078 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005079 ;}
5080 break;
5081
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005082 case 267:
5083#line 2454 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencera132e042006-12-03 05:46:11 +00005084 { (yyval.ValueList) = 0; ;}
Reid Spencer861d9d62006-11-28 07:29:44 +00005085 break;
5086
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005087 case 268:
5088#line 2456 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005089 {
5090 (yyval.BoolVal) = true;
Reid Spencer61c83e02006-08-18 08:43:06 +00005091 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005092 ;}
5093 break;
5094
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005095 case 269:
5096#line 2460 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005097 {
5098 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00005099 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005100 ;}
5101 break;
5102
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005103 case 270:
5104#line 2465 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005105 {
Reid Spencera132e042006-12-03 05:46:11 +00005106 if (!(*(yyvsp[-3].TypeVal))->isInteger() && !(*(yyvsp[-3].TypeVal))->isFloatingPoint() &&
5107 !isa<PackedType>((*(yyvsp[-3].TypeVal)).get()))
Reid Spencer61c83e02006-08-18 08:43:06 +00005108 GEN_ERROR(
Reid Spencer68a24bd2005-08-27 18:50:39 +00005109 "Arithmetic operator requires integer, FP, or packed operands!");
Reid Spencera132e042006-12-03 05:46:11 +00005110 if (isa<PackedType>((*(yyvsp[-3].TypeVal)).get()) &&
5111 ((yyvsp[-4].BinaryOpVal) == Instruction::URem ||
5112 (yyvsp[-4].BinaryOpVal) == Instruction::SRem ||
5113 (yyvsp[-4].BinaryOpVal) == Instruction::FRem))
Reid Spencer3ed469c2006-11-02 20:25:50 +00005114 GEN_ERROR("U/S/FRem not supported on packed types!");
Reid Spencera132e042006-12-03 05:46:11 +00005115 Value* val1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005116 CHECK_FOR_ERROR
Reid Spencera132e042006-12-03 05:46:11 +00005117 Value* val2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005118 CHECK_FOR_ERROR
Reid Spencera132e042006-12-03 05:46:11 +00005119 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), val1, val2);
Reid Spencer3822ff52006-11-08 06:47:33 +00005120 if ((yyval.InstVal) == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00005121 GEN_ERROR("binary operator returned null!");
Reid Spencera132e042006-12-03 05:46:11 +00005122 delete (yyvsp[-3].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00005123 ;}
5124 break;
5125
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005126 case 271:
5127#line 2484 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005128 {
Reid Spencera132e042006-12-03 05:46:11 +00005129 if (!(*(yyvsp[-3].TypeVal))->isIntegral()) {
5130 if (!isa<PackedType>((yyvsp[-3].TypeVal)->get()) ||
5131 !cast<PackedType>((yyvsp[-3].TypeVal)->get())->getElementType()->isIntegral())
Reid Spencer61c83e02006-08-18 08:43:06 +00005132 GEN_ERROR("Logical operator requires integral operands!");
Chris Lattner524a1312005-12-21 18:31:50 +00005133 }
Reid Spencera132e042006-12-03 05:46:11 +00005134 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005135 CHECK_FOR_ERROR
Reid Spencera132e042006-12-03 05:46:11 +00005136 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005137 CHECK_FOR_ERROR
Reid Spencera132e042006-12-03 05:46:11 +00005138 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), tmpVal1, tmpVal2);
Reid Spencer3822ff52006-11-08 06:47:33 +00005139 if ((yyval.InstVal) == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00005140 GEN_ERROR("binary operator returned null!");
Reid Spencera132e042006-12-03 05:46:11 +00005141 delete (yyvsp[-3].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00005142 ;}
5143 break;
5144
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005145 case 272:
5146#line 2499 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005147 {
Reid Spencera132e042006-12-03 05:46:11 +00005148 if(isa<PackedType>((*(yyvsp[-3].TypeVal)).get())) {
Reid Spencer61c83e02006-08-18 08:43:06 +00005149 GEN_ERROR(
Reid Spencer68a24bd2005-08-27 18:50:39 +00005150 "PackedTypes currently not supported in setcc instructions!");
5151 }
Reid Spencera132e042006-12-03 05:46:11 +00005152 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005153 CHECK_FOR_ERROR
Reid Spencera132e042006-12-03 05:46:11 +00005154 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005155 CHECK_FOR_ERROR
Reid Spencera132e042006-12-03 05:46:11 +00005156 (yyval.InstVal) = new SetCondInst((yyvsp[-4].BinaryOpVal), tmpVal1, tmpVal2);
Reid Spencer3822ff52006-11-08 06:47:33 +00005157 if ((yyval.InstVal) == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00005158 GEN_ERROR("binary operator returned null!");
Reid Spencera132e042006-12-03 05:46:11 +00005159 delete (yyvsp[-3].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00005160 ;}
5161 break;
5162
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005163 case 273:
5164#line 2513 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencera132e042006-12-03 05:46:11 +00005165 {
5166 if (isa<PackedType>((*(yyvsp[-3].TypeVal)).get()))
5167 GEN_ERROR("Packed types not supported by icmp instruction");
5168 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
5169 CHECK_FOR_ERROR
5170 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
5171 CHECK_FOR_ERROR
5172 (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].IPredicate), tmpVal1, tmpVal2);
5173 if ((yyval.InstVal) == 0)
5174 GEN_ERROR("icmp operator returned null!");
5175 ;}
5176 break;
5177
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005178 case 274:
5179#line 2524 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencera132e042006-12-03 05:46:11 +00005180 {
5181 if (isa<PackedType>((*(yyvsp[-3].TypeVal)).get()))
5182 GEN_ERROR("Packed types not supported by fcmp instruction");
5183 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
5184 CHECK_FOR_ERROR
5185 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
5186 CHECK_FOR_ERROR
5187 (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].FPredicate), tmpVal1, tmpVal2);
5188 if ((yyval.InstVal) == 0)
5189 GEN_ERROR("fcmp operator returned null!");
5190 ;}
5191 break;
5192
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005193 case 275:
5194#line 2535 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005195 {
Reid Spencer481169e2006-12-01 00:33:46 +00005196 llvm_cerr << "WARNING: Use of eliminated 'not' instruction:"
Reid Spencer68a24bd2005-08-27 18:50:39 +00005197 << " Replacing with 'xor'.\n";
5198
Reid Spencera132e042006-12-03 05:46:11 +00005199 Value *Ones = ConstantIntegral::getAllOnesValue((yyvsp[0].ValueVal)->getType());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005200 if (Ones == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00005201 GEN_ERROR("Expected integral type for not instruction!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005202
Reid Spencera132e042006-12-03 05:46:11 +00005203 (yyval.InstVal) = BinaryOperator::create(Instruction::Xor, (yyvsp[0].ValueVal), Ones);
Reid Spencer3822ff52006-11-08 06:47:33 +00005204 if ((yyval.InstVal) == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00005205 GEN_ERROR("Could not create a xor instruction!");
5206 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005207 ;}
5208 break;
5209
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005210 case 276:
5211#line 2548 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005212 {
Reid Spencera132e042006-12-03 05:46:11 +00005213 if ((yyvsp[0].ValueVal)->getType() != Type::UByteTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00005214 GEN_ERROR("Shift amount must be ubyte!");
Reid Spencera132e042006-12-03 05:46:11 +00005215 if (!(yyvsp[-2].ValueVal)->getType()->isInteger())
Reid Spencer61c83e02006-08-18 08:43:06 +00005216 GEN_ERROR("Shift constant expression requires integer operand!");
Reid Spencer3822ff52006-11-08 06:47:33 +00005217 CHECK_FOR_ERROR;
Reid Spencera132e042006-12-03 05:46:11 +00005218 (yyval.InstVal) = new ShiftInst((yyvsp[-3].OtherOpVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005219 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005220 ;}
5221 break;
5222
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005223 case 277:
5224#line 2557 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005225 {
Reid Spencera132e042006-12-03 05:46:11 +00005226 Value* Val = (yyvsp[-2].ValueVal);
5227 const Type* Ty = (yyvsp[0].TypeVal)->get();
Reid Spencer3da59db2006-11-27 01:05:10 +00005228 if (!Val->getType()->isFirstClassType())
5229 GEN_ERROR("cast from a non-primitive type: '" +
5230 Val->getType()->getDescription() + "'!");
5231 if (!Ty->isFirstClassType())
5232 GEN_ERROR("cast to a non-primitive type: '" + Ty->getDescription() +"'!");
Reid Spencera132e042006-12-03 05:46:11 +00005233 (yyval.InstVal) = CastInst::create((yyvsp[-3].CastOpVal), (yyvsp[-2].ValueVal), (yyvsp[0].TypeVal)->get());
5234 delete (yyvsp[0].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00005235 ;}
5236 break;
5237
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005238 case 278:
5239#line 2568 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005240 {
Reid Spencera132e042006-12-03 05:46:11 +00005241 if ((yyvsp[-4].ValueVal)->getType() != Type::BoolTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00005242 GEN_ERROR("select condition must be boolean!");
Reid Spencera132e042006-12-03 05:46:11 +00005243 if ((yyvsp[-2].ValueVal)->getType() != (yyvsp[0].ValueVal)->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00005244 GEN_ERROR("select value types should match!");
Reid Spencera132e042006-12-03 05:46:11 +00005245 (yyval.InstVal) = new SelectInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005246 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005247 ;}
5248 break;
5249
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005250 case 279:
5251#line 2576 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005252 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00005253 NewVarArgs = true;
Reid Spencera132e042006-12-03 05:46:11 +00005254 (yyval.InstVal) = new VAArgInst((yyvsp[-2].ValueVal), *(yyvsp[0].TypeVal));
5255 delete (yyvsp[0].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005256 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005257 ;}
5258 break;
5259
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005260 case 280:
5261#line 2582 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005262 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00005263 ObsoleteVarArgs = true;
Reid Spencera132e042006-12-03 05:46:11 +00005264 const Type* ArgTy = (yyvsp[-2].ValueVal)->getType();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005265 Function* NF = CurModule.CurrentModule->
Jeff Cohen66c5fd62005-10-23 04:37:20 +00005266 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005267
5268 //b = vaarg a, t ->
5269 //foo = alloca 1 of t
5270 //bar = vacopy a
5271 //store bar -> foo
5272 //b = vaarg foo, t
5273 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
5274 CurBB->getInstList().push_back(foo);
Reid Spencera132e042006-12-03 05:46:11 +00005275 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005276 CurBB->getInstList().push_back(bar);
5277 CurBB->getInstList().push_back(new StoreInst(bar, foo));
Reid Spencera132e042006-12-03 05:46:11 +00005278 (yyval.InstVal) = new VAArgInst(foo, *(yyvsp[0].TypeVal));
5279 delete (yyvsp[0].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005280 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005281 ;}
5282 break;
5283
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005284 case 281:
5285#line 2602 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005286 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00005287 ObsoleteVarArgs = true;
Reid Spencera132e042006-12-03 05:46:11 +00005288 const Type* ArgTy = (yyvsp[-2].ValueVal)->getType();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005289 Function* NF = CurModule.CurrentModule->
Jeff Cohen66c5fd62005-10-23 04:37:20 +00005290 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005291
5292 //b = vanext a, t ->
5293 //foo = alloca 1 of t
5294 //bar = vacopy a
5295 //store bar -> foo
5296 //tmp = vaarg foo, t
5297 //b = load foo
5298 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
5299 CurBB->getInstList().push_back(foo);
Reid Spencera132e042006-12-03 05:46:11 +00005300 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005301 CurBB->getInstList().push_back(bar);
5302 CurBB->getInstList().push_back(new StoreInst(bar, foo));
Reid Spencera132e042006-12-03 05:46:11 +00005303 Instruction* tmp = new VAArgInst(foo, *(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005304 CurBB->getInstList().push_back(tmp);
Reid Spencer3822ff52006-11-08 06:47:33 +00005305 (yyval.InstVal) = new LoadInst(foo);
Reid Spencera132e042006-12-03 05:46:11 +00005306 delete (yyvsp[0].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005307 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005308 ;}
5309 break;
5310
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005311 case 282:
5312#line 2625 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005313 {
Reid Spencera132e042006-12-03 05:46:11 +00005314 if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00005315 GEN_ERROR("Invalid extractelement operands!");
Reid Spencera132e042006-12-03 05:46:11 +00005316 (yyval.InstVal) = new ExtractElementInst((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005317 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005318 ;}
5319 break;
5320
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005321 case 283:
5322#line 2631 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005323 {
Reid Spencera132e042006-12-03 05:46:11 +00005324 if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00005325 GEN_ERROR("Invalid insertelement operands!");
Reid Spencera132e042006-12-03 05:46:11 +00005326 (yyval.InstVal) = new InsertElementInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005327 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005328 ;}
5329 break;
5330
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005331 case 284:
5332#line 2637 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005333 {
Reid Spencera132e042006-12-03 05:46:11 +00005334 if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00005335 GEN_ERROR("Invalid shufflevector operands!");
Reid Spencera132e042006-12-03 05:46:11 +00005336 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005337 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005338 ;}
5339 break;
5340
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005341 case 285:
5342#line 2643 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005343 {
5344 const Type *Ty = (yyvsp[0].PHIList)->front().first->getType();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005345 if (!Ty->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00005346 GEN_ERROR("PHI node operands must be of first class type!");
Reid Spencer3822ff52006-11-08 06:47:33 +00005347 (yyval.InstVal) = new PHINode(Ty);
5348 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[0].PHIList)->size());
5349 while ((yyvsp[0].PHIList)->begin() != (yyvsp[0].PHIList)->end()) {
5350 if ((yyvsp[0].PHIList)->front().first->getType() != Ty)
Reid Spencer61c83e02006-08-18 08:43:06 +00005351 GEN_ERROR("All elements of a PHI node must be of the same type!");
Reid Spencer3822ff52006-11-08 06:47:33 +00005352 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[0].PHIList)->front().first, (yyvsp[0].PHIList)->front().second);
5353 (yyvsp[0].PHIList)->pop_front();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005354 }
Reid Spencer3822ff52006-11-08 06:47:33 +00005355 delete (yyvsp[0].PHIList); // Free the list...
Reid Spencer61c83e02006-08-18 08:43:06 +00005356 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005357 ;}
5358 break;
5359
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005360 case 286:
5361#line 2658 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005362 {
Reid Spencer3da59db2006-11-27 01:05:10 +00005363 const PointerType *PFTy = 0;
5364 const FunctionType *Ty = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005365
Reid Spencera132e042006-12-03 05:46:11 +00005366 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-4].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00005367 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5368 // Pull out the types of all of the arguments...
5369 std::vector<const Type*> ParamTypes;
Reid Spencer3822ff52006-11-08 06:47:33 +00005370 if ((yyvsp[-1].ValueList)) {
Reid Spencera132e042006-12-03 05:46:11 +00005371 for (std::vector<Value*>::iterator I = (yyvsp[-1].ValueList)->begin(), E = (yyvsp[-1].ValueList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005372 I != E; ++I)
Reid Spencera132e042006-12-03 05:46:11 +00005373 ParamTypes.push_back((*I)->getType());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005374 }
5375
5376 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
5377 if (isVarArg) ParamTypes.pop_back();
5378
Reid Spencera132e042006-12-03 05:46:11 +00005379 if (!(*(yyvsp[-4].TypeVal))->isFirstClassType() && *(yyvsp[-4].TypeVal) != Type::VoidTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00005380 GEN_ERROR("LLVM functions cannot return aggregate types!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005381
Reid Spencera132e042006-12-03 05:46:11 +00005382 Ty = FunctionType::get((yyvsp[-4].TypeVal)->get(), ParamTypes, isVarArg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005383 PFTy = PointerType::get(Ty);
5384 }
5385
Reid Spencer3822ff52006-11-08 06:47:33 +00005386 Value *V = getVal(PFTy, (yyvsp[-3].ValIDVal)); // Get the function we're calling...
Reid Spencer5b7e7532006-09-28 19:28:24 +00005387 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005388
5389 // Create the call node...
Reid Spencer3822ff52006-11-08 06:47:33 +00005390 if (!(yyvsp[-1].ValueList)) { // Has no arguments?
Reid Spencer68a24bd2005-08-27 18:50:39 +00005391 // Make sure no arguments is a good thing!
5392 if (Ty->getNumParams() != 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00005393 GEN_ERROR("No arguments passed to a function that "
Reid Spencer68a24bd2005-08-27 18:50:39 +00005394 "expects arguments!");
5395
Reid Spencer3822ff52006-11-08 06:47:33 +00005396 (yyval.InstVal) = new CallInst(V, std::vector<Value*>());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005397 } else { // Has arguments?
5398 // Loop through FunctionType's arguments and ensure they are specified
5399 // correctly!
5400 //
5401 FunctionType::param_iterator I = Ty->param_begin();
5402 FunctionType::param_iterator E = Ty->param_end();
Reid Spencera132e042006-12-03 05:46:11 +00005403 std::vector<Value*>::iterator ArgI = (yyvsp[-1].ValueList)->begin(), ArgE = (yyvsp[-1].ValueList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005404
Reid Spencera132e042006-12-03 05:46:11 +00005405 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
5406 if ((*ArgI)->getType() != *I)
5407 GEN_ERROR("Parameter " +(*ArgI)->getName()+ " is not of type '" +
5408 (*I)->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005409
5410 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
Reid Spencer61c83e02006-08-18 08:43:06 +00005411 GEN_ERROR("Invalid number of parameters detected!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005412
Reid Spencera132e042006-12-03 05:46:11 +00005413 (yyval.InstVal) = new CallInst(V, *(yyvsp[-1].ValueList));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005414 }
Reid Spencer3822ff52006-11-08 06:47:33 +00005415 cast<CallInst>((yyval.InstVal))->setTailCall((yyvsp[-6].BoolVal));
5416 cast<CallInst>((yyval.InstVal))->setCallingConv((yyvsp[-5].UIntVal));
Reid Spencera132e042006-12-03 05:46:11 +00005417 delete (yyvsp[-4].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00005418 delete (yyvsp[-1].ValueList);
Reid Spencer61c83e02006-08-18 08:43:06 +00005419 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005420 ;}
5421 break;
5422
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005423 case 287:
5424#line 2717 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005425 {
5426 (yyval.InstVal) = (yyvsp[0].InstVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005427 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005428 ;}
5429 break;
5430
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005431 case 288:
5432#line 2724 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005433 {
5434 (yyval.ValueList) = (yyvsp[0].ValueList);
Reid Spencer61c83e02006-08-18 08:43:06 +00005435 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005436 ;}
5437 break;
5438
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005439 case 289:
5440#line 2727 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005441 {
Reid Spencera132e042006-12-03 05:46:11 +00005442 (yyval.ValueList) = new std::vector<Value*>();
Reid Spencer61c83e02006-08-18 08:43:06 +00005443 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005444 ;}
5445 break;
5446
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005447 case 290:
5448#line 2732 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005449 {
5450 (yyval.BoolVal) = true;
Reid Spencer61c83e02006-08-18 08:43:06 +00005451 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005452 ;}
5453 break;
5454
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005455 case 291:
5456#line 2736 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005457 {
5458 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00005459 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005460 ;}
5461 break;
5462
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005463 case 292:
5464#line 2743 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005465 {
Reid Spencera132e042006-12-03 05:46:11 +00005466 (yyval.InstVal) = new MallocInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
5467 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005468 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005469 ;}
5470 break;
5471
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005472 case 293:
5473#line 2748 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005474 {
Reid Spencera132e042006-12-03 05:46:11 +00005475 Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005476 CHECK_FOR_ERROR
Reid Spencera132e042006-12-03 05:46:11 +00005477 (yyval.InstVal) = new MallocInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal));
5478 delete (yyvsp[-4].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00005479 ;}
5480 break;
5481
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005482 case 294:
5483#line 2754 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005484 {
Reid Spencera132e042006-12-03 05:46:11 +00005485 (yyval.InstVal) = new AllocaInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
5486 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005487 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005488 ;}
5489 break;
5490
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005491 case 295:
5492#line 2759 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005493 {
Reid Spencera132e042006-12-03 05:46:11 +00005494 Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005495 CHECK_FOR_ERROR
Reid Spencera132e042006-12-03 05:46:11 +00005496 (yyval.InstVal) = new AllocaInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal));
5497 delete (yyvsp[-4].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00005498 ;}
5499 break;
5500
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005501 case 296:
5502#line 2765 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005503 {
Reid Spencera132e042006-12-03 05:46:11 +00005504 if (!isa<PointerType>((yyvsp[0].ValueVal)->getType()))
Reid Spencer61c83e02006-08-18 08:43:06 +00005505 GEN_ERROR("Trying to free nonpointer type " +
Reid Spencera132e042006-12-03 05:46:11 +00005506 (yyvsp[0].ValueVal)->getType()->getDescription() + "!");
5507 (yyval.InstVal) = new FreeInst((yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005508 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005509 ;}
5510 break;
5511
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005512 case 297:
5513#line 2773 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005514 {
Reid Spencera132e042006-12-03 05:46:11 +00005515 if (!isa<PointerType>((yyvsp[-1].TypeVal)->get()))
Reid Spencer61c83e02006-08-18 08:43:06 +00005516 GEN_ERROR("Can't load from nonpointer type: " +
Reid Spencera132e042006-12-03 05:46:11 +00005517 (*(yyvsp[-1].TypeVal))->getDescription());
5518 if (!cast<PointerType>((yyvsp[-1].TypeVal)->get())->getElementType()->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00005519 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Reid Spencera132e042006-12-03 05:46:11 +00005520 (*(yyvsp[-1].TypeVal))->getDescription());
5521 Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005522 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005523 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal));
Reid Spencera132e042006-12-03 05:46:11 +00005524 delete (yyvsp[-1].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00005525 ;}
5526 break;
5527
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005528 case 298:
5529#line 2785 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005530 {
Reid Spencera132e042006-12-03 05:46:11 +00005531 const PointerType *PT = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005532 if (!PT)
Reid Spencer61c83e02006-08-18 08:43:06 +00005533 GEN_ERROR("Can't store to a nonpointer type: " +
Reid Spencera132e042006-12-03 05:46:11 +00005534 (*(yyvsp[-1].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005535 const Type *ElTy = PT->getElementType();
Reid Spencera132e042006-12-03 05:46:11 +00005536 if (ElTy != (yyvsp[-3].ValueVal)->getType())
5537 GEN_ERROR("Can't store '" + (yyvsp[-3].ValueVal)->getType()->getDescription() +
Reid Spencer68a24bd2005-08-27 18:50:39 +00005538 "' into space of type '" + ElTy->getDescription() + "'!");
5539
Reid Spencera132e042006-12-03 05:46:11 +00005540 Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005541 CHECK_FOR_ERROR
Reid Spencera132e042006-12-03 05:46:11 +00005542 (yyval.InstVal) = new StoreInst((yyvsp[-3].ValueVal), tmpVal, (yyvsp[-5].BoolVal));
5543 delete (yyvsp[-1].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00005544 ;}
5545 break;
5546
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005547 case 299:
5548#line 2800 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005549 {
Reid Spencera132e042006-12-03 05:46:11 +00005550 if (!isa<PointerType>((yyvsp[-2].TypeVal)->get()))
Reid Spencer61c83e02006-08-18 08:43:06 +00005551 GEN_ERROR("getelementptr insn requires pointer operand!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005552
Reid Spencera132e042006-12-03 05:46:11 +00005553 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
5554 // indices to uint struct indices for compatibility.
5555 generic_gep_type_iterator<std::vector<Value*>::iterator>
5556 GTI = gep_type_begin((yyvsp[-2].TypeVal)->get(), (yyvsp[0].ValueList)->begin(), (yyvsp[0].ValueList)->end()),
5557 GTE = gep_type_end((yyvsp[-2].TypeVal)->get(), (yyvsp[0].ValueList)->begin(), (yyvsp[0].ValueList)->end());
5558 for (unsigned i = 0, e = (yyvsp[0].ValueList)->size(); i != e && GTI != GTE; ++i, ++GTI)
5559 if (isa<StructType>(*GTI)) // Only change struct indices
5560 if (ConstantInt *CUI = dyn_cast<ConstantInt>((*(yyvsp[0].ValueList))[i]))
5561 if (CUI->getType() == Type::UByteTy)
5562 (*(yyvsp[0].ValueList))[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005563
Reid Spencera132e042006-12-03 05:46:11 +00005564 if (!GetElementPtrInst::getIndexedType(*(yyvsp[-2].TypeVal), *(yyvsp[0].ValueList), true))
Reid Spencer61c83e02006-08-18 08:43:06 +00005565 GEN_ERROR("Invalid getelementptr indices for type '" +
Reid Spencera132e042006-12-03 05:46:11 +00005566 (*(yyvsp[-2].TypeVal))->getDescription()+ "'!");
5567 Value* tmpVal = getVal(*(yyvsp[-2].TypeVal), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005568 CHECK_FOR_ERROR
Reid Spencera132e042006-12-03 05:46:11 +00005569 (yyval.InstVal) = new GetElementPtrInst(tmpVal, *(yyvsp[0].ValueList));
5570 delete (yyvsp[-2].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00005571 delete (yyvsp[0].ValueList);
5572 ;}
5573 break;
5574
5575
5576 default: break;
5577 }
5578
5579/* Line 1126 of yacc.c. */
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005580#line 5581 "llvmAsmParser.tab.c"
Reid Spencer5b7e7532006-09-28 19:28:24 +00005581
5582 yyvsp -= yylen;
5583 yyssp -= yylen;
5584
Reid Spencer3822ff52006-11-08 06:47:33 +00005585
5586 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005587
5588 *++yyvsp = yyval;
5589
5590
Reid Spencer3822ff52006-11-08 06:47:33 +00005591 /* Now `shift' the result of the reduction. Determine what state
5592 that goes to, based on the state we popped back to and the rule
5593 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005594
5595 yyn = yyr1[yyn];
5596
Reid Spencer3822ff52006-11-08 06:47:33 +00005597 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
5598 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005599 yystate = yytable[yystate];
5600 else
Reid Spencer3822ff52006-11-08 06:47:33 +00005601 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00005602
5603 goto yynewstate;
5604
5605
Reid Spencer3822ff52006-11-08 06:47:33 +00005606/*------------------------------------.
5607| yyerrlab -- here on detecting error |
5608`------------------------------------*/
5609yyerrlab:
5610 /* If not already recovering from an error, report this error. */
5611 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005612 {
5613 ++yynerrs;
Reid Spencer3822ff52006-11-08 06:47:33 +00005614#if YYERROR_VERBOSE
Reid Spencer5b7e7532006-09-28 19:28:24 +00005615 yyn = yypact[yystate];
Chris Lattner224f84f2006-08-18 17:34:45 +00005616
Reid Spencer3822ff52006-11-08 06:47:33 +00005617 if (YYPACT_NINF < yyn && yyn < YYLAST)
Reid Spencer5b7e7532006-09-28 19:28:24 +00005618 {
Reid Spencer3822ff52006-11-08 06:47:33 +00005619 int yytype = YYTRANSLATE (yychar);
5620 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
5621 YYSIZE_T yysize = yysize0;
5622 YYSIZE_T yysize1;
5623 int yysize_overflow = 0;
5624 char *yymsg = 0;
5625# define YYERROR_VERBOSE_ARGS_MAXIMUM 5
5626 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
5627 int yyx;
Reid Spencer5b7e7532006-09-28 19:28:24 +00005628
Reid Spencer3822ff52006-11-08 06:47:33 +00005629#if 0
5630 /* This is so xgettext sees the translatable formats that are
5631 constructed on the fly. */
5632 YY_("syntax error, unexpected %s");
5633 YY_("syntax error, unexpected %s, expecting %s");
5634 YY_("syntax error, unexpected %s, expecting %s or %s");
5635 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
5636 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
5637#endif
5638 char *yyfmt;
5639 char const *yyf;
5640 static char const yyunexpected[] = "syntax error, unexpected %s";
5641 static char const yyexpecting[] = ", expecting %s";
5642 static char const yyor[] = " or %s";
5643 char yyformat[sizeof yyunexpected
5644 + sizeof yyexpecting - 1
5645 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
5646 * (sizeof yyor - 1))];
5647 char const *yyprefix = yyexpecting;
5648
5649 /* Start YYX at -YYN if negative to avoid negative indexes in
5650 YYCHECK. */
5651 int yyxbegin = yyn < 0 ? -yyn : 0;
5652
5653 /* Stay within bounds of both yycheck and yytname. */
5654 int yychecklim = YYLAST - yyn;
5655 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
5656 int yycount = 1;
5657
5658 yyarg[0] = yytname[yytype];
5659 yyfmt = yystpcpy (yyformat, yyunexpected);
5660
5661 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
5662 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
5663 {
5664 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
5665 {
5666 yycount = 1;
5667 yysize = yysize0;
5668 yyformat[sizeof yyunexpected - 1] = '\0';
5669 break;
5670 }
5671 yyarg[yycount++] = yytname[yyx];
5672 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
5673 yysize_overflow |= yysize1 < yysize;
5674 yysize = yysize1;
5675 yyfmt = yystpcpy (yyfmt, yyprefix);
5676 yyprefix = yyor;
5677 }
5678
5679 yyf = YY_(yyformat);
5680 yysize1 = yysize + yystrlen (yyf);
5681 yysize_overflow |= yysize1 < yysize;
5682 yysize = yysize1;
5683
5684 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
5685 yymsg = (char *) YYSTACK_ALLOC (yysize);
5686 if (yymsg)
Reid Spencer5b7e7532006-09-28 19:28:24 +00005687 {
Reid Spencer3822ff52006-11-08 06:47:33 +00005688 /* Avoid sprintf, as that infringes on the user's name space.
5689 Don't have undefined behavior even if the translation
5690 produced a string with the wrong number of "%s"s. */
5691 char *yyp = yymsg;
5692 int yyi = 0;
5693 while ((*yyp = *yyf))
Reid Spencer5b7e7532006-09-28 19:28:24 +00005694 {
Reid Spencer3822ff52006-11-08 06:47:33 +00005695 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
5696 {
5697 yyp += yytnamerr (yyp, yyarg[yyi++]);
5698 yyf += 2;
5699 }
5700 else
5701 {
5702 yyp++;
5703 yyf++;
5704 }
Reid Spencer5b7e7532006-09-28 19:28:24 +00005705 }
Reid Spencer3822ff52006-11-08 06:47:33 +00005706 yyerror (yymsg);
5707 YYSTACK_FREE (yymsg);
Reid Spencer5b7e7532006-09-28 19:28:24 +00005708 }
5709 else
Reid Spencer3822ff52006-11-08 06:47:33 +00005710 {
5711 yyerror (YY_("syntax error"));
5712 goto yyexhaustedlab;
5713 }
Reid Spencer5b7e7532006-09-28 19:28:24 +00005714 }
5715 else
5716#endif /* YYERROR_VERBOSE */
Reid Spencer3822ff52006-11-08 06:47:33 +00005717 yyerror (YY_("syntax error"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005718 }
5719
Reid Spencer3822ff52006-11-08 06:47:33 +00005720
Reid Spencer68a24bd2005-08-27 18:50:39 +00005721
5722 if (yyerrstatus == 3)
5723 {
Reid Spencer3822ff52006-11-08 06:47:33 +00005724 /* If just tried and failed to reuse look-ahead token after an
5725 error, discard it. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005726
Reid Spencer3822ff52006-11-08 06:47:33 +00005727 if (yychar <= YYEOF)
5728 {
5729 /* Return failure if at end of input. */
5730 if (yychar == YYEOF)
5731 YYABORT;
5732 }
5733 else
5734 {
5735 yydestruct ("Error: discarding", yytoken, &yylval);
5736 yychar = YYEMPTY;
5737 }
5738 }
5739
5740 /* Else will try to reuse look-ahead token after shifting the error
5741 token. */
5742 goto yyerrlab1;
5743
5744
5745/*---------------------------------------------------.
5746| yyerrorlab -- error raised explicitly by YYERROR. |
5747`---------------------------------------------------*/
5748yyerrorlab:
5749
5750 /* Pacify compilers like GCC when the user code never invokes
5751 YYERROR and the label yyerrorlab therefore never appears in user
5752 code. */
5753 if (0)
5754 goto yyerrorlab;
5755
5756yyvsp -= yylen;
5757 yyssp -= yylen;
5758 yystate = *yyssp;
5759 goto yyerrlab1;
5760
5761
5762/*-------------------------------------------------------------.
5763| yyerrlab1 -- common code for both syntax error and YYERROR. |
5764`-------------------------------------------------------------*/
5765yyerrlab1:
5766 yyerrstatus = 3; /* Each real token shifted decrements this. */
5767
5768 for (;;)
5769 {
5770 yyn = yypact[yystate];
5771 if (yyn != YYPACT_NINF)
5772 {
5773 yyn += YYTERROR;
5774 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
5775 {
5776 yyn = yytable[yyn];
5777 if (0 < yyn)
5778 break;
5779 }
5780 }
5781
5782 /* Pop the current state because it cannot handle the error token. */
5783 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005784 YYABORT;
5785
Chris Lattner8335e842006-01-23 23:05:42 +00005786
Reid Spencer3822ff52006-11-08 06:47:33 +00005787 yydestruct ("Error: popping", yystos[yystate], yyvsp);
5788 YYPOPSTACK;
5789 yystate = *yyssp;
5790 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005791 }
5792
5793 if (yyn == YYFINAL)
5794 YYACCEPT;
5795
Reid Spencer68a24bd2005-08-27 18:50:39 +00005796 *++yyvsp = yylval;
Reid Spencer3822ff52006-11-08 06:47:33 +00005797
5798
5799 /* Shift the error token. */
5800 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005801
5802 yystate = yyn;
5803 goto yynewstate;
5804
Chris Lattnerf49c1762006-11-08 05:58:47 +00005805
Reid Spencer3822ff52006-11-08 06:47:33 +00005806/*-------------------------------------.
5807| yyacceptlab -- YYACCEPT comes here. |
5808`-------------------------------------*/
5809yyacceptlab:
5810 yyresult = 0;
5811 goto yyreturn;
5812
5813/*-----------------------------------.
5814| yyabortlab -- YYABORT comes here. |
5815`-----------------------------------*/
5816yyabortlab:
5817 yyresult = 1;
5818 goto yyreturn;
5819
5820#ifndef yyoverflow
5821/*-------------------------------------------------.
5822| yyexhaustedlab -- memory exhaustion comes here. |
5823`-------------------------------------------------*/
5824yyexhaustedlab:
5825 yyerror (YY_("memory exhausted"));
5826 yyresult = 2;
5827 /* Fall through. */
Chris Lattnerf49c1762006-11-08 05:58:47 +00005828#endif
Reid Spencer3822ff52006-11-08 06:47:33 +00005829
5830yyreturn:
5831 if (yychar != YYEOF && yychar != YYEMPTY)
5832 yydestruct ("Cleanup: discarding lookahead",
5833 yytoken, &yylval);
5834 while (yyssp != yyss)
5835 {
5836 yydestruct ("Cleanup: popping",
5837 yystos[*yyssp], yyvsp);
5838 YYPOPSTACK;
Chris Lattnerf49c1762006-11-08 05:58:47 +00005839 }
Reid Spencer3822ff52006-11-08 06:47:33 +00005840#ifndef yyoverflow
5841 if (yyss != yyssa)
5842 YYSTACK_FREE (yyss);
5843#endif
5844 return yyresult;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005845}
Reid Spencer3822ff52006-11-08 06:47:33 +00005846
5847
Reid Spencer6e18b7d2006-12-03 06:59:29 +00005848#line 2826 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00005849
5850
5851void llvm::GenerateError(const std::string &message, int LineNo) {
5852 if (LineNo == -1) LineNo = llvmAsmlineno;
5853 // TODO: column number in exception
5854 if (TheParseError)
5855 TheParseError->setError(CurFilename, message, LineNo);
5856 TriggerError = 1;
5857}
Reid Spencer68a24bd2005-08-27 18:50:39 +00005858
5859int yyerror(const char *ErrorMsg) {
5860 std::string where
5861 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
5862 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
5863 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
5864 if (yychar == YYEMPTY || yychar == 0)
5865 errMsg += "end-of-file.";
5866 else
5867 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
Reid Spencer61c83e02006-08-18 08:43:06 +00005868 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005869 return 0;
5870}
Reid Spencer3822ff52006-11-08 06:47:33 +00005871