blob: 361027cf4b572cd58197fbe4c2b98e57b0761338 [file] [log] [blame]
Reid Spencer38c91a92007-02-28 02:24:54 +00001/* A Bison parser, made by GNU Bison 2.1. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002
Reid Spencer38c91a92007-02-28 02:24:54 +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.
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00005
Reid Spencer38c91a92007-02-28 02:24:54 +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 Korobeynikov178a3522007-01-12 19:22:51 +000010
Reid Spencer38c91a92007-02-28 02:24:54 +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 Spencer38c91a92007-02-28 02:24:54 +000053#define yylex llvmAsmlex
Reid Spencer68a24bd2005-08-27 18:50:39 +000054#define yyerror llvmAsmerror
Reid Spencer38c91a92007-02-28 02:24:54 +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 Spencer38c91a92007-02-28 02:24:54 +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 ESAPINTVAL = 260,
70 EUAPINTVAL = 261,
71 LOCALVAL_ID = 262,
72 GLOBALVAL_ID = 263,
73 FPVAL = 264,
74 VOID = 265,
75 INTTYPE = 266,
76 FLOAT = 267,
77 DOUBLE = 268,
78 LABEL = 269,
79 TYPE = 270,
80 LOCALVAR = 271,
81 GLOBALVAR = 272,
82 LABELSTR = 273,
83 STRINGCONSTANT = 274,
84 ATSTRINGCONSTANT = 275,
85 IMPLEMENTATION = 276,
86 ZEROINITIALIZER = 277,
87 TRUETOK = 278,
88 FALSETOK = 279,
89 BEGINTOK = 280,
90 ENDTOK = 281,
91 DECLARE = 282,
92 DEFINE = 283,
93 GLOBAL = 284,
94 CONSTANT = 285,
95 SECTION = 286,
96 VOLATILE = 287,
97 TO = 288,
98 DOTDOTDOT = 289,
99 NULL_TOK = 290,
100 UNDEF = 291,
101 INTERNAL = 292,
102 LINKONCE = 293,
103 WEAK = 294,
104 APPENDING = 295,
105 DLLIMPORT = 296,
106 DLLEXPORT = 297,
107 EXTERN_WEAK = 298,
108 OPAQUE = 299,
109 EXTERNAL = 300,
110 TARGET = 301,
111 TRIPLE = 302,
112 ALIGN = 303,
113 DEPLIBS = 304,
114 CALL = 305,
115 TAIL = 306,
116 ASM_TOK = 307,
117 MODULE = 308,
118 SIDEEFFECT = 309,
119 CC_TOK = 310,
120 CCC_TOK = 311,
121 FASTCC_TOK = 312,
122 COLDCC_TOK = 313,
123 X86_STDCALLCC_TOK = 314,
124 X86_FASTCALLCC_TOK = 315,
125 DATALAYOUT = 316,
126 RET = 317,
127 BR = 318,
128 SWITCH = 319,
129 INVOKE = 320,
130 UNWIND = 321,
131 UNREACHABLE = 322,
132 ADD = 323,
133 SUB = 324,
134 MUL = 325,
135 UDIV = 326,
136 SDIV = 327,
137 FDIV = 328,
138 UREM = 329,
139 SREM = 330,
140 FREM = 331,
141 AND = 332,
142 OR = 333,
143 XOR = 334,
144 SHL = 335,
145 LSHR = 336,
146 ASHR = 337,
147 ICMP = 338,
148 FCMP = 339,
149 EQ = 340,
150 NE = 341,
151 SLT = 342,
152 SGT = 343,
153 SLE = 344,
154 SGE = 345,
155 ULT = 346,
156 UGT = 347,
157 ULE = 348,
158 UGE = 349,
159 OEQ = 350,
160 ONE = 351,
161 OLT = 352,
162 OGT = 353,
163 OLE = 354,
164 OGE = 355,
165 ORD = 356,
166 UNO = 357,
167 UEQ = 358,
168 UNE = 359,
169 MALLOC = 360,
170 ALLOCA = 361,
171 FREE = 362,
172 LOAD = 363,
173 STORE = 364,
174 GETELEMENTPTR = 365,
175 TRUNC = 366,
176 ZEXT = 367,
177 SEXT = 368,
178 FPTRUNC = 369,
179 FPEXT = 370,
180 BITCAST = 371,
181 UITOFP = 372,
182 SITOFP = 373,
183 FPTOUI = 374,
184 FPTOSI = 375,
185 INTTOPTR = 376,
186 PTRTOINT = 377,
187 PHI_TOK = 378,
188 SELECT = 379,
189 VAARG = 380,
190 EXTRACTELEMENT = 381,
191 INSERTELEMENT = 382,
192 SHUFFLEVECTOR = 383,
193 NORETURN = 384,
194 INREG = 385,
195 SRET = 386,
196 DEFAULT = 387,
197 HIDDEN = 388
198 };
199#endif
200/* Tokens. */
201#define ESINT64VAL 258
202#define EUINT64VAL 259
203#define ESAPINTVAL 260
204#define EUAPINTVAL 261
205#define LOCALVAL_ID 262
206#define GLOBALVAL_ID 263
207#define FPVAL 264
208#define VOID 265
209#define INTTYPE 266
210#define FLOAT 267
211#define DOUBLE 268
212#define LABEL 269
213#define TYPE 270
214#define LOCALVAR 271
215#define GLOBALVAR 272
216#define LABELSTR 273
217#define STRINGCONSTANT 274
218#define ATSTRINGCONSTANT 275
219#define IMPLEMENTATION 276
220#define ZEROINITIALIZER 277
221#define TRUETOK 278
222#define FALSETOK 279
223#define BEGINTOK 280
224#define ENDTOK 281
225#define DECLARE 282
226#define DEFINE 283
227#define GLOBAL 284
228#define CONSTANT 285
229#define SECTION 286
230#define VOLATILE 287
231#define TO 288
232#define DOTDOTDOT 289
233#define NULL_TOK 290
234#define UNDEF 291
235#define INTERNAL 292
236#define LINKONCE 293
237#define WEAK 294
238#define APPENDING 295
239#define DLLIMPORT 296
240#define DLLEXPORT 297
241#define EXTERN_WEAK 298
242#define OPAQUE 299
243#define EXTERNAL 300
244#define TARGET 301
245#define TRIPLE 302
246#define ALIGN 303
247#define DEPLIBS 304
248#define CALL 305
249#define TAIL 306
250#define ASM_TOK 307
251#define MODULE 308
252#define SIDEEFFECT 309
253#define CC_TOK 310
254#define CCC_TOK 311
255#define FASTCC_TOK 312
256#define COLDCC_TOK 313
257#define X86_STDCALLCC_TOK 314
258#define X86_FASTCALLCC_TOK 315
259#define DATALAYOUT 316
260#define RET 317
261#define BR 318
262#define SWITCH 319
263#define INVOKE 320
264#define UNWIND 321
265#define UNREACHABLE 322
266#define ADD 323
267#define SUB 324
268#define MUL 325
269#define UDIV 326
270#define SDIV 327
271#define FDIV 328
272#define UREM 329
273#define SREM 330
274#define FREM 331
275#define AND 332
276#define OR 333
277#define XOR 334
278#define SHL 335
279#define LSHR 336
280#define ASHR 337
281#define ICMP 338
282#define FCMP 339
283#define EQ 340
284#define NE 341
285#define SLT 342
286#define SGT 343
287#define SLE 344
288#define SGE 345
289#define ULT 346
290#define UGT 347
291#define ULE 348
292#define UGE 349
293#define OEQ 350
294#define ONE 351
295#define OLT 352
296#define OGT 353
297#define OLE 354
298#define OGE 355
299#define ORD 356
300#define UNO 357
301#define UEQ 358
302#define UNE 359
303#define MALLOC 360
304#define ALLOCA 361
305#define FREE 362
306#define LOAD 363
307#define STORE 364
308#define GETELEMENTPTR 365
309#define TRUNC 366
310#define ZEXT 367
311#define SEXT 368
312#define FPTRUNC 369
313#define FPEXT 370
314#define BITCAST 371
315#define UITOFP 372
316#define SITOFP 373
317#define FPTOUI 374
318#define FPTOSI 375
319#define INTTOPTR 376
320#define PTRTOINT 377
321#define PHI_TOK 378
322#define SELECT 379
323#define VAARG 380
324#define EXTRACTELEMENT 381
325#define INSERTELEMENT 382
326#define SHUFFLEVECTOR 383
327#define NORETURN 384
328#define INREG 385
329#define SRET 386
330#define DEFAULT 387
331#define HIDDEN 388
332
333
334
335
336/* Copy the first part of user declarations. */
337#line 14 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000338
339#include "ParserInternals.h"
340#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000341#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000342#include "llvm/Instructions.h"
343#include "llvm/Module.h"
Reid Spenceref9b9a72007-02-05 20:47:22 +0000344#include "llvm/ValueSymbolTable.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000345#include "llvm/Support/GetElementPtrTypeIterator.h"
Reid Spencer14310612006-12-31 05:40:51 +0000346#include "llvm/Support/CommandLine.h"
Chris Lattnerf7469af2007-01-31 04:44:08 +0000347#include "llvm/ADT/SmallVector.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000348#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000349#include "llvm/Support/MathExtras.h"
Reid Spencer481169e2006-12-01 00:33:46 +0000350#include "llvm/Support/Streams.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000351#include <algorithm>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000352#include <list>
Chris Lattner8adde282007-02-11 21:40:10 +0000353#include <map>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000354#include <utility>
Reid Spencer14310612006-12-31 05:40:51 +0000355#ifndef NDEBUG
356#define YYDEBUG 1
357#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000358
Reid Spencere4f47592006-08-18 17:32:55 +0000359// The following is a gross hack. In order to rid the libAsmParser library of
360// exceptions, we have to have a way of getting the yyparse function to go into
361// an error situation. So, whenever we want an error to occur, the GenerateError
362// function (see bottom of file) sets TriggerError. Then, at the end of each
363// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
364// (a goto) to put YACC in error state. Furthermore, several calls to
365// GenerateError are made from inside productions and they must simulate the
366// previous exception behavior by exiting the production immediately. We have
367// replaced these with the GEN_ERROR macro which calls GeneratError and then
368// immediately invokes YYERROR. This would be so much cleaner if it was a
369// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000370static bool TriggerError = false;
Reid Spencerf63697d2006-10-09 17:36:59 +0000371#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000372#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
373
Reid Spencer68a24bd2005-08-27 18:50:39 +0000374int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
375int yylex(); // declaration" of xxx warnings.
376int yyparse();
377
378namespace llvm {
379 std::string CurFilename;
Reid Spencer14310612006-12-31 05:40:51 +0000380#if YYDEBUG
381static cl::opt<bool>
382Debug("debug-yacc", cl::desc("Print yacc debug state changes"),
383 cl::Hidden, cl::init(false));
384#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000385}
386using namespace llvm;
387
388static Module *ParserResult;
389
390// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
391// relating to upreferences in the input stream.
392//
393//#define DEBUG_UPREFS 1
394#ifdef DEBUG_UPREFS
Bill Wendlinge8156192006-12-07 01:30:32 +0000395#define UR_OUT(X) cerr << X
Reid Spencer68a24bd2005-08-27 18:50:39 +0000396#else
397#define UR_OUT(X)
398#endif
399
400#define YYERROR_VERBOSE 1
401
Chris Lattnerb475c422005-11-12 18:22:38 +0000402static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000403
404
405// This contains info used when building the body of a function. It is
406// destroyed when the function is completed.
407//
408typedef std::vector<Value *> ValueList; // Numbered defs
Reid Spencer14310612006-12-31 05:40:51 +0000409
Reid Spencer68a24bd2005-08-27 18:50:39 +0000410static void
Reid Spencer93c40032007-03-19 18:40:50 +0000411ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000412
413static struct PerModuleInfo {
414 Module *CurrentModule;
Reid Spencer93c40032007-03-19 18:40:50 +0000415 ValueList Values; // Module level numbered definitions
416 ValueList LateResolveValues;
Reid Spencer861d9d62006-11-28 07:29:44 +0000417 std::vector<PATypeHolder> Types;
418 std::map<ValID, PATypeHolder> LateResolveTypes;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000419
420 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000421 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000422 /// that we can resolve them later and print error messages as appropriate.
423 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
424
425 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
426 // references to global values. Global values may be referenced before they
427 // are defined, and if so, the temporary object that they represent is held
428 // here. This is used for forward references of GlobalValues.
429 //
430 typedef std::map<std::pair<const PointerType *,
431 ValID>, GlobalValue*> GlobalRefsType;
432 GlobalRefsType GlobalRefs;
433
434 void ModuleDone() {
435 // If we could not resolve some functions at function compilation time
436 // (calls to functions before they are defined), resolve them now... Types
437 // are resolved when the constant pool has been completely parsed.
438 //
439 ResolveDefinitions(LateResolveValues);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000440 if (TriggerError)
441 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000442
443 // Check to make sure that all global value forward references have been
444 // resolved!
445 //
446 if (!GlobalRefs.empty()) {
447 std::string UndefinedReferences = "Unresolved global references exist:\n";
448
449 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
450 I != E; ++I) {
451 UndefinedReferences += " " + I->first.first->getDescription() + " " +
452 I->first.second.getName() + "\n";
453 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000454 GenerateError(UndefinedReferences);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000455 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000456 }
457
458 Values.clear(); // Clear out function local definitions
459 Types.clear();
460 CurrentModule = 0;
461 }
462
Reid Spencer68a24bd2005-08-27 18:50:39 +0000463 // GetForwardRefForGlobal - Check to see if there is a forward reference
464 // for this global. If so, remove it from the GlobalRefs map and return it.
465 // If not, just return null.
466 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
467 // Check to see if there is a forward reference to this global variable...
468 // if there is, eliminate it and patch the reference to use the new def'n.
469 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
470 GlobalValue *Ret = 0;
471 if (I != GlobalRefs.end()) {
472 Ret = I->second;
473 GlobalRefs.erase(I);
474 }
475 return Ret;
476 }
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000477
478 bool TypeIsUnresolved(PATypeHolder* PATy) {
479 // If it isn't abstract, its resolved
480 const Type* Ty = PATy->get();
481 if (!Ty->isAbstract())
482 return false;
483 // Traverse the type looking for abstract types. If it isn't abstract then
484 // we don't need to traverse that leg of the type.
485 std::vector<const Type*> WorkList, SeenList;
486 WorkList.push_back(Ty);
487 while (!WorkList.empty()) {
488 const Type* Ty = WorkList.back();
489 SeenList.push_back(Ty);
490 WorkList.pop_back();
491 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
492 // Check to see if this is an unresolved type
493 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
494 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
495 for ( ; I != E; ++I) {
496 if (I->second.get() == OpTy)
497 return true;
498 }
499 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
500 const Type* TheTy = SeqTy->getElementType();
501 if (TheTy->isAbstract() && TheTy != Ty) {
502 std::vector<const Type*>::iterator I = SeenList.begin(),
503 E = SeenList.end();
504 for ( ; I != E; ++I)
505 if (*I == TheTy)
506 break;
507 if (I == E)
508 WorkList.push_back(TheTy);
509 }
510 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
511 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
512 const Type* TheTy = StrTy->getElementType(i);
513 if (TheTy->isAbstract() && TheTy != Ty) {
514 std::vector<const Type*>::iterator I = SeenList.begin(),
515 E = SeenList.end();
516 for ( ; I != E; ++I)
517 if (*I == TheTy)
518 break;
519 if (I == E)
520 WorkList.push_back(TheTy);
521 }
522 }
523 }
524 }
525 return false;
526 }
527
528
Reid Spencer68a24bd2005-08-27 18:50:39 +0000529} CurModule;
530
531static struct PerFunctionInfo {
532 Function *CurrentFunction; // Pointer to current function being created
533
Reid Spencer93c40032007-03-19 18:40:50 +0000534 ValueList Values; // Keep track of #'d definitions
535 unsigned NextValNum;
536 ValueList LateResolveValues;
Reid Spenceref9b9a72007-02-05 20:47:22 +0000537 bool isDeclare; // Is this function a forward declararation?
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000538 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000539 GlobalValue::VisibilityTypes Visibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000540
541 /// BBForwardRefs - When we see forward references to basic blocks, keep
542 /// track of them here.
Reid Spencer93c40032007-03-19 18:40:50 +0000543 std::map<ValID, BasicBlock*> BBForwardRefs;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000544
545 inline PerFunctionInfo() {
546 CurrentFunction = 0;
547 isDeclare = false;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000548 Linkage = GlobalValue::ExternalLinkage;
549 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000550 }
551
552 inline void FunctionStart(Function *M) {
553 CurrentFunction = M;
Reid Spencer93c40032007-03-19 18:40:50 +0000554 NextValNum = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000555 }
556
557 void FunctionDone() {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000558 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000559 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000560 GenerateError("Undefined reference to label " +
Reid Spencer93c40032007-03-19 18:40:50 +0000561 BBForwardRefs.begin()->second->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000562 return;
563 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000564
565 // Resolve all forward references now.
566 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
567
568 Values.clear(); // Clear out function local definitions
Reid Spencer93c40032007-03-19 18:40:50 +0000569 BBForwardRefs.clear();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000570 CurrentFunction = 0;
571 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000572 Linkage = GlobalValue::ExternalLinkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000573 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000574 }
575} CurFun; // Info for the current function...
576
577static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
578
579
580//===----------------------------------------------------------------------===//
581// Code to handle definitions of all the types
582//===----------------------------------------------------------------------===//
583
Reid Spencer93c40032007-03-19 18:40:50 +0000584static void InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) {
585 // Things that have names or are void typed don't get slot numbers
586 if (V->hasName() || (V->getType() == Type::VoidTy))
587 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000588
Reid Spencer93c40032007-03-19 18:40:50 +0000589 // In the case of function values, we have to allow for the forward reference
590 // of basic blocks, which are included in the numbering. Consequently, we keep
591 // track of the next insertion location with NextValNum. When a BB gets
592 // inserted, it could change the size of the CurFun.Values vector.
593 if (&ValueTab == &CurFun.Values) {
594 if (ValueTab.size() <= CurFun.NextValNum)
595 ValueTab.resize(CurFun.NextValNum+1);
596 ValueTab[CurFun.NextValNum++] = V;
597 return;
598 }
599 // For all other lists, its okay to just tack it on the back of the vector.
600 ValueTab.push_back(V);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000601}
602
603static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
604 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000605 case ValID::LocalID: // Is it a numbered definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000606 // Module constants occupy the lowest numbered slots...
Reid Spencer41dff5e2007-01-26 08:05:27 +0000607 if (D.Num < CurModule.Types.size())
608 return CurModule.Types[D.Num];
Reid Spencer68a24bd2005-08-27 18:50:39 +0000609 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000610 case ValID::LocalName: // Is it a named definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000611 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
612 D.destroy(); // Free old strdup'd memory...
613 return N;
614 }
615 break;
616 default:
Reid Spencerb5334b02007-02-05 10:18:06 +0000617 GenerateError("Internal parser error: Invalid symbol type reference");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000618 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000619 }
620
621 // If we reached here, we referenced either a symbol that we don't know about
622 // or an id number that hasn't been read yet. We may be referencing something
623 // forward, so just create an entry to be resolved later and get to it...
624 //
625 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
626
627
628 if (inFunctionScope()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000629 if (D.Type == ValID::LocalName) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000630 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000631 return 0;
632 } else {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000633 GenerateError("Reference to an undefined type: #" + utostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000634 return 0;
635 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000636 }
637
Reid Spencer861d9d62006-11-28 07:29:44 +0000638 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000639 if (I != CurModule.LateResolveTypes.end())
Reid Spencer861d9d62006-11-28 07:29:44 +0000640 return I->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000641
Reid Spencer861d9d62006-11-28 07:29:44 +0000642 Type *Typ = OpaqueType::get();
643 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
644 return Typ;
Reid Spencera132e042006-12-03 05:46:11 +0000645 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000646
Reid Spencer93c40032007-03-19 18:40:50 +0000647// getExistingVal - Look up the value specified by the provided type and
Reid Spencer68a24bd2005-08-27 18:50:39 +0000648// the provided ValID. If the value exists and has already been defined, return
649// it. Otherwise return null.
650//
Reid Spencer93c40032007-03-19 18:40:50 +0000651static Value *getExistingVal(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000652 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000653 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000654 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000655 return 0;
656 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000657
658 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000659 case ValID::LocalID: { // Is it a numbered definition?
Reid Spencer41dff5e2007-01-26 08:05:27 +0000660 // Check that the number is within bounds.
Reid Spencer93c40032007-03-19 18:40:50 +0000661 if (D.Num >= CurFun.Values.size())
662 return 0;
663 Value *Result = CurFun.Values[D.Num];
664 if (Ty != Result->getType()) {
665 GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" +
666 Result->getType()->getDescription() + "' does not match "
667 "expected type, '" + Ty->getDescription() + "'");
668 return 0;
669 }
670 return Result;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000671 }
672 case ValID::GlobalID: { // Is it a numbered definition?
Reid Spencer93c40032007-03-19 18:40:50 +0000673 if (D.Num >= CurModule.Values.size())
Reid Spenceref9b9a72007-02-05 20:47:22 +0000674 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000675 Value *Result = CurModule.Values[D.Num];
676 if (Ty != Result->getType()) {
677 GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" +
678 Result->getType()->getDescription() + "' does not match "
679 "expected type, '" + Ty->getDescription() + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +0000680 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000681 }
682 return Result;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000683 }
Reid Spencer41dff5e2007-01-26 08:05:27 +0000684
685 case ValID::LocalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000686 if (!inFunctionScope())
687 return 0;
688 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
689 Value *N = SymTab.lookup(D.Name);
690 if (N == 0)
691 return 0;
692 if (N->getType() != Ty)
693 return 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000694
695 D.destroy(); // Free old strdup'd memory...
696 return N;
697 }
698 case ValID::GlobalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000699 ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
700 Value *N = SymTab.lookup(D.Name);
701 if (N == 0)
702 return 0;
703 if (N->getType() != Ty)
704 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000705
706 D.destroy(); // Free old strdup'd memory...
707 return N;
708 }
709
710 // Check to make sure that "Ty" is an integral type, and that our
711 // value will fit into the specified type...
712 case ValID::ConstSIntVal: // Is it a constant pool reference??
Reid Spencerb83eb642006-10-20 07:07:24 +0000713 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000714 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000715 itostr(D.ConstPool64) + "' is invalid for type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000716 Ty->getDescription() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000717 return 0;
718 }
Reid Spencer49d273e2007-03-19 20:40:51 +0000719 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000720
721 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Reid Spencerb83eb642006-10-20 07:07:24 +0000722 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
723 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000724 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
Reid Spencerb5334b02007-02-05 10:18:06 +0000725 "' is invalid or out of range");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000726 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000727 } else { // This is really a signed reference. Transmogrify.
Reid Spencer49d273e2007-03-19 20:40:51 +0000728 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000729 }
730 } else {
Reid Spencerb83eb642006-10-20 07:07:24 +0000731 return ConstantInt::get(Ty, D.UConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000732 }
733
734 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000735 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000736 GenerateError("FP constant invalid for type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000737 return 0;
738 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000739 return ConstantFP::get(Ty, D.ConstPoolFP);
740
741 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000742 if (!isa<PointerType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000743 GenerateError("Cannot create a a non pointer null");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000744 return 0;
745 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000746 return ConstantPointerNull::get(cast<PointerType>(Ty));
747
748 case ValID::ConstUndefVal: // Is it an undef value?
749 return UndefValue::get(Ty);
750
Chris Lattner7aa61892005-12-21 17:53:23 +0000751 case ValID::ConstZeroVal: // Is it a zero value?
752 return Constant::getNullValue(Ty);
753
Reid Spencer68a24bd2005-08-27 18:50:39 +0000754 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000755 if (D.ConstantValue->getType() != Ty) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000756 GenerateError("Constant expression type different from required type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000757 return 0;
758 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000759 return D.ConstantValue;
760
Chris Lattner0e9c3762006-01-25 22:27:16 +0000761 case ValID::InlineAsmVal: { // Inline asm expression
762 const PointerType *PTy = dyn_cast<PointerType>(Ty);
763 const FunctionType *FTy =
764 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000765 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000766 GenerateError("Invalid type for asm constraint string");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000767 return 0;
768 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000769 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
770 D.IAD->HasSideEffects);
771 D.destroy(); // Free InlineAsmDescriptor.
772 return IA;
773 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000774 default:
Reid Spencera9720f52007-02-05 17:04:00 +0000775 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000776 return 0;
777 } // End of switch
778
Reid Spencera9720f52007-02-05 17:04:00 +0000779 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000780 return 0;
781}
782
Reid Spencer93c40032007-03-19 18:40:50 +0000783// getVal - This function is identical to getExistingVal, except that if a
Reid Spencer68a24bd2005-08-27 18:50:39 +0000784// value is not already defined, it "improvises" by creating a placeholder var
785// that looks and acts just like the requested variable. When the value is
786// defined later, all uses of the placeholder variable are replaced with the
787// real thing.
788//
789static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000790 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000791 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000792 return 0;
793 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000794
795 // See if the value has already been defined.
Reid Spencer93c40032007-03-19 18:40:50 +0000796 Value *V = getExistingVal(Ty, ID);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000797 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000798 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000799
Reid Spencer5b7e7532006-09-28 19:28:24 +0000800 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000801 GenerateError("Invalid use of a composite type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000802 return 0;
803 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000804
805 // If we reached here, we referenced either a symbol that we don't know about
806 // or an id number that hasn't been read yet. We may be referencing something
807 // forward, so just create an entry to be resolved later and get to it...
808 //
809 V = new Argument(Ty);
810
811 // Remember where this forward reference came from. FIXME, shouldn't we try
812 // to recycle these things??
813 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
814 llvmAsmlineno)));
815
816 if (inFunctionScope())
817 InsertValue(V, CurFun.LateResolveValues);
818 else
819 InsertValue(V, CurModule.LateResolveValues);
820 return V;
821}
822
Reid Spencer93c40032007-03-19 18:40:50 +0000823/// defineBBVal - This is a definition of a new basic block with the specified
824/// identifier which must be the same as CurFun.NextValNum, if its numeric.
825static BasicBlock *defineBBVal(const ValID &ID) {
Reid Spencera9720f52007-02-05 17:04:00 +0000826 assert(inFunctionScope() && "Can't get basic block at global scope!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000827
Reid Spencer68a24bd2005-08-27 18:50:39 +0000828 BasicBlock *BB = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000829
Reid Spencer93c40032007-03-19 18:40:50 +0000830 // First, see if this was forward referenced
Reid Spencer68a24bd2005-08-27 18:50:39 +0000831
Reid Spencer93c40032007-03-19 18:40:50 +0000832 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
833 if (BBI != CurFun.BBForwardRefs.end()) {
834 BB = BBI->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000835 // The forward declaration could have been inserted anywhere in the
836 // function: insert it into the correct place now.
837 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
838 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
Reid Spencer93c40032007-03-19 18:40:50 +0000839
840 // Erase the forward ref from the map as its no longer "forward"
841 CurFun.BBForwardRefs.erase(ID);
842
843 // If its a numbered definition, bump the number and set the BB value.
844 if (ID.Type == ValID::LocalID) {
845 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
846 InsertValue(BB);
847 }
848
849 ID.destroy();
850 return BB;
851 }
852
853 // We haven't seen this BB before and its first mention is a definition.
854 // Just create it and return it.
855 std::string Name (ID.Type == ValID::LocalName ? ID.Name : "");
856 BB = new BasicBlock(Name, CurFun.CurrentFunction);
857 if (ID.Type == ValID::LocalID) {
858 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
859 InsertValue(BB);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000860 }
Reid Spencer93c40032007-03-19 18:40:50 +0000861
862 ID.destroy(); // Free strdup'd memory
863 return BB;
864}
865
866/// getBBVal - get an existing BB value or create a forward reference for it.
867///
868static BasicBlock *getBBVal(const ValID &ID) {
869 assert(inFunctionScope() && "Can't get basic block at global scope!");
870
871 BasicBlock *BB = 0;
872
873 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
874 if (BBI != CurFun.BBForwardRefs.end()) {
875 BB = BBI->second;
876 } if (ID.Type == ValID::LocalName) {
877 std::string Name = ID.Name;
878 Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
879 if (N)
880 if (N->getType()->getTypeID() == Type::LabelTyID)
881 BB = cast<BasicBlock>(N);
882 else
883 GenerateError("Reference to label '" + Name + "' is actually of type '"+
884 N->getType()->getDescription() + "'");
885 } else if (ID.Type == ValID::LocalID) {
886 if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) {
887 if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID)
888 BB = cast<BasicBlock>(CurFun.Values[ID.Num]);
889 else
890 GenerateError("Reference to label '%" + utostr(ID.Num) +
891 "' is actually of type '"+
892 CurFun.Values[ID.Num]->getType()->getDescription() + "'");
893 }
894 } else {
895 GenerateError("Illegal label reference " + ID.getName());
896 return 0;
897 }
898
899 // If its already been defined, return it now.
900 if (BB) {
901 ID.destroy(); // Free strdup'd memory.
902 return BB;
903 }
904
905 // Otherwise, this block has not been seen before, create it.
906 std::string Name;
907 if (ID.Type == ValID::LocalName)
908 Name = ID.Name;
909 BB = new BasicBlock(Name, CurFun.CurrentFunction);
910
911 // Insert it in the forward refs map.
912 CurFun.BBForwardRefs[ID] = BB;
913
Reid Spencer68a24bd2005-08-27 18:50:39 +0000914 return BB;
915}
916
917
918//===----------------------------------------------------------------------===//
919// Code to handle forward references in instructions
920//===----------------------------------------------------------------------===//
921//
922// This code handles the late binding needed with statements that reference
923// values not defined yet... for example, a forward branch, or the PHI node for
924// a loop body.
925//
926// This keeps a table (CurFun.LateResolveValues) of all such forward references
927// and back patchs after we are done.
928//
929
930// ResolveDefinitions - If we could not resolve some defs at parsing
931// time (forward branches, phi functions for loops, etc...) resolve the
932// defs now...
933//
934static void
Reid Spencer93c40032007-03-19 18:40:50 +0000935ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000936 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
Reid Spencer93c40032007-03-19 18:40:50 +0000937 while (!LateResolvers.empty()) {
938 Value *V = LateResolvers.back();
939 LateResolvers.pop_back();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000940
Reid Spencer93c40032007-03-19 18:40:50 +0000941 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
942 CurModule.PlaceHolderInfo.find(V);
943 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000944
Reid Spencer93c40032007-03-19 18:40:50 +0000945 ValID &DID = PHI->second.first;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000946
Reid Spencer93c40032007-03-19 18:40:50 +0000947 Value *TheRealValue = getExistingVal(V->getType(), DID);
948 if (TriggerError)
949 return;
950 if (TheRealValue) {
951 V->replaceAllUsesWith(TheRealValue);
952 delete V;
953 CurModule.PlaceHolderInfo.erase(PHI);
954 } else if (FutureLateResolvers) {
955 // Functions have their unresolved items forwarded to the module late
956 // resolver table
957 InsertValue(V, *FutureLateResolvers);
958 } else {
959 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
960 GenerateError("Reference to an invalid definition: '" +DID.getName()+
961 "' of type '" + V->getType()->getDescription() + "'",
962 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000963 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000964 } else {
Reid Spencer93c40032007-03-19 18:40:50 +0000965 GenerateError("Reference to an invalid definition: #" +
966 itostr(DID.Num) + " of type '" +
967 V->getType()->getDescription() + "'",
968 PHI->second.second);
969 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000970 }
971 }
972 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000973 LateResolvers.clear();
974}
975
976// ResolveTypeTo - A brand new type was just declared. This means that (if
977// name is not null) things referencing Name can be resolved. Otherwise, things
978// refering to the number can be resolved. Do this now.
979//
980static void ResolveTypeTo(char *Name, const Type *ToTy) {
981 ValID D;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000982 if (Name) D = ValID::createLocalName(Name);
983 else D = ValID::createLocalID(CurModule.Types.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +0000984
Reid Spencer861d9d62006-11-28 07:29:44 +0000985 std::map<ValID, PATypeHolder>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +0000986 CurModule.LateResolveTypes.find(D);
987 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer861d9d62006-11-28 07:29:44 +0000988 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000989 CurModule.LateResolveTypes.erase(I);
990 }
991}
992
993// setValueName - Set the specified value to the name given. The name may be
994// null potentially, in which case this is a noop. The string passed in is
995// assumed to be a malloc'd string buffer, and is free'd by this function.
996//
997static void setValueName(Value *V, char *NameStr) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000998 if (!NameStr) return;
999 std::string Name(NameStr); // Copy string
1000 free(NameStr); // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001001
Reid Spencer41dff5e2007-01-26 08:05:27 +00001002 if (V->getType() == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001003 GenerateError("Can't assign name '" + Name+"' to value with void type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001004 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001005 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00001006
Reid Spencera9720f52007-02-05 17:04:00 +00001007 assert(inFunctionScope() && "Must be in function scope!");
Reid Spenceref9b9a72007-02-05 20:47:22 +00001008 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1009 if (ST.lookup(Name)) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001010 GenerateError("Redefinition of value '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001011 V->getType()->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001012 return;
1013 }
1014
1015 // Set the name.
1016 V->setName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001017}
1018
1019/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1020/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +00001021static GlobalVariable *
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001022ParseGlobalVariable(char *NameStr,
1023 GlobalValue::LinkageTypes Linkage,
1024 GlobalValue::VisibilityTypes Visibility,
Chris Lattnerb475c422005-11-12 18:22:38 +00001025 bool isConstantGlobal, const Type *Ty,
1026 Constant *Initializer) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001027 if (isa<FunctionType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001028 GenerateError("Cannot declare global vars of function type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001029 return 0;
1030 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001031
1032 const PointerType *PTy = PointerType::get(Ty);
1033
1034 std::string Name;
1035 if (NameStr) {
1036 Name = NameStr; // Copy string
1037 free(NameStr); // Free old string
1038 }
1039
1040 // See if this global value was forward referenced. If so, recycle the
1041 // object.
1042 ValID ID;
1043 if (!Name.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001044 ID = ValID::createGlobalName((char*)Name.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001045 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00001046 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001047 }
1048
1049 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1050 // Move the global to the end of the list, from whereever it was
1051 // previously inserted.
1052 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1053 CurModule.CurrentModule->getGlobalList().remove(GV);
1054 CurModule.CurrentModule->getGlobalList().push_back(GV);
1055 GV->setInitializer(Initializer);
1056 GV->setLinkage(Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001057 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001058 GV->setConstant(isConstantGlobal);
1059 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001060 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001061 }
1062
Reid Spenceref9b9a72007-02-05 20:47:22 +00001063 // If this global has a name
Reid Spencer68a24bd2005-08-27 18:50:39 +00001064 if (!Name.empty()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00001065 // if the global we're parsing has an initializer (is a definition) and
1066 // has external linkage.
1067 if (Initializer && Linkage != GlobalValue::InternalLinkage)
1068 // If there is already a global with external linkage with this name
1069 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
1070 // If we allow this GVar to get created, it will be renamed in the
1071 // symbol table because it conflicts with an existing GVar. We can't
1072 // allow redefinition of GVars whose linking indicates that their name
1073 // must stay the same. Issue the error.
1074 GenerateError("Redefinition of global variable named '" + Name +
1075 "' of type '" + Ty->getDescription() + "'");
1076 return 0;
1077 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001078 }
1079
1080 // Otherwise there is no existing GV to use, create one now.
1081 GlobalVariable *GV =
1082 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
1083 CurModule.CurrentModule);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001084 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001085 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001086 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001087}
1088
1089// setTypeName - Set the specified type to the name given. The name may be
1090// null potentially, in which case this is a noop. The string passed in is
1091// assumed to be a malloc'd string buffer, and is freed by this function.
1092//
1093// This function returns true if the type has already been defined, but is
1094// allowed to be redefined in the specified context. If the name is a new name
1095// for the type plane, it is inserted and false is returned.
1096static bool setTypeName(const Type *T, char *NameStr) {
Reid Spencera9720f52007-02-05 17:04:00 +00001097 assert(!inFunctionScope() && "Can't give types function-local names!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001098 if (NameStr == 0) return false;
1099
1100 std::string Name(NameStr); // Copy string
1101 free(NameStr); // Free old string
1102
1103 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +00001104 if (T == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001105 GenerateError("Can't assign name '" + Name + "' to the void type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001106 return false;
1107 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001108
1109 // Set the type name, checking for conflicts as we do so.
1110 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1111
1112 if (AlreadyExists) { // Inserting a name that is already defined???
1113 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
Reid Spencera9720f52007-02-05 17:04:00 +00001114 assert(Existing && "Conflict but no matching type?!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001115
1116 // There is only one case where this is allowed: when we are refining an
1117 // opaque type. In this case, Existing will be an opaque type.
1118 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1119 // We ARE replacing an opaque type!
1120 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1121 return true;
1122 }
1123
1124 // Otherwise, this is an attempt to redefine a type. That's okay if
1125 // the redefinition is identical to the original. This will be so if
1126 // Existing and T point to the same Type object. In this one case we
1127 // allow the equivalent redefinition.
1128 if (Existing == T) return true; // Yes, it's equal.
1129
1130 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer63c34452007-01-05 21:51:07 +00001131 GenerateError("Redefinition of type named '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001132 T->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001133 }
1134
1135 return false;
1136}
1137
1138//===----------------------------------------------------------------------===//
1139// Code for handling upreferences in type names...
1140//
1141
1142// TypeContains - Returns true if Ty directly contains E in it.
1143//
1144static bool TypeContains(const Type *Ty, const Type *E) {
1145 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1146 E) != Ty->subtype_end();
1147}
1148
1149namespace {
1150 struct UpRefRecord {
1151 // NestingLevel - The number of nesting levels that need to be popped before
1152 // this type is resolved.
1153 unsigned NestingLevel;
1154
1155 // LastContainedTy - This is the type at the current binding level for the
1156 // type. Every time we reduce the nesting level, this gets updated.
1157 const Type *LastContainedTy;
1158
1159 // UpRefTy - This is the actual opaque type that the upreference is
1160 // represented with.
1161 OpaqueType *UpRefTy;
1162
1163 UpRefRecord(unsigned NL, OpaqueType *URTy)
1164 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1165 };
1166}
1167
1168// UpRefs - A list of the outstanding upreferences that need to be resolved.
1169static std::vector<UpRefRecord> UpRefs;
1170
1171/// HandleUpRefs - Every time we finish a new layer of types, this function is
1172/// called. It loops through the UpRefs vector, which is a list of the
1173/// currently active types. For each type, if the up reference is contained in
1174/// the newly completed type, we decrement the level count. When the level
1175/// count reaches zero, the upreferenced type is the type that is passed in:
1176/// thus we can complete the cycle.
1177///
1178static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001179 // If Ty isn't abstract, or if there are no up-references in it, then there is
1180 // nothing to resolve here.
1181 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1182
Reid Spencer68a24bd2005-08-27 18:50:39 +00001183 PATypeHolder Ty(ty);
1184 UR_OUT("Type '" << Ty->getDescription() <<
1185 "' newly formed. Resolving upreferences.\n" <<
1186 UpRefs.size() << " upreferences active!\n");
1187
1188 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1189 // to zero), we resolve them all together before we resolve them to Ty. At
1190 // the end of the loop, if there is anything to resolve to Ty, it will be in
1191 // this variable.
1192 OpaqueType *TypeToResolve = 0;
1193
1194 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1195 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1196 << UpRefs[i].second->getDescription() << ") = "
1197 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1198 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1199 // Decrement level of upreference
1200 unsigned Level = --UpRefs[i].NestingLevel;
1201 UpRefs[i].LastContainedTy = Ty;
1202 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1203 if (Level == 0) { // Upreference should be resolved!
1204 if (!TypeToResolve) {
1205 TypeToResolve = UpRefs[i].UpRefTy;
1206 } else {
1207 UR_OUT(" * Resolving upreference for "
1208 << UpRefs[i].second->getDescription() << "\n";
1209 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1210 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1211 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1212 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1213 }
1214 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1215 --i; // Do not skip the next element...
1216 }
1217 }
1218 }
1219
1220 if (TypeToResolve) {
1221 UR_OUT(" * Resolving upreference for "
1222 << UpRefs[i].second->getDescription() << "\n";
1223 std::string OldName = TypeToResolve->getDescription());
1224 TypeToResolve->refineAbstractTypeTo(Ty);
1225 }
1226
1227 return Ty;
1228}
1229
Reid Spencer68a24bd2005-08-27 18:50:39 +00001230//===----------------------------------------------------------------------===//
1231// RunVMAsmParser - Define an interface to this parser
1232//===----------------------------------------------------------------------===//
1233//
Reid Spencer14310612006-12-31 05:40:51 +00001234static Module* RunParser(Module * M);
1235
Reid Spencer68a24bd2005-08-27 18:50:39 +00001236Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1237 set_scan_file(F);
1238
1239 CurFilename = Filename;
1240 return RunParser(new Module(CurFilename));
1241}
1242
1243Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1244 set_scan_string(AsmString);
1245
1246 CurFilename = "from_memory";
1247 if (M == NULL) {
1248 return RunParser(new Module (CurFilename));
1249 } else {
1250 return RunParser(M);
1251 }
1252}
1253
1254
Reid Spencer38c91a92007-02-28 02:24:54 +00001255
1256/* Enabling traces. */
1257#ifndef YYDEBUG
1258# define YYDEBUG 0
1259#endif
1260
1261/* Enabling verbose error messages. */
1262#ifdef YYERROR_VERBOSE
1263# undef YYERROR_VERBOSE
1264# define YYERROR_VERBOSE 1
1265#else
1266# define YYERROR_VERBOSE 0
1267#endif
1268
1269/* Enabling the token table. */
1270#ifndef YYTOKEN_TABLE
1271# define YYTOKEN_TABLE 0
1272#endif
1273
1274#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
Reid Spencer93c40032007-03-19 18:40:50 +00001275#line 932 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00001276typedef union YYSTYPE {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001277 llvm::Module *ModuleVal;
1278 llvm::Function *FunctionVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001279 llvm::BasicBlock *BasicBlockVal;
1280 llvm::TerminatorInst *TermInstVal;
1281 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001282 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001283
Reid Spencera132e042006-12-03 05:46:11 +00001284 const llvm::Type *PrimType;
Reid Spencer14310612006-12-31 05:40:51 +00001285 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencera132e042006-12-03 05:46:11 +00001286 llvm::PATypeHolder *TypeVal;
1287 llvm::Value *ValueVal;
Reid Spencera132e042006-12-03 05:46:11 +00001288 std::vector<llvm::Value*> *ValueList;
Reid Spencer14310612006-12-31 05:40:51 +00001289 llvm::ArgListType *ArgList;
1290 llvm::TypeWithAttrs TypeWithAttrs;
1291 llvm::TypeWithAttrsList *TypeWithAttrsList;
1292 llvm::ValueRefList *ValueRefList;
1293
Reid Spencer68a24bd2005-08-27 18:50:39 +00001294 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001295 std::list<std::pair<llvm::Value*,
1296 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001297 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001298 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001299
1300 llvm::GlobalValue::LinkageTypes Linkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001301 llvm::GlobalValue::VisibilityTypes Visibility;
Reid Spencer14310612006-12-31 05:40:51 +00001302 llvm::FunctionType::ParameterAttributes ParamAttrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00001303 llvm::APInt *APIntVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001304 int64_t SInt64Val;
1305 uint64_t UInt64Val;
1306 int SIntVal;
1307 unsigned UIntVal;
1308 double FPVal;
1309 bool BoolVal;
1310
1311 char *StrVal; // This memory is strdup'd!
Reid Spencer1628cec2006-10-26 06:15:43 +00001312 llvm::ValID ValIDVal; // strdup'd memory maybe!
Reid Spencer68a24bd2005-08-27 18:50:39 +00001313
Reid Spencera132e042006-12-03 05:46:11 +00001314 llvm::Instruction::BinaryOps BinaryOpVal;
1315 llvm::Instruction::TermOps TermOpVal;
1316 llvm::Instruction::MemoryOps MemOpVal;
1317 llvm::Instruction::CastOps CastOpVal;
1318 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencera132e042006-12-03 05:46:11 +00001319 llvm::ICmpInst::Predicate IPredicate;
1320 llvm::FCmpInst::Predicate FPredicate;
Chris Lattner9d2fda62007-02-13 05:53:56 +00001321} YYSTYPE;
Reid Spencer38c91a92007-02-28 02:24:54 +00001322/* Line 196 of yacc.c. */
Reid Spencer93c40032007-03-19 18:40:50 +00001323#line 1324 "llvmAsmParser.tab.c"
Reid Spencer38c91a92007-02-28 02:24:54 +00001324# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1325# define YYSTYPE_IS_DECLARED 1
1326# define YYSTYPE_IS_TRIVIAL 1
Reid Spencer68a24bd2005-08-27 18:50:39 +00001327#endif
1328
Reid Spencer41dff5e2007-01-26 08:05:27 +00001329
Reid Spencer68a24bd2005-08-27 18:50:39 +00001330
Reid Spencer38c91a92007-02-28 02:24:54 +00001331/* Copy the second part of user declarations. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001332
1333
Reid Spencer38c91a92007-02-28 02:24:54 +00001334/* Line 219 of yacc.c. */
Reid Spencer93c40032007-03-19 18:40:50 +00001335#line 1336 "llvmAsmParser.tab.c"
Reid Spencer41dff5e2007-01-26 08:05:27 +00001336
Reid Spencer38c91a92007-02-28 02:24:54 +00001337#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
1338# define YYSIZE_T __SIZE_TYPE__
1339#endif
1340#if ! defined (YYSIZE_T) && defined (size_t)
1341# define YYSIZE_T size_t
1342#endif
1343#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
1344# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1345# define YYSIZE_T size_t
1346#endif
1347#if ! defined (YYSIZE_T)
1348# define YYSIZE_T unsigned int
1349#endif
Chris Lattner9d2fda62007-02-13 05:53:56 +00001350
Reid Spencer38c91a92007-02-28 02:24:54 +00001351#ifndef YY_
1352# if YYENABLE_NLS
1353# if ENABLE_NLS
1354# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1355# define YY_(msgid) dgettext ("bison-runtime", msgid)
1356# endif
1357# endif
1358# ifndef YY_
1359# define YY_(msgid) msgid
1360# endif
1361#endif
1362
1363#if ! defined (yyoverflow) || YYERROR_VERBOSE
1364
1365/* The parser invokes alloca or malloc; define the necessary symbols. */
1366
1367# ifdef YYSTACK_USE_ALLOCA
1368# if YYSTACK_USE_ALLOCA
1369# ifdef __GNUC__
1370# define YYSTACK_ALLOC __builtin_alloca
1371# else
1372# define YYSTACK_ALLOC alloca
1373# if defined (__STDC__) || defined (__cplusplus)
1374# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1375# define YYINCLUDED_STDLIB_H
1376# endif
1377# endif
1378# endif
1379# endif
1380
1381# ifdef YYSTACK_ALLOC
1382 /* Pacify GCC's `empty if-body' warning. */
1383# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
1384# ifndef YYSTACK_ALLOC_MAXIMUM
1385 /* The OS might guarantee only one guard page at the bottom of the stack,
1386 and a page size can be as small as 4096 bytes. So we cannot safely
1387 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1388 to allow for a few compiler-allocated temporary stack slots. */
1389# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
1390# endif
1391# else
1392# define YYSTACK_ALLOC YYMALLOC
1393# define YYSTACK_FREE YYFREE
1394# ifndef YYSTACK_ALLOC_MAXIMUM
1395# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
1396# endif
1397# ifdef __cplusplus
1398extern "C" {
1399# endif
1400# ifndef YYMALLOC
1401# define YYMALLOC malloc
1402# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
1403 && (defined (__STDC__) || defined (__cplusplus)))
1404void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1405# endif
1406# endif
1407# ifndef YYFREE
1408# define YYFREE free
1409# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
1410 && (defined (__STDC__) || defined (__cplusplus)))
1411void free (void *); /* INFRINGES ON USER NAME SPACE */
1412# endif
1413# endif
1414# ifdef __cplusplus
1415}
1416# endif
1417# endif
1418#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
1419
1420
1421#if (! defined (yyoverflow) \
1422 && (! defined (__cplusplus) \
1423 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
1424
1425/* A type that is properly aligned for any stack member. */
1426union yyalloc
1427{
1428 short int yyss;
1429 YYSTYPE yyvs;
1430 };
1431
1432/* The size of the maximum gap between one aligned stack and the next. */
1433# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1434
1435/* The size of an array large to enough to hold all stacks, each with
1436 N elements. */
1437# define YYSTACK_BYTES(N) \
1438 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
1439 + YYSTACK_GAP_MAXIMUM)
1440
1441/* Copy COUNT objects from FROM to TO. The source and destination do
1442 not overlap. */
1443# ifndef YYCOPY
1444# if defined (__GNUC__) && 1 < __GNUC__
1445# define YYCOPY(To, From, Count) \
1446 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1447# else
1448# define YYCOPY(To, From, Count) \
1449 do \
1450 { \
1451 YYSIZE_T yyi; \
1452 for (yyi = 0; yyi < (Count); yyi++) \
1453 (To)[yyi] = (From)[yyi]; \
1454 } \
1455 while (0)
1456# endif
1457# endif
1458
1459/* Relocate STACK from its old location to the new one. The
1460 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1461 elements in the stack, and YYPTR gives the new location of the
1462 stack. Advance YYPTR to a properly aligned location for the next
1463 stack. */
1464# define YYSTACK_RELOCATE(Stack) \
1465 do \
1466 { \
1467 YYSIZE_T yynewbytes; \
1468 YYCOPY (&yyptr->Stack, Stack, yysize); \
1469 Stack = &yyptr->Stack; \
1470 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1471 yyptr += yynewbytes / sizeof (*yyptr); \
1472 } \
1473 while (0)
Chris Lattner9d2fda62007-02-13 05:53:56 +00001474
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001475#endif
1476
Reid Spencer38c91a92007-02-28 02:24:54 +00001477#if defined (__STDC__) || defined (__cplusplus)
1478 typedef signed char yysigned_char;
Reid Spencer5cbf9852007-01-30 20:08:39 +00001479#else
Reid Spencer38c91a92007-02-28 02:24:54 +00001480 typedef short int yysigned_char;
Reid Spencer5cbf9852007-01-30 20:08:39 +00001481#endif
1482
Reid Spencer38c91a92007-02-28 02:24:54 +00001483/* YYFINAL -- State number of the termination state. */
1484#define YYFINAL 40
1485/* YYLAST -- Last index in YYTABLE. */
1486#define YYLAST 1429
1487
1488/* YYNTOKENS -- Number of terminals. */
1489#define YYNTOKENS 148
1490/* YYNNTS -- Number of nonterminals. */
1491#define YYNNTS 78
1492/* YYNRULES -- Number of rules. */
1493#define YYNRULES 286
1494/* YYNRULES -- Number of states. */
1495#define YYNSTATES 559
1496
1497/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1498#define YYUNDEFTOK 2
1499#define YYMAXUTOK 388
1500
1501#define YYTRANSLATE(YYX) \
1502 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1503
1504/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1505static const unsigned char yytranslate[] =
1506{
1507 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1508 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1509 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1510 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1511 138, 139, 136, 2, 135, 2, 2, 2, 2, 2,
1512 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1513 143, 134, 144, 2, 2, 2, 2, 2, 2, 2,
1514 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1515 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1516 2, 140, 137, 142, 2, 2, 2, 2, 2, 147,
1517 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1518 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1519 141, 2, 2, 145, 2, 146, 2, 2, 2, 2,
1520 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1521 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1522 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1523 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1524 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1525 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1526 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1527 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1528 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1529 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1530 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1531 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1532 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1533 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1534 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1535 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1536 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1537 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1538 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1539 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1540 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1541 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1542 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
1543 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
1544 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1545 125, 126, 127, 128, 129, 130, 131, 132, 133
1546};
1547
1548#if YYDEBUG
1549/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1550 YYRHS. */
1551static const unsigned short int yyprhs[] =
1552{
1553 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1554 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1555 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1556 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
1557 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
1558 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
1559 119, 121, 122, 125, 126, 128, 130, 133, 134, 136,
1560 138, 140, 142, 144, 146, 148, 150, 151, 153, 154,
1561 156, 158, 159, 161, 163, 165, 167, 168, 170, 172,
1562 174, 176, 178, 181, 183, 185, 187, 189, 190, 193,
1563 195, 197, 198, 201, 202, 205, 206, 210, 213, 214,
1564 216, 217, 221, 223, 226, 228, 230, 232, 234, 236,
1565 238, 241, 243, 246, 252, 258, 264, 270, 274, 277,
1566 283, 288, 291, 293, 295, 297, 301, 303, 307, 309,
1567 310, 312, 316, 321, 325, 329, 334, 339, 343, 350,
1568 356, 359, 362, 365, 368, 371, 374, 377, 380, 383,
1569 386, 389, 392, 399, 405, 414, 421, 428, 436, 444,
1570 451, 460, 469, 473, 475, 477, 479, 481, 482, 484,
1571 487, 488, 492, 493, 497, 501, 503, 507, 511, 512,
1572 519, 520, 528, 529, 537, 540, 544, 546, 550, 554,
1573 558, 562, 564, 565, 571, 575, 577, 581, 583, 584,
1574 594, 596, 598, 603, 605, 607, 610, 614, 615, 617,
1575 619, 621, 623, 625, 627, 629, 631, 633, 637, 639,
1576 645, 647, 649, 651, 653, 655, 657, 660, 663, 666,
1577 670, 673, 674, 676, 679, 682, 686, 696, 706, 715,
1578 730, 732, 734, 741, 747, 750, 757, 765, 769, 775,
1579 776, 777, 781, 784, 786, 792, 798, 805, 812, 817,
1580 824, 829, 834, 841, 848, 851, 860, 862, 864, 865,
1581 869, 876, 880, 887, 890, 895, 902
1582};
1583
1584/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1585static const short int yyrhs[] =
1586{
1587 188, 0, -1, 68, -1, 69, -1, 70, -1, 71,
1588 -1, 72, -1, 73, -1, 74, -1, 75, -1, 76,
1589 -1, 80, -1, 81, -1, 82, -1, 77, -1, 78,
1590 -1, 79, -1, 111, -1, 112, -1, 113, -1, 114,
1591 -1, 115, -1, 116, -1, 117, -1, 118, -1, 119,
1592 -1, 120, -1, 121, -1, 122, -1, 85, -1, 86,
1593 -1, 87, -1, 88, -1, 89, -1, 90, -1, 91,
1594 -1, 92, -1, 93, -1, 94, -1, 95, -1, 96,
1595 -1, 97, -1, 98, -1, 99, -1, 100, -1, 101,
1596 -1, 102, -1, 103, -1, 104, -1, 91, -1, 92,
1597 -1, 93, -1, 94, -1, 23, -1, 24, -1, 11,
1598 -1, 12, -1, 13, -1, 16, -1, 19, -1, 156,
1599 -1, -1, 156, 134, -1, -1, 17, -1, 20, -1,
1600 159, 134, -1, -1, 37, -1, 39, -1, 38, -1,
1601 40, -1, 42, -1, 41, -1, 43, -1, 45, -1,
1602 -1, 133, -1, -1, 41, -1, 43, -1, -1, 37,
1603 -1, 38, -1, 39, -1, 42, -1, -1, 56, -1,
1604 57, -1, 58, -1, 59, -1, 60, -1, 55, 4,
1605 -1, 112, -1, 113, -1, 130, -1, 131, -1, -1,
1606 168, 167, -1, 129, -1, 167, -1, -1, 170, 169,
1607 -1, -1, 48, 4, -1, -1, 135, 48, 4, -1,
1608 31, 19, -1, -1, 173, -1, -1, 135, 176, 175,
1609 -1, 173, -1, 48, 4, -1, 11, -1, 12, -1,
1610 13, -1, 14, -1, 44, -1, 177, -1, 178, 136,
1611 -1, 210, -1, 137, 4, -1, 178, 138, 182, 139,
1612 170, -1, 10, 138, 182, 139, 170, -1, 140, 4,
1613 141, 178, 142, -1, 143, 4, 141, 178, 144, -1,
1614 145, 183, 146, -1, 145, 146, -1, 143, 145, 183,
1615 146, 144, -1, 143, 145, 146, 144, -1, 178, 168,
1616 -1, 178, -1, 10, -1, 179, -1, 181, 135, 179,
1617 -1, 181, -1, 181, 135, 34, -1, 34, -1, -1,
1618 178, -1, 183, 135, 178, -1, 178, 140, 186, 142,
1619 -1, 178, 140, 142, -1, 178, 147, 19, -1, 178,
1620 143, 186, 144, -1, 178, 145, 186, 146, -1, 178,
1621 145, 146, -1, 178, 143, 145, 186, 146, 144, -1,
1622 178, 143, 145, 146, 144, -1, 178, 35, -1, 178,
1623 36, -1, 178, 210, -1, 178, 185, -1, 178, 22,
1624 -1, 154, 3, -1, 154, 5, -1, 154, 4, -1,
1625 154, 6, -1, 11, 23, -1, 11, 24, -1, 155,
1626 9, -1, 151, 138, 184, 33, 178, 139, -1, 110,
1627 138, 184, 221, 139, -1, 124, 138, 184, 135, 184,
1628 135, 184, 139, -1, 149, 138, 184, 135, 184, 139,
1629 -1, 150, 138, 184, 135, 184, 139, -1, 83, 152,
1630 138, 184, 135, 184, 139, -1, 84, 153, 138, 184,
1631 135, 184, 139, -1, 126, 138, 184, 135, 184, 139,
1632 -1, 127, 138, 184, 135, 184, 135, 184, 139, -1,
1633 128, 138, 184, 135, 184, 135, 184, 139, -1, 186,
1634 135, 184, -1, 184, -1, 29, -1, 30, -1, 189,
1635 -1, -1, 190, -1, 189, 190, -1, -1, 28, 191,
1636 206, -1, -1, 27, 192, 207, -1, 53, 52, 196,
1637 -1, 21, -1, 158, 15, 178, -1, 158, 15, 10,
1638 -1, -1, 160, 163, 187, 184, 193, 175, -1, -1,
1639 160, 161, 163, 187, 184, 194, 175, -1, -1, 160,
1640 162, 163, 187, 178, 195, 175, -1, 46, 197, -1,
1641 49, 134, 198, -1, 19, -1, 47, 134, 19, -1,
1642 61, 134, 19, -1, 140, 199, 142, -1, 199, 135,
1643 19, -1, 19, -1, -1, 200, 135, 178, 168, 157,
1644 -1, 178, 168, 157, -1, 200, -1, 200, 135, 34,
1645 -1, 34, -1, -1, 166, 180, 159, 138, 201, 139,
1646 170, 174, 171, -1, 25, -1, 145, -1, 165, 163,
1647 202, 203, -1, 26, -1, 146, -1, 213, 205, -1,
1648 164, 163, 202, -1, -1, 54, -1, 3, -1, 4,
1649 -1, 9, -1, 23, -1, 24, -1, 35, -1, 36,
1650 -1, 22, -1, 143, 186, 144, -1, 185, -1, 52,
1651 208, 19, 135, 19, -1, 7, -1, 8, -1, 156,
1652 -1, 159, -1, 210, -1, 209, -1, 178, 211, -1,
1653 213, 214, -1, 204, 214, -1, 215, 158, 216, -1,
1654 215, 218, -1, -1, 18, -1, 62, 212, -1, 62,
1655 10, -1, 63, 14, 211, -1, 63, 11, 211, 135,
1656 14, 211, 135, 14, 211, -1, 64, 154, 211, 135,
1657 14, 211, 140, 217, 142, -1, 64, 154, 211, 135,
1658 14, 211, 140, 142, -1, 65, 166, 180, 211, 138,
1659 220, 139, 170, 33, 14, 211, 66, 14, 211, -1,
1660 66, -1, 67, -1, 217, 154, 209, 135, 14, 211,
1661 -1, 154, 209, 135, 14, 211, -1, 158, 223, -1,
1662 178, 140, 211, 135, 211, 142, -1, 219, 135, 140,
1663 211, 135, 211, 142, -1, 178, 211, 168, -1, 220,
1664 135, 178, 211, 168, -1, -1, -1, 221, 135, 212,
1665 -1, 51, 50, -1, 50, -1, 149, 178, 211, 135,
1666 211, -1, 150, 178, 211, 135, 211, -1, 83, 152,
1667 178, 211, 135, 211, -1, 84, 153, 178, 211, 135,
1668 211, -1, 151, 212, 33, 178, -1, 124, 212, 135,
1669 212, 135, 212, -1, 125, 212, 135, 178, -1, 126,
1670 212, 135, 212, -1, 127, 212, 135, 212, 135, 212,
1671 -1, 128, 212, 135, 212, 135, 212, -1, 123, 219,
1672 -1, 222, 166, 180, 211, 138, 220, 139, 170, -1,
1673 225, -1, 32, -1, -1, 105, 178, 172, -1, 105,
1674 178, 135, 11, 211, 172, -1, 106, 178, 172, -1,
1675 106, 178, 135, 11, 211, 172, -1, 107, 212, -1,
1676 224, 108, 178, 211, -1, 224, 109, 212, 135, 178,
1677 211, -1, 110, 178, 211, 221, -1
1678};
1679
1680/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1681static const unsigned short int yyrline[] =
1682{
Reid Spencer93c40032007-03-19 18:40:50 +00001683 0, 1086, 1086, 1086, 1086, 1086, 1086, 1086, 1086, 1086,
1684 1086, 1087, 1087, 1087, 1087, 1087, 1087, 1088, 1088, 1088,
1685 1088, 1088, 1088, 1089, 1089, 1089, 1089, 1089, 1089, 1092,
1686 1092, 1093, 1093, 1094, 1094, 1095, 1095, 1096, 1096, 1100,
1687 1100, 1101, 1101, 1102, 1102, 1103, 1103, 1104, 1104, 1105,
1688 1105, 1106, 1106, 1107, 1108, 1113, 1114, 1114, 1116, 1116,
1689 1117, 1117, 1121, 1125, 1130, 1130, 1132, 1136, 1142, 1143,
1690 1144, 1145, 1146, 1150, 1151, 1152, 1156, 1157, 1161, 1162,
1691 1163, 1167, 1168, 1169, 1170, 1171, 1174, 1175, 1176, 1177,
1692 1178, 1179, 1180, 1187, 1188, 1189, 1190, 1193, 1194, 1199,
1693 1200, 1203, 1204, 1211, 1212, 1218, 1219, 1227, 1235, 1236,
1694 1241, 1242, 1243, 1248, 1261, 1261, 1261, 1261, 1264, 1268,
1695 1272, 1279, 1284, 1292, 1310, 1328, 1333, 1345, 1355, 1359,
1696 1369, 1376, 1383, 1390, 1395, 1400, 1407, 1408, 1415, 1422,
1697 1430, 1435, 1446, 1474, 1490, 1519, 1547, 1572, 1591, 1617,
Reid Spencer49d273e2007-03-19 20:40:51 +00001698 1637, 1649, 1656, 1722, 1732, 1742, 1748, 1758, 1764, 1774,
1699 1779, 1784, 1792, 1804, 1826, 1834, 1840, 1851, 1856, 1861,
1700 1867, 1873, 1882, 1886, 1894, 1894, 1905, 1910, 1918, 1919,
1701 1923, 1923, 1927, 1927, 1930, 1933, 1945, 1969, 1980, 1980,
1702 1990, 1990, 1998, 1998, 2008, 2011, 2017, 2030, 2034, 2039,
1703 2041, 2046, 2051, 2060, 2070, 2081, 2085, 2094, 2103, 2108,
1704 2220, 2220, 2222, 2231, 2231, 2233, 2238, 2250, 2254, 2259,
1705 2263, 2267, 2271, 2275, 2279, 2283, 2287, 2291, 2316, 2320,
1706 2334, 2338, 2342, 2346, 2352, 2352, 2358, 2367, 2371, 2380,
1707 2389, 2398, 2402, 2407, 2411, 2415, 2420, 2430, 2449, 2458,
1708 2525, 2529, 2536, 2547, 2560, 2570, 2581, 2591, 2599, 2607,
1709 2610, 2611, 2618, 2622, 2627, 2648, 2665, 2678, 2691, 2703,
1710 2711, 2718, 2724, 2730, 2736, 2751, 2815, 2820, 2824, 2831,
1711 2838, 2846, 2853, 2861, 2869, 2883, 2900
Reid Spencer38c91a92007-02-28 02:24:54 +00001712};
1713#endif
1714
1715#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1716/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1717 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1718static const char *const yytname[] =
1719{
1720 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "ESAPINTVAL",
1721 "EUAPINTVAL", "LOCALVAL_ID", "GLOBALVAL_ID", "FPVAL", "VOID", "INTTYPE",
1722 "FLOAT", "DOUBLE", "LABEL", "TYPE", "LOCALVAR", "GLOBALVAR", "LABELSTR",
1723 "STRINGCONSTANT", "ATSTRINGCONSTANT", "IMPLEMENTATION",
1724 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
1725 "DECLARE", "DEFINE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO",
1726 "DOTDOTDOT", "NULL_TOK", "UNDEF", "INTERNAL", "LINKONCE", "WEAK",
1727 "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
1728 "EXTERNAL", "TARGET", "TRIPLE", "ALIGN", "DEPLIBS", "CALL", "TAIL",
1729 "ASM_TOK", "MODULE", "SIDEEFFECT", "CC_TOK", "CCC_TOK", "FASTCC_TOK",
1730 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
1731 "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE", "ADD", "SUB",
1732 "MUL", "UDIV", "SDIV", "FDIV", "UREM", "SREM", "FREM", "AND", "OR",
1733 "XOR", "SHL", "LSHR", "ASHR", "ICMP", "FCMP", "EQ", "NE", "SLT", "SGT",
1734 "SLE", "SGE", "ULT", "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT",
1735 "OLE", "OGE", "ORD", "UNO", "UEQ", "UNE", "MALLOC", "ALLOCA", "FREE",
1736 "LOAD", "STORE", "GETELEMENTPTR", "TRUNC", "ZEXT", "SEXT", "FPTRUNC",
1737 "FPEXT", "BITCAST", "UITOFP", "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR",
1738 "PTRTOINT", "PHI_TOK", "SELECT", "VAARG", "EXTRACTELEMENT",
1739 "INSERTELEMENT", "SHUFFLEVECTOR", "NORETURN", "INREG", "SRET", "DEFAULT",
1740 "HIDDEN", "'='", "','", "'*'", "'\\\\'", "'('", "')'", "'['", "'x'",
1741 "']'", "'<'", "'>'", "'{'", "'}'", "'c'", "$accept", "ArithmeticOps",
1742 "LogicalOps", "CastOps", "IPredicates", "FPredicates", "IntType",
1743 "FPType", "LocalName", "OptLocalName", "OptLocalAssign", "GlobalName",
1744 "OptGlobalAssign", "GVInternalLinkage", "GVExternalLinkage",
1745 "GVVisibilityStyle", "FunctionDeclareLinkage", "FunctionDefineLinkage",
1746 "OptCallingConv", "ParamAttr", "OptParamAttrs", "FuncAttr",
1747 "OptFuncAttrs", "OptAlign", "OptCAlign", "SectionString", "OptSection",
1748 "GlobalVarAttributes", "GlobalVarAttribute", "PrimType", "Types",
1749 "ArgType", "ResultTypes", "ArgTypeList", "ArgTypeListI", "TypeListI",
1750 "ConstVal", "ConstExpr", "ConstVector", "GlobalType", "Module",
1751 "DefinitionList", "Definition", "@1", "@2", "@3", "@4", "@5", "AsmBlock",
1752 "TargetDefinition", "LibrariesDefinition", "LibList", "ArgListH",
1753 "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader", "END",
1754 "Function", "FunctionProto", "OptSideEffect", "ConstValueRef",
1755 "SymbolicValueRef", "ValueRef", "ResolvedVal", "BasicBlockList",
1756 "BasicBlock", "InstructionList", "BBTerminatorInst", "JumpTable", "Inst",
1757 "PHIList", "ValueRefList", "IndexList", "OptTailCall", "InstVal",
1758 "OptVolatile", "MemoryInst", 0
1759};
1760#endif
1761
1762# ifdef YYPRINT
1763/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1764 token YYLEX-NUM. */
1765static const unsigned short int yytoknum[] =
1766{
1767 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1768 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1769 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1770 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1771 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1772 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1773 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1774 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1775 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1776 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1777 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
1778 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
1779 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
1780 385, 386, 387, 388, 61, 44, 42, 92, 40, 41,
1781 91, 120, 93, 60, 62, 123, 125, 99
1782};
1783# endif
1784
1785/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1786static const unsigned char yyr1[] =
1787{
1788 0, 148, 149, 149, 149, 149, 149, 149, 149, 149,
1789 149, 150, 150, 150, 150, 150, 150, 151, 151, 151,
1790 151, 151, 151, 151, 151, 151, 151, 151, 151, 152,
1791 152, 152, 152, 152, 152, 152, 152, 152, 152, 153,
1792 153, 153, 153, 153, 153, 153, 153, 153, 153, 153,
1793 153, 153, 153, 153, 153, 154, 155, 155, 156, 156,
1794 157, 157, 158, 158, 159, 159, 160, 160, 161, 161,
1795 161, 161, 161, 162, 162, 162, 163, 163, 164, 164,
1796 164, 165, 165, 165, 165, 165, 166, 166, 166, 166,
1797 166, 166, 166, 167, 167, 167, 167, 168, 168, 169,
1798 169, 170, 170, 171, 171, 172, 172, 173, 174, 174,
1799 175, 175, 176, 176, 177, 177, 177, 177, 178, 178,
1800 178, 178, 178, 178, 178, 178, 178, 178, 178, 178,
1801 178, 179, 180, 180, 181, 181, 182, 182, 182, 182,
1802 183, 183, 184, 184, 184, 184, 184, 184, 184, 184,
1803 184, 184, 184, 184, 184, 184, 184, 184, 184, 184,
1804 184, 184, 185, 185, 185, 185, 185, 185, 185, 185,
1805 185, 185, 186, 186, 187, 187, 188, 188, 189, 189,
1806 191, 190, 192, 190, 190, 190, 190, 190, 193, 190,
1807 194, 190, 195, 190, 190, 190, 196, 197, 197, 198,
1808 199, 199, 199, 200, 200, 201, 201, 201, 201, 202,
1809 203, 203, 204, 205, 205, 206, 207, 208, 208, 209,
1810 209, 209, 209, 209, 209, 209, 209, 209, 209, 209,
1811 210, 210, 210, 210, 211, 211, 212, 213, 213, 214,
1812 215, 215, 215, 216, 216, 216, 216, 216, 216, 216,
1813 216, 216, 217, 217, 218, 219, 219, 220, 220, 220,
1814 221, 221, 222, 222, 223, 223, 223, 223, 223, 223,
1815 223, 223, 223, 223, 223, 223, 223, 224, 224, 225,
1816 225, 225, 225, 225, 225, 225, 225
1817};
1818
1819/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
1820static const unsigned char yyr2[] =
1821{
1822 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1823 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1824 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1825 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1826 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1827 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1828 1, 0, 2, 0, 1, 1, 2, 0, 1, 1,
1829 1, 1, 1, 1, 1, 1, 0, 1, 0, 1,
1830 1, 0, 1, 1, 1, 1, 0, 1, 1, 1,
1831 1, 1, 2, 1, 1, 1, 1, 0, 2, 1,
1832 1, 0, 2, 0, 2, 0, 3, 2, 0, 1,
1833 0, 3, 1, 2, 1, 1, 1, 1, 1, 1,
1834 2, 1, 2, 5, 5, 5, 5, 3, 2, 5,
1835 4, 2, 1, 1, 1, 3, 1, 3, 1, 0,
1836 1, 3, 4, 3, 3, 4, 4, 3, 6, 5,
1837 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1838 2, 2, 6, 5, 8, 6, 6, 7, 7, 6,
1839 8, 8, 3, 1, 1, 1, 1, 0, 1, 2,
1840 0, 3, 0, 3, 3, 1, 3, 3, 0, 6,
1841 0, 7, 0, 7, 2, 3, 1, 3, 3, 3,
1842 3, 1, 0, 5, 3, 1, 3, 1, 0, 9,
1843 1, 1, 4, 1, 1, 2, 3, 0, 1, 1,
1844 1, 1, 1, 1, 1, 1, 1, 3, 1, 5,
1845 1, 1, 1, 1, 1, 1, 2, 2, 2, 3,
1846 2, 0, 1, 2, 2, 3, 9, 9, 8, 14,
1847 1, 1, 6, 5, 2, 6, 7, 3, 5, 0,
1848 0, 3, 2, 1, 5, 5, 6, 6, 4, 6,
1849 4, 4, 6, 6, 2, 8, 1, 1, 0, 3,
1850 6, 3, 6, 2, 4, 6, 4
1851};
1852
1853/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
1854 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
1855 means the default is an error. */
1856static const unsigned short int yydefact[] =
1857{
1858 67, 58, 64, 59, 65, 185, 182, 180, 0, 0,
1859 0, 0, 0, 0, 76, 0, 67, 178, 78, 81,
1860 0, 0, 194, 0, 0, 62, 0, 66, 68, 70,
1861 69, 71, 73, 72, 74, 75, 77, 76, 76, 0,
1862 1, 179, 79, 80, 76, 183, 82, 83, 84, 85,
1863 76, 241, 181, 241, 0, 0, 202, 195, 196, 184,
1864 230, 231, 187, 114, 115, 116, 117, 118, 0, 0,
1865 0, 0, 232, 233, 119, 186, 121, 0, 0, 174,
1866 175, 0, 86, 86, 242, 238, 63, 213, 214, 215,
1867 237, 197, 198, 201, 0, 139, 122, 0, 0, 0,
1868 0, 128, 140, 0, 120, 139, 0, 0, 114, 115,
1869 116, 0, 0, 0, 188, 0, 87, 88, 89, 90,
1870 91, 0, 216, 0, 278, 240, 0, 199, 138, 97,
1871 134, 136, 0, 0, 0, 0, 0, 0, 127, 0,
1872 190, 192, 159, 160, 155, 157, 156, 158, 161, 154,
1873 150, 151, 2, 3, 4, 5, 6, 7, 8, 9,
1874 10, 14, 15, 16, 11, 12, 13, 0, 0, 0,
1875 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1876 27, 28, 0, 0, 0, 0, 0, 0, 0, 0,
1877 0, 0, 0, 153, 152, 110, 92, 133, 132, 0,
1878 210, 211, 212, 277, 263, 0, 0, 0, 0, 86,
1879 250, 251, 0, 0, 0, 0, 0, 0, 0, 0,
1880 0, 0, 0, 0, 0, 0, 0, 239, 86, 254,
1881 0, 276, 200, 131, 0, 101, 0, 0, 130, 0,
1882 141, 101, 110, 110, 29, 30, 31, 32, 33, 34,
1883 35, 36, 37, 38, 0, 53, 54, 49, 50, 51,
1884 52, 39, 40, 41, 42, 43, 44, 45, 46, 47,
1885 48, 0, 0, 0, 0, 0, 0, 143, 173, 0,
1886 0, 0, 147, 0, 144, 0, 0, 0, 0, 189,
1887 0, 262, 244, 0, 243, 0, 0, 55, 0, 0,
1888 0, 0, 105, 105, 283, 0, 0, 274, 0, 0,
1889 0, 0, 0, 0, 0, 0, 0, 0, 0, 93,
1890 94, 95, 96, 98, 137, 135, 124, 125, 126, 129,
1891 123, 191, 193, 0, 0, 260, 0, 0, 0, 0,
1892 0, 142, 128, 140, 0, 145, 146, 0, 0, 0,
1893 0, 0, 112, 110, 208, 219, 220, 221, 226, 222,
1894 223, 224, 225, 217, 0, 228, 235, 234, 236, 0,
1895 245, 0, 0, 0, 0, 0, 279, 0, 281, 260,
1896 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1897 0, 0, 0, 99, 100, 102, 0, 0, 0, 0,
1898 0, 0, 0, 172, 149, 0, 0, 0, 0, 107,
1899 113, 111, 207, 97, 205, 0, 218, 0, 0, 0,
1900 0, 0, 0, 0, 0, 0, 0, 286, 0, 0,
1901 0, 270, 271, 0, 0, 0, 0, 268, 0, 284,
1902 0, 0, 0, 0, 163, 0, 0, 0, 0, 148,
1903 0, 0, 0, 61, 0, 101, 0, 227, 0, 0,
1904 259, 0, 0, 105, 106, 105, 0, 0, 0, 0,
1905 0, 264, 265, 259, 0, 0, 0, 261, 0, 169,
1906 0, 0, 165, 166, 162, 60, 204, 206, 97, 108,
1907 0, 0, 0, 0, 0, 266, 267, 0, 280, 282,
1908 0, 0, 269, 272, 273, 0, 285, 167, 168, 0,
1909 0, 0, 61, 109, 103, 229, 0, 0, 97, 0,
1910 101, 255, 0, 101, 164, 170, 171, 203, 0, 209,
1911 0, 248, 0, 0, 257, 0, 0, 256, 275, 104,
1912 246, 0, 247, 0, 97, 0, 0, 0, 258, 0,
1913 0, 0, 0, 253, 0, 0, 252, 0, 249
1914};
1915
1916/* YYDEFGOTO[NTERM-NUM]. */
1917static const short int yydefgoto[] =
1918{
1919 -1, 190, 191, 192, 254, 271, 111, 112, 72, 486,
1920 12, 73, 14, 37, 38, 39, 44, 50, 121, 323,
1921 233, 395, 326, 529, 376, 352, 514, 289, 353, 74,
1922 113, 130, 199, 131, 132, 103, 278, 365, 279, 81,
1923 15, 16, 17, 19, 18, 195, 242, 243, 59, 22,
1924 57, 94, 414, 415, 122, 202, 51, 89, 52, 45,
1925 417, 366, 76, 368, 294, 53, 85, 86, 227, 533,
1926 125, 307, 494, 398, 228, 229, 230, 231
1927};
1928
1929/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
1930 STATE-NUM. */
1931#define YYPACT_NINF -440
1932static const short int yypact[] =
1933{
1934 406, -440, -440, -440, -440, -440, -440, -440, -2, -101,
1935 21, -55, 80, -20, 15, 132, 556, -440, 253, 197,
1936 -7, 87, -440, 20, 207, -440, 893, -440, -440, -440,
1937 -440, -440, -440, -440, -440, -440, -440, 97, 97, 125,
1938 -440, -440, -440, -440, 97, -440, -440, -440, -440, -440,
1939 97, 235, -440, 6, 240, 248, 258, -440, -440, -440,
1940 -440, -440, 134, -440, -440, -440, -440, -440, 269, 277,
1941 11, 123, -440, -440, -440, 33, -440, 125, 125, -440,
1942 -440, 1055, 128, 128, -440, -440, 47, -440, -440, -440,
1943 -440, -440, -440, -440, -57, 939, -440, 154, 156, 488,
1944 134, -440, 33, -112, -440, 939, 1055, 1149, 38, 281,
1945 289, 239, 293, 850, -440, 299, -440, -440, -440, -440,
1946 -440, 1168, -440, 2, 1301, -440, 285, -440, -440, 33,
1947 -440, 170, 167, 1149, 1149, 164, -97, 1149, -440, 171,
1948 -440, 33, -440, -440, -440, -440, -440, -440, -440, -440,
1949 -440, -440, -440, -440, -440, -440, -440, -440, -440, -440,
1950 -440, -440, -440, -440, -440, -440, -440, 254, 446, 174,
1951 -440, -440, -440, -440, -440, -440, -440, -440, -440, -440,
1952 -440, -440, 175, 176, 177, 178, 109, 1203, 676, 290,
1953 181, 182, 183, -440, -440, 187, -440, 134, 33, 93,
1954 -440, -440, -440, -440, -440, 273, 1217, 127, 313, 128,
1955 -440, -440, 254, 446, 1149, 1149, 1149, 1149, 1149, 1149,
1956 1149, 1149, 1149, 1149, 1149, 1149, 1149, -440, 128, -440,
1957 70, -440, -440, -29, 1098, -440, 72, -39, -440, 184,
1958 33, -440, 187, 187, -440, -440, -440, -440, -440, -440,
1959 -440, -440, -440, -440, 188, -440, -440, -440, -440, -440,
1960 -440, -440, -440, -440, -440, -440, -440, -440, -440, -440,
1961 -440, 196, 1055, 1055, 1055, 1055, 1055, -440, -440, 22,
1962 771, -44, -440, -59, -440, 1055, 1055, 1055, -9, -440,
1963 198, -440, 134, 591, -440, 728, 728, -440, 728, 1168,
1964 1149, 1149, 112, 147, -440, 591, 75, 190, 200, 214,
1965 215, 217, 219, 591, 591, 322, 1168, 1149, 1149, -440,
1966 -440, -440, -440, -440, -440, -440, -41, -440, -440, -440,
1967 -41, -440, -440, 1055, 1055, -440, 230, 231, 232, 233,
1968 1055, -440, 225, 850, -43, -440, -440, 236, 241, 337,
1969 355, 371, -440, 187, 1114, -440, -440, -440, -440, -440,
1970 -440, -440, -440, 323, 1055, -440, -440, -440, -440, 243,
1971 -440, 244, 728, 591, 591, 17, -440, 19, -440, -440,
1972 728, 242, 1149, 1149, 1149, 1149, 1149, 245, 246, 1149,
1973 728, 591, 249, -440, -440, -440, 252, 255, -24, 1055,
1974 1055, 1055, 1055, -440, -440, 247, 1055, 1055, 1149, -440,
1975 -440, -440, -440, 33, 257, 260, -440, 375, -37, 383,
1976 386, 264, 268, 272, 728, 400, 728, 275, 282, 728,
1977 284, 33, -440, 295, 296, 728, 728, 33, 270, -440,
1978 1149, 1055, 1055, 1149, -440, 297, 298, 301, 303, -440,
1979 300, 302, 150, 32, 1133, -440, 305, -440, 728, 728,
1980 1149, 728, 728, 307, -440, 307, 728, 311, 1149, 1149,
1981 1149, -440, -440, 1149, 591, 308, 310, -440, 1055, -440,
1982 1055, 1055, -440, -440, -440, -440, -440, -440, 33, 46,
1983 397, 315, 314, 591, 26, -440, -440, 376, -440, -440,
1984 309, 728, -440, -440, -440, 89, -440, -440, -440, 317,
1985 319, 321, 32, -440, 413, -440, 449, 7, -440, 1149,
1986 -440, -440, 324, -440, -440, -440, -440, -440, 460, -440,
1987 728, -440, 976, 9, -29, 591, 149, -440, -41, -440,
1988 -440, 330, -440, 976, -440, 453, 454, 336, -29, 728,
1989 728, 461, 412, -440, 728, 465, -440, 728, -440
1990};
1991
1992/* YYPGOTO[NTERM-NUM]. */
1993static const short int yypgoto[] =
1994{
1995 -440, 358, 359, 361, 274, 276, -206, -440, 0, -19,
1996 401, 13, -440, -440, -440, 31, -440, -440, -178, -309,
1997 -394, -440, -236, -440, -297, -1, -440, -207, -440, -440,
1998 -25, 263, -252, -440, 387, 404, -69, -110, -162, 160,
1999 -440, -440, 490, -440, -440, -440, -440, -440, -440, -440,
2000 -440, -440, -440, -440, 426, -440, -440, -440, -440, -440,
2001 -440, -439, -73, 100, -212, -440, 457, -440, -440, -440,
2002 -440, -440, 40, 135, -440, -440, -440, -440
2003};
2004
2005/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2006 positive, shift that token. If negative, reduce the rule which
2007 number is the opposite. If zero, do what YYDEFACT says.
2008 If YYTABLE_NINF, syntax error. */
2009#define YYTABLE_NINF -178
2010static const short int yytable[] =
2011{
2012 11, 75, 298, 193, 304, 330, 378, 308, 309, 310,
2013 311, 312, 114, 13, 315, 98, 11, 394, 297, 453,
2014 297, 394, 350, 137, 84, 281, 283, 200, 424, 13,
2015 426, 299, 87, 23, 138, 331, 332, 140, 137, 351,
2016 194, -55, -55, -55, -55, 20, 102, 372, 1, 239,
2017 316, 3, 28, 29, 30, 31, 32, 33, 34, 21,
2018 35, 142, 143, 1, 390, 425, 3, 425, 77, 78,
2019 129, 319, 320, 24, 102, 82, 340, 350, 126, 25,
2020 129, 83, 141, 319, 320, 127, 11, 346, 393, 321,
2021 322, 340, 340, 541, 512, 26, 198, 104, 340, 105,
2022 345, 321, 322, 405, 547, 328, 392, 457, 236, 237,
2023 2, 443, 240, 4, 27, 444, 60, 61, 344, 100,
2024 108, 109, 110, 66, 534, 1, 2, 54, 3, 4,
2025 60, 61, 40, 100, 63, 64, 65, 66, 295, 1,
2026 2, 296, 3, 4, 319, 320, 411, 201, 36, 531,
2027 548, 542, 88, 67, 79, 80, 99, 340, 319, 320,
2028 56, 519, 321, 322, 341, 520, 498, 67, 499, 104,
2029 430, 105, 432, 433, 434, 393, 321, 322, 317, 318,
2030 394, 293, 545, 115, 116, 117, 118, 119, 120, 302,
2031 303, 293, 305, 306, 293, 293, 293, 293, 293, 313,
2032 314, 293, 418, 335, 336, 337, 338, 339, 104, 129,
2033 105, 104, 290, 105, 327, 380, 347, 348, 349, 489,
2034 367, 55, 367, 367, 519, 367, 58, 394, 523, 394,
2035 36, 477, 367, 193, 46, 47, 48, 106, 107, 49,
2036 367, 367, 144, 145, 146, 147, 68, 375, 104, 69,
2037 105, 277, 70, 84, 71, 343, 502, 503, 504, 91,
2038 68, 319, 320, 69, 396, 397, 70, 92, 71, 101,
2039 194, 403, 95, 96, 198, 373, 374, 93, 393, 321,
2040 322, 97, 377, 104, 536, 105, 104, 538, 105, 484,
2041 -56, 198, 391, 293, 42, 133, 43, 134, -57, 367,
2042 367, 367, 148, 196, 232, 234, 235, 367, 238, 284,
2043 241, 532, 272, 273, 274, 275, 276, 367, 367, 285,
2044 286, 287, 288, 291, 297, 381, 333, 543, 329, 413,
2045 445, 446, 447, 448, 334, 382, 354, 450, 451, 244,
2046 245, 246, 247, 248, 249, 250, 251, 252, 253, 383,
2047 384, 367, 385, 367, 386, 389, 367, 293, 431, 293,
2048 293, 293, 367, 367, 437, 399, 400, 401, 402, 404,
2049 408, 406, 475, 476, 409, 410, 407, 416, 419, 420,
2050 435, 436, 429, 452, 440, 367, 367, 441, 367, 367,
2051 442, 449, 454, 367, 456, 369, 370, 458, 371, 455,
2052 459, 367, 460, 461, 464, 379, -177, 462, 473, 509,
2053 443, 510, 511, 387, 388, 474, 515, 466, 293, 468,
2054 367, -63, 1, 2, 425, 3, 4, 5, 367, 488,
2055 469, 470, 478, 6, 7, 493, 480, 479, 481, 482,
2056 490, 483, 497, 293, 293, 293, 501, 507, 493, 508,
2057 516, 521, 8, 485, 517, 9, 524, 367, 525, 10,
2058 526, 528, 367, 530, 539, 546, 537, 549, 550, 255,
2059 256, 551, 421, 422, 423, 554, 367, 367, 555, 557,
2060 428, 367, 224, 225, 367, 226, 300, 124, 513, 301,
2061 438, 439, 139, 527, 535, 60, 61, 325, 100, 63,
2062 64, 65, 66, 136, 1, 2, 41, 3, 4, 123,
2063 90, 0, 485, 505, 427, 0, 0, 0, 0, 0,
2064 0, 0, 0, 0, 463, 0, 465, 0, 0, 467,
2065 0, 0, 67, 0, 0, 471, 472, 257, 258, 259,
2066 260, 261, 262, 263, 264, 265, 266, 267, 268, 269,
2067 270, 0, 0, 0, 0, 0, -176, 0, 491, 492,
2068 0, 495, 496, 0, 0, 0, 500, 0, 0, 0,
2069 0, -63, 1, 2, 506, 3, 4, 5, 0, 0,
2070 0, 0, 0, 6, 7, 0, 0, 0, 0, 0,
2071 0, 0, 0, 518, 355, 356, 0, 0, 60, 61,
2072 357, 522, 8, 0, 0, 9, 0, 1, 2, 10,
2073 3, 4, 0, 358, 359, 360, 0, 0, 0, 0,
2074 0, 0, 0, 0, 0, 68, 361, 362, 69, 0,
2075 540, 70, 0, 71, 135, 544, 0, 0, 0, 0,
2076 0, 0, 0, 363, 0, 0, 0, 0, 0, 552,
2077 553, 0, 0, 0, 556, 0, 0, 558, 0, 152,
2078 153, 154, 155, 156, 157, 158, 159, 160, 161, 162,
2079 163, 164, 165, 166, 167, 168, 0, 0, 0, 0,
2080 0, 0, 0, 60, 61, 0, 100, 108, 109, 110,
2081 66, 0, 1, 2, 0, 3, 4, 0, 0, 0,
2082 0, 169, 170, 171, 172, 173, 174, 175, 176, 177,
2083 178, 179, 180, 181, 0, 182, 0, 183, 184, 185,
2084 67, 0, 0, 0, 0, 0, 0, 104, 0, 105,
2085 0, 355, 356, 0, 364, 60, 61, 357, 0, 0,
2086 0, 0, 0, 0, 1, 2, 0, 3, 4, 0,
2087 358, 359, 360, 0, 0, 0, 0, 0, 0, 0,
2088 0, 0, 0, 361, 362, 0, 0, 0, 0, 0,
2089 0, 0, 0, 0, 0, 0, 0, 0, 60, 61,
2090 363, 100, 108, 109, 110, 66, 0, 1, 2, 0,
2091 3, 4, 0, 0, 0, 0, 152, 153, 154, 155,
2092 156, 157, 158, 159, 160, 161, 162, 163, 164, 165,
2093 166, 167, 168, 68, 0, 67, 69, 0, 0, 70,
2094 0, 71, 282, 0, 0, 0, 0, 0, 0, 0,
2095 0, 0, 0, 0, 0, 0, 0, 0, 169, 170,
2096 171, 172, 173, 174, 175, 176, 177, 178, 179, 180,
2097 181, 0, 182, 0, 183, 184, 185, 60, 61, 0,
2098 0, 0, 0, 0, 0, 0, 1, 2, 0, 3,
2099 4, 364, 149, 0, 0, 0, 0, 0, 0, 0,
2100 0, 0, 0, 0, 0, 150, 151, 0, 0, 0,
2101 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2102 60, 61, 0, 62, 63, 64, 65, 66, 68, 1,
2103 2, 69, 3, 4, 70, 0, 71, 342, 152, 153,
2104 154, 155, 156, 157, 158, 159, 160, 161, 162, 163,
2105 164, 165, 166, 167, 168, 0, 0, 67, 0, 0,
2106 0, 0, 0, 0, 0, 0, 60, 61, 0, 100,
2107 63, 64, 65, 66, 0, 1, 2, 0, 3, 4,
2108 169, 170, 171, 172, 173, 174, 175, 176, 177, 178,
2109 179, 180, 181, 128, 182, 0, 183, 184, 185, 355,
2110 356, 0, 0, 67, 0, 357, 104, 0, 105, 0,
2111 186, 0, 0, 187, 0, 188, 0, 189, 358, 359,
2112 360, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2113 0, 361, 362, 0, 0, 0, 0, 0, 0, 0,
2114 0, 0, 0, 0, 0, 0, 0, 0, 363, 0,
2115 68, 0, 0, 69, 0, 0, 70, 0, 71, 0,
2116 0, 0, 0, 0, 152, 153, 154, 155, 156, 157,
2117 158, 159, 160, 161, 162, 163, 164, 165, 166, 167,
2118 168, 0, 60, 61, 0, 100, 108, 109, 110, 66,
2119 0, 1, 2, 0, 3, 4, 68, 0, 0, 69,
2120 0, 0, 70, 0, 71, 0, 169, 170, 171, 172,
2121 173, 174, 175, 176, 177, 178, 179, 180, 181, 67,
2122 182, 0, 183, 184, 185, 60, 61, 0, 100, 63,
2123 64, 65, 66, 0, 1, 2, 0, 3, 4, 364,
2124 0, 60, 61, 0, 100, 63, 64, 65, 66, 0,
2125 1, 2, 324, 3, 4, 0, 0, 0, 0, 0,
2126 60, 61, 67, 100, 63, 64, 65, 66, 412, 1,
2127 2, 0, 3, 4, 0, 0, 60, 61, 67, 100,
2128 63, 64, 65, 66, 0, 1, 2, 487, 3, 4,
2129 0, 0, 0, 0, 0, 60, 61, 67, 197, 63,
2130 64, 65, 66, 0, 1, 2, 0, 3, 4, 0,
2131 0, 0, 68, 67, 0, 69, 0, 0, 70, 0,
2132 71, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2133 60, 61, 67, 100, 108, 109, 110, 66, 0, 1,
2134 2, 0, 3, 4, 60, 61, 0, 292, 63, 64,
2135 65, 66, 0, 1, 2, 68, 3, 4, 69, 0,
2136 0, 70, 0, 71, 0, 0, 0, 67, 0, 0,
2137 0, 68, 0, 0, 69, 0, 0, 70, 0, 71,
2138 0, 67, 0, 0, 0, 0, 0, 0, 0, 0,
2139 68, 0, 0, 69, 0, 0, 70, 0, 71, 0,
2140 0, 0, 0, 0, 0, 0, 68, 0, 0, 69,
2141 0, 0, 70, 0, 71, 0, 0, 0, 0, 0,
2142 0, 0, 0, 0, 0, 68, 0, 0, 69, 0,
2143 0, 70, 0, 71, 0, 0, 0, 0, 0, 0,
2144 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2145 0, 0, 0, 203, 0, 0, 0, 0, 0, 0,
2146 68, 0, 0, 69, 0, 0, 70, 0, 280, 0,
2147 0, 204, 205, 0, 68, 0, 0, 69, 0, 0,
2148 70, 0, 71, 206, 207, 208, 209, 210, 211, 152,
2149 153, 154, 155, 156, 157, 158, 159, 160, 161, 162,
2150 163, 164, 165, 166, 212, 213, 0, 0, 0, 0,
2151 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2152 0, 0, 0, 0, 0, 0, 214, 215, 216, 0,
2153 0, 217, 170, 171, 172, 173, 174, 175, 176, 177,
2154 178, 179, 180, 181, 218, 219, 220, 221, 222, 223
2155};
2156
2157static const short int yycheck[] =
2158{
2159 0, 26, 208, 113, 216, 241, 303, 219, 220, 221,
2160 222, 223, 81, 0, 226, 4, 16, 326, 11, 413,
2161 11, 330, 31, 135, 18, 187, 188, 25, 11, 16,
2162 11, 209, 26, 134, 146, 242, 243, 106, 135, 48,
2163 113, 3, 4, 5, 6, 47, 71, 299, 16, 146,
2164 228, 19, 37, 38, 39, 40, 41, 42, 43, 61,
2165 45, 23, 24, 16, 316, 48, 19, 48, 37, 38,
2166 95, 112, 113, 52, 99, 44, 135, 31, 135, 134,
2167 105, 50, 107, 112, 113, 142, 86, 146, 129, 130,
2168 131, 135, 135, 532, 488, 15, 121, 136, 135, 138,
2169 144, 130, 131, 146, 543, 144, 318, 144, 133, 134,
2170 17, 135, 137, 20, 134, 139, 7, 8, 280, 10,
2171 11, 12, 13, 14, 518, 16, 17, 134, 19, 20,
2172 7, 8, 0, 10, 11, 12, 13, 14, 11, 16,
2173 17, 14, 19, 20, 112, 113, 353, 145, 133, 142,
2174 544, 142, 146, 44, 29, 30, 145, 135, 112, 113,
2175 140, 135, 130, 131, 142, 139, 463, 44, 465, 136,
2176 382, 138, 384, 385, 386, 129, 130, 131, 108, 109,
2177 489, 206, 33, 55, 56, 57, 58, 59, 60, 214,
2178 215, 216, 217, 218, 219, 220, 221, 222, 223, 224,
2179 225, 226, 364, 272, 273, 274, 275, 276, 136, 234,
2180 138, 136, 199, 138, 142, 140, 285, 286, 287, 455,
2181 293, 134, 295, 296, 135, 298, 19, 536, 139, 538,
2182 133, 443, 305, 343, 37, 38, 39, 77, 78, 42,
2183 313, 314, 3, 4, 5, 6, 137, 135, 136, 140,
2184 138, 142, 143, 18, 145, 280, 468, 469, 470, 19,
2185 137, 112, 113, 140, 333, 334, 143, 19, 145, 146,
2186 343, 340, 138, 4, 299, 300, 301, 19, 129, 130,
2187 131, 4, 135, 136, 520, 138, 136, 523, 138, 139,
2188 9, 316, 317, 318, 41, 141, 43, 141, 9, 372,
2189 373, 374, 9, 4, 19, 135, 139, 380, 144, 19,
2190 139, 517, 138, 138, 138, 138, 138, 390, 391, 138,
2191 138, 138, 135, 50, 11, 135, 138, 533, 144, 354,
2192 399, 400, 401, 402, 138, 135, 138, 406, 407, 85,
2193 86, 87, 88, 89, 90, 91, 92, 93, 94, 135,
2194 135, 424, 135, 426, 135, 33, 429, 382, 383, 384,
2195 385, 386, 435, 436, 389, 135, 135, 135, 135, 144,
2196 33, 135, 441, 442, 19, 4, 135, 54, 135, 135,
2197 135, 135, 140, 408, 135, 458, 459, 135, 461, 462,
2198 135, 144, 135, 466, 19, 295, 296, 14, 298, 139,
2199 14, 474, 138, 135, 4, 305, 0, 135, 138, 478,
2200 135, 480, 481, 313, 314, 440, 19, 135, 443, 135,
2201 493, 15, 16, 17, 48, 19, 20, 21, 501, 454,
2202 135, 135, 135, 27, 28, 460, 135, 139, 135, 139,
2203 135, 139, 135, 468, 469, 470, 135, 139, 473, 139,
2204 135, 142, 46, 453, 140, 49, 139, 530, 139, 53,
2205 139, 48, 535, 14, 4, 135, 142, 14, 14, 23,
2206 24, 135, 372, 373, 374, 14, 549, 550, 66, 14,
2207 380, 554, 124, 124, 557, 124, 212, 86, 489, 213,
2208 390, 391, 105, 512, 519, 7, 8, 234, 10, 11,
2209 12, 13, 14, 99, 16, 17, 16, 19, 20, 83,
2210 53, -1, 512, 473, 379, -1, -1, -1, -1, -1,
2211 -1, -1, -1, -1, 424, -1, 426, -1, -1, 429,
2212 -1, -1, 44, -1, -1, 435, 436, 91, 92, 93,
2213 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
2214 104, -1, -1, -1, -1, -1, 0, -1, 458, 459,
2215 -1, 461, 462, -1, -1, -1, 466, -1, -1, -1,
2216 -1, 15, 16, 17, 474, 19, 20, 21, -1, -1,
2217 -1, -1, -1, 27, 28, -1, -1, -1, -1, -1,
2218 -1, -1, -1, 493, 3, 4, -1, -1, 7, 8,
2219 9, 501, 46, -1, -1, 49, -1, 16, 17, 53,
2220 19, 20, -1, 22, 23, 24, -1, -1, -1, -1,
2221 -1, -1, -1, -1, -1, 137, 35, 36, 140, -1,
2222 530, 143, -1, 145, 146, 535, -1, -1, -1, -1,
2223 -1, -1, -1, 52, -1, -1, -1, -1, -1, 549,
2224 550, -1, -1, -1, 554, -1, -1, 557, -1, 68,
2225 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
2226 79, 80, 81, 82, 83, 84, -1, -1, -1, -1,
2227 -1, -1, -1, 7, 8, -1, 10, 11, 12, 13,
2228 14, -1, 16, 17, -1, 19, 20, -1, -1, -1,
2229 -1, 110, 111, 112, 113, 114, 115, 116, 117, 118,
2230 119, 120, 121, 122, -1, 124, -1, 126, 127, 128,
2231 44, -1, -1, -1, -1, -1, -1, 136, -1, 138,
2232 -1, 3, 4, -1, 143, 7, 8, 9, -1, -1,
2233 -1, -1, -1, -1, 16, 17, -1, 19, 20, -1,
2234 22, 23, 24, -1, -1, -1, -1, -1, -1, -1,
2235 -1, -1, -1, 35, 36, -1, -1, -1, -1, -1,
2236 -1, -1, -1, -1, -1, -1, -1, -1, 7, 8,
2237 52, 10, 11, 12, 13, 14, -1, 16, 17, -1,
2238 19, 20, -1, -1, -1, -1, 68, 69, 70, 71,
2239 72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
2240 82, 83, 84, 137, -1, 44, 140, -1, -1, 143,
2241 -1, 145, 146, -1, -1, -1, -1, -1, -1, -1,
2242 -1, -1, -1, -1, -1, -1, -1, -1, 110, 111,
2243 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
2244 122, -1, 124, -1, 126, 127, 128, 7, 8, -1,
2245 -1, -1, -1, -1, -1, -1, 16, 17, -1, 19,
2246 20, 143, 22, -1, -1, -1, -1, -1, -1, -1,
2247 -1, -1, -1, -1, -1, 35, 36, -1, -1, -1,
2248 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2249 7, 8, -1, 10, 11, 12, 13, 14, 137, 16,
2250 17, 140, 19, 20, 143, -1, 145, 146, 68, 69,
2251 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
2252 80, 81, 82, 83, 84, -1, -1, 44, -1, -1,
2253 -1, -1, -1, -1, -1, -1, 7, 8, -1, 10,
2254 11, 12, 13, 14, -1, 16, 17, -1, 19, 20,
2255 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
2256 120, 121, 122, 34, 124, -1, 126, 127, 128, 3,
2257 4, -1, -1, 44, -1, 9, 136, -1, 138, -1,
2258 140, -1, -1, 143, -1, 145, -1, 147, 22, 23,
2259 24, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2260 -1, 35, 36, -1, -1, -1, -1, -1, -1, -1,
2261 -1, -1, -1, -1, -1, -1, -1, -1, 52, -1,
2262 137, -1, -1, 140, -1, -1, 143, -1, 145, -1,
2263 -1, -1, -1, -1, 68, 69, 70, 71, 72, 73,
2264 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2265 84, -1, 7, 8, -1, 10, 11, 12, 13, 14,
2266 -1, 16, 17, -1, 19, 20, 137, -1, -1, 140,
2267 -1, -1, 143, -1, 145, -1, 110, 111, 112, 113,
2268 114, 115, 116, 117, 118, 119, 120, 121, 122, 44,
2269 124, -1, 126, 127, 128, 7, 8, -1, 10, 11,
2270 12, 13, 14, -1, 16, 17, -1, 19, 20, 143,
2271 -1, 7, 8, -1, 10, 11, 12, 13, 14, -1,
2272 16, 17, 34, 19, 20, -1, -1, -1, -1, -1,
2273 7, 8, 44, 10, 11, 12, 13, 14, 34, 16,
2274 17, -1, 19, 20, -1, -1, 7, 8, 44, 10,
2275 11, 12, 13, 14, -1, 16, 17, 34, 19, 20,
2276 -1, -1, -1, -1, -1, 7, 8, 44, 10, 11,
2277 12, 13, 14, -1, 16, 17, -1, 19, 20, -1,
2278 -1, -1, 137, 44, -1, 140, -1, -1, 143, -1,
2279 145, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2280 7, 8, 44, 10, 11, 12, 13, 14, -1, 16,
2281 17, -1, 19, 20, 7, 8, -1, 10, 11, 12,
2282 13, 14, -1, 16, 17, 137, 19, 20, 140, -1,
2283 -1, 143, -1, 145, -1, -1, -1, 44, -1, -1,
2284 -1, 137, -1, -1, 140, -1, -1, 143, -1, 145,
2285 -1, 44, -1, -1, -1, -1, -1, -1, -1, -1,
2286 137, -1, -1, 140, -1, -1, 143, -1, 145, -1,
2287 -1, -1, -1, -1, -1, -1, 137, -1, -1, 140,
2288 -1, -1, 143, -1, 145, -1, -1, -1, -1, -1,
2289 -1, -1, -1, -1, -1, 137, -1, -1, 140, -1,
2290 -1, 143, -1, 145, -1, -1, -1, -1, -1, -1,
2291 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2292 -1, -1, -1, 32, -1, -1, -1, -1, -1, -1,
2293 137, -1, -1, 140, -1, -1, 143, -1, 145, -1,
2294 -1, 50, 51, -1, 137, -1, -1, 140, -1, -1,
2295 143, -1, 145, 62, 63, 64, 65, 66, 67, 68,
2296 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
2297 79, 80, 81, 82, 83, 84, -1, -1, -1, -1,
2298 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2299 -1, -1, -1, -1, -1, -1, 105, 106, 107, -1,
2300 -1, 110, 111, 112, 113, 114, 115, 116, 117, 118,
2301 119, 120, 121, 122, 123, 124, 125, 126, 127, 128
2302};
2303
2304/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2305 symbol of state STATE-NUM. */
2306static const unsigned char yystos[] =
2307{
2308 0, 16, 17, 19, 20, 21, 27, 28, 46, 49,
2309 53, 156, 158, 159, 160, 188, 189, 190, 192, 191,
2310 47, 61, 197, 134, 52, 134, 15, 134, 37, 38,
2311 39, 40, 41, 42, 43, 45, 133, 161, 162, 163,
2312 0, 190, 41, 43, 164, 207, 37, 38, 39, 42,
2313 165, 204, 206, 213, 134, 134, 140, 198, 19, 196,
2314 7, 8, 10, 11, 12, 13, 14, 44, 137, 140,
2315 143, 145, 156, 159, 177, 178, 210, 163, 163, 29,
2316 30, 187, 163, 163, 18, 214, 215, 26, 146, 205,
2317 214, 19, 19, 19, 199, 138, 4, 4, 4, 145,
2318 10, 146, 178, 183, 136, 138, 187, 187, 11, 12,
2319 13, 154, 155, 178, 184, 55, 56, 57, 58, 59,
2320 60, 166, 202, 202, 158, 218, 135, 142, 34, 178,
2321 179, 181, 182, 141, 141, 146, 183, 135, 146, 182,
2322 184, 178, 23, 24, 3, 4, 5, 6, 9, 22,
2323 35, 36, 68, 69, 70, 71, 72, 73, 74, 75,
2324 76, 77, 78, 79, 80, 81, 82, 83, 84, 110,
2325 111, 112, 113, 114, 115, 116, 117, 118, 119, 120,
2326 121, 122, 124, 126, 127, 128, 140, 143, 145, 147,
2327 149, 150, 151, 185, 210, 193, 4, 10, 178, 180,
2328 25, 145, 203, 32, 50, 51, 62, 63, 64, 65,
2329 66, 67, 83, 84, 105, 106, 107, 110, 123, 124,
2330 125, 126, 127, 128, 149, 150, 151, 216, 222, 223,
2331 224, 225, 19, 168, 135, 139, 178, 178, 144, 146,
2332 178, 139, 194, 195, 85, 86, 87, 88, 89, 90,
2333 91, 92, 93, 94, 152, 23, 24, 91, 92, 93,
2334 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
2335 104, 153, 138, 138, 138, 138, 138, 142, 184, 186,
2336 145, 186, 146, 186, 19, 138, 138, 138, 135, 175,
2337 159, 50, 10, 178, 212, 11, 14, 11, 154, 166,
2338 152, 153, 178, 178, 212, 178, 178, 219, 212, 212,
2339 212, 212, 212, 178, 178, 212, 166, 108, 109, 112,
2340 113, 130, 131, 167, 34, 179, 170, 142, 144, 144,
2341 170, 175, 175, 138, 138, 184, 184, 184, 184, 184,
2342 135, 142, 146, 178, 186, 144, 146, 184, 184, 184,
2343 31, 48, 173, 176, 138, 3, 4, 9, 22, 23,
2344 24, 35, 36, 52, 143, 185, 209, 210, 211, 211,
2345 211, 211, 180, 178, 178, 135, 172, 135, 172, 211,
2346 140, 135, 135, 135, 135, 135, 135, 211, 211, 33,
2347 180, 178, 212, 129, 167, 169, 184, 184, 221, 135,
2348 135, 135, 135, 184, 144, 146, 135, 135, 33, 19,
2349 4, 175, 34, 178, 200, 201, 54, 208, 186, 135,
2350 135, 211, 211, 211, 11, 48, 11, 221, 211, 140,
2351 212, 178, 212, 212, 212, 135, 135, 178, 211, 211,
2352 135, 135, 135, 135, 139, 184, 184, 184, 184, 144,
2353 184, 184, 178, 168, 135, 139, 19, 144, 14, 14,
2354 138, 135, 135, 211, 4, 211, 135, 211, 135, 135,
2355 135, 211, 211, 138, 178, 184, 184, 212, 135, 139,
2356 135, 135, 139, 139, 139, 156, 157, 34, 178, 170,
2357 135, 211, 211, 178, 220, 211, 211, 135, 172, 172,
2358 211, 135, 212, 212, 212, 220, 211, 139, 139, 184,
2359 184, 184, 168, 173, 174, 19, 135, 140, 211, 135,
2360 139, 142, 211, 139, 139, 139, 139, 157, 48, 171,
2361 14, 142, 154, 217, 168, 178, 170, 142, 170, 4,
2362 211, 209, 142, 154, 211, 33, 135, 209, 168, 14,
2363 14, 135, 211, 211, 14, 66, 211, 14, 211
2364};
Reid Spencer68a24bd2005-08-27 18:50:39 +00002365
2366#define yyerrok (yyerrstatus = 0)
2367#define yyclearin (yychar = YYEMPTY)
Reid Spencer38c91a92007-02-28 02:24:54 +00002368#define YYEMPTY (-2)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002369#define YYEOF 0
Reid Spencer38c91a92007-02-28 02:24:54 +00002370
Reid Spencer68a24bd2005-08-27 18:50:39 +00002371#define YYACCEPT goto yyacceptlab
Reid Spencer38c91a92007-02-28 02:24:54 +00002372#define YYABORT goto yyabortlab
2373#define YYERROR goto yyerrorlab
2374
2375
2376/* Like YYERROR except do call yyerror. This remains here temporarily
2377 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002378 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer38c91a92007-02-28 02:24:54 +00002379
Reid Spencer68a24bd2005-08-27 18:50:39 +00002380#define YYFAIL goto yyerrlab
Reid Spencer38c91a92007-02-28 02:24:54 +00002381
Reid Spencer68a24bd2005-08-27 18:50:39 +00002382#define YYRECOVERING() (!!yyerrstatus)
Reid Spencer38c91a92007-02-28 02:24:54 +00002383
2384#define YYBACKUP(Token, Value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002385do \
2386 if (yychar == YYEMPTY && yylen == 1) \
Reid Spencer38c91a92007-02-28 02:24:54 +00002387 { \
2388 yychar = (Token); \
2389 yylval = (Value); \
2390 yytoken = YYTRANSLATE (yychar); \
Chris Lattner9d2fda62007-02-13 05:53:56 +00002391 YYPOPSTACK; \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002392 goto yybackup; \
2393 } \
2394 else \
Reid Spencer38c91a92007-02-28 02:24:54 +00002395 { \
2396 yyerror (YY_("syntax error: cannot back up")); \
2397 YYERROR; \
2398 } \
Chris Lattner9d2fda62007-02-13 05:53:56 +00002399while (0)
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002400
Reid Spencer38c91a92007-02-28 02:24:54 +00002401
Reid Spencer68a24bd2005-08-27 18:50:39 +00002402#define YYTERROR 1
2403#define YYERRCODE 256
2404
Reid Spencer38c91a92007-02-28 02:24:54 +00002405
2406/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2407 If N is 0, then set CURRENT to the empty location which ends
2408 the previous symbol: RHS[0] (always defined). */
2409
2410#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2411#ifndef YYLLOC_DEFAULT
2412# define YYLLOC_DEFAULT(Current, Rhs, N) \
2413 do \
2414 if (N) \
2415 { \
2416 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2417 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2418 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2419 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2420 } \
2421 else \
2422 { \
2423 (Current).first_line = (Current).last_line = \
2424 YYRHSLOC (Rhs, 0).last_line; \
2425 (Current).first_column = (Current).last_column = \
2426 YYRHSLOC (Rhs, 0).last_column; \
2427 } \
2428 while (0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002429#endif
2430
Reid Spencer38c91a92007-02-28 02:24:54 +00002431
2432/* YY_LOCATION_PRINT -- Print the location on the stream.
2433 This macro was not mandated originally: define only if we know
2434 we won't break user code: when these are the locations we know. */
2435
2436#ifndef YY_LOCATION_PRINT
2437# if YYLTYPE_IS_TRIVIAL
2438# define YY_LOCATION_PRINT(File, Loc) \
2439 fprintf (File, "%d.%d-%d.%d", \
2440 (Loc).first_line, (Loc).first_column, \
2441 (Loc).last_line, (Loc).last_column)
2442# else
2443# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2444# endif
2445#endif
2446
2447
2448/* YYLEX -- calling `yylex' with the right arguments. */
2449
Reid Spencer41dff5e2007-01-26 08:05:27 +00002450#ifdef YYLEX_PARAM
Reid Spencer38c91a92007-02-28 02:24:54 +00002451# define YYLEX yylex (YYLEX_PARAM)
Reid Spencer41dff5e2007-01-26 08:05:27 +00002452#else
Reid Spencer38c91a92007-02-28 02:24:54 +00002453# define YYLEX yylex ()
Chris Lattner32980692007-02-19 07:44:24 +00002454#endif
Reid Spencer38c91a92007-02-28 02:24:54 +00002455
2456/* Enable debugging if requested. */
2457#if YYDEBUG
2458
2459# ifndef YYFPRINTF
2460# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2461# define YYFPRINTF fprintf
2462# endif
2463
2464# define YYDPRINTF(Args) \
2465do { \
2466 if (yydebug) \
2467 YYFPRINTF Args; \
2468} while (0)
2469
2470# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2471do { \
2472 if (yydebug) \
2473 { \
2474 YYFPRINTF (stderr, "%s ", Title); \
2475 yysymprint (stderr, \
2476 Type, Value); \
2477 YYFPRINTF (stderr, "\n"); \
2478 } \
2479} while (0)
2480
2481/*------------------------------------------------------------------.
2482| yy_stack_print -- Print the state stack from its BOTTOM up to its |
2483| TOP (included). |
2484`------------------------------------------------------------------*/
2485
2486#if defined (__STDC__) || defined (__cplusplus)
2487static void
2488yy_stack_print (short int *bottom, short int *top)
Chris Lattner32980692007-02-19 07:44:24 +00002489#else
Reid Spencer38c91a92007-02-28 02:24:54 +00002490static void
2491yy_stack_print (bottom, top)
2492 short int *bottom;
2493 short int *top;
Chris Lattner32980692007-02-19 07:44:24 +00002494#endif
Reid Spencer38c91a92007-02-28 02:24:54 +00002495{
2496 YYFPRINTF (stderr, "Stack now");
2497 for (/* Nothing. */; bottom <= top; ++bottom)
2498 YYFPRINTF (stderr, " %d", *bottom);
2499 YYFPRINTF (stderr, "\n");
2500}
2501
2502# define YY_STACK_PRINT(Bottom, Top) \
2503do { \
2504 if (yydebug) \
2505 yy_stack_print ((Bottom), (Top)); \
2506} while (0)
2507
2508
2509/*------------------------------------------------.
2510| Report that the YYRULE is going to be reduced. |
2511`------------------------------------------------*/
2512
2513#if defined (__STDC__) || defined (__cplusplus)
2514static void
2515yy_reduce_print (int yyrule)
2516#else
2517static void
2518yy_reduce_print (yyrule)
2519 int yyrule;
Chris Lattner9d2fda62007-02-13 05:53:56 +00002520#endif
Reid Spencer38c91a92007-02-28 02:24:54 +00002521{
2522 int yyi;
2523 unsigned long int yylno = yyrline[yyrule];
2524 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
2525 yyrule - 1, yylno);
2526 /* Print the symbols being reduced, and their result. */
2527 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
2528 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
2529 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
2530}
Reid Spencer9d6565a2007-02-15 02:26:10 +00002531
Reid Spencer38c91a92007-02-28 02:24:54 +00002532# define YY_REDUCE_PRINT(Rule) \
2533do { \
2534 if (yydebug) \
2535 yy_reduce_print (Rule); \
2536} while (0)
Reid Spencer9d6565a2007-02-15 02:26:10 +00002537
Reid Spencer38c91a92007-02-28 02:24:54 +00002538/* Nonzero means print parse trace. It is left uninitialized so that
2539 multiple parsers can coexist. */
2540int yydebug;
2541#else /* !YYDEBUG */
2542# define YYDPRINTF(Args)
2543# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
2544# define YY_STACK_PRINT(Bottom, Top)
2545# define YY_REDUCE_PRINT(Rule)
2546#endif /* !YYDEBUG */
Reid Spencer9d6565a2007-02-15 02:26:10 +00002547
Reid Spencer9d6565a2007-02-15 02:26:10 +00002548
Reid Spencer38c91a92007-02-28 02:24:54 +00002549/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002550#ifndef YYINITDEPTH
Reid Spencer38c91a92007-02-28 02:24:54 +00002551# define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00002552#endif
2553
Reid Spencer38c91a92007-02-28 02:24:54 +00002554/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2555 if the built-in stack extension method is used).
Reid Spencer68a24bd2005-08-27 18:50:39 +00002556
Reid Spencer38c91a92007-02-28 02:24:54 +00002557 Do not make this value too large; the results are undefined if
2558 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
2559 evaluated with infinite-precision integer arithmetic. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002560
2561#ifndef YYMAXDEPTH
Reid Spencer38c91a92007-02-28 02:24:54 +00002562# define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00002563#endif
Reid Spencer38c91a92007-02-28 02:24:54 +00002564
Reid Spencer68a24bd2005-08-27 18:50:39 +00002565
2566
Reid Spencer38c91a92007-02-28 02:24:54 +00002567#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00002568
Reid Spencer38c91a92007-02-28 02:24:54 +00002569# ifndef yystrlen
2570# if defined (__GLIBC__) && defined (_STRING_H)
2571# define yystrlen strlen
2572# else
2573/* Return the length of YYSTR. */
2574static YYSIZE_T
2575# if defined (__STDC__) || defined (__cplusplus)
2576yystrlen (const char *yystr)
2577# else
2578yystrlen (yystr)
2579 const char *yystr;
2580# endif
Chris Lattner32980692007-02-19 07:44:24 +00002581{
Reid Spencer38c91a92007-02-28 02:24:54 +00002582 const char *yys = yystr;
Chris Lattner32980692007-02-19 07:44:24 +00002583
Reid Spencer38c91a92007-02-28 02:24:54 +00002584 while (*yys++ != '\0')
2585 continue;
2586
2587 return yys - yystr - 1;
Chris Lattner32980692007-02-19 07:44:24 +00002588}
Reid Spencer38c91a92007-02-28 02:24:54 +00002589# endif
2590# endif
Chris Lattner32980692007-02-19 07:44:24 +00002591
Reid Spencer38c91a92007-02-28 02:24:54 +00002592# ifndef yystpcpy
2593# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
2594# define yystpcpy stpcpy
2595# else
2596/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2597 YYDEST. */
2598static char *
2599# if defined (__STDC__) || defined (__cplusplus)
2600yystpcpy (char *yydest, const char *yysrc)
2601# else
2602yystpcpy (yydest, yysrc)
2603 char *yydest;
2604 const char *yysrc;
2605# endif
Chris Lattner32980692007-02-19 07:44:24 +00002606{
Reid Spencer38c91a92007-02-28 02:24:54 +00002607 char *yyd = yydest;
2608 const char *yys = yysrc;
Chris Lattner32980692007-02-19 07:44:24 +00002609
Reid Spencer38c91a92007-02-28 02:24:54 +00002610 while ((*yyd++ = *yys++) != '\0')
2611 continue;
2612
2613 return yyd - 1;
Chris Lattner32980692007-02-19 07:44:24 +00002614}
Reid Spencer38c91a92007-02-28 02:24:54 +00002615# endif
2616# endif
Chris Lattner32980692007-02-19 07:44:24 +00002617
Reid Spencer38c91a92007-02-28 02:24:54 +00002618# ifndef yytnamerr
2619/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
2620 quotes and backslashes, so that it's suitable for yyerror. The
2621 heuristic is that double-quoting is unnecessary unless the string
2622 contains an apostrophe, a comma, or backslash (other than
2623 backslash-backslash). YYSTR is taken from yytname. If YYRES is
2624 null, do not copy; instead, return the length of what the result
2625 would have been. */
2626static YYSIZE_T
2627yytnamerr (char *yyres, const char *yystr)
2628{
2629 if (*yystr == '"')
2630 {
2631 size_t yyn = 0;
2632 char const *yyp = yystr;
2633
2634 for (;;)
2635 switch (*++yyp)
2636 {
2637 case '\'':
2638 case ',':
2639 goto do_not_strip_quotes;
2640
2641 case '\\':
2642 if (*++yyp != '\\')
2643 goto do_not_strip_quotes;
2644 /* Fall through. */
2645 default:
2646 if (yyres)
2647 yyres[yyn] = *yyp;
2648 yyn++;
2649 break;
2650
2651 case '"':
2652 if (yyres)
2653 yyres[yyn] = '\0';
2654 return yyn;
2655 }
2656 do_not_strip_quotes: ;
2657 }
2658
2659 if (! yyres)
2660 return yystrlen (yystr);
2661
2662 return yystpcpy (yyres, yystr) - yyres;
2663}
2664# endif
2665
2666#endif /* YYERROR_VERBOSE */
2667
Reid Spencer9d6565a2007-02-15 02:26:10 +00002668
2669
Reid Spencer38c91a92007-02-28 02:24:54 +00002670#if YYDEBUG
2671/*--------------------------------.
2672| Print this symbol on YYOUTPUT. |
2673`--------------------------------*/
Reid Spencer9d6565a2007-02-15 02:26:10 +00002674
Reid Spencer38c91a92007-02-28 02:24:54 +00002675#if defined (__STDC__) || defined (__cplusplus)
2676static void
2677yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
Chris Lattner32980692007-02-19 07:44:24 +00002678#else
Reid Spencer38c91a92007-02-28 02:24:54 +00002679static void
2680yysymprint (yyoutput, yytype, yyvaluep)
2681 FILE *yyoutput;
2682 int yytype;
2683 YYSTYPE *yyvaluep;
2684#endif
2685{
2686 /* Pacify ``unused variable'' warnings. */
2687 (void) yyvaluep;
2688
2689 if (yytype < YYNTOKENS)
2690 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2691 else
2692 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
2693
2694
2695# ifdef YYPRINT
2696 if (yytype < YYNTOKENS)
2697 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2698# endif
2699 switch (yytype)
2700 {
2701 default:
2702 break;
2703 }
2704 YYFPRINTF (yyoutput, ")");
2705}
2706
2707#endif /* ! YYDEBUG */
2708/*-----------------------------------------------.
2709| Release the memory associated to this symbol. |
2710`-----------------------------------------------*/
2711
2712#if defined (__STDC__) || defined (__cplusplus)
2713static void
2714yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
2715#else
2716static void
2717yydestruct (yymsg, yytype, yyvaluep)
2718 const char *yymsg;
2719 int yytype;
2720 YYSTYPE *yyvaluep;
2721#endif
2722{
2723 /* Pacify ``unused variable'' warnings. */
2724 (void) yyvaluep;
2725
2726 if (!yymsg)
2727 yymsg = "Deleting";
2728 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
2729
2730 switch (yytype)
2731 {
2732
2733 default:
2734 break;
2735 }
2736}
2737
2738
2739/* Prevent warnings from -Wmissing-prototypes. */
2740
2741#ifdef YYPARSE_PARAM
2742# if defined (__STDC__) || defined (__cplusplus)
2743int yyparse (void *YYPARSE_PARAM);
2744# else
2745int yyparse ();
2746# endif
2747#else /* ! YYPARSE_PARAM */
2748#if defined (__STDC__) || defined (__cplusplus)
Reid Spencere812fb22006-01-19 01:21:04 +00002749int yyparse (void);
Chris Lattner32980692007-02-19 07:44:24 +00002750#else
Reid Spencer38c91a92007-02-28 02:24:54 +00002751int yyparse ();
2752#endif
2753#endif /* ! YYPARSE_PARAM */
2754
2755
2756
2757/* The look-ahead symbol. */
2758int yychar;
2759
2760/* The semantic value of the look-ahead symbol. */
2761YYSTYPE yylval;
2762
2763/* Number of syntax errors so far. */
2764int yynerrs;
2765
2766
2767
2768/*----------.
2769| yyparse. |
2770`----------*/
2771
2772#ifdef YYPARSE_PARAM
2773# if defined (__STDC__) || defined (__cplusplus)
2774int yyparse (void *YYPARSE_PARAM)
2775# else
2776int yyparse (YYPARSE_PARAM)
2777 void *YYPARSE_PARAM;
2778# endif
2779#else /* ! YYPARSE_PARAM */
2780#if defined (__STDC__) || defined (__cplusplus)
2781int
2782yyparse (void)
2783#else
2784int
2785yyparse ()
2786
2787#endif
2788#endif
2789{
2790
2791 int yystate;
2792 int yyn;
2793 int yyresult;
2794 /* Number of tokens to shift before error messages enabled. */
2795 int yyerrstatus;
2796 /* Look-ahead token as an internal (translated) token number. */
2797 int yytoken = 0;
2798
2799 /* Three stacks and their tools:
2800 `yyss': related to states,
2801 `yyvs': related to semantic values,
2802 `yyls': related to locations.
2803
2804 Refer to the stacks thru separate pointers, to allow yyoverflow
2805 to reallocate them elsewhere. */
2806
2807 /* The state stack. */
2808 short int yyssa[YYINITDEPTH];
2809 short int *yyss = yyssa;
2810 short int *yyssp;
2811
2812 /* The semantic value stack. */
2813 YYSTYPE yyvsa[YYINITDEPTH];
2814 YYSTYPE *yyvs = yyvsa;
2815 YYSTYPE *yyvsp;
2816
2817
2818
Chris Lattner9d2fda62007-02-13 05:53:56 +00002819#define YYPOPSTACK (yyvsp--, yyssp--)
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002820
Reid Spencer38c91a92007-02-28 02:24:54 +00002821 YYSIZE_T yystacksize = YYINITDEPTH;
Chris Lattner7d9801d2007-02-13 00:58:01 +00002822
Reid Spencer38c91a92007-02-28 02:24:54 +00002823 /* The variables used to return semantic value and location from the
2824 action routines. */
2825 YYSTYPE yyval;
Chris Lattner7d9801d2007-02-13 00:58:01 +00002826
Chris Lattner7d9801d2007-02-13 00:58:01 +00002827
Reid Spencer38c91a92007-02-28 02:24:54 +00002828 /* When reducing, the number of symbols on the RHS of the reduced
2829 rule. */
Chris Lattner9d2fda62007-02-13 05:53:56 +00002830 int yylen;
Chris Lattner7d9801d2007-02-13 00:58:01 +00002831
Reid Spencer38c91a92007-02-28 02:24:54 +00002832 YYDPRINTF ((stderr, "Starting parse\n"));
Chris Lattner7d9801d2007-02-13 00:58:01 +00002833
Reid Spencer68a24bd2005-08-27 18:50:39 +00002834 yystate = 0;
2835 yyerrstatus = 0;
2836 yynerrs = 0;
2837 yychar = YYEMPTY; /* Cause a token to be read. */
2838
2839 /* Initialize stack pointers.
2840 Waste one element of value and location stack
2841 so that they stay on the same level as the state stack.
2842 The wasted elements are never initialized. */
2843
Reid Spencer38c91a92007-02-28 02:24:54 +00002844 yyssp = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002845 yyvsp = yyvs;
2846
Reid Spencer38c91a92007-02-28 02:24:54 +00002847 goto yysetstate;
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002848
Reid Spencer38c91a92007-02-28 02:24:54 +00002849/*------------------------------------------------------------.
2850| yynewstate -- Push a new state, which is found in yystate. |
2851`------------------------------------------------------------*/
2852 yynewstate:
2853 /* In all cases, when you get here, the value and location stacks
2854 have just been pushed. so pushing a state here evens the stacks.
2855 */
2856 yyssp++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002857
Reid Spencer38c91a92007-02-28 02:24:54 +00002858 yysetstate:
2859 *yyssp = yystate;
2860
2861 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002862 {
2863 /* Get the current used size of the three stacks, in elements. */
Reid Spencer38c91a92007-02-28 02:24:54 +00002864 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002865
2866#ifdef yyoverflow
Reid Spencer38c91a92007-02-28 02:24:54 +00002867 {
2868 /* Give user a chance to reallocate the stack. Use copies of
2869 these so that the &'s don't force the real ones into
2870 memory. */
2871 YYSTYPE *yyvs1 = yyvs;
2872 short int *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002873
Reid Spencer38c91a92007-02-28 02:24:54 +00002874
2875 /* Each stack pointer address is followed by the size of the
2876 data in use in that stack, in bytes. This used to be a
2877 conditional around just the two extra args, but that might
2878 be undefined if yyoverflow is a macro. */
2879 yyoverflow (YY_("memory exhausted"),
2880 &yyss1, yysize * sizeof (*yyssp),
2881 &yyvs1, yysize * sizeof (*yyvsp),
2882
2883 &yystacksize);
2884
2885 yyss = yyss1;
2886 yyvs = yyvs1;
2887 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002888#else /* no yyoverflow */
Reid Spencer38c91a92007-02-28 02:24:54 +00002889# ifndef YYSTACK_RELOCATE
2890 goto yyexhaustedlab;
2891# else
Reid Spencer68a24bd2005-08-27 18:50:39 +00002892 /* Extend the stack our own way. */
Reid Spencer38c91a92007-02-28 02:24:54 +00002893 if (YYMAXDEPTH <= yystacksize)
2894 goto yyexhaustedlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002895 yystacksize *= 2;
Reid Spencer38c91a92007-02-28 02:24:54 +00002896 if (YYMAXDEPTH < yystacksize)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002897 yystacksize = YYMAXDEPTH;
Reid Spencer38c91a92007-02-28 02:24:54 +00002898
2899 {
2900 short int *yyss1 = yyss;
2901 union yyalloc *yyptr =
2902 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
2903 if (! yyptr)
2904 goto yyexhaustedlab;
2905 YYSTACK_RELOCATE (yyss);
2906 YYSTACK_RELOCATE (yyvs);
2907
2908# undef YYSTACK_RELOCATE
2909 if (yyss1 != yyssa)
2910 YYSTACK_FREE (yyss1);
2911 }
2912# endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002913#endif /* no yyoverflow */
2914
Reid Spencer38c91a92007-02-28 02:24:54 +00002915 yyssp = yyss + yysize - 1;
2916 yyvsp = yyvs + yysize - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002917
2918
Reid Spencer38c91a92007-02-28 02:24:54 +00002919 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
2920 (unsigned long int) yystacksize));
2921
2922 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002923 YYABORT;
2924 }
2925
Reid Spencer38c91a92007-02-28 02:24:54 +00002926 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002927
2928 goto yybackup;
Reid Spencer38c91a92007-02-28 02:24:54 +00002929
2930/*-----------.
2931| yybackup. |
2932`-----------*/
2933yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002934
Chris Lattner9d2fda62007-02-13 05:53:56 +00002935/* Do appropriate processing given the current state. */
Reid Spencer38c91a92007-02-28 02:24:54 +00002936/* Read a look-ahead token if we need one and don't already have one. */
Chris Lattner9d2fda62007-02-13 05:53:56 +00002937/* yyresume: */
Andrew Lenharth6353e052006-12-08 18:07:09 +00002938
Reid Spencer38c91a92007-02-28 02:24:54 +00002939 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencer5cbf9852007-01-30 20:08:39 +00002940
Reid Spencer68a24bd2005-08-27 18:50:39 +00002941 yyn = yypact[yystate];
Reid Spencer38c91a92007-02-28 02:24:54 +00002942 if (yyn == YYPACT_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002943 goto yydefault;
2944
Reid Spencer38c91a92007-02-28 02:24:54 +00002945 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002946
Reid Spencer38c91a92007-02-28 02:24:54 +00002947 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002948 if (yychar == YYEMPTY)
2949 {
Reid Spencer38c91a92007-02-28 02:24:54 +00002950 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002951 yychar = YYLEX;
2952 }
2953
Reid Spencer38c91a92007-02-28 02:24:54 +00002954 if (yychar <= YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002955 {
Reid Spencer38c91a92007-02-28 02:24:54 +00002956 yychar = yytoken = YYEOF;
2957 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002958 }
2959 else
2960 {
Reid Spencer38c91a92007-02-28 02:24:54 +00002961 yytoken = YYTRANSLATE (yychar);
2962 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00002963 }
2964
Reid Spencer38c91a92007-02-28 02:24:54 +00002965 /* If the proper action on seeing token YYTOKEN is to reduce or to
2966 detect an error, take that action. */
2967 yyn += yytoken;
2968 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002969 goto yydefault;
2970 yyn = yytable[yyn];
Reid Spencer38c91a92007-02-28 02:24:54 +00002971 if (yyn <= 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002972 {
Reid Spencer38c91a92007-02-28 02:24:54 +00002973 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002974 goto yyerrlab;
2975 yyn = -yyn;
2976 goto yyreduce;
2977 }
2978
2979 if (yyn == YYFINAL)
2980 YYACCEPT;
2981
Reid Spencer38c91a92007-02-28 02:24:54 +00002982 /* Shift the look-ahead token. */
2983 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Reid Spencer5cbf9852007-01-30 20:08:39 +00002984
Chris Lattner9d2fda62007-02-13 05:53:56 +00002985 /* Discard the token being shifted unless it is eof. */
Reid Spencer5cbf9852007-01-30 20:08:39 +00002986 if (yychar != YYEOF)
2987 yychar = YYEMPTY;
2988
Chris Lattner7d9801d2007-02-13 00:58:01 +00002989 *++yyvsp = yylval;
2990
Reid Spencer38c91a92007-02-28 02:24:54 +00002991
2992 /* Count tokens shifted since error; after three, turn off error
2993 status. */
2994 if (yyerrstatus)
2995 yyerrstatus--;
Chris Lattner9d2fda62007-02-13 05:53:56 +00002996
2997 yystate = yyn;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002998 goto yynewstate;
2999
Chris Lattner32980692007-02-19 07:44:24 +00003000
Reid Spencer38c91a92007-02-28 02:24:54 +00003001/*-----------------------------------------------------------.
3002| yydefault -- do the default action for the current state. |
3003`-----------------------------------------------------------*/
3004yydefault:
Reid Spencer68a24bd2005-08-27 18:50:39 +00003005 yyn = yydefact[yystate];
3006 if (yyn == 0)
3007 goto yyerrlab;
Reid Spencer38c91a92007-02-28 02:24:54 +00003008 goto yyreduce;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003009
Reid Spencer38c91a92007-02-28 02:24:54 +00003010
3011/*-----------------------------.
3012| yyreduce -- Do a reduction. |
3013`-----------------------------*/
Reid Spencer68a24bd2005-08-27 18:50:39 +00003014yyreduce:
Reid Spencer38c91a92007-02-28 02:24:54 +00003015 /* yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003016 yylen = yyr2[yyn];
3017
Reid Spencer38c91a92007-02-28 02:24:54 +00003018 /* If YYLEN is nonzero, implement the default value of the action:
3019 `$$ = $1'.
3020
3021 Otherwise, the following line sets YYVAL to garbage.
3022 This behavior is undocumented and Bison
3023 users should not rely upon it. Assigning to YYVAL
3024 unconditionally makes the parser a bit smaller, and it avoids a
3025 GCC warning that YYVAL may be used uninitialized. */
3026 yyval = yyvsp[1-yylen];
3027
3028
3029 YY_REDUCE_PRINT (yyn);
3030 switch (yyn)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003031 {
Reid Spencer38c91a92007-02-28 02:24:54 +00003032 case 29:
Reid Spencer93c40032007-03-19 18:40:50 +00003033#line 1092 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003034 { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;}
3035 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003036
Reid Spencer38c91a92007-02-28 02:24:54 +00003037 case 30:
Reid Spencer93c40032007-03-19 18:40:50 +00003038#line 1092 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003039 { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;}
3040 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003041
Reid Spencer38c91a92007-02-28 02:24:54 +00003042 case 31:
Reid Spencer93c40032007-03-19 18:40:50 +00003043#line 1093 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003044 { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;}
3045 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003046
Reid Spencer38c91a92007-02-28 02:24:54 +00003047 case 32:
Reid Spencer93c40032007-03-19 18:40:50 +00003048#line 1093 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003049 { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;}
3050 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003051
Reid Spencer38c91a92007-02-28 02:24:54 +00003052 case 33:
Reid Spencer93c40032007-03-19 18:40:50 +00003053#line 1094 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003054 { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;}
3055 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003056
Reid Spencer38c91a92007-02-28 02:24:54 +00003057 case 34:
Reid Spencer93c40032007-03-19 18:40:50 +00003058#line 1094 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003059 { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;}
3060 break;
3061
3062 case 35:
Reid Spencer93c40032007-03-19 18:40:50 +00003063#line 1095 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003064 { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;}
3065 break;
3066
3067 case 36:
Reid Spencer93c40032007-03-19 18:40:50 +00003068#line 1095 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003069 { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;}
3070 break;
3071
3072 case 37:
Reid Spencer93c40032007-03-19 18:40:50 +00003073#line 1096 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003074 { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;}
3075 break;
3076
3077 case 38:
Reid Spencer93c40032007-03-19 18:40:50 +00003078#line 1096 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003079 { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;}
3080 break;
3081
3082 case 39:
Reid Spencer93c40032007-03-19 18:40:50 +00003083#line 1100 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003084 { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;}
3085 break;
3086
3087 case 40:
Reid Spencer93c40032007-03-19 18:40:50 +00003088#line 1100 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003089 { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;}
3090 break;
3091
3092 case 41:
Reid Spencer93c40032007-03-19 18:40:50 +00003093#line 1101 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003094 { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;}
3095 break;
3096
3097 case 42:
Reid Spencer93c40032007-03-19 18:40:50 +00003098#line 1101 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003099 { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;}
3100 break;
3101
3102 case 43:
Reid Spencer93c40032007-03-19 18:40:50 +00003103#line 1102 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003104 { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;}
3105 break;
3106
3107 case 44:
Reid Spencer93c40032007-03-19 18:40:50 +00003108#line 1102 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003109 { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;}
3110 break;
3111
3112 case 45:
Reid Spencer93c40032007-03-19 18:40:50 +00003113#line 1103 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003114 { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;}
3115 break;
3116
3117 case 46:
Reid Spencer93c40032007-03-19 18:40:50 +00003118#line 1103 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003119 { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;}
3120 break;
3121
3122 case 47:
Reid Spencer93c40032007-03-19 18:40:50 +00003123#line 1104 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003124 { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;}
3125 break;
3126
3127 case 48:
Reid Spencer93c40032007-03-19 18:40:50 +00003128#line 1104 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003129 { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;}
3130 break;
3131
3132 case 49:
Reid Spencer93c40032007-03-19 18:40:50 +00003133#line 1105 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003134 { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;}
3135 break;
3136
3137 case 50:
Reid Spencer93c40032007-03-19 18:40:50 +00003138#line 1105 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003139 { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;}
3140 break;
3141
3142 case 51:
Reid Spencer93c40032007-03-19 18:40:50 +00003143#line 1106 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003144 { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;}
3145 break;
3146
3147 case 52:
Reid Spencer93c40032007-03-19 18:40:50 +00003148#line 1106 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003149 { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;}
3150 break;
3151
3152 case 53:
Reid Spencer93c40032007-03-19 18:40:50 +00003153#line 1107 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003154 { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;}
3155 break;
3156
3157 case 54:
Reid Spencer93c40032007-03-19 18:40:50 +00003158#line 1108 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003159 { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;}
3160 break;
3161
3162 case 61:
Reid Spencer93c40032007-03-19 18:40:50 +00003163#line 1117 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003164 { (yyval.StrVal) = 0; ;}
3165 break;
3166
3167 case 62:
Reid Spencer93c40032007-03-19 18:40:50 +00003168#line 1121 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003169 {
3170 (yyval.StrVal) = (yyvsp[-1].StrVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003171 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003172 ;}
3173 break;
3174
3175 case 63:
Reid Spencer93c40032007-03-19 18:40:50 +00003176#line 1125 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003177 {
3178 (yyval.StrVal) = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003179 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003180 ;}
3181 break;
3182
3183 case 66:
Reid Spencer93c40032007-03-19 18:40:50 +00003184#line 1132 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003185 {
3186 (yyval.StrVal) = (yyvsp[-1].StrVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003187 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003188 ;}
3189 break;
3190
3191 case 67:
Reid Spencer93c40032007-03-19 18:40:50 +00003192#line 1136 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003193 {
3194 (yyval.StrVal) = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003195 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003196 ;}
3197 break;
3198
3199 case 68:
Reid Spencer93c40032007-03-19 18:40:50 +00003200#line 1142 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003201 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3202 break;
3203
3204 case 69:
Reid Spencer93c40032007-03-19 18:40:50 +00003205#line 1143 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003206 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3207 break;
3208
3209 case 70:
Reid Spencer93c40032007-03-19 18:40:50 +00003210#line 1144 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003211 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3212 break;
3213
3214 case 71:
Reid Spencer93c40032007-03-19 18:40:50 +00003215#line 1145 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003216 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3217 break;
3218
3219 case 72:
Reid Spencer93c40032007-03-19 18:40:50 +00003220#line 1146 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003221 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3222 break;
3223
3224 case 73:
Reid Spencer93c40032007-03-19 18:40:50 +00003225#line 1150 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003226 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3227 break;
3228
3229 case 74:
Reid Spencer93c40032007-03-19 18:40:50 +00003230#line 1151 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003231 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3232 break;
3233
3234 case 75:
Reid Spencer93c40032007-03-19 18:40:50 +00003235#line 1152 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003236 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3237 break;
3238
3239 case 76:
Reid Spencer93c40032007-03-19 18:40:50 +00003240#line 1156 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003241 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3242 break;
3243
3244 case 77:
Reid Spencer93c40032007-03-19 18:40:50 +00003245#line 1157 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003246 { (yyval.Visibility) = GlobalValue::HiddenVisibility; ;}
3247 break;
3248
3249 case 78:
Reid Spencer93c40032007-03-19 18:40:50 +00003250#line 1161 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003251 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3252 break;
3253
3254 case 79:
Reid Spencer93c40032007-03-19 18:40:50 +00003255#line 1162 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003256 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3257 break;
3258
3259 case 80:
Reid Spencer93c40032007-03-19 18:40:50 +00003260#line 1163 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003261 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3262 break;
3263
3264 case 81:
Reid Spencer93c40032007-03-19 18:40:50 +00003265#line 1167 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003266 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3267 break;
3268
3269 case 82:
Reid Spencer93c40032007-03-19 18:40:50 +00003270#line 1168 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003271 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3272 break;
3273
3274 case 83:
Reid Spencer93c40032007-03-19 18:40:50 +00003275#line 1169 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003276 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3277 break;
3278
3279 case 84:
Reid Spencer93c40032007-03-19 18:40:50 +00003280#line 1170 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003281 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3282 break;
3283
3284 case 85:
Reid Spencer93c40032007-03-19 18:40:50 +00003285#line 1171 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003286 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3287 break;
3288
3289 case 86:
Reid Spencer93c40032007-03-19 18:40:50 +00003290#line 1174 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003291 { (yyval.UIntVal) = CallingConv::C; ;}
3292 break;
3293
3294 case 87:
Reid Spencer93c40032007-03-19 18:40:50 +00003295#line 1175 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003296 { (yyval.UIntVal) = CallingConv::C; ;}
3297 break;
3298
3299 case 88:
Reid Spencer93c40032007-03-19 18:40:50 +00003300#line 1176 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003301 { (yyval.UIntVal) = CallingConv::Fast; ;}
3302 break;
3303
3304 case 89:
Reid Spencer93c40032007-03-19 18:40:50 +00003305#line 1177 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003306 { (yyval.UIntVal) = CallingConv::Cold; ;}
3307 break;
3308
3309 case 90:
Reid Spencer93c40032007-03-19 18:40:50 +00003310#line 1178 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003311 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
3312 break;
3313
3314 case 91:
Reid Spencer93c40032007-03-19 18:40:50 +00003315#line 1179 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003316 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
3317 break;
3318
3319 case 92:
Reid Spencer93c40032007-03-19 18:40:50 +00003320#line 1180 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003321 {
3322 if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val))
Reid Spencerb5334b02007-02-05 10:18:06 +00003323 GEN_ERROR("Calling conv too large");
Reid Spencer38c91a92007-02-28 02:24:54 +00003324 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003325 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003326 ;}
3327 break;
3328
3329 case 93:
Reid Spencer93c40032007-03-19 18:40:50 +00003330#line 1187 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003331 { (yyval.ParamAttrs) = FunctionType::ZExtAttribute; ;}
3332 break;
3333
3334 case 94:
Reid Spencer93c40032007-03-19 18:40:50 +00003335#line 1188 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003336 { (yyval.ParamAttrs) = FunctionType::SExtAttribute; ;}
3337 break;
3338
3339 case 95:
Reid Spencer93c40032007-03-19 18:40:50 +00003340#line 1189 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003341 { (yyval.ParamAttrs) = FunctionType::InRegAttribute; ;}
3342 break;
3343
3344 case 96:
Reid Spencer93c40032007-03-19 18:40:50 +00003345#line 1190 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003346 { (yyval.ParamAttrs) = FunctionType::StructRetAttribute; ;}
3347 break;
3348
3349 case 97:
Reid Spencer93c40032007-03-19 18:40:50 +00003350#line 1193 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003351 { (yyval.ParamAttrs) = FunctionType::NoAttributeSet; ;}
3352 break;
3353
3354 case 98:
Reid Spencer93c40032007-03-19 18:40:50 +00003355#line 1194 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003356 {
3357 (yyval.ParamAttrs) = FunctionType::ParameterAttributes((yyvsp[-1].ParamAttrs) | (yyvsp[0].ParamAttrs));
3358 ;}
3359 break;
3360
3361 case 99:
Reid Spencer93c40032007-03-19 18:40:50 +00003362#line 1199 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003363 { (yyval.ParamAttrs) = FunctionType::NoReturnAttribute; ;}
3364 break;
3365
3366 case 101:
Reid Spencer93c40032007-03-19 18:40:50 +00003367#line 1203 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003368 { (yyval.ParamAttrs) = FunctionType::NoAttributeSet; ;}
3369 break;
3370
3371 case 102:
Reid Spencer93c40032007-03-19 18:40:50 +00003372#line 1204 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003373 {
3374 (yyval.ParamAttrs) = FunctionType::ParameterAttributes((yyvsp[-1].ParamAttrs) | (yyvsp[0].ParamAttrs));
3375 ;}
3376 break;
3377
3378 case 103:
Reid Spencer93c40032007-03-19 18:40:50 +00003379#line 1211 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003380 { (yyval.UIntVal) = 0; ;}
3381 break;
3382
3383 case 104:
Reid Spencer93c40032007-03-19 18:40:50 +00003384#line 1212 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003385 {
3386 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3387 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00003388 GEN_ERROR("Alignment must be a power of two");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003389 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003390;}
3391 break;
3392
3393 case 105:
Reid Spencer93c40032007-03-19 18:40:50 +00003394#line 1218 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003395 { (yyval.UIntVal) = 0; ;}
3396 break;
3397
3398 case 106:
Reid Spencer93c40032007-03-19 18:40:50 +00003399#line 1219 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003400 {
3401 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3402 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00003403 GEN_ERROR("Alignment must be a power of two");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003404 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003405;}
3406 break;
3407
3408 case 107:
Reid Spencer93c40032007-03-19 18:40:50 +00003409#line 1227 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003410 {
3411 for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i)
3412 if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\')
Reid Spencerb5334b02007-02-05 10:18:06 +00003413 GEN_ERROR("Invalid character in section name");
Reid Spencer38c91a92007-02-28 02:24:54 +00003414 (yyval.StrVal) = (yyvsp[0].StrVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003415 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003416;}
3417 break;
3418
3419 case 108:
Reid Spencer93c40032007-03-19 18:40:50 +00003420#line 1235 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003421 { (yyval.StrVal) = 0; ;}
3422 break;
3423
3424 case 109:
Reid Spencer93c40032007-03-19 18:40:50 +00003425#line 1236 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003426 { (yyval.StrVal) = (yyvsp[0].StrVal); ;}
3427 break;
3428
3429 case 110:
Reid Spencer93c40032007-03-19 18:40:50 +00003430#line 1241 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003431 {;}
3432 break;
3433
3434 case 111:
Reid Spencer93c40032007-03-19 18:40:50 +00003435#line 1242 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003436 {;}
3437 break;
3438
3439 case 112:
Reid Spencer93c40032007-03-19 18:40:50 +00003440#line 1243 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003441 {
3442 CurGV->setSection((yyvsp[0].StrVal));
3443 free((yyvsp[0].StrVal));
Reid Spencer6f407902007-01-13 05:00:46 +00003444 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003445 ;}
3446 break;
3447
3448 case 113:
Reid Spencer93c40032007-03-19 18:40:50 +00003449#line 1248 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003450 {
3451 if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00003452 GEN_ERROR("Alignment must be a power of two");
Reid Spencer38c91a92007-02-28 02:24:54 +00003453 CurGV->setAlignment((yyvsp[0].UInt64Val));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003454 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003455 ;}
3456 break;
3457
3458 case 118:
Reid Spencer93c40032007-03-19 18:40:50 +00003459#line 1264 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003460 {
3461 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003462 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003463 ;}
3464 break;
3465
3466 case 119:
Reid Spencer93c40032007-03-19 18:40:50 +00003467#line 1268 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003468 {
3469 (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003470 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003471 ;}
3472 break;
3473
3474 case 120:
Reid Spencer93c40032007-03-19 18:40:50 +00003475#line 1272 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003476 { // Pointer type?
3477 if (*(yyvsp[-1].TypeVal) == Type::LabelTy)
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003478 GEN_ERROR("Cannot form a pointer to a basic block");
Reid Spencer38c91a92007-02-28 02:24:54 +00003479 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[-1].TypeVal))));
3480 delete (yyvsp[-1].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003481 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003482 ;}
3483 break;
3484
3485 case 121:
Reid Spencer93c40032007-03-19 18:40:50 +00003486#line 1279 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003487 { // Named types are also simple types...
3488 const Type* tmp = getTypeVal((yyvsp[0].ValIDVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003489 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003490 (yyval.TypeVal) = new PATypeHolder(tmp);
3491 ;}
3492 break;
3493
3494 case 122:
Reid Spencer93c40032007-03-19 18:40:50 +00003495#line 1284 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003496 { // Type UpReference
3497 if ((yyvsp[0].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003498 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Reid Spencer38c91a92007-02-28 02:24:54 +00003499 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector...
3500 (yyval.TypeVal) = new PATypeHolder(OT);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003501 UR_OUT("New Upreference!\n");
3502 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003503 ;}
3504 break;
3505
3506 case 123:
Reid Spencer93c40032007-03-19 18:40:50 +00003507#line 1292 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003508 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003509 std::vector<const Type*> Params;
3510 std::vector<FunctionType::ParameterAttributes> Attrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00003511 Attrs.push_back((yyvsp[0].ParamAttrs));
3512 for (TypeWithAttrsList::iterator I=(yyvsp[-2].TypeWithAttrsList)->begin(), E=(yyvsp[-2].TypeWithAttrsList)->end(); I != E; ++I) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003513 Params.push_back(I->Ty->get());
3514 if (I->Ty->get() != Type::VoidTy)
3515 Attrs.push_back(I->Attrs);
3516 }
3517 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3518 if (isVarArg) Params.pop_back();
3519
Reid Spencer38c91a92007-02-28 02:24:54 +00003520 FunctionType *FT = FunctionType::get(*(yyvsp[-4].TypeVal), Params, isVarArg, Attrs);
3521 delete (yyvsp[-2].TypeWithAttrsList); // Delete the argument list
3522 delete (yyvsp[-4].TypeVal); // Delete the return type handle
3523 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencere4d87aa2006-12-23 06:05:41 +00003524 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003525 ;}
3526 break;
3527
3528 case 124:
Reid Spencer93c40032007-03-19 18:40:50 +00003529#line 1310 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003530 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003531 std::vector<const Type*> Params;
3532 std::vector<FunctionType::ParameterAttributes> Attrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00003533 Attrs.push_back((yyvsp[0].ParamAttrs));
3534 for (TypeWithAttrsList::iterator I=(yyvsp[-2].TypeWithAttrsList)->begin(), E=(yyvsp[-2].TypeWithAttrsList)->end(); I != E; ++I) {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003535 Params.push_back(I->Ty->get());
3536 if (I->Ty->get() != Type::VoidTy)
3537 Attrs.push_back(I->Attrs);
3538 }
3539 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3540 if (isVarArg) Params.pop_back();
3541
Reid Spencer38c91a92007-02-28 02:24:54 +00003542 FunctionType *FT = FunctionType::get((yyvsp[-4].PrimType), Params, isVarArg, Attrs);
3543 delete (yyvsp[-2].TypeWithAttrsList); // Delete the argument list
3544 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003545 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003546 ;}
3547 break;
3548
3549 case 125:
Reid Spencer93c40032007-03-19 18:40:50 +00003550#line 1328 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003551 { // Sized array type?
3552 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3553 delete (yyvsp[-1].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003554 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003555 ;}
3556 break;
3557
3558 case 126:
Reid Spencer93c40032007-03-19 18:40:50 +00003559#line 1333 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003560 { // Vector type?
3561 const llvm::Type* ElemTy = (yyvsp[-1].TypeVal)->get();
3562 if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003563 GEN_ERROR("Unsigned result not equal to signed result");
3564 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
Reid Spencer9d6565a2007-02-15 02:26:10 +00003565 GEN_ERROR("Element type of a VectorType must be primitive");
Reid Spencer38c91a92007-02-28 02:24:54 +00003566 if (!isPowerOf2_32((yyvsp[-3].UInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00003567 GEN_ERROR("Vector length should be a power of 2");
Reid Spencer38c91a92007-02-28 02:24:54 +00003568 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(VectorType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3569 delete (yyvsp[-1].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003570 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003571 ;}
3572 break;
3573
3574 case 127:
Reid Spencer93c40032007-03-19 18:40:50 +00003575#line 1345 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003576 { // Structure type?
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003577 std::vector<const Type*> Elements;
Reid Spencer38c91a92007-02-28 02:24:54 +00003578 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-1].TypeList)->begin(),
3579 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003580 Elements.push_back(*I);
3581
Reid Spencer38c91a92007-02-28 02:24:54 +00003582 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
3583 delete (yyvsp[-1].TypeList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003584 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003585 ;}
3586 break;
3587
3588 case 128:
Reid Spencer93c40032007-03-19 18:40:50 +00003589#line 1355 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003590 { // Empty structure type?
3591 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer14310612006-12-31 05:40:51 +00003592 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003593 ;}
3594 break;
3595
3596 case 129:
Reid Spencer93c40032007-03-19 18:40:50 +00003597#line 1359 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003598 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003599 std::vector<const Type*> Elements;
Reid Spencer38c91a92007-02-28 02:24:54 +00003600 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-2].TypeList)->begin(),
3601 E = (yyvsp[-2].TypeList)->end(); I != E; ++I)
Reid Spencer41dff5e2007-01-26 08:05:27 +00003602 Elements.push_back(*I);
3603
Reid Spencer38c91a92007-02-28 02:24:54 +00003604 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
3605 delete (yyvsp[-2].TypeList);
Reid Spencer14310612006-12-31 05:40:51 +00003606 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003607 ;}
3608 break;
3609
3610 case 130:
Reid Spencer93c40032007-03-19 18:40:50 +00003611#line 1369 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003612 { // Empty structure type?
3613 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003614 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003615 ;}
3616 break;
3617
3618 case 131:
Reid Spencer93c40032007-03-19 18:40:50 +00003619#line 1376 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003620 {
3621 (yyval.TypeWithAttrs).Ty = (yyvsp[-1].TypeVal);
3622 (yyval.TypeWithAttrs).Attrs = (yyvsp[0].ParamAttrs);
3623 ;}
3624 break;
3625
3626 case 132:
Reid Spencer93c40032007-03-19 18:40:50 +00003627#line 1383 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003628 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003629 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003630 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
3631 if (!(*(yyvsp[0].TypeVal))->isFirstClassType())
Reid Spencerb5334b02007-02-05 10:18:06 +00003632 GEN_ERROR("LLVM functions cannot return aggregate types");
Reid Spencer38c91a92007-02-28 02:24:54 +00003633 (yyval.TypeVal) = (yyvsp[0].TypeVal);
3634 ;}
3635 break;
3636
3637 case 133:
Reid Spencer93c40032007-03-19 18:40:50 +00003638#line 1390 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003639 {
3640 (yyval.TypeVal) = new PATypeHolder(Type::VoidTy);
3641 ;}
3642 break;
3643
3644 case 134:
Reid Spencer93c40032007-03-19 18:40:50 +00003645#line 1395 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003646 {
3647 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
3648 (yyval.TypeWithAttrsList)->push_back((yyvsp[0].TypeWithAttrs));
Reid Spencer6f407902007-01-13 05:00:46 +00003649 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003650 ;}
3651 break;
3652
3653 case 135:
Reid Spencer93c40032007-03-19 18:40:50 +00003654#line 1400 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003655 {
3656 ((yyval.TypeWithAttrsList)=(yyvsp[-2].TypeWithAttrsList))->push_back((yyvsp[0].TypeWithAttrs));
Reid Spencer3da59db2006-11-27 01:05:10 +00003657 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003658 ;}
3659 break;
3660
3661 case 137:
Reid Spencer93c40032007-03-19 18:40:50 +00003662#line 1408 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003663 {
3664 (yyval.TypeWithAttrsList)=(yyvsp[-2].TypeWithAttrsList);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003665 TypeWithAttrs TWA; TWA.Attrs = FunctionType::NoAttributeSet;
3666 TWA.Ty = new PATypeHolder(Type::VoidTy);
Reid Spencer38c91a92007-02-28 02:24:54 +00003667 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003668 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003669 ;}
3670 break;
3671
3672 case 138:
Reid Spencer93c40032007-03-19 18:40:50 +00003673#line 1415 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003674 {
3675 (yyval.TypeWithAttrsList) = new TypeWithAttrsList;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003676 TypeWithAttrs TWA; TWA.Attrs = FunctionType::NoAttributeSet;
3677 TWA.Ty = new PATypeHolder(Type::VoidTy);
Reid Spencer38c91a92007-02-28 02:24:54 +00003678 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003679 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003680 ;}
3681 break;
3682
3683 case 139:
Reid Spencer93c40032007-03-19 18:40:50 +00003684#line 1422 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003685 {
3686 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
Reid Spencer41dff5e2007-01-26 08:05:27 +00003687 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003688 ;}
3689 break;
3690
3691 case 140:
Reid Spencer93c40032007-03-19 18:40:50 +00003692#line 1430 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003693 {
3694 (yyval.TypeList) = new std::list<PATypeHolder>();
3695 (yyval.TypeList)->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003696 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003697 ;}
3698 break;
3699
3700 case 141:
Reid Spencer93c40032007-03-19 18:40:50 +00003701#line 1435 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003702 {
3703 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00003704 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003705 ;}
3706 break;
3707
3708 case 142:
Reid Spencer93c40032007-03-19 18:40:50 +00003709#line 1446 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003710 { // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00003711 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003712 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
3713 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003714 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003715 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003716 (*(yyvsp[-3].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003717 const Type *ETy = ATy->getElementType();
3718 int NumElements = ATy->getNumElements();
3719
3720 // Verify that we have the correct size...
Reid Spencer38c91a92007-02-28 02:24:54 +00003721 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003722 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Reid Spencer38c91a92007-02-28 02:24:54 +00003723 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00003724 itostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003725
3726 // Verify all elements are correct type!
Reid Spencer38c91a92007-02-28 02:24:54 +00003727 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
3728 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003729 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3730 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencer38c91a92007-02-28 02:24:54 +00003731 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003732 }
3733
Reid Spencer38c91a92007-02-28 02:24:54 +00003734 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[-1].ConstVector));
3735 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003736 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003737 ;}
3738 break;
3739
3740 case 143:
Reid Spencer93c40032007-03-19 18:40:50 +00003741#line 1474 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003742 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003743 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003744 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
3745 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003746 if (ATy == 0)
3747 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003748 (*(yyvsp[-2].TypeVal))->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003749
Andrew Lenharth6353e052006-12-08 18:07:09 +00003750 int NumElements = ATy->getNumElements();
3751 if (NumElements != -1 && NumElements != 0)
3752 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Reid Spencerb5334b02007-02-05 10:18:06 +00003753 " arguments, but has size of " + itostr(NumElements) +"");
Reid Spencer38c91a92007-02-28 02:24:54 +00003754 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
3755 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003756 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003757 ;}
3758 break;
3759
3760 case 144:
Reid Spencer93c40032007-03-19 18:40:50 +00003761#line 1490 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003762 {
Reid Spencer14310612006-12-31 05:40:51 +00003763 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003764 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
3765 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003766 if (ATy == 0)
3767 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003768 (*(yyvsp[-2].TypeVal))->getDescription() + "'");
Reid Spencer61c83e02006-08-18 08:43:06 +00003769
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003770 int NumElements = ATy->getNumElements();
3771 const Type *ETy = ATy->getElementType();
Reid Spencer38c91a92007-02-28 02:24:54 +00003772 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
3773 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal)))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003774 GEN_ERROR("Can't build string constant of size " +
Reid Spencer38c91a92007-02-28 02:24:54 +00003775 itostr((int)(EndStr-(yyvsp[0].StrVal))) +
Reid Spencerb5334b02007-02-05 10:18:06 +00003776 " when array has size " + itostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003777 std::vector<Constant*> Vals;
3778 if (ETy == Type::Int8Ty) {
Reid Spencer38c91a92007-02-28 02:24:54 +00003779 for (unsigned char *C = (unsigned char *)(yyvsp[0].StrVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003780 C != (unsigned char*)EndStr; ++C)
3781 Vals.push_back(ConstantInt::get(ETy, *C));
3782 } else {
Reid Spencer38c91a92007-02-28 02:24:54 +00003783 free((yyvsp[0].StrVal));
Reid Spencerb5334b02007-02-05 10:18:06 +00003784 GEN_ERROR("Cannot build string arrays of non byte sized elements");
Andrew Lenharth6353e052006-12-08 18:07:09 +00003785 }
Reid Spencer38c91a92007-02-28 02:24:54 +00003786 free((yyvsp[0].StrVal));
3787 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
3788 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003789 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003790 ;}
3791 break;
3792
3793 case 145:
Reid Spencer93c40032007-03-19 18:40:50 +00003794#line 1519 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003795 { // Nonempty unsized arr
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003796 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003797 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
3798 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[-3].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003799 if (PTy == 0)
3800 GEN_ERROR("Cannot make packed constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003801 (*(yyvsp[-3].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003802 const Type *ETy = PTy->getElementType();
3803 int NumElements = PTy->getNumElements();
Reid Spencer41dff5e2007-01-26 08:05:27 +00003804
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003805 // Verify that we have the correct size...
Reid Spencer38c91a92007-02-28 02:24:54 +00003806 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003807 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Reid Spencer38c91a92007-02-28 02:24:54 +00003808 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00003809 itostr(NumElements) + "");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003810
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003811 // Verify all elements are correct type!
Reid Spencer38c91a92007-02-28 02:24:54 +00003812 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
3813 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003814 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3815 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencer38c91a92007-02-28 02:24:54 +00003816 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003817 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00003818
Reid Spencer38c91a92007-02-28 02:24:54 +00003819 (yyval.ConstVal) = ConstantVector::get(PTy, *(yyvsp[-1].ConstVector));
3820 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003821 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003822 ;}
3823 break;
3824
3825 case 146:
Reid Spencer93c40032007-03-19 18:40:50 +00003826#line 1547 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003827 {
3828 const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003829 if (STy == 0)
3830 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003831 (*(yyvsp[-3].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003832
Reid Spencer38c91a92007-02-28 02:24:54 +00003833 if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00003834 GEN_ERROR("Illegal number of initializers for structure type");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003835
3836 // Check to ensure that constants are compatible with the type initializer!
Reid Spencer38c91a92007-02-28 02:24:54 +00003837 for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i)
3838 if ((*(yyvsp[-1].ConstVector))[i]->getType() != STy->getElementType(i))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003839 GEN_ERROR("Expected type '" +
3840 STy->getElementType(i)->getDescription() +
3841 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00003842 " of structure initializer");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003843
3844 // Check to ensure that Type is not packed
3845 if (STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00003846 GEN_ERROR("Unpacked Initializer to vector type '" + STy->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003847
Reid Spencer38c91a92007-02-28 02:24:54 +00003848 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-1].ConstVector));
3849 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003850 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003851 ;}
3852 break;
3853
3854 case 147:
Reid Spencer93c40032007-03-19 18:40:50 +00003855#line 1572 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003856 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003857 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003858 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
3859 const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003860 if (STy == 0)
3861 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003862 (*(yyvsp[-2].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003863
3864 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003865 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003866
3867 // Check to ensure that Type is not packed
3868 if (STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00003869 GEN_ERROR("Unpacked Initializer to vector type '" + STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003870
Reid Spencer38c91a92007-02-28 02:24:54 +00003871 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
3872 delete (yyvsp[-2].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003873 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003874 ;}
3875 break;
3876
3877 case 148:
Reid Spencer93c40032007-03-19 18:40:50 +00003878#line 1591 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003879 {
3880 const StructType *STy = dyn_cast<StructType>((yyvsp[-5].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003881 if (STy == 0)
3882 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003883 (*(yyvsp[-5].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003884
Reid Spencer38c91a92007-02-28 02:24:54 +00003885 if ((yyvsp[-2].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00003886 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003887
3888 // Check to ensure that constants are compatible with the type initializer!
Reid Spencer38c91a92007-02-28 02:24:54 +00003889 for (unsigned i = 0, e = (yyvsp[-2].ConstVector)->size(); i != e; ++i)
3890 if ((*(yyvsp[-2].ConstVector))[i]->getType() != STy->getElementType(i))
Reid Spencer41dff5e2007-01-26 08:05:27 +00003891 GEN_ERROR("Expected type '" +
3892 STy->getElementType(i)->getDescription() +
3893 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00003894 " of structure initializer");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003895
3896 // Check to ensure that Type is packed
3897 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00003898 GEN_ERROR("Vector initializer to non-vector type '" +
3899 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003900
Reid Spencer38c91a92007-02-28 02:24:54 +00003901 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-2].ConstVector));
3902 delete (yyvsp[-5].TypeVal); delete (yyvsp[-2].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003903 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003904 ;}
3905 break;
3906
3907 case 149:
Reid Spencer93c40032007-03-19 18:40:50 +00003908#line 1617 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003909 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003910 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003911 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription());
3912 const StructType *STy = dyn_cast<StructType>((yyvsp[-4].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003913 if (STy == 0)
3914 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003915 (*(yyvsp[-4].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003916
3917 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003918 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003919
3920 // Check to ensure that Type is packed
3921 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00003922 GEN_ERROR("Vector initializer to non-vector type '" +
3923 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003924
Reid Spencer38c91a92007-02-28 02:24:54 +00003925 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
3926 delete (yyvsp[-4].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003927 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003928 ;}
3929 break;
3930
3931 case 150:
Reid Spencer93c40032007-03-19 18:40:50 +00003932#line 1637 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003933 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003934 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003935 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
3936 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003937 if (PTy == 0)
3938 GEN_ERROR("Cannot make null pointer constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003939 (*(yyvsp[-1].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003940
Reid Spencer38c91a92007-02-28 02:24:54 +00003941 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
3942 delete (yyvsp[-1].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003943 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003944 ;}
3945 break;
3946
3947 case 151:
Reid Spencer93c40032007-03-19 18:40:50 +00003948#line 1649 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003949 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003950 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003951 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
3952 (yyval.ConstVal) = UndefValue::get((yyvsp[-1].TypeVal)->get());
3953 delete (yyvsp[-1].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003954 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003955 ;}
3956 break;
3957
3958 case 152:
Reid Spencer93c40032007-03-19 18:40:50 +00003959#line 1656 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003960 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003961 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003962 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
3963 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003964 if (Ty == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003965 GEN_ERROR("Global const reference must be a pointer type");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003966
3967 // ConstExprs can exist in the body of a function, thus creating
3968 // GlobalValues whenever they refer to a variable. Because we are in
Reid Spencer93c40032007-03-19 18:40:50 +00003969 // the context of a function, getExistingVal will search the functions
Reid Spencer68a24bd2005-08-27 18:50:39 +00003970 // symbol table instead of the module symbol table for the global symbol,
3971 // which throws things all off. To get around this, we just tell
Reid Spencer93c40032007-03-19 18:40:50 +00003972 // getExistingVal that we are at global scope here.
Reid Spencer68a24bd2005-08-27 18:50:39 +00003973 //
3974 Function *SavedCurFn = CurFun.CurrentFunction;
3975 CurFun.CurrentFunction = 0;
3976
Reid Spencer93c40032007-03-19 18:40:50 +00003977 Value *V = getExistingVal(Ty, (yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00003978 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003979
3980 CurFun.CurrentFunction = SavedCurFn;
3981
3982 // If this is an initializer for a constant pointer, which is referencing a
3983 // (currently) undefined variable, create a stub now that shall be replaced
3984 // in the future with the right type of variable.
3985 //
3986 if (V == 0) {
Reid Spencera9720f52007-02-05 17:04:00 +00003987 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003988 const PointerType *PT = cast<PointerType>(Ty);
3989
3990 // First check to see if the forward references value is already created!
3991 PerModuleInfo::GlobalRefsType::iterator I =
Reid Spencer38c91a92007-02-28 02:24:54 +00003992 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal)));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003993
3994 if (I != CurModule.GlobalRefs.end()) {
3995 V = I->second; // Placeholder already exists, use it...
Reid Spencer38c91a92007-02-28 02:24:54 +00003996 (yyvsp[0].ValIDVal).destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003997 } else {
3998 std::string Name;
Reid Spencer38c91a92007-02-28 02:24:54 +00003999 if ((yyvsp[0].ValIDVal).Type == ValID::GlobalName)
4000 Name = (yyvsp[0].ValIDVal).Name;
4001 else if ((yyvsp[0].ValIDVal).Type != ValID::GlobalID)
Reid Spencer41dff5e2007-01-26 08:05:27 +00004002 GEN_ERROR("Invalid reference to global");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004003
4004 // Create the forward referenced global.
4005 GlobalValue *GV;
4006 if (const FunctionType *FTy =
4007 dyn_cast<FunctionType>(PT->getElementType())) {
4008 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
4009 CurModule.CurrentModule);
4010 } else {
4011 GV = new GlobalVariable(PT->getElementType(), false,
4012 GlobalValue::ExternalLinkage, 0,
4013 Name, CurModule.CurrentModule);
4014 }
4015
4016 // Keep track of the fact that we have a forward ref to recycle it
Reid Spencer38c91a92007-02-28 02:24:54 +00004017 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004018 V = GV;
4019 }
4020 }
4021
Reid Spencer38c91a92007-02-28 02:24:54 +00004022 (yyval.ConstVal) = cast<GlobalValue>(V);
4023 delete (yyvsp[-1].TypeVal); // Free the type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00004024 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004025 ;}
4026 break;
4027
4028 case 153:
Reid Spencer93c40032007-03-19 18:40:50 +00004029#line 1722 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004030 {
Reid Spencer14310612006-12-31 05:40:51 +00004031 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00004032 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4033 if ((yyvsp[-1].TypeVal)->get() != (yyvsp[0].ConstVal)->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004034 GEN_ERROR("Mismatched types for constant expression: " +
Reid Spencer38c91a92007-02-28 02:24:54 +00004035 (*(yyvsp[-1].TypeVal))->getDescription() + " and " + (yyvsp[0].ConstVal)->getType()->getDescription());
4036 (yyval.ConstVal) = (yyvsp[0].ConstVal);
4037 delete (yyvsp[-1].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004038 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004039 ;}
4040 break;
4041
4042 case 154:
Reid Spencer93c40032007-03-19 18:40:50 +00004043#line 1732 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004044 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004045 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00004046 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4047 const Type *Ty = (yyvsp[-1].TypeVal)->get();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004048 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
Reid Spencerb5334b02007-02-05 10:18:06 +00004049 GEN_ERROR("Cannot create a null initialized value of this type");
Reid Spencer38c91a92007-02-28 02:24:54 +00004050 (yyval.ConstVal) = Constant::getNullValue(Ty);
4051 delete (yyvsp[-1].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004052 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004053 ;}
4054 break;
4055
4056 case 155:
Reid Spencer93c40032007-03-19 18:40:50 +00004057#line 1742 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004058 { // integral constants
4059 if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004060 GEN_ERROR("Constant value doesn't fit in type");
Reid Spencer49d273e2007-03-19 20:40:51 +00004061 (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val), true);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004062 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004063 ;}
4064 break;
4065
4066 case 156:
Reid Spencer49d273e2007-03-19 20:40:51 +00004067#line 1748 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004068 { // arbitrary precision integer constants
4069 uint32_t BitWidth = cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth();
4070 if ((yyvsp[0].APIntVal)->getBitWidth() > BitWidth) {
4071 GEN_ERROR("Constant value does not fit in type");
Reid Spencer10794272007-03-01 19:41:47 +00004072 }
4073 (yyvsp[0].APIntVal)->sextOrTrunc(BitWidth);
4074 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[0].APIntVal));
Reid Spencer38c91a92007-02-28 02:24:54 +00004075 delete (yyvsp[0].APIntVal);
4076 CHECK_FOR_ERROR
4077 ;}
4078 break;
4079
4080 case 157:
Reid Spencer49d273e2007-03-19 20:40:51 +00004081#line 1758 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004082 { // integral constants
4083 if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004084 GEN_ERROR("Constant value doesn't fit in type");
Reid Spencer49d273e2007-03-19 20:40:51 +00004085 (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val), false);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004086 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004087 ;}
4088 break;
4089
4090 case 158:
Reid Spencer49d273e2007-03-19 20:40:51 +00004091#line 1764 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004092 { // arbitrary precision integer constants
4093 uint32_t BitWidth = cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth();
4094 if ((yyvsp[0].APIntVal)->getBitWidth() > BitWidth) {
4095 GEN_ERROR("Constant value does not fit in type");
Reid Spencer10794272007-03-01 19:41:47 +00004096 }
4097 (yyvsp[0].APIntVal)->zextOrTrunc(BitWidth);
4098 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[0].APIntVal));
Reid Spencer38c91a92007-02-28 02:24:54 +00004099 delete (yyvsp[0].APIntVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004100 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004101 ;}
4102 break;
4103
4104 case 159:
Reid Spencer49d273e2007-03-19 20:40:51 +00004105#line 1774 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004106 { // Boolean constants
4107 assert(cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth() == 1 && "Not Bool?");
4108 (yyval.ConstVal) = ConstantInt::getTrue();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004109 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004110 ;}
4111 break;
4112
4113 case 160:
Reid Spencer49d273e2007-03-19 20:40:51 +00004114#line 1779 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004115 { // Boolean constants
4116 assert(cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth() == 1 && "Not Bool?");
4117 (yyval.ConstVal) = ConstantInt::getFalse();
4118 CHECK_FOR_ERROR
4119 ;}
4120 break;
4121
4122 case 161:
Reid Spencer49d273e2007-03-19 20:40:51 +00004123#line 1784 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004124 { // Float & Double constants
4125 if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].FPVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004126 GEN_ERROR("Floating point constant invalid for type");
Reid Spencer38c91a92007-02-28 02:24:54 +00004127 (yyval.ConstVal) = ConstantFP::get((yyvsp[-1].PrimType), (yyvsp[0].FPVal));
Reid Spencer6f407902007-01-13 05:00:46 +00004128 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004129 ;}
4130 break;
4131
4132 case 162:
Reid Spencer49d273e2007-03-19 20:40:51 +00004133#line 1792 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004134 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004135 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00004136 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4137 Constant *Val = (yyvsp[-3].ConstVal);
4138 const Type *DestTy = (yyvsp[-1].TypeVal)->get();
4139 if (!CastInst::castIsValid((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), DestTy))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004140 GEN_ERROR("invalid cast opcode for cast from '" +
4141 Val->getType()->getDescription() + "' to '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00004142 DestTy->getDescription() + "'");
Reid Spencer38c91a92007-02-28 02:24:54 +00004143 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), DestTy);
4144 delete (yyvsp[-1].TypeVal);
4145 ;}
4146 break;
4147
4148 case 163:
Reid Spencer49d273e2007-03-19 20:40:51 +00004149#line 1804 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004150 {
4151 if (!isa<PointerType>((yyvsp[-2].ConstVal)->getType()))
Reid Spencerb5334b02007-02-05 10:18:06 +00004152 GEN_ERROR("GetElementPtr requires a pointer operand");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004153
4154 const Type *IdxTy =
Reid Spencer38c91a92007-02-28 02:24:54 +00004155 GetElementPtrInst::getIndexedType((yyvsp[-2].ConstVal)->getType(), &(*(yyvsp[-1].ValueList))[0], (yyvsp[-1].ValueList)->size(),
Chris Lattner7d9801d2007-02-13 00:58:01 +00004156 true);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004157 if (!IdxTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00004158 GEN_ERROR("Index list invalid for constant getelementptr");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004159
Chris Lattnerf7469af2007-01-31 04:44:08 +00004160 SmallVector<Constant*, 8> IdxVec;
Reid Spencer38c91a92007-02-28 02:24:54 +00004161 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e; ++i)
4162 if (Constant *C = dyn_cast<Constant>((*(yyvsp[-1].ValueList))[i]))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004163 IdxVec.push_back(C);
4164 else
Reid Spencerb5334b02007-02-05 10:18:06 +00004165 GEN_ERROR("Indices to constant getelementptr must be constants");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004166
Reid Spencer38c91a92007-02-28 02:24:54 +00004167 delete (yyvsp[-1].ValueList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004168
Reid Spencer38c91a92007-02-28 02:24:54 +00004169 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal), &IdxVec[0], IdxVec.size());
Andrew Lenharth6353e052006-12-08 18:07:09 +00004170 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004171 ;}
4172 break;
4173
4174 case 164:
Reid Spencer49d273e2007-03-19 20:40:51 +00004175#line 1826 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004176 {
4177 if ((yyvsp[-5].ConstVal)->getType() != Type::Int1Ty)
Reid Spencerb5334b02007-02-05 10:18:06 +00004178 GEN_ERROR("Select condition must be of boolean type");
Reid Spencer38c91a92007-02-28 02:24:54 +00004179 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004180 GEN_ERROR("Select operand types must match");
Reid Spencer38c91a92007-02-28 02:24:54 +00004181 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004182 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004183 ;}
4184 break;
4185
4186 case 165:
Reid Spencer49d273e2007-03-19 20:40:51 +00004187#line 1834 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004188 {
4189 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004190 GEN_ERROR("Binary operator types must match");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004191 CHECK_FOR_ERROR;
Reid Spencer38c91a92007-02-28 02:24:54 +00004192 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
4193 ;}
4194 break;
4195
4196 case 166:
Reid Spencer49d273e2007-03-19 20:40:51 +00004197#line 1840 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004198 {
4199 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004200 GEN_ERROR("Logical operator types must match");
Reid Spencer38c91a92007-02-28 02:24:54 +00004201 if (!(yyvsp[-3].ConstVal)->getType()->isInteger()) {
4202 if (Instruction::isShift((yyvsp[-5].BinaryOpVal)) || !isa<VectorType>((yyvsp[-3].ConstVal)->getType()) ||
4203 !cast<VectorType>((yyvsp[-3].ConstVal)->getType())->getElementType()->isInteger())
Reid Spencerb5334b02007-02-05 10:18:06 +00004204 GEN_ERROR("Logical operator requires integral operands");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004205 }
Reid Spencer38c91a92007-02-28 02:24:54 +00004206 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004207 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004208 ;}
4209 break;
4210
4211 case 167:
Reid Spencer49d273e2007-03-19 20:40:51 +00004212#line 1851 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004213 {
4214 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004215 GEN_ERROR("icmp operand types must match");
Reid Spencer38c91a92007-02-28 02:24:54 +00004216 (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[-5].IPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
4217 ;}
4218 break;
4219
4220 case 168:
Reid Spencer49d273e2007-03-19 20:40:51 +00004221#line 1856 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004222 {
4223 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004224 GEN_ERROR("fcmp operand types must match");
Reid Spencer38c91a92007-02-28 02:24:54 +00004225 (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[-5].FPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
4226 ;}
4227 break;
4228
4229 case 169:
Reid Spencer49d273e2007-03-19 20:40:51 +00004230#line 1861 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004231 {
4232 if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004233 GEN_ERROR("Invalid extractelement operands");
Reid Spencer38c91a92007-02-28 02:24:54 +00004234 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004235 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004236 ;}
4237 break;
4238
4239 case 170:
Reid Spencer49d273e2007-03-19 20:40:51 +00004240#line 1867 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004241 {
4242 if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004243 GEN_ERROR("Invalid insertelement operands");
Reid Spencer38c91a92007-02-28 02:24:54 +00004244 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004245 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004246 ;}
4247 break;
4248
4249 case 171:
Reid Spencer49d273e2007-03-19 20:40:51 +00004250#line 1873 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004251 {
4252 if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004253 GEN_ERROR("Invalid shufflevector operands");
Reid Spencer38c91a92007-02-28 02:24:54 +00004254 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004255 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004256 ;}
4257 break;
4258
4259 case 172:
Reid Spencer49d273e2007-03-19 20:40:51 +00004260#line 1882 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004261 {
4262 ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004263 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004264 ;}
4265 break;
4266
4267 case 173:
Reid Spencer49d273e2007-03-19 20:40:51 +00004268#line 1886 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004269 {
4270 (yyval.ConstVector) = new std::vector<Constant*>();
4271 (yyval.ConstVector)->push_back((yyvsp[0].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004272 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004273 ;}
4274 break;
4275
4276 case 174:
Reid Spencer49d273e2007-03-19 20:40:51 +00004277#line 1894 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004278 { (yyval.BoolVal) = false; ;}
4279 break;
4280
4281 case 175:
Reid Spencer49d273e2007-03-19 20:40:51 +00004282#line 1894 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004283 { (yyval.BoolVal) = true; ;}
4284 break;
4285
4286 case 176:
Reid Spencer49d273e2007-03-19 20:40:51 +00004287#line 1905 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004288 {
4289 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004290 CurModule.ModuleDone();
4291 CHECK_FOR_ERROR;
Reid Spencer38c91a92007-02-28 02:24:54 +00004292 ;}
4293 break;
4294
4295 case 177:
Reid Spencer49d273e2007-03-19 20:40:51 +00004296#line 1910 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004297 {
4298 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004299 CurModule.ModuleDone();
4300 CHECK_FOR_ERROR;
Reid Spencer38c91a92007-02-28 02:24:54 +00004301 ;}
4302 break;
4303
4304 case 180:
Reid Spencer49d273e2007-03-19 20:40:51 +00004305#line 1923 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004306 { CurFun.isDeclare = false; ;}
4307 break;
4308
4309 case 181:
Reid Spencer49d273e2007-03-19 20:40:51 +00004310#line 1923 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004311 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004312 CurFun.FunctionDone();
4313 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004314 ;}
4315 break;
4316
4317 case 182:
Reid Spencer49d273e2007-03-19 20:40:51 +00004318#line 1927 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004319 { CurFun.isDeclare = true; ;}
4320 break;
4321
4322 case 183:
Reid Spencer49d273e2007-03-19 20:40:51 +00004323#line 1927 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004324 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004325 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004326 ;}
4327 break;
4328
4329 case 184:
Reid Spencer49d273e2007-03-19 20:40:51 +00004330#line 1930 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004331 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004332 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004333 ;}
4334 break;
4335
4336 case 185:
Reid Spencer49d273e2007-03-19 20:40:51 +00004337#line 1933 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004338 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004339 // Emit an error if there are any unresolved types left.
4340 if (!CurModule.LateResolveTypes.empty()) {
4341 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004342 if (DID.Type == ValID::LocalName) {
Reid Spencer61c83e02006-08-18 08:43:06 +00004343 GEN_ERROR("Reference to an undefined type: '"+DID.getName() + "'");
4344 } else {
4345 GEN_ERROR("Reference to an undefined type: #" + itostr(DID.Num));
4346 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004347 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004348 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004349 ;}
4350 break;
4351
4352 case 186:
Reid Spencer49d273e2007-03-19 20:40:51 +00004353#line 1945 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004354 {
Reid Spencer14310612006-12-31 05:40:51 +00004355 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00004356 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004357 // Eagerly resolve types. This is not an optimization, this is a
4358 // requirement that is due to the fact that we could have this:
4359 //
4360 // %list = type { %list * }
4361 // %list = type { %list * } ; repeated type decl
4362 //
4363 // If types are not resolved eagerly, then the two types will not be
4364 // determined to be the same type!
4365 //
Reid Spencer38c91a92007-02-28 02:24:54 +00004366 ResolveTypeTo((yyvsp[-2].StrVal), *(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004367
Reid Spencer38c91a92007-02-28 02:24:54 +00004368 if (!setTypeName(*(yyvsp[0].TypeVal), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00004369 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004370 // If this is a named type that is not a redefinition, add it to the slot
4371 // table.
Reid Spencer38c91a92007-02-28 02:24:54 +00004372 CurModule.Types.push_back(*(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004373 }
Reid Spencera132e042006-12-03 05:46:11 +00004374
Reid Spencer38c91a92007-02-28 02:24:54 +00004375 delete (yyvsp[0].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004376 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004377 ;}
4378 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004379
Reid Spencer38c91a92007-02-28 02:24:54 +00004380 case 187:
Reid Spencer49d273e2007-03-19 20:40:51 +00004381#line 1969 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004382 {
4383 ResolveTypeTo((yyvsp[-2].StrVal), (yyvsp[0].PrimType));
4384
4385 if (!setTypeName((yyvsp[0].PrimType), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004386 CHECK_FOR_ERROR
4387 // If this is a named type that is not a redefinition, add it to the slot
4388 // table.
Reid Spencer38c91a92007-02-28 02:24:54 +00004389 CurModule.Types.push_back((yyvsp[0].PrimType));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004390 }
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004391 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004392 ;}
4393 break;
4394
4395 case 188:
Reid Spencer49d273e2007-03-19 20:40:51 +00004396#line 1980 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004397 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004398 /* "Externally Visible" Linkage */
Reid Spencer38c91a92007-02-28 02:24:54 +00004399 if ((yyvsp[0].ConstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004400 GEN_ERROR("Global value initializer is not a constant");
Reid Spencer38c91a92007-02-28 02:24:54 +00004401 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage,
4402 (yyvsp[-2].Visibility), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal)->getType(), (yyvsp[0].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004403 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004404 ;}
4405 break;
4406
4407 case 189:
Reid Spencer49d273e2007-03-19 20:40:51 +00004408#line 1987 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004409 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004410 CurGV = 0;
Reid Spencer38c91a92007-02-28 02:24:54 +00004411 ;}
4412 break;
4413
4414 case 190:
Reid Spencer49d273e2007-03-19 20:40:51 +00004415#line 1990 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004416 {
4417 if ((yyvsp[0].ConstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004418 GEN_ERROR("Global value initializer is not a constant");
Reid Spencer38c91a92007-02-28 02:24:54 +00004419 CurGV = ParseGlobalVariable((yyvsp[-4].StrVal), (yyvsp[-3].Linkage), (yyvsp[-2].Visibility), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal)->getType(), (yyvsp[0].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004420 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004421 ;}
4422 break;
4423
4424 case 191:
Reid Spencer49d273e2007-03-19 20:40:51 +00004425#line 1995 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004426 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004427 CurGV = 0;
Reid Spencer38c91a92007-02-28 02:24:54 +00004428 ;}
4429 break;
4430
4431 case 192:
Reid Spencer49d273e2007-03-19 20:40:51 +00004432#line 1998 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004433 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004434 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00004435 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
4436 CurGV = ParseGlobalVariable((yyvsp[-4].StrVal), (yyvsp[-3].Linkage), (yyvsp[-2].Visibility), (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004437 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004438 delete (yyvsp[0].TypeVal);
4439 ;}
4440 break;
4441
4442 case 193:
Reid Spencer49d273e2007-03-19 20:40:51 +00004443#line 2004 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004444 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004445 CurGV = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004446 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004447 ;}
4448 break;
4449
4450 case 194:
Reid Spencer49d273e2007-03-19 20:40:51 +00004451#line 2008 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004452 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004453 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004454 ;}
4455 break;
4456
4457 case 195:
Reid Spencer49d273e2007-03-19 20:40:51 +00004458#line 2011 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004459 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004460 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004461 ;}
4462 break;
4463
4464 case 196:
Reid Spencer49d273e2007-03-19 20:40:51 +00004465#line 2017 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004466 {
Chris Lattner66316012006-01-24 04:14:29 +00004467 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Reid Spencer38c91a92007-02-28 02:24:54 +00004468 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4469 std::string NewAsm((yyvsp[0].StrVal), EndStr);
4470 free((yyvsp[0].StrVal));
Chris Lattner66316012006-01-24 04:14:29 +00004471
4472 if (AsmSoFar.empty())
4473 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
4474 else
4475 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Reid Spencer61c83e02006-08-18 08:43:06 +00004476 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004477;}
4478 break;
4479
4480 case 197:
Reid Spencer49d273e2007-03-19 20:40:51 +00004481#line 2030 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004482 {
4483 CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal));
4484 free((yyvsp[0].StrVal));
4485 ;}
4486 break;
4487
4488 case 198:
Reid Spencer49d273e2007-03-19 20:40:51 +00004489#line 2034 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004490 {
4491 CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal));
4492 free((yyvsp[0].StrVal));
4493 ;}
4494 break;
4495
4496 case 200:
Reid Spencer49d273e2007-03-19 20:40:51 +00004497#line 2041 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004498 {
4499 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4500 free((yyvsp[0].StrVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004501 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004502 ;}
4503 break;
4504
4505 case 201:
Reid Spencer49d273e2007-03-19 20:40:51 +00004506#line 2046 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004507 {
4508 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4509 free((yyvsp[0].StrVal));
Reid Spencera54b7cb2007-01-12 07:05:14 +00004510 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004511 ;}
4512 break;
4513
4514 case 202:
Reid Spencer49d273e2007-03-19 20:40:51 +00004515#line 2051 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004516 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004517 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004518 ;}
4519 break;
4520
4521 case 203:
Reid Spencer49d273e2007-03-19 20:40:51 +00004522#line 2060 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004523 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004524 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00004525 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
4526 if (*(yyvsp[-2].TypeVal) == Type::VoidTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00004527 GEN_ERROR("void typed arguments are invalid");
Reid Spencer38c91a92007-02-28 02:24:54 +00004528 ArgListEntry E; E.Attrs = (yyvsp[-1].ParamAttrs); E.Ty = (yyvsp[-2].TypeVal); E.Name = (yyvsp[0].StrVal);
4529 (yyval.ArgList) = (yyvsp[-4].ArgList);
4530 (yyvsp[-4].ArgList)->push_back(E);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004531 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004532 ;}
4533 break;
4534
4535 case 204:
Reid Spencer49d273e2007-03-19 20:40:51 +00004536#line 2070 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004537 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004538 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00004539 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
4540 if (*(yyvsp[-2].TypeVal) == Type::VoidTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00004541 GEN_ERROR("void typed arguments are invalid");
Reid Spencer38c91a92007-02-28 02:24:54 +00004542 ArgListEntry E; E.Attrs = (yyvsp[-1].ParamAttrs); E.Ty = (yyvsp[-2].TypeVal); E.Name = (yyvsp[0].StrVal);
4543 (yyval.ArgList) = new ArgListType;
4544 (yyval.ArgList)->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00004545 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004546 ;}
4547 break;
4548
4549 case 205:
Reid Spencer49d273e2007-03-19 20:40:51 +00004550#line 2081 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004551 {
4552 (yyval.ArgList) = (yyvsp[0].ArgList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004553 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004554 ;}
4555 break;
4556
4557 case 206:
Reid Spencer49d273e2007-03-19 20:40:51 +00004558#line 2085 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004559 {
4560 (yyval.ArgList) = (yyvsp[-2].ArgList);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004561 struct ArgListEntry E;
4562 E.Ty = new PATypeHolder(Type::VoidTy);
4563 E.Name = 0;
4564 E.Attrs = FunctionType::NoAttributeSet;
Reid Spencer38c91a92007-02-28 02:24:54 +00004565 (yyval.ArgList)->push_back(E);
Reid Spencer6f407902007-01-13 05:00:46 +00004566 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004567 ;}
4568 break;
4569
4570 case 207:
Reid Spencer49d273e2007-03-19 20:40:51 +00004571#line 2094 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004572 {
4573 (yyval.ArgList) = new ArgListType;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004574 struct ArgListEntry E;
4575 E.Ty = new PATypeHolder(Type::VoidTy);
4576 E.Name = 0;
4577 E.Attrs = FunctionType::NoAttributeSet;
Reid Spencer38c91a92007-02-28 02:24:54 +00004578 (yyval.ArgList)->push_back(E);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004579 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004580 ;}
4581 break;
4582
4583 case 208:
Reid Spencer49d273e2007-03-19 20:40:51 +00004584#line 2103 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004585 {
4586 (yyval.ArgList) = 0;
Reid Spencer61c83e02006-08-18 08:43:06 +00004587 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004588 ;}
4589 break;
4590
4591 case 209:
Reid Spencer49d273e2007-03-19 20:40:51 +00004592#line 2109 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004593 {
4594 UnEscapeLexed((yyvsp[-6].StrVal));
4595 std::string FunctionName((yyvsp[-6].StrVal));
4596 free((yyvsp[-6].StrVal)); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004597
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004598 // Check the function result for abstractness if this is a define. We should
4599 // have no abstract types at this point
Reid Spencer38c91a92007-02-28 02:24:54 +00004600 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[-7].TypeVal)))
4601 GEN_ERROR("Reference to abstract result: "+ (yyvsp[-7].TypeVal)->get()->getDescription());
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004602
Reid Spencer68a24bd2005-08-27 18:50:39 +00004603 std::vector<const Type*> ParamTypeList;
Reid Spencer14310612006-12-31 05:40:51 +00004604 std::vector<FunctionType::ParameterAttributes> ParamAttrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00004605 ParamAttrs.push_back((yyvsp[-2].ParamAttrs));
4606 if ((yyvsp[-4].ArgList)) { // If there are arguments...
4607 for (ArgListType::iterator I = (yyvsp[-4].ArgList)->begin(); I != (yyvsp[-4].ArgList)->end(); ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00004608 const Type* Ty = I->Ty->get();
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004609 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
4610 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00004611 ParamTypeList.push_back(Ty);
4612 if (Ty != Type::VoidTy)
4613 ParamAttrs.push_back(I->Attrs);
4614 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004615 }
4616
4617 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
4618 if (isVarArg) ParamTypeList.pop_back();
4619
Reid Spencer38c91a92007-02-28 02:24:54 +00004620 FunctionType *FT = FunctionType::get(*(yyvsp[-7].TypeVal), ParamTypeList, isVarArg,
Reid Spencer14310612006-12-31 05:40:51 +00004621 ParamAttrs);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004622 const PointerType *PFT = PointerType::get(FT);
Reid Spencer38c91a92007-02-28 02:24:54 +00004623 delete (yyvsp[-7].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004624
4625 ValID ID;
4626 if (!FunctionName.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004627 ID = ValID::createGlobalName((char*)FunctionName.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004628 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00004629 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004630 }
4631
4632 Function *Fn = 0;
4633 // See if this function was forward referenced. If so, recycle the object.
4634 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4635 // Move the function to the end of the list, from whereever it was
4636 // previously inserted.
4637 Fn = cast<Function>(FWRef);
4638 CurModule.CurrentModule->getFunctionList().remove(Fn);
4639 CurModule.CurrentModule->getFunctionList().push_back(Fn);
4640 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
Reid Spenceref9b9a72007-02-05 20:47:22 +00004641 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
4642 if (Fn->getFunctionType() != FT ) {
4643 // The existing function doesn't have the same type. This is an overload
4644 // error.
4645 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
4646 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
4647 // Neither the existing or the current function is a declaration and they
4648 // have the same name and same type. Clearly this is a redefinition.
Reid Spencerb5334b02007-02-05 10:18:06 +00004649 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +00004650 } if (Fn->isDeclaration()) {
4651 // Make sure to strip off any argument names so we can't get conflicts.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004652 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
4653 AI != AE; ++AI)
4654 AI->setName("");
Reid Spenceref9b9a72007-02-05 20:47:22 +00004655 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004656 } else { // Not already defined?
4657 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
4658 CurModule.CurrentModule);
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004659
Reid Spencer68a24bd2005-08-27 18:50:39 +00004660 InsertValue(Fn, CurModule.Values);
4661 }
4662
4663 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004664
4665 if (CurFun.isDeclare) {
4666 // If we have declaration, always overwrite linkage. This will allow us to
4667 // correctly handle cases, when pointer to function is passed as argument to
4668 // another function.
4669 Fn->setLinkage(CurFun.Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004670 Fn->setVisibility(CurFun.Visibility);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004671 }
Reid Spencer38c91a92007-02-28 02:24:54 +00004672 Fn->setCallingConv((yyvsp[-8].UIntVal));
4673 Fn->setAlignment((yyvsp[0].UIntVal));
4674 if ((yyvsp[-1].StrVal)) {
4675 Fn->setSection((yyvsp[-1].StrVal));
4676 free((yyvsp[-1].StrVal));
Chris Lattnere869eef2005-11-12 00:11:49 +00004677 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004678
4679 // Add all of the arguments we parsed to the function...
Reid Spencer38c91a92007-02-28 02:24:54 +00004680 if ((yyvsp[-4].ArgList)) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00004681 if (isVarArg) { // Nuke the last entry
Reid Spencer38c91a92007-02-28 02:24:54 +00004682 assert((yyvsp[-4].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[-4].ArgList)->back().Name == 0 &&
Reid Spencera9720f52007-02-05 17:04:00 +00004683 "Not a varargs marker!");
Reid Spencer38c91a92007-02-28 02:24:54 +00004684 delete (yyvsp[-4].ArgList)->back().Ty;
4685 (yyvsp[-4].ArgList)->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00004686 }
4687 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00004688 Function::arg_iterator ArgEnd = Fn->arg_end();
Reid Spencer14310612006-12-31 05:40:51 +00004689 unsigned Idx = 1;
Reid Spencer38c91a92007-02-28 02:24:54 +00004690 for (ArgListType::iterator I = (yyvsp[-4].ArgList)->begin();
4691 I != (yyvsp[-4].ArgList)->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencer14310612006-12-31 05:40:51 +00004692 delete I->Ty; // Delete the typeholder...
Reid Spenceref9b9a72007-02-05 20:47:22 +00004693 setValueName(ArgIt, I->Name); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00004694 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004695 InsertValue(ArgIt);
Reid Spencer14310612006-12-31 05:40:51 +00004696 Idx++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004697 }
Reid Spencera132e042006-12-03 05:46:11 +00004698
Reid Spencer38c91a92007-02-28 02:24:54 +00004699 delete (yyvsp[-4].ArgList); // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00004700 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004701 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004702;}
4703 break;
4704
4705 case 212:
Reid Spencer49d273e2007-03-19 20:40:51 +00004706#line 2222 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004707 {
4708 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004709
4710 // Make sure that we keep track of the linkage type even if there was a
4711 // previous "declare".
Reid Spencer38c91a92007-02-28 02:24:54 +00004712 (yyval.FunctionVal)->setLinkage((yyvsp[-3].Linkage));
4713 (yyval.FunctionVal)->setVisibility((yyvsp[-2].Visibility));
4714;}
4715 break;
4716
4717 case 215:
Reid Spencer49d273e2007-03-19 20:40:51 +00004718#line 2233 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004719 {
4720 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004721 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004722;}
4723 break;
4724
4725 case 216:
Reid Spencer49d273e2007-03-19 20:40:51 +00004726#line 2238 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004727 {
4728 CurFun.CurrentFunction->setLinkage((yyvsp[-2].Linkage));
4729 CurFun.CurrentFunction->setVisibility((yyvsp[-1].Visibility));
4730 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004731 CurFun.FunctionDone();
4732 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004733 ;}
4734 break;
4735
4736 case 217:
Reid Spencer49d273e2007-03-19 20:40:51 +00004737#line 2250 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004738 {
4739 (yyval.BoolVal) = false;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004740 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004741 ;}
4742 break;
4743
4744 case 218:
Reid Spencer49d273e2007-03-19 20:40:51 +00004745#line 2254 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004746 {
4747 (yyval.BoolVal) = true;
Reid Spencer61c83e02006-08-18 08:43:06 +00004748 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004749 ;}
4750 break;
4751
4752 case 219:
Reid Spencer49d273e2007-03-19 20:40:51 +00004753#line 2259 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004754 { // A reference to a direct constant
4755 (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val));
Reid Spencere4d87aa2006-12-23 06:05:41 +00004756 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004757 ;}
4758 break;
4759
4760 case 220:
Reid Spencer49d273e2007-03-19 20:40:51 +00004761#line 2263 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004762 {
4763 (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val));
Reid Spencer6f407902007-01-13 05:00:46 +00004764 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004765 ;}
4766 break;
4767
4768 case 221:
Reid Spencer49d273e2007-03-19 20:40:51 +00004769#line 2267 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004770 { // Perhaps it's an FP constant?
4771 (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004772 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004773 ;}
4774 break;
4775
4776 case 222:
Reid Spencer49d273e2007-03-19 20:40:51 +00004777#line 2271 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004778 {
4779 (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue());
Reid Spencere4d87aa2006-12-23 06:05:41 +00004780 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004781 ;}
4782 break;
4783
4784 case 223:
Reid Spencer49d273e2007-03-19 20:40:51 +00004785#line 2275 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004786 {
4787 (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse());
Reid Spencere4d87aa2006-12-23 06:05:41 +00004788 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004789 ;}
4790 break;
4791
4792 case 224:
Reid Spencer49d273e2007-03-19 20:40:51 +00004793#line 2279 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004794 {
4795 (yyval.ValIDVal) = ValID::createNull();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004796 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004797 ;}
4798 break;
4799
4800 case 225:
Reid Spencer49d273e2007-03-19 20:40:51 +00004801#line 2283 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004802 {
4803 (yyval.ValIDVal) = ValID::createUndef();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004804 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004805 ;}
4806 break;
4807
4808 case 226:
Reid Spencer49d273e2007-03-19 20:40:51 +00004809#line 2287 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004810 { // A vector zero constant.
4811 (yyval.ValIDVal) = ValID::createZeroInit();
Reid Spencer61c83e02006-08-18 08:43:06 +00004812 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004813 ;}
4814 break;
4815
4816 case 227:
Reid Spencer49d273e2007-03-19 20:40:51 +00004817#line 2291 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004818 { // Nonempty unsized packed vector
4819 const Type *ETy = (*(yyvsp[-1].ConstVector))[0]->getType();
4820 int NumElements = (yyvsp[-1].ConstVector)->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004821
Reid Spencer9d6565a2007-02-15 02:26:10 +00004822 VectorType* pt = VectorType::get(ETy, NumElements);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004823 PATypeHolder* PTy = new PATypeHolder(
Reid Spencera132e042006-12-03 05:46:11 +00004824 HandleUpRefs(
Reid Spencer9d6565a2007-02-15 02:26:10 +00004825 VectorType::get(
Reid Spencera132e042006-12-03 05:46:11 +00004826 ETy,
4827 NumElements)
4828 )
4829 );
Reid Spencer68a24bd2005-08-27 18:50:39 +00004830
4831 // Verify all elements are correct type!
Reid Spencer38c91a92007-02-28 02:24:54 +00004832 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4833 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00004834 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00004835 ETy->getDescription() +"' as required!\nIt is of type '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00004836 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004837 }
4838
Reid Spencer38c91a92007-02-28 02:24:54 +00004839 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, *(yyvsp[-1].ConstVector)));
4840 delete PTy; delete (yyvsp[-1].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004841 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004842 ;}
4843 break;
4844
4845 case 228:
Reid Spencer49d273e2007-03-19 20:40:51 +00004846#line 2316 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004847 {
4848 (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal));
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004849 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004850 ;}
4851 break;
4852
4853 case 229:
Reid Spencer49d273e2007-03-19 20:40:51 +00004854#line 2320 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004855 {
4856 char *End = UnEscapeLexed((yyvsp[-2].StrVal), true);
4857 std::string AsmStr = std::string((yyvsp[-2].StrVal), End);
4858 End = UnEscapeLexed((yyvsp[0].StrVal), true);
4859 std::string Constraints = std::string((yyvsp[0].StrVal), End);
4860 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal));
4861 free((yyvsp[-2].StrVal));
4862 free((yyvsp[0].StrVal));
Reid Spencer832254e2007-02-02 02:16:23 +00004863 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004864 ;}
4865 break;
4866
4867 case 230:
Reid Spencer49d273e2007-03-19 20:40:51 +00004868#line 2334 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004869 { // Is it an integer reference...?
4870 (yyval.ValIDVal) = ValID::createLocalID((yyvsp[0].UIntVal));
Reid Spencer832254e2007-02-02 02:16:23 +00004871 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004872 ;}
4873 break;
4874
4875 case 231:
Reid Spencer49d273e2007-03-19 20:40:51 +00004876#line 2338 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004877 {
4878 (yyval.ValIDVal) = ValID::createGlobalID((yyvsp[0].UIntVal));
Reid Spencer832254e2007-02-02 02:16:23 +00004879 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004880 ;}
4881 break;
4882
4883 case 232:
Reid Spencer49d273e2007-03-19 20:40:51 +00004884#line 2342 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004885 { // Is it a named reference...?
4886 (yyval.ValIDVal) = ValID::createLocalName((yyvsp[0].StrVal));
Reid Spencer832254e2007-02-02 02:16:23 +00004887 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004888 ;}
4889 break;
4890
4891 case 233:
Reid Spencer49d273e2007-03-19 20:40:51 +00004892#line 2346 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004893 { // Is it a named reference...?
4894 (yyval.ValIDVal) = ValID::createGlobalName((yyvsp[0].StrVal));
Reid Spencer832254e2007-02-02 02:16:23 +00004895 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004896 ;}
4897 break;
4898
4899 case 236:
Reid Spencer49d273e2007-03-19 20:40:51 +00004900#line 2358 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004901 {
Reid Spencer832254e2007-02-02 02:16:23 +00004902 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00004903 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4904 (yyval.ValueVal) = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
4905 delete (yyvsp[-1].TypeVal);
Reid Spencer832254e2007-02-02 02:16:23 +00004906 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004907 ;}
4908 break;
4909
4910 case 237:
Reid Spencer49d273e2007-03-19 20:40:51 +00004911#line 2367 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004912 {
4913 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Reid Spencer832254e2007-02-02 02:16:23 +00004914 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004915 ;}
4916 break;
4917
4918 case 238:
Reid Spencer49d273e2007-03-19 20:40:51 +00004919#line 2371 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004920 { // Do not allow functions with 0 basic blocks
4921 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Reid Spencer832254e2007-02-02 02:16:23 +00004922 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004923 ;}
4924 break;
4925
4926 case 239:
Reid Spencer49d273e2007-03-19 20:40:51 +00004927#line 2380 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004928 {
4929 setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal));
Reid Spencer832254e2007-02-02 02:16:23 +00004930 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004931 InsertValue((yyvsp[0].TermInstVal));
4932 (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal));
Reid Spencer38c91a92007-02-28 02:24:54 +00004933 (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal);
Reid Spencer832254e2007-02-02 02:16:23 +00004934 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004935 ;}
4936 break;
4937
4938 case 240:
Reid Spencer49d273e2007-03-19 20:40:51 +00004939#line 2389 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004940 {
4941 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[0].InstVal)))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004942 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
4943 if (CI2->getParent() == 0)
Reid Spencer38c91a92007-02-28 02:24:54 +00004944 (yyvsp[-1].BasicBlockVal)->getInstList().push_back(CI2);
4945 (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal));
4946 (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004947 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004948 ;}
4949 break;
4950
4951 case 241:
Reid Spencer49d273e2007-03-19 20:40:51 +00004952#line 2398 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer93c40032007-03-19 18:40:50 +00004953 { // Empty space between instruction lists
4954 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
Reid Spencere4d87aa2006-12-23 06:05:41 +00004955 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004956 ;}
4957 break;
4958
4959 case 242:
Reid Spencer49d273e2007-03-19 20:40:51 +00004960#line 2402 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer93c40032007-03-19 18:40:50 +00004961 { // Labelled (named) basic block
4962 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName((yyvsp[0].StrVal)));
Reid Spencer3822ff52006-11-08 06:47:33 +00004963 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004964 ;}
4965 break;
Reid Spencer3822ff52006-11-08 06:47:33 +00004966
Reid Spencer38c91a92007-02-28 02:24:54 +00004967 case 243:
Reid Spencer49d273e2007-03-19 20:40:51 +00004968#line 2407 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004969 { // Return with a result...
4970 (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal));
4971 CHECK_FOR_ERROR
4972 ;}
4973 break;
4974
4975 case 244:
Reid Spencer49d273e2007-03-19 20:40:51 +00004976#line 2411 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer93c40032007-03-19 18:40:50 +00004977 { // Return with no result...
Reid Spencer38c91a92007-02-28 02:24:54 +00004978 (yyval.TermInstVal) = new ReturnInst();
4979 CHECK_FOR_ERROR
4980 ;}
4981 break;
4982
4983 case 245:
Reid Spencer49d273e2007-03-19 20:40:51 +00004984#line 2415 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer93c40032007-03-19 18:40:50 +00004985 { // Unconditional Branch...
Reid Spencer38c91a92007-02-28 02:24:54 +00004986 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
4987 CHECK_FOR_ERROR
4988 (yyval.TermInstVal) = new BranchInst(tmpBB);
4989 ;}
4990 break;
4991
4992 case 246:
Reid Spencer49d273e2007-03-19 20:40:51 +00004993#line 2420 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004994 {
4995 assert(cast<IntegerType>((yyvsp[-7].PrimType))->getBitWidth() == 1 && "Not Bool?");
4996 BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal));
4997 CHECK_FOR_ERROR
4998 BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal));
4999 CHECK_FOR_ERROR
5000 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[-6].ValIDVal));
5001 CHECK_FOR_ERROR
5002 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5003 ;}
5004 break;
5005
5006 case 247:
Reid Spencer49d273e2007-03-19 20:40:51 +00005007#line 2430 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005008 {
5009 Value* tmpVal = getVal((yyvsp[-7].PrimType), (yyvsp[-6].ValIDVal));
5010 CHECK_FOR_ERROR
5011 BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal));
5012 CHECK_FOR_ERROR
5013 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size());
5014 (yyval.TermInstVal) = S;
5015
5016 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(),
5017 E = (yyvsp[-1].JumpTable)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005018 for (; I != E; ++I) {
5019 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5020 S->addCase(CI, I->second);
5021 else
Reid Spencerb5334b02007-02-05 10:18:06 +00005022 GEN_ERROR("Switch case is constant, but not a simple integer");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005023 }
Reid Spencer38c91a92007-02-28 02:24:54 +00005024 delete (yyvsp[-1].JumpTable);
Reid Spencer61c83e02006-08-18 08:43:06 +00005025 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005026 ;}
5027 break;
5028
5029 case 248:
Reid Spencer49d273e2007-03-19 20:40:51 +00005030#line 2449 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005031 {
5032 Value* tmpVal = getVal((yyvsp[-6].PrimType), (yyvsp[-5].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005033 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005034 BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005035 CHECK_FOR_ERROR
5036 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Reid Spencer38c91a92007-02-28 02:24:54 +00005037 (yyval.TermInstVal) = S;
Reid Spencer61c83e02006-08-18 08:43:06 +00005038 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005039 ;}
5040 break;
5041
5042 case 249:
Reid Spencer49d273e2007-03-19 20:40:51 +00005043#line 2459 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005044 {
Reid Spencer3822ff52006-11-08 06:47:33 +00005045
Reid Spencer14310612006-12-31 05:40:51 +00005046 // Handle the short syntax
5047 const PointerType *PFTy = 0;
5048 const FunctionType *Ty = 0;
Reid Spencer38c91a92007-02-28 02:24:54 +00005049 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-11].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00005050 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5051 // Pull out the types of all of the arguments...
5052 std::vector<const Type*> ParamTypes;
Reid Spencer14310612006-12-31 05:40:51 +00005053 FunctionType::ParamAttrsList ParamAttrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00005054 ParamAttrs.push_back((yyvsp[-6].ParamAttrs));
5055 for (ValueRefList::iterator I = (yyvsp[-8].ValueRefList)->begin(), E = (yyvsp[-8].ValueRefList)->end(); I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00005056 const Type *Ty = I->Val->getType();
5057 if (Ty == Type::VoidTy)
5058 GEN_ERROR("Short call syntax cannot be used with varargs");
5059 ParamTypes.push_back(Ty);
5060 ParamAttrs.push_back(I->Attrs);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005061 }
5062
Reid Spencer38c91a92007-02-28 02:24:54 +00005063 Ty = FunctionType::get((yyvsp[-11].TypeVal)->get(), ParamTypes, false, ParamAttrs);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005064 PFTy = PointerType::get(Ty);
5065 }
5066
Reid Spencer38c91a92007-02-28 02:24:54 +00005067 Value *V = getVal(PFTy, (yyvsp[-10].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005068 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005069 BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005070 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005071 BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005072 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005073
Reid Spencer14310612006-12-31 05:40:51 +00005074 // Check the arguments
5075 ValueList Args;
Reid Spencer38c91a92007-02-28 02:24:54 +00005076 if ((yyvsp[-8].ValueRefList)->empty()) { // Has no arguments?
Reid Spencer14310612006-12-31 05:40:51 +00005077 // Make sure no arguments is a good thing!
5078 if (Ty->getNumParams() != 0)
5079 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00005080 "expects arguments");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005081 } else { // Has arguments?
5082 // Loop through FunctionType's arguments and ensure they are specified
5083 // correctly!
Reid Spencer68a24bd2005-08-27 18:50:39 +00005084 FunctionType::param_iterator I = Ty->param_begin();
5085 FunctionType::param_iterator E = Ty->param_end();
Reid Spencer38c91a92007-02-28 02:24:54 +00005086 ValueRefList::iterator ArgI = (yyvsp[-8].ValueRefList)->begin(), ArgE = (yyvsp[-8].ValueRefList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005087
Reid Spencer14310612006-12-31 05:40:51 +00005088 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5089 if (ArgI->Val->getType() != *I)
5090 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005091 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00005092 Args.push_back(ArgI->Val);
5093 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005094
Reid Spencer14310612006-12-31 05:40:51 +00005095 if (Ty->isVarArg()) {
5096 if (I == E)
5097 for (; ArgI != ArgE; ++ArgI)
5098 Args.push_back(ArgI->Val); // push the remaining varargs
5099 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00005100 GEN_ERROR("Invalid number of parameters detected");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005101 }
Reid Spencer14310612006-12-31 05:40:51 +00005102
5103 // Create the InvokeInst
Chris Lattner9d2fda62007-02-13 05:53:56 +00005104 InvokeInst *II = new InvokeInst(V, Normal, Except, &Args[0], Args.size());
Reid Spencer38c91a92007-02-28 02:24:54 +00005105 II->setCallingConv((yyvsp[-12].UIntVal));
5106 (yyval.TermInstVal) = II;
5107 delete (yyvsp[-8].ValueRefList);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005108 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005109 ;}
5110 break;
5111
5112 case 250:
Reid Spencer49d273e2007-03-19 20:40:51 +00005113#line 2525 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005114 {
5115 (yyval.TermInstVal) = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005116 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005117 ;}
5118 break;
5119
5120 case 251:
Reid Spencer49d273e2007-03-19 20:40:51 +00005121#line 2529 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005122 {
5123 (yyval.TermInstVal) = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005124 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005125 ;}
5126 break;
5127
5128 case 252:
Reid Spencer49d273e2007-03-19 20:40:51 +00005129#line 2536 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005130 {
5131 (yyval.JumpTable) = (yyvsp[-5].JumpTable);
Reid Spencer93c40032007-03-19 18:40:50 +00005132 Constant *V = cast<Constant>(getExistingVal((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005133 CHECK_FOR_ERROR
5134 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005135 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005136
Reid Spencer38c91a92007-02-28 02:24:54 +00005137 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005138 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005139 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5140 ;}
5141 break;
5142
5143 case 253:
Reid Spencer49d273e2007-03-19 20:40:51 +00005144#line 2547 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005145 {
5146 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
Reid Spencer93c40032007-03-19 18:40:50 +00005147 Constant *V = cast<Constant>(getExistingVal((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005148 CHECK_FOR_ERROR
5149
5150 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005151 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005152
Reid Spencer38c91a92007-02-28 02:24:54 +00005153 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005154 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005155 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5156 ;}
5157 break;
5158
5159 case 254:
Reid Spencer49d273e2007-03-19 20:40:51 +00005160#line 2560 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005161 {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005162 // Is this definition named?? if so, assign the name...
Reid Spencer38c91a92007-02-28 02:24:54 +00005163 setValueName((yyvsp[0].InstVal), (yyvsp[-1].StrVal));
Reid Spenceref9b9a72007-02-05 20:47:22 +00005164 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005165 InsertValue((yyvsp[0].InstVal));
5166 (yyval.InstVal) = (yyvsp[0].InstVal);
Reid Spenceref9b9a72007-02-05 20:47:22 +00005167 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005168 ;}
5169 break;
5170
5171 case 255:
Reid Spencer49d273e2007-03-19 20:40:51 +00005172#line 2570 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005173 { // Used for PHI nodes
Reid Spencer14310612006-12-31 05:40:51 +00005174 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005175 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-5].TypeVal))->getDescription());
5176 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
5177 Value* tmpVal = getVal(*(yyvsp[-5].TypeVal), (yyvsp[-3].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005178 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005179 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005180 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005181 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5182 delete (yyvsp[-5].TypeVal);
5183 ;}
5184 break;
5185
5186 case 256:
Reid Spencer49d273e2007-03-19 20:40:51 +00005187#line 2581 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005188 {
5189 (yyval.PHIList) = (yyvsp[-6].PHIList);
5190 Value* tmpVal = getVal((yyvsp[-6].PHIList)->front().first->getType(), (yyvsp[-3].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005191 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005192 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005193 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005194 (yyvsp[-6].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5195 ;}
5196 break;
5197
5198 case 257:
Reid Spencer49d273e2007-03-19 20:40:51 +00005199#line 2591 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005200 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005201 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005202 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005203 // Used for call and invoke instructions
Reid Spencer38c91a92007-02-28 02:24:54 +00005204 (yyval.ValueRefList) = new ValueRefList();
5205 ValueRefListEntry E; E.Attrs = (yyvsp[0].ParamAttrs); E.Val = getVal((yyvsp[-2].TypeVal)->get(), (yyvsp[-1].ValIDVal));
5206 (yyval.ValueRefList)->push_back(E);
5207 ;}
5208 break;
5209
5210 case 258:
Reid Spencer49d273e2007-03-19 20:40:51 +00005211#line 2599 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005212 {
Reid Spencer14310612006-12-31 05:40:51 +00005213 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005214 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
5215 (yyval.ValueRefList) = (yyvsp[-4].ValueRefList);
5216 ValueRefListEntry E; E.Attrs = (yyvsp[0].ParamAttrs); E.Val = getVal((yyvsp[-2].TypeVal)->get(), (yyvsp[-1].ValIDVal));
5217 (yyval.ValueRefList)->push_back(E);
Reid Spencer6f407902007-01-13 05:00:46 +00005218 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005219 ;}
5220 break;
5221
5222 case 259:
Reid Spencer49d273e2007-03-19 20:40:51 +00005223#line 2607 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005224 { (yyval.ValueRefList) = new ValueRefList(); ;}
5225 break;
5226
5227 case 260:
Reid Spencer49d273e2007-03-19 20:40:51 +00005228#line 2610 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005229 { (yyval.ValueList) = new std::vector<Value*>(); ;}
5230 break;
5231
5232 case 261:
Reid Spencer49d273e2007-03-19 20:40:51 +00005233#line 2611 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005234 {
5235 (yyval.ValueList) = (yyvsp[-2].ValueList);
5236 (yyval.ValueList)->push_back((yyvsp[0].ValueVal));
Reid Spencer14310612006-12-31 05:40:51 +00005237 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005238 ;}
5239 break;
5240
5241 case 262:
Reid Spencer49d273e2007-03-19 20:40:51 +00005242#line 2618 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005243 {
5244 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005245 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005246 ;}
5247 break;
5248
5249 case 263:
Reid Spencer49d273e2007-03-19 20:40:51 +00005250#line 2622 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005251 {
5252 (yyval.BoolVal) = false;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005253 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005254 ;}
5255 break;
5256
5257 case 264:
Reid Spencer49d273e2007-03-19 20:40:51 +00005258#line 2627 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005259 {
Reid Spencer14310612006-12-31 05:40:51 +00005260 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005261 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5262 if (!(*(yyvsp[-3].TypeVal))->isInteger() && !(*(yyvsp[-3].TypeVal))->isFloatingPoint() &&
5263 !isa<VectorType>((*(yyvsp[-3].TypeVal)).get()))
Reid Spencere4d87aa2006-12-23 06:05:41 +00005264 GEN_ERROR(
Reid Spencerb5334b02007-02-05 10:18:06 +00005265 "Arithmetic operator requires integer, FP, or packed operands");
Reid Spencer38c91a92007-02-28 02:24:54 +00005266 if (isa<VectorType>((*(yyvsp[-3].TypeVal)).get()) &&
5267 ((yyvsp[-4].BinaryOpVal) == Instruction::URem ||
5268 (yyvsp[-4].BinaryOpVal) == Instruction::SRem ||
5269 (yyvsp[-4].BinaryOpVal) == Instruction::FRem))
Chris Lattner32980692007-02-19 07:44:24 +00005270 GEN_ERROR("Remainder not supported on vector types");
Reid Spencer38c91a92007-02-28 02:24:54 +00005271 Value* val1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005272 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005273 Value* val2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005274 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005275 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), val1, val2);
5276 if ((yyval.InstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005277 GEN_ERROR("binary operator returned null");
Reid Spencer38c91a92007-02-28 02:24:54 +00005278 delete (yyvsp[-3].TypeVal);
5279 ;}
5280 break;
5281
5282 case 265:
Reid Spencer49d273e2007-03-19 20:40:51 +00005283#line 2648 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005284 {
Reid Spencer14310612006-12-31 05:40:51 +00005285 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005286 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5287 if (!(*(yyvsp[-3].TypeVal))->isInteger()) {
5288 if (Instruction::isShift((yyvsp[-4].BinaryOpVal)) || !isa<VectorType>((yyvsp[-3].TypeVal)->get()) ||
5289 !cast<VectorType>((yyvsp[-3].TypeVal)->get())->getElementType()->isInteger())
Reid Spencerb5334b02007-02-05 10:18:06 +00005290 GEN_ERROR("Logical operator requires integral operands");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005291 }
Reid Spencer38c91a92007-02-28 02:24:54 +00005292 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005293 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005294 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005295 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005296 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), tmpVal1, tmpVal2);
5297 if ((yyval.InstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005298 GEN_ERROR("binary operator returned null");
Reid Spencer38c91a92007-02-28 02:24:54 +00005299 delete (yyvsp[-3].TypeVal);
5300 ;}
5301 break;
5302
5303 case 266:
Reid Spencer49d273e2007-03-19 20:40:51 +00005304#line 2665 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005305 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005306 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005307 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5308 if (isa<VectorType>((*(yyvsp[-3].TypeVal)).get()))
Chris Lattner32980692007-02-19 07:44:24 +00005309 GEN_ERROR("Vector types not supported by icmp instruction");
Reid Spencer38c91a92007-02-28 02:24:54 +00005310 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005311 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005312 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005313 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005314 (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].IPredicate), tmpVal1, tmpVal2);
5315 if ((yyval.InstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005316 GEN_ERROR("icmp operator returned null");
Reid Spencer38c91a92007-02-28 02:24:54 +00005317 ;}
5318 break;
5319
5320 case 267:
Reid Spencer49d273e2007-03-19 20:40:51 +00005321#line 2678 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005322 {
Reid Spencer14310612006-12-31 05:40:51 +00005323 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005324 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5325 if (isa<VectorType>((*(yyvsp[-3].TypeVal)).get()))
Chris Lattner32980692007-02-19 07:44:24 +00005326 GEN_ERROR("Vector types not supported by fcmp instruction");
Reid Spencer38c91a92007-02-28 02:24:54 +00005327 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005328 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005329 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005330 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005331 (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].FPredicate), tmpVal1, tmpVal2);
5332 if ((yyval.InstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005333 GEN_ERROR("fcmp operator returned null");
Reid Spencer38c91a92007-02-28 02:24:54 +00005334 ;}
5335 break;
5336
5337 case 268:
Reid Spencer49d273e2007-03-19 20:40:51 +00005338#line 2691 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005339 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005340 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005341 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
5342 Value* Val = (yyvsp[-2].ValueVal);
5343 const Type* DestTy = (yyvsp[0].TypeVal)->get();
5344 if (!CastInst::castIsValid((yyvsp[-3].CastOpVal), Val, DestTy))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005345 GEN_ERROR("invalid cast opcode for cast from '" +
5346 Val->getType()->getDescription() + "' to '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005347 DestTy->getDescription() + "'");
Reid Spencer38c91a92007-02-28 02:24:54 +00005348 (yyval.InstVal) = CastInst::create((yyvsp[-3].CastOpVal), Val, DestTy);
5349 delete (yyvsp[0].TypeVal);
5350 ;}
5351 break;
5352
5353 case 269:
Reid Spencer49d273e2007-03-19 20:40:51 +00005354#line 2703 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005355 {
5356 if ((yyvsp[-4].ValueVal)->getType() != Type::Int1Ty)
Reid Spencerb5334b02007-02-05 10:18:06 +00005357 GEN_ERROR("select condition must be boolean");
Reid Spencer38c91a92007-02-28 02:24:54 +00005358 if ((yyvsp[-2].ValueVal)->getType() != (yyvsp[0].ValueVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00005359 GEN_ERROR("select value types should match");
Reid Spencer38c91a92007-02-28 02:24:54 +00005360 (yyval.InstVal) = new SelectInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005361 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005362 ;}
5363 break;
5364
5365 case 270:
Reid Spencer49d273e2007-03-19 20:40:51 +00005366#line 2711 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005367 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005368 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005369 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
5370 (yyval.InstVal) = new VAArgInst((yyvsp[-2].ValueVal), *(yyvsp[0].TypeVal));
5371 delete (yyvsp[0].TypeVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005372 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005373 ;}
5374 break;
5375
5376 case 271:
Reid Spencer49d273e2007-03-19 20:40:51 +00005377#line 2718 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005378 {
5379 if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00005380 GEN_ERROR("Invalid extractelement operands");
Reid Spencer38c91a92007-02-28 02:24:54 +00005381 (yyval.InstVal) = new ExtractElementInst((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005382 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005383 ;}
5384 break;
5385
5386 case 272:
Reid Spencer49d273e2007-03-19 20:40:51 +00005387#line 2724 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005388 {
5389 if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00005390 GEN_ERROR("Invalid insertelement operands");
Reid Spencer38c91a92007-02-28 02:24:54 +00005391 (yyval.InstVal) = new InsertElementInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005392 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005393 ;}
5394 break;
5395
5396 case 273:
Reid Spencer49d273e2007-03-19 20:40:51 +00005397#line 2730 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005398 {
5399 if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00005400 GEN_ERROR("Invalid shufflevector operands");
Reid Spencer38c91a92007-02-28 02:24:54 +00005401 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005402 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005403 ;}
5404 break;
5405
5406 case 274:
Reid Spencer49d273e2007-03-19 20:40:51 +00005407#line 2736 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005408 {
5409 const Type *Ty = (yyvsp[0].PHIList)->front().first->getType();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005410 if (!Ty->isFirstClassType())
Reid Spencerb5334b02007-02-05 10:18:06 +00005411 GEN_ERROR("PHI node operands must be of first class type");
Reid Spencer38c91a92007-02-28 02:24:54 +00005412 (yyval.InstVal) = new PHINode(Ty);
5413 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[0].PHIList)->size());
5414 while ((yyvsp[0].PHIList)->begin() != (yyvsp[0].PHIList)->end()) {
5415 if ((yyvsp[0].PHIList)->front().first->getType() != Ty)
Reid Spencerb5334b02007-02-05 10:18:06 +00005416 GEN_ERROR("All elements of a PHI node must be of the same type");
Reid Spencer38c91a92007-02-28 02:24:54 +00005417 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[0].PHIList)->front().first, (yyvsp[0].PHIList)->front().second);
5418 (yyvsp[0].PHIList)->pop_front();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005419 }
Reid Spencer38c91a92007-02-28 02:24:54 +00005420 delete (yyvsp[0].PHIList); // Free the list...
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005421 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005422 ;}
5423 break;
5424
5425 case 275:
Reid Spencer49d273e2007-03-19 20:40:51 +00005426#line 2752 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005427 {
Reid Spencer14310612006-12-31 05:40:51 +00005428
5429 // Handle the short syntax
Andrew Lenharth6353e052006-12-08 18:07:09 +00005430 const PointerType *PFTy = 0;
5431 const FunctionType *Ty = 0;
Reid Spencer38c91a92007-02-28 02:24:54 +00005432 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-5].TypeVal)->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00005433 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5434 // Pull out the types of all of the arguments...
5435 std::vector<const Type*> ParamTypes;
Reid Spencer14310612006-12-31 05:40:51 +00005436 FunctionType::ParamAttrsList ParamAttrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00005437 ParamAttrs.push_back((yyvsp[0].ParamAttrs));
5438 for (ValueRefList::iterator I = (yyvsp[-2].ValueRefList)->begin(), E = (yyvsp[-2].ValueRefList)->end(); I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00005439 const Type *Ty = I->Val->getType();
5440 if (Ty == Type::VoidTy)
5441 GEN_ERROR("Short call syntax cannot be used with varargs");
5442 ParamTypes.push_back(Ty);
5443 ParamAttrs.push_back(I->Attrs);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005444 }
5445
Reid Spencer38c91a92007-02-28 02:24:54 +00005446 Ty = FunctionType::get((yyvsp[-5].TypeVal)->get(), ParamTypes, false, ParamAttrs);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005447 PFTy = PointerType::get(Ty);
5448 }
5449
Reid Spencer38c91a92007-02-28 02:24:54 +00005450 Value *V = getVal(PFTy, (yyvsp[-4].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005451 CHECK_FOR_ERROR
5452
Reid Spencer14310612006-12-31 05:40:51 +00005453 // Check the arguments
5454 ValueList Args;
Reid Spencer38c91a92007-02-28 02:24:54 +00005455 if ((yyvsp[-2].ValueRefList)->empty()) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00005456 // Make sure no arguments is a good thing!
5457 if (Ty->getNumParams() != 0)
5458 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00005459 "expects arguments");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005460 } else { // Has arguments?
5461 // Loop through FunctionType's arguments and ensure they are specified
5462 // correctly!
5463 //
5464 FunctionType::param_iterator I = Ty->param_begin();
5465 FunctionType::param_iterator E = Ty->param_end();
Reid Spencer38c91a92007-02-28 02:24:54 +00005466 ValueRefList::iterator ArgI = (yyvsp[-2].ValueRefList)->begin(), ArgE = (yyvsp[-2].ValueRefList)->end();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005467
Reid Spencer14310612006-12-31 05:40:51 +00005468 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5469 if (ArgI->Val->getType() != *I)
5470 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005471 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00005472 Args.push_back(ArgI->Val);
5473 }
5474 if (Ty->isVarArg()) {
5475 if (I == E)
5476 for (; ArgI != ArgE; ++ArgI)
5477 Args.push_back(ArgI->Val); // push the remaining varargs
5478 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00005479 GEN_ERROR("Invalid number of parameters detected");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005480 }
Reid Spencer14310612006-12-31 05:40:51 +00005481 // Create the call node
Chris Lattner9d2fda62007-02-13 05:53:56 +00005482 CallInst *CI = new CallInst(V, &Args[0], Args.size());
Reid Spencer38c91a92007-02-28 02:24:54 +00005483 CI->setTailCall((yyvsp[-7].BoolVal));
5484 CI->setCallingConv((yyvsp[-6].UIntVal));
5485 (yyval.InstVal) = CI;
5486 delete (yyvsp[-2].ValueRefList);
5487 delete (yyvsp[-5].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00005488 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005489 ;}
5490 break;
5491
5492 case 276:
Reid Spencer49d273e2007-03-19 20:40:51 +00005493#line 2815 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005494 {
5495 (yyval.InstVal) = (yyvsp[0].InstVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005496 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005497 ;}
5498 break;
5499
5500 case 277:
Reid Spencer49d273e2007-03-19 20:40:51 +00005501#line 2820 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005502 {
5503 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005504 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005505 ;}
5506 break;
5507
5508 case 278:
Reid Spencer49d273e2007-03-19 20:40:51 +00005509#line 2824 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005510 {
5511 (yyval.BoolVal) = false;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005512 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005513 ;}
5514 break;
5515
5516 case 279:
Reid Spencer49d273e2007-03-19 20:40:51 +00005517#line 2831 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005518 {
Reid Spencer6f407902007-01-13 05:00:46 +00005519 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005520 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5521 (yyval.InstVal) = new MallocInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
5522 delete (yyvsp[-1].TypeVal);
Reid Spencer6f407902007-01-13 05:00:46 +00005523 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005524 ;}
5525 break;
5526
5527 case 280:
Reid Spencer49d273e2007-03-19 20:40:51 +00005528#line 2838 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005529 {
Reid Spencer14310612006-12-31 05:40:51 +00005530 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005531 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription());
5532 Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00005533 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005534 (yyval.InstVal) = new MallocInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal));
5535 delete (yyvsp[-4].TypeVal);
5536 ;}
5537 break;
5538
5539 case 281:
Reid Spencer49d273e2007-03-19 20:40:51 +00005540#line 2846 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005541 {
Reid Spencer14310612006-12-31 05:40:51 +00005542 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005543 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5544 (yyval.InstVal) = new AllocaInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
5545 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005546 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005547 ;}
5548 break;
5549
5550 case 282:
Reid Spencer49d273e2007-03-19 20:40:51 +00005551#line 2853 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005552 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005553 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005554 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription());
5555 Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005556 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005557 (yyval.InstVal) = new AllocaInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal));
5558 delete (yyvsp[-4].TypeVal);
5559 ;}
5560 break;
5561
5562 case 283:
Reid Spencer49d273e2007-03-19 20:40:51 +00005563#line 2861 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005564 {
5565 if (!isa<PointerType>((yyvsp[0].ValueVal)->getType()))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005566 GEN_ERROR("Trying to free nonpointer type " +
Reid Spencer38c91a92007-02-28 02:24:54 +00005567 (yyvsp[0].ValueVal)->getType()->getDescription() + "");
5568 (yyval.InstVal) = new FreeInst((yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005569 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005570 ;}
5571 break;
5572
5573 case 284:
Reid Spencer49d273e2007-03-19 20:40:51 +00005574#line 2869 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005575 {
Reid Spencer14310612006-12-31 05:40:51 +00005576 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005577 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5578 if (!isa<PointerType>((yyvsp[-1].TypeVal)->get()))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005579 GEN_ERROR("Can't load from nonpointer type: " +
Reid Spencer38c91a92007-02-28 02:24:54 +00005580 (*(yyvsp[-1].TypeVal))->getDescription());
5581 if (!cast<PointerType>((yyvsp[-1].TypeVal)->get())->getElementType()->isFirstClassType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005582 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Reid Spencer38c91a92007-02-28 02:24:54 +00005583 (*(yyvsp[-1].TypeVal))->getDescription());
5584 Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005585 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005586 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal));
5587 delete (yyvsp[-1].TypeVal);
5588 ;}
5589 break;
5590
5591 case 285:
Reid Spencer49d273e2007-03-19 20:40:51 +00005592#line 2883 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005593 {
Reid Spencer14310612006-12-31 05:40:51 +00005594 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005595 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5596 const PointerType *PT = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005597 if (!PT)
5598 GEN_ERROR("Can't store to a nonpointer type: " +
Reid Spencer38c91a92007-02-28 02:24:54 +00005599 (*(yyvsp[-1].TypeVal))->getDescription());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005600 const Type *ElTy = PT->getElementType();
Reid Spencer38c91a92007-02-28 02:24:54 +00005601 if (ElTy != (yyvsp[-3].ValueVal)->getType())
5602 GEN_ERROR("Can't store '" + (yyvsp[-3].ValueVal)->getType()->getDescription() +
Reid Spencerb5334b02007-02-05 10:18:06 +00005603 "' into space of type '" + ElTy->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005604
Reid Spencer38c91a92007-02-28 02:24:54 +00005605 Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005606 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005607 (yyval.InstVal) = new StoreInst((yyvsp[-3].ValueVal), tmpVal, (yyvsp[-5].BoolVal));
5608 delete (yyvsp[-1].TypeVal);
5609 ;}
5610 break;
5611
5612 case 286:
Reid Spencer49d273e2007-03-19 20:40:51 +00005613#line 2900 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005614 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005615 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005616 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
5617 if (!isa<PointerType>((yyvsp[-2].TypeVal)->get()))
Reid Spencerb5334b02007-02-05 10:18:06 +00005618 GEN_ERROR("getelementptr insn requires pointer operand");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005619
Reid Spencer38c91a92007-02-28 02:24:54 +00005620 if (!GetElementPtrInst::getIndexedType(*(yyvsp[-2].TypeVal), &(*(yyvsp[0].ValueList))[0], (yyvsp[0].ValueList)->size(), true))
Reid Spencer61c83e02006-08-18 08:43:06 +00005621 GEN_ERROR("Invalid getelementptr indices for type '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00005622 (*(yyvsp[-2].TypeVal))->getDescription()+ "'");
5623 Value* tmpVal = getVal(*(yyvsp[-2].TypeVal), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005624 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005625 (yyval.InstVal) = new GetElementPtrInst(tmpVal, &(*(yyvsp[0].ValueList))[0], (yyvsp[0].ValueList)->size());
5626 delete (yyvsp[-2].TypeVal);
5627 delete (yyvsp[0].ValueList);
5628 ;}
5629 break;
5630
5631
5632 default: break;
5633 }
5634
5635/* Line 1126 of yacc.c. */
Reid Spencer49d273e2007-03-19 20:40:51 +00005636#line 5637 "llvmAsmParser.tab.c"
Chris Lattner9d2fda62007-02-13 05:53:56 +00005637
5638 yyvsp -= yylen;
5639 yyssp -= yylen;
Reid Spencer5cbf9852007-01-30 20:08:39 +00005640
Reid Spencer38c91a92007-02-28 02:24:54 +00005641
5642 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005643
5644 *++yyvsp = yyval;
5645
5646
Reid Spencer38c91a92007-02-28 02:24:54 +00005647 /* Now `shift' the result of the reduction. Determine what state
5648 that goes to, based on the state we popped back to and the rule
5649 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005650
5651 yyn = yyr1[yyn];
5652
Reid Spencer38c91a92007-02-28 02:24:54 +00005653 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
5654 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005655 yystate = yytable[yystate];
5656 else
Reid Spencer38c91a92007-02-28 02:24:54 +00005657 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00005658
5659 goto yynewstate;
5660
5661
Reid Spencer38c91a92007-02-28 02:24:54 +00005662/*------------------------------------.
5663| yyerrlab -- here on detecting error |
5664`------------------------------------*/
5665yyerrlab:
5666 /* If not already recovering from an error, report this error. */
5667 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005668 {
5669 ++yynerrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00005670#if YYERROR_VERBOSE
Chris Lattner9d2fda62007-02-13 05:53:56 +00005671 yyn = yypact[yystate];
5672
Reid Spencer38c91a92007-02-28 02:24:54 +00005673 if (YYPACT_NINF < yyn && yyn < YYLAST)
Chris Lattner9d2fda62007-02-13 05:53:56 +00005674 {
Reid Spencer38c91a92007-02-28 02:24:54 +00005675 int yytype = YYTRANSLATE (yychar);
5676 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
5677 YYSIZE_T yysize = yysize0;
5678 YYSIZE_T yysize1;
5679 int yysize_overflow = 0;
5680 char *yymsg = 0;
5681# define YYERROR_VERBOSE_ARGS_MAXIMUM 5
5682 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
5683 int yyx;
Chris Lattner9d2fda62007-02-13 05:53:56 +00005684
Reid Spencer38c91a92007-02-28 02:24:54 +00005685#if 0
5686 /* This is so xgettext sees the translatable formats that are
5687 constructed on the fly. */
5688 YY_("syntax error, unexpected %s");
5689 YY_("syntax error, unexpected %s, expecting %s");
5690 YY_("syntax error, unexpected %s, expecting %s or %s");
5691 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
5692 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
5693#endif
5694 char *yyfmt;
5695 char const *yyf;
5696 static char const yyunexpected[] = "syntax error, unexpected %s";
5697 static char const yyexpecting[] = ", expecting %s";
5698 static char const yyor[] = " or %s";
5699 char yyformat[sizeof yyunexpected
5700 + sizeof yyexpecting - 1
5701 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
5702 * (sizeof yyor - 1))];
5703 char const *yyprefix = yyexpecting;
5704
5705 /* Start YYX at -YYN if negative to avoid negative indexes in
5706 YYCHECK. */
5707 int yyxbegin = yyn < 0 ? -yyn : 0;
5708
5709 /* Stay within bounds of both yycheck and yytname. */
5710 int yychecklim = YYLAST - yyn;
5711 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
5712 int yycount = 1;
5713
5714 yyarg[0] = yytname[yytype];
5715 yyfmt = yystpcpy (yyformat, yyunexpected);
5716
5717 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
5718 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
5719 {
5720 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
5721 {
5722 yycount = 1;
5723 yysize = yysize0;
5724 yyformat[sizeof yyunexpected - 1] = '\0';
5725 break;
5726 }
5727 yyarg[yycount++] = yytname[yyx];
5728 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
5729 yysize_overflow |= yysize1 < yysize;
5730 yysize = yysize1;
5731 yyfmt = yystpcpy (yyfmt, yyprefix);
5732 yyprefix = yyor;
5733 }
5734
5735 yyf = YY_(yyformat);
5736 yysize1 = yysize + yystrlen (yyf);
5737 yysize_overflow |= yysize1 < yysize;
5738 yysize = yysize1;
5739
5740 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
5741 yymsg = (char *) YYSTACK_ALLOC (yysize);
5742 if (yymsg)
Chris Lattner9d2fda62007-02-13 05:53:56 +00005743 {
Reid Spencer38c91a92007-02-28 02:24:54 +00005744 /* Avoid sprintf, as that infringes on the user's name space.
5745 Don't have undefined behavior even if the translation
5746 produced a string with the wrong number of "%s"s. */
5747 char *yyp = yymsg;
5748 int yyi = 0;
5749 while ((*yyp = *yyf))
Chris Lattner9d2fda62007-02-13 05:53:56 +00005750 {
Reid Spencer38c91a92007-02-28 02:24:54 +00005751 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
5752 {
5753 yyp += yytnamerr (yyp, yyarg[yyi++]);
5754 yyf += 2;
5755 }
5756 else
5757 {
5758 yyp++;
5759 yyf++;
5760 }
Chris Lattner9d2fda62007-02-13 05:53:56 +00005761 }
Reid Spencer38c91a92007-02-28 02:24:54 +00005762 yyerror (yymsg);
5763 YYSTACK_FREE (yymsg);
Chris Lattner9d2fda62007-02-13 05:53:56 +00005764 }
5765 else
Reid Spencer38c91a92007-02-28 02:24:54 +00005766 {
5767 yyerror (YY_("syntax error"));
5768 goto yyexhaustedlab;
5769 }
Chris Lattner9d2fda62007-02-13 05:53:56 +00005770 }
5771 else
5772#endif /* YYERROR_VERBOSE */
Reid Spencer38c91a92007-02-28 02:24:54 +00005773 yyerror (YY_("syntax error"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005774 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00005775
Reid Spencer38c91a92007-02-28 02:24:54 +00005776
Reid Spencer41dff5e2007-01-26 08:05:27 +00005777
5778 if (yyerrstatus == 3)
5779 {
Reid Spencer38c91a92007-02-28 02:24:54 +00005780 /* If just tried and failed to reuse look-ahead token after an
5781 error, discard it. */
Reid Spencer41dff5e2007-01-26 08:05:27 +00005782
Reid Spencer38c91a92007-02-28 02:24:54 +00005783 if (yychar <= YYEOF)
5784 {
5785 /* Return failure if at end of input. */
5786 if (yychar == YYEOF)
5787 YYABORT;
5788 }
5789 else
5790 {
5791 yydestruct ("Error: discarding", yytoken, &yylval);
5792 yychar = YYEMPTY;
5793 }
5794 }
5795
5796 /* Else will try to reuse look-ahead token after shifting the error
5797 token. */
5798 goto yyerrlab1;
5799
5800
5801/*---------------------------------------------------.
5802| yyerrorlab -- error raised explicitly by YYERROR. |
5803`---------------------------------------------------*/
5804yyerrorlab:
5805
5806 /* Pacify compilers like GCC when the user code never invokes
5807 YYERROR and the label yyerrorlab therefore never appears in user
5808 code. */
5809 if (0)
5810 goto yyerrorlab;
5811
5812yyvsp -= yylen;
5813 yyssp -= yylen;
5814 yystate = *yyssp;
5815 goto yyerrlab1;
5816
5817
5818/*-------------------------------------------------------------.
5819| yyerrlab1 -- common code for both syntax error and YYERROR. |
5820`-------------------------------------------------------------*/
5821yyerrlab1:
5822 yyerrstatus = 3; /* Each real token shifted decrements this. */
5823
5824 for (;;)
5825 {
5826 yyn = yypact[yystate];
5827 if (yyn != YYPACT_NINF)
5828 {
5829 yyn += YYTERROR;
5830 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
5831 {
5832 yyn = yytable[yyn];
5833 if (0 < yyn)
5834 break;
5835 }
5836 }
5837
5838 /* Pop the current state because it cannot handle the error token. */
5839 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005840 YYABORT;
5841
Reid Spencere4d87aa2006-12-23 06:05:41 +00005842
Reid Spencer38c91a92007-02-28 02:24:54 +00005843 yydestruct ("Error: popping", yystos[yystate], yyvsp);
5844 YYPOPSTACK;
5845 yystate = *yyssp;
5846 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005847 }
5848
5849 if (yyn == YYFINAL)
5850 YYACCEPT;
5851
Reid Spencer68a24bd2005-08-27 18:50:39 +00005852 *++yyvsp = yylval;
Reid Spencer38c91a92007-02-28 02:24:54 +00005853
5854
5855 /* Shift the error token. */
5856 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spencer41dff5e2007-01-26 08:05:27 +00005857
Reid Spencer68a24bd2005-08-27 18:50:39 +00005858 yystate = yyn;
5859 goto yynewstate;
5860
Chris Lattner32980692007-02-19 07:44:24 +00005861
Reid Spencer38c91a92007-02-28 02:24:54 +00005862/*-------------------------------------.
5863| yyacceptlab -- YYACCEPT comes here. |
5864`-------------------------------------*/
5865yyacceptlab:
5866 yyresult = 0;
5867 goto yyreturn;
5868
5869/*-----------------------------------.
5870| yyabortlab -- YYABORT comes here. |
5871`-----------------------------------*/
5872yyabortlab:
5873 yyresult = 1;
5874 goto yyreturn;
5875
5876#ifndef yyoverflow
5877/*-------------------------------------------------.
5878| yyexhaustedlab -- memory exhaustion comes here. |
5879`-------------------------------------------------*/
5880yyexhaustedlab:
5881 yyerror (YY_("memory exhausted"));
5882 yyresult = 2;
5883 /* Fall through. */
Chris Lattner32980692007-02-19 07:44:24 +00005884#endif
Reid Spencer38c91a92007-02-28 02:24:54 +00005885
5886yyreturn:
5887 if (yychar != YYEOF && yychar != YYEMPTY)
5888 yydestruct ("Cleanup: discarding lookahead",
5889 yytoken, &yylval);
5890 while (yyssp != yyss)
5891 {
5892 yydestruct ("Cleanup: popping",
5893 yystos[*yyssp], yyvsp);
5894 YYPOPSTACK;
Chris Lattner32980692007-02-19 07:44:24 +00005895 }
Reid Spencer38c91a92007-02-28 02:24:54 +00005896#ifndef yyoverflow
5897 if (yyss != yyssa)
5898 YYSTACK_FREE (yyss);
5899#endif
5900 return yyresult;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005901}
Reid Spencer38c91a92007-02-28 02:24:54 +00005902
5903
Reid Spencer49d273e2007-03-19 20:40:51 +00005904#line 2917 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00005905
5906
Reid Spencer14310612006-12-31 05:40:51 +00005907// common code from the two 'RunVMAsmParser' functions
5908static Module* RunParser(Module * M) {
5909
5910 llvmAsmlineno = 1; // Reset the current line number...
5911 CurModule.CurrentModule = M;
5912#if YYDEBUG
5913 yydebug = Debug;
5914#endif
5915
5916 // Check to make sure the parser succeeded
5917 if (yyparse()) {
5918 if (ParserResult)
5919 delete ParserResult;
5920 return 0;
5921 }
5922
5923 // Check to make sure that parsing produced a result
5924 if (!ParserResult)
5925 return 0;
5926
5927 // Reset ParserResult variable while saving its value for the result.
5928 Module *Result = ParserResult;
5929 ParserResult = 0;
5930
5931 return Result;
5932}
5933
Reid Spencer61c83e02006-08-18 08:43:06 +00005934void llvm::GenerateError(const std::string &message, int LineNo) {
5935 if (LineNo == -1) LineNo = llvmAsmlineno;
5936 // TODO: column number in exception
5937 if (TheParseError)
5938 TheParseError->setError(CurFilename, message, LineNo);
5939 TriggerError = 1;
5940}
Reid Spencer68a24bd2005-08-27 18:50:39 +00005941
5942int yyerror(const char *ErrorMsg) {
5943 std::string where
5944 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
5945 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
Reid Spenceref9b9a72007-02-05 20:47:22 +00005946 std::string errMsg = where + "error: " + std::string(ErrorMsg);
5947 if (yychar != YYEMPTY && yychar != 0)
5948 errMsg += " while reading token: '" + std::string(llvmAsmtext, llvmAsmleng)+
5949 "'";
Reid Spencer61c83e02006-08-18 08:43:06 +00005950 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005951 return 0;
5952}
Reid Spencer38c91a92007-02-28 02:24:54 +00005953