blob: 125ece66d5d1b00c9b1f8eace4f8699cfc62f071 [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,
172 ORDEQ = 363,
173 ORDNE = 364,
174 ORDLT = 365,
175 ORDGT = 366,
176 ORDLE = 367,
177 ORDGE = 368,
178 ORD = 369,
179 UNO = 370,
180 UNOEQ = 371,
181 UNONE = 372,
182 UNOLT = 373,
183 UNOGT = 374,
184 UNOLE = 375,
185 UNOGE = 376,
186 MALLOC = 377,
187 ALLOCA = 378,
188 FREE = 379,
189 LOAD = 380,
190 STORE = 381,
191 GETELEMENTPTR = 382,
192 TRUNC = 383,
193 ZEXT = 384,
194 SEXT = 385,
195 FPTRUNC = 386,
196 FPEXT = 387,
197 BITCAST = 388,
198 UITOFP = 389,
199 SITOFP = 390,
200 FPTOUI = 391,
201 FPTOSI = 392,
202 INTTOPTR = 393,
203 PTRTOINT = 394,
204 PHI_TOK = 395,
205 SELECT = 396,
206 SHL = 397,
207 LSHR = 398,
208 ASHR = 399,
209 VAARG = 400,
210 EXTRACTELEMENT = 401,
211 INSERTELEMENT = 402,
212 SHUFFLEVECTOR = 403,
213 VAARG_old = 404,
214 VANEXT_old = 405
Reid Spencer3822ff52006-11-08 06:47:33 +0000215 };
216#endif
217/* Tokens. */
218#define ESINT64VAL 258
219#define EUINT64VAL 259
220#define SINTVAL 260
221#define UINTVAL 261
222#define FPVAL 262
223#define VOID 263
224#define BOOL 264
225#define SBYTE 265
226#define UBYTE 266
227#define SHORT 267
228#define USHORT 268
229#define INT 269
230#define UINT 270
231#define LONG 271
232#define ULONG 272
233#define FLOAT 273
234#define DOUBLE 274
235#define TYPE 275
236#define LABEL 276
237#define VAR_ID 277
238#define LABELSTR 278
239#define STRINGCONSTANT 279
240#define IMPLEMENTATION 280
241#define ZEROINITIALIZER 281
242#define TRUETOK 282
243#define FALSETOK 283
244#define BEGINTOK 284
245#define ENDTOK 285
246#define DECLARE 286
247#define GLOBAL 287
248#define CONSTANT 288
249#define SECTION 289
250#define VOLATILE 290
251#define TO 291
252#define DOTDOTDOT 292
253#define NULL_TOK 293
254#define UNDEF 294
255#define CONST 295
256#define INTERNAL 296
257#define LINKONCE 297
258#define WEAK 298
259#define APPENDING 299
260#define DLLIMPORT 300
261#define DLLEXPORT 301
262#define EXTERN_WEAK 302
263#define OPAQUE 303
264#define NOT 304
265#define EXTERNAL 305
266#define TARGET 306
267#define TRIPLE 307
268#define ENDIAN 308
269#define POINTERSIZE 309
270#define LITTLE 310
271#define BIG 311
272#define ALIGN 312
273#define DEPLIBS 313
274#define CALL 314
275#define TAIL 315
276#define ASM_TOK 316
277#define MODULE 317
278#define SIDEEFFECT 318
279#define CC_TOK 319
280#define CCC_TOK 320
281#define CSRETCC_TOK 321
282#define FASTCC_TOK 322
283#define COLDCC_TOK 323
284#define X86_STDCALLCC_TOK 324
285#define X86_FASTCALLCC_TOK 325
286#define DATALAYOUT 326
287#define RET 327
288#define BR 328
289#define SWITCH 329
290#define INVOKE 330
291#define UNWIND 331
292#define UNREACHABLE 332
293#define ADD 333
294#define SUB 334
295#define MUL 335
296#define UDIV 336
297#define SDIV 337
298#define FDIV 338
299#define UREM 339
300#define SREM 340
301#define FREM 341
302#define AND 342
303#define OR 343
304#define XOR 344
305#define SETLE 345
306#define SETGE 346
307#define SETLT 347
308#define SETGT 348
309#define SETEQ 349
310#define SETNE 350
Reid Spencera132e042006-12-03 05:46:11 +0000311#define ICMP 351
312#define FCMP 352
313#define EQ 353
314#define NE 354
315#define SLT 355
316#define SGT 356
317#define SLE 357
318#define SGE 358
319#define ULT 359
320#define UGT 360
321#define ULE 361
322#define UGE 362
323#define ORDEQ 363
324#define ORDNE 364
325#define ORDLT 365
326#define ORDGT 366
327#define ORDLE 367
328#define ORDGE 368
329#define ORD 369
330#define UNO 370
331#define UNOEQ 371
332#define UNONE 372
333#define UNOLT 373
334#define UNOGT 374
335#define UNOLE 375
336#define UNOGE 376
337#define MALLOC 377
338#define ALLOCA 378
339#define FREE 379
340#define LOAD 380
341#define STORE 381
342#define GETELEMENTPTR 382
343#define TRUNC 383
344#define ZEXT 384
345#define SEXT 385
346#define FPTRUNC 386
347#define FPEXT 387
348#define BITCAST 388
349#define UITOFP 389
350#define SITOFP 390
351#define FPTOUI 391
352#define FPTOSI 392
353#define INTTOPTR 393
354#define PTRTOINT 394
355#define PHI_TOK 395
356#define SELECT 396
357#define SHL 397
358#define LSHR 398
359#define ASHR 399
360#define VAARG 400
361#define EXTRACTELEMENT 401
362#define INSERTELEMENT 402
363#define SHUFFLEVECTOR 403
364#define VAARG_old 404
365#define VANEXT_old 405
Reid Spencer3822ff52006-11-08 06:47:33 +0000366
367
368
369
370/* Copy the first part of user declarations. */
Reid Spencer861d9d62006-11-28 07:29:44 +0000371#line 14 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000372
373#include "ParserInternals.h"
374#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000375#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000376#include "llvm/Instructions.h"
377#include "llvm/Module.h"
378#include "llvm/SymbolTable.h"
Reid Spencer0b118202006-01-16 21:12:35 +0000379#include "llvm/Assembly/AutoUpgrade.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000380#include "llvm/Support/GetElementPtrTypeIterator.h"
381#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000382#include "llvm/Support/MathExtras.h"
Reid Spencer481169e2006-12-01 00:33:46 +0000383#include "llvm/Support/Streams.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000384#include <algorithm>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000385#include <list>
386#include <utility>
387
Reid Spencere4f47592006-08-18 17:32:55 +0000388// The following is a gross hack. In order to rid the libAsmParser library of
389// exceptions, we have to have a way of getting the yyparse function to go into
390// an error situation. So, whenever we want an error to occur, the GenerateError
391// function (see bottom of file) sets TriggerError. Then, at the end of each
392// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
393// (a goto) to put YACC in error state. Furthermore, several calls to
394// GenerateError are made from inside productions and they must simulate the
395// previous exception behavior by exiting the production immediately. We have
396// replaced these with the GEN_ERROR macro which calls GeneratError and then
397// immediately invokes YYERROR. This would be so much cleaner if it was a
398// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000399static bool TriggerError = false;
Reid Spencerf63697d2006-10-09 17:36:59 +0000400#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000401#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
402
Reid Spencer68a24bd2005-08-27 18:50:39 +0000403int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
404int yylex(); // declaration" of xxx warnings.
405int yyparse();
406
407namespace llvm {
408 std::string CurFilename;
409}
410using namespace llvm;
411
412static Module *ParserResult;
413
414// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
415// relating to upreferences in the input stream.
416//
417//#define DEBUG_UPREFS 1
418#ifdef DEBUG_UPREFS
Reid Spencer481169e2006-12-01 00:33:46 +0000419#define UR_OUT(X) llvm_cerr << X
Reid Spencer68a24bd2005-08-27 18:50:39 +0000420#else
421#define UR_OUT(X)
422#endif
423
424#define YYERROR_VERBOSE 1
425
426static bool ObsoleteVarArgs;
427static bool NewVarArgs;
Chris Lattnerb475c422005-11-12 18:22:38 +0000428static BasicBlock *CurBB;
429static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000430
431
432// This contains info used when building the body of a function. It is
433// destroyed when the function is completed.
434//
435typedef std::vector<Value *> ValueList; // Numbered defs
436static void
437ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
438 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
439
440static struct PerModuleInfo {
441 Module *CurrentModule;
442 std::map<const Type *, ValueList> Values; // Module level numbered definitions
443 std::map<const Type *,ValueList> LateResolveValues;
Reid Spencer861d9d62006-11-28 07:29:44 +0000444 std::vector<PATypeHolder> Types;
445 std::map<ValID, PATypeHolder> LateResolveTypes;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000446
447 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000448 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000449 /// that we can resolve them later and print error messages as appropriate.
450 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
451
452 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
453 // references to global values. Global values may be referenced before they
454 // are defined, and if so, the temporary object that they represent is held
455 // here. This is used for forward references of GlobalValues.
456 //
457 typedef std::map<std::pair<const PointerType *,
458 ValID>, GlobalValue*> GlobalRefsType;
459 GlobalRefsType GlobalRefs;
460
461 void ModuleDone() {
462 // If we could not resolve some functions at function compilation time
463 // (calls to functions before they are defined), resolve them now... Types
464 // are resolved when the constant pool has been completely parsed.
465 //
466 ResolveDefinitions(LateResolveValues);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000467 if (TriggerError)
468 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000469
470 // Check to make sure that all global value forward references have been
471 // resolved!
472 //
473 if (!GlobalRefs.empty()) {
474 std::string UndefinedReferences = "Unresolved global references exist:\n";
475
476 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
477 I != E; ++I) {
478 UndefinedReferences += " " + I->first.first->getDescription() + " " +
479 I->first.second.getName() + "\n";
480 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000481 GenerateError(UndefinedReferences);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000482 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000483 }
484
485 Values.clear(); // Clear out function local definitions
486 Types.clear();
487 CurrentModule = 0;
488 }
489
Reid Spencer68a24bd2005-08-27 18:50:39 +0000490 // GetForwardRefForGlobal - Check to see if there is a forward reference
491 // for this global. If so, remove it from the GlobalRefs map and return it.
492 // If not, just return null.
493 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
494 // Check to see if there is a forward reference to this global variable...
495 // if there is, eliminate it and patch the reference to use the new def'n.
496 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
497 GlobalValue *Ret = 0;
498 if (I != GlobalRefs.end()) {
499 Ret = I->second;
500 GlobalRefs.erase(I);
501 }
502 return Ret;
503 }
504} CurModule;
505
506static struct PerFunctionInfo {
507 Function *CurrentFunction; // Pointer to current function being created
508
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000509 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
Reid Spencer68a24bd2005-08-27 18:50:39 +0000510 std::map<const Type*, ValueList> LateResolveValues;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000511 bool isDeclare; // Is this function a forward declararation?
512 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Reid Spencer68a24bd2005-08-27 18:50:39 +0000513
514 /// BBForwardRefs - When we see forward references to basic blocks, keep
515 /// track of them here.
516 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
517 std::vector<BasicBlock*> NumberedBlocks;
518 unsigned NextBBNum;
519
520 inline PerFunctionInfo() {
521 CurrentFunction = 0;
522 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000523 Linkage = GlobalValue::ExternalLinkage;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000524 }
525
526 inline void FunctionStart(Function *M) {
527 CurrentFunction = M;
528 NextBBNum = 0;
529 }
530
531 void FunctionDone() {
532 NumberedBlocks.clear();
533
534 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000535 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000536 GenerateError("Undefined reference to label " +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000537 BBForwardRefs.begin()->first->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000538 return;
539 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000540
541 // Resolve all forward references now.
542 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
543
544 Values.clear(); // Clear out function local definitions
545 CurrentFunction = 0;
546 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000547 Linkage = GlobalValue::ExternalLinkage;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000548 }
549} CurFun; // Info for the current function...
550
551static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
552
553
554//===----------------------------------------------------------------------===//
555// Code to handle definitions of all the types
556//===----------------------------------------------------------------------===//
557
558static int InsertValue(Value *V,
559 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
560 if (V->hasName()) return -1; // Is this a numbered definition?
561
562 // Yes, insert the value into the value table...
563 ValueList &List = ValueTab[V->getType()];
564 List.push_back(V);
565 return List.size()-1;
566}
567
568static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
569 switch (D.Type) {
570 case ValID::NumberVal: // Is it a numbered definition?
571 // Module constants occupy the lowest numbered slots...
572 if ((unsigned)D.Num < CurModule.Types.size())
Reid Spencer861d9d62006-11-28 07:29:44 +0000573 return CurModule.Types[(unsigned)D.Num];
Reid Spencer68a24bd2005-08-27 18:50:39 +0000574 break;
575 case ValID::NameVal: // Is it a named definition?
576 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
577 D.destroy(); // Free old strdup'd memory...
578 return N;
579 }
580 break;
581 default:
Reid Spencer61c83e02006-08-18 08:43:06 +0000582 GenerateError("Internal parser error: Invalid symbol type reference!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000583 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000584 }
585
586 // If we reached here, we referenced either a symbol that we don't know about
587 // or an id number that hasn't been read yet. We may be referencing something
588 // forward, so just create an entry to be resolved later and get to it...
589 //
590 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
591
592
593 if (inFunctionScope()) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000594 if (D.Type == ValID::NameVal) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000595 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000596 return 0;
597 } else {
Reid Spencer61c83e02006-08-18 08:43:06 +0000598 GenerateError("Reference to an undefined type: #" + itostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000599 return 0;
600 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000601 }
602
Reid Spencer861d9d62006-11-28 07:29:44 +0000603 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000604 if (I != CurModule.LateResolveTypes.end())
Reid Spencer861d9d62006-11-28 07:29:44 +0000605 return I->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000606
Reid Spencer861d9d62006-11-28 07:29:44 +0000607 Type *Typ = OpaqueType::get();
608 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
609 return Typ;
Reid Spencera132e042006-12-03 05:46:11 +0000610 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000611
612static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
613 SymbolTable &SymTab =
614 inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() :
615 CurModule.CurrentModule->getSymbolTable();
616 return SymTab.lookup(Ty, Name);
617}
618
619// getValNonImprovising - Look up the value specified by the provided type and
620// the provided ValID. If the value exists and has already been defined, return
621// it. Otherwise return null.
622//
623static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000624 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000625 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000626 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000627 return 0;
628 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000629
630 switch (D.Type) {
631 case ValID::NumberVal: { // Is it a numbered definition?
632 unsigned Num = (unsigned)D.Num;
633
634 // Module constants occupy the lowest numbered slots...
635 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
636 if (VI != CurModule.Values.end()) {
637 if (Num < VI->second.size())
638 return VI->second[Num];
639 Num -= VI->second.size();
640 }
641
642 // Make sure that our type is within bounds
643 VI = CurFun.Values.find(Ty);
644 if (VI == CurFun.Values.end()) return 0;
645
646 // Check that the number is within bounds...
647 if (VI->second.size() <= Num) return 0;
648
649 return VI->second[Num];
650 }
651
652 case ValID::NameVal: { // Is it a named definition?
653 Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
654 if (N == 0) return 0;
655
656 D.destroy(); // Free old strdup'd memory...
657 return N;
658 }
659
660 // Check to make sure that "Ty" is an integral type, and that our
661 // value will fit into the specified type...
662 case ValID::ConstSIntVal: // Is it a constant pool reference??
Reid Spencerb83eb642006-10-20 07:07:24 +0000663 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000664 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000665 itostr(D.ConstPool64) + "' is invalid for type '" +
666 Ty->getDescription() + "'!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000667 return 0;
668 }
Reid Spencerb83eb642006-10-20 07:07:24 +0000669 return ConstantInt::get(Ty, D.ConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000670
671 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Reid Spencerb83eb642006-10-20 07:07:24 +0000672 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
673 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000674 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000675 "' is invalid or out of range!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000676 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000677 } else { // This is really a signed reference. Transmogrify.
Reid Spencerb83eb642006-10-20 07:07:24 +0000678 return ConstantInt::get(Ty, D.ConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000679 }
680 } else {
Reid Spencerb83eb642006-10-20 07:07:24 +0000681 return ConstantInt::get(Ty, D.UConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000682 }
683
684 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000685 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000686 GenerateError("FP constant invalid for type!!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000687 return 0;
688 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000689 return ConstantFP::get(Ty, D.ConstPoolFP);
690
691 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000692 if (!isa<PointerType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000693 GenerateError("Cannot create a a non pointer null!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000694 return 0;
695 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000696 return ConstantPointerNull::get(cast<PointerType>(Ty));
697
698 case ValID::ConstUndefVal: // Is it an undef value?
699 return UndefValue::get(Ty);
700
Chris Lattner7aa61892005-12-21 17:53:23 +0000701 case ValID::ConstZeroVal: // Is it a zero value?
702 return Constant::getNullValue(Ty);
703
Reid Spencer68a24bd2005-08-27 18:50:39 +0000704 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000705 if (D.ConstantValue->getType() != Ty) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000706 GenerateError("Constant expression type different from required type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000707 return 0;
708 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000709 return D.ConstantValue;
710
Chris Lattner0e9c3762006-01-25 22:27:16 +0000711 case ValID::InlineAsmVal: { // Inline asm expression
712 const PointerType *PTy = dyn_cast<PointerType>(Ty);
713 const FunctionType *FTy =
714 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000715 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000716 GenerateError("Invalid type for asm constraint string!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000717 return 0;
718 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000719 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
720 D.IAD->HasSideEffects);
721 D.destroy(); // Free InlineAsmDescriptor.
722 return IA;
723 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000724 default:
725 assert(0 && "Unhandled case!");
726 return 0;
727 } // End of switch
728
729 assert(0 && "Unhandled case!");
730 return 0;
731}
732
733// getVal - This function is identical to getValNonImprovising, except that if a
734// value is not already defined, it "improvises" by creating a placeholder var
735// that looks and acts just like the requested variable. When the value is
736// defined later, all uses of the placeholder variable are replaced with the
737// real thing.
738//
739static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000740 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000741 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000742 return 0;
743 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000744
745 // See if the value has already been defined.
746 Value *V = getValNonImprovising(Ty, ID);
747 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000748 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000749
Reid Spencer5b7e7532006-09-28 19:28:24 +0000750 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000751 GenerateError("Invalid use of a composite type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000752 return 0;
753 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000754
755 // If we reached here, we referenced either a symbol that we don't know about
756 // or an id number that hasn't been read yet. We may be referencing something
757 // forward, so just create an entry to be resolved later and get to it...
758 //
759 V = new Argument(Ty);
760
761 // Remember where this forward reference came from. FIXME, shouldn't we try
762 // to recycle these things??
763 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
764 llvmAsmlineno)));
765
766 if (inFunctionScope())
767 InsertValue(V, CurFun.LateResolveValues);
768 else
769 InsertValue(V, CurModule.LateResolveValues);
770 return V;
771}
772
773/// getBBVal - This is used for two purposes:
774/// * If isDefinition is true, a new basic block with the specified ID is being
775/// defined.
776/// * If isDefinition is true, this is a reference to a basic block, which may
777/// or may not be a forward reference.
778///
779static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
780 assert(inFunctionScope() && "Can't get basic block at global scope!");
781
782 std::string Name;
783 BasicBlock *BB = 0;
784 switch (ID.Type) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000785 default:
786 GenerateError("Illegal label reference " + ID.getName());
787 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000788 case ValID::NumberVal: // Is it a numbered definition?
789 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
790 CurFun.NumberedBlocks.resize(ID.Num+1);
791 BB = CurFun.NumberedBlocks[ID.Num];
792 break;
793 case ValID::NameVal: // Is it a named definition?
794 Name = ID.Name;
795 if (Value *N = CurFun.CurrentFunction->
796 getSymbolTable().lookup(Type::LabelTy, Name))
797 BB = cast<BasicBlock>(N);
798 break;
799 }
800
801 // See if the block has already been defined.
802 if (BB) {
803 // If this is the definition of the block, make sure the existing value was
804 // just a forward reference. If it was a forward reference, there will be
805 // an entry for it in the PlaceHolderInfo map.
Reid Spencer5b7e7532006-09-28 19:28:24 +0000806 if (isDefinition && !CurFun.BBForwardRefs.erase(BB)) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000807 // The existing value was a definition, not a forward reference.
Reid Spencer61c83e02006-08-18 08:43:06 +0000808 GenerateError("Redefinition of label " + ID.getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000809 return 0;
810 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000811
812 ID.destroy(); // Free strdup'd memory.
813 return BB;
814 }
815
816 // Otherwise this block has not been seen before.
817 BB = new BasicBlock("", CurFun.CurrentFunction);
818 if (ID.Type == ValID::NameVal) {
819 BB->setName(ID.Name);
820 } else {
821 CurFun.NumberedBlocks[ID.Num] = BB;
822 }
823
824 // If this is not a definition, keep track of it so we can use it as a forward
825 // reference.
826 if (!isDefinition) {
827 // Remember where this forward reference came from.
828 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
829 } else {
830 // The forward declaration could have been inserted anywhere in the
831 // function: insert it into the correct place now.
832 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
833 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
834 }
835 ID.destroy();
836 return BB;
837}
838
839
840//===----------------------------------------------------------------------===//
841// Code to handle forward references in instructions
842//===----------------------------------------------------------------------===//
843//
844// This code handles the late binding needed with statements that reference
845// values not defined yet... for example, a forward branch, or the PHI node for
846// a loop body.
847//
848// This keeps a table (CurFun.LateResolveValues) of all such forward references
849// and back patchs after we are done.
850//
851
852// ResolveDefinitions - If we could not resolve some defs at parsing
853// time (forward branches, phi functions for loops, etc...) resolve the
854// defs now...
855//
856static void
857ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
858 std::map<const Type*,ValueList> *FutureLateResolvers) {
859 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
860 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
861 E = LateResolvers.end(); LRI != E; ++LRI) {
862 ValueList &List = LRI->second;
863 while (!List.empty()) {
864 Value *V = List.back();
865 List.pop_back();
866
867 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
868 CurModule.PlaceHolderInfo.find(V);
869 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
870
871 ValID &DID = PHI->second.first;
872
873 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000874 if (TriggerError)
875 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000876 if (TheRealValue) {
877 V->replaceAllUsesWith(TheRealValue);
878 delete V;
879 CurModule.PlaceHolderInfo.erase(PHI);
880 } else if (FutureLateResolvers) {
881 // Functions have their unresolved items forwarded to the module late
882 // resolver table
883 InsertValue(V, *FutureLateResolvers);
884 } else {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000885 if (DID.Type == ValID::NameVal) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000886 GenerateError("Reference to an invalid definition: '" +DID.getName()+
Reid Spencer68a24bd2005-08-27 18:50:39 +0000887 "' of type '" + V->getType()->getDescription() + "'",
888 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000889 return;
890 } else {
Reid Spencer61c83e02006-08-18 08:43:06 +0000891 GenerateError("Reference to an invalid definition: #" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000892 itostr(DID.Num) + " of type '" +
893 V->getType()->getDescription() + "'",
894 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000895 return;
896 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000897 }
898 }
899 }
900
901 LateResolvers.clear();
902}
903
904// ResolveTypeTo - A brand new type was just declared. This means that (if
905// name is not null) things referencing Name can be resolved. Otherwise, things
906// refering to the number can be resolved. Do this now.
907//
908static void ResolveTypeTo(char *Name, const Type *ToTy) {
909 ValID D;
910 if (Name) D = ValID::create(Name);
911 else D = ValID::create((int)CurModule.Types.size());
912
Reid Spencer861d9d62006-11-28 07:29:44 +0000913 std::map<ValID, PATypeHolder>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +0000914 CurModule.LateResolveTypes.find(D);
915 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer861d9d62006-11-28 07:29:44 +0000916 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000917 CurModule.LateResolveTypes.erase(I);
918 }
919}
920
921// setValueName - Set the specified value to the name given. The name may be
922// null potentially, in which case this is a noop. The string passed in is
923// assumed to be a malloc'd string buffer, and is free'd by this function.
924//
925static void setValueName(Value *V, char *NameStr) {
926 if (NameStr) {
927 std::string Name(NameStr); // Copy string
928 free(NameStr); // Free old string
929
Reid Spencer5b7e7532006-09-28 19:28:24 +0000930 if (V->getType() == Type::VoidTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000931 GenerateError("Can't assign name '" + Name+"' to value with void type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000932 return;
933 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000934
935 assert(inFunctionScope() && "Must be in function scope!");
936 SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable();
Reid Spencer5b7e7532006-09-28 19:28:24 +0000937 if (ST.lookup(V->getType(), Name)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000938 GenerateError("Redefinition of value named '" + Name + "' in the '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000939 V->getType()->getDescription() + "' type plane!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000940 return;
941 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000942
943 // Set the name.
944 V->setName(Name);
945 }
946}
947
948/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
949/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +0000950static GlobalVariable *
951ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
952 bool isConstantGlobal, const Type *Ty,
953 Constant *Initializer) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000954 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000955 GenerateError("Cannot declare global vars of function type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000956 return 0;
957 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000958
959 const PointerType *PTy = PointerType::get(Ty);
960
961 std::string Name;
962 if (NameStr) {
963 Name = NameStr; // Copy string
964 free(NameStr); // Free old string
965 }
966
967 // See if this global value was forward referenced. If so, recycle the
968 // object.
969 ValID ID;
970 if (!Name.empty()) {
971 ID = ValID::create((char*)Name.c_str());
972 } else {
973 ID = ValID::create((int)CurModule.Values[PTy].size());
974 }
975
976 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
977 // Move the global to the end of the list, from whereever it was
978 // previously inserted.
979 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
980 CurModule.CurrentModule->getGlobalList().remove(GV);
981 CurModule.CurrentModule->getGlobalList().push_back(GV);
982 GV->setInitializer(Initializer);
983 GV->setLinkage(Linkage);
984 GV->setConstant(isConstantGlobal);
985 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000986 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000987 }
988
989 // If this global has a name, check to see if there is already a definition
990 // of this global in the module. If so, merge as appropriate. Note that
991 // this is really just a hack around problems in the CFE. :(
992 if (!Name.empty()) {
993 // We are a simple redefinition of a value, check to see if it is defined
994 // the same as the old one.
995 if (GlobalVariable *EGV =
996 CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
997 // We are allowed to redefine a global variable in two circumstances:
998 // 1. If at least one of the globals is uninitialized or
999 // 2. If both initializers have the same value.
1000 //
1001 if (!EGV->hasInitializer() || !Initializer ||
1002 EGV->getInitializer() == Initializer) {
1003
1004 // Make sure the existing global version gets the initializer! Make
1005 // sure that it also gets marked const if the new version is.
1006 if (Initializer && !EGV->hasInitializer())
1007 EGV->setInitializer(Initializer);
1008 if (isConstantGlobal)
1009 EGV->setConstant(true);
1010 EGV->setLinkage(Linkage);
Chris Lattnerb475c422005-11-12 18:22:38 +00001011 return EGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001012 }
1013
Reid Spencer61c83e02006-08-18 08:43:06 +00001014 GenerateError("Redefinition of global variable named '" + Name +
Reid Spencer68a24bd2005-08-27 18:50:39 +00001015 "' in the '" + Ty->getDescription() + "' type plane!");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001016 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001017 }
1018 }
1019
1020 // Otherwise there is no existing GV to use, create one now.
1021 GlobalVariable *GV =
1022 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
1023 CurModule.CurrentModule);
1024 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001025 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001026}
1027
1028// setTypeName - Set the specified type to the name given. The name may be
1029// null potentially, in which case this is a noop. The string passed in is
1030// assumed to be a malloc'd string buffer, and is freed by this function.
1031//
1032// This function returns true if the type has already been defined, but is
1033// allowed to be redefined in the specified context. If the name is a new name
1034// for the type plane, it is inserted and false is returned.
1035static bool setTypeName(const Type *T, char *NameStr) {
1036 assert(!inFunctionScope() && "Can't give types function-local names!");
1037 if (NameStr == 0) return false;
1038
1039 std::string Name(NameStr); // Copy string
1040 free(NameStr); // Free old string
1041
1042 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +00001043 if (T == Type::VoidTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +00001044 GenerateError("Can't assign name '" + Name + "' to the void type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001045 return false;
1046 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001047
1048 // Set the type name, checking for conflicts as we do so.
1049 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1050
1051 if (AlreadyExists) { // Inserting a name that is already defined???
1052 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
1053 assert(Existing && "Conflict but no matching type?");
1054
1055 // There is only one case where this is allowed: when we are refining an
1056 // opaque type. In this case, Existing will be an opaque type.
1057 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1058 // We ARE replacing an opaque type!
1059 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1060 return true;
1061 }
1062
1063 // Otherwise, this is an attempt to redefine a type. That's okay if
1064 // the redefinition is identical to the original. This will be so if
1065 // Existing and T point to the same Type object. In this one case we
1066 // allow the equivalent redefinition.
1067 if (Existing == T) return true; // Yes, it's equal.
1068
1069 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer61c83e02006-08-18 08:43:06 +00001070 GenerateError("Redefinition of type named '" + Name + "' in the '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00001071 T->getDescription() + "' type plane!");
1072 }
1073
1074 return false;
1075}
1076
1077//===----------------------------------------------------------------------===//
1078// Code for handling upreferences in type names...
1079//
1080
1081// TypeContains - Returns true if Ty directly contains E in it.
1082//
1083static bool TypeContains(const Type *Ty, const Type *E) {
1084 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1085 E) != Ty->subtype_end();
1086}
1087
1088namespace {
1089 struct UpRefRecord {
1090 // NestingLevel - The number of nesting levels that need to be popped before
1091 // this type is resolved.
1092 unsigned NestingLevel;
1093
1094 // LastContainedTy - This is the type at the current binding level for the
1095 // type. Every time we reduce the nesting level, this gets updated.
1096 const Type *LastContainedTy;
1097
1098 // UpRefTy - This is the actual opaque type that the upreference is
1099 // represented with.
1100 OpaqueType *UpRefTy;
1101
1102 UpRefRecord(unsigned NL, OpaqueType *URTy)
1103 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1104 };
1105}
1106
1107// UpRefs - A list of the outstanding upreferences that need to be resolved.
1108static std::vector<UpRefRecord> UpRefs;
1109
1110/// HandleUpRefs - Every time we finish a new layer of types, this function is
1111/// called. It loops through the UpRefs vector, which is a list of the
1112/// currently active types. For each type, if the up reference is contained in
1113/// the newly completed type, we decrement the level count. When the level
1114/// count reaches zero, the upreferenced type is the type that is passed in:
1115/// thus we can complete the cycle.
1116///
1117static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001118 // If Ty isn't abstract, or if there are no up-references in it, then there is
1119 // nothing to resolve here.
1120 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1121
Reid Spencer68a24bd2005-08-27 18:50:39 +00001122 PATypeHolder Ty(ty);
1123 UR_OUT("Type '" << Ty->getDescription() <<
1124 "' newly formed. Resolving upreferences.\n" <<
1125 UpRefs.size() << " upreferences active!\n");
1126
1127 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1128 // to zero), we resolve them all together before we resolve them to Ty. At
1129 // the end of the loop, if there is anything to resolve to Ty, it will be in
1130 // this variable.
1131 OpaqueType *TypeToResolve = 0;
1132
1133 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1134 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1135 << UpRefs[i].second->getDescription() << ") = "
1136 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1137 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1138 // Decrement level of upreference
1139 unsigned Level = --UpRefs[i].NestingLevel;
1140 UpRefs[i].LastContainedTy = Ty;
1141 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1142 if (Level == 0) { // Upreference should be resolved!
1143 if (!TypeToResolve) {
1144 TypeToResolve = UpRefs[i].UpRefTy;
1145 } else {
1146 UR_OUT(" * Resolving upreference for "
1147 << UpRefs[i].second->getDescription() << "\n";
1148 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1149 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1150 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1151 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1152 }
1153 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1154 --i; // Do not skip the next element...
1155 }
1156 }
1157 }
1158
1159 if (TypeToResolve) {
1160 UR_OUT(" * Resolving upreference for "
1161 << UpRefs[i].second->getDescription() << "\n";
1162 std::string OldName = TypeToResolve->getDescription());
1163 TypeToResolve->refineAbstractTypeTo(Ty);
1164 }
1165
1166 return Ty;
1167}
1168
Reid Spencer68a24bd2005-08-27 18:50:39 +00001169// common code from the two 'RunVMAsmParser' functions
Reid Spencer5b7e7532006-09-28 19:28:24 +00001170static Module* RunParser(Module * M) {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001171
1172 llvmAsmlineno = 1; // Reset the current line number...
1173 ObsoleteVarArgs = false;
1174 NewVarArgs = false;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001175 CurModule.CurrentModule = M;
Reid Spencerf63697d2006-10-09 17:36:59 +00001176
1177 // Check to make sure the parser succeeded
1178 if (yyparse()) {
1179 if (ParserResult)
1180 delete ParserResult;
1181 return 0;
1182 }
1183
1184 // Check to make sure that parsing produced a result
Reid Spencer61c83e02006-08-18 08:43:06 +00001185 if (!ParserResult)
1186 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001187
Reid Spencerf63697d2006-10-09 17:36:59 +00001188 // Reset ParserResult variable while saving its value for the result.
Reid Spencer68a24bd2005-08-27 18:50:39 +00001189 Module *Result = ParserResult;
1190 ParserResult = 0;
1191
1192 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
1193 {
1194 Function* F;
1195 if ((F = Result->getNamedFunction("llvm.va_start"))
1196 && F->getFunctionType()->getNumParams() == 0)
1197 ObsoleteVarArgs = true;
1198 if((F = Result->getNamedFunction("llvm.va_copy"))
1199 && F->getFunctionType()->getNumParams() == 1)
1200 ObsoleteVarArgs = true;
1201 }
1202
Reid Spencer5b7e7532006-09-28 19:28:24 +00001203 if (ObsoleteVarArgs && NewVarArgs) {
1204 GenerateError(
1205 "This file is corrupt: it uses both new and old style varargs");
1206 return 0;
1207 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001208
1209 if(ObsoleteVarArgs) {
1210 if(Function* F = Result->getNamedFunction("llvm.va_start")) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001211 if (F->arg_size() != 0) {
Reid Spencer61c83e02006-08-18 08:43:06 +00001212 GenerateError("Obsolete va_start takes 0 argument!");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001213 return 0;
1214 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001215
1216 //foo = va_start()
1217 // ->
1218 //bar = alloca typeof(foo)
1219 //va_start(bar)
1220 //foo = load bar
1221
1222 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1223 const Type* ArgTy = F->getFunctionType()->getReturnType();
1224 const Type* ArgTyPtr = PointerType::get(ArgTy);
1225 Function* NF = Result->getOrInsertFunction("llvm.va_start",
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001226 RetTy, ArgTyPtr, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001227
1228 while (!F->use_empty()) {
1229 CallInst* CI = cast<CallInst>(F->use_back());
1230 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
1231 new CallInst(NF, bar, "", CI);
1232 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
1233 CI->replaceAllUsesWith(foo);
1234 CI->getParent()->getInstList().erase(CI);
1235 }
1236 Result->getFunctionList().erase(F);
1237 }
1238
1239 if(Function* F = Result->getNamedFunction("llvm.va_end")) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001240 if(F->arg_size() != 1) {
Reid Spencer61c83e02006-08-18 08:43:06 +00001241 GenerateError("Obsolete va_end takes 1 argument!");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001242 return 0;
1243 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001244
1245 //vaend foo
1246 // ->
1247 //bar = alloca 1 of typeof(foo)
1248 //vaend bar
1249 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1250 const Type* ArgTy = F->getFunctionType()->getParamType(0);
1251 const Type* ArgTyPtr = PointerType::get(ArgTy);
1252 Function* NF = Result->getOrInsertFunction("llvm.va_end",
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001253 RetTy, ArgTyPtr, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001254
1255 while (!F->use_empty()) {
1256 CallInst* CI = cast<CallInst>(F->use_back());
1257 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
1258 new StoreInst(CI->getOperand(1), bar, CI);
1259 new CallInst(NF, bar, "", CI);
1260 CI->getParent()->getInstList().erase(CI);
1261 }
1262 Result->getFunctionList().erase(F);
1263 }
1264
1265 if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001266 if(F->arg_size() != 1) {
Reid Spencer61c83e02006-08-18 08:43:06 +00001267 GenerateError("Obsolete va_copy takes 1 argument!");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001268 return 0;
1269 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001270 //foo = vacopy(bar)
1271 // ->
1272 //a = alloca 1 of typeof(foo)
1273 //b = alloca 1 of typeof(foo)
1274 //store bar -> b
1275 //vacopy(a, b)
1276 //foo = load a
1277
1278 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1279 const Type* ArgTy = F->getFunctionType()->getReturnType();
1280 const Type* ArgTyPtr = PointerType::get(ArgTy);
1281 Function* NF = Result->getOrInsertFunction("llvm.va_copy",
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001282 RetTy, ArgTyPtr, ArgTyPtr,
1283 (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001284
1285 while (!F->use_empty()) {
1286 CallInst* CI = cast<CallInst>(F->use_back());
1287 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
1288 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
1289 new StoreInst(CI->getOperand(1), b, CI);
1290 new CallInst(NF, a, b, "", CI);
1291 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
1292 CI->replaceAllUsesWith(foo);
1293 CI->getParent()->getInstList().erase(CI);
1294 }
1295 Result->getFunctionList().erase(F);
1296 }
1297 }
1298
1299 return Result;
Reid Spencer5b7e7532006-09-28 19:28:24 +00001300}
Reid Spencer68a24bd2005-08-27 18:50:39 +00001301
1302//===----------------------------------------------------------------------===//
1303// RunVMAsmParser - Define an interface to this parser
1304//===----------------------------------------------------------------------===//
1305//
1306Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1307 set_scan_file(F);
1308
1309 CurFilename = Filename;
1310 return RunParser(new Module(CurFilename));
1311}
1312
1313Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1314 set_scan_string(AsmString);
1315
1316 CurFilename = "from_memory";
1317 if (M == NULL) {
1318 return RunParser(new Module (CurFilename));
1319 } else {
1320 return RunParser(M);
1321 }
1322}
1323
1324
Reid Spencer3822ff52006-11-08 06:47:33 +00001325
1326/* Enabling traces. */
1327#ifndef YYDEBUG
1328# define YYDEBUG 0
1329#endif
1330
1331/* Enabling verbose error messages. */
1332#ifdef YYERROR_VERBOSE
1333# undef YYERROR_VERBOSE
1334# define YYERROR_VERBOSE 1
1335#else
1336# define YYERROR_VERBOSE 0
1337#endif
1338
1339/* Enabling the token table. */
1340#ifndef YYTOKEN_TABLE
1341# define YYTOKEN_TABLE 0
1342#endif
1343
1344#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
Reid Spencera132e042006-12-03 05:46:11 +00001345#line 968 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00001346typedef union YYSTYPE {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001347 llvm::Module *ModuleVal;
1348 llvm::Function *FunctionVal;
Reid Spencera132e042006-12-03 05:46:11 +00001349 std::pair<llvm::PATypeHolder*, char*> *ArgVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001350 llvm::BasicBlock *BasicBlockVal;
1351 llvm::TerminatorInst *TermInstVal;
1352 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001353 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001354
Reid Spencera132e042006-12-03 05:46:11 +00001355 const llvm::Type *PrimType;
1356 llvm::PATypeHolder *TypeVal;
1357 llvm::Value *ValueVal;
1358
1359 std::vector<std::pair<llvm::PATypeHolder*,char*> > *ArgList;
1360 std::vector<llvm::Value*> *ValueList;
1361 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001362 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001363 std::list<std::pair<llvm::Value*,
1364 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001365 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001366 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001367
1368 llvm::GlobalValue::LinkageTypes Linkage;
1369 int64_t SInt64Val;
1370 uint64_t UInt64Val;
1371 int SIntVal;
1372 unsigned UIntVal;
1373 double FPVal;
1374 bool BoolVal;
1375
1376 char *StrVal; // This memory is strdup'd!
Reid Spencer1628cec2006-10-26 06:15:43 +00001377 llvm::ValID ValIDVal; // strdup'd memory maybe!
Reid Spencer68a24bd2005-08-27 18:50:39 +00001378
Reid Spencera132e042006-12-03 05:46:11 +00001379 llvm::Instruction::BinaryOps BinaryOpVal;
1380 llvm::Instruction::TermOps TermOpVal;
1381 llvm::Instruction::MemoryOps MemOpVal;
1382 llvm::Instruction::CastOps CastOpVal;
1383 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencer1628cec2006-10-26 06:15:43 +00001384 llvm::Module::Endianness Endianness;
Reid Spencera132e042006-12-03 05:46:11 +00001385 llvm::ICmpInst::Predicate IPredicate;
1386 llvm::FCmpInst::Predicate FPredicate;
Reid Spencer5b7e7532006-09-28 19:28:24 +00001387} YYSTYPE;
Reid Spencer3822ff52006-11-08 06:47:33 +00001388/* Line 196 of yacc.c. */
Reid Spencera132e042006-12-03 05:46:11 +00001389#line 1390 "llvmAsmParser.tab.c"
Reid Spencer3822ff52006-11-08 06:47:33 +00001390# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1391# define YYSTYPE_IS_DECLARED 1
1392# define YYSTYPE_IS_TRIVIAL 1
Reid Spencer68a24bd2005-08-27 18:50:39 +00001393#endif
1394
1395
1396
Reid Spencer3822ff52006-11-08 06:47:33 +00001397/* Copy the second part of user declarations. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001398
1399
Reid Spencer3822ff52006-11-08 06:47:33 +00001400/* Line 219 of yacc.c. */
Reid Spencera132e042006-12-03 05:46:11 +00001401#line 1402 "llvmAsmParser.tab.c"
Reid Spencer68a24bd2005-08-27 18:50:39 +00001402
Reid Spencer3822ff52006-11-08 06:47:33 +00001403#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
1404# define YYSIZE_T __SIZE_TYPE__
1405#endif
1406#if ! defined (YYSIZE_T) && defined (size_t)
1407# define YYSIZE_T size_t
1408#endif
1409#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
1410# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1411# define YYSIZE_T size_t
1412#endif
1413#if ! defined (YYSIZE_T)
1414# define YYSIZE_T unsigned int
1415#endif
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00001416
Reid Spencer3822ff52006-11-08 06:47:33 +00001417#ifndef YY_
1418# if YYENABLE_NLS
1419# if ENABLE_NLS
1420# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1421# define YY_(msgid) dgettext ("bison-runtime", msgid)
1422# endif
1423# endif
1424# ifndef YY_
1425# define YY_(msgid) msgid
1426# endif
1427#endif
1428
1429#if ! defined (yyoverflow) || YYERROR_VERBOSE
1430
1431/* The parser invokes alloca or malloc; define the necessary symbols. */
1432
1433# ifdef YYSTACK_USE_ALLOCA
1434# if YYSTACK_USE_ALLOCA
1435# ifdef __GNUC__
1436# define YYSTACK_ALLOC __builtin_alloca
1437# else
1438# define YYSTACK_ALLOC alloca
1439# if defined (__STDC__) || defined (__cplusplus)
1440# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1441# define YYINCLUDED_STDLIB_H
1442# endif
1443# endif
1444# endif
1445# endif
1446
1447# ifdef YYSTACK_ALLOC
1448 /* Pacify GCC's `empty if-body' warning. */
1449# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
1450# ifndef YYSTACK_ALLOC_MAXIMUM
1451 /* The OS might guarantee only one guard page at the bottom of the stack,
1452 and a page size can be as small as 4096 bytes. So we cannot safely
1453 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1454 to allow for a few compiler-allocated temporary stack slots. */
1455# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
1456# endif
1457# else
1458# define YYSTACK_ALLOC YYMALLOC
1459# define YYSTACK_FREE YYFREE
1460# ifndef YYSTACK_ALLOC_MAXIMUM
1461# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
1462# endif
1463# ifdef __cplusplus
1464extern "C" {
1465# endif
1466# ifndef YYMALLOC
1467# define YYMALLOC malloc
1468# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
1469 && (defined (__STDC__) || defined (__cplusplus)))
1470void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1471# endif
1472# endif
1473# ifndef YYFREE
1474# define YYFREE free
1475# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
1476 && (defined (__STDC__) || defined (__cplusplus)))
1477void free (void *); /* INFRINGES ON USER NAME SPACE */
1478# endif
1479# endif
1480# ifdef __cplusplus
1481}
1482# endif
1483# endif
1484#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
1485
1486
1487#if (! defined (yyoverflow) \
1488 && (! defined (__cplusplus) \
1489 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
1490
1491/* A type that is properly aligned for any stack member. */
1492union yyalloc
1493{
1494 short int yyss;
1495 YYSTYPE yyvs;
1496 };
1497
1498/* The size of the maximum gap between one aligned stack and the next. */
1499# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1500
1501/* The size of an array large to enough to hold all stacks, each with
1502 N elements. */
1503# define YYSTACK_BYTES(N) \
1504 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
1505 + YYSTACK_GAP_MAXIMUM)
1506
1507/* Copy COUNT objects from FROM to TO. The source and destination do
1508 not overlap. */
1509# ifndef YYCOPY
1510# if defined (__GNUC__) && 1 < __GNUC__
1511# define YYCOPY(To, From, Count) \
1512 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1513# else
1514# define YYCOPY(To, From, Count) \
1515 do \
1516 { \
1517 YYSIZE_T yyi; \
1518 for (yyi = 0; yyi < (Count); yyi++) \
1519 (To)[yyi] = (From)[yyi]; \
1520 } \
1521 while (0)
1522# endif
1523# endif
1524
1525/* Relocate STACK from its old location to the new one. The
1526 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1527 elements in the stack, and YYPTR gives the new location of the
1528 stack. Advance YYPTR to a properly aligned location for the next
1529 stack. */
1530# define YYSTACK_RELOCATE(Stack) \
1531 do \
1532 { \
1533 YYSIZE_T yynewbytes; \
1534 YYCOPY (&yyptr->Stack, Stack, yysize); \
1535 Stack = &yyptr->Stack; \
1536 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1537 yyptr += yynewbytes / sizeof (*yyptr); \
1538 } \
1539 while (0)
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00001540
1541#endif
1542
Reid Spencer3822ff52006-11-08 06:47:33 +00001543#if defined (__STDC__) || defined (__cplusplus)
1544 typedef signed char yysigned_char;
Reid Spencer5b7e7532006-09-28 19:28:24 +00001545#else
Reid Spencer3822ff52006-11-08 06:47:33 +00001546 typedef short int yysigned_char;
Reid Spencer5b7e7532006-09-28 19:28:24 +00001547#endif
1548
Reid Spencer3822ff52006-11-08 06:47:33 +00001549/* YYFINAL -- State number of the termination state. */
1550#define YYFINAL 4
1551/* YYLAST -- Last index in YYTABLE. */
Reid Spencera132e042006-12-03 05:46:11 +00001552#define YYLAST 1503
Reid Spencer3822ff52006-11-08 06:47:33 +00001553
1554/* YYNTOKENS -- Number of terminals. */
Reid Spencera132e042006-12-03 05:46:11 +00001555#define YYNTOKENS 165
Reid Spencer3822ff52006-11-08 06:47:33 +00001556/* YYNNTS -- Number of nonterminals. */
Reid Spencera132e042006-12-03 05:46:11 +00001557#define YYNNTS 78
Reid Spencer3822ff52006-11-08 06:47:33 +00001558/* YYNRULES -- Number of rules. */
Reid Spencera132e042006-12-03 05:46:11 +00001559#define YYNRULES 297
Reid Spencer3822ff52006-11-08 06:47:33 +00001560/* YYNRULES -- Number of states. */
Reid Spencera132e042006-12-03 05:46:11 +00001561#define YYNSTATES 586
Reid Spencer3822ff52006-11-08 06:47:33 +00001562
1563/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1564#define YYUNDEFTOK 2
Reid Spencera132e042006-12-03 05:46:11 +00001565#define YYMAXUTOK 405
Reid Spencer3822ff52006-11-08 06:47:33 +00001566
1567#define YYTRANSLATE(YYX) \
1568 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1569
1570/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1571static const unsigned char yytranslate[] =
1572{
1573 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1574 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1575 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1576 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencera132e042006-12-03 05:46:11 +00001577 154, 155, 163, 2, 152, 2, 2, 2, 2, 2,
Reid Spencer3822ff52006-11-08 06:47:33 +00001578 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencera132e042006-12-03 05:46:11 +00001579 159, 151, 160, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer3822ff52006-11-08 06:47:33 +00001580 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1581 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencera132e042006-12-03 05:46:11 +00001582 2, 156, 153, 158, 2, 2, 2, 2, 2, 164,
Reid Spencer3822ff52006-11-08 06:47:33 +00001583 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1584 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencera132e042006-12-03 05:46:11 +00001585 157, 2, 2, 161, 2, 162, 2, 2, 2, 2,
Reid Spencer3822ff52006-11-08 06:47:33 +00001586 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, 2, 2, 2, 2,
1591 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1592 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1593 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1594 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1595 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1596 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1597 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1598 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1599 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1600 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1601 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1602 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1603 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1604 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1605 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1606 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1607 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1608 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
Reid Spencer3da59db2006-11-27 01:05:10 +00001609 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
Reid Spencera132e042006-12-03 05:46:11 +00001610 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1611 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
1612 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
1613 145, 146, 147, 148, 149, 150
Reid Spencer3822ff52006-11-08 06:47:33 +00001614};
1615
1616#if YYDEBUG
1617/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1618 YYRHS. */
1619static const unsigned short int yyprhs[] =
1620{
1621 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1622 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1623 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1624 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
Reid Spencer3da59db2006-11-27 01:05:10 +00001625 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
Reid Spencera132e042006-12-03 05:46:11 +00001626 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
1627 119, 121, 123, 125, 127, 129, 131, 133, 135, 137,
1628 139, 141, 143, 145, 147, 149, 152, 153, 155, 157,
1629 159, 161, 163, 165, 167, 168, 169, 171, 173, 175,
1630 177, 179, 181, 184, 185, 188, 189, 193, 196, 197,
1631 199, 200, 204, 206, 209, 211, 213, 215, 217, 219,
1632 221, 223, 225, 227, 229, 231, 233, 235, 237, 239,
1633 241, 243, 245, 247, 249, 251, 254, 259, 265, 271,
1634 275, 278, 281, 283, 287, 289, 293, 295, 296, 301,
1635 305, 309, 314, 319, 323, 326, 329, 332, 335, 338,
1636 341, 344, 347, 350, 353, 360, 366, 375, 382, 389,
1637 396, 405, 414, 421, 428, 437, 446, 450, 452, 454,
1638 456, 458, 461, 464, 469, 472, 474, 479, 482, 487,
1639 488, 496, 497, 505, 506, 514, 515, 523, 527, 532,
1640 533, 535, 537, 539, 543, 547, 551, 555, 559, 563,
1641 565, 566, 568, 570, 572, 573, 576, 580, 582, 584,
1642 588, 590, 591, 600, 602, 604, 608, 610, 612, 615,
1643 616, 618, 620, 621, 626, 627, 629, 631, 633, 635,
1644 637, 639, 641, 643, 645, 649, 651, 657, 659, 661,
1645 663, 665, 668, 671, 674, 678, 681, 682, 684, 687,
1646 690, 694, 704, 714, 723, 737, 739, 741, 748, 754,
1647 757, 764, 772, 774, 778, 780, 781, 784, 786, 792,
1648 798, 804, 811, 818, 821, 826, 831, 838, 843, 848,
1649 853, 858, 865, 872, 875, 883, 885, 888, 889, 891,
1650 892, 896, 903, 907, 914, 917, 922, 929
Reid Spencer3822ff52006-11-08 06:47:33 +00001651};
1652
1653/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1654static const short int yyrhs[] =
1655{
Reid Spencera132e042006-12-03 05:46:11 +00001656 199, 0, -1, 5, -1, 6, -1, 3, -1, 4,
Reid Spencer3822ff52006-11-08 06:47:33 +00001657 -1, 78, -1, 79, -1, 80, -1, 81, -1, 82,
1658 -1, 83, -1, 84, -1, 85, -1, 86, -1, 87,
1659 -1, 88, -1, 89, -1, 90, -1, 91, -1, 92,
Reid Spencera132e042006-12-03 05:46:11 +00001660 -1, 93, -1, 94, -1, 95, -1, 128, -1, 129,
1661 -1, 130, -1, 131, -1, 132, -1, 133, -1, 134,
1662 -1, 135, -1, 136, -1, 137, -1, 138, -1, 139,
1663 -1, 142, -1, 143, -1, 144, -1, 98, -1, 99,
1664 -1, 100, -1, 101, -1, 102, -1, 103, -1, 104,
1665 -1, 105, -1, 106, -1, 107, -1, 108, -1, 109,
1666 -1, 110, -1, 111, -1, 112, -1, 113, -1, 114,
1667 -1, 115, -1, 116, -1, 117, -1, 118, -1, 119,
1668 -1, 120, -1, 121, -1, 16, -1, 14, -1, 12,
1669 -1, 10, -1, 17, -1, 15, -1, 13, -1, 11,
1670 -1, 175, -1, 176, -1, 18, -1, 19, -1, 211,
1671 151, -1, -1, 41, -1, 42, -1, 43, -1, 44,
1672 -1, 45, -1, 46, -1, 47, -1, -1, -1, 65,
1673 -1, 66, -1, 67, -1, 68, -1, 69, -1, 70,
1674 -1, 64, 4, -1, -1, 57, 4, -1, -1, 152,
1675 57, 4, -1, 34, 24, -1, -1, 184, -1, -1,
1676 152, 187, 186, -1, 184, -1, 57, 4, -1, 190,
1677 -1, 8, -1, 192, -1, 8, -1, 192, -1, 9,
1678 -1, 10, -1, 11, -1, 12, -1, 13, -1, 14,
1679 -1, 15, -1, 16, -1, 17, -1, 18, -1, 19,
1680 -1, 20, -1, 21, -1, 48, -1, 191, -1, 226,
1681 -1, 153, 4, -1, 189, 154, 194, 155, -1, 156,
1682 4, 157, 192, 158, -1, 159, 4, 157, 192, 160,
1683 -1, 161, 193, 162, -1, 161, 162, -1, 192, 163,
1684 -1, 192, -1, 193, 152, 192, -1, 193, -1, 193,
1685 152, 37, -1, 37, -1, -1, 190, 156, 197, 158,
1686 -1, 190, 156, 158, -1, 190, 164, 24, -1, 190,
1687 159, 197, 160, -1, 190, 161, 197, 162, -1, 190,
1688 161, 162, -1, 190, 38, -1, 190, 39, -1, 190,
1689 226, -1, 190, 196, -1, 190, 26, -1, 175, 167,
1690 -1, 176, 4, -1, 9, 27, -1, 9, 28, -1,
1691 178, 7, -1, 171, 154, 195, 36, 190, 155, -1,
1692 127, 154, 195, 240, 155, -1, 141, 154, 195, 152,
1693 195, 152, 195, 155, -1, 168, 154, 195, 152, 195,
1694 155, -1, 169, 154, 195, 152, 195, 155, -1, 170,
1695 154, 195, 152, 195, 155, -1, 96, 154, 173, 152,
1696 195, 152, 195, 155, -1, 97, 154, 174, 152, 195,
1697 152, 195, 155, -1, 172, 154, 195, 152, 195, 155,
1698 -1, 146, 154, 195, 152, 195, 155, -1, 147, 154,
1699 195, 152, 195, 152, 195, 155, -1, 148, 154, 195,
1700 152, 195, 152, 195, 155, -1, 197, 152, 195, -1,
1701 195, -1, 32, -1, 33, -1, 200, -1, 200, 220,
1702 -1, 200, 222, -1, 200, 62, 61, 206, -1, 200,
1703 25, -1, 201, -1, 201, 179, 20, 188, -1, 201,
1704 222, -1, 201, 62, 61, 206, -1, -1, 201, 179,
1705 180, 198, 195, 202, 186, -1, -1, 201, 179, 50,
1706 198, 190, 203, 186, -1, -1, 201, 179, 45, 198,
1707 190, 204, 186, -1, -1, 201, 179, 47, 198, 190,
1708 205, 186, -1, 201, 51, 208, -1, 201, 58, 151,
1709 209, -1, -1, 24, -1, 56, -1, 55, -1, 53,
1710 151, 207, -1, 54, 151, 4, -1, 52, 151, 24,
1711 -1, 71, 151, 24, -1, 156, 210, 158, -1, 210,
1712 152, 24, -1, 24, -1, -1, 22, -1, 24, -1,
1713 211, -1, -1, 190, 212, -1, 214, 152, 213, -1,
1714 213, -1, 214, -1, 214, 152, 37, -1, 37, -1,
1715 -1, 181, 188, 211, 154, 215, 155, 185, 182, -1,
1716 29, -1, 161, -1, 180, 216, 217, -1, 30, -1,
1717 162, -1, 229, 219, -1, -1, 45, -1, 47, -1,
1718 -1, 31, 223, 221, 216, -1, -1, 63, -1, 3,
1719 -1, 4, -1, 7, -1, 27, -1, 28, -1, 38,
1720 -1, 39, -1, 26, -1, 159, 197, 160, -1, 196,
1721 -1, 61, 224, 24, 152, 24, -1, 166, -1, 211,
1722 -1, 226, -1, 225, -1, 190, 227, -1, 229, 230,
1723 -1, 218, 230, -1, 231, 179, 232, -1, 231, 234,
1724 -1, -1, 23, -1, 72, 228, -1, 72, 8, -1,
1725 73, 21, 227, -1, 73, 9, 227, 152, 21, 227,
1726 152, 21, 227, -1, 74, 177, 227, 152, 21, 227,
1727 156, 233, 158, -1, 74, 177, 227, 152, 21, 227,
1728 156, 158, -1, 75, 181, 188, 227, 154, 237, 155,
1729 36, 21, 227, 76, 21, 227, -1, 76, -1, 77,
1730 -1, 233, 177, 225, 152, 21, 227, -1, 177, 225,
1731 152, 21, 227, -1, 179, 239, -1, 190, 156, 227,
1732 152, 227, 158, -1, 235, 152, 156, 227, 152, 227,
1733 158, -1, 228, -1, 236, 152, 228, -1, 236, -1,
1734 -1, 60, 59, -1, 59, -1, 168, 190, 227, 152,
1735 227, -1, 169, 190, 227, 152, 227, -1, 170, 190,
1736 227, 152, 227, -1, 96, 173, 190, 227, 152, 227,
1737 -1, 97, 174, 190, 227, 152, 227, -1, 49, 228,
1738 -1, 172, 228, 152, 228, -1, 171, 228, 36, 190,
1739 -1, 141, 228, 152, 228, 152, 228, -1, 145, 228,
1740 152, 190, -1, 149, 228, 152, 190, -1, 150, 228,
1741 152, 190, -1, 146, 228, 152, 228, -1, 147, 228,
1742 152, 228, 152, 228, -1, 148, 228, 152, 228, 152,
1743 228, -1, 140, 235, -1, 238, 181, 188, 227, 154,
1744 237, 155, -1, 242, -1, 152, 236, -1, -1, 35,
1745 -1, -1, 122, 190, 183, -1, 122, 190, 152, 15,
1746 227, 183, -1, 123, 190, 183, -1, 123, 190, 152,
1747 15, 227, 183, -1, 124, 228, -1, 241, 125, 190,
1748 227, -1, 241, 126, 228, 152, 190, 227, -1, 127,
1749 190, 227, 240, -1
Reid Spencer3822ff52006-11-08 06:47:33 +00001750};
1751
1752/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1753static const unsigned short int yyrline[] =
1754{
Reid Spencera132e042006-12-03 05:46:11 +00001755 0, 1105, 1105, 1106, 1114, 1115, 1125, 1125, 1125, 1125,
1756 1125, 1125, 1125, 1125, 1125, 1126, 1126, 1126, 1127, 1127,
1757 1127, 1127, 1127, 1127, 1128, 1128, 1128, 1128, 1128, 1128,
1758 1129, 1129, 1129, 1129, 1129, 1129, 1130, 1130, 1130, 1131,
1759 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1132,
1760 1132, 1132, 1132, 1132, 1132, 1132, 1132, 1133, 1133, 1133,
1761 1133, 1133, 1133, 1137, 1137, 1137, 1137, 1138, 1138, 1138,
1762 1138, 1139, 1139, 1140, 1140, 1143, 1147, 1152, 1153, 1154,
1763 1155, 1156, 1157, 1158, 1159, 1161, 1162, 1163, 1164, 1165,
1764 1166, 1167, 1168, 1177, 1178, 1184, 1185, 1193, 1201, 1202,
1765 1207, 1208, 1209, 1214, 1228, 1228, 1229, 1229, 1231, 1241,
1766 1241, 1241, 1241, 1241, 1241, 1241, 1242, 1242, 1242, 1242,
1767 1242, 1242, 1243, 1247, 1251, 1259, 1267, 1280, 1285, 1297,
1768 1307, 1311, 1322, 1327, 1333, 1334, 1338, 1342, 1353, 1379,
1769 1393, 1423, 1449, 1470, 1483, 1493, 1498, 1559, 1566, 1574,
1770 1580, 1586, 1590, 1594, 1602, 1614, 1646, 1654, 1678, 1689,
1771 1695, 1700, 1705, 1714, 1720, 1726, 1735, 1739, 1747, 1747,
1772 1757, 1765, 1770, 1774, 1778, 1782, 1797, 1819, 1822, 1825,
1773 1825, 1833, 1833, 1841, 1841, 1849, 1849, 1858, 1861, 1864,
1774 1868, 1881, 1882, 1884, 1888, 1897, 1901, 1906, 1908, 1913,
1775 1918, 1927, 1927, 1928, 1928, 1930, 1937, 1943, 1950, 1954,
1776 1960, 1965, 1970, 2065, 2065, 2067, 2075, 2075, 2077, 2082,
1777 2083, 2084, 2086, 2086, 2096, 2100, 2105, 2109, 2113, 2117,
1778 2121, 2125, 2129, 2133, 2137, 2162, 2166, 2180, 2184, 2190,
1779 2190, 2196, 2201, 2205, 2214, 2225, 2234, 2246, 2259, 2263,
1780 2267, 2272, 2281, 2300, 2309, 2365, 2369, 2376, 2387, 2400,
1781 2409, 2418, 2428, 2432, 2439, 2439, 2441, 2445, 2450, 2469,
1782 2484, 2498, 2509, 2520, 2533, 2542, 2553, 2561, 2567, 2587,
1783 2610, 2616, 2622, 2628, 2643, 2702, 2709, 2712, 2717, 2721,
1784 2728, 2733, 2739, 2744, 2750, 2758, 2770, 2785
Reid Spencer3822ff52006-11-08 06:47:33 +00001785};
1786#endif
1787
1788#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1789/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1790 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1791static const char *const yytname[] =
1792{
1793 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL",
1794 "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT",
1795 "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL",
1796 "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION",
1797 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
1798 "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO",
1799 "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE",
1800 "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
1801 "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE",
1802 "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE",
1803 "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK",
1804 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
1805 "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE", "ADD", "SUB",
1806 "MUL", "UDIV", "SDIV", "FDIV", "UREM", "SREM", "FREM", "AND", "OR",
Reid Spencera132e042006-12-03 05:46:11 +00001807 "XOR", "SETLE", "SETGE", "SETLT", "SETGT", "SETEQ", "SETNE", "ICMP",
1808 "FCMP", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT", "UGT", "ULE",
1809 "UGE", "ORDEQ", "ORDNE", "ORDLT", "ORDGT", "ORDLE", "ORDGE", "ORD",
1810 "UNO", "UNOEQ", "UNONE", "UNOLT", "UNOGT", "UNOLE", "UNOGE", "MALLOC",
Reid Spencer3da59db2006-11-27 01:05:10 +00001811 "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR", "TRUNC", "ZEXT",
1812 "SEXT", "FPTRUNC", "FPEXT", "BITCAST", "UITOFP", "SITOFP", "FPTOUI",
1813 "FPTOSI", "INTTOPTR", "PTRTOINT", "PHI_TOK", "SELECT", "SHL", "LSHR",
1814 "ASHR", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR",
1815 "VAARG_old", "VANEXT_old", "'='", "','", "'\\\\'", "'('", "')'", "'['",
1816 "'x'", "']'", "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept",
1817 "INTVAL", "EINT64VAL", "ArithmeticOps", "LogicalOps", "SetCondOps",
Reid Spencera132e042006-12-03 05:46:11 +00001818 "CastOps", "ShiftOps", "IPredicates", "FPredicates", "SIntType",
1819 "UIntType", "IntType", "FPType", "OptAssign", "OptLinkage",
1820 "OptCallingConv", "OptAlign", "OptCAlign", "SectionString", "OptSection",
1821 "GlobalVarAttributes", "GlobalVarAttribute", "TypesV", "UpRTypesV",
1822 "Types", "PrimType", "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal",
1823 "ConstExpr", "ConstVector", "GlobalType", "Module", "FunctionList",
1824 "ConstPool", "@1", "@2", "@3", "@4", "AsmBlock", "BigOrLittle",
1825 "TargetDefinition", "LibrariesDefinition", "LibList", "Name", "OptName",
1826 "ArgVal", "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN",
1827 "FunctionHeader", "END", "Function", "FnDeclareLinkage", "FunctionProto",
1828 "@5", "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef",
Reid Spencer3822ff52006-11-08 06:47:33 +00001829 "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList",
1830 "BBTerminatorInst", "JumpTable", "Inst", "PHIList", "ValueRefList",
1831 "ValueRefListE", "OptTailCall", "InstVal", "IndexList", "OptVolatile",
1832 "MemoryInst", 0
1833};
1834#endif
1835
1836# ifdef YYPRINT
1837/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1838 token YYLEX-NUM. */
1839static const unsigned short int yytoknum[] =
1840{
1841 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1842 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1843 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1844 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1845 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1846 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1847 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1848 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1849 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1850 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1851 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
Reid Spencer3da59db2006-11-27 01:05:10 +00001852 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
Reid Spencera132e042006-12-03 05:46:11 +00001853 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
1854 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
1855 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
1856 405, 61, 44, 92, 40, 41, 91, 120, 93, 60,
1857 62, 123, 125, 42, 99
Reid Spencer3822ff52006-11-08 06:47:33 +00001858};
1859# endif
1860
1861/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1862static const unsigned char yyr1[] =
1863{
Reid Spencera132e042006-12-03 05:46:11 +00001864 0, 165, 166, 166, 167, 167, 168, 168, 168, 168,
1865 168, 168, 168, 168, 168, 169, 169, 169, 170, 170,
1866 170, 170, 170, 170, 171, 171, 171, 171, 171, 171,
1867 171, 171, 171, 171, 171, 171, 172, 172, 172, 173,
1868 173, 173, 173, 173, 173, 173, 173, 173, 173, 174,
1869 174, 174, 174, 174, 174, 174, 174, 174, 174, 174,
1870 174, 174, 174, 175, 175, 175, 175, 176, 176, 176,
1871 176, 177, 177, 178, 178, 179, 179, 180, 180, 180,
1872 180, 180, 180, 180, 180, 181, 181, 181, 181, 181,
1873 181, 181, 181, 182, 182, 183, 183, 184, 185, 185,
1874 186, 186, 187, 187, 188, 188, 189, 189, 190, 191,
1875 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
1876 191, 191, 192, 192, 192, 192, 192, 192, 192, 192,
1877 192, 192, 193, 193, 194, 194, 194, 194, 195, 195,
1878 195, 195, 195, 195, 195, 195, 195, 195, 195, 195,
1879 195, 195, 195, 195, 196, 196, 196, 196, 196, 196,
1880 196, 196, 196, 196, 196, 196, 197, 197, 198, 198,
1881 199, 200, 200, 200, 200, 200, 201, 201, 201, 202,
1882 201, 203, 201, 204, 201, 205, 201, 201, 201, 201,
1883 206, 207, 207, 208, 208, 208, 208, 209, 210, 210,
1884 210, 211, 211, 212, 212, 213, 214, 214, 215, 215,
1885 215, 215, 216, 217, 217, 218, 219, 219, 220, 221,
1886 221, 221, 223, 222, 224, 224, 225, 225, 225, 225,
1887 225, 225, 225, 225, 225, 225, 225, 226, 226, 227,
1888 227, 228, 229, 229, 230, 231, 231, 231, 232, 232,
1889 232, 232, 232, 232, 232, 232, 232, 233, 233, 234,
1890 235, 235, 236, 236, 237, 237, 238, 238, 239, 239,
1891 239, 239, 239, 239, 239, 239, 239, 239, 239, 239,
1892 239, 239, 239, 239, 239, 239, 240, 240, 241, 241,
1893 242, 242, 242, 242, 242, 242, 242, 242
Reid Spencer3822ff52006-11-08 06:47:33 +00001894};
1895
1896/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
1897static const unsigned char yyr2[] =
1898{
1899 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1900 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1901 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Reid Spencer3822ff52006-11-08 06:47:33 +00001902 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Reid Spencer3da59db2006-11-27 01:05:10 +00001903 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Reid Spencer3da59db2006-11-27 01:05:10 +00001904 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1905 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Reid Spencera132e042006-12-03 05:46:11 +00001906 1, 1, 1, 1, 1, 2, 0, 1, 1, 1,
1907 1, 1, 1, 1, 0, 0, 1, 1, 1, 1,
1908 1, 1, 2, 0, 2, 0, 3, 2, 0, 1,
1909 0, 3, 1, 2, 1, 1, 1, 1, 1, 1,
1910 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1911 1, 1, 1, 1, 1, 2, 4, 5, 5, 3,
1912 2, 2, 1, 3, 1, 3, 1, 0, 4, 3,
1913 3, 4, 4, 3, 2, 2, 2, 2, 2, 2,
1914 2, 2, 2, 2, 6, 5, 8, 6, 6, 6,
1915 8, 8, 6, 6, 8, 8, 3, 1, 1, 1,
1916 1, 2, 2, 4, 2, 1, 4, 2, 4, 0,
1917 7, 0, 7, 0, 7, 0, 7, 3, 4, 0,
1918 1, 1, 1, 3, 3, 3, 3, 3, 3, 1,
1919 0, 1, 1, 1, 0, 2, 3, 1, 1, 3,
1920 1, 0, 8, 1, 1, 3, 1, 1, 2, 0,
1921 1, 1, 0, 4, 0, 1, 1, 1, 1, 1,
1922 1, 1, 1, 1, 3, 1, 5, 1, 1, 1,
1923 1, 2, 2, 2, 3, 2, 0, 1, 2, 2,
1924 3, 9, 9, 8, 13, 1, 1, 6, 5, 2,
1925 6, 7, 1, 3, 1, 0, 2, 1, 5, 5,
1926 5, 6, 6, 2, 4, 4, 6, 4, 4, 4,
1927 4, 6, 6, 2, 7, 1, 2, 0, 1, 0,
1928 3, 6, 3, 6, 2, 4, 6, 4
Reid Spencer3822ff52006-11-08 06:47:33 +00001929};
1930
1931/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
1932 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
1933 means the default is an error. */
1934static const unsigned short int yydefact[] =
1935{
Reid Spencera132e042006-12-03 05:46:11 +00001936 189, 0, 84, 175, 1, 174, 222, 77, 78, 79,
1937 80, 81, 82, 83, 0, 85, 246, 171, 172, 246,
1938 201, 202, 0, 0, 0, 84, 0, 177, 219, 0,
1939 0, 86, 87, 88, 89, 90, 91, 0, 0, 247,
1940 243, 76, 216, 217, 218, 242, 0, 0, 0, 0,
1941 187, 0, 0, 0, 0, 0, 0, 0, 75, 220,
1942 221, 85, 190, 173, 92, 2, 3, 105, 109, 110,
1943 111, 112, 113, 114, 115, 116, 117, 118, 119, 120,
1944 121, 122, 0, 0, 0, 0, 237, 0, 0, 104,
1945 123, 108, 238, 124, 213, 214, 215, 289, 245, 0,
1946 0, 0, 0, 200, 188, 178, 176, 168, 169, 0,
1947 0, 0, 0, 223, 125, 0, 0, 107, 130, 132,
1948 0, 0, 137, 131, 288, 0, 267, 0, 0, 0,
1949 0, 85, 255, 256, 6, 7, 8, 9, 10, 11,
Reid Spencer3822ff52006-11-08 06:47:33 +00001950 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
Reid Spencera132e042006-12-03 05:46:11 +00001951 22, 23, 0, 0, 0, 0, 0, 0, 24, 25,
1952 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
1953 0, 0, 36, 37, 38, 0, 0, 0, 0, 0,
1954 0, 0, 0, 0, 0, 0, 244, 85, 259, 0,
1955 285, 195, 192, 191, 193, 194, 196, 199, 0, 183,
1956 185, 181, 109, 110, 111, 112, 113, 114, 115, 116,
1957 117, 118, 119, 0, 0, 0, 0, 179, 0, 0,
1958 0, 129, 211, 136, 134, 0, 0, 273, 266, 249,
1959 248, 0, 0, 66, 70, 65, 69, 64, 68, 63,
1960 67, 71, 72, 0, 0, 39, 40, 41, 42, 43,
1961 44, 45, 46, 47, 48, 0, 49, 50, 51, 52,
1962 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
1963 0, 95, 95, 294, 0, 0, 283, 0, 0, 0,
Reid Spencer3822ff52006-11-08 06:47:33 +00001964 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencera132e042006-12-03 05:46:11 +00001965 0, 0, 0, 197, 100, 100, 100, 151, 152, 4,
1966 5, 149, 150, 153, 148, 144, 145, 0, 0, 0,
Reid Spencer3822ff52006-11-08 06:47:33 +00001967 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencera132e042006-12-03 05:46:11 +00001968 0, 0, 0, 147, 146, 100, 106, 106, 133, 210,
1969 204, 207, 208, 0, 0, 126, 226, 227, 228, 233,
1970 229, 230, 231, 232, 224, 0, 235, 240, 239, 241,
1971 0, 250, 0, 0, 0, 0, 0, 290, 0, 292,
1972 287, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1973 0, 0, 0, 0, 0, 0, 0, 0, 198, 0,
1974 184, 186, 182, 0, 0, 0, 0, 0, 0, 0,
1975 139, 167, 0, 0, 143, 0, 140, 0, 0, 0,
1976 0, 0, 180, 127, 128, 203, 205, 0, 98, 135,
1977 225, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1978 0, 0, 297, 0, 0, 0, 277, 280, 0, 0,
1979 278, 279, 0, 0, 0, 275, 274, 0, 295, 0,
1980 0, 0, 102, 100, 0, 0, 287, 0, 0, 0,
1981 0, 0, 138, 141, 142, 0, 0, 0, 0, 0,
1982 209, 206, 99, 93, 0, 234, 0, 0, 265, 0,
1983 0, 95, 96, 95, 262, 286, 0, 0, 0, 0,
1984 0, 268, 269, 270, 265, 0, 97, 103, 101, 0,
1985 0, 0, 0, 0, 0, 0, 166, 0, 0, 0,
1986 0, 0, 0, 212, 0, 0, 0, 264, 0, 271,
1987 272, 0, 291, 293, 0, 0, 0, 276, 281, 282,
1988 0, 296, 0, 0, 155, 0, 0, 0, 0, 0,
1989 0, 0, 0, 0, 94, 236, 0, 0, 0, 263,
1990 260, 0, 284, 0, 0, 0, 163, 0, 0, 157,
1991 158, 159, 154, 162, 0, 253, 0, 0, 0, 261,
1992 0, 0, 0, 0, 0, 251, 0, 252, 0, 0,
1993 160, 161, 156, 164, 165, 0, 0, 0, 0, 0,
1994 0, 258, 0, 0, 257, 254
Reid Spencer3822ff52006-11-08 06:47:33 +00001995};
1996
1997/* YYDEFGOTO[NTERM-NUM]. */
1998static const short int yydefgoto[] =
1999{
Reid Spencera132e042006-12-03 05:46:11 +00002000 -1, 86, 301, 318, 319, 320, 321, 322, 255, 270,
2001 213, 214, 243, 215, 25, 15, 37, 503, 357, 442,
2002 463, 380, 443, 87, 88, 216, 90, 91, 120, 225,
2003 391, 346, 392, 109, 1, 2, 3, 325, 296, 294,
2004 295, 63, 194, 50, 104, 198, 92, 406, 331, 332,
2005 333, 38, 96, 16, 44, 17, 61, 18, 28, 411,
2006 347, 93, 349, 474, 19, 40, 41, 186, 557, 98,
2007 276, 507, 508, 187, 188, 422, 189, 190
Reid Spencer3822ff52006-11-08 06:47:33 +00002008};
2009
2010/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2011 STATE-NUM. */
Reid Spencera132e042006-12-03 05:46:11 +00002012#define YYPACT_NINF -531
Reid Spencer3822ff52006-11-08 06:47:33 +00002013static const short int yypact[] =
2014{
Reid Spencera132e042006-12-03 05:46:11 +00002015 -531, 114, 234, 65, -531, -531, -531, -531, -531, -531,
2016 -531, -531, -531, -531, 74, 132, 47, -531, -531, -13,
2017 -531, -531, 24, -15, 98, 145, 13, -531, 84, 153,
2018 175, -531, -531, -531, -531, -531, -531, 1181, -24, -531,
2019 -531, 108, -531, -531, -531, -531, 29, 30, 32, 33,
2020 -531, 26, 153, 1181, 10, 10, 10, 10, -531, -531,
2021 -531, 132, -531, -531, -531, -531, -531, 50, -531, -531,
2022 -531, -531, -531, -531, -531, -531, -531, -531, -531, -531,
2023 -531, -531, 202, 204, 205, 593, -531, 108, 56, -531,
2024 -531, -70, -531, -531, -531, -531, -531, 1353, -531, 187,
2025 70, 209, 190, 192, -531, -531, -531, -531, -531, 1201,
2026 1201, 1201, 1242, -531, -531, 62, 63, -531, -531, -70,
2027 -140, 68, 982, -531, -531, 1201, -531, 164, 1262, 0,
2028 273, 132, -531, -531, -531, -531, -531, -531, -531, -531,
2029 -531, -531, -531, -531, -531, -531, -531, -531, -531, -531,
2030 -531, -531, 216, 516, 1201, 1201, 1201, 1201, -531, -531,
2031 -531, -531, -531, -531, -531, -531, -531, -531, -531, -531,
2032 1201, 1201, -531, -531, -531, 1201, 1201, 1201, 1201, 1201,
2033 1201, 1201, 1201, 1201, 1201, 1201, -531, 132, -531, 31,
2034 -531, -531, -531, -531, -531, -531, -531, -531, -72, -531,
2035 -531, -531, 133, 159, 220, 163, 221, 165, 222, 167,
2036 223, 225, 228, 172, 224, 229, 433, -531, 1201, 1201,
2037 1201, -531, 1023, -531, 85, 83, 684, -531, -531, 50,
2038 -531, 684, 684, -531, -531, -531, -531, -531, -531, -531,
2039 -531, -531, -531, 684, 1181, -531, -531, -531, -531, -531,
2040 -531, -531, -531, -531, -531, 1201, -531, -531, -531, -531,
2041 -531, -531, -531, -531, -531, -531, -531, -531, -531, -531,
2042 1201, 88, 89, -531, 684, 86, 91, 92, 93, 95,
2043 99, 103, 104, 106, 684, 684, 684, 226, 109, 1181,
2044 1201, 1201, 236, -531, 116, 116, 116, -531, -531, -531,
2045 -531, -531, -531, -531, -531, -531, -531, 117, 118, 120,
2046 143, 144, 148, 154, 927, 1242, 648, 246, 155, 156,
2047 157, 170, 171, -531, -531, 116, -59, -39, -70, -531,
2048 108, -531, 147, 179, 1084, -531, -531, -531, -531, -531,
2049 -531, -531, -531, -531, 272, 1242, -531, -531, -531, -531,
2050 186, -531, 188, 684, 684, 684, -1, -531, 9, -531,
2051 189, 684, 183, 1201, 1201, 1201, 1201, 1201, 1201, 1201,
2052 193, 194, 195, 1201, 1201, 684, 684, 196, -531, -19,
2053 -531, -531, -531, 216, 516, 1242, 1242, 1242, 1242, 1242,
2054 -531, -531, -30, -60, -531, -83, -531, 1242, 1242, 1242,
2055 1242, 1242, -531, -531, -531, -531, -531, 1140, 308, -531,
2056 -531, 320, -47, 328, 329, 198, 206, 207, 684, 352,
2057 684, 1201, -531, 208, 684, 212, -531, -531, 213, 215,
2058 -531, -531, 684, 684, 684, -531, -531, 214, -531, 1201,
2059 345, 367, -531, 116, 230, 231, 189, 233, 235, 237,
2060 238, 1242, -531, -531, -531, 239, 240, 241, 336, 242,
2061 -531, -531, -531, 316, 254, -531, 684, 684, 1201, 684,
2062 684, 258, -531, 258, -531, 259, 684, 260, 1201, 1201,
2063 1201, -531, -531, -531, 1201, 684, -531, -531, -531, 1242,
2064 1242, 219, 1242, 1242, 1242, 1242, -531, 1242, 1242, 1242,
2065 1201, 1242, 372, -531, 353, 261, 232, 259, 262, -531,
2066 -531, 321, -531, -531, 1201, 256, 684, -531, -531, -531,
2067 263, -531, 264, 267, -531, 268, 266, 274, 275, 270,
2068 277, 278, 279, 280, -531, -531, 360, 20, 350, -531,
2069 -531, 257, -531, 1242, 1242, 1242, -531, 1242, 1242, -531,
2070 -531, -531, -531, -531, 684, -531, 830, 35, 415, -531,
2071 282, 285, 291, 293, 297, -531, 304, -531, 830, 684,
2072 -531, -531, -531, -531, -531, 437, 309, 384, 684, 441,
2073 443, -531, 684, 684, -531, -531
Reid Spencer3822ff52006-11-08 06:47:33 +00002074};
2075
2076/* YYPGOTO[NTERM-NUM]. */
2077static const short int yypgoto[] =
2078{
Reid Spencera132e042006-12-03 05:46:11 +00002079 -531, -531, -531, 368, 369, 370, 371, 373, 90, 94,
2080 -129, -128, -530, -531, 428, 449, -112, -531, -268, 67,
2081 -531, -231, -531, -50, -531, -37, -531, -65, 354, -531,
2082 -94, 265, -290, 46, -531, -531, -531, -531, -531, -531,
2083 -531, 427, -531, -531, -531, -531, 3, -531, 73, -531,
2084 -531, 421, -531, -531, -531, -531, -531, 480, -531, -531,
2085 -515, -203, 69, -117, -531, 465, -531, -531, -531, -531,
2086 -531, 64, 2, -531, -531, 42, -531, -531
Reid Spencer3822ff52006-11-08 06:47:33 +00002087};
2088
2089/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2090 positive, shift that token. If negative, reduce the rule which
2091 number is the opposite. If zero, do what YYDEFACT says.
2092 If YYTABLE_NINF, syntax error. */
Reid Spencera132e042006-12-03 05:46:11 +00002093#define YYTABLE_NINF -171
Reid Spencer3822ff52006-11-08 06:47:33 +00002094static const short int yytable[] =
2095{
Reid Spencera132e042006-12-03 05:46:11 +00002096 89, 241, 242, 106, 359, 94, 26, 556, 227, 231,
2097 39, 230, 220, 324, 418, 440, 89, 42, 217, 244,
2098 119, 232, 221, 348, 420, 393, 395, 568, 348, 348,
2099 233, 234, 235, 236, 237, 238, 239, 240, 441, 273,
2100 348, 566, 107, 108, 26, 233, 234, 235, 236, 237,
2101 238, 239, 240, 576, 277, 412, 419, 119, 278, 279,
2102 280, 281, 282, 283, 381, 382, 419, 287, 288, 451,
2103 39, 348, 199, 200, 201, 289, 46, 47, 48, 454,
2104 292, 348, 348, 348, -106, -76, 293, 20, 226, 21,
2105 121, 226, 451, 123, 402, 49, 6, -76, -76, 403,
2106 453, 110, 111, 112, 123, 451, -76, -76, -76, -76,
2107 -76, -76, -76, 465, 4, -76, 22, 271, 272, 226,
2108 274, 404, 451, 23, 123, 192, 193, 24, 452, 59,
2109 20, 60, 21, 275, 226, 29, 51, 95, 226, 226,
2110 226, 226, 226, 226, 284, 285, 286, 226, 226, 43,
2111 348, 348, 348, 326, 327, 328, 290, 291, 348, 52,
2112 297, 298, -66, -66, 58, 53, -65, -65, -64, -64,
2113 -63, -63, 348, 348, 377, 299, 300, 62, 555, 64,
2114 99, 100, 103, 101, 102, 330, 7, 8, 9, 10,
2115 54, 12, 55, 567, 353, 56, 30, 31, 32, 33,
2116 34, 35, 36, 512, -107, 513, 114, 89, 115, 116,
2117 122, 191, 488, 195, 196, 348, 197, 348, 354, 218,
2118 219, 348, 222, 228, -70, -69, -68, -67, 302, 348,
2119 348, 348, -73, 355, -170, -74, 303, 334, 335, 375,
2120 356, 358, 361, 362, 363, 364, 425, 365, 427, 428,
2121 429, 366, 89, 376, 226, 367, 368, 436, 369, 5,
2122 378, 374, 373, 348, 348, 6, 348, 348, 379, 328,
2123 396, 383, 384, 348, 385, 7, 8, 9, 10, 11,
2124 12, 13, 348, 233, 234, 235, 236, 237, 238, 239,
2125 240, 446, 447, 448, 449, 450, 14, 386, 387, 407,
2126 350, 351, 388, 455, 456, 457, 458, 459, 389, 397,
2127 398, 399, 352, 348, 245, 246, 247, 248, 249, 250,
2128 251, 252, 253, 254, 400, 401, 226, 426, 226, 226,
2129 226, 430, 431, 405, 408, 410, 435, 226, 413, 424,
2130 414, 421, 440, 360, 464, 432, 433, 434, 439, 466,
2131 467, 348, 468, 370, 371, 372, 472, 496, 469, 470,
2132 476, 517, 518, 519, 478, 479, 348, 480, 484, 486,
2133 330, 487, 500, 502, 524, 348, 534, 535, 419, 348,
2134 348, 554, 489, 490, 226, 492, 558, 493, 537, 494,
2135 495, 497, 498, 499, 501, 522, 523, 539, 525, 526,
2136 527, 528, 485, 529, 530, 531, 504, 533, 241, 242,
2137 511, 514, 516, 536, 540, 559, 543, 538, 542, 544,
2138 545, 546, 415, 416, 417, 549, 547, 548, 241, 242,
2139 423, 226, 550, 551, 552, 553, 569, 570, 65, 66,
2140 571, 226, 226, 226, 437, 438, 572, 226, 573, 560,
2141 561, 562, 574, 563, 564, 20, 575, 21, 578, 304,
2142 580, 579, 582, 532, 583, 181, 182, 183, 184, 97,
2143 185, 305, 306, 444, 57, 462, 224, 226, 445, 105,
2144 461, 323, 113, 27, 45, 475, 520, 471, 491, 473,
2145 0, 0, 0, 477, 0, 0, 0, 0, 0, 0,
2146 0, 481, 482, 483, 0, 0, 0, 0, 0, 0,
2147 0, 134, 135, 136, 137, 138, 139, 140, 141, 142,
2148 143, 144, 145, 146, 147, 148, 149, 150, 151, 307,
2149 308, 0, 0, 0, 0, 505, 506, 0, 509, 510,
2150 0, 0, 0, 0, 0, 515, 0, 0, 0, 0,
2151 0, 0, 0, 0, 521, 0, 0, 0, 0, 0,
2152 309, 158, 159, 160, 161, 162, 163, 164, 165, 166,
2153 167, 168, 169, 0, 310, 172, 173, 174, 0, 311,
2154 312, 313, 0, 0, 0, 541, 0, 0, 0, 314,
2155 0, 0, 315, 0, 316, 0, 0, 317, 65, 66,
2156 0, 117, 68, 69, 70, 71, 72, 73, 74, 75,
2157 76, 77, 78, 79, 80, 20, 0, 21, 0, 0,
2158 0, 0, 0, 565, 256, 257, 258, 259, 260, 261,
2159 262, 263, 264, 265, 266, 267, 268, 269, 577, 0,
2160 0, 81, 0, 0, 0, 0, 0, 581, 0, 0,
2161 0, 584, 585, 65, 66, 0, 117, 202, 203, 204,
2162 205, 206, 207, 208, 209, 210, 211, 212, 79, 80,
2163 20, 0, 21, 0, 0, 0, 0, 0, 0, 0,
2164 0, 0, 0, 0, 0, 0, 0, 336, 337, 65,
2165 66, 338, 0, 0, 0, 0, 81, 0, 0, 0,
2166 0, 0, 0, 0, 0, 0, 20, 0, 21, 0,
2167 339, 340, 341, 0, 0, 0, 0, 0, 0, 0,
2168 0, 0, 342, 343, 0, 0, 0, 0, 0, 0,
Reid Spencer3822ff52006-11-08 06:47:33 +00002169 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencera132e042006-12-03 05:46:11 +00002170 0, 0, 0, 0, 0, 344, 82, 0, 0, 83,
2171 0, 0, 84, 0, 85, 118, 0, 0, 0, 0,
2172 0, 0, 134, 135, 136, 137, 138, 139, 140, 141,
2173 142, 143, 144, 145, 146, 147, 148, 149, 150, 151,
2174 307, 308, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer3da59db2006-11-27 01:05:10 +00002175 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencera132e042006-12-03 05:46:11 +00002176 0, 82, 0, 0, 83, 0, 0, 84, 0, 85,
2177 394, 309, 158, 159, 160, 161, 162, 163, 164, 165,
2178 166, 167, 168, 169, 0, 310, 172, 173, 174, 0,
2179 311, 312, 313, 336, 337, 0, 0, 338, 0, 0,
2180 0, 0, 0, 345, 0, 0, 0, 0, 0, 0,
2181 0, 0, 0, 0, 0, 0, 339, 340, 341, 0,
2182 0, 0, 0, 0, 0, 0, 0, 0, 342, 343,
Reid Spencer3da59db2006-11-27 01:05:10 +00002183 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer3da59db2006-11-27 01:05:10 +00002184 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencera132e042006-12-03 05:46:11 +00002185 0, 344, 0, 0, 0, 0, 0, 0, 0, 0,
2186 0, 0, 0, 0, 0, 0, 0, 0, 134, 135,
2187 136, 137, 138, 139, 140, 141, 142, 143, 144, 145,
2188 146, 147, 148, 149, 150, 151, 307, 308, 0, 0,
2189 0, 0, 65, 66, 0, 117, 202, 203, 204, 205,
2190 206, 207, 208, 209, 210, 211, 212, 79, 80, 20,
2191 0, 21, 0, 0, 0, 0, 0, 309, 158, 159,
2192 160, 161, 162, 163, 164, 165, 166, 167, 168, 169,
2193 0, 310, 172, 173, 174, 81, 311, 312, 313, 0,
2194 0, 0, 0, 0, 0, 0, 0, 65, 66, 345,
2195 117, 68, 69, 70, 71, 72, 73, 74, 75, 76,
2196 77, 78, 79, 80, 20, 0, 21, 0, 0, 0,
2197 0, 0, 0, 0, 0, 0, 0, 0, 0, 223,
2198 0, 0, 0, 0, 0, 0, 0, 0, 65, 66,
2199 81, 117, 68, 69, 70, 71, 72, 73, 74, 75,
2200 76, 77, 78, 79, 80, 20, 0, 21, 0, 0,
Reid Spencer3da59db2006-11-27 01:05:10 +00002201 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencera132e042006-12-03 05:46:11 +00002202 329, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2203 0, 81, 0, 0, 0, 0, 0, 0, 0, 0,
2204 82, 0, 0, 83, 0, 390, 84, 0, 85, 65,
2205 66, 0, 117, 68, 69, 70, 71, 72, 73, 74,
Reid Spencer3822ff52006-11-08 06:47:33 +00002206 75, 76, 77, 78, 79, 80, 20, 0, 21, 0,
2207 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencera132e042006-12-03 05:46:11 +00002208 0, 409, 0, 0, 0, 0, 0, 0, 0, 0,
2209 0, 0, 81, 0, 0, 82, 0, 0, 83, 0,
2210 0, 84, 0, 85, 0, 65, 66, 0, 117, 68,
2211 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
2212 79, 80, 20, 0, 21, 0, 0, 0, 0, 0,
2213 0, 0, 0, 0, 0, 0, 82, 460, 0, 83,
2214 0, 0, 84, 0, 85, 0, 65, 66, 81, 67,
2215 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2216 78, 79, 80, 20, 0, 21, 65, 66, 0, 117,
2217 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2218 78, 79, 80, 20, 0, 21, 0, 0, 0, 81,
2219 0, 0, 0, 0, 0, 0, 0, 82, 0, 0,
2220 83, 0, 0, 84, 0, 85, 0, 65, 66, 81,
2221 117, 202, 203, 204, 205, 206, 207, 208, 209, 210,
2222 211, 212, 79, 80, 20, 0, 21, 65, 66, 0,
2223 229, 68, 69, 70, 71, 72, 73, 74, 75, 76,
2224 77, 78, 79, 80, 20, 0, 21, 0, 0, 0,
2225 81, 0, 0, 82, 0, 0, 83, 0, 0, 84,
2226 0, 85, 0, 0, 0, 0, 0, 0, 0, 0,
2227 81, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer3da59db2006-11-27 01:05:10 +00002228 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2229 0, 0, 0, 0, 82, 0, 0, 83, 0, 0,
2230 84, 0, 85, 0, 0, 0, 0, 0, 0, 0,
Reid Spencera132e042006-12-03 05:46:11 +00002231 0, 0, 0, 0, 82, 0, 0, 83, 0, 0,
2232 84, 0, 85, 0, 0, 0, 0, 0, 0, 0,
2233 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2234 0, 0, 0, 0, 0, 0, 0, 0, 124, 0,
2235 0, 0, 0, 0, 0, 82, 0, 0, 83, 0,
2236 0, 84, 125, 85, 0, 0, 0, 0, 0, 0,
2237 0, 0, 126, 127, 0, 82, 0, 0, 83, 0,
2238 0, 84, 0, 85, 0, 128, 129, 130, 131, 132,
2239 133, 134, 135, 136, 137, 138, 139, 140, 141, 142,
2240 143, 144, 145, 146, 147, 148, 149, 150, 151, 152,
2241 153, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2242 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2243 0, 0, 0, 0, 0, 154, 155, 156, 0, 0,
2244 157, 158, 159, 160, 161, 162, 163, 164, 165, 166,
2245 167, 168, 169, 170, 171, 172, 173, 174, 175, 176,
2246 177, 178, 179, 180
Reid Spencer3822ff52006-11-08 06:47:33 +00002247};
2248
2249static const short int yycheck[] =
2250{
Reid Spencera132e042006-12-03 05:46:11 +00002251 37, 130, 130, 53, 272, 29, 3, 537, 125, 9,
2252 23, 128, 152, 216, 15, 34, 53, 30, 112, 131,
2253 85, 21, 162, 226, 15, 315, 316, 557, 231, 232,
2254 10, 11, 12, 13, 14, 15, 16, 17, 57, 156,
2255 243, 556, 32, 33, 41, 10, 11, 12, 13, 14,
2256 15, 16, 17, 568, 171, 345, 57, 122, 175, 176,
2257 177, 178, 179, 180, 295, 296, 57, 184, 185, 152,
2258 23, 274, 109, 110, 111, 187, 52, 53, 54, 162,
2259 152, 284, 285, 286, 154, 20, 158, 22, 125, 24,
2260 87, 128, 152, 163, 325, 71, 31, 32, 33, 158,
2261 160, 55, 56, 57, 163, 152, 41, 42, 43, 44,
2262 45, 46, 47, 160, 0, 50, 51, 154, 155, 156,
2263 157, 160, 152, 58, 163, 55, 56, 62, 158, 45,
2264 22, 47, 24, 170, 171, 61, 151, 161, 175, 176,
2265 177, 178, 179, 180, 181, 182, 183, 184, 185, 162,
2266 353, 354, 355, 218, 219, 220, 125, 126, 361, 61,
2267 27, 28, 3, 4, 151, 20, 3, 4, 3, 4,
2268 3, 4, 375, 376, 291, 3, 4, 24, 158, 4,
2269 151, 151, 156, 151, 151, 222, 41, 42, 43, 44,
2270 45, 46, 47, 158, 244, 50, 64, 65, 66, 67,
2271 68, 69, 70, 471, 154, 473, 4, 244, 4, 4,
2272 154, 24, 443, 4, 24, 418, 24, 420, 255, 157,
2273 157, 424, 154, 59, 4, 4, 4, 4, 4, 432,
2274 433, 434, 7, 270, 0, 7, 7, 152, 155, 289,
2275 152, 152, 156, 152, 152, 152, 363, 152, 365, 366,
2276 367, 152, 289, 290, 291, 152, 152, 374, 152, 25,
2277 24, 152, 36, 466, 467, 31, 469, 470, 152, 334,
2278 24, 154, 154, 476, 154, 41, 42, 43, 44, 45,
2279 46, 47, 485, 10, 11, 12, 13, 14, 15, 16,
2280 17, 385, 386, 387, 388, 389, 62, 154, 154, 152,
2281 231, 232, 154, 397, 398, 399, 400, 401, 154, 154,
2282 154, 154, 243, 516, 98, 99, 100, 101, 102, 103,
2283 104, 105, 106, 107, 154, 154, 363, 364, 365, 366,
2284 367, 368, 369, 330, 155, 63, 373, 374, 152, 156,
2285 152, 152, 34, 274, 24, 152, 152, 152, 152, 21,
2286 21, 554, 154, 284, 285, 286, 4, 451, 152, 152,
2287 152, 478, 479, 480, 152, 152, 569, 152, 154, 24,
2288 407, 4, 36, 57, 155, 578, 4, 24, 57, 582,
2289 583, 21, 152, 152, 421, 152, 36, 152, 156, 152,
2290 152, 152, 152, 152, 152, 489, 490, 514, 492, 493,
2291 494, 495, 439, 497, 498, 499, 152, 501, 537, 537,
2292 152, 152, 152, 152, 158, 158, 152, 155, 155, 152,
2293 152, 155, 353, 354, 355, 155, 152, 152, 557, 557,
2294 361, 468, 155, 155, 155, 155, 21, 155, 5, 6,
2295 155, 478, 479, 480, 375, 376, 155, 484, 155, 543,
2296 544, 545, 155, 547, 548, 22, 152, 24, 21, 26,
2297 76, 152, 21, 500, 21, 97, 97, 97, 97, 41,
2298 97, 38, 39, 383, 25, 408, 122, 514, 384, 52,
2299 407, 216, 61, 3, 19, 421, 484, 418, 446, 420,
2300 -1, -1, -1, 424, -1, -1, -1, -1, -1, -1,
2301 -1, 432, 433, 434, -1, -1, -1, -1, -1, -1,
2302 -1, 78, 79, 80, 81, 82, 83, 84, 85, 86,
2303 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
2304 97, -1, -1, -1, -1, 466, 467, -1, 469, 470,
2305 -1, -1, -1, -1, -1, 476, -1, -1, -1, -1,
2306 -1, -1, -1, -1, 485, -1, -1, -1, -1, -1,
2307 127, 128, 129, 130, 131, 132, 133, 134, 135, 136,
2308 137, 138, 139, -1, 141, 142, 143, 144, -1, 146,
2309 147, 148, -1, -1, -1, 516, -1, -1, -1, 156,
2310 -1, -1, 159, -1, 161, -1, -1, 164, 5, 6,
2311 -1, 8, 9, 10, 11, 12, 13, 14, 15, 16,
2312 17, 18, 19, 20, 21, 22, -1, 24, -1, -1,
2313 -1, -1, -1, 554, 108, 109, 110, 111, 112, 113,
2314 114, 115, 116, 117, 118, 119, 120, 121, 569, -1,
2315 -1, 48, -1, -1, -1, -1, -1, 578, -1, -1,
2316 -1, 582, 583, 5, 6, -1, 8, 9, 10, 11,
2317 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
2318 22, -1, 24, -1, -1, -1, -1, -1, -1, -1,
2319 -1, -1, -1, -1, -1, -1, -1, 3, 4, 5,
2320 6, 7, -1, -1, -1, -1, 48, -1, -1, -1,
2321 -1, -1, -1, -1, -1, -1, 22, -1, 24, -1,
2322 26, 27, 28, -1, -1, -1, -1, -1, -1, -1,
2323 -1, -1, 38, 39, -1, -1, -1, -1, -1, -1,
Reid Spencer3822ff52006-11-08 06:47:33 +00002324 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencera132e042006-12-03 05:46:11 +00002325 -1, -1, -1, -1, -1, 61, 153, -1, -1, 156,
2326 -1, -1, 159, -1, 161, 162, -1, -1, -1, -1,
2327 -1, -1, 78, 79, 80, 81, 82, 83, 84, 85,
2328 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
2329 96, 97, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer3da59db2006-11-27 01:05:10 +00002330 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencera132e042006-12-03 05:46:11 +00002331 -1, 153, -1, -1, 156, -1, -1, 159, -1, 161,
2332 162, 127, 128, 129, 130, 131, 132, 133, 134, 135,
2333 136, 137, 138, 139, -1, 141, 142, 143, 144, -1,
2334 146, 147, 148, 3, 4, -1, -1, 7, -1, -1,
2335 -1, -1, -1, 159, -1, -1, -1, -1, -1, -1,
2336 -1, -1, -1, -1, -1, -1, 26, 27, 28, -1,
2337 -1, -1, -1, -1, -1, -1, -1, -1, 38, 39,
Reid Spencer3da59db2006-11-27 01:05:10 +00002338 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer3da59db2006-11-27 01:05:10 +00002339 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencera132e042006-12-03 05:46:11 +00002340 -1, 61, -1, -1, -1, -1, -1, -1, -1, -1,
2341 -1, -1, -1, -1, -1, -1, -1, -1, 78, 79,
2342 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
2343 90, 91, 92, 93, 94, 95, 96, 97, -1, -1,
2344 -1, -1, 5, 6, -1, 8, 9, 10, 11, 12,
2345 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
2346 -1, 24, -1, -1, -1, -1, -1, 127, 128, 129,
2347 130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
2348 -1, 141, 142, 143, 144, 48, 146, 147, 148, -1,
2349 -1, -1, -1, -1, -1, -1, -1, 5, 6, 159,
2350 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
2351 18, 19, 20, 21, 22, -1, 24, -1, -1, -1,
2352 -1, -1, -1, -1, -1, -1, -1, -1, -1, 37,
2353 -1, -1, -1, -1, -1, -1, -1, -1, 5, 6,
2354 48, 8, 9, 10, 11, 12, 13, 14, 15, 16,
2355 17, 18, 19, 20, 21, 22, -1, 24, -1, -1,
Reid Spencer3da59db2006-11-27 01:05:10 +00002356 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencera132e042006-12-03 05:46:11 +00002357 37, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2358 -1, 48, -1, -1, -1, -1, -1, -1, -1, -1,
2359 153, -1, -1, 156, -1, 158, 159, -1, 161, 5,
2360 6, -1, 8, 9, 10, 11, 12, 13, 14, 15,
Reid Spencer3822ff52006-11-08 06:47:33 +00002361 16, 17, 18, 19, 20, 21, 22, -1, 24, -1,
2362 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2363 -1, 37, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencera132e042006-12-03 05:46:11 +00002364 -1, -1, 48, -1, -1, 153, -1, -1, 156, -1,
2365 -1, 159, -1, 161, -1, 5, 6, -1, 8, 9,
2366 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2367 20, 21, 22, -1, 24, -1, -1, -1, -1, -1,
2368 -1, -1, -1, -1, -1, -1, 153, 37, -1, 156,
2369 -1, -1, 159, -1, 161, -1, 5, 6, 48, 8,
2370 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
2371 19, 20, 21, 22, -1, 24, 5, 6, -1, 8,
2372 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
2373 19, 20, 21, 22, -1, 24, -1, -1, -1, 48,
2374 -1, -1, -1, -1, -1, -1, -1, 153, -1, -1,
2375 156, -1, -1, 159, -1, 161, -1, 5, 6, 48,
Reid Spencer3da59db2006-11-27 01:05:10 +00002376 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
Reid Spencera132e042006-12-03 05:46:11 +00002377 18, 19, 20, 21, 22, -1, 24, 5, 6, -1,
2378 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
2379 18, 19, 20, 21, 22, -1, 24, -1, -1, -1,
2380 48, -1, -1, 153, -1, -1, 156, -1, -1, 159,
2381 -1, 161, -1, -1, -1, -1, -1, -1, -1, -1,
2382 48, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer3da59db2006-11-27 01:05:10 +00002383 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencera132e042006-12-03 05:46:11 +00002384 -1, -1, -1, -1, 153, -1, -1, 156, -1, -1,
2385 159, -1, 161, -1, -1, -1, -1, -1, -1, -1,
2386 -1, -1, -1, -1, 153, -1, -1, 156, -1, -1,
2387 159, -1, 161, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer3da59db2006-11-27 01:05:10 +00002388 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencera132e042006-12-03 05:46:11 +00002389 -1, -1, -1, -1, -1, -1, -1, -1, 35, -1,
2390 -1, -1, -1, -1, -1, 153, -1, -1, 156, -1,
2391 -1, 159, 49, 161, -1, -1, -1, -1, -1, -1,
2392 -1, -1, 59, 60, -1, 153, -1, -1, 156, -1,
2393 -1, 159, -1, 161, -1, 72, 73, 74, 75, 76,
2394 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
2395 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
2396 97, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer3da59db2006-11-27 01:05:10 +00002397 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencera132e042006-12-03 05:46:11 +00002398 -1, -1, -1, -1, -1, 122, 123, 124, -1, -1,
2399 127, 128, 129, 130, 131, 132, 133, 134, 135, 136,
2400 137, 138, 139, 140, 141, 142, 143, 144, 145, 146,
2401 147, 148, 149, 150
Reid Spencer3822ff52006-11-08 06:47:33 +00002402};
2403
2404/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2405 symbol of state STATE-NUM. */
2406static const unsigned char yystos[] =
2407{
Reid Spencera132e042006-12-03 05:46:11 +00002408 0, 199, 200, 201, 0, 25, 31, 41, 42, 43,
2409 44, 45, 46, 47, 62, 180, 218, 220, 222, 229,
2410 22, 24, 51, 58, 62, 179, 211, 222, 223, 61,
2411 64, 65, 66, 67, 68, 69, 70, 181, 216, 23,
2412 230, 231, 30, 162, 219, 230, 52, 53, 54, 71,
2413 208, 151, 61, 20, 45, 47, 50, 180, 151, 45,
2414 47, 221, 24, 206, 4, 5, 6, 8, 9, 10,
Reid Spencer3822ff52006-11-08 06:47:33 +00002415 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
Reid Spencera132e042006-12-03 05:46:11 +00002416 21, 48, 153, 156, 159, 161, 166, 188, 189, 190,
2417 191, 192, 211, 226, 29, 161, 217, 179, 234, 151,
2418 151, 151, 151, 156, 209, 206, 188, 32, 33, 198,
2419 198, 198, 198, 216, 4, 4, 4, 8, 162, 192,
2420 193, 211, 154, 163, 35, 49, 59, 60, 72, 73,
Reid Spencer3822ff52006-11-08 06:47:33 +00002421 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2422 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
Reid Spencera132e042006-12-03 05:46:11 +00002423 94, 95, 96, 97, 122, 123, 124, 127, 128, 129,
2424 130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
2425 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
2426 150, 168, 169, 170, 171, 172, 232, 238, 239, 241,
2427 242, 24, 55, 56, 207, 4, 24, 24, 210, 190,
2428 190, 190, 9, 10, 11, 12, 13, 14, 15, 16,
2429 17, 18, 19, 175, 176, 178, 190, 195, 157, 157,
2430 152, 162, 154, 37, 193, 194, 190, 228, 59, 8,
2431 228, 9, 21, 10, 11, 12, 13, 14, 15, 16,
2432 17, 175, 176, 177, 181, 98, 99, 100, 101, 102,
2433 103, 104, 105, 106, 107, 173, 108, 109, 110, 111,
2434 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
2435 174, 190, 190, 228, 190, 190, 235, 228, 228, 228,
2436 228, 228, 228, 228, 190, 190, 190, 228, 228, 181,
2437 125, 126, 152, 158, 204, 205, 203, 27, 28, 3,
2438 4, 167, 4, 7, 26, 38, 39, 96, 97, 127,
2439 141, 146, 147, 148, 156, 159, 161, 164, 168, 169,
2440 170, 171, 172, 196, 226, 202, 192, 192, 192, 37,
2441 190, 213, 214, 215, 152, 155, 3, 4, 7, 26,
2442 27, 28, 38, 39, 61, 159, 196, 225, 226, 227,
2443 227, 227, 227, 188, 190, 190, 152, 183, 152, 183,
2444 227, 156, 152, 152, 152, 152, 152, 152, 152, 152,
2445 227, 227, 227, 36, 152, 188, 190, 228, 24, 152,
2446 186, 186, 186, 154, 154, 154, 154, 154, 154, 154,
2447 158, 195, 197, 197, 162, 197, 24, 154, 154, 154,
2448 154, 154, 186, 158, 160, 211, 212, 152, 155, 37,
2449 63, 224, 197, 152, 152, 227, 227, 227, 15, 57,
2450 15, 152, 240, 227, 156, 228, 190, 228, 228, 228,
2451 190, 190, 152, 152, 152, 190, 228, 227, 227, 152,
2452 34, 57, 184, 187, 173, 174, 195, 195, 195, 195,
2453 195, 152, 158, 160, 162, 195, 195, 195, 195, 195,
2454 37, 213, 184, 185, 24, 160, 21, 21, 154, 152,
2455 152, 227, 4, 227, 228, 236, 152, 227, 152, 152,
2456 152, 227, 227, 227, 154, 190, 24, 4, 186, 152,
2457 152, 240, 152, 152, 152, 152, 195, 152, 152, 152,
2458 36, 152, 57, 182, 152, 227, 227, 236, 237, 227,
2459 227, 152, 183, 183, 152, 227, 152, 228, 228, 228,
2460 237, 227, 195, 195, 155, 195, 195, 195, 195, 195,
2461 195, 195, 190, 195, 4, 24, 152, 156, 155, 228,
2462 158, 227, 155, 152, 152, 152, 155, 152, 152, 155,
2463 155, 155, 155, 155, 21, 158, 177, 233, 36, 158,
2464 195, 195, 195, 195, 195, 227, 225, 158, 177, 21,
2465 155, 155, 155, 155, 155, 152, 225, 227, 21, 152,
2466 76, 227, 21, 21, 227, 227
Reid Spencer3822ff52006-11-08 06:47:33 +00002467};
Reid Spencer68a24bd2005-08-27 18:50:39 +00002468
2469#define yyerrok (yyerrstatus = 0)
2470#define yyclearin (yychar = YYEMPTY)
Reid Spencer3822ff52006-11-08 06:47:33 +00002471#define YYEMPTY (-2)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002472#define YYEOF 0
Reid Spencer3822ff52006-11-08 06:47:33 +00002473
Reid Spencer68a24bd2005-08-27 18:50:39 +00002474#define YYACCEPT goto yyacceptlab
Reid Spencer3822ff52006-11-08 06:47:33 +00002475#define YYABORT goto yyabortlab
2476#define YYERROR goto yyerrorlab
2477
2478
2479/* Like YYERROR except do call yyerror. This remains here temporarily
2480 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002481 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer3822ff52006-11-08 06:47:33 +00002482
Reid Spencer68a24bd2005-08-27 18:50:39 +00002483#define YYFAIL goto yyerrlab
Reid Spencer3822ff52006-11-08 06:47:33 +00002484
Reid Spencer68a24bd2005-08-27 18:50:39 +00002485#define YYRECOVERING() (!!yyerrstatus)
Reid Spencer3822ff52006-11-08 06:47:33 +00002486
2487#define YYBACKUP(Token, Value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002488do \
2489 if (yychar == YYEMPTY && yylen == 1) \
Reid Spencer3822ff52006-11-08 06:47:33 +00002490 { \
2491 yychar = (Token); \
2492 yylval = (Value); \
2493 yytoken = YYTRANSLATE (yychar); \
Reid Spencer5b7e7532006-09-28 19:28:24 +00002494 YYPOPSTACK; \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002495 goto yybackup; \
2496 } \
2497 else \
Reid Spencer3822ff52006-11-08 06:47:33 +00002498 { \
2499 yyerror (YY_("syntax error: cannot back up")); \
2500 YYERROR; \
2501 } \
Reid Spencer5b7e7532006-09-28 19:28:24 +00002502while (0)
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002503
Reid Spencer3822ff52006-11-08 06:47:33 +00002504
Reid Spencer68a24bd2005-08-27 18:50:39 +00002505#define YYTERROR 1
2506#define YYERRCODE 256
2507
Reid Spencer3822ff52006-11-08 06:47:33 +00002508
2509/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2510 If N is 0, then set CURRENT to the empty location which ends
2511 the previous symbol: RHS[0] (always defined). */
2512
2513#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2514#ifndef YYLLOC_DEFAULT
2515# define YYLLOC_DEFAULT(Current, Rhs, N) \
2516 do \
2517 if (N) \
2518 { \
2519 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2520 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2521 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2522 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2523 } \
2524 else \
2525 { \
2526 (Current).first_line = (Current).last_line = \
2527 YYRHSLOC (Rhs, 0).last_line; \
2528 (Current).first_column = (Current).last_column = \
2529 YYRHSLOC (Rhs, 0).last_column; \
2530 } \
2531 while (0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002532#endif
2533
Reid Spencer3822ff52006-11-08 06:47:33 +00002534
2535/* YY_LOCATION_PRINT -- Print the location on the stream.
2536 This macro was not mandated originally: define only if we know
2537 we won't break user code: when these are the locations we know. */
2538
2539#ifndef YY_LOCATION_PRINT
2540# if YYLTYPE_IS_TRIVIAL
2541# define YY_LOCATION_PRINT(File, Loc) \
2542 fprintf (File, "%d.%d-%d.%d", \
2543 (Loc).first_line, (Loc).first_column, \
2544 (Loc).last_line, (Loc).last_column)
2545# else
2546# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2547# endif
2548#endif
2549
2550
2551/* YYLEX -- calling `yylex' with the right arguments. */
2552
Reid Spencer68a24bd2005-08-27 18:50:39 +00002553#ifdef YYLEX_PARAM
Reid Spencer3822ff52006-11-08 06:47:33 +00002554# define YYLEX yylex (YYLEX_PARAM)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002555#else
Reid Spencer3822ff52006-11-08 06:47:33 +00002556# define YYLEX yylex ()
Chris Lattnerf49c1762006-11-08 05:58:47 +00002557#endif
Reid Spencer3822ff52006-11-08 06:47:33 +00002558
2559/* Enable debugging if requested. */
2560#if YYDEBUG
2561
2562# ifndef YYFPRINTF
2563# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2564# define YYFPRINTF fprintf
2565# endif
2566
2567# define YYDPRINTF(Args) \
2568do { \
2569 if (yydebug) \
2570 YYFPRINTF Args; \
2571} while (0)
2572
2573# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2574do { \
2575 if (yydebug) \
2576 { \
2577 YYFPRINTF (stderr, "%s ", Title); \
2578 yysymprint (stderr, \
2579 Type, Value); \
2580 YYFPRINTF (stderr, "\n"); \
2581 } \
2582} while (0)
2583
2584/*------------------------------------------------------------------.
2585| yy_stack_print -- Print the state stack from its BOTTOM up to its |
2586| TOP (included). |
2587`------------------------------------------------------------------*/
2588
2589#if defined (__STDC__) || defined (__cplusplus)
2590static void
2591yy_stack_print (short int *bottom, short int *top)
Chris Lattnerf49c1762006-11-08 05:58:47 +00002592#else
Reid Spencer3822ff52006-11-08 06:47:33 +00002593static void
2594yy_stack_print (bottom, top)
2595 short int *bottom;
2596 short int *top;
Chris Lattnerf49c1762006-11-08 05:58:47 +00002597#endif
Reid Spencer3822ff52006-11-08 06:47:33 +00002598{
2599 YYFPRINTF (stderr, "Stack now");
2600 for (/* Nothing. */; bottom <= top; ++bottom)
2601 YYFPRINTF (stderr, " %d", *bottom);
2602 YYFPRINTF (stderr, "\n");
2603}
2604
2605# define YY_STACK_PRINT(Bottom, Top) \
2606do { \
2607 if (yydebug) \
2608 yy_stack_print ((Bottom), (Top)); \
2609} while (0)
2610
2611
2612/*------------------------------------------------.
2613| Report that the YYRULE is going to be reduced. |
2614`------------------------------------------------*/
2615
2616#if defined (__STDC__) || defined (__cplusplus)
2617static void
2618yy_reduce_print (int yyrule)
2619#else
2620static void
2621yy_reduce_print (yyrule)
2622 int yyrule;
Chris Lattner1ae022f2006-10-22 06:08:13 +00002623#endif
Reid Spencer3822ff52006-11-08 06:47:33 +00002624{
2625 int yyi;
2626 unsigned long int yylno = yyrline[yyrule];
2627 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
2628 yyrule - 1, yylno);
2629 /* Print the symbols being reduced, and their result. */
2630 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
2631 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
2632 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
2633}
Reid Spencer21be8652006-10-22 07:03:43 +00002634
Reid Spencer3822ff52006-11-08 06:47:33 +00002635# define YY_REDUCE_PRINT(Rule) \
2636do { \
2637 if (yydebug) \
2638 yy_reduce_print (Rule); \
2639} while (0)
Reid Spencer21be8652006-10-22 07:03:43 +00002640
Reid Spencer3822ff52006-11-08 06:47:33 +00002641/* Nonzero means print parse trace. It is left uninitialized so that
2642 multiple parsers can coexist. */
2643int yydebug;
2644#else /* !YYDEBUG */
2645# define YYDPRINTF(Args)
2646# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
2647# define YY_STACK_PRINT(Bottom, Top)
2648# define YY_REDUCE_PRINT(Rule)
2649#endif /* !YYDEBUG */
Reid Spencer21be8652006-10-22 07:03:43 +00002650
Reid Spencer21be8652006-10-22 07:03:43 +00002651
Reid Spencer3822ff52006-11-08 06:47:33 +00002652/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002653#ifndef YYINITDEPTH
Reid Spencer3822ff52006-11-08 06:47:33 +00002654# define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00002655#endif
2656
Reid Spencer3822ff52006-11-08 06:47:33 +00002657/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2658 if the built-in stack extension method is used).
Reid Spencer68a24bd2005-08-27 18:50:39 +00002659
Reid Spencer3822ff52006-11-08 06:47:33 +00002660 Do not make this value too large; the results are undefined if
2661 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
2662 evaluated with infinite-precision integer arithmetic. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002663
2664#ifndef YYMAXDEPTH
Reid Spencer3822ff52006-11-08 06:47:33 +00002665# define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00002666#endif
Reid Spencer3822ff52006-11-08 06:47:33 +00002667
Reid Spencer68a24bd2005-08-27 18:50:39 +00002668
2669
Reid Spencer3822ff52006-11-08 06:47:33 +00002670#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00002671
Reid Spencer3822ff52006-11-08 06:47:33 +00002672# ifndef yystrlen
2673# if defined (__GLIBC__) && defined (_STRING_H)
2674# define yystrlen strlen
2675# else
2676/* Return the length of YYSTR. */
2677static YYSIZE_T
2678# if defined (__STDC__) || defined (__cplusplus)
2679yystrlen (const char *yystr)
2680# else
2681yystrlen (yystr)
2682 const char *yystr;
2683# endif
Chris Lattnerf49c1762006-11-08 05:58:47 +00002684{
Reid Spencer3822ff52006-11-08 06:47:33 +00002685 const char *yys = yystr;
Chris Lattnerf49c1762006-11-08 05:58:47 +00002686
Reid Spencer3822ff52006-11-08 06:47:33 +00002687 while (*yys++ != '\0')
2688 continue;
2689
2690 return yys - yystr - 1;
Chris Lattnerf49c1762006-11-08 05:58:47 +00002691}
Reid Spencer3822ff52006-11-08 06:47:33 +00002692# endif
2693# endif
Chris Lattnerf49c1762006-11-08 05:58:47 +00002694
Reid Spencer3822ff52006-11-08 06:47:33 +00002695# ifndef yystpcpy
2696# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
2697# define yystpcpy stpcpy
2698# else
2699/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2700 YYDEST. */
2701static char *
2702# if defined (__STDC__) || defined (__cplusplus)
2703yystpcpy (char *yydest, const char *yysrc)
2704# else
2705yystpcpy (yydest, yysrc)
2706 char *yydest;
2707 const char *yysrc;
2708# endif
Chris Lattnerf49c1762006-11-08 05:58:47 +00002709{
Reid Spencer3822ff52006-11-08 06:47:33 +00002710 char *yyd = yydest;
2711 const char *yys = yysrc;
Chris Lattnerf49c1762006-11-08 05:58:47 +00002712
Reid Spencer3822ff52006-11-08 06:47:33 +00002713 while ((*yyd++ = *yys++) != '\0')
2714 continue;
2715
2716 return yyd - 1;
Chris Lattnerf49c1762006-11-08 05:58:47 +00002717}
Reid Spencer3822ff52006-11-08 06:47:33 +00002718# endif
2719# endif
Chris Lattnerf49c1762006-11-08 05:58:47 +00002720
Reid Spencer3822ff52006-11-08 06:47:33 +00002721# ifndef yytnamerr
2722/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
2723 quotes and backslashes, so that it's suitable for yyerror. The
2724 heuristic is that double-quoting is unnecessary unless the string
2725 contains an apostrophe, a comma, or backslash (other than
2726 backslash-backslash). YYSTR is taken from yytname. If YYRES is
2727 null, do not copy; instead, return the length of what the result
2728 would have been. */
2729static YYSIZE_T
2730yytnamerr (char *yyres, const char *yystr)
2731{
2732 if (*yystr == '"')
2733 {
2734 size_t yyn = 0;
2735 char const *yyp = yystr;
2736
2737 for (;;)
2738 switch (*++yyp)
2739 {
2740 case '\'':
2741 case ',':
2742 goto do_not_strip_quotes;
2743
2744 case '\\':
2745 if (*++yyp != '\\')
2746 goto do_not_strip_quotes;
2747 /* Fall through. */
2748 default:
2749 if (yyres)
2750 yyres[yyn] = *yyp;
2751 yyn++;
2752 break;
2753
2754 case '"':
2755 if (yyres)
2756 yyres[yyn] = '\0';
2757 return yyn;
2758 }
2759 do_not_strip_quotes: ;
2760 }
2761
2762 if (! yyres)
2763 return yystrlen (yystr);
2764
2765 return yystpcpy (yyres, yystr) - yyres;
2766}
2767# endif
2768
2769#endif /* YYERROR_VERBOSE */
2770
Reid Spencer21be8652006-10-22 07:03:43 +00002771
2772
Reid Spencer3822ff52006-11-08 06:47:33 +00002773#if YYDEBUG
2774/*--------------------------------.
2775| Print this symbol on YYOUTPUT. |
2776`--------------------------------*/
Reid Spencer21be8652006-10-22 07:03:43 +00002777
Reid Spencer3822ff52006-11-08 06:47:33 +00002778#if defined (__STDC__) || defined (__cplusplus)
2779static void
2780yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
Chris Lattnerf49c1762006-11-08 05:58:47 +00002781#else
Reid Spencer3822ff52006-11-08 06:47:33 +00002782static void
2783yysymprint (yyoutput, yytype, yyvaluep)
2784 FILE *yyoutput;
2785 int yytype;
2786 YYSTYPE *yyvaluep;
2787#endif
2788{
2789 /* Pacify ``unused variable'' warnings. */
2790 (void) yyvaluep;
2791
2792 if (yytype < YYNTOKENS)
2793 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2794 else
2795 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
2796
2797
2798# ifdef YYPRINT
2799 if (yytype < YYNTOKENS)
2800 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2801# endif
2802 switch (yytype)
2803 {
2804 default:
2805 break;
2806 }
2807 YYFPRINTF (yyoutput, ")");
2808}
2809
2810#endif /* ! YYDEBUG */
2811/*-----------------------------------------------.
2812| Release the memory associated to this symbol. |
2813`-----------------------------------------------*/
2814
2815#if defined (__STDC__) || defined (__cplusplus)
2816static void
2817yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
2818#else
2819static void
2820yydestruct (yymsg, yytype, yyvaluep)
2821 const char *yymsg;
2822 int yytype;
2823 YYSTYPE *yyvaluep;
2824#endif
2825{
2826 /* Pacify ``unused variable'' warnings. */
2827 (void) yyvaluep;
2828
2829 if (!yymsg)
2830 yymsg = "Deleting";
2831 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
2832
2833 switch (yytype)
2834 {
2835
2836 default:
2837 break;
2838 }
2839}
2840
2841
2842/* Prevent warnings from -Wmissing-prototypes. */
2843
2844#ifdef YYPARSE_PARAM
2845# if defined (__STDC__) || defined (__cplusplus)
2846int yyparse (void *YYPARSE_PARAM);
2847# else
2848int yyparse ();
2849# endif
2850#else /* ! YYPARSE_PARAM */
2851#if defined (__STDC__) || defined (__cplusplus)
Reid Spencere812fb22006-01-19 01:21:04 +00002852int yyparse (void);
Chris Lattnerf49c1762006-11-08 05:58:47 +00002853#else
Reid Spencer3822ff52006-11-08 06:47:33 +00002854int yyparse ();
2855#endif
2856#endif /* ! YYPARSE_PARAM */
2857
2858
2859
2860/* The look-ahead symbol. */
2861int yychar;
2862
2863/* The semantic value of the look-ahead symbol. */
2864YYSTYPE yylval;
2865
2866/* Number of syntax errors so far. */
2867int yynerrs;
2868
2869
2870
2871/*----------.
2872| yyparse. |
2873`----------*/
2874
2875#ifdef YYPARSE_PARAM
2876# if defined (__STDC__) || defined (__cplusplus)
2877int yyparse (void *YYPARSE_PARAM)
2878# else
2879int yyparse (YYPARSE_PARAM)
2880 void *YYPARSE_PARAM;
2881# endif
2882#else /* ! YYPARSE_PARAM */
2883#if defined (__STDC__) || defined (__cplusplus)
2884int
2885yyparse (void)
2886#else
2887int
2888yyparse ()
2889
2890#endif
2891#endif
2892{
2893
2894 int yystate;
2895 int yyn;
2896 int yyresult;
2897 /* Number of tokens to shift before error messages enabled. */
2898 int yyerrstatus;
2899 /* Look-ahead token as an internal (translated) token number. */
2900 int yytoken = 0;
2901
2902 /* Three stacks and their tools:
2903 `yyss': related to states,
2904 `yyvs': related to semantic values,
2905 `yyls': related to locations.
2906
2907 Refer to the stacks thru separate pointers, to allow yyoverflow
2908 to reallocate them elsewhere. */
2909
2910 /* The state stack. */
2911 short int yyssa[YYINITDEPTH];
2912 short int *yyss = yyssa;
2913 short int *yyssp;
2914
2915 /* The semantic value stack. */
2916 YYSTYPE yyvsa[YYINITDEPTH];
2917 YYSTYPE *yyvs = yyvsa;
2918 YYSTYPE *yyvsp;
2919
2920
2921
Reid Spencer5b7e7532006-09-28 19:28:24 +00002922#define YYPOPSTACK (yyvsp--, yyssp--)
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002923
Reid Spencer3822ff52006-11-08 06:47:33 +00002924 YYSIZE_T yystacksize = YYINITDEPTH;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002925
Reid Spencer3822ff52006-11-08 06:47:33 +00002926 /* The variables used to return semantic value and location from the
2927 action routines. */
2928 YYSTYPE yyval;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002929
2930
Reid Spencer3822ff52006-11-08 06:47:33 +00002931 /* When reducing, the number of symbols on the RHS of the reduced
2932 rule. */
Reid Spencer5b7e7532006-09-28 19:28:24 +00002933 int yylen;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002934
Reid Spencer3822ff52006-11-08 06:47:33 +00002935 YYDPRINTF ((stderr, "Starting parse\n"));
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002936
Reid Spencer68a24bd2005-08-27 18:50:39 +00002937 yystate = 0;
2938 yyerrstatus = 0;
2939 yynerrs = 0;
2940 yychar = YYEMPTY; /* Cause a token to be read. */
2941
2942 /* Initialize stack pointers.
2943 Waste one element of value and location stack
2944 so that they stay on the same level as the state stack.
2945 The wasted elements are never initialized. */
2946
Reid Spencer3822ff52006-11-08 06:47:33 +00002947 yyssp = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002948 yyvsp = yyvs;
2949
Reid Spencer3822ff52006-11-08 06:47:33 +00002950 goto yysetstate;
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002951
Reid Spencer3822ff52006-11-08 06:47:33 +00002952/*------------------------------------------------------------.
2953| yynewstate -- Push a new state, which is found in yystate. |
2954`------------------------------------------------------------*/
2955 yynewstate:
2956 /* In all cases, when you get here, the value and location stacks
2957 have just been pushed. so pushing a state here evens the stacks.
2958 */
2959 yyssp++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002960
Reid Spencer3822ff52006-11-08 06:47:33 +00002961 yysetstate:
2962 *yyssp = yystate;
2963
2964 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002965 {
2966 /* Get the current used size of the three stacks, in elements. */
Reid Spencer3822ff52006-11-08 06:47:33 +00002967 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002968
2969#ifdef yyoverflow
Reid Spencer3822ff52006-11-08 06:47:33 +00002970 {
2971 /* Give user a chance to reallocate the stack. Use copies of
2972 these so that the &'s don't force the real ones into
2973 memory. */
2974 YYSTYPE *yyvs1 = yyvs;
2975 short int *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002976
Reid Spencer3822ff52006-11-08 06:47:33 +00002977
2978 /* Each stack pointer address is followed by the size of the
2979 data in use in that stack, in bytes. This used to be a
2980 conditional around just the two extra args, but that might
2981 be undefined if yyoverflow is a macro. */
2982 yyoverflow (YY_("memory exhausted"),
2983 &yyss1, yysize * sizeof (*yyssp),
2984 &yyvs1, yysize * sizeof (*yyvsp),
2985
2986 &yystacksize);
2987
2988 yyss = yyss1;
2989 yyvs = yyvs1;
2990 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002991#else /* no yyoverflow */
Reid Spencer3822ff52006-11-08 06:47:33 +00002992# ifndef YYSTACK_RELOCATE
2993 goto yyexhaustedlab;
2994# else
Reid Spencer68a24bd2005-08-27 18:50:39 +00002995 /* Extend the stack our own way. */
Reid Spencer3822ff52006-11-08 06:47:33 +00002996 if (YYMAXDEPTH <= yystacksize)
2997 goto yyexhaustedlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002998 yystacksize *= 2;
Reid Spencer3822ff52006-11-08 06:47:33 +00002999 if (YYMAXDEPTH < yystacksize)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003000 yystacksize = YYMAXDEPTH;
Reid Spencer3822ff52006-11-08 06:47:33 +00003001
3002 {
3003 short int *yyss1 = yyss;
3004 union yyalloc *yyptr =
3005 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3006 if (! yyptr)
3007 goto yyexhaustedlab;
3008 YYSTACK_RELOCATE (yyss);
3009 YYSTACK_RELOCATE (yyvs);
3010
3011# undef YYSTACK_RELOCATE
3012 if (yyss1 != yyssa)
3013 YYSTACK_FREE (yyss1);
3014 }
3015# endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00003016#endif /* no yyoverflow */
3017
Reid Spencer3822ff52006-11-08 06:47:33 +00003018 yyssp = yyss + yysize - 1;
3019 yyvsp = yyvs + yysize - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003020
3021
Reid Spencer3822ff52006-11-08 06:47:33 +00003022 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3023 (unsigned long int) yystacksize));
3024
3025 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003026 YYABORT;
3027 }
3028
Reid Spencer3822ff52006-11-08 06:47:33 +00003029 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003030
3031 goto yybackup;
Reid Spencer3822ff52006-11-08 06:47:33 +00003032
3033/*-----------.
3034| yybackup. |
3035`-----------*/
3036yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00003037
Reid Spencer5b7e7532006-09-28 19:28:24 +00003038/* Do appropriate processing given the current state. */
Reid Spencer3822ff52006-11-08 06:47:33 +00003039/* Read a look-ahead token if we need one and don't already have one. */
Reid Spencer5b7e7532006-09-28 19:28:24 +00003040/* yyresume: */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003041
Reid Spencer3822ff52006-11-08 06:47:33 +00003042 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencer5b7e7532006-09-28 19:28:24 +00003043
Reid Spencer68a24bd2005-08-27 18:50:39 +00003044 yyn = yypact[yystate];
Reid Spencer3822ff52006-11-08 06:47:33 +00003045 if (yyn == YYPACT_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003046 goto yydefault;
3047
Reid Spencer3822ff52006-11-08 06:47:33 +00003048 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003049
Reid Spencer3822ff52006-11-08 06:47:33 +00003050 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003051 if (yychar == YYEMPTY)
3052 {
Reid Spencer3822ff52006-11-08 06:47:33 +00003053 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003054 yychar = YYLEX;
3055 }
3056
Reid Spencer3822ff52006-11-08 06:47:33 +00003057 if (yychar <= YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003058 {
Reid Spencer3822ff52006-11-08 06:47:33 +00003059 yychar = yytoken = YYEOF;
3060 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003061 }
3062 else
3063 {
Reid Spencer3822ff52006-11-08 06:47:33 +00003064 yytoken = YYTRANSLATE (yychar);
3065 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003066 }
3067
Reid Spencer3822ff52006-11-08 06:47:33 +00003068 /* If the proper action on seeing token YYTOKEN is to reduce or to
3069 detect an error, take that action. */
3070 yyn += yytoken;
3071 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003072 goto yydefault;
3073 yyn = yytable[yyn];
Reid Spencer3822ff52006-11-08 06:47:33 +00003074 if (yyn <= 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003075 {
Reid Spencer3822ff52006-11-08 06:47:33 +00003076 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003077 goto yyerrlab;
3078 yyn = -yyn;
3079 goto yyreduce;
3080 }
3081
3082 if (yyn == YYFINAL)
3083 YYACCEPT;
3084
Reid Spencer3822ff52006-11-08 06:47:33 +00003085 /* Shift the look-ahead token. */
3086 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Reid Spencer5b7e7532006-09-28 19:28:24 +00003087
3088 /* Discard the token being shifted unless it is eof. */
3089 if (yychar != YYEOF)
3090 yychar = YYEMPTY;
3091
3092 *++yyvsp = yylval;
3093
Reid Spencer3822ff52006-11-08 06:47:33 +00003094
3095 /* Count tokens shifted since error; after three, turn off error
3096 status. */
3097 if (yyerrstatus)
3098 yyerrstatus--;
Chris Lattner224f84f2006-08-18 17:34:45 +00003099
Reid Spencer68a24bd2005-08-27 18:50:39 +00003100 yystate = yyn;
3101 goto yynewstate;
3102
Chris Lattnerf49c1762006-11-08 05:58:47 +00003103
Reid Spencer3822ff52006-11-08 06:47:33 +00003104/*-----------------------------------------------------------.
3105| yydefault -- do the default action for the current state. |
3106`-----------------------------------------------------------*/
3107yydefault:
Reid Spencer68a24bd2005-08-27 18:50:39 +00003108 yyn = yydefact[yystate];
3109 if (yyn == 0)
3110 goto yyerrlab;
Reid Spencer3822ff52006-11-08 06:47:33 +00003111 goto yyreduce;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003112
Reid Spencer3822ff52006-11-08 06:47:33 +00003113
3114/*-----------------------------.
3115| yyreduce -- Do a reduction. |
3116`-----------------------------*/
Reid Spencer68a24bd2005-08-27 18:50:39 +00003117yyreduce:
Reid Spencer3822ff52006-11-08 06:47:33 +00003118 /* yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003119 yylen = yyr2[yyn];
3120
Reid Spencer3822ff52006-11-08 06:47:33 +00003121 /* If YYLEN is nonzero, implement the default value of the action:
3122 `$$ = $1'.
3123
3124 Otherwise, the following line sets YYVAL to garbage.
3125 This behavior is undocumented and Bison
3126 users should not rely upon it. Assigning to YYVAL
3127 unconditionally makes the parser a bit smaller, and it avoids a
3128 GCC warning that YYVAL may be used uninitialized. */
3129 yyval = yyvsp[1-yylen];
3130
3131
3132 YY_REDUCE_PRINT (yyn);
3133 switch (yyn)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003134 {
Reid Spencer3822ff52006-11-08 06:47:33 +00003135 case 3:
Reid Spencera132e042006-12-03 05:46:11 +00003136#line 1106 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003137 {
3138 if ((yyvsp[0].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range!
Reid Spencer61c83e02006-08-18 08:43:06 +00003139 GEN_ERROR("Value too large for type!");
Reid Spencer3822ff52006-11-08 06:47:33 +00003140 (yyval.SIntVal) = (int32_t)(yyvsp[0].UIntVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003141 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003142;}
3143 break;
3144
3145 case 5:
Reid Spencera132e042006-12-03 05:46:11 +00003146#line 1115 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003147 {
3148 if ((yyvsp[0].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range!
Reid Spencer61c83e02006-08-18 08:43:06 +00003149 GEN_ERROR("Value too large for type!");
Reid Spencer3822ff52006-11-08 06:47:33 +00003150 (yyval.SInt64Val) = (int64_t)(yyvsp[0].UInt64Val);
Reid Spencer61c83e02006-08-18 08:43:06 +00003151 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003152;}
3153 break;
3154
Reid Spencera132e042006-12-03 05:46:11 +00003155 case 75:
3156#line 1143 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003157 {
3158 (yyval.StrVal) = (yyvsp[-1].StrVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003159 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003160 ;}
3161 break;
3162
Reid Spencera132e042006-12-03 05:46:11 +00003163 case 76:
3164#line 1147 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003165 {
3166 (yyval.StrVal) = 0;
Reid Spencer61c83e02006-08-18 08:43:06 +00003167 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003168 ;}
3169 break;
3170
Reid Spencera132e042006-12-03 05:46:11 +00003171 case 77:
3172#line 1152 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003173 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3174 break;
3175
Reid Spencera132e042006-12-03 05:46:11 +00003176 case 78:
3177#line 1153 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003178 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3179 break;
3180
Reid Spencera132e042006-12-03 05:46:11 +00003181 case 79:
3182#line 1154 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003183 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3184 break;
3185
Reid Spencera132e042006-12-03 05:46:11 +00003186 case 80:
3187#line 1155 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003188 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3189 break;
3190
Reid Spencera132e042006-12-03 05:46:11 +00003191 case 81:
3192#line 1156 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003193 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3194 break;
3195
Reid Spencera132e042006-12-03 05:46:11 +00003196 case 82:
3197#line 1157 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003198 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3199 break;
3200
Reid Spencera132e042006-12-03 05:46:11 +00003201 case 83:
3202#line 1158 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003203 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3204 break;
3205
Reid Spencera132e042006-12-03 05:46:11 +00003206 case 84:
3207#line 1159 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003208 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3209 break;
3210
Reid Spencera132e042006-12-03 05:46:11 +00003211 case 85:
3212#line 1161 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003213 { (yyval.UIntVal) = CallingConv::C; ;}
3214 break;
3215
Reid Spencera132e042006-12-03 05:46:11 +00003216 case 86:
3217#line 1162 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003218 { (yyval.UIntVal) = CallingConv::C; ;}
3219 break;
3220
Reid Spencera132e042006-12-03 05:46:11 +00003221 case 87:
3222#line 1163 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003223 { (yyval.UIntVal) = CallingConv::CSRet; ;}
3224 break;
3225
Reid Spencera132e042006-12-03 05:46:11 +00003226 case 88:
3227#line 1164 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003228 { (yyval.UIntVal) = CallingConv::Fast; ;}
3229 break;
3230
Reid Spencera132e042006-12-03 05:46:11 +00003231 case 89:
3232#line 1165 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003233 { (yyval.UIntVal) = CallingConv::Cold; ;}
3234 break;
3235
Reid Spencera132e042006-12-03 05:46:11 +00003236 case 90:
3237#line 1166 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003238 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
3239 break;
3240
Reid Spencera132e042006-12-03 05:46:11 +00003241 case 91:
3242#line 1167 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003243 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
3244 break;
3245
Reid Spencera132e042006-12-03 05:46:11 +00003246 case 92:
3247#line 1168 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003248 {
3249 if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val))
Reid Spencer61c83e02006-08-18 08:43:06 +00003250 GEN_ERROR("Calling conv too large!");
Reid Spencer3822ff52006-11-08 06:47:33 +00003251 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Reid Spencer61c83e02006-08-18 08:43:06 +00003252 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003253 ;}
3254 break;
3255
Reid Spencera132e042006-12-03 05:46:11 +00003256 case 93:
3257#line 1177 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003258 { (yyval.UIntVal) = 0; ;}
3259 break;
3260
Reid Spencera132e042006-12-03 05:46:11 +00003261 case 94:
3262#line 1178 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003263 {
3264 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3265 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencer1628cec2006-10-26 06:15:43 +00003266 GEN_ERROR("Alignment must be a power of two!");
3267 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003268;}
3269 break;
3270
Reid Spencera132e042006-12-03 05:46:11 +00003271 case 95:
3272#line 1184 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003273 { (yyval.UIntVal) = 0; ;}
3274 break;
3275
Reid Spencera132e042006-12-03 05:46:11 +00003276 case 96:
3277#line 1185 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003278 {
3279 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3280 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencer3ed469c2006-11-02 20:25:50 +00003281 GEN_ERROR("Alignment must be a power of two!");
3282 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003283;}
3284 break;
3285
Reid Spencera132e042006-12-03 05:46:11 +00003286 case 97:
3287#line 1193 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003288 {
3289 for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i)
3290 if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\')
Reid Spencer61c83e02006-08-18 08:43:06 +00003291 GEN_ERROR("Invalid character in section name!");
Reid Spencer3822ff52006-11-08 06:47:33 +00003292 (yyval.StrVal) = (yyvsp[0].StrVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003293 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003294;}
3295 break;
3296
Reid Spencera132e042006-12-03 05:46:11 +00003297 case 98:
3298#line 1201 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003299 { (yyval.StrVal) = 0; ;}
3300 break;
3301
Reid Spencera132e042006-12-03 05:46:11 +00003302 case 99:
3303#line 1202 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003304 { (yyval.StrVal) = (yyvsp[0].StrVal); ;}
3305 break;
3306
Reid Spencera132e042006-12-03 05:46:11 +00003307 case 100:
3308#line 1207 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003309 {;}
3310 break;
3311
Reid Spencera132e042006-12-03 05:46:11 +00003312 case 101:
3313#line 1208 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003314 {;}
3315 break;
3316
Reid Spencera132e042006-12-03 05:46:11 +00003317 case 102:
3318#line 1209 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003319 {
3320 CurGV->setSection((yyvsp[0].StrVal));
3321 free((yyvsp[0].StrVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003322 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003323 ;}
3324 break;
3325
Reid Spencera132e042006-12-03 05:46:11 +00003326 case 103:
3327#line 1214 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003328 {
3329 if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val)))
Reid Spencer61c83e02006-08-18 08:43:06 +00003330 GEN_ERROR("Alignment must be a power of two!");
Reid Spencer3822ff52006-11-08 06:47:33 +00003331 CurGV->setAlignment((yyvsp[0].UInt64Val));
Reid Spencer61c83e02006-08-18 08:43:06 +00003332 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003333 ;}
3334 break;
3335
Reid Spencera132e042006-12-03 05:46:11 +00003336 case 105:
3337#line 1228 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3338 { (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType)); ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003339 break;
3340
Reid Spencera132e042006-12-03 05:46:11 +00003341 case 107:
3342#line 1229 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3343 { (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType)); ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003344 break;
3345
Reid Spencera132e042006-12-03 05:46:11 +00003346 case 108:
3347#line 1231 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003348 {
Reid Spencer3da59db2006-11-27 01:05:10 +00003349 if (!UpRefs.empty())
Reid Spencera132e042006-12-03 05:46:11 +00003350 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
Reid Spencer3da59db2006-11-27 01:05:10 +00003351 (yyval.TypeVal) = (yyvsp[0].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003352 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003353 ;}
3354 break;
3355
Reid Spencera132e042006-12-03 05:46:11 +00003356 case 122:
3357#line 1243 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3358 {
3359 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
3360 CHECK_FOR_ERROR
3361 ;}
3362 break;
3363
3364 case 123:
3365#line 1247 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3366 {
3367 (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType));
3368 CHECK_FOR_ERROR
3369 ;}
3370 break;
3371
3372 case 124:
3373#line 1251 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3da59db2006-11-27 01:05:10 +00003374 { // Named types are also simple types...
3375 const Type* tmp = getTypeVal((yyvsp[0].ValIDVal));
3376 CHECK_FOR_ERROR
Reid Spencera132e042006-12-03 05:46:11 +00003377 (yyval.TypeVal) = new PATypeHolder(tmp);
Reid Spencer3da59db2006-11-27 01:05:10 +00003378;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003379 break;
3380
Reid Spencera132e042006-12-03 05:46:11 +00003381 case 125:
3382#line 1259 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3da59db2006-11-27 01:05:10 +00003383 { // Type UpReference
3384 if ((yyvsp[0].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range!");
3385 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
3386 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector...
Reid Spencera132e042006-12-03 05:46:11 +00003387 (yyval.TypeVal) = new PATypeHolder(OT);
Reid Spencer3da59db2006-11-27 01:05:10 +00003388 UR_OUT("New Upreference!\n");
Reid Spencer61c83e02006-08-18 08:43:06 +00003389 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003390 ;}
3391 break;
3392
Reid Spencera132e042006-12-03 05:46:11 +00003393 case 126:
3394#line 1267 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3da59db2006-11-27 01:05:10 +00003395 { // Function derived type?
3396 std::vector<const Type*> Params;
Reid Spencera132e042006-12-03 05:46:11 +00003397 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-1].TypeList)->begin(),
Reid Spencer3da59db2006-11-27 01:05:10 +00003398 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
Reid Spencera132e042006-12-03 05:46:11 +00003399 Params.push_back(*I);
Reid Spencer3da59db2006-11-27 01:05:10 +00003400 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3401 if (isVarArg) Params.pop_back();
3402
Reid Spencera132e042006-12-03 05:46:11 +00003403 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FunctionType::get(*(yyvsp[-3].TypeVal),Params,isVarArg)));
Reid Spencer3da59db2006-11-27 01:05:10 +00003404 delete (yyvsp[-1].TypeList); // Delete the argument list
Reid Spencera132e042006-12-03 05:46:11 +00003405 delete (yyvsp[-3].TypeVal); // Delete the return type handle
Reid Spencer3da59db2006-11-27 01:05:10 +00003406 CHECK_FOR_ERROR
3407 ;}
3408 break;
3409
Reid Spencera132e042006-12-03 05:46:11 +00003410 case 127:
3411#line 1280 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3da59db2006-11-27 01:05:10 +00003412 { // Sized array type?
Reid Spencera132e042006-12-03 05:46:11 +00003413 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3414 delete (yyvsp[-1].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00003415 CHECK_FOR_ERROR
3416 ;}
3417 break;
3418
Reid Spencera132e042006-12-03 05:46:11 +00003419 case 128:
3420#line 1285 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3da59db2006-11-27 01:05:10 +00003421 { // Packed array type?
Reid Spencera132e042006-12-03 05:46:11 +00003422 const llvm::Type* ElemTy = (yyvsp[-1].TypeVal)->get();
3423 if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val))
3424 GEN_ERROR("Unsigned result not equal to signed result");
3425 if (!ElemTy->isPrimitiveType())
3426 GEN_ERROR("Elemental type of a PackedType must be primitive");
3427 if (!isPowerOf2_32((yyvsp[-3].UInt64Val)))
3428 GEN_ERROR("Vector length should be a power of 2!");
3429 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PackedType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3430 delete (yyvsp[-1].TypeVal);
3431 CHECK_FOR_ERROR
Reid Spencer3da59db2006-11-27 01:05:10 +00003432 ;}
3433 break;
3434
Reid Spencera132e042006-12-03 05:46:11 +00003435 case 129:
3436#line 1297 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3da59db2006-11-27 01:05:10 +00003437 { // Structure type?
3438 std::vector<const Type*> Elements;
Reid Spencera132e042006-12-03 05:46:11 +00003439 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-1].TypeList)->begin(),
Reid Spencer3da59db2006-11-27 01:05:10 +00003440 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
Reid Spencera132e042006-12-03 05:46:11 +00003441 Elements.push_back(*I);
Reid Spencer3da59db2006-11-27 01:05:10 +00003442
Reid Spencera132e042006-12-03 05:46:11 +00003443 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
Reid Spencer3da59db2006-11-27 01:05:10 +00003444 delete (yyvsp[-1].TypeList);
3445 CHECK_FOR_ERROR
3446 ;}
3447 break;
3448
Reid Spencera132e042006-12-03 05:46:11 +00003449 case 130:
3450#line 1307 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3da59db2006-11-27 01:05:10 +00003451 { // Empty structure type?
Reid Spencera132e042006-12-03 05:46:11 +00003452 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer3da59db2006-11-27 01:05:10 +00003453 CHECK_FOR_ERROR
3454 ;}
3455 break;
3456
Reid Spencera132e042006-12-03 05:46:11 +00003457 case 131:
3458#line 1311 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3da59db2006-11-27 01:05:10 +00003459 { // Pointer type?
Reid Spencera132e042006-12-03 05:46:11 +00003460 if (*(yyvsp[-1].TypeVal) == Type::LabelTy)
Reid Spencer3da59db2006-11-27 01:05:10 +00003461 GEN_ERROR("Cannot form a pointer to a basic block");
Reid Spencera132e042006-12-03 05:46:11 +00003462 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[-1].TypeVal))));
3463 delete (yyvsp[-1].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00003464 CHECK_FOR_ERROR
3465 ;}
3466 break;
3467
Reid Spencera132e042006-12-03 05:46:11 +00003468 case 132:
3469#line 1322 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3da59db2006-11-27 01:05:10 +00003470 {
Reid Spencera132e042006-12-03 05:46:11 +00003471 (yyval.TypeList) = new std::list<PATypeHolder>();
3472 (yyval.TypeList)->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00003473 CHECK_FOR_ERROR
3474 ;}
3475 break;
3476
Reid Spencera132e042006-12-03 05:46:11 +00003477 case 133:
3478#line 1327 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3da59db2006-11-27 01:05:10 +00003479 {
Reid Spencera132e042006-12-03 05:46:11 +00003480 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00003481 CHECK_FOR_ERROR
3482 ;}
3483 break;
3484
Reid Spencera132e042006-12-03 05:46:11 +00003485 case 135:
3486#line 1334 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3da59db2006-11-27 01:05:10 +00003487 {
Reid Spencera132e042006-12-03 05:46:11 +00003488 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(Type::VoidTy);
Reid Spencer3da59db2006-11-27 01:05:10 +00003489 CHECK_FOR_ERROR
3490 ;}
3491 break;
3492
Reid Spencera132e042006-12-03 05:46:11 +00003493 case 136:
3494#line 1338 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3da59db2006-11-27 01:05:10 +00003495 {
Reid Spencera132e042006-12-03 05:46:11 +00003496 ((yyval.TypeList) = new std::list<PATypeHolder>())->push_back(Type::VoidTy);
Reid Spencer3da59db2006-11-27 01:05:10 +00003497 CHECK_FOR_ERROR
3498 ;}
3499 break;
3500
Reid Spencera132e042006-12-03 05:46:11 +00003501 case 137:
3502#line 1342 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3da59db2006-11-27 01:05:10 +00003503 {
Reid Spencera132e042006-12-03 05:46:11 +00003504 (yyval.TypeList) = new std::list<PATypeHolder>();
Reid Spencer3da59db2006-11-27 01:05:10 +00003505 CHECK_FOR_ERROR
3506 ;}
3507 break;
3508
Reid Spencera132e042006-12-03 05:46:11 +00003509 case 138:
3510#line 1353 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003511 { // Nonempty unsized arr
Reid Spencera132e042006-12-03 05:46:11 +00003512 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003513 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003514 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencera132e042006-12-03 05:46:11 +00003515 (*(yyvsp[-3].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003516 const Type *ETy = ATy->getElementType();
3517 int NumElements = ATy->getNumElements();
3518
3519 // Verify that we have the correct size...
Reid Spencer3822ff52006-11-08 06:47:33 +00003520 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Reid Spencer61c83e02006-08-18 08:43:06 +00003521 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Reid Spencer3822ff52006-11-08 06:47:33 +00003522 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003523 itostr(NumElements) + "!");
3524
3525 // Verify all elements are correct type!
Reid Spencer3822ff52006-11-08 06:47:33 +00003526 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
Reid Spencera132e042006-12-03 05:46:11 +00003527 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003528 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003529 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencera132e042006-12-03 05:46:11 +00003530 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003531 }
3532
Reid Spencera132e042006-12-03 05:46:11 +00003533 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[-1].ConstVector));
3534 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Reid Spencer61c83e02006-08-18 08:43:06 +00003535 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003536 ;}
3537 break;
3538
Reid Spencera132e042006-12-03 05:46:11 +00003539 case 139:
3540#line 1379 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003541 {
Reid Spencera132e042006-12-03 05:46:11 +00003542 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003543 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003544 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencera132e042006-12-03 05:46:11 +00003545 (*(yyvsp[-2].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003546
3547 int NumElements = ATy->getNumElements();
3548 if (NumElements != -1 && NumElements != 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003549 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003550 " arguments, but has size of " + itostr(NumElements) +"!");
Reid Spencera132e042006-12-03 05:46:11 +00003551 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
3552 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003553 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003554 ;}
3555 break;
3556
Reid Spencera132e042006-12-03 05:46:11 +00003557 case 140:
3558#line 1393 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003559 {
Reid Spencera132e042006-12-03 05:46:11 +00003560 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003561 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003562 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencera132e042006-12-03 05:46:11 +00003563 (*(yyvsp[-2].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003564
3565 int NumElements = ATy->getNumElements();
3566 const Type *ETy = ATy->getElementType();
Reid Spencer3822ff52006-11-08 06:47:33 +00003567 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
3568 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00003569 GEN_ERROR("Can't build string constant of size " +
Reid Spencer3822ff52006-11-08 06:47:33 +00003570 itostr((int)(EndStr-(yyvsp[0].StrVal))) +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003571 " when array has size " + itostr(NumElements) + "!");
3572 std::vector<Constant*> Vals;
3573 if (ETy == Type::SByteTy) {
Reid Spencer3822ff52006-11-08 06:47:33 +00003574 for (signed char *C = (signed char *)(yyvsp[0].StrVal); C != (signed char *)EndStr; ++C)
Reid Spencerb83eb642006-10-20 07:07:24 +00003575 Vals.push_back(ConstantInt::get(ETy, *C));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003576 } else if (ETy == Type::UByteTy) {
Reid Spencer3822ff52006-11-08 06:47:33 +00003577 for (unsigned char *C = (unsigned char *)(yyvsp[0].StrVal);
Chris Lattner66316012006-01-24 04:14:29 +00003578 C != (unsigned char*)EndStr; ++C)
Reid Spencerb83eb642006-10-20 07:07:24 +00003579 Vals.push_back(ConstantInt::get(ETy, *C));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003580 } else {
Reid Spencer3822ff52006-11-08 06:47:33 +00003581 free((yyvsp[0].StrVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003582 GEN_ERROR("Cannot build string arrays of non byte sized elements!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003583 }
Reid Spencer3822ff52006-11-08 06:47:33 +00003584 free((yyvsp[0].StrVal));
Reid Spencera132e042006-12-03 05:46:11 +00003585 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
3586 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003587 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003588 ;}
3589 break;
3590
Reid Spencera132e042006-12-03 05:46:11 +00003591 case 141:
3592#line 1423 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003593 { // Nonempty unsized arr
Reid Spencera132e042006-12-03 05:46:11 +00003594 const PackedType *PTy = dyn_cast<PackedType>((yyvsp[-3].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003595 if (PTy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003596 GEN_ERROR("Cannot make packed constant with type: '" +
Reid Spencera132e042006-12-03 05:46:11 +00003597 (*(yyvsp[-3].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003598 const Type *ETy = PTy->getElementType();
3599 int NumElements = PTy->getNumElements();
3600
3601 // Verify that we have the correct size...
Reid Spencer3822ff52006-11-08 06:47:33 +00003602 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Reid Spencer61c83e02006-08-18 08:43:06 +00003603 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Reid Spencer3822ff52006-11-08 06:47:33 +00003604 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003605 itostr(NumElements) + "!");
3606
3607 // Verify all elements are correct type!
Reid Spencer3822ff52006-11-08 06:47:33 +00003608 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
Reid Spencera132e042006-12-03 05:46:11 +00003609 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003610 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003611 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencera132e042006-12-03 05:46:11 +00003612 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003613 }
3614
Reid Spencera132e042006-12-03 05:46:11 +00003615 (yyval.ConstVal) = ConstantPacked::get(PTy, *(yyvsp[-1].ConstVector));
3616 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Reid Spencer61c83e02006-08-18 08:43:06 +00003617 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003618 ;}
3619 break;
3620
Reid Spencera132e042006-12-03 05:46:11 +00003621 case 142:
3622#line 1449 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003623 {
Reid Spencera132e042006-12-03 05:46:11 +00003624 const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal)->get());
Reid Spencer61c83e02006-08-18 08:43:06 +00003625 if (STy == 0)
3626 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencera132e042006-12-03 05:46:11 +00003627 (*(yyvsp[-3].TypeVal))->getDescription() + "'!");
Reid Spencer61c83e02006-08-18 08:43:06 +00003628
Reid Spencer3822ff52006-11-08 06:47:33 +00003629 if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencer61c83e02006-08-18 08:43:06 +00003630 GEN_ERROR("Illegal number of initializers for structure type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003631
3632 // Check to ensure that constants are compatible with the type initializer!
Reid Spencer3822ff52006-11-08 06:47:33 +00003633 for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i)
Reid Spencera132e042006-12-03 05:46:11 +00003634 if ((*(yyvsp[-1].ConstVector))[i]->getType() != STy->getElementType(i))
Reid Spencer61c83e02006-08-18 08:43:06 +00003635 GEN_ERROR("Expected type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003636 STy->getElementType(i)->getDescription() +
3637 "' for element #" + utostr(i) +
3638 " of structure initializer!");
3639
Reid Spencera132e042006-12-03 05:46:11 +00003640 (yyval.ConstVal) = ConstantStruct::get(STy, *(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 Spencera132e042006-12-03 05:46:11 +00003646 case 143:
3647#line 1470 "/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 StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003650 if (STy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003651 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencera132e042006-12-03 05:46:11 +00003652 (*(yyvsp[-2].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003653
3654 if (STy->getNumContainedTypes() != 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003655 GEN_ERROR("Illegal number of initializers for structure type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003656
Reid Spencera132e042006-12-03 05:46:11 +00003657 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
3658 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003659 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003660 ;}
3661 break;
3662
Reid Spencera132e042006-12-03 05:46:11 +00003663 case 144:
3664#line 1483 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003665 {
Reid Spencera132e042006-12-03 05:46:11 +00003666 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003667 if (PTy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003668 GEN_ERROR("Cannot make null pointer constant with type: '" +
Reid Spencera132e042006-12-03 05:46:11 +00003669 (*(yyvsp[-1].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003670
Reid Spencera132e042006-12-03 05:46:11 +00003671 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
3672 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003673 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003674 ;}
3675 break;
3676
Reid Spencera132e042006-12-03 05:46:11 +00003677 case 145:
3678#line 1493 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003679 {
Reid Spencera132e042006-12-03 05:46:11 +00003680 (yyval.ConstVal) = UndefValue::get((yyvsp[-1].TypeVal)->get());
3681 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003682 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003683 ;}
3684 break;
3685
Reid Spencera132e042006-12-03 05:46:11 +00003686 case 146:
3687#line 1498 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003688 {
Reid Spencera132e042006-12-03 05:46:11 +00003689 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003690 if (Ty == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003691 GEN_ERROR("Global const reference must be a pointer type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003692
3693 // ConstExprs can exist in the body of a function, thus creating
3694 // GlobalValues whenever they refer to a variable. Because we are in
3695 // the context of a function, getValNonImprovising will search the functions
3696 // symbol table instead of the module symbol table for the global symbol,
3697 // which throws things all off. To get around this, we just tell
3698 // getValNonImprovising that we are at global scope here.
3699 //
3700 Function *SavedCurFn = CurFun.CurrentFunction;
3701 CurFun.CurrentFunction = 0;
3702
Reid Spencer3822ff52006-11-08 06:47:33 +00003703 Value *V = getValNonImprovising(Ty, (yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00003704 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003705
3706 CurFun.CurrentFunction = SavedCurFn;
3707
3708 // If this is an initializer for a constant pointer, which is referencing a
3709 // (currently) undefined variable, create a stub now that shall be replaced
3710 // in the future with the right type of variable.
3711 //
3712 if (V == 0) {
3713 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
3714 const PointerType *PT = cast<PointerType>(Ty);
3715
3716 // First check to see if the forward references value is already created!
3717 PerModuleInfo::GlobalRefsType::iterator I =
Reid Spencer3822ff52006-11-08 06:47:33 +00003718 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal)));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003719
3720 if (I != CurModule.GlobalRefs.end()) {
3721 V = I->second; // Placeholder already exists, use it...
Reid Spencer3822ff52006-11-08 06:47:33 +00003722 (yyvsp[0].ValIDVal).destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003723 } else {
3724 std::string Name;
Reid Spencer3822ff52006-11-08 06:47:33 +00003725 if ((yyvsp[0].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[0].ValIDVal).Name;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003726
3727 // Create the forward referenced global.
3728 GlobalValue *GV;
3729 if (const FunctionType *FTy =
3730 dyn_cast<FunctionType>(PT->getElementType())) {
3731 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
3732 CurModule.CurrentModule);
3733 } else {
3734 GV = new GlobalVariable(PT->getElementType(), false,
3735 GlobalValue::ExternalLinkage, 0,
3736 Name, CurModule.CurrentModule);
3737 }
3738
3739 // Keep track of the fact that we have a forward ref to recycle it
Reid Spencer3822ff52006-11-08 06:47:33 +00003740 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003741 V = GV;
3742 }
3743 }
3744
Reid Spencera132e042006-12-03 05:46:11 +00003745 (yyval.ConstVal) = cast<GlobalValue>(V);
3746 delete (yyvsp[-1].TypeVal); // Free the type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00003747 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003748 ;}
3749 break;
3750
Reid Spencera132e042006-12-03 05:46:11 +00003751 case 147:
3752#line 1559 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003753 {
Reid Spencera132e042006-12-03 05:46:11 +00003754 if ((yyvsp[-1].TypeVal)->get() != (yyvsp[0].ConstVal)->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003755 GEN_ERROR("Mismatched types for constant expression!");
Reid Spencer3822ff52006-11-08 06:47:33 +00003756 (yyval.ConstVal) = (yyvsp[0].ConstVal);
Reid Spencera132e042006-12-03 05:46:11 +00003757 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003758 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003759 ;}
3760 break;
3761
Reid Spencera132e042006-12-03 05:46:11 +00003762 case 148:
3763#line 1566 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003764 {
Reid Spencera132e042006-12-03 05:46:11 +00003765 const Type *Ty = (yyvsp[-1].TypeVal)->get();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003766 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
Reid Spencer61c83e02006-08-18 08:43:06 +00003767 GEN_ERROR("Cannot create a null initialized value of this type!");
Reid Spencera132e042006-12-03 05:46:11 +00003768 (yyval.ConstVal) = Constant::getNullValue(Ty);
3769 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003770 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003771 ;}
3772 break;
3773
Reid Spencera132e042006-12-03 05:46:11 +00003774 case 149:
3775#line 1574 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003776 { // integral constants
Reid Spencera132e042006-12-03 05:46:11 +00003777 if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val)))
Reid Spencer61c83e02006-08-18 08:43:06 +00003778 GEN_ERROR("Constant value doesn't fit in type!");
Reid Spencera132e042006-12-03 05:46:11 +00003779 (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val));
Reid Spencer61c83e02006-08-18 08:43:06 +00003780 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003781 ;}
3782 break;
3783
Reid Spencera132e042006-12-03 05:46:11 +00003784 case 150:
3785#line 1580 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003786 { // integral constants
Reid Spencera132e042006-12-03 05:46:11 +00003787 if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val)))
Reid Spencer61c83e02006-08-18 08:43:06 +00003788 GEN_ERROR("Constant value doesn't fit in type!");
Reid Spencera132e042006-12-03 05:46:11 +00003789 (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val));
Reid Spencer61c83e02006-08-18 08:43:06 +00003790 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003791 ;}
3792 break;
3793
Reid Spencera132e042006-12-03 05:46:11 +00003794 case 151:
3795#line 1586 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003796 { // Boolean constants
Reid Spencera132e042006-12-03 05:46:11 +00003797 (yyval.ConstVal) = ConstantBool::getTrue();
Reid Spencer61c83e02006-08-18 08:43:06 +00003798 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003799 ;}
3800 break;
3801
Reid Spencera132e042006-12-03 05:46:11 +00003802 case 152:
3803#line 1590 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003804 { // Boolean constants
Reid Spencera132e042006-12-03 05:46:11 +00003805 (yyval.ConstVal) = ConstantBool::getFalse();
Reid Spencer61c83e02006-08-18 08:43:06 +00003806 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003807 ;}
3808 break;
3809
Reid Spencera132e042006-12-03 05:46:11 +00003810 case 153:
3811#line 1594 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003812 { // Float & Double constants
Reid Spencera132e042006-12-03 05:46:11 +00003813 if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].FPVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00003814 GEN_ERROR("Floating point constant invalid for type!!");
Reid Spencera132e042006-12-03 05:46:11 +00003815 (yyval.ConstVal) = ConstantFP::get((yyvsp[-1].PrimType), (yyvsp[0].FPVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003816 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003817 ;}
3818 break;
3819
Reid Spencera132e042006-12-03 05:46:11 +00003820 case 154:
3821#line 1602 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003822 {
Reid Spencera132e042006-12-03 05:46:11 +00003823 Constant *Val = (yyvsp[-3].ConstVal);
3824 const Type *Ty = (yyvsp[-1].TypeVal)->get();
Reid Spencer3da59db2006-11-27 01:05:10 +00003825 if (!Val->getType()->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003826 GEN_ERROR("cast constant expression from a non-primitive type: '" +
Reid Spencer3da59db2006-11-27 01:05:10 +00003827 Val->getType()->getDescription() + "'!");
3828 if (!Ty->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003829 GEN_ERROR("cast constant expression to a non-primitive type: '" +
Reid Spencer3da59db2006-11-27 01:05:10 +00003830 Ty->getDescription() + "'!");
Reid Spencera132e042006-12-03 05:46:11 +00003831 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].TypeVal)->get());
3832 delete (yyvsp[-1].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00003833 ;}
3834 break;
3835
Reid Spencera132e042006-12-03 05:46:11 +00003836 case 155:
3837#line 1614 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003838 {
Reid Spencera132e042006-12-03 05:46:11 +00003839 if (!isa<PointerType>((yyvsp[-2].ConstVal)->getType()))
Reid Spencer61c83e02006-08-18 08:43:06 +00003840 GEN_ERROR("GetElementPtr requires a pointer operand!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003841
Reid Spencera132e042006-12-03 05:46:11 +00003842 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
3843 // indices to uint struct indices for compatibility.
3844 generic_gep_type_iterator<std::vector<Value*>::iterator>
3845 GTI = gep_type_begin((yyvsp[-2].ConstVal)->getType(), (yyvsp[-1].ValueList)->begin(), (yyvsp[-1].ValueList)->end()),
3846 GTE = gep_type_end((yyvsp[-2].ConstVal)->getType(), (yyvsp[-1].ValueList)->begin(), (yyvsp[-1].ValueList)->end());
3847 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e && GTI != GTE; ++i, ++GTI)
3848 if (isa<StructType>(*GTI)) // Only change struct indices
3849 if (ConstantInt *CUI = dyn_cast<ConstantInt>((*(yyvsp[-1].ValueList))[i]))
3850 if (CUI->getType() == Type::UByteTy)
3851 (*(yyvsp[-1].ValueList))[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
3852
3853 const Type *IdxTy =
3854 GetElementPtrInst::getIndexedType((yyvsp[-2].ConstVal)->getType(), *(yyvsp[-1].ValueList), true);
3855 if (!IdxTy)
3856 GEN_ERROR("Index list invalid for constant getelementptr!");
3857
3858 std::vector<Constant*> IdxVec;
3859 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e; ++i)
3860 if (Constant *C = dyn_cast<Constant>((*(yyvsp[-1].ValueList))[i]))
Reid Spencer68a24bd2005-08-27 18:50:39 +00003861 IdxVec.push_back(C);
3862 else
Reid Spencer61c83e02006-08-18 08:43:06 +00003863 GEN_ERROR("Indices to constant getelementptr must be constants!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003864
Reid Spencer3822ff52006-11-08 06:47:33 +00003865 delete (yyvsp[-1].ValueList);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003866
Reid Spencera132e042006-12-03 05:46:11 +00003867 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal), IdxVec);
Reid Spencer61c83e02006-08-18 08:43:06 +00003868 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003869 ;}
3870 break;
3871
Reid Spencera132e042006-12-03 05:46:11 +00003872 case 156:
3873#line 1646 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003874 {
Reid Spencera132e042006-12-03 05:46:11 +00003875 if ((yyvsp[-5].ConstVal)->getType() != Type::BoolTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00003876 GEN_ERROR("Select condition must be of boolean type!");
Reid Spencera132e042006-12-03 05:46:11 +00003877 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003878 GEN_ERROR("Select operand types must match!");
Reid Spencera132e042006-12-03 05:46:11 +00003879 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003880 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003881 ;}
3882 break;
3883
Reid Spencera132e042006-12-03 05:46:11 +00003884 case 157:
3885#line 1654 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003886 {
Reid Spencera132e042006-12-03 05:46:11 +00003887 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003888 GEN_ERROR("Binary operator types must match!");
Reid Spencer1628cec2006-10-26 06:15:43 +00003889 CHECK_FOR_ERROR;
3890
Reid Spencer68a24bd2005-08-27 18:50:39 +00003891 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
3892 // To retain backward compatibility with these early compilers, we emit a
3893 // cast to the appropriate integer type automatically if we are in the
3894 // broken case. See PR424 for more information.
Reid Spencera132e042006-12-03 05:46:11 +00003895 if (!isa<PointerType>((yyvsp[-3].ConstVal)->getType())) {
3896 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003897 } else {
3898 const Type *IntPtrTy = 0;
3899 switch (CurModule.CurrentModule->getPointerSize()) {
3900 case Module::Pointer32: IntPtrTy = Type::IntTy; break;
3901 case Module::Pointer64: IntPtrTy = Type::LongTy; break;
Reid Spencer61c83e02006-08-18 08:43:06 +00003902 default: GEN_ERROR("invalid pointer binary constant expr!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003903 }
Reid Spencera132e042006-12-03 05:46:11 +00003904 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), ConstantExpr::getCast((yyvsp[-3].ConstVal), IntPtrTy),
3905 ConstantExpr::getCast((yyvsp[-1].ConstVal), IntPtrTy));
3906 (yyval.ConstVal) = ConstantExpr::getCast((yyval.ConstVal), (yyvsp[-3].ConstVal)->getType());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003907 }
Reid Spencer61c83e02006-08-18 08:43:06 +00003908 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003909 ;}
3910 break;
3911
Reid Spencera132e042006-12-03 05:46:11 +00003912 case 158:
3913#line 1678 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003914 {
Reid Spencera132e042006-12-03 05:46:11 +00003915 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003916 GEN_ERROR("Logical operator types must match!");
Reid Spencera132e042006-12-03 05:46:11 +00003917 if (!(yyvsp[-3].ConstVal)->getType()->isIntegral()) {
3918 if (!isa<PackedType>((yyvsp[-3].ConstVal)->getType()) ||
3919 !cast<PackedType>((yyvsp[-3].ConstVal)->getType())->getElementType()->isIntegral())
Reid Spencer61c83e02006-08-18 08:43:06 +00003920 GEN_ERROR("Logical operator requires integral operands!");
Chris Lattner524a1312005-12-21 18:31:50 +00003921 }
Reid Spencera132e042006-12-03 05:46:11 +00003922 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003923 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003924 ;}
3925 break;
3926
Reid Spencera132e042006-12-03 05:46:11 +00003927 case 159:
3928#line 1689 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003929 {
Reid Spencera132e042006-12-03 05:46:11 +00003930 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencer1628cec2006-10-26 06:15:43 +00003931 GEN_ERROR("setcc operand types must match!");
Reid Spencera132e042006-12-03 05:46:11 +00003932 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer1628cec2006-10-26 06:15:43 +00003933 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003934 ;}
3935 break;
3936
Reid Spencera132e042006-12-03 05:46:11 +00003937 case 160:
3938#line 1695 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003939 {
Reid Spencera132e042006-12-03 05:46:11 +00003940 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
3941 GEN_ERROR("icmp operand types must match!");
3942 (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[-5].IPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
3943 ;}
3944 break;
3945
3946 case 161:
3947#line 1700 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3948 {
3949 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
3950 GEN_ERROR("fcmp operand types must match!");
3951 (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[-5].FPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
3952 ;}
3953 break;
3954
3955 case 162:
3956#line 1705 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3957 {
3958 if ((yyvsp[-1].ConstVal)->getType() != Type::UByteTy)
Reid Spencer1628cec2006-10-26 06:15:43 +00003959 GEN_ERROR("Shift count for shift constant must be unsigned byte!");
Reid Spencera132e042006-12-03 05:46:11 +00003960 if (!(yyvsp[-3].ConstVal)->getType()->isInteger())
Reid Spencer1628cec2006-10-26 06:15:43 +00003961 GEN_ERROR("Shift constant expression requires integer operand!");
Reid Spencer3822ff52006-11-08 06:47:33 +00003962 CHECK_FOR_ERROR;
Reid Spencera132e042006-12-03 05:46:11 +00003963 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].OtherOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer1628cec2006-10-26 06:15:43 +00003964 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003965 ;}
3966 break;
3967
Reid Spencera132e042006-12-03 05:46:11 +00003968 case 163:
3969#line 1714 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003970 {
Reid Spencera132e042006-12-03 05:46:11 +00003971 if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00003972 GEN_ERROR("Invalid extractelement operands!");
Reid Spencera132e042006-12-03 05:46:11 +00003973 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003974 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003975 ;}
3976 break;
3977
Reid Spencera132e042006-12-03 05:46:11 +00003978 case 164:
3979#line 1720 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003980 {
Reid Spencera132e042006-12-03 05:46:11 +00003981 if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00003982 GEN_ERROR("Invalid insertelement operands!");
Reid Spencera132e042006-12-03 05:46:11 +00003983 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003984 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003985 ;}
3986 break;
3987
Reid Spencera132e042006-12-03 05:46:11 +00003988 case 165:
3989#line 1726 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003990 {
Reid Spencera132e042006-12-03 05:46:11 +00003991 if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00003992 GEN_ERROR("Invalid shufflevector operands!");
Reid Spencera132e042006-12-03 05:46:11 +00003993 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003994 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003995 ;}
3996 break;
3997
Reid Spencera132e042006-12-03 05:46:11 +00003998 case 166:
3999#line 1735 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004000 {
4001 ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004002 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004003 ;}
4004 break;
4005
Reid Spencera132e042006-12-03 05:46:11 +00004006 case 167:
4007#line 1739 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004008 {
Reid Spencera132e042006-12-03 05:46:11 +00004009 (yyval.ConstVector) = new std::vector<Constant*>();
Reid Spencer3822ff52006-11-08 06:47:33 +00004010 (yyval.ConstVector)->push_back((yyvsp[0].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004011 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004012 ;}
4013 break;
4014
Reid Spencera132e042006-12-03 05:46:11 +00004015 case 168:
4016#line 1747 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004017 { (yyval.BoolVal) = false; ;}
4018 break;
4019
Reid Spencera132e042006-12-03 05:46:11 +00004020 case 169:
4021#line 1747 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004022 { (yyval.BoolVal) = true; ;}
4023 break;
4024
Reid Spencera132e042006-12-03 05:46:11 +00004025 case 170:
4026#line 1757 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004027 {
4028 (yyval.ModuleVal) = ParserResult = (yyvsp[0].ModuleVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004029 CurModule.ModuleDone();
Reid Spencerf63697d2006-10-09 17:36:59 +00004030 CHECK_FOR_ERROR;
Reid Spencer3822ff52006-11-08 06:47:33 +00004031;}
4032 break;
4033
Reid Spencera132e042006-12-03 05:46:11 +00004034 case 171:
4035#line 1765 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004036 {
4037 (yyval.ModuleVal) = (yyvsp[-1].ModuleVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004038 CurFun.FunctionDone();
Reid Spencer61c83e02006-08-18 08:43:06 +00004039 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004040 ;}
4041 break;
4042
Reid Spencera132e042006-12-03 05:46:11 +00004043 case 172:
4044#line 1770 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004045 {
4046 (yyval.ModuleVal) = (yyvsp[-1].ModuleVal);
Reid Spencer1628cec2006-10-26 06:15:43 +00004047 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004048 ;}
4049 break;
4050
Reid Spencera132e042006-12-03 05:46:11 +00004051 case 173:
4052#line 1774 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004053 {
4054 (yyval.ModuleVal) = (yyvsp[-3].ModuleVal);
Reid Spencer3ed469c2006-11-02 20:25:50 +00004055 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004056 ;}
4057 break;
4058
Reid Spencera132e042006-12-03 05:46:11 +00004059 case 174:
4060#line 1778 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004061 {
4062 (yyval.ModuleVal) = (yyvsp[-1].ModuleVal);
Reid Spencer3ed469c2006-11-02 20:25:50 +00004063 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004064 ;}
4065 break;
4066
Reid Spencera132e042006-12-03 05:46:11 +00004067 case 175:
4068#line 1782 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004069 {
4070 (yyval.ModuleVal) = CurModule.CurrentModule;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004071 // Emit an error if there are any unresolved types left.
4072 if (!CurModule.LateResolveTypes.empty()) {
4073 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
Reid Spencer61c83e02006-08-18 08:43:06 +00004074 if (DID.Type == ValID::NameVal) {
4075 GEN_ERROR("Reference to an undefined type: '"+DID.getName() + "'");
4076 } else {
4077 GEN_ERROR("Reference to an undefined type: #" + itostr(DID.Num));
4078 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004079 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004080 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004081 ;}
4082 break;
4083
Reid Spencera132e042006-12-03 05:46:11 +00004084 case 176:
4085#line 1797 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004086 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004087 // Eagerly resolve types. This is not an optimization, this is a
4088 // requirement that is due to the fact that we could have this:
4089 //
4090 // %list = type { %list * }
4091 // %list = type { %list * } ; repeated type decl
4092 //
4093 // If types are not resolved eagerly, then the two types will not be
4094 // determined to be the same type!
4095 //
Reid Spencera132e042006-12-03 05:46:11 +00004096 ResolveTypeTo((yyvsp[-2].StrVal), *(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004097
Reid Spencera132e042006-12-03 05:46:11 +00004098 if (!setTypeName(*(yyvsp[0].TypeVal), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00004099 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004100 // If this is a named type that is not a redefinition, add it to the slot
4101 // table.
Reid Spencera132e042006-12-03 05:46:11 +00004102 CurModule.Types.push_back(*(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004103 }
Reid Spencera132e042006-12-03 05:46:11 +00004104
4105 delete (yyvsp[0].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004106 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004107 ;}
4108 break;
4109
Reid Spencera132e042006-12-03 05:46:11 +00004110 case 177:
4111#line 1819 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004112 { // Function prototypes can be in const pool
Reid Spencer61c83e02006-08-18 08:43:06 +00004113 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004114 ;}
4115 break;
4116
Reid Spencera132e042006-12-03 05:46:11 +00004117 case 178:
4118#line 1822 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004119 { // Asm blocks can be in the const pool
Reid Spencer61c83e02006-08-18 08:43:06 +00004120 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004121 ;}
4122 break;
4123
Reid Spencera132e042006-12-03 05:46:11 +00004124 case 179:
4125#line 1825 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004126 {
Reid Spencera132e042006-12-03 05:46:11 +00004127 if ((yyvsp[0].ConstVal) == 0)
Reid Spencer5b7e7532006-09-28 19:28:24 +00004128 GEN_ERROR("Global value initializer is not a constant!");
Reid Spencera132e042006-12-03 05:46:11 +00004129 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 +00004130 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004131 ;}
4132 break;
4133
Reid Spencera132e042006-12-03 05:46:11 +00004134 case 180:
4135#line 1830 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004136 {
Reid Spencer5b7e7532006-09-28 19:28:24 +00004137 CurGV = 0;
Reid Spencer3822ff52006-11-08 06:47:33 +00004138 ;}
4139 break;
4140
Reid Spencera132e042006-12-03 05:46:11 +00004141 case 181:
4142#line 1833 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004143 {
Reid Spencera132e042006-12-03 05:46:11 +00004144 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage, (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0);
Reid Spencer5b7e7532006-09-28 19:28:24 +00004145 CHECK_FOR_ERROR
Reid Spencera132e042006-12-03 05:46:11 +00004146 delete (yyvsp[0].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00004147 ;}
4148 break;
4149
Reid Spencera132e042006-12-03 05:46:11 +00004150 case 182:
4151#line 1837 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004152 {
Reid Spencer1628cec2006-10-26 06:15:43 +00004153 CurGV = 0;
4154 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004155 ;}
4156 break;
4157
Reid Spencera132e042006-12-03 05:46:11 +00004158 case 183:
4159#line 1841 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004160 {
Reid Spencera132e042006-12-03 05:46:11 +00004161 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0);
Reid Spencer3ed469c2006-11-02 20:25:50 +00004162 CHECK_FOR_ERROR
Reid Spencera132e042006-12-03 05:46:11 +00004163 delete (yyvsp[0].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00004164 ;}
4165 break;
4166
Reid Spencera132e042006-12-03 05:46:11 +00004167 case 184:
4168#line 1845 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004169 {
Reid Spencer3ed469c2006-11-02 20:25:50 +00004170 CurGV = 0;
4171 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004172 ;}
4173 break;
4174
Reid Spencera132e042006-12-03 05:46:11 +00004175 case 185:
4176#line 1849 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004177 {
Reid Spencer5b7e7532006-09-28 19:28:24 +00004178 CurGV =
Reid Spencera132e042006-12-03 05:46:11 +00004179 ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0);
Reid Spencer5b7e7532006-09-28 19:28:24 +00004180 CHECK_FOR_ERROR
Reid Spencera132e042006-12-03 05:46:11 +00004181 delete (yyvsp[0].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00004182 ;}
4183 break;
4184
Reid Spencera132e042006-12-03 05:46:11 +00004185 case 186:
4186#line 1854 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004187 {
Anton Korobeynikovbcb97702006-09-17 20:25:45 +00004188 CurGV = 0;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004189 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004190 ;}
4191 break;
4192
Reid Spencera132e042006-12-03 05:46:11 +00004193 case 187:
4194#line 1858 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004195 {
Anton Korobeynikovbcb97702006-09-17 20:25:45 +00004196 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004197 ;}
4198 break;
4199
Reid Spencera132e042006-12-03 05:46:11 +00004200 case 188:
4201#line 1861 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004202 {
Anton Korobeynikovbcb97702006-09-17 20:25:45 +00004203 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004204 ;}
4205 break;
4206
Reid Spencera132e042006-12-03 05:46:11 +00004207 case 189:
4208#line 1864 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004209 {
4210 ;}
4211 break;
4212
Reid Spencera132e042006-12-03 05:46:11 +00004213 case 190:
4214#line 1868 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004215 {
Chris Lattner66316012006-01-24 04:14:29 +00004216 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Reid Spencer3822ff52006-11-08 06:47:33 +00004217 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4218 std::string NewAsm((yyvsp[0].StrVal), EndStr);
4219 free((yyvsp[0].StrVal));
Chris Lattner66316012006-01-24 04:14:29 +00004220
4221 if (AsmSoFar.empty())
4222 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
4223 else
4224 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Reid Spencer61c83e02006-08-18 08:43:06 +00004225 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004226;}
4227 break;
4228
Reid Spencera132e042006-12-03 05:46:11 +00004229 case 191:
4230#line 1881 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004231 { (yyval.Endianness) = Module::BigEndian; ;}
4232 break;
4233
Reid Spencera132e042006-12-03 05:46:11 +00004234 case 192:
4235#line 1882 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004236 { (yyval.Endianness) = Module::LittleEndian; ;}
4237 break;
4238
Reid Spencera132e042006-12-03 05:46:11 +00004239 case 193:
4240#line 1884 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004241 {
4242 CurModule.CurrentModule->setEndianness((yyvsp[0].Endianness));
Reid Spencer61c83e02006-08-18 08:43:06 +00004243 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004244 ;}
4245 break;
4246
Reid Spencera132e042006-12-03 05:46:11 +00004247 case 194:
4248#line 1888 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004249 {
4250 if ((yyvsp[0].UInt64Val) == 32)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004251 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
Reid Spencer3822ff52006-11-08 06:47:33 +00004252 else if ((yyvsp[0].UInt64Val) == 64)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004253 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
4254 else
Reid Spencer3822ff52006-11-08 06:47:33 +00004255 GEN_ERROR("Invalid pointer size: '" + utostr((yyvsp[0].UInt64Val)) + "'!");
Reid Spencer61c83e02006-08-18 08:43:06 +00004256 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004257 ;}
4258 break;
4259
Reid Spencera132e042006-12-03 05:46:11 +00004260 case 195:
4261#line 1897 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004262 {
4263 CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal));
4264 free((yyvsp[0].StrVal));
4265 ;}
4266 break;
4267
Reid Spencera132e042006-12-03 05:46:11 +00004268 case 196:
4269#line 1901 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004270 {
4271 CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal));
4272 free((yyvsp[0].StrVal));
4273 ;}
4274 break;
4275
Reid Spencera132e042006-12-03 05:46:11 +00004276 case 198:
4277#line 1908 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004278 {
4279 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4280 free((yyvsp[0].StrVal));
Reid Spencer3ed469c2006-11-02 20:25:50 +00004281 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004282 ;}
4283 break;
4284
Reid Spencera132e042006-12-03 05:46:11 +00004285 case 199:
4286#line 1913 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004287 {
4288 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4289 free((yyvsp[0].StrVal));
Reid Spencer3ed469c2006-11-02 20:25:50 +00004290 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004291 ;}
4292 break;
4293
Reid Spencera132e042006-12-03 05:46:11 +00004294 case 200:
4295#line 1918 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004296 {
Reid Spencer61c83e02006-08-18 08:43:06 +00004297 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004298 ;}
4299 break;
4300
Reid Spencera132e042006-12-03 05:46:11 +00004301 case 204:
4302#line 1928 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004303 { (yyval.StrVal) = 0; ;}
4304 break;
4305
Reid Spencera132e042006-12-03 05:46:11 +00004306 case 205:
4307#line 1930 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004308 {
Reid Spencera132e042006-12-03 05:46:11 +00004309 if (*(yyvsp[-1].TypeVal) == Type::VoidTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00004310 GEN_ERROR("void typed arguments are invalid!");
Reid Spencera132e042006-12-03 05:46:11 +00004311 (yyval.ArgVal) = new std::pair<PATypeHolder*, char*>((yyvsp[-1].TypeVal), (yyvsp[0].StrVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004312 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004313;}
4314 break;
4315
Reid Spencera132e042006-12-03 05:46:11 +00004316 case 206:
4317#line 1937 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004318 {
4319 (yyval.ArgList) = (yyvsp[-2].ArgList);
4320 (yyvsp[-2].ArgList)->push_back(*(yyvsp[0].ArgVal));
4321 delete (yyvsp[0].ArgVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004322 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004323 ;}
4324 break;
4325
Reid Spencera132e042006-12-03 05:46:11 +00004326 case 207:
4327#line 1943 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004328 {
Reid Spencera132e042006-12-03 05:46:11 +00004329 (yyval.ArgList) = new std::vector<std::pair<PATypeHolder*,char*> >();
Reid Spencer3822ff52006-11-08 06:47:33 +00004330 (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal));
4331 delete (yyvsp[0].ArgVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004332 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004333 ;}
4334 break;
4335
Reid Spencera132e042006-12-03 05:46:11 +00004336 case 208:
4337#line 1950 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004338 {
4339 (yyval.ArgList) = (yyvsp[0].ArgList);
Reid Spencer61c83e02006-08-18 08:43:06 +00004340 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004341 ;}
4342 break;
4343
Reid Spencera132e042006-12-03 05:46:11 +00004344 case 209:
4345#line 1954 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004346 {
4347 (yyval.ArgList) = (yyvsp[-2].ArgList);
Reid Spencera132e042006-12-03 05:46:11 +00004348 (yyval.ArgList)->push_back(std::pair<PATypeHolder*,
4349 char*>(new PATypeHolder(Type::VoidTy), 0));
Reid Spencer61c83e02006-08-18 08:43:06 +00004350 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004351 ;}
4352 break;
4353
Reid Spencera132e042006-12-03 05:46:11 +00004354 case 210:
4355#line 1960 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004356 {
Reid Spencera132e042006-12-03 05:46:11 +00004357 (yyval.ArgList) = new std::vector<std::pair<PATypeHolder*,char*> >();
4358 (yyval.ArgList)->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0));
Reid Spencer61c83e02006-08-18 08:43:06 +00004359 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004360 ;}
4361 break;
4362
Reid Spencera132e042006-12-03 05:46:11 +00004363 case 211:
4364#line 1965 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004365 {
4366 (yyval.ArgList) = 0;
Reid Spencer61c83e02006-08-18 08:43:06 +00004367 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004368 ;}
4369 break;
4370
Reid Spencera132e042006-12-03 05:46:11 +00004371 case 212:
4372#line 1971 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004373 {
4374 UnEscapeLexed((yyvsp[-5].StrVal));
4375 std::string FunctionName((yyvsp[-5].StrVal));
4376 free((yyvsp[-5].StrVal)); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004377
Reid Spencera132e042006-12-03 05:46:11 +00004378 if (!(*(yyvsp[-6].TypeVal))->isFirstClassType() && *(yyvsp[-6].TypeVal) != Type::VoidTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00004379 GEN_ERROR("LLVM functions cannot return aggregate types!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004380
4381 std::vector<const Type*> ParamTypeList;
Reid Spencer3822ff52006-11-08 06:47:33 +00004382 if ((yyvsp[-3].ArgList)) { // If there are arguments...
Reid Spencera132e042006-12-03 05:46:11 +00004383 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = (yyvsp[-3].ArgList)->begin();
Reid Spencer3822ff52006-11-08 06:47:33 +00004384 I != (yyvsp[-3].ArgList)->end(); ++I)
Reid Spencera132e042006-12-03 05:46:11 +00004385 ParamTypeList.push_back(I->first->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004386 }
4387
4388 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
4389 if (isVarArg) ParamTypeList.pop_back();
4390
Reid Spencera132e042006-12-03 05:46:11 +00004391 const FunctionType *FT = FunctionType::get(*(yyvsp[-6].TypeVal), ParamTypeList, isVarArg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004392 const PointerType *PFT = PointerType::get(FT);
Reid Spencera132e042006-12-03 05:46:11 +00004393 delete (yyvsp[-6].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004394
4395 ValID ID;
4396 if (!FunctionName.empty()) {
4397 ID = ValID::create((char*)FunctionName.c_str());
4398 } else {
4399 ID = ValID::create((int)CurModule.Values[PFT].size());
4400 }
4401
4402 Function *Fn = 0;
4403 // See if this function was forward referenced. If so, recycle the object.
4404 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4405 // Move the function to the end of the list, from whereever it was
4406 // previously inserted.
4407 Fn = cast<Function>(FWRef);
4408 CurModule.CurrentModule->getFunctionList().remove(Fn);
4409 CurModule.CurrentModule->getFunctionList().push_back(Fn);
4410 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
4411 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
4412 // If this is the case, either we need to be a forward decl, or it needs
4413 // to be.
4414 if (!CurFun.isDeclare && !Fn->isExternal())
Reid Spencer61c83e02006-08-18 08:43:06 +00004415 GEN_ERROR("Redefinition of function '" + FunctionName + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004416
4417 // Make sure to strip off any argument names so we can't get conflicts.
4418 if (Fn->isExternal())
4419 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
4420 AI != AE; ++AI)
4421 AI->setName("");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004422 } else { // Not already defined?
4423 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
4424 CurModule.CurrentModule);
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004425
Reid Spencer68a24bd2005-08-27 18:50:39 +00004426 InsertValue(Fn, CurModule.Values);
4427 }
4428
4429 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004430
4431 if (CurFun.isDeclare) {
4432 // If we have declaration, always overwrite linkage. This will allow us to
4433 // correctly handle cases, when pointer to function is passed as argument to
4434 // another function.
4435 Fn->setLinkage(CurFun.Linkage);
4436 }
Reid Spencer3822ff52006-11-08 06:47:33 +00004437 Fn->setCallingConv((yyvsp[-7].UIntVal));
4438 Fn->setAlignment((yyvsp[0].UIntVal));
4439 if ((yyvsp[-1].StrVal)) {
4440 Fn->setSection((yyvsp[-1].StrVal));
4441 free((yyvsp[-1].StrVal));
Chris Lattnere869eef2005-11-12 00:11:49 +00004442 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004443
4444 // Add all of the arguments we parsed to the function...
Reid Spencer3822ff52006-11-08 06:47:33 +00004445 if ((yyvsp[-3].ArgList)) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00004446 if (isVarArg) { // Nuke the last entry
Reid Spencera132e042006-12-03 05:46:11 +00004447 assert((yyvsp[-3].ArgList)->back().first->get() == Type::VoidTy && (yyvsp[-3].ArgList)->back().second == 0&&
4448 "Not a varargs marker!");
4449 delete (yyvsp[-3].ArgList)->back().first;
Reid Spencer3822ff52006-11-08 06:47:33 +00004450 (yyvsp[-3].ArgList)->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00004451 }
4452 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spencera132e042006-12-03 05:46:11 +00004453 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = (yyvsp[-3].ArgList)->begin();
Reid Spencer3822ff52006-11-08 06:47:33 +00004454 I != (yyvsp[-3].ArgList)->end(); ++I, ++ArgIt) {
Reid Spencera132e042006-12-03 05:46:11 +00004455 delete I->first; // Delete the typeholder...
4456
Reid Spencer68a24bd2005-08-27 18:50:39 +00004457 setValueName(ArgIt, I->second); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00004458 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004459 InsertValue(ArgIt);
4460 }
Reid Spencera132e042006-12-03 05:46:11 +00004461
Reid Spencer3822ff52006-11-08 06:47:33 +00004462 delete (yyvsp[-3].ArgList); // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00004463 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004464 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004465;}
4466 break;
4467
Reid Spencera132e042006-12-03 05:46:11 +00004468 case 215:
4469#line 2067 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004470 {
4471 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004472
4473 // Make sure that we keep track of the linkage type even if there was a
4474 // previous "declare".
Reid Spencer3822ff52006-11-08 06:47:33 +00004475 (yyval.FunctionVal)->setLinkage((yyvsp[-2].Linkage));
4476;}
4477 break;
4478
Reid Spencera132e042006-12-03 05:46:11 +00004479 case 218:
4480#line 2077 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004481 {
4482 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004483 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004484;}
4485 break;
4486
Reid Spencera132e042006-12-03 05:46:11 +00004487 case 220:
4488#line 2083 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004489 { CurFun.Linkage = GlobalValue::DLLImportLinkage; ;}
4490 break;
4491
Reid Spencera132e042006-12-03 05:46:11 +00004492 case 221:
4493#line 2084 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer481169e2006-12-01 00:33:46 +00004494 { CurFun.Linkage = GlobalValue::ExternalWeakLinkage; ;}
Reid Spencer3822ff52006-11-08 06:47:33 +00004495 break;
4496
Reid Spencera132e042006-12-03 05:46:11 +00004497 case 222:
4498#line 2086 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004499 { CurFun.isDeclare = true; ;}
4500 break;
4501
Reid Spencera132e042006-12-03 05:46:11 +00004502 case 223:
4503#line 2086 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004504 {
4505 (yyval.FunctionVal) = CurFun.CurrentFunction;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004506 CurFun.FunctionDone();
Reid Spencer61c83e02006-08-18 08:43:06 +00004507 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004508 ;}
4509 break;
4510
Reid Spencera132e042006-12-03 05:46:11 +00004511 case 224:
4512#line 2096 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004513 {
4514 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00004515 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004516 ;}
4517 break;
4518
Reid Spencera132e042006-12-03 05:46:11 +00004519 case 225:
4520#line 2100 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004521 {
4522 (yyval.BoolVal) = true;
Reid Spencer61c83e02006-08-18 08:43:06 +00004523 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004524 ;}
4525 break;
4526
Reid Spencera132e042006-12-03 05:46:11 +00004527 case 226:
4528#line 2105 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004529 { // A reference to a direct constant
4530 (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val));
Reid Spencer61c83e02006-08-18 08:43:06 +00004531 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004532 ;}
4533 break;
4534
Reid Spencera132e042006-12-03 05:46:11 +00004535 case 227:
4536#line 2109 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004537 {
4538 (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val));
Reid Spencer61c83e02006-08-18 08:43:06 +00004539 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004540 ;}
4541 break;
4542
Reid Spencera132e042006-12-03 05:46:11 +00004543 case 228:
4544#line 2113 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004545 { // Perhaps it's an FP constant?
4546 (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004547 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004548 ;}
4549 break;
4550
Reid Spencera132e042006-12-03 05:46:11 +00004551 case 229:
4552#line 2117 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004553 {
4554 (yyval.ValIDVal) = ValID::create(ConstantBool::getTrue());
Reid Spencer61c83e02006-08-18 08:43:06 +00004555 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004556 ;}
4557 break;
4558
Reid Spencera132e042006-12-03 05:46:11 +00004559 case 230:
4560#line 2121 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004561 {
4562 (yyval.ValIDVal) = ValID::create(ConstantBool::getFalse());
Reid Spencer61c83e02006-08-18 08:43:06 +00004563 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004564 ;}
4565 break;
4566
Reid Spencera132e042006-12-03 05:46:11 +00004567 case 231:
4568#line 2125 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004569 {
4570 (yyval.ValIDVal) = ValID::createNull();
Reid Spencer61c83e02006-08-18 08:43:06 +00004571 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004572 ;}
4573 break;
4574
Reid Spencera132e042006-12-03 05:46:11 +00004575 case 232:
4576#line 2129 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004577 {
4578 (yyval.ValIDVal) = ValID::createUndef();
Reid Spencer61c83e02006-08-18 08:43:06 +00004579 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004580 ;}
4581 break;
4582
Reid Spencera132e042006-12-03 05:46:11 +00004583 case 233:
4584#line 2133 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004585 { // A vector zero constant.
4586 (yyval.ValIDVal) = ValID::createZeroInit();
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004587 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004588 ;}
4589 break;
4590
Reid Spencera132e042006-12-03 05:46:11 +00004591 case 234:
4592#line 2137 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004593 { // Nonempty unsized packed vector
Reid Spencera132e042006-12-03 05:46:11 +00004594 const Type *ETy = (*(yyvsp[-1].ConstVector))[0]->getType();
Reid Spencer3822ff52006-11-08 06:47:33 +00004595 int NumElements = (yyvsp[-1].ConstVector)->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004596
4597 PackedType* pt = PackedType::get(ETy, NumElements);
4598 PATypeHolder* PTy = new PATypeHolder(
Reid Spencera132e042006-12-03 05:46:11 +00004599 HandleUpRefs(
4600 PackedType::get(
4601 ETy,
4602 NumElements)
4603 )
4604 );
Reid Spencer68a24bd2005-08-27 18:50:39 +00004605
4606 // Verify all elements are correct type!
Reid Spencer3822ff52006-11-08 06:47:33 +00004607 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
Reid Spencera132e042006-12-03 05:46:11 +00004608 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00004609 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00004610 ETy->getDescription() +"' as required!\nIt is of type '" +
Reid Spencera132e042006-12-03 05:46:11 +00004611 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004612 }
4613
Reid Spencera132e042006-12-03 05:46:11 +00004614 (yyval.ValIDVal) = ValID::create(ConstantPacked::get(pt, *(yyvsp[-1].ConstVector)));
Reid Spencer3822ff52006-11-08 06:47:33 +00004615 delete PTy; delete (yyvsp[-1].ConstVector);
Reid Spencer61c83e02006-08-18 08:43:06 +00004616 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004617 ;}
4618 break;
Reid Spencer21be8652006-10-22 07:03:43 +00004619
Reid Spencera132e042006-12-03 05:46:11 +00004620 case 235:
4621#line 2162 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004622 {
Reid Spencera132e042006-12-03 05:46:11 +00004623 (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal));
Reid Spencer21be8652006-10-22 07:03:43 +00004624 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004625 ;}
4626 break;
4627
Reid Spencera132e042006-12-03 05:46:11 +00004628 case 236:
4629#line 2166 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004630 {
4631 char *End = UnEscapeLexed((yyvsp[-2].StrVal), true);
4632 std::string AsmStr = std::string((yyvsp[-2].StrVal), End);
4633 End = UnEscapeLexed((yyvsp[0].StrVal), true);
4634 std::string Constraints = std::string((yyvsp[0].StrVal), End);
4635 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal));
4636 free((yyvsp[-2].StrVal));
4637 free((yyvsp[0].StrVal));
Reid Spencer21be8652006-10-22 07:03:43 +00004638 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004639 ;}
4640 break;
4641
Reid Spencera132e042006-12-03 05:46:11 +00004642 case 237:
4643#line 2180 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004644 { // Is it an integer reference...?
4645 (yyval.ValIDVal) = ValID::create((yyvsp[0].SIntVal));
4646 CHECK_FOR_ERROR
4647 ;}
4648 break;
4649
Reid Spencera132e042006-12-03 05:46:11 +00004650 case 238:
4651#line 2184 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004652 { // Is it a named reference...?
4653 (yyval.ValIDVal) = ValID::create((yyvsp[0].StrVal));
4654 CHECK_FOR_ERROR
4655 ;}
4656 break;
4657
Reid Spencera132e042006-12-03 05:46:11 +00004658 case 241:
4659#line 2196 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004660 {
Reid Spencera132e042006-12-03 05:46:11 +00004661 (yyval.ValueVal) = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal)); delete (yyvsp[-1].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00004662 CHECK_FOR_ERROR
4663 ;}
4664 break;
4665
Reid Spencera132e042006-12-03 05:46:11 +00004666 case 242:
4667#line 2201 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004668 {
4669 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
4670 CHECK_FOR_ERROR
4671 ;}
4672 break;
4673
Reid Spencera132e042006-12-03 05:46:11 +00004674 case 243:
4675#line 2205 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004676 { // Do not allow functions with 0 basic blocks
4677 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
4678 CHECK_FOR_ERROR
4679 ;}
4680 break;
4681
Reid Spencera132e042006-12-03 05:46:11 +00004682 case 244:
4683#line 2214 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004684 {
4685 setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal));
4686 CHECK_FOR_ERROR
4687 InsertValue((yyvsp[0].TermInstVal));
4688
4689 (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal));
4690 InsertValue((yyvsp[-2].BasicBlockVal));
4691 (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal);
4692 CHECK_FOR_ERROR
4693 ;}
4694 break;
4695
Reid Spencera132e042006-12-03 05:46:11 +00004696 case 245:
4697#line 2225 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004698 {
Reid Spencer3da59db2006-11-27 01:05:10 +00004699 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[0].InstVal)))
4700 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
4701 if (CI2->getParent() == 0)
4702 (yyvsp[-1].BasicBlockVal)->getInstList().push_back(CI2);
Reid Spencer3822ff52006-11-08 06:47:33 +00004703 (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal));
4704 (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal);
4705 CHECK_FOR_ERROR
4706 ;}
4707 break;
4708
Reid Spencera132e042006-12-03 05:46:11 +00004709 case 246:
4710#line 2234 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004711 {
4712 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
Reid Spencer5b7e7532006-09-28 19:28:24 +00004713 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004714
4715 // Make sure to move the basic block to the correct location in the
4716 // function, instead of leaving it inserted wherever it was first
4717 // referenced.
4718 Function::BasicBlockListType &BBL =
4719 CurFun.CurrentFunction->getBasicBlockList();
Reid Spencer3822ff52006-11-08 06:47:33 +00004720 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004721 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004722 ;}
4723 break;
4724
Reid Spencera132e042006-12-03 05:46:11 +00004725 case 247:
4726#line 2246 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004727 {
4728 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[0].StrVal)), true);
Reid Spencer5b7e7532006-09-28 19:28:24 +00004729 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004730
4731 // Make sure to move the basic block to the correct location in the
4732 // function, instead of leaving it inserted wherever it was first
4733 // referenced.
4734 Function::BasicBlockListType &BBL =
4735 CurFun.CurrentFunction->getBasicBlockList();
Reid Spencer3822ff52006-11-08 06:47:33 +00004736 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004737 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004738 ;}
4739 break;
Reid Spencer61c83e02006-08-18 08:43:06 +00004740
Reid Spencera132e042006-12-03 05:46:11 +00004741 case 248:
4742#line 2259 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004743 { // Return with a result...
Reid Spencera132e042006-12-03 05:46:11 +00004744 (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal));
Reid Spencer3822ff52006-11-08 06:47:33 +00004745 CHECK_FOR_ERROR
4746 ;}
4747 break;
4748
Reid Spencera132e042006-12-03 05:46:11 +00004749 case 249:
4750#line 2263 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004751 { // Return with no result...
4752 (yyval.TermInstVal) = new ReturnInst();
4753 CHECK_FOR_ERROR
4754 ;}
4755 break;
4756
Reid Spencera132e042006-12-03 05:46:11 +00004757 case 250:
4758#line 2267 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004759 { // Unconditional Branch...
4760 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
4761 CHECK_FOR_ERROR
4762 (yyval.TermInstVal) = new BranchInst(tmpBB);
4763 ;}
4764 break;
4765
Reid Spencera132e042006-12-03 05:46:11 +00004766 case 251:
4767#line 2272 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004768 {
4769 BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal));
4770 CHECK_FOR_ERROR
4771 BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal));
4772 CHECK_FOR_ERROR
4773 Value* tmpVal = getVal(Type::BoolTy, (yyvsp[-6].ValIDVal));
4774 CHECK_FOR_ERROR
4775 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
4776 ;}
4777 break;
4778
Reid Spencera132e042006-12-03 05:46:11 +00004779 case 252:
4780#line 2281 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004781 {
Reid Spencera132e042006-12-03 05:46:11 +00004782 Value* tmpVal = getVal((yyvsp[-7].PrimType), (yyvsp[-6].ValIDVal));
Reid Spencer3822ff52006-11-08 06:47:33 +00004783 CHECK_FOR_ERROR
4784 BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal));
4785 CHECK_FOR_ERROR
4786 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size());
4787 (yyval.TermInstVal) = S;
4788
4789 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(),
4790 E = (yyvsp[-1].JumpTable)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004791 for (; I != E; ++I) {
4792 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
4793 S->addCase(CI, I->second);
4794 else
Reid Spencer61c83e02006-08-18 08:43:06 +00004795 GEN_ERROR("Switch case is constant, but not a simple integer!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004796 }
Reid Spencer3822ff52006-11-08 06:47:33 +00004797 delete (yyvsp[-1].JumpTable);
Reid Spencer61c83e02006-08-18 08:43:06 +00004798 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004799 ;}
4800 break;
4801
Reid Spencera132e042006-12-03 05:46:11 +00004802 case 253:
4803#line 2300 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004804 {
Reid Spencera132e042006-12-03 05:46:11 +00004805 Value* tmpVal = getVal((yyvsp[-6].PrimType), (yyvsp[-5].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004806 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004807 BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004808 CHECK_FOR_ERROR
4809 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Reid Spencer3822ff52006-11-08 06:47:33 +00004810 (yyval.TermInstVal) = S;
Reid Spencer61c83e02006-08-18 08:43:06 +00004811 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004812 ;}
4813 break;
4814
Reid Spencera132e042006-12-03 05:46:11 +00004815 case 254:
4816#line 2310 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004817 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004818 const PointerType *PFTy;
4819 const FunctionType *Ty;
4820
Reid Spencera132e042006-12-03 05:46:11 +00004821 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-10].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00004822 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4823 // Pull out the types of all of the arguments...
4824 std::vector<const Type*> ParamTypes;
Reid Spencer3822ff52006-11-08 06:47:33 +00004825 if ((yyvsp[-7].ValueList)) {
Reid Spencera132e042006-12-03 05:46:11 +00004826 for (std::vector<Value*>::iterator I = (yyvsp[-7].ValueList)->begin(), E = (yyvsp[-7].ValueList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004827 I != E; ++I)
Reid Spencera132e042006-12-03 05:46:11 +00004828 ParamTypes.push_back((*I)->getType());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004829 }
4830
4831 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
4832 if (isVarArg) ParamTypes.pop_back();
4833
Reid Spencera132e042006-12-03 05:46:11 +00004834 Ty = FunctionType::get((yyvsp[-10].TypeVal)->get(), ParamTypes, isVarArg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004835 PFTy = PointerType::get(Ty);
4836 }
4837
Reid Spencer3822ff52006-11-08 06:47:33 +00004838 Value *V = getVal(PFTy, (yyvsp[-9].ValIDVal)); // Get the function we're calling...
Reid Spencer5b7e7532006-09-28 19:28:24 +00004839 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004840 BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004841 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004842 BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004843 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004844
4845 // Create the call node...
Reid Spencer3822ff52006-11-08 06:47:33 +00004846 if (!(yyvsp[-7].ValueList)) { // Has no arguments?
4847 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, std::vector<Value*>());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004848 } else { // Has arguments?
4849 // Loop through FunctionType's arguments and ensure they are specified
4850 // correctly!
4851 //
4852 FunctionType::param_iterator I = Ty->param_begin();
4853 FunctionType::param_iterator E = Ty->param_end();
Reid Spencera132e042006-12-03 05:46:11 +00004854 std::vector<Value*>::iterator ArgI = (yyvsp[-7].ValueList)->begin(), ArgE = (yyvsp[-7].ValueList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004855
Reid Spencera132e042006-12-03 05:46:11 +00004856 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
4857 if ((*ArgI)->getType() != *I)
4858 GEN_ERROR("Parameter " +(*ArgI)->getName()+ " is not of type '" +
4859 (*I)->getDescription() + "'!");
4860
4861 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
4862 GEN_ERROR("Invalid number of parameters detected!");
4863
4864 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, *(yyvsp[-7].ValueList));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004865 }
Reid Spencer3822ff52006-11-08 06:47:33 +00004866 cast<InvokeInst>((yyval.TermInstVal))->setCallingConv((yyvsp[-11].UIntVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004867
Reid Spencera132e042006-12-03 05:46:11 +00004868 delete (yyvsp[-10].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00004869 delete (yyvsp[-7].ValueList);
Reid Spencer61c83e02006-08-18 08:43:06 +00004870 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004871 ;}
4872 break;
4873
Reid Spencera132e042006-12-03 05:46:11 +00004874 case 255:
4875#line 2365 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004876 {
4877 (yyval.TermInstVal) = new UnwindInst();
Reid Spencer61c83e02006-08-18 08:43:06 +00004878 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004879 ;}
4880 break;
4881
Reid Spencera132e042006-12-03 05:46:11 +00004882 case 256:
4883#line 2369 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004884 {
4885 (yyval.TermInstVal) = new UnreachableInst();
Reid Spencer61c83e02006-08-18 08:43:06 +00004886 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004887 ;}
4888 break;
4889
Reid Spencera132e042006-12-03 05:46:11 +00004890 case 257:
4891#line 2376 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004892 {
4893 (yyval.JumpTable) = (yyvsp[-5].JumpTable);
Reid Spencera132e042006-12-03 05:46:11 +00004894 Constant *V = cast<Constant>(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal)));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004895 CHECK_FOR_ERROR
Reid Spencer61c83e02006-08-18 08:43:06 +00004896 if (V == 0)
4897 GEN_ERROR("May only switch on a constant pool value!");
4898
Reid Spencer3822ff52006-11-08 06:47:33 +00004899 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004900 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004901 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
4902 ;}
4903 break;
4904
Reid Spencera132e042006-12-03 05:46:11 +00004905 case 258:
4906#line 2387 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004907 {
4908 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
Reid Spencera132e042006-12-03 05:46:11 +00004909 Constant *V = cast<Constant>(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal)));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004910 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004911
4912 if (V == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00004913 GEN_ERROR("May only switch on a constant pool value!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004914
Reid Spencer3822ff52006-11-08 06:47:33 +00004915 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004916 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004917 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
4918 ;}
4919 break;
4920
Reid Spencera132e042006-12-03 05:46:11 +00004921 case 259:
4922#line 2400 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004923 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004924 // Is this definition named?? if so, assign the name...
Reid Spencer3822ff52006-11-08 06:47:33 +00004925 setValueName((yyvsp[0].InstVal), (yyvsp[-1].StrVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004926 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004927 InsertValue((yyvsp[0].InstVal));
4928 (yyval.InstVal) = (yyvsp[0].InstVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004929 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004930;}
4931 break;
4932
Reid Spencera132e042006-12-03 05:46:11 +00004933 case 260:
4934#line 2409 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004935 { // Used for PHI nodes
4936 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
Reid Spencera132e042006-12-03 05:46:11 +00004937 Value* tmpVal = getVal(*(yyvsp[-5].TypeVal), (yyvsp[-3].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004938 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004939 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004940 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004941 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
Reid Spencera132e042006-12-03 05:46:11 +00004942 delete (yyvsp[-5].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00004943 ;}
4944 break;
4945
Reid Spencera132e042006-12-03 05:46:11 +00004946 case 261:
4947#line 2418 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004948 {
4949 (yyval.PHIList) = (yyvsp[-6].PHIList);
4950 Value* tmpVal = getVal((yyvsp[-6].PHIList)->front().first->getType(), (yyvsp[-3].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004951 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004952 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004953 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004954 (yyvsp[-6].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
4955 ;}
4956 break;
4957
Reid Spencera132e042006-12-03 05:46:11 +00004958 case 262:
4959#line 2428 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004960 { // Used for call statements, and memory insts...
Reid Spencera132e042006-12-03 05:46:11 +00004961 (yyval.ValueList) = new std::vector<Value*>();
Reid Spencer3822ff52006-11-08 06:47:33 +00004962 (yyval.ValueList)->push_back((yyvsp[0].ValueVal));
4963 ;}
4964 break;
4965
Reid Spencera132e042006-12-03 05:46:11 +00004966 case 263:
4967#line 2432 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004968 {
4969 (yyval.ValueList) = (yyvsp[-2].ValueList);
4970 (yyvsp[-2].ValueList)->push_back((yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004971 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004972 ;}
4973 break;
4974
Reid Spencera132e042006-12-03 05:46:11 +00004975 case 265:
4976#line 2439 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4977 { (yyval.ValueList) = 0; ;}
Reid Spencer861d9d62006-11-28 07:29:44 +00004978 break;
4979
Reid Spencera132e042006-12-03 05:46:11 +00004980 case 266:
4981#line 2441 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004982 {
4983 (yyval.BoolVal) = true;
Reid Spencer61c83e02006-08-18 08:43:06 +00004984 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004985 ;}
4986 break;
4987
Reid Spencera132e042006-12-03 05:46:11 +00004988 case 267:
4989#line 2445 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004990 {
4991 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00004992 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004993 ;}
4994 break;
4995
Reid Spencera132e042006-12-03 05:46:11 +00004996 case 268:
4997#line 2450 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004998 {
Reid Spencera132e042006-12-03 05:46:11 +00004999 if (!(*(yyvsp[-3].TypeVal))->isInteger() && !(*(yyvsp[-3].TypeVal))->isFloatingPoint() &&
5000 !isa<PackedType>((*(yyvsp[-3].TypeVal)).get()))
Reid Spencer61c83e02006-08-18 08:43:06 +00005001 GEN_ERROR(
Reid Spencer68a24bd2005-08-27 18:50:39 +00005002 "Arithmetic operator requires integer, FP, or packed operands!");
Reid Spencera132e042006-12-03 05:46:11 +00005003 if (isa<PackedType>((*(yyvsp[-3].TypeVal)).get()) &&
5004 ((yyvsp[-4].BinaryOpVal) == Instruction::URem ||
5005 (yyvsp[-4].BinaryOpVal) == Instruction::SRem ||
5006 (yyvsp[-4].BinaryOpVal) == Instruction::FRem))
Reid Spencer3ed469c2006-11-02 20:25:50 +00005007 GEN_ERROR("U/S/FRem not supported on packed types!");
Reid Spencera132e042006-12-03 05:46:11 +00005008 Value* val1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005009 CHECK_FOR_ERROR
Reid Spencera132e042006-12-03 05:46:11 +00005010 Value* val2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005011 CHECK_FOR_ERROR
Reid Spencera132e042006-12-03 05:46:11 +00005012 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), val1, val2);
Reid Spencer3822ff52006-11-08 06:47:33 +00005013 if ((yyval.InstVal) == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00005014 GEN_ERROR("binary operator returned null!");
Reid Spencera132e042006-12-03 05:46:11 +00005015 delete (yyvsp[-3].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00005016 ;}
5017 break;
5018
Reid Spencera132e042006-12-03 05:46:11 +00005019 case 269:
5020#line 2469 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005021 {
Reid Spencera132e042006-12-03 05:46:11 +00005022 if (!(*(yyvsp[-3].TypeVal))->isIntegral()) {
5023 if (!isa<PackedType>((yyvsp[-3].TypeVal)->get()) ||
5024 !cast<PackedType>((yyvsp[-3].TypeVal)->get())->getElementType()->isIntegral())
Reid Spencer61c83e02006-08-18 08:43:06 +00005025 GEN_ERROR("Logical operator requires integral operands!");
Chris Lattner524a1312005-12-21 18:31:50 +00005026 }
Reid Spencera132e042006-12-03 05:46:11 +00005027 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005028 CHECK_FOR_ERROR
Reid Spencera132e042006-12-03 05:46:11 +00005029 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005030 CHECK_FOR_ERROR
Reid Spencera132e042006-12-03 05:46:11 +00005031 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), tmpVal1, tmpVal2);
Reid Spencer3822ff52006-11-08 06:47:33 +00005032 if ((yyval.InstVal) == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00005033 GEN_ERROR("binary operator returned null!");
Reid Spencera132e042006-12-03 05:46:11 +00005034 delete (yyvsp[-3].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00005035 ;}
5036 break;
5037
Reid Spencera132e042006-12-03 05:46:11 +00005038 case 270:
5039#line 2484 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005040 {
Reid Spencera132e042006-12-03 05:46:11 +00005041 if(isa<PackedType>((*(yyvsp[-3].TypeVal)).get())) {
Reid Spencer61c83e02006-08-18 08:43:06 +00005042 GEN_ERROR(
Reid Spencer68a24bd2005-08-27 18:50:39 +00005043 "PackedTypes currently not supported in setcc instructions!");
5044 }
Reid Spencera132e042006-12-03 05:46:11 +00005045 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005046 CHECK_FOR_ERROR
Reid Spencera132e042006-12-03 05:46:11 +00005047 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005048 CHECK_FOR_ERROR
Reid Spencera132e042006-12-03 05:46:11 +00005049 (yyval.InstVal) = new SetCondInst((yyvsp[-4].BinaryOpVal), tmpVal1, tmpVal2);
Reid Spencer3822ff52006-11-08 06:47:33 +00005050 if ((yyval.InstVal) == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00005051 GEN_ERROR("binary operator returned null!");
Reid Spencera132e042006-12-03 05:46:11 +00005052 delete (yyvsp[-3].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00005053 ;}
5054 break;
5055
Reid Spencera132e042006-12-03 05:46:11 +00005056 case 271:
5057#line 2498 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5058 {
5059 if (isa<PackedType>((*(yyvsp[-3].TypeVal)).get()))
5060 GEN_ERROR("Packed types not supported by icmp instruction");
5061 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
5062 CHECK_FOR_ERROR
5063 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
5064 CHECK_FOR_ERROR
5065 (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].IPredicate), tmpVal1, tmpVal2);
5066 if ((yyval.InstVal) == 0)
5067 GEN_ERROR("icmp operator returned null!");
5068 ;}
5069 break;
5070
5071 case 272:
5072#line 2509 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5073 {
5074 if (isa<PackedType>((*(yyvsp[-3].TypeVal)).get()))
5075 GEN_ERROR("Packed types not supported by fcmp instruction");
5076 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
5077 CHECK_FOR_ERROR
5078 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
5079 CHECK_FOR_ERROR
5080 (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].FPredicate), tmpVal1, tmpVal2);
5081 if ((yyval.InstVal) == 0)
5082 GEN_ERROR("fcmp operator returned null!");
5083 ;}
5084 break;
5085
5086 case 273:
5087#line 2520 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005088 {
Reid Spencer481169e2006-12-01 00:33:46 +00005089 llvm_cerr << "WARNING: Use of eliminated 'not' instruction:"
Reid Spencer68a24bd2005-08-27 18:50:39 +00005090 << " Replacing with 'xor'.\n";
5091
Reid Spencera132e042006-12-03 05:46:11 +00005092 Value *Ones = ConstantIntegral::getAllOnesValue((yyvsp[0].ValueVal)->getType());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005093 if (Ones == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00005094 GEN_ERROR("Expected integral type for not instruction!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005095
Reid Spencera132e042006-12-03 05:46:11 +00005096 (yyval.InstVal) = BinaryOperator::create(Instruction::Xor, (yyvsp[0].ValueVal), Ones);
Reid Spencer3822ff52006-11-08 06:47:33 +00005097 if ((yyval.InstVal) == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00005098 GEN_ERROR("Could not create a xor instruction!");
5099 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005100 ;}
5101 break;
5102
Reid Spencera132e042006-12-03 05:46:11 +00005103 case 274:
5104#line 2533 "/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[0].ValueVal)->getType() != Type::UByteTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00005107 GEN_ERROR("Shift amount must be ubyte!");
Reid Spencera132e042006-12-03 05:46:11 +00005108 if (!(yyvsp[-2].ValueVal)->getType()->isInteger())
Reid Spencer61c83e02006-08-18 08:43:06 +00005109 GEN_ERROR("Shift constant expression requires integer operand!");
Reid Spencer3822ff52006-11-08 06:47:33 +00005110 CHECK_FOR_ERROR;
Reid Spencera132e042006-12-03 05:46:11 +00005111 (yyval.InstVal) = new ShiftInst((yyvsp[-3].OtherOpVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005112 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005113 ;}
5114 break;
5115
Reid Spencera132e042006-12-03 05:46:11 +00005116 case 275:
5117#line 2542 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005118 {
Reid Spencera132e042006-12-03 05:46:11 +00005119 Value* Val = (yyvsp[-2].ValueVal);
5120 const Type* Ty = (yyvsp[0].TypeVal)->get();
Reid Spencer3da59db2006-11-27 01:05:10 +00005121 if (!Val->getType()->isFirstClassType())
5122 GEN_ERROR("cast from a non-primitive type: '" +
5123 Val->getType()->getDescription() + "'!");
5124 if (!Ty->isFirstClassType())
5125 GEN_ERROR("cast to a non-primitive type: '" + Ty->getDescription() +"'!");
Reid Spencera132e042006-12-03 05:46:11 +00005126 (yyval.InstVal) = CastInst::create((yyvsp[-3].CastOpVal), (yyvsp[-2].ValueVal), (yyvsp[0].TypeVal)->get());
5127 delete (yyvsp[0].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00005128 ;}
5129 break;
5130
Reid Spencera132e042006-12-03 05:46:11 +00005131 case 276:
5132#line 2553 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005133 {
Reid Spencera132e042006-12-03 05:46:11 +00005134 if ((yyvsp[-4].ValueVal)->getType() != Type::BoolTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00005135 GEN_ERROR("select condition must be boolean!");
Reid Spencera132e042006-12-03 05:46:11 +00005136 if ((yyvsp[-2].ValueVal)->getType() != (yyvsp[0].ValueVal)->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00005137 GEN_ERROR("select value types should match!");
Reid Spencera132e042006-12-03 05:46:11 +00005138 (yyval.InstVal) = new SelectInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005139 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005140 ;}
5141 break;
5142
Reid Spencera132e042006-12-03 05:46:11 +00005143 case 277:
5144#line 2561 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005145 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00005146 NewVarArgs = true;
Reid Spencera132e042006-12-03 05:46:11 +00005147 (yyval.InstVal) = new VAArgInst((yyvsp[-2].ValueVal), *(yyvsp[0].TypeVal));
5148 delete (yyvsp[0].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005149 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005150 ;}
5151 break;
5152
Reid Spencera132e042006-12-03 05:46:11 +00005153 case 278:
5154#line 2567 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005155 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00005156 ObsoleteVarArgs = true;
Reid Spencera132e042006-12-03 05:46:11 +00005157 const Type* ArgTy = (yyvsp[-2].ValueVal)->getType();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005158 Function* NF = CurModule.CurrentModule->
Jeff Cohen66c5fd62005-10-23 04:37:20 +00005159 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005160
5161 //b = vaarg a, t ->
5162 //foo = alloca 1 of t
5163 //bar = vacopy a
5164 //store bar -> foo
5165 //b = vaarg foo, t
5166 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
5167 CurBB->getInstList().push_back(foo);
Reid Spencera132e042006-12-03 05:46:11 +00005168 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005169 CurBB->getInstList().push_back(bar);
5170 CurBB->getInstList().push_back(new StoreInst(bar, foo));
Reid Spencera132e042006-12-03 05:46:11 +00005171 (yyval.InstVal) = new VAArgInst(foo, *(yyvsp[0].TypeVal));
5172 delete (yyvsp[0].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005173 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005174 ;}
5175 break;
5176
Reid Spencera132e042006-12-03 05:46:11 +00005177 case 279:
5178#line 2587 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005179 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00005180 ObsoleteVarArgs = true;
Reid Spencera132e042006-12-03 05:46:11 +00005181 const Type* ArgTy = (yyvsp[-2].ValueVal)->getType();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005182 Function* NF = CurModule.CurrentModule->
Jeff Cohen66c5fd62005-10-23 04:37:20 +00005183 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005184
5185 //b = vanext a, t ->
5186 //foo = alloca 1 of t
5187 //bar = vacopy a
5188 //store bar -> foo
5189 //tmp = vaarg foo, t
5190 //b = load foo
5191 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
5192 CurBB->getInstList().push_back(foo);
Reid Spencera132e042006-12-03 05:46:11 +00005193 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005194 CurBB->getInstList().push_back(bar);
5195 CurBB->getInstList().push_back(new StoreInst(bar, foo));
Reid Spencera132e042006-12-03 05:46:11 +00005196 Instruction* tmp = new VAArgInst(foo, *(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005197 CurBB->getInstList().push_back(tmp);
Reid Spencer3822ff52006-11-08 06:47:33 +00005198 (yyval.InstVal) = new LoadInst(foo);
Reid Spencera132e042006-12-03 05:46:11 +00005199 delete (yyvsp[0].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005200 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005201 ;}
5202 break;
5203
Reid Spencera132e042006-12-03 05:46:11 +00005204 case 280:
5205#line 2610 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005206 {
Reid Spencera132e042006-12-03 05:46:11 +00005207 if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00005208 GEN_ERROR("Invalid extractelement operands!");
Reid Spencera132e042006-12-03 05:46:11 +00005209 (yyval.InstVal) = new ExtractElementInst((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005210 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005211 ;}
5212 break;
5213
Reid Spencera132e042006-12-03 05:46:11 +00005214 case 281:
5215#line 2616 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005216 {
Reid Spencera132e042006-12-03 05:46:11 +00005217 if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00005218 GEN_ERROR("Invalid insertelement operands!");
Reid Spencera132e042006-12-03 05:46:11 +00005219 (yyval.InstVal) = new InsertElementInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005220 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005221 ;}
5222 break;
5223
Reid Spencera132e042006-12-03 05:46:11 +00005224 case 282:
5225#line 2622 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005226 {
Reid Spencera132e042006-12-03 05:46:11 +00005227 if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00005228 GEN_ERROR("Invalid shufflevector operands!");
Reid Spencera132e042006-12-03 05:46:11 +00005229 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005230 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005231 ;}
5232 break;
5233
Reid Spencera132e042006-12-03 05:46:11 +00005234 case 283:
5235#line 2628 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005236 {
5237 const Type *Ty = (yyvsp[0].PHIList)->front().first->getType();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005238 if (!Ty->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00005239 GEN_ERROR("PHI node operands must be of first class type!");
Reid Spencer3822ff52006-11-08 06:47:33 +00005240 (yyval.InstVal) = new PHINode(Ty);
5241 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[0].PHIList)->size());
5242 while ((yyvsp[0].PHIList)->begin() != (yyvsp[0].PHIList)->end()) {
5243 if ((yyvsp[0].PHIList)->front().first->getType() != Ty)
Reid Spencer61c83e02006-08-18 08:43:06 +00005244 GEN_ERROR("All elements of a PHI node must be of the same type!");
Reid Spencer3822ff52006-11-08 06:47:33 +00005245 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[0].PHIList)->front().first, (yyvsp[0].PHIList)->front().second);
5246 (yyvsp[0].PHIList)->pop_front();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005247 }
Reid Spencer3822ff52006-11-08 06:47:33 +00005248 delete (yyvsp[0].PHIList); // Free the list...
Reid Spencer61c83e02006-08-18 08:43:06 +00005249 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005250 ;}
5251 break;
5252
Reid Spencera132e042006-12-03 05:46:11 +00005253 case 284:
5254#line 2643 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005255 {
Reid Spencer3da59db2006-11-27 01:05:10 +00005256 const PointerType *PFTy = 0;
5257 const FunctionType *Ty = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005258
Reid Spencera132e042006-12-03 05:46:11 +00005259 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-4].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00005260 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5261 // Pull out the types of all of the arguments...
5262 std::vector<const Type*> ParamTypes;
Reid Spencer3822ff52006-11-08 06:47:33 +00005263 if ((yyvsp[-1].ValueList)) {
Reid Spencera132e042006-12-03 05:46:11 +00005264 for (std::vector<Value*>::iterator I = (yyvsp[-1].ValueList)->begin(), E = (yyvsp[-1].ValueList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005265 I != E; ++I)
Reid Spencera132e042006-12-03 05:46:11 +00005266 ParamTypes.push_back((*I)->getType());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005267 }
5268
5269 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
5270 if (isVarArg) ParamTypes.pop_back();
5271
Reid Spencera132e042006-12-03 05:46:11 +00005272 if (!(*(yyvsp[-4].TypeVal))->isFirstClassType() && *(yyvsp[-4].TypeVal) != Type::VoidTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00005273 GEN_ERROR("LLVM functions cannot return aggregate types!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005274
Reid Spencera132e042006-12-03 05:46:11 +00005275 Ty = FunctionType::get((yyvsp[-4].TypeVal)->get(), ParamTypes, isVarArg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005276 PFTy = PointerType::get(Ty);
5277 }
5278
Reid Spencer3822ff52006-11-08 06:47:33 +00005279 Value *V = getVal(PFTy, (yyvsp[-3].ValIDVal)); // Get the function we're calling...
Reid Spencer5b7e7532006-09-28 19:28:24 +00005280 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005281
5282 // Create the call node...
Reid Spencer3822ff52006-11-08 06:47:33 +00005283 if (!(yyvsp[-1].ValueList)) { // Has no arguments?
Reid Spencer68a24bd2005-08-27 18:50:39 +00005284 // Make sure no arguments is a good thing!
5285 if (Ty->getNumParams() != 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00005286 GEN_ERROR("No arguments passed to a function that "
Reid Spencer68a24bd2005-08-27 18:50:39 +00005287 "expects arguments!");
5288
Reid Spencer3822ff52006-11-08 06:47:33 +00005289 (yyval.InstVal) = new CallInst(V, std::vector<Value*>());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005290 } else { // Has arguments?
5291 // Loop through FunctionType's arguments and ensure they are specified
5292 // correctly!
5293 //
5294 FunctionType::param_iterator I = Ty->param_begin();
5295 FunctionType::param_iterator E = Ty->param_end();
Reid Spencera132e042006-12-03 05:46:11 +00005296 std::vector<Value*>::iterator ArgI = (yyvsp[-1].ValueList)->begin(), ArgE = (yyvsp[-1].ValueList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005297
Reid Spencera132e042006-12-03 05:46:11 +00005298 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
5299 if ((*ArgI)->getType() != *I)
5300 GEN_ERROR("Parameter " +(*ArgI)->getName()+ " is not of type '" +
5301 (*I)->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005302
5303 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
Reid Spencer61c83e02006-08-18 08:43:06 +00005304 GEN_ERROR("Invalid number of parameters detected!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005305
Reid Spencera132e042006-12-03 05:46:11 +00005306 (yyval.InstVal) = new CallInst(V, *(yyvsp[-1].ValueList));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005307 }
Reid Spencer3822ff52006-11-08 06:47:33 +00005308 cast<CallInst>((yyval.InstVal))->setTailCall((yyvsp[-6].BoolVal));
5309 cast<CallInst>((yyval.InstVal))->setCallingConv((yyvsp[-5].UIntVal));
Reid Spencera132e042006-12-03 05:46:11 +00005310 delete (yyvsp[-4].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00005311 delete (yyvsp[-1].ValueList);
Reid Spencer61c83e02006-08-18 08:43:06 +00005312 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005313 ;}
5314 break;
5315
Reid Spencera132e042006-12-03 05:46:11 +00005316 case 285:
5317#line 2702 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005318 {
5319 (yyval.InstVal) = (yyvsp[0].InstVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005320 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005321 ;}
5322 break;
5323
Reid Spencera132e042006-12-03 05:46:11 +00005324 case 286:
5325#line 2709 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005326 {
5327 (yyval.ValueList) = (yyvsp[0].ValueList);
Reid Spencer61c83e02006-08-18 08:43:06 +00005328 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005329 ;}
5330 break;
5331
Reid Spencera132e042006-12-03 05:46:11 +00005332 case 287:
5333#line 2712 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005334 {
Reid Spencera132e042006-12-03 05:46:11 +00005335 (yyval.ValueList) = new std::vector<Value*>();
Reid Spencer61c83e02006-08-18 08:43:06 +00005336 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005337 ;}
5338 break;
5339
Reid Spencera132e042006-12-03 05:46:11 +00005340 case 288:
5341#line 2717 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005342 {
5343 (yyval.BoolVal) = true;
Reid Spencer61c83e02006-08-18 08:43:06 +00005344 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005345 ;}
5346 break;
5347
Reid Spencera132e042006-12-03 05:46:11 +00005348 case 289:
5349#line 2721 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005350 {
5351 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00005352 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005353 ;}
5354 break;
5355
Reid Spencera132e042006-12-03 05:46:11 +00005356 case 290:
5357#line 2728 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005358 {
Reid Spencera132e042006-12-03 05:46:11 +00005359 (yyval.InstVal) = new MallocInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
5360 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005361 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005362 ;}
5363 break;
5364
Reid Spencera132e042006-12-03 05:46:11 +00005365 case 291:
5366#line 2733 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005367 {
Reid Spencera132e042006-12-03 05:46:11 +00005368 Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005369 CHECK_FOR_ERROR
Reid Spencera132e042006-12-03 05:46:11 +00005370 (yyval.InstVal) = new MallocInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal));
5371 delete (yyvsp[-4].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00005372 ;}
5373 break;
5374
Reid Spencera132e042006-12-03 05:46:11 +00005375 case 292:
5376#line 2739 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005377 {
Reid Spencera132e042006-12-03 05:46:11 +00005378 (yyval.InstVal) = new AllocaInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
5379 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005380 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005381 ;}
5382 break;
5383
Reid Spencera132e042006-12-03 05:46:11 +00005384 case 293:
5385#line 2744 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005386 {
Reid Spencera132e042006-12-03 05:46:11 +00005387 Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005388 CHECK_FOR_ERROR
Reid Spencera132e042006-12-03 05:46:11 +00005389 (yyval.InstVal) = new AllocaInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal));
5390 delete (yyvsp[-4].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00005391 ;}
5392 break;
5393
Reid Spencera132e042006-12-03 05:46:11 +00005394 case 294:
5395#line 2750 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005396 {
Reid Spencera132e042006-12-03 05:46:11 +00005397 if (!isa<PointerType>((yyvsp[0].ValueVal)->getType()))
Reid Spencer61c83e02006-08-18 08:43:06 +00005398 GEN_ERROR("Trying to free nonpointer type " +
Reid Spencera132e042006-12-03 05:46:11 +00005399 (yyvsp[0].ValueVal)->getType()->getDescription() + "!");
5400 (yyval.InstVal) = new FreeInst((yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005401 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005402 ;}
5403 break;
5404
Reid Spencera132e042006-12-03 05:46:11 +00005405 case 295:
5406#line 2758 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005407 {
Reid Spencera132e042006-12-03 05:46:11 +00005408 if (!isa<PointerType>((yyvsp[-1].TypeVal)->get()))
Reid Spencer61c83e02006-08-18 08:43:06 +00005409 GEN_ERROR("Can't load from nonpointer type: " +
Reid Spencera132e042006-12-03 05:46:11 +00005410 (*(yyvsp[-1].TypeVal))->getDescription());
5411 if (!cast<PointerType>((yyvsp[-1].TypeVal)->get())->getElementType()->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00005412 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Reid Spencera132e042006-12-03 05:46:11 +00005413 (*(yyvsp[-1].TypeVal))->getDescription());
5414 Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005415 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005416 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal));
Reid Spencera132e042006-12-03 05:46:11 +00005417 delete (yyvsp[-1].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00005418 ;}
5419 break;
5420
Reid Spencera132e042006-12-03 05:46:11 +00005421 case 296:
5422#line 2770 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005423 {
Reid Spencera132e042006-12-03 05:46:11 +00005424 const PointerType *PT = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005425 if (!PT)
Reid Spencer61c83e02006-08-18 08:43:06 +00005426 GEN_ERROR("Can't store to a nonpointer type: " +
Reid Spencera132e042006-12-03 05:46:11 +00005427 (*(yyvsp[-1].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005428 const Type *ElTy = PT->getElementType();
Reid Spencera132e042006-12-03 05:46:11 +00005429 if (ElTy != (yyvsp[-3].ValueVal)->getType())
5430 GEN_ERROR("Can't store '" + (yyvsp[-3].ValueVal)->getType()->getDescription() +
Reid Spencer68a24bd2005-08-27 18:50:39 +00005431 "' into space of type '" + ElTy->getDescription() + "'!");
5432
Reid Spencera132e042006-12-03 05:46:11 +00005433 Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005434 CHECK_FOR_ERROR
Reid Spencera132e042006-12-03 05:46:11 +00005435 (yyval.InstVal) = new StoreInst((yyvsp[-3].ValueVal), tmpVal, (yyvsp[-5].BoolVal));
5436 delete (yyvsp[-1].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00005437 ;}
5438 break;
5439
Reid Spencera132e042006-12-03 05:46:11 +00005440 case 297:
5441#line 2785 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005442 {
Reid Spencera132e042006-12-03 05:46:11 +00005443 if (!isa<PointerType>((yyvsp[-2].TypeVal)->get()))
Reid Spencer61c83e02006-08-18 08:43:06 +00005444 GEN_ERROR("getelementptr insn requires pointer operand!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005445
Reid Spencera132e042006-12-03 05:46:11 +00005446 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
5447 // indices to uint struct indices for compatibility.
5448 generic_gep_type_iterator<std::vector<Value*>::iterator>
5449 GTI = gep_type_begin((yyvsp[-2].TypeVal)->get(), (yyvsp[0].ValueList)->begin(), (yyvsp[0].ValueList)->end()),
5450 GTE = gep_type_end((yyvsp[-2].TypeVal)->get(), (yyvsp[0].ValueList)->begin(), (yyvsp[0].ValueList)->end());
5451 for (unsigned i = 0, e = (yyvsp[0].ValueList)->size(); i != e && GTI != GTE; ++i, ++GTI)
5452 if (isa<StructType>(*GTI)) // Only change struct indices
5453 if (ConstantInt *CUI = dyn_cast<ConstantInt>((*(yyvsp[0].ValueList))[i]))
5454 if (CUI->getType() == Type::UByteTy)
5455 (*(yyvsp[0].ValueList))[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005456
Reid Spencera132e042006-12-03 05:46:11 +00005457 if (!GetElementPtrInst::getIndexedType(*(yyvsp[-2].TypeVal), *(yyvsp[0].ValueList), true))
Reid Spencer61c83e02006-08-18 08:43:06 +00005458 GEN_ERROR("Invalid getelementptr indices for type '" +
Reid Spencera132e042006-12-03 05:46:11 +00005459 (*(yyvsp[-2].TypeVal))->getDescription()+ "'!");
5460 Value* tmpVal = getVal(*(yyvsp[-2].TypeVal), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005461 CHECK_FOR_ERROR
Reid Spencera132e042006-12-03 05:46:11 +00005462 (yyval.InstVal) = new GetElementPtrInst(tmpVal, *(yyvsp[0].ValueList));
5463 delete (yyvsp[-2].TypeVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00005464 delete (yyvsp[0].ValueList);
5465 ;}
5466 break;
5467
5468
5469 default: break;
5470 }
5471
5472/* Line 1126 of yacc.c. */
Reid Spencera132e042006-12-03 05:46:11 +00005473#line 5474 "llvmAsmParser.tab.c"
Reid Spencer5b7e7532006-09-28 19:28:24 +00005474
5475 yyvsp -= yylen;
5476 yyssp -= yylen;
5477
Reid Spencer3822ff52006-11-08 06:47:33 +00005478
5479 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005480
5481 *++yyvsp = yyval;
5482
5483
Reid Spencer3822ff52006-11-08 06:47:33 +00005484 /* Now `shift' the result of the reduction. Determine what state
5485 that goes to, based on the state we popped back to and the rule
5486 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005487
5488 yyn = yyr1[yyn];
5489
Reid Spencer3822ff52006-11-08 06:47:33 +00005490 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
5491 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005492 yystate = yytable[yystate];
5493 else
Reid Spencer3822ff52006-11-08 06:47:33 +00005494 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00005495
5496 goto yynewstate;
5497
5498
Reid Spencer3822ff52006-11-08 06:47:33 +00005499/*------------------------------------.
5500| yyerrlab -- here on detecting error |
5501`------------------------------------*/
5502yyerrlab:
5503 /* If not already recovering from an error, report this error. */
5504 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005505 {
5506 ++yynerrs;
Reid Spencer3822ff52006-11-08 06:47:33 +00005507#if YYERROR_VERBOSE
Reid Spencer5b7e7532006-09-28 19:28:24 +00005508 yyn = yypact[yystate];
Chris Lattner224f84f2006-08-18 17:34:45 +00005509
Reid Spencer3822ff52006-11-08 06:47:33 +00005510 if (YYPACT_NINF < yyn && yyn < YYLAST)
Reid Spencer5b7e7532006-09-28 19:28:24 +00005511 {
Reid Spencer3822ff52006-11-08 06:47:33 +00005512 int yytype = YYTRANSLATE (yychar);
5513 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
5514 YYSIZE_T yysize = yysize0;
5515 YYSIZE_T yysize1;
5516 int yysize_overflow = 0;
5517 char *yymsg = 0;
5518# define YYERROR_VERBOSE_ARGS_MAXIMUM 5
5519 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
5520 int yyx;
Reid Spencer5b7e7532006-09-28 19:28:24 +00005521
Reid Spencer3822ff52006-11-08 06:47:33 +00005522#if 0
5523 /* This is so xgettext sees the translatable formats that are
5524 constructed on the fly. */
5525 YY_("syntax error, unexpected %s");
5526 YY_("syntax error, unexpected %s, expecting %s");
5527 YY_("syntax error, unexpected %s, expecting %s or %s");
5528 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
5529 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
5530#endif
5531 char *yyfmt;
5532 char const *yyf;
5533 static char const yyunexpected[] = "syntax error, unexpected %s";
5534 static char const yyexpecting[] = ", expecting %s";
5535 static char const yyor[] = " or %s";
5536 char yyformat[sizeof yyunexpected
5537 + sizeof yyexpecting - 1
5538 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
5539 * (sizeof yyor - 1))];
5540 char const *yyprefix = yyexpecting;
5541
5542 /* Start YYX at -YYN if negative to avoid negative indexes in
5543 YYCHECK. */
5544 int yyxbegin = yyn < 0 ? -yyn : 0;
5545
5546 /* Stay within bounds of both yycheck and yytname. */
5547 int yychecklim = YYLAST - yyn;
5548 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
5549 int yycount = 1;
5550
5551 yyarg[0] = yytname[yytype];
5552 yyfmt = yystpcpy (yyformat, yyunexpected);
5553
5554 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
5555 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
5556 {
5557 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
5558 {
5559 yycount = 1;
5560 yysize = yysize0;
5561 yyformat[sizeof yyunexpected - 1] = '\0';
5562 break;
5563 }
5564 yyarg[yycount++] = yytname[yyx];
5565 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
5566 yysize_overflow |= yysize1 < yysize;
5567 yysize = yysize1;
5568 yyfmt = yystpcpy (yyfmt, yyprefix);
5569 yyprefix = yyor;
5570 }
5571
5572 yyf = YY_(yyformat);
5573 yysize1 = yysize + yystrlen (yyf);
5574 yysize_overflow |= yysize1 < yysize;
5575 yysize = yysize1;
5576
5577 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
5578 yymsg = (char *) YYSTACK_ALLOC (yysize);
5579 if (yymsg)
Reid Spencer5b7e7532006-09-28 19:28:24 +00005580 {
Reid Spencer3822ff52006-11-08 06:47:33 +00005581 /* Avoid sprintf, as that infringes on the user's name space.
5582 Don't have undefined behavior even if the translation
5583 produced a string with the wrong number of "%s"s. */
5584 char *yyp = yymsg;
5585 int yyi = 0;
5586 while ((*yyp = *yyf))
Reid Spencer5b7e7532006-09-28 19:28:24 +00005587 {
Reid Spencer3822ff52006-11-08 06:47:33 +00005588 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
5589 {
5590 yyp += yytnamerr (yyp, yyarg[yyi++]);
5591 yyf += 2;
5592 }
5593 else
5594 {
5595 yyp++;
5596 yyf++;
5597 }
Reid Spencer5b7e7532006-09-28 19:28:24 +00005598 }
Reid Spencer3822ff52006-11-08 06:47:33 +00005599 yyerror (yymsg);
5600 YYSTACK_FREE (yymsg);
Reid Spencer5b7e7532006-09-28 19:28:24 +00005601 }
5602 else
Reid Spencer3822ff52006-11-08 06:47:33 +00005603 {
5604 yyerror (YY_("syntax error"));
5605 goto yyexhaustedlab;
5606 }
Reid Spencer5b7e7532006-09-28 19:28:24 +00005607 }
5608 else
5609#endif /* YYERROR_VERBOSE */
Reid Spencer3822ff52006-11-08 06:47:33 +00005610 yyerror (YY_("syntax error"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005611 }
5612
Reid Spencer3822ff52006-11-08 06:47:33 +00005613
Reid Spencer68a24bd2005-08-27 18:50:39 +00005614
5615 if (yyerrstatus == 3)
5616 {
Reid Spencer3822ff52006-11-08 06:47:33 +00005617 /* If just tried and failed to reuse look-ahead token after an
5618 error, discard it. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005619
Reid Spencer3822ff52006-11-08 06:47:33 +00005620 if (yychar <= YYEOF)
5621 {
5622 /* Return failure if at end of input. */
5623 if (yychar == YYEOF)
5624 YYABORT;
5625 }
5626 else
5627 {
5628 yydestruct ("Error: discarding", yytoken, &yylval);
5629 yychar = YYEMPTY;
5630 }
5631 }
5632
5633 /* Else will try to reuse look-ahead token after shifting the error
5634 token. */
5635 goto yyerrlab1;
5636
5637
5638/*---------------------------------------------------.
5639| yyerrorlab -- error raised explicitly by YYERROR. |
5640`---------------------------------------------------*/
5641yyerrorlab:
5642
5643 /* Pacify compilers like GCC when the user code never invokes
5644 YYERROR and the label yyerrorlab therefore never appears in user
5645 code. */
5646 if (0)
5647 goto yyerrorlab;
5648
5649yyvsp -= yylen;
5650 yyssp -= yylen;
5651 yystate = *yyssp;
5652 goto yyerrlab1;
5653
5654
5655/*-------------------------------------------------------------.
5656| yyerrlab1 -- common code for both syntax error and YYERROR. |
5657`-------------------------------------------------------------*/
5658yyerrlab1:
5659 yyerrstatus = 3; /* Each real token shifted decrements this. */
5660
5661 for (;;)
5662 {
5663 yyn = yypact[yystate];
5664 if (yyn != YYPACT_NINF)
5665 {
5666 yyn += YYTERROR;
5667 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
5668 {
5669 yyn = yytable[yyn];
5670 if (0 < yyn)
5671 break;
5672 }
5673 }
5674
5675 /* Pop the current state because it cannot handle the error token. */
5676 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005677 YYABORT;
5678
Chris Lattner8335e842006-01-23 23:05:42 +00005679
Reid Spencer3822ff52006-11-08 06:47:33 +00005680 yydestruct ("Error: popping", yystos[yystate], yyvsp);
5681 YYPOPSTACK;
5682 yystate = *yyssp;
5683 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005684 }
5685
5686 if (yyn == YYFINAL)
5687 YYACCEPT;
5688
Reid Spencer68a24bd2005-08-27 18:50:39 +00005689 *++yyvsp = yylval;
Reid Spencer3822ff52006-11-08 06:47:33 +00005690
5691
5692 /* Shift the error token. */
5693 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005694
5695 yystate = yyn;
5696 goto yynewstate;
5697
Chris Lattnerf49c1762006-11-08 05:58:47 +00005698
Reid Spencer3822ff52006-11-08 06:47:33 +00005699/*-------------------------------------.
5700| yyacceptlab -- YYACCEPT comes here. |
5701`-------------------------------------*/
5702yyacceptlab:
5703 yyresult = 0;
5704 goto yyreturn;
5705
5706/*-----------------------------------.
5707| yyabortlab -- YYABORT comes here. |
5708`-----------------------------------*/
5709yyabortlab:
5710 yyresult = 1;
5711 goto yyreturn;
5712
5713#ifndef yyoverflow
5714/*-------------------------------------------------.
5715| yyexhaustedlab -- memory exhaustion comes here. |
5716`-------------------------------------------------*/
5717yyexhaustedlab:
5718 yyerror (YY_("memory exhausted"));
5719 yyresult = 2;
5720 /* Fall through. */
Chris Lattnerf49c1762006-11-08 05:58:47 +00005721#endif
Reid Spencer3822ff52006-11-08 06:47:33 +00005722
5723yyreturn:
5724 if (yychar != YYEOF && yychar != YYEMPTY)
5725 yydestruct ("Cleanup: discarding lookahead",
5726 yytoken, &yylval);
5727 while (yyssp != yyss)
5728 {
5729 yydestruct ("Cleanup: popping",
5730 yystos[*yyssp], yyvsp);
5731 YYPOPSTACK;
Chris Lattnerf49c1762006-11-08 05:58:47 +00005732 }
Reid Spencer3822ff52006-11-08 06:47:33 +00005733#ifndef yyoverflow
5734 if (yyss != yyssa)
5735 YYSTACK_FREE (yyss);
5736#endif
5737 return yyresult;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005738}
Reid Spencer3822ff52006-11-08 06:47:33 +00005739
5740
Reid Spencera132e042006-12-03 05:46:11 +00005741#line 2811 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00005742
5743
5744void llvm::GenerateError(const std::string &message, int LineNo) {
5745 if (LineNo == -1) LineNo = llvmAsmlineno;
5746 // TODO: column number in exception
5747 if (TheParseError)
5748 TheParseError->setError(CurFilename, message, LineNo);
5749 TriggerError = 1;
5750}
Reid Spencer68a24bd2005-08-27 18:50:39 +00005751
5752int yyerror(const char *ErrorMsg) {
5753 std::string where
5754 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
5755 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
5756 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
5757 if (yychar == YYEMPTY || yychar == 0)
5758 errMsg += "end-of-file.";
5759 else
5760 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
Reid Spencer61c83e02006-08-18 08:43:06 +00005761 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005762 return 0;
5763}
Reid Spencer3822ff52006-11-08 06:47:33 +00005764