blob: 28061f8e3f8ece3f195dc302e54a0cc9906dbfd9 [file] [log] [blame]
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00001/* A Bison parser, made by GNU Bison 2.3. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003/* Skeleton implementation for Bison's Yacc-like parsers in C
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
6 Free Software Foundation, Inc.
Anton Korobeynikov178a3522007-01-12 19:22:51 +00007
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00008 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
22
23/* As a special exception, you may create a larger work that contains
24 part or all of the Bison parser skeleton and distribute that work
25 under terms of your choice, so long as that work isn't itself a
26 parser generator using the skeleton or a modified version thereof
27 as a parser skeleton. Alternatively, if you modify or redistribute
28 the parser skeleton itself, you may (at your option) remove this
29 special exception, which will cause the skeleton and the resulting
30 Bison output files to be licensed under the GNU General Public
31 License without this special exception.
32
33 This special exception was added by the Free Software Foundation in
34 version 2.2 of Bison. */
35
36/* C LALR(1) parser skeleton written by Richard Stallman, by
37 simplifying the original so-called "semantic" parser. */
38
39/* All symbols defined below should begin with yy or YY, to avoid
40 infringing on user name space. This should be done even for local
41 variables, as they might otherwise be expanded by user macros.
42 There are some unavoidable exceptions within include files to
43 define necessary library symbols; they are noted "INFRINGES ON
44 USER NAME SPACE" below. */
45
46/* Identify Bison output. */
47#define YYBISON 1
48
49/* Bison version. */
50#define YYBISON_VERSION "2.3"
51
52/* Skeleton name. */
53#define YYSKELETON_NAME "yacc.c"
54
55/* Pure parsers. */
56#define YYPURE 0
57
58/* Using locations. */
59#define YYLSP_NEEDED 0
60
61/* Substitute the variable and function names. */
Reid Spencer68a24bd2005-08-27 18:50:39 +000062#define yyparse llvmAsmparse
Anton Korobeynikov77d0f972007-04-25 14:29:12 +000063#define yylex llvmAsmlex
Reid Spencer68a24bd2005-08-27 18:50:39 +000064#define yyerror llvmAsmerror
Anton Korobeynikov77d0f972007-04-25 14:29:12 +000065#define yylval llvmAsmlval
66#define yychar llvmAsmchar
Reid Spencer68a24bd2005-08-27 18:50:39 +000067#define yydebug llvmAsmdebug
68#define yynerrs llvmAsmnerrs
69
Anton Korobeynikov77d0f972007-04-25 14:29:12 +000070
71/* Tokens. */
72#ifndef YYTOKENTYPE
73# define YYTOKENTYPE
74 /* Put the tokens into the symbol table, so that GDB and other debuggers
75 know about them. */
76 enum yytokentype {
77 ESINT64VAL = 258,
78 EUINT64VAL = 259,
79 ESAPINTVAL = 260,
80 EUAPINTVAL = 261,
81 LOCALVAL_ID = 262,
82 GLOBALVAL_ID = 263,
83 FPVAL = 264,
84 VOID = 265,
85 INTTYPE = 266,
86 FLOAT = 267,
87 DOUBLE = 268,
88 LABEL = 269,
89 TYPE = 270,
90 LOCALVAR = 271,
91 GLOBALVAR = 272,
92 LABELSTR = 273,
93 STRINGCONSTANT = 274,
94 ATSTRINGCONSTANT = 275,
95 ZEROINITIALIZER = 276,
96 TRUETOK = 277,
97 FALSETOK = 278,
98 BEGINTOK = 279,
99 ENDTOK = 280,
100 DECLARE = 281,
101 DEFINE = 282,
102 GLOBAL = 283,
103 CONSTANT = 284,
104 SECTION = 285,
105 ALIAS = 286,
106 VOLATILE = 287,
107 THREAD_LOCAL = 288,
108 TO = 289,
109 DOTDOTDOT = 290,
110 NULL_TOK = 291,
111 UNDEF = 292,
112 INTERNAL = 293,
113 LINKONCE = 294,
114 WEAK = 295,
115 APPENDING = 296,
116 DLLIMPORT = 297,
117 DLLEXPORT = 298,
118 EXTERN_WEAK = 299,
119 OPAQUE = 300,
120 EXTERNAL = 301,
121 TARGET = 302,
122 TRIPLE = 303,
123 ALIGN = 304,
124 DEPLIBS = 305,
125 CALL = 306,
126 TAIL = 307,
127 ASM_TOK = 308,
128 MODULE = 309,
129 SIDEEFFECT = 310,
130 CC_TOK = 311,
131 CCC_TOK = 312,
132 FASTCC_TOK = 313,
133 COLDCC_TOK = 314,
134 X86_STDCALLCC_TOK = 315,
135 X86_FASTCALLCC_TOK = 316,
136 DATALAYOUT = 317,
137 RET = 318,
138 BR = 319,
139 SWITCH = 320,
140 INVOKE = 321,
141 UNWIND = 322,
142 UNREACHABLE = 323,
143 ADD = 324,
144 SUB = 325,
145 MUL = 326,
146 UDIV = 327,
147 SDIV = 328,
148 FDIV = 329,
149 UREM = 330,
150 SREM = 331,
151 FREM = 332,
152 AND = 333,
153 OR = 334,
154 XOR = 335,
155 SHL = 336,
156 LSHR = 337,
157 ASHR = 338,
158 ICMP = 339,
159 FCMP = 340,
160 EQ = 341,
161 NE = 342,
162 SLT = 343,
163 SGT = 344,
164 SLE = 345,
165 SGE = 346,
166 ULT = 347,
167 UGT = 348,
168 ULE = 349,
169 UGE = 350,
170 OEQ = 351,
171 ONE = 352,
172 OLT = 353,
173 OGT = 354,
174 OLE = 355,
175 OGE = 356,
176 ORD = 357,
177 UNO = 358,
178 UEQ = 359,
179 UNE = 360,
180 MALLOC = 361,
181 ALLOCA = 362,
182 FREE = 363,
183 LOAD = 364,
184 STORE = 365,
185 GETELEMENTPTR = 366,
186 TRUNC = 367,
187 ZEXT = 368,
188 SEXT = 369,
189 FPTRUNC = 370,
190 FPEXT = 371,
191 BITCAST = 372,
192 UITOFP = 373,
193 SITOFP = 374,
194 FPTOUI = 375,
195 FPTOSI = 376,
196 INTTOPTR = 377,
197 PTRTOINT = 378,
198 PHI_TOK = 379,
199 SELECT = 380,
200 VAARG = 381,
201 EXTRACTELEMENT = 382,
202 INSERTELEMENT = 383,
203 SHUFFLEVECTOR = 384,
204 NORETURN = 385,
205 INREG = 386,
206 SRET = 387,
207 NOUNWIND = 388,
208 DEFAULT = 389,
209 HIDDEN = 390
210 };
211#endif
212/* Tokens. */
213#define ESINT64VAL 258
214#define EUINT64VAL 259
215#define ESAPINTVAL 260
216#define EUAPINTVAL 261
217#define LOCALVAL_ID 262
218#define GLOBALVAL_ID 263
219#define FPVAL 264
220#define VOID 265
221#define INTTYPE 266
222#define FLOAT 267
223#define DOUBLE 268
224#define LABEL 269
225#define TYPE 270
226#define LOCALVAR 271
227#define GLOBALVAR 272
228#define LABELSTR 273
229#define STRINGCONSTANT 274
230#define ATSTRINGCONSTANT 275
231#define ZEROINITIALIZER 276
232#define TRUETOK 277
233#define FALSETOK 278
234#define BEGINTOK 279
235#define ENDTOK 280
236#define DECLARE 281
237#define DEFINE 282
238#define GLOBAL 283
239#define CONSTANT 284
240#define SECTION 285
241#define ALIAS 286
242#define VOLATILE 287
243#define THREAD_LOCAL 288
244#define TO 289
245#define DOTDOTDOT 290
246#define NULL_TOK 291
247#define UNDEF 292
248#define INTERNAL 293
249#define LINKONCE 294
250#define WEAK 295
251#define APPENDING 296
252#define DLLIMPORT 297
253#define DLLEXPORT 298
254#define EXTERN_WEAK 299
255#define OPAQUE 300
256#define EXTERNAL 301
257#define TARGET 302
258#define TRIPLE 303
259#define ALIGN 304
260#define DEPLIBS 305
261#define CALL 306
262#define TAIL 307
263#define ASM_TOK 308
264#define MODULE 309
265#define SIDEEFFECT 310
266#define CC_TOK 311
267#define CCC_TOK 312
268#define FASTCC_TOK 313
269#define COLDCC_TOK 314
270#define X86_STDCALLCC_TOK 315
271#define X86_FASTCALLCC_TOK 316
272#define DATALAYOUT 317
273#define RET 318
274#define BR 319
275#define SWITCH 320
276#define INVOKE 321
277#define UNWIND 322
278#define UNREACHABLE 323
279#define ADD 324
280#define SUB 325
281#define MUL 326
282#define UDIV 327
283#define SDIV 328
284#define FDIV 329
285#define UREM 330
286#define SREM 331
287#define FREM 332
288#define AND 333
289#define OR 334
290#define XOR 335
291#define SHL 336
292#define LSHR 337
293#define ASHR 338
294#define ICMP 339
295#define FCMP 340
296#define EQ 341
297#define NE 342
298#define SLT 343
299#define SGT 344
300#define SLE 345
301#define SGE 346
302#define ULT 347
303#define UGT 348
304#define ULE 349
305#define UGE 350
306#define OEQ 351
307#define ONE 352
308#define OLT 353
309#define OGT 354
310#define OLE 355
311#define OGE 356
312#define ORD 357
313#define UNO 358
314#define UEQ 359
315#define UNE 360
316#define MALLOC 361
317#define ALLOCA 362
318#define FREE 363
319#define LOAD 364
320#define STORE 365
321#define GETELEMENTPTR 366
322#define TRUNC 367
323#define ZEXT 368
324#define SEXT 369
325#define FPTRUNC 370
326#define FPEXT 371
327#define BITCAST 372
328#define UITOFP 373
329#define SITOFP 374
330#define FPTOUI 375
331#define FPTOSI 376
332#define INTTOPTR 377
333#define PTRTOINT 378
334#define PHI_TOK 379
335#define SELECT 380
336#define VAARG 381
337#define EXTRACTELEMENT 382
338#define INSERTELEMENT 383
339#define SHUFFLEVECTOR 384
340#define NORETURN 385
341#define INREG 386
342#define SRET 387
343#define NOUNWIND 388
344#define DEFAULT 389
345#define HIDDEN 390
346
347
348
349
350/* Copy the first part of user declarations. */
351#line 14 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000352
353#include "ParserInternals.h"
354#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000355#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000356#include "llvm/Instructions.h"
357#include "llvm/Module.h"
Reid Spenceref9b9a72007-02-05 20:47:22 +0000358#include "llvm/ValueSymbolTable.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000359#include "llvm/Support/GetElementPtrTypeIterator.h"
Reid Spencer14310612006-12-31 05:40:51 +0000360#include "llvm/Support/CommandLine.h"
Chris Lattnerf7469af2007-01-31 04:44:08 +0000361#include "llvm/ADT/SmallVector.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000362#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000363#include "llvm/Support/MathExtras.h"
Reid Spencer481169e2006-12-01 00:33:46 +0000364#include "llvm/Support/Streams.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000365#include <algorithm>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000366#include <list>
Chris Lattner8adde282007-02-11 21:40:10 +0000367#include <map>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000368#include <utility>
Reid Spencer14310612006-12-31 05:40:51 +0000369#ifndef NDEBUG
370#define YYDEBUG 1
371#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000372
Reid Spencere4f47592006-08-18 17:32:55 +0000373// The following is a gross hack. In order to rid the libAsmParser library of
374// exceptions, we have to have a way of getting the yyparse function to go into
375// an error situation. So, whenever we want an error to occur, the GenerateError
376// function (see bottom of file) sets TriggerError. Then, at the end of each
377// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
378// (a goto) to put YACC in error state. Furthermore, several calls to
379// GenerateError are made from inside productions and they must simulate the
380// previous exception behavior by exiting the production immediately. We have
381// replaced these with the GEN_ERROR macro which calls GeneratError and then
382// immediately invokes YYERROR. This would be so much cleaner if it was a
383// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000384static bool TriggerError = false;
Reid Spencerf63697d2006-10-09 17:36:59 +0000385#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000386#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
387
Reid Spencer68a24bd2005-08-27 18:50:39 +0000388int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
389int yylex(); // declaration" of xxx warnings.
390int yyparse();
391
392namespace llvm {
393 std::string CurFilename;
Reid Spencer14310612006-12-31 05:40:51 +0000394#if YYDEBUG
395static cl::opt<bool>
396Debug("debug-yacc", cl::desc("Print yacc debug state changes"),
397 cl::Hidden, cl::init(false));
398#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000399}
400using namespace llvm;
401
402static Module *ParserResult;
403
404// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
405// relating to upreferences in the input stream.
406//
407//#define DEBUG_UPREFS 1
408#ifdef DEBUG_UPREFS
Bill Wendlinge8156192006-12-07 01:30:32 +0000409#define UR_OUT(X) cerr << X
Reid Spencer68a24bd2005-08-27 18:50:39 +0000410#else
411#define UR_OUT(X)
412#endif
413
414#define YYERROR_VERBOSE 1
415
Chris Lattnerb475c422005-11-12 18:22:38 +0000416static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000417
418
419// This contains info used when building the body of a function. It is
420// destroyed when the function is completed.
421//
422typedef std::vector<Value *> ValueList; // Numbered defs
Reid Spencer14310612006-12-31 05:40:51 +0000423
Reid Spencer68a24bd2005-08-27 18:50:39 +0000424static void
Reid Spencer93c40032007-03-19 18:40:50 +0000425ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000426
427static struct PerModuleInfo {
428 Module *CurrentModule;
Reid Spencer93c40032007-03-19 18:40:50 +0000429 ValueList Values; // Module level numbered definitions
430 ValueList LateResolveValues;
Reid Spencer861d9d62006-11-28 07:29:44 +0000431 std::vector<PATypeHolder> Types;
432 std::map<ValID, PATypeHolder> LateResolveTypes;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000433
434 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000435 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000436 /// that we can resolve them later and print error messages as appropriate.
437 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
438
439 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
440 // references to global values. Global values may be referenced before they
441 // are defined, and if so, the temporary object that they represent is held
442 // here. This is used for forward references of GlobalValues.
443 //
444 typedef std::map<std::pair<const PointerType *,
445 ValID>, GlobalValue*> GlobalRefsType;
446 GlobalRefsType GlobalRefs;
447
448 void ModuleDone() {
449 // If we could not resolve some functions at function compilation time
450 // (calls to functions before they are defined), resolve them now... Types
451 // are resolved when the constant pool has been completely parsed.
452 //
453 ResolveDefinitions(LateResolveValues);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000454 if (TriggerError)
455 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000456
457 // Check to make sure that all global value forward references have been
458 // resolved!
459 //
460 if (!GlobalRefs.empty()) {
461 std::string UndefinedReferences = "Unresolved global references exist:\n";
462
463 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
464 I != E; ++I) {
465 UndefinedReferences += " " + I->first.first->getDescription() + " " +
466 I->first.second.getName() + "\n";
467 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000468 GenerateError(UndefinedReferences);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000469 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000470 }
471
472 Values.clear(); // Clear out function local definitions
473 Types.clear();
474 CurrentModule = 0;
475 }
476
Reid Spencer68a24bd2005-08-27 18:50:39 +0000477 // GetForwardRefForGlobal - Check to see if there is a forward reference
478 // for this global. If so, remove it from the GlobalRefs map and return it.
479 // If not, just return null.
480 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
481 // Check to see if there is a forward reference to this global variable...
482 // if there is, eliminate it and patch the reference to use the new def'n.
483 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
484 GlobalValue *Ret = 0;
485 if (I != GlobalRefs.end()) {
486 Ret = I->second;
487 GlobalRefs.erase(I);
488 }
489 return Ret;
490 }
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000491
492 bool TypeIsUnresolved(PATypeHolder* PATy) {
493 // If it isn't abstract, its resolved
494 const Type* Ty = PATy->get();
495 if (!Ty->isAbstract())
496 return false;
497 // Traverse the type looking for abstract types. If it isn't abstract then
498 // we don't need to traverse that leg of the type.
499 std::vector<const Type*> WorkList, SeenList;
500 WorkList.push_back(Ty);
501 while (!WorkList.empty()) {
502 const Type* Ty = WorkList.back();
503 SeenList.push_back(Ty);
504 WorkList.pop_back();
505 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
506 // Check to see if this is an unresolved type
507 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
508 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
509 for ( ; I != E; ++I) {
510 if (I->second.get() == OpTy)
511 return true;
512 }
513 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
514 const Type* TheTy = SeqTy->getElementType();
515 if (TheTy->isAbstract() && TheTy != Ty) {
516 std::vector<const Type*>::iterator I = SeenList.begin(),
517 E = SeenList.end();
518 for ( ; I != E; ++I)
519 if (*I == TheTy)
520 break;
521 if (I == E)
522 WorkList.push_back(TheTy);
523 }
524 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
525 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
526 const Type* TheTy = StrTy->getElementType(i);
527 if (TheTy->isAbstract() && TheTy != Ty) {
528 std::vector<const Type*>::iterator I = SeenList.begin(),
529 E = SeenList.end();
530 for ( ; I != E; ++I)
531 if (*I == TheTy)
532 break;
533 if (I == E)
534 WorkList.push_back(TheTy);
535 }
536 }
537 }
538 }
539 return false;
540 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000541} CurModule;
542
543static struct PerFunctionInfo {
544 Function *CurrentFunction; // Pointer to current function being created
545
Reid Spencer93c40032007-03-19 18:40:50 +0000546 ValueList Values; // Keep track of #'d definitions
547 unsigned NextValNum;
548 ValueList LateResolveValues;
Reid Spenceref9b9a72007-02-05 20:47:22 +0000549 bool isDeclare; // Is this function a forward declararation?
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000550 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000551 GlobalValue::VisibilityTypes Visibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000552
553 /// BBForwardRefs - When we see forward references to basic blocks, keep
554 /// track of them here.
Reid Spencer93c40032007-03-19 18:40:50 +0000555 std::map<ValID, BasicBlock*> BBForwardRefs;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000556
557 inline PerFunctionInfo() {
558 CurrentFunction = 0;
559 isDeclare = false;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000560 Linkage = GlobalValue::ExternalLinkage;
561 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000562 }
563
564 inline void FunctionStart(Function *M) {
565 CurrentFunction = M;
Reid Spencer93c40032007-03-19 18:40:50 +0000566 NextValNum = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000567 }
568
569 void FunctionDone() {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000570 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000571 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000572 GenerateError("Undefined reference to label " +
Reid Spencer93c40032007-03-19 18:40:50 +0000573 BBForwardRefs.begin()->second->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000574 return;
575 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000576
577 // Resolve all forward references now.
578 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
579
580 Values.clear(); // Clear out function local definitions
Reid Spencer93c40032007-03-19 18:40:50 +0000581 BBForwardRefs.clear();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000582 CurrentFunction = 0;
583 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000584 Linkage = GlobalValue::ExternalLinkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000585 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000586 }
587} CurFun; // Info for the current function...
588
589static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
590
591
592//===----------------------------------------------------------------------===//
593// Code to handle definitions of all the types
594//===----------------------------------------------------------------------===//
595
Reid Spencer93c40032007-03-19 18:40:50 +0000596static void InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) {
597 // Things that have names or are void typed don't get slot numbers
598 if (V->hasName() || (V->getType() == Type::VoidTy))
599 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000600
Reid Spencer93c40032007-03-19 18:40:50 +0000601 // In the case of function values, we have to allow for the forward reference
602 // of basic blocks, which are included in the numbering. Consequently, we keep
603 // track of the next insertion location with NextValNum. When a BB gets
604 // inserted, it could change the size of the CurFun.Values vector.
605 if (&ValueTab == &CurFun.Values) {
606 if (ValueTab.size() <= CurFun.NextValNum)
607 ValueTab.resize(CurFun.NextValNum+1);
608 ValueTab[CurFun.NextValNum++] = V;
609 return;
610 }
611 // For all other lists, its okay to just tack it on the back of the vector.
612 ValueTab.push_back(V);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000613}
614
615static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
616 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000617 case ValID::LocalID: // Is it a numbered definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000618 // Module constants occupy the lowest numbered slots...
Reid Spencer41dff5e2007-01-26 08:05:27 +0000619 if (D.Num < CurModule.Types.size())
620 return CurModule.Types[D.Num];
Reid Spencer68a24bd2005-08-27 18:50:39 +0000621 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000622 case ValID::LocalName: // Is it a named definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000623 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
624 D.destroy(); // Free old strdup'd memory...
625 return N;
626 }
627 break;
628 default:
Reid Spencerb5334b02007-02-05 10:18:06 +0000629 GenerateError("Internal parser error: Invalid symbol type reference");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000630 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000631 }
632
633 // If we reached here, we referenced either a symbol that we don't know about
634 // or an id number that hasn't been read yet. We may be referencing something
635 // forward, so just create an entry to be resolved later and get to it...
636 //
637 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
638
639
640 if (inFunctionScope()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000641 if (D.Type == ValID::LocalName) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000642 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000643 return 0;
644 } else {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000645 GenerateError("Reference to an undefined type: #" + utostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000646 return 0;
647 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000648 }
649
Reid Spencer861d9d62006-11-28 07:29:44 +0000650 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000651 if (I != CurModule.LateResolveTypes.end())
Reid Spencer861d9d62006-11-28 07:29:44 +0000652 return I->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000653
Reid Spencer861d9d62006-11-28 07:29:44 +0000654 Type *Typ = OpaqueType::get();
655 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
656 return Typ;
Reid Spencera132e042006-12-03 05:46:11 +0000657 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000658
Reid Spencer93c40032007-03-19 18:40:50 +0000659// getExistingVal - Look up the value specified by the provided type and
Reid Spencer68a24bd2005-08-27 18:50:39 +0000660// the provided ValID. If the value exists and has already been defined, return
661// it. Otherwise return null.
662//
Reid Spencer93c40032007-03-19 18:40:50 +0000663static Value *getExistingVal(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000664 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000665 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000666 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000667 return 0;
668 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000669
670 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000671 case ValID::LocalID: { // Is it a numbered definition?
Reid Spencer41dff5e2007-01-26 08:05:27 +0000672 // Check that the number is within bounds.
Reid Spencer93c40032007-03-19 18:40:50 +0000673 if (D.Num >= CurFun.Values.size())
674 return 0;
675 Value *Result = CurFun.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() + "'");
680 return 0;
681 }
682 return Result;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000683 }
684 case ValID::GlobalID: { // Is it a numbered definition?
Reid Spencer93c40032007-03-19 18:40:50 +0000685 if (D.Num >= CurModule.Values.size())
Reid Spenceref9b9a72007-02-05 20:47:22 +0000686 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000687 Value *Result = CurModule.Values[D.Num];
688 if (Ty != Result->getType()) {
689 GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" +
690 Result->getType()->getDescription() + "' does not match "
691 "expected type, '" + Ty->getDescription() + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +0000692 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000693 }
694 return Result;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000695 }
Reid Spencer41dff5e2007-01-26 08:05:27 +0000696
697 case ValID::LocalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000698 if (!inFunctionScope())
699 return 0;
700 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
701 Value *N = SymTab.lookup(D.Name);
702 if (N == 0)
703 return 0;
704 if (N->getType() != Ty)
705 return 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000706
707 D.destroy(); // Free old strdup'd memory...
708 return N;
709 }
710 case ValID::GlobalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000711 ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
712 Value *N = SymTab.lookup(D.Name);
713 if (N == 0)
714 return 0;
715 if (N->getType() != Ty)
716 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000717
718 D.destroy(); // Free old strdup'd memory...
719 return N;
720 }
721
722 // Check to make sure that "Ty" is an integral type, and that our
723 // value will fit into the specified type...
724 case ValID::ConstSIntVal: // Is it a constant pool reference??
Reid Spencerb83eb642006-10-20 07:07:24 +0000725 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000726 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000727 itostr(D.ConstPool64) + "' is invalid for type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000728 Ty->getDescription() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000729 return 0;
730 }
Reid Spencer49d273e2007-03-19 20:40:51 +0000731 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000732
733 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Reid Spencerb83eb642006-10-20 07:07:24 +0000734 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
735 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000736 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
Reid Spencerb5334b02007-02-05 10:18:06 +0000737 "' is invalid or out of range");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000738 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000739 } else { // This is really a signed reference. Transmogrify.
Reid Spencer49d273e2007-03-19 20:40:51 +0000740 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000741 }
742 } else {
Reid Spencerb83eb642006-10-20 07:07:24 +0000743 return ConstantInt::get(Ty, D.UConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000744 }
745
746 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000747 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000748 GenerateError("FP constant invalid for type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000749 return 0;
750 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000751 return ConstantFP::get(Ty, D.ConstPoolFP);
752
753 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000754 if (!isa<PointerType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000755 GenerateError("Cannot create a a non pointer null");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000756 return 0;
757 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000758 return ConstantPointerNull::get(cast<PointerType>(Ty));
759
760 case ValID::ConstUndefVal: // Is it an undef value?
761 return UndefValue::get(Ty);
762
Chris Lattner7aa61892005-12-21 17:53:23 +0000763 case ValID::ConstZeroVal: // Is it a zero value?
764 return Constant::getNullValue(Ty);
765
Reid Spencer68a24bd2005-08-27 18:50:39 +0000766 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000767 if (D.ConstantValue->getType() != Ty) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000768 GenerateError("Constant expression type different from required type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000769 return 0;
770 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000771 return D.ConstantValue;
772
Chris Lattner0e9c3762006-01-25 22:27:16 +0000773 case ValID::InlineAsmVal: { // Inline asm expression
774 const PointerType *PTy = dyn_cast<PointerType>(Ty);
775 const FunctionType *FTy =
776 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000777 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000778 GenerateError("Invalid type for asm constraint string");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000779 return 0;
780 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000781 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
782 D.IAD->HasSideEffects);
783 D.destroy(); // Free InlineAsmDescriptor.
784 return IA;
785 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000786 default:
Reid Spencera9720f52007-02-05 17:04:00 +0000787 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000788 return 0;
789 } // End of switch
790
Reid Spencera9720f52007-02-05 17:04:00 +0000791 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000792 return 0;
793}
794
Reid Spencer93c40032007-03-19 18:40:50 +0000795// getVal - This function is identical to getExistingVal, except that if a
Reid Spencer68a24bd2005-08-27 18:50:39 +0000796// value is not already defined, it "improvises" by creating a placeholder var
797// that looks and acts just like the requested variable. When the value is
798// defined later, all uses of the placeholder variable are replaced with the
799// real thing.
800//
801static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000802 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000803 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000804 return 0;
805 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000806
807 // See if the value has already been defined.
Reid Spencer93c40032007-03-19 18:40:50 +0000808 Value *V = getExistingVal(Ty, ID);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000809 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000810 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000811
Reid Spencer5b7e7532006-09-28 19:28:24 +0000812 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000813 GenerateError("Invalid use of a composite type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000814 return 0;
815 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000816
817 // If we reached here, we referenced either a symbol that we don't know about
818 // or an id number that hasn't been read yet. We may be referencing something
819 // forward, so just create an entry to be resolved later and get to it...
820 //
821 V = new Argument(Ty);
822
823 // Remember where this forward reference came from. FIXME, shouldn't we try
824 // to recycle these things??
825 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
826 llvmAsmlineno)));
827
828 if (inFunctionScope())
829 InsertValue(V, CurFun.LateResolveValues);
830 else
831 InsertValue(V, CurModule.LateResolveValues);
832 return V;
833}
834
Reid Spencer93c40032007-03-19 18:40:50 +0000835/// defineBBVal - This is a definition of a new basic block with the specified
836/// identifier which must be the same as CurFun.NextValNum, if its numeric.
837static BasicBlock *defineBBVal(const ValID &ID) {
Reid Spencera9720f52007-02-05 17:04:00 +0000838 assert(inFunctionScope() && "Can't get basic block at global scope!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000839
Reid Spencer68a24bd2005-08-27 18:50:39 +0000840 BasicBlock *BB = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000841
Reid Spencer93c40032007-03-19 18:40:50 +0000842 // First, see if this was forward referenced
Reid Spencer68a24bd2005-08-27 18:50:39 +0000843
Reid Spencer93c40032007-03-19 18:40:50 +0000844 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
845 if (BBI != CurFun.BBForwardRefs.end()) {
846 BB = BBI->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000847 // The forward declaration could have been inserted anywhere in the
848 // function: insert it into the correct place now.
849 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
850 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
Reid Spencer93c40032007-03-19 18:40:50 +0000851
Reid Spencer66728ef2007-03-20 01:13:36 +0000852 // We're about to erase the entry, save the key so we can clean it up.
853 ValID Tmp = BBI->first;
854
Reid Spencer93c40032007-03-19 18:40:50 +0000855 // Erase the forward ref from the map as its no longer "forward"
856 CurFun.BBForwardRefs.erase(ID);
857
Reid Spencer66728ef2007-03-20 01:13:36 +0000858 // The key has been removed from the map but so we don't want to leave
859 // strdup'd memory around so destroy it too.
860 Tmp.destroy();
861
Reid Spencer93c40032007-03-19 18:40:50 +0000862 // If its a numbered definition, bump the number and set the BB value.
863 if (ID.Type == ValID::LocalID) {
864 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
865 InsertValue(BB);
866 }
867
868 ID.destroy();
869 return BB;
870 }
871
872 // We haven't seen this BB before and its first mention is a definition.
873 // Just create it and return it.
874 std::string Name (ID.Type == ValID::LocalName ? ID.Name : "");
875 BB = new BasicBlock(Name, CurFun.CurrentFunction);
876 if (ID.Type == ValID::LocalID) {
877 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
878 InsertValue(BB);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000879 }
Reid Spencer93c40032007-03-19 18:40:50 +0000880
881 ID.destroy(); // Free strdup'd memory
882 return BB;
883}
884
885/// getBBVal - get an existing BB value or create a forward reference for it.
886///
887static BasicBlock *getBBVal(const ValID &ID) {
888 assert(inFunctionScope() && "Can't get basic block at global scope!");
889
890 BasicBlock *BB = 0;
891
892 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
893 if (BBI != CurFun.BBForwardRefs.end()) {
894 BB = BBI->second;
895 } if (ID.Type == ValID::LocalName) {
896 std::string Name = ID.Name;
897 Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
898 if (N)
899 if (N->getType()->getTypeID() == Type::LabelTyID)
900 BB = cast<BasicBlock>(N);
901 else
902 GenerateError("Reference to label '" + Name + "' is actually of type '"+
903 N->getType()->getDescription() + "'");
904 } else if (ID.Type == ValID::LocalID) {
905 if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) {
906 if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID)
907 BB = cast<BasicBlock>(CurFun.Values[ID.Num]);
908 else
909 GenerateError("Reference to label '%" + utostr(ID.Num) +
910 "' is actually of type '"+
911 CurFun.Values[ID.Num]->getType()->getDescription() + "'");
912 }
913 } else {
914 GenerateError("Illegal label reference " + ID.getName());
915 return 0;
916 }
917
918 // If its already been defined, return it now.
919 if (BB) {
920 ID.destroy(); // Free strdup'd memory.
921 return BB;
922 }
923
924 // Otherwise, this block has not been seen before, create it.
925 std::string Name;
926 if (ID.Type == ValID::LocalName)
927 Name = ID.Name;
928 BB = new BasicBlock(Name, CurFun.CurrentFunction);
929
930 // Insert it in the forward refs map.
931 CurFun.BBForwardRefs[ID] = BB;
932
Reid Spencer68a24bd2005-08-27 18:50:39 +0000933 return BB;
934}
935
936
937//===----------------------------------------------------------------------===//
938// Code to handle forward references in instructions
939//===----------------------------------------------------------------------===//
940//
941// This code handles the late binding needed with statements that reference
942// values not defined yet... for example, a forward branch, or the PHI node for
943// a loop body.
944//
945// This keeps a table (CurFun.LateResolveValues) of all such forward references
946// and back patchs after we are done.
947//
948
949// ResolveDefinitions - If we could not resolve some defs at parsing
950// time (forward branches, phi functions for loops, etc...) resolve the
951// defs now...
952//
953static void
Reid Spencer93c40032007-03-19 18:40:50 +0000954ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000955 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
Reid Spencer93c40032007-03-19 18:40:50 +0000956 while (!LateResolvers.empty()) {
957 Value *V = LateResolvers.back();
958 LateResolvers.pop_back();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000959
Reid Spencer93c40032007-03-19 18:40:50 +0000960 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
961 CurModule.PlaceHolderInfo.find(V);
962 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000963
Reid Spencer93c40032007-03-19 18:40:50 +0000964 ValID &DID = PHI->second.first;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000965
Reid Spencer93c40032007-03-19 18:40:50 +0000966 Value *TheRealValue = getExistingVal(V->getType(), DID);
967 if (TriggerError)
968 return;
969 if (TheRealValue) {
970 V->replaceAllUsesWith(TheRealValue);
971 delete V;
972 CurModule.PlaceHolderInfo.erase(PHI);
973 } else if (FutureLateResolvers) {
974 // Functions have their unresolved items forwarded to the module late
975 // resolver table
976 InsertValue(V, *FutureLateResolvers);
977 } else {
978 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
979 GenerateError("Reference to an invalid definition: '" +DID.getName()+
980 "' of type '" + V->getType()->getDescription() + "'",
981 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000982 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000983 } else {
Reid Spencer93c40032007-03-19 18:40:50 +0000984 GenerateError("Reference to an invalid definition: #" +
985 itostr(DID.Num) + " of type '" +
986 V->getType()->getDescription() + "'",
987 PHI->second.second);
988 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000989 }
990 }
991 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000992 LateResolvers.clear();
993}
994
995// ResolveTypeTo - A brand new type was just declared. This means that (if
996// name is not null) things referencing Name can be resolved. Otherwise, things
997// refering to the number can be resolved. Do this now.
998//
999static void ResolveTypeTo(char *Name, const Type *ToTy) {
1000 ValID D;
Reid Spencer41dff5e2007-01-26 08:05:27 +00001001 if (Name) D = ValID::createLocalName(Name);
1002 else D = ValID::createLocalID(CurModule.Types.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001003
Reid Spencer861d9d62006-11-28 07:29:44 +00001004 std::map<ValID, PATypeHolder>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +00001005 CurModule.LateResolveTypes.find(D);
1006 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer861d9d62006-11-28 07:29:44 +00001007 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001008 CurModule.LateResolveTypes.erase(I);
1009 }
1010}
1011
1012// setValueName - Set the specified value to the name given. The name may be
1013// null potentially, in which case this is a noop. The string passed in is
1014// assumed to be a malloc'd string buffer, and is free'd by this function.
1015//
1016static void setValueName(Value *V, char *NameStr) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001017 if (!NameStr) return;
1018 std::string Name(NameStr); // Copy string
1019 free(NameStr); // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001020
Reid Spencer41dff5e2007-01-26 08:05:27 +00001021 if (V->getType() == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001022 GenerateError("Can't assign name '" + Name+"' to value with void type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001023 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001024 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00001025
Reid Spencera9720f52007-02-05 17:04:00 +00001026 assert(inFunctionScope() && "Must be in function scope!");
Reid Spenceref9b9a72007-02-05 20:47:22 +00001027 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1028 if (ST.lookup(Name)) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001029 GenerateError("Redefinition of value '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001030 V->getType()->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001031 return;
1032 }
1033
1034 // Set the name.
1035 V->setName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001036}
1037
1038/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1039/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +00001040static GlobalVariable *
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001041ParseGlobalVariable(char *NameStr,
1042 GlobalValue::LinkageTypes Linkage,
1043 GlobalValue::VisibilityTypes Visibility,
Chris Lattnerb475c422005-11-12 18:22:38 +00001044 bool isConstantGlobal, const Type *Ty,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001045 Constant *Initializer, bool IsThreadLocal) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001046 if (isa<FunctionType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001047 GenerateError("Cannot declare global vars of function type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001048 return 0;
1049 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001050
1051 const PointerType *PTy = PointerType::get(Ty);
1052
1053 std::string Name;
1054 if (NameStr) {
1055 Name = NameStr; // Copy string
1056 free(NameStr); // Free old string
1057 }
1058
1059 // See if this global value was forward referenced. If so, recycle the
1060 // object.
1061 ValID ID;
1062 if (!Name.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001063 ID = ValID::createGlobalName((char*)Name.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001064 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00001065 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001066 }
1067
1068 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1069 // Move the global to the end of the list, from whereever it was
1070 // previously inserted.
1071 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1072 CurModule.CurrentModule->getGlobalList().remove(GV);
1073 CurModule.CurrentModule->getGlobalList().push_back(GV);
1074 GV->setInitializer(Initializer);
1075 GV->setLinkage(Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001076 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001077 GV->setConstant(isConstantGlobal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001078 GV->setThreadLocal(IsThreadLocal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001079 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001080 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001081 }
1082
Reid Spenceref9b9a72007-02-05 20:47:22 +00001083 // If this global has a name
Reid Spencer68a24bd2005-08-27 18:50:39 +00001084 if (!Name.empty()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00001085 // if the global we're parsing has an initializer (is a definition) and
1086 // has external linkage.
1087 if (Initializer && Linkage != GlobalValue::InternalLinkage)
1088 // If there is already a global with external linkage with this name
1089 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
1090 // If we allow this GVar to get created, it will be renamed in the
1091 // symbol table because it conflicts with an existing GVar. We can't
1092 // allow redefinition of GVars whose linking indicates that their name
1093 // must stay the same. Issue the error.
1094 GenerateError("Redefinition of global variable named '" + Name +
1095 "' of type '" + Ty->getDescription() + "'");
1096 return 0;
1097 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001098 }
1099
1100 // Otherwise there is no existing GV to use, create one now.
1101 GlobalVariable *GV =
1102 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001103 CurModule.CurrentModule, IsThreadLocal);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001104 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001105 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001106 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001107}
1108
1109// setTypeName - Set the specified type to the name given. The name may be
1110// null potentially, in which case this is a noop. The string passed in is
1111// assumed to be a malloc'd string buffer, and is freed by this function.
1112//
1113// This function returns true if the type has already been defined, but is
1114// allowed to be redefined in the specified context. If the name is a new name
1115// for the type plane, it is inserted and false is returned.
1116static bool setTypeName(const Type *T, char *NameStr) {
Reid Spencera9720f52007-02-05 17:04:00 +00001117 assert(!inFunctionScope() && "Can't give types function-local names!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001118 if (NameStr == 0) return false;
1119
1120 std::string Name(NameStr); // Copy string
1121 free(NameStr); // Free old string
1122
1123 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +00001124 if (T == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001125 GenerateError("Can't assign name '" + Name + "' to the void type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001126 return false;
1127 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001128
1129 // Set the type name, checking for conflicts as we do so.
1130 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1131
1132 if (AlreadyExists) { // Inserting a name that is already defined???
1133 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
Reid Spencera9720f52007-02-05 17:04:00 +00001134 assert(Existing && "Conflict but no matching type?!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001135
1136 // There is only one case where this is allowed: when we are refining an
1137 // opaque type. In this case, Existing will be an opaque type.
1138 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1139 // We ARE replacing an opaque type!
1140 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1141 return true;
1142 }
1143
1144 // Otherwise, this is an attempt to redefine a type. That's okay if
1145 // the redefinition is identical to the original. This will be so if
1146 // Existing and T point to the same Type object. In this one case we
1147 // allow the equivalent redefinition.
1148 if (Existing == T) return true; // Yes, it's equal.
1149
1150 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer63c34452007-01-05 21:51:07 +00001151 GenerateError("Redefinition of type named '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001152 T->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001153 }
1154
1155 return false;
1156}
1157
1158//===----------------------------------------------------------------------===//
1159// Code for handling upreferences in type names...
1160//
1161
1162// TypeContains - Returns true if Ty directly contains E in it.
1163//
1164static bool TypeContains(const Type *Ty, const Type *E) {
1165 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1166 E) != Ty->subtype_end();
1167}
1168
1169namespace {
1170 struct UpRefRecord {
1171 // NestingLevel - The number of nesting levels that need to be popped before
1172 // this type is resolved.
1173 unsigned NestingLevel;
1174
1175 // LastContainedTy - This is the type at the current binding level for the
1176 // type. Every time we reduce the nesting level, this gets updated.
1177 const Type *LastContainedTy;
1178
1179 // UpRefTy - This is the actual opaque type that the upreference is
1180 // represented with.
1181 OpaqueType *UpRefTy;
1182
1183 UpRefRecord(unsigned NL, OpaqueType *URTy)
1184 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1185 };
1186}
1187
1188// UpRefs - A list of the outstanding upreferences that need to be resolved.
1189static std::vector<UpRefRecord> UpRefs;
1190
1191/// HandleUpRefs - Every time we finish a new layer of types, this function is
1192/// called. It loops through the UpRefs vector, which is a list of the
1193/// currently active types. For each type, if the up reference is contained in
1194/// the newly completed type, we decrement the level count. When the level
1195/// count reaches zero, the upreferenced type is the type that is passed in:
1196/// thus we can complete the cycle.
1197///
1198static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001199 // If Ty isn't abstract, or if there are no up-references in it, then there is
1200 // nothing to resolve here.
1201 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1202
Reid Spencer68a24bd2005-08-27 18:50:39 +00001203 PATypeHolder Ty(ty);
1204 UR_OUT("Type '" << Ty->getDescription() <<
1205 "' newly formed. Resolving upreferences.\n" <<
1206 UpRefs.size() << " upreferences active!\n");
1207
1208 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1209 // to zero), we resolve them all together before we resolve them to Ty. At
1210 // the end of the loop, if there is anything to resolve to Ty, it will be in
1211 // this variable.
1212 OpaqueType *TypeToResolve = 0;
1213
1214 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1215 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1216 << UpRefs[i].second->getDescription() << ") = "
1217 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1218 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1219 // Decrement level of upreference
1220 unsigned Level = --UpRefs[i].NestingLevel;
1221 UpRefs[i].LastContainedTy = Ty;
1222 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1223 if (Level == 0) { // Upreference should be resolved!
1224 if (!TypeToResolve) {
1225 TypeToResolve = UpRefs[i].UpRefTy;
1226 } else {
1227 UR_OUT(" * Resolving upreference for "
1228 << UpRefs[i].second->getDescription() << "\n";
1229 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1230 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1231 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1232 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1233 }
1234 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1235 --i; // Do not skip the next element...
1236 }
1237 }
1238 }
1239
1240 if (TypeToResolve) {
1241 UR_OUT(" * Resolving upreference for "
1242 << UpRefs[i].second->getDescription() << "\n";
1243 std::string OldName = TypeToResolve->getDescription());
1244 TypeToResolve->refineAbstractTypeTo(Ty);
1245 }
1246
1247 return Ty;
1248}
1249
Reid Spencer68a24bd2005-08-27 18:50:39 +00001250//===----------------------------------------------------------------------===//
1251// RunVMAsmParser - Define an interface to this parser
1252//===----------------------------------------------------------------------===//
1253//
Reid Spencer14310612006-12-31 05:40:51 +00001254static Module* RunParser(Module * M);
1255
Reid Spencer68a24bd2005-08-27 18:50:39 +00001256Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1257 set_scan_file(F);
1258
1259 CurFilename = Filename;
1260 return RunParser(new Module(CurFilename));
1261}
1262
1263Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1264 set_scan_string(AsmString);
1265
1266 CurFilename = "from_memory";
1267 if (M == NULL) {
1268 return RunParser(new Module (CurFilename));
1269 } else {
1270 return RunParser(M);
1271 }
1272}
1273
1274
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00001275
1276/* Enabling traces. */
1277#ifndef YYDEBUG
1278# define YYDEBUG 0
1279#endif
1280
1281/* Enabling verbose error messages. */
1282#ifdef YYERROR_VERBOSE
1283# undef YYERROR_VERBOSE
1284# define YYERROR_VERBOSE 1
1285#else
1286# define YYERROR_VERBOSE 0
1287#endif
1288
1289/* Enabling the token table. */
1290#ifndef YYTOKEN_TABLE
1291# define YYTOKEN_TABLE 0
1292#endif
1293
1294#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
1295typedef union YYSTYPE
1296#line 938 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
1297{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001298 llvm::Module *ModuleVal;
1299 llvm::Function *FunctionVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001300 llvm::BasicBlock *BasicBlockVal;
1301 llvm::TerminatorInst *TermInstVal;
1302 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001303 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001304
Reid Spencera132e042006-12-03 05:46:11 +00001305 const llvm::Type *PrimType;
Reid Spencer14310612006-12-31 05:40:51 +00001306 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencera132e042006-12-03 05:46:11 +00001307 llvm::PATypeHolder *TypeVal;
1308 llvm::Value *ValueVal;
Reid Spencera132e042006-12-03 05:46:11 +00001309 std::vector<llvm::Value*> *ValueList;
Reid Spencer14310612006-12-31 05:40:51 +00001310 llvm::ArgListType *ArgList;
1311 llvm::TypeWithAttrs TypeWithAttrs;
1312 llvm::TypeWithAttrsList *TypeWithAttrsList;
1313 llvm::ValueRefList *ValueRefList;
1314
Reid Spencer68a24bd2005-08-27 18:50:39 +00001315 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001316 std::list<std::pair<llvm::Value*,
1317 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001318 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001319 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001320
1321 llvm::GlobalValue::LinkageTypes Linkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001322 llvm::GlobalValue::VisibilityTypes Visibility;
Reid Spencer7b5d4662007-04-09 06:16:21 +00001323 uint16_t ParamAttrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00001324 llvm::APInt *APIntVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001325 int64_t SInt64Val;
1326 uint64_t UInt64Val;
1327 int SIntVal;
1328 unsigned UIntVal;
1329 double FPVal;
1330 bool BoolVal;
1331
1332 char *StrVal; // This memory is strdup'd!
Reid Spencer1628cec2006-10-26 06:15:43 +00001333 llvm::ValID ValIDVal; // strdup'd memory maybe!
Reid Spencer68a24bd2005-08-27 18:50:39 +00001334
Reid Spencera132e042006-12-03 05:46:11 +00001335 llvm::Instruction::BinaryOps BinaryOpVal;
1336 llvm::Instruction::TermOps TermOpVal;
1337 llvm::Instruction::MemoryOps MemOpVal;
1338 llvm::Instruction::CastOps CastOpVal;
1339 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencera132e042006-12-03 05:46:11 +00001340 llvm::ICmpInst::Predicate IPredicate;
1341 llvm::FCmpInst::Predicate FPredicate;
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00001342}
1343/* Line 187 of yacc.c. */
1344#line 1345 "llvmAsmParser.tab.c"
1345 YYSTYPE;
1346# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1347# define YYSTYPE_IS_DECLARED 1
1348# define YYSTYPE_IS_TRIVIAL 1
Reid Spencer68a24bd2005-08-27 18:50:39 +00001349#endif
1350
Reid Spencer41dff5e2007-01-26 08:05:27 +00001351
Reid Spencer68a24bd2005-08-27 18:50:39 +00001352
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00001353/* Copy the second part of user declarations. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001354
1355
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00001356/* Line 216 of yacc.c. */
1357#line 1358 "llvmAsmParser.tab.c"
Reid Spencer41dff5e2007-01-26 08:05:27 +00001358
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00001359#ifdef short
1360# undef short
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001361#endif
1362
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00001363#ifdef YYTYPE_UINT8
1364typedef YYTYPE_UINT8 yytype_uint8;
Reid Spencer7780acb2007-04-16 06:56:07 +00001365#else
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00001366typedef unsigned char yytype_uint8;
Reid Spencer7780acb2007-04-16 06:56:07 +00001367#endif
1368
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00001369#ifdef YYTYPE_INT8
1370typedef YYTYPE_INT8 yytype_int8;
1371#elif (defined __STDC__ || defined __C99__FUNC__ \
1372 || defined __cplusplus || defined _MSC_VER)
1373typedef signed char yytype_int8;
1374#else
1375typedef short int yytype_int8;
1376#endif
1377
1378#ifdef YYTYPE_UINT16
1379typedef YYTYPE_UINT16 yytype_uint16;
1380#else
1381typedef unsigned short int yytype_uint16;
1382#endif
1383
1384#ifdef YYTYPE_INT16
1385typedef YYTYPE_INT16 yytype_int16;
1386#else
1387typedef short int yytype_int16;
1388#endif
1389
1390#ifndef YYSIZE_T
1391# ifdef __SIZE_TYPE__
1392# define YYSIZE_T __SIZE_TYPE__
1393# elif defined size_t
1394# define YYSIZE_T size_t
1395# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
1396 || defined __cplusplus || defined _MSC_VER)
1397# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1398# define YYSIZE_T size_t
1399# else
1400# define YYSIZE_T unsigned int
1401# endif
1402#endif
1403
1404#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
1405
1406#ifndef YY_
1407# if YYENABLE_NLS
1408# if ENABLE_NLS
1409# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1410# define YY_(msgid) dgettext ("bison-runtime", msgid)
1411# endif
1412# endif
1413# ifndef YY_
1414# define YY_(msgid) msgid
1415# endif
1416#endif
1417
1418/* Suppress unused-variable warnings by "using" E. */
1419#if ! defined lint || defined __GNUC__
1420# define YYUSE(e) ((void) (e))
1421#else
1422# define YYUSE(e) /* empty */
1423#endif
1424
1425/* Identity function, used to suppress warnings about constant conditions. */
1426#ifndef lint
1427# define YYID(n) (n)
1428#else
1429#if (defined __STDC__ || defined __C99__FUNC__ \
1430 || defined __cplusplus || defined _MSC_VER)
1431static int
1432YYID (int i)
1433#else
1434static int
1435YYID (i)
1436 int i;
1437#endif
1438{
1439 return i;
1440}
1441#endif
1442
1443#if ! defined yyoverflow || YYERROR_VERBOSE
1444
1445/* The parser invokes alloca or malloc; define the necessary symbols. */
1446
1447# ifdef YYSTACK_USE_ALLOCA
1448# if YYSTACK_USE_ALLOCA
1449# ifdef __GNUC__
1450# define YYSTACK_ALLOC __builtin_alloca
1451# elif defined __BUILTIN_VA_ARG_INCR
1452# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
1453# elif defined _AIX
1454# define YYSTACK_ALLOC __alloca
1455# elif defined _MSC_VER
1456# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
1457# define alloca _alloca
1458# else
1459# define YYSTACK_ALLOC alloca
1460# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1461 || defined __cplusplus || defined _MSC_VER)
1462# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1463# ifndef _STDLIB_H
1464# define _STDLIB_H 1
1465# endif
1466# endif
1467# endif
1468# endif
1469# endif
1470
1471# ifdef YYSTACK_ALLOC
1472 /* Pacify GCC's `empty if-body' warning. */
1473# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
1474# ifndef YYSTACK_ALLOC_MAXIMUM
1475 /* The OS might guarantee only one guard page at the bottom of the stack,
1476 and a page size can be as small as 4096 bytes. So we cannot safely
1477 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1478 to allow for a few compiler-allocated temporary stack slots. */
1479# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
1480# endif
1481# else
1482# define YYSTACK_ALLOC YYMALLOC
1483# define YYSTACK_FREE YYFREE
1484# ifndef YYSTACK_ALLOC_MAXIMUM
1485# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
1486# endif
1487# if (defined __cplusplus && ! defined _STDLIB_H \
1488 && ! ((defined YYMALLOC || defined malloc) \
1489 && (defined YYFREE || defined free)))
1490# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1491# ifndef _STDLIB_H
1492# define _STDLIB_H 1
1493# endif
1494# endif
1495# ifndef YYMALLOC
1496# define YYMALLOC malloc
1497# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1498 || defined __cplusplus || defined _MSC_VER)
1499void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1500# endif
1501# endif
1502# ifndef YYFREE
1503# define YYFREE free
1504# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1505 || defined __cplusplus || defined _MSC_VER)
1506void free (void *); /* INFRINGES ON USER NAME SPACE */
1507# endif
1508# endif
1509# endif
1510#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
1511
1512
1513#if (! defined yyoverflow \
1514 && (! defined __cplusplus \
1515 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
1516
1517/* A type that is properly aligned for any stack member. */
1518union yyalloc
1519{
1520 yytype_int16 yyss;
1521 YYSTYPE yyvs;
1522 };
1523
1524/* The size of the maximum gap between one aligned stack and the next. */
1525# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1526
1527/* The size of an array large to enough to hold all stacks, each with
1528 N elements. */
1529# define YYSTACK_BYTES(N) \
1530 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
1531 + YYSTACK_GAP_MAXIMUM)
1532
1533/* Copy COUNT objects from FROM to TO. The source and destination do
1534 not overlap. */
1535# ifndef YYCOPY
1536# if defined __GNUC__ && 1 < __GNUC__
1537# define YYCOPY(To, From, Count) \
1538 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1539# else
1540# define YYCOPY(To, From, Count) \
1541 do \
1542 { \
1543 YYSIZE_T yyi; \
1544 for (yyi = 0; yyi < (Count); yyi++) \
1545 (To)[yyi] = (From)[yyi]; \
1546 } \
1547 while (YYID (0))
1548# endif
1549# endif
1550
1551/* Relocate STACK from its old location to the new one. The
1552 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1553 elements in the stack, and YYPTR gives the new location of the
1554 stack. Advance YYPTR to a properly aligned location for the next
1555 stack. */
1556# define YYSTACK_RELOCATE(Stack) \
1557 do \
1558 { \
1559 YYSIZE_T yynewbytes; \
1560 YYCOPY (&yyptr->Stack, Stack, yysize); \
1561 Stack = &yyptr->Stack; \
1562 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1563 yyptr += yynewbytes / sizeof (*yyptr); \
1564 } \
1565 while (YYID (0))
1566
1567#endif
1568
1569/* YYFINAL -- State number of the termination state. */
1570#define YYFINAL 41
1571/* YYLAST -- Last index in YYTABLE. */
1572#define YYLAST 1455
1573
1574/* YYNTOKENS -- Number of terminals. */
1575#define YYNTOKENS 150
1576/* YYNNTS -- Number of nonterminals. */
1577#define YYNNTS 81
1578/* YYNRULES -- Number of rules. */
1579#define YYNRULES 294
1580/* YYNRULES -- Number of states. */
1581#define YYNSTATES 573
1582
1583/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1584#define YYUNDEFTOK 2
1585#define YYMAXUTOK 390
1586
1587#define YYTRANSLATE(YYX) \
1588 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1589
1590/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1591static const yytype_uint8 yytranslate[] =
1592{
1593 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1594 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1595 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1596 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1597 140, 141, 138, 2, 137, 2, 2, 2, 2, 2,
1598 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1599 145, 136, 146, 2, 2, 2, 2, 2, 2, 2,
1600 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1601 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1602 2, 142, 139, 144, 2, 2, 2, 2, 2, 149,
1603 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1604 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1605 143, 2, 2, 147, 2, 148, 2, 2, 2, 2,
1606 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1607 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1608 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1609 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1610 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1611 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1612 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1613 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1614 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1615 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1616 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1617 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1618 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1619 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1620 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1621 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1622 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1623 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1624 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1625 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1626 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1627 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1628 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
1629 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
1630 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1631 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
1632 135
1633};
1634
1635#if YYDEBUG
1636/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1637 YYRHS. */
1638static const yytype_uint16 yyprhs[] =
1639{
1640 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1641 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1642 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1643 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
1644 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
1645 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
1646 119, 121, 122, 125, 126, 128, 130, 132, 133, 136,
1647 138, 140, 142, 144, 146, 148, 150, 152, 153, 155,
1648 157, 158, 160, 162, 163, 165, 167, 169, 171, 172,
1649 174, 176, 177, 179, 181, 183, 185, 187, 190, 192,
1650 194, 196, 198, 199, 202, 204, 206, 208, 209, 212,
1651 213, 216, 217, 221, 224, 225, 227, 228, 232, 234,
1652 237, 239, 241, 243, 245, 247, 249, 252, 254, 257,
1653 263, 269, 275, 281, 285, 288, 294, 299, 302, 304,
1654 306, 308, 312, 314, 318, 320, 321, 323, 327, 332,
1655 336, 340, 345, 350, 354, 361, 367, 370, 373, 376,
1656 379, 382, 385, 388, 391, 394, 397, 400, 403, 410,
1657 416, 425, 432, 439, 447, 455, 462, 471, 480, 484,
1658 486, 488, 490, 492, 493, 495, 496, 498, 501, 502,
1659 506, 507, 511, 515, 519, 523, 524, 532, 533, 542,
1660 543, 552, 559, 562, 566, 568, 572, 576, 580, 584,
1661 586, 587, 593, 597, 599, 603, 605, 606, 616, 618,
1662 620, 625, 627, 629, 632, 636, 637, 639, 641, 643,
1663 645, 647, 649, 651, 653, 655, 659, 661, 667, 669,
1664 671, 673, 675, 677, 679, 682, 685, 688, 692, 695,
1665 696, 698, 701, 704, 708, 718, 728, 737, 752, 754,
1666 756, 763, 769, 772, 779, 787, 791, 797, 798, 799,
1667 803, 806, 808, 814, 820, 827, 834, 839, 846, 851,
1668 856, 863, 870, 873, 882, 884, 886, 887, 891, 898,
1669 902, 909, 912, 918, 926
1670};
1671
1672/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1673static const yytype_int16 yyrhs[] =
1674{
1675 193, 0, -1, 69, -1, 70, -1, 71, -1, 72,
1676 -1, 73, -1, 74, -1, 75, -1, 76, -1, 77,
1677 -1, 81, -1, 82, -1, 83, -1, 78, -1, 79,
1678 -1, 80, -1, 112, -1, 113, -1, 114, -1, 115,
1679 -1, 116, -1, 117, -1, 118, -1, 119, -1, 120,
1680 -1, 121, -1, 122, -1, 123, -1, 86, -1, 87,
1681 -1, 88, -1, 89, -1, 90, -1, 91, -1, 92,
1682 -1, 93, -1, 94, -1, 95, -1, 96, -1, 97,
1683 -1, 98, -1, 99, -1, 100, -1, 101, -1, 102,
1684 -1, 103, -1, 104, -1, 105, -1, 92, -1, 93,
1685 -1, 94, -1, 95, -1, 22, -1, 23, -1, 11,
1686 -1, 12, -1, 13, -1, 16, -1, 19, -1, 158,
1687 -1, -1, 158, 136, -1, -1, 17, -1, 20, -1,
1688 163, -1, -1, 161, 136, -1, 38, -1, 40, -1,
1689 39, -1, 41, -1, 43, -1, 42, -1, 44, -1,
1690 46, -1, -1, 134, -1, 135, -1, -1, 42, -1,
1691 44, -1, -1, 38, -1, 39, -1, 40, -1, 43,
1692 -1, -1, 40, -1, 38, -1, -1, 57, -1, 58,
1693 -1, 59, -1, 60, -1, 61, -1, 56, 4, -1,
1694 113, -1, 114, -1, 131, -1, 132, -1, -1, 172,
1695 171, -1, 130, -1, 133, -1, 171, -1, -1, 174,
1696 173, -1, -1, 49, 4, -1, -1, 137, 49, 4,
1697 -1, 30, 19, -1, -1, 177, -1, -1, 137, 180,
1698 179, -1, 177, -1, 49, 4, -1, 11, -1, 12,
1699 -1, 13, -1, 14, -1, 45, -1, 181, -1, 182,
1700 138, -1, 215, -1, 139, 4, -1, 182, 140, 186,
1701 141, 174, -1, 10, 140, 186, 141, 174, -1, 142,
1702 4, 143, 182, 144, -1, 145, 4, 143, 182, 146,
1703 -1, 147, 187, 148, -1, 147, 148, -1, 145, 147,
1704 187, 148, 146, -1, 145, 147, 148, 146, -1, 182,
1705 172, -1, 182, -1, 10, -1, 183, -1, 185, 137,
1706 183, -1, 185, -1, 185, 137, 35, -1, 35, -1,
1707 -1, 182, -1, 187, 137, 182, -1, 182, 142, 190,
1708 144, -1, 182, 142, 144, -1, 182, 149, 19, -1,
1709 182, 145, 190, 146, -1, 182, 147, 190, 148, -1,
1710 182, 147, 148, -1, 182, 145, 147, 190, 148, 146,
1711 -1, 182, 145, 147, 148, 146, -1, 182, 36, -1,
1712 182, 37, -1, 182, 215, -1, 182, 189, -1, 182,
1713 21, -1, 156, 3, -1, 156, 5, -1, 156, 4,
1714 -1, 156, 6, -1, 11, 22, -1, 11, 23, -1,
1715 157, 9, -1, 153, 140, 188, 34, 182, 141, -1,
1716 111, 140, 188, 226, 141, -1, 125, 140, 188, 137,
1717 188, 137, 188, 141, -1, 151, 140, 188, 137, 188,
1718 141, -1, 152, 140, 188, 137, 188, 141, -1, 84,
1719 154, 140, 188, 137, 188, 141, -1, 85, 155, 140,
1720 188, 137, 188, 141, -1, 127, 140, 188, 137, 188,
1721 141, -1, 128, 140, 188, 137, 188, 137, 188, 141,
1722 -1, 129, 140, 188, 137, 188, 137, 188, 141, -1,
1723 190, 137, 188, -1, 188, -1, 28, -1, 29, -1,
1724 33, -1, -1, 194, -1, -1, 195, -1, 194, 195,
1725 -1, -1, 27, 196, 211, -1, -1, 26, 197, 212,
1726 -1, 54, 53, 201, -1, 160, 15, 182, -1, 160,
1727 15, 10, -1, -1, 162, 166, 192, 191, 188, 198,
1728 179, -1, -1, 162, 164, 166, 192, 191, 188, 199,
1729 179, -1, -1, 162, 165, 166, 192, 191, 182, 200,
1730 179, -1, 162, 166, 31, 169, 184, 215, -1, 47,
1731 202, -1, 50, 136, 203, -1, 19, -1, 48, 136,
1732 19, -1, 62, 136, 19, -1, 142, 204, 144, -1,
1733 204, 137, 19, -1, 19, -1, -1, 205, 137, 182,
1734 172, 159, -1, 182, 172, 159, -1, 205, -1, 205,
1735 137, 35, -1, 35, -1, -1, 170, 184, 161, 140,
1736 206, 141, 174, 178, 175, -1, 24, -1, 147, -1,
1737 168, 166, 207, 208, -1, 25, -1, 148, -1, 218,
1738 210, -1, 167, 166, 207, -1, -1, 55, -1, 3,
1739 -1, 4, -1, 9, -1, 22, -1, 23, -1, 36,
1740 -1, 37, -1, 21, -1, 145, 190, 146, -1, 189,
1741 -1, 53, 213, 19, 137, 19, -1, 7, -1, 8,
1742 -1, 158, -1, 161, -1, 215, -1, 214, -1, 182,
1743 216, -1, 218, 219, -1, 209, 219, -1, 220, 160,
1744 221, -1, 220, 223, -1, -1, 18, -1, 63, 217,
1745 -1, 63, 10, -1, 64, 14, 216, -1, 64, 11,
1746 216, 137, 14, 216, 137, 14, 216, -1, 65, 156,
1747 216, 137, 14, 216, 142, 222, 144, -1, 65, 156,
1748 216, 137, 14, 216, 142, 144, -1, 66, 170, 184,
1749 216, 140, 225, 141, 174, 34, 14, 216, 67, 14,
1750 216, -1, 67, -1, 68, -1, 222, 156, 214, 137,
1751 14, 216, -1, 156, 214, 137, 14, 216, -1, 160,
1752 228, -1, 182, 142, 216, 137, 216, 144, -1, 224,
1753 137, 142, 216, 137, 216, 144, -1, 182, 216, 172,
1754 -1, 225, 137, 182, 216, 172, -1, -1, -1, 226,
1755 137, 217, -1, 52, 51, -1, 51, -1, 151, 182,
1756 216, 137, 216, -1, 152, 182, 216, 137, 216, -1,
1757 84, 154, 182, 216, 137, 216, -1, 85, 155, 182,
1758 216, 137, 216, -1, 153, 217, 34, 182, -1, 125,
1759 217, 137, 217, 137, 217, -1, 126, 217, 137, 182,
1760 -1, 127, 217, 137, 217, -1, 128, 217, 137, 217,
1761 137, 217, -1, 129, 217, 137, 217, 137, 217, -1,
1762 124, 224, -1, 227, 170, 184, 216, 140, 225, 141,
1763 174, -1, 230, -1, 32, -1, -1, 106, 182, 176,
1764 -1, 106, 182, 137, 11, 216, 176, -1, 107, 182,
1765 176, -1, 107, 182, 137, 11, 216, 176, -1, 108,
1766 217, -1, 229, 109, 182, 216, 176, -1, 229, 110,
1767 217, 137, 182, 216, 176, -1, 111, 182, 216, 226,
1768 -1
1769};
1770
1771/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1772static const yytype_uint16 yyrline[] =
1773{
1774 0, 1094, 1094, 1094, 1094, 1094, 1094, 1094, 1094, 1094,
1775 1094, 1095, 1095, 1095, 1095, 1095, 1095, 1096, 1096, 1096,
1776 1096, 1096, 1096, 1097, 1097, 1097, 1097, 1097, 1097, 1100,
1777 1100, 1101, 1101, 1102, 1102, 1103, 1103, 1104, 1104, 1108,
1778 1108, 1109, 1109, 1110, 1110, 1111, 1111, 1112, 1112, 1113,
1779 1113, 1114, 1114, 1115, 1116, 1121, 1122, 1122, 1124, 1124,
1780 1125, 1125, 1129, 1133, 1138, 1138, 1140, 1141, 1146, 1152,
1781 1153, 1154, 1155, 1156, 1160, 1161, 1162, 1166, 1167, 1168,
1782 1172, 1173, 1174, 1178, 1179, 1180, 1181, 1182, 1186, 1187,
1783 1188, 1191, 1192, 1193, 1194, 1195, 1196, 1197, 1204, 1205,
1784 1206, 1207, 1210, 1211, 1216, 1217, 1218, 1221, 1222, 1229,
1785 1230, 1236, 1237, 1245, 1253, 1254, 1259, 1260, 1261, 1266,
1786 1279, 1279, 1279, 1279, 1282, 1286, 1290, 1297, 1302, 1310,
1787 1340, 1371, 1376, 1388, 1398, 1402, 1412, 1419, 1426, 1433,
1788 1438, 1443, 1450, 1451, 1458, 1465, 1473, 1479, 1491, 1519,
1789 1535, 1564, 1592, 1617, 1636, 1662, 1682, 1694, 1701, 1767,
1790 1777, 1787, 1793, 1803, 1809, 1819, 1824, 1829, 1837, 1849,
1791 1871, 1879, 1885, 1896, 1901, 1906, 1912, 1918, 1927, 1931,
1792 1939, 1939, 1942, 1942, 1953, 1958, 1966, 1967, 1971, 1971,
1793 1975, 1975, 1978, 1981, 2005, 2016, 2016, 2026, 2026, 2034,
1794 2034, 2044, 2072, 2075, 2081, 2094, 2098, 2103, 2105, 2110,
1795 2115, 2124, 2134, 2145, 2149, 2158, 2167, 2172, 2294, 2294,
1796 2296, 2305, 2305, 2307, 2312, 2324, 2328, 2333, 2337, 2341,
1797 2345, 2349, 2353, 2357, 2361, 2365, 2390, 2394, 2408, 2412,
1798 2416, 2420, 2426, 2426, 2432, 2441, 2445, 2454, 2463, 2472,
1799 2476, 2481, 2485, 2489, 2494, 2504, 2523, 2532, 2612, 2616,
1800 2623, 2634, 2647, 2657, 2668, 2678, 2687, 2696, 2699, 2700,
1801 2707, 2711, 2716, 2737, 2754, 2768, 2782, 2794, 2802, 2809,
1802 2815, 2821, 2827, 2842, 2927, 2932, 2936, 2943, 2950, 2958,
1803 2965, 2973, 2981, 2995, 3012
1804};
1805#endif
1806
1807#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1808/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1809 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1810static const char *const yytname[] =
1811{
1812 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "ESAPINTVAL",
1813 "EUAPINTVAL", "LOCALVAL_ID", "GLOBALVAL_ID", "FPVAL", "VOID", "INTTYPE",
1814 "FLOAT", "DOUBLE", "LABEL", "TYPE", "LOCALVAR", "GLOBALVAR", "LABELSTR",
1815 "STRINGCONSTANT", "ATSTRINGCONSTANT", "ZEROINITIALIZER", "TRUETOK",
1816 "FALSETOK", "BEGINTOK", "ENDTOK", "DECLARE", "DEFINE", "GLOBAL",
1817 "CONSTANT", "SECTION", "ALIAS", "VOLATILE", "THREAD_LOCAL", "TO",
1818 "DOTDOTDOT", "NULL_TOK", "UNDEF", "INTERNAL", "LINKONCE", "WEAK",
1819 "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
1820 "EXTERNAL", "TARGET", "TRIPLE", "ALIGN", "DEPLIBS", "CALL", "TAIL",
1821 "ASM_TOK", "MODULE", "SIDEEFFECT", "CC_TOK", "CCC_TOK", "FASTCC_TOK",
1822 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
1823 "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE", "ADD", "SUB",
1824 "MUL", "UDIV", "SDIV", "FDIV", "UREM", "SREM", "FREM", "AND", "OR",
1825 "XOR", "SHL", "LSHR", "ASHR", "ICMP", "FCMP", "EQ", "NE", "SLT", "SGT",
1826 "SLE", "SGE", "ULT", "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT",
1827 "OLE", "OGE", "ORD", "UNO", "UEQ", "UNE", "MALLOC", "ALLOCA", "FREE",
1828 "LOAD", "STORE", "GETELEMENTPTR", "TRUNC", "ZEXT", "SEXT", "FPTRUNC",
1829 "FPEXT", "BITCAST", "UITOFP", "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR",
1830 "PTRTOINT", "PHI_TOK", "SELECT", "VAARG", "EXTRACTELEMENT",
1831 "INSERTELEMENT", "SHUFFLEVECTOR", "NORETURN", "INREG", "SRET",
1832 "NOUNWIND", "DEFAULT", "HIDDEN", "'='", "','", "'*'", "'\\\\'", "'('",
1833 "')'", "'['", "'x'", "']'", "'<'", "'>'", "'{'", "'}'", "'c'", "$accept",
1834 "ArithmeticOps", "LogicalOps", "CastOps", "IPredicates", "FPredicates",
1835 "IntType", "FPType", "LocalName", "OptLocalName", "OptLocalAssign",
1836 "GlobalName", "OptGlobalAssign", "GlobalAssign", "GVInternalLinkage",
1837 "GVExternalLinkage", "GVVisibilityStyle", "FunctionDeclareLinkage",
1838 "FunctionDefineLinkage", "AliasLinkage", "OptCallingConv", "ParamAttr",
1839 "OptParamAttrs", "FuncAttr", "OptFuncAttrs", "OptAlign", "OptCAlign",
1840 "SectionString", "OptSection", "GlobalVarAttributes",
1841 "GlobalVarAttribute", "PrimType", "Types", "ArgType", "ResultTypes",
1842 "ArgTypeList", "ArgTypeListI", "TypeListI", "ConstVal", "ConstExpr",
1843 "ConstVector", "GlobalType", "ThreadLocal", "Module", "DefinitionList",
1844 "Definition", "@1", "@2", "@3", "@4", "@5", "AsmBlock",
1845 "TargetDefinition", "LibrariesDefinition", "LibList", "ArgListH",
1846 "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader", "END",
1847 "Function", "FunctionProto", "OptSideEffect", "ConstValueRef",
1848 "SymbolicValueRef", "ValueRef", "ResolvedVal", "BasicBlockList",
1849 "BasicBlock", "InstructionList", "BBTerminatorInst", "JumpTable", "Inst",
1850 "PHIList", "ValueRefList", "IndexList", "OptTailCall", "InstVal",
1851 "OptVolatile", "MemoryInst", 0
1852};
1853#endif
1854
1855# ifdef YYPRINT
1856/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1857 token YYLEX-NUM. */
1858static const yytype_uint16 yytoknum[] =
1859{
1860 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1861 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1862 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1863 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1864 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1865 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1866 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1867 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1868 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1869 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1870 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
1871 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
1872 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
1873 385, 386, 387, 388, 389, 390, 61, 44, 42, 92,
1874 40, 41, 91, 120, 93, 60, 62, 123, 125, 99
1875};
1876# endif
1877
1878/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1879static const yytype_uint8 yyr1[] =
1880{
1881 0, 150, 151, 151, 151, 151, 151, 151, 151, 151,
1882 151, 152, 152, 152, 152, 152, 152, 153, 153, 153,
1883 153, 153, 153, 153, 153, 153, 153, 153, 153, 154,
1884 154, 154, 154, 154, 154, 154, 154, 154, 154, 155,
1885 155, 155, 155, 155, 155, 155, 155, 155, 155, 155,
1886 155, 155, 155, 155, 155, 156, 157, 157, 158, 158,
1887 159, 159, 160, 160, 161, 161, 162, 162, 163, 164,
1888 164, 164, 164, 164, 165, 165, 165, 166, 166, 166,
1889 167, 167, 167, 168, 168, 168, 168, 168, 169, 169,
1890 169, 170, 170, 170, 170, 170, 170, 170, 171, 171,
1891 171, 171, 172, 172, 173, 173, 173, 174, 174, 175,
1892 175, 176, 176, 177, 178, 178, 179, 179, 180, 180,
1893 181, 181, 181, 181, 182, 182, 182, 182, 182, 182,
1894 182, 182, 182, 182, 182, 182, 182, 183, 184, 184,
1895 185, 185, 186, 186, 186, 186, 187, 187, 188, 188,
1896 188, 188, 188, 188, 188, 188, 188, 188, 188, 188,
1897 188, 188, 188, 188, 188, 188, 188, 188, 189, 189,
1898 189, 189, 189, 189, 189, 189, 189, 189, 190, 190,
1899 191, 191, 192, 192, 193, 193, 194, 194, 196, 195,
1900 197, 195, 195, 195, 195, 198, 195, 199, 195, 200,
1901 195, 195, 195, 195, 201, 202, 202, 203, 204, 204,
1902 204, 205, 205, 206, 206, 206, 206, 207, 208, 208,
1903 209, 210, 210, 211, 212, 213, 213, 214, 214, 214,
1904 214, 214, 214, 214, 214, 214, 214, 214, 215, 215,
1905 215, 215, 216, 216, 217, 218, 218, 219, 220, 220,
1906 220, 221, 221, 221, 221, 221, 221, 221, 221, 221,
1907 222, 222, 223, 224, 224, 225, 225, 225, 226, 226,
1908 227, 227, 228, 228, 228, 228, 228, 228, 228, 228,
1909 228, 228, 228, 228, 228, 229, 229, 230, 230, 230,
1910 230, 230, 230, 230, 230
1911};
1912
1913/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
1914static const yytype_uint8 yyr2[] =
1915{
1916 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1917 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1918 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1919 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1920 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1921 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1922 1, 0, 2, 0, 1, 1, 1, 0, 2, 1,
1923 1, 1, 1, 1, 1, 1, 1, 0, 1, 1,
1924 0, 1, 1, 0, 1, 1, 1, 1, 0, 1,
1925 1, 0, 1, 1, 1, 1, 1, 2, 1, 1,
1926 1, 1, 0, 2, 1, 1, 1, 0, 2, 0,
1927 2, 0, 3, 2, 0, 1, 0, 3, 1, 2,
1928 1, 1, 1, 1, 1, 1, 2, 1, 2, 5,
1929 5, 5, 5, 3, 2, 5, 4, 2, 1, 1,
1930 1, 3, 1, 3, 1, 0, 1, 3, 4, 3,
1931 3, 4, 4, 3, 6, 5, 2, 2, 2, 2,
1932 2, 2, 2, 2, 2, 2, 2, 2, 6, 5,
1933 8, 6, 6, 7, 7, 6, 8, 8, 3, 1,
1934 1, 1, 1, 0, 1, 0, 1, 2, 0, 3,
1935 0, 3, 3, 3, 3, 0, 7, 0, 8, 0,
1936 8, 6, 2, 3, 1, 3, 3, 3, 3, 1,
1937 0, 5, 3, 1, 3, 1, 0, 9, 1, 1,
1938 4, 1, 1, 2, 3, 0, 1, 1, 1, 1,
1939 1, 1, 1, 1, 1, 3, 1, 5, 1, 1,
1940 1, 1, 1, 1, 2, 2, 2, 3, 2, 0,
1941 1, 2, 2, 3, 9, 9, 8, 14, 1, 1,
1942 6, 5, 2, 6, 7, 3, 5, 0, 0, 3,
1943 2, 1, 5, 5, 6, 6, 4, 6, 4, 4,
1944 6, 6, 2, 8, 1, 1, 0, 3, 6, 3,
1945 6, 2, 5, 7, 4
1946};
1947
1948/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
1949 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
1950 means the default is an error. */
1951static const yytype_uint16 yydefact[] =
1952{
1953 67, 58, 64, 59, 65, 190, 188, 0, 0, 0,
1954 0, 0, 0, 77, 66, 0, 67, 186, 80, 83,
1955 0, 0, 202, 0, 0, 62, 0, 68, 69, 71,
1956 70, 72, 74, 73, 75, 76, 78, 79, 77, 77,
1957 183, 1, 187, 81, 82, 77, 191, 84, 85, 86,
1958 87, 77, 249, 189, 249, 0, 0, 210, 203, 204,
1959 192, 238, 239, 194, 120, 121, 122, 123, 124, 0,
1960 0, 0, 0, 240, 241, 125, 193, 127, 183, 183,
1961 88, 182, 0, 91, 91, 250, 246, 63, 221, 222,
1962 223, 245, 205, 206, 209, 0, 145, 128, 0, 0,
1963 0, 0, 134, 146, 0, 126, 145, 0, 0, 90,
1964 89, 0, 180, 181, 0, 0, 92, 93, 94, 95,
1965 96, 0, 224, 0, 286, 248, 0, 207, 144, 102,
1966 140, 142, 0, 0, 0, 0, 0, 0, 133, 0,
1967 0, 0, 139, 138, 0, 120, 121, 122, 0, 0,
1968 0, 195, 97, 0, 218, 219, 220, 285, 271, 0,
1969 0, 0, 0, 91, 258, 259, 2, 3, 4, 5,
1970 6, 7, 8, 9, 10, 14, 15, 16, 11, 12,
1971 13, 0, 0, 0, 0, 0, 0, 17, 18, 19,
1972 20, 21, 22, 23, 24, 25, 26, 27, 28, 0,
1973 0, 0, 0, 0, 0, 0, 0, 0, 247, 91,
1974 262, 0, 284, 208, 137, 0, 107, 0, 0, 136,
1975 0, 147, 107, 197, 199, 201, 165, 166, 161, 163,
1976 162, 164, 167, 160, 156, 157, 0, 0, 0, 0,
1977 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1978 159, 158, 116, 0, 270, 252, 0, 251, 0, 0,
1979 55, 0, 0, 29, 30, 31, 32, 33, 34, 35,
1980 36, 37, 38, 0, 53, 54, 49, 50, 51, 52,
1981 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
1982 0, 111, 111, 291, 0, 0, 282, 0, 0, 0,
1983 0, 0, 0, 0, 0, 0, 0, 0, 98, 99,
1984 100, 101, 103, 143, 141, 130, 131, 132, 135, 129,
1985 116, 116, 0, 0, 0, 0, 0, 0, 0, 149,
1986 179, 0, 0, 0, 153, 0, 150, 0, 0, 0,
1987 0, 196, 216, 227, 228, 229, 234, 230, 231, 232,
1988 233, 225, 0, 236, 243, 242, 244, 0, 253, 0,
1989 0, 0, 0, 0, 287, 0, 289, 268, 0, 0,
1990 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1991 0, 104, 105, 106, 108, 198, 200, 0, 0, 268,
1992 0, 0, 0, 0, 0, 148, 134, 146, 0, 151,
1993 152, 0, 0, 0, 0, 0, 118, 116, 215, 102,
1994 213, 0, 226, 0, 0, 0, 0, 0, 0, 0,
1995 0, 0, 0, 294, 0, 0, 0, 278, 279, 0,
1996 0, 0, 0, 276, 0, 111, 0, 0, 0, 0,
1997 0, 0, 0, 0, 178, 155, 0, 0, 0, 0,
1998 113, 119, 117, 61, 0, 107, 0, 235, 0, 0,
1999 267, 0, 0, 111, 112, 111, 0, 0, 0, 0,
2000 0, 0, 272, 273, 267, 0, 292, 0, 0, 0,
2001 169, 0, 0, 0, 0, 154, 0, 0, 0, 60,
2002 212, 214, 102, 114, 0, 0, 0, 0, 0, 274,
2003 275, 288, 290, 269, 0, 0, 277, 280, 281, 0,
2004 111, 0, 0, 0, 175, 0, 0, 171, 172, 168,
2005 61, 115, 109, 237, 0, 0, 102, 0, 107, 263,
2006 0, 107, 293, 173, 174, 0, 0, 0, 211, 0,
2007 217, 0, 256, 0, 0, 265, 0, 0, 264, 283,
2008 170, 176, 177, 110, 254, 0, 255, 0, 102, 0,
2009 0, 0, 266, 0, 0, 0, 0, 261, 0, 0,
2010 260, 0, 257
2011};
2012
2013/* YYDEFGOTO[NTERM-NUM]. */
2014static const yytype_int16 yydefgoto[] =
2015{
2016 -1, 247, 248, 249, 273, 290, 148, 149, 73, 490,
2017 11, 74, 13, 14, 38, 39, 40, 45, 51, 111,
2018 121, 312, 214, 384, 315, 540, 364, 406, 522, 341,
2019 407, 75, 150, 130, 144, 131, 132, 104, 330, 353,
2020 331, 114, 82, 15, 16, 17, 19, 18, 252, 320,
2021 321, 60, 22, 58, 95, 410, 411, 122, 156, 52,
2022 90, 53, 46, 413, 354, 77, 356, 257, 54, 86,
2023 87, 208, 544, 125, 296, 498, 423, 209, 210, 211,
2024 212
2025};
2026
2027/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2028 STATE-NUM. */
2029#define YYPACT_NINF -467
2030static const yytype_int16 yypact[] =
2031{
2032 601, -467, -467, -467, -467, -467, -467, 28, -64, 41,
2033 -37, 98, 10, 16, -467, 139, 856, -467, 36, 170,
2034 18, 26, -467, 31, 148, -467, 1069, -467, -467, -467,
2035 -467, -467, -467, -467, -467, -467, -467, -467, 81, 81,
2036 107, -467, -467, -467, -467, 81, -467, -467, -467, -467,
2037 -467, 81, 179, -467, 8, 209, 220, 226, -467, -467,
2038 -467, -467, -467, 118, -467, -467, -467, -467, -467, 269,
2039 275, 1, 541, -467, -467, -467, 100, -467, 251, 251,
2040 229, -467, 204, 196, 196, -467, -467, 104, -467, -467,
2041 -467, -467, -467, -467, -467, -100, 981, -467, 143, 146,
2042 754, 118, -467, 100, -96, -467, 981, 204, 204, -467,
2043 -467, 1086, -467, -467, 1137, 289, -467, -467, -467, -467,
2044 -467, 1086, -467, -15, 1326, -467, 277, -467, -467, 100,
2045 -467, 162, 163, 1181, 1181, 167, -95, 1181, -467, 173,
2046 1137, 1181, 118, 100, 227, 45, 299, 306, 216, 309,
2047 712, -467, -467, 23, -467, -467, -467, -467, -467, 268,
2048 1227, 200, 312, 196, -467, -467, -467, -467, -467, -467,
2049 -467, -467, -467, -467, -467, -467, -467, -467, -467, -467,
2050 -467, 303, 1195, 1181, 1181, 1181, 1181, -467, -467, -467,
2051 -467, -467, -467, -467, -467, -467, -467, -467, -467, 1181,
2052 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, -467, 196,
2053 -467, 140, -467, -467, -68, 995, -467, 58, -9, -467,
2054 174, 100, -467, -467, 100, -467, -467, -467, -467, -467,
2055 -467, -467, -467, -467, -467, -467, 303, 1195, 186, 187,
2056 188, 189, 191, 633, 1241, 793, 313, 193, 194, 195,
2057 -467, -467, 201, 197, -467, 118, 462, -467, 589, 589,
2058 -467, 589, 1086, -467, -467, -467, -467, -467, -467, -467,
2059 -467, -467, -467, 1181, -467, -467, -467, -467, -467, -467,
2060 -467, -467, -467, -467, -467, -467, -467, -467, -467, -467,
2061 1181, 89, 165, -467, 462, 134, 202, 205, 206, 213,
2062 214, 217, 462, 462, 307, 1086, 1181, 1181, -467, -467,
2063 -467, -467, -467, -467, -467, -48, -467, -467, -467, -48,
2064 201, 201, 215, 218, 1137, 1137, 1137, 1137, 1137, -467,
2065 -467, -26, 965, -67, -467, -45, -467, 1137, 1137, 1137,
2066 -10, -467, 1025, -467, -467, -467, -467, -467, -467, -467,
2067 -467, 298, 1137, -467, -467, -467, -467, 219, -467, 222,
2068 589, 462, 462, 24, -467, 25, -467, -467, 589, 221,
2069 1181, 1181, 1181, 1181, 1181, 224, 225, 1181, 589, 462,
2070 230, -467, -467, -467, -467, -467, -467, 1137, 1137, -467,
2071 233, 234, 235, 241, 1137, -467, 211, 712, -44, -467,
2072 -467, 242, 244, 330, 347, 365, -467, 201, -467, 100,
2073 245, 258, -467, 364, -31, 386, 387, 265, 271, 276,
2074 589, 402, 589, 278, 279, 589, 280, 100, -467, 281,
2075 282, 589, 589, 100, 272, 283, 1181, 284, 285, -27,
2076 1137, 1137, 1137, 1137, -467, -467, 286, 1137, 1137, 1181,
2077 -467, -467, -467, 13, 1039, -467, 288, -467, 589, 589,
2078 1181, 589, 589, 283, -467, 283, 1181, 589, 291, 1181,
2079 1181, 1181, -467, -467, 1181, 374, -467, 462, 1137, 1137,
2080 -467, 293, 273, 296, 301, -467, 310, 311, 137, -467,
2081 -467, -467, 100, 39, 420, 305, 308, 462, -7, -467,
2082 -467, -467, -467, -467, 304, 589, -467, -467, -467, 47,
2083 283, 314, 315, 1137, -467, 1137, 1137, -467, -467, -467,
2084 13, -467, 391, -467, 433, -1, -467, 1181, -467, -467,
2085 316, -467, -467, -467, -467, 317, 318, 320, -467, 450,
2086 -467, 589, -467, 842, 3, -68, 462, 73, -467, -48,
2087 -467, -467, -467, -467, -467, 325, -467, 842, -467, 443,
2088 449, 327, -68, 589, 589, 453, 401, -467, 589, 458,
2089 -467, 589, -467
2090};
2091
2092/* YYPGOTO[NTERM-NUM]. */
2093static const yytype_int16 yypgoto[] =
2094{
2095 -467, 349, 350, 351, 240, 243, -160, -467, 0, -43,
2096 399, 11, -467, -467, -467, -467, 50, -467, -467, -467,
2097 -148, -281, -390, -467, -219, -467, -280, -6, -467, -290,
2098 -467, -467, -25, 290, -113, -467, 382, 393, 49, -146,
2099 -227, 155, 232, -467, -467, 478, -467, -467, -467, -467,
2100 -467, -467, -467, -467, -467, -467, -467, 411, -467, -467,
2101 -467, -467, -467, -467, -466, -137, -161, -179, -467, 446,
2102 -467, -467, -467, -467, -467, 27, 114, -467, -467, -467,
2103 -467
2104};
2105
2106/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2107 positive, shift that token. If negative, reduce the rule which
2108 number is the opposite. If zero, do what YYDEFACT says.
2109 If YYTABLE_NINF, syntax error. */
2110#define YYTABLE_NINF -186
2111static const yytype_int16 yytable[] =
2112{
2113 10, 76, 261, 319, 250, 99, 293, 225, 153, 154,
2114 260, 12, 366, 251, 260, 262, 10, 333, 335, 453,
2115 404, 297, 298, 299, 300, 301, 85, 12, 304, 1,
2116 385, 386, 3, 88, 383, 420, 422, 126, 383, 405,
2117 2, 137, 137, 4, 127, 308, 309, 103, -55, -55,
2118 -55, -55, 138, 220, 28, 29, 30, 31, 32, 33,
2119 34, 305, 35, 310, 311, 308, 309, 226, 227, 404,
2120 394, 129, 23, 421, 421, 103, 20, 555, 43, 399,
2121 44, 129, 381, 310, 311, 382, 143, 10, 78, 79,
2122 21, 561, 394, 394, 24, 83, 143, 357, 358, 25,
2123 359, 84, 520, 400, 446, 398, 394, 559, 217, 218,
2124 466, 394, 221, 26, 480, 457, 224, 452, 395, 355,
2125 1, 355, 355, 3, 355, 414, 308, 309, 380, 105,
2126 527, 106, 155, 367, 528, 256, 545, 317, 80, 41,
2127 81, 375, 376, 542, 310, 311, 27, 556, 100, 360,
2128 36, 37, 308, 309, 55, 476, 89, 355, 291, 292,
2129 256, 294, 56, 151, 253, 355, 355, 59, 562, 381,
2130 310, 311, 382, 57, 295, 256, 256, 256, 256, 256,
2131 302, 303, 256, 501, 527, 502, 308, 309, 531, 223,
2132 129, 426, 378, 428, 429, 430, 105, 85, 106, 417,
2133 418, 419, 316, 381, 310, 311, 382, 424, 47, 48,
2134 49, 258, 383, 50, 259, 36, 37, 434, 435, 228,
2135 229, 230, 231, 355, 355, 355, 363, 105, 92, 106,
2136 532, 355, 112, 113, 61, 62, 493, 143, 105, 93,
2137 106, 355, 355, 1, 2, 94, 3, 4, 361, 306,
2138 307, 250, 115, 116, 117, 118, 119, 120, 96, 463,
2139 251, 465, 140, 141, 468, 362, 383, 109, 383, 110,
2140 472, 473, 105, 97, 106, 105, 368, 106, 519, 98,
2141 143, 379, 256, 355, 81, 355, 133, 503, 355, 134,
2142 506, 507, 508, 152, 355, 355, 213, 495, 496, 215,
2143 499, 500, 365, 105, 216, 106, 504, 397, -56, 547,
2144 107, 108, 549, 219, 222, -57, 510, 409, 232, 254,
2145 318, 355, 355, 260, 355, 355, 324, 325, 326, 327,
2146 355, 328, 336, 337, 338, 339, 526, 342, 340, 369,
2147 355, 377, 370, 371, 530, 256, 427, 256, 256, 256,
2148 372, 373, 433, 412, 374, 387, 415, 445, 388, 416,
2149 355, 431, 432, 425, 449, 543, 450, 436, 355, 451,
2150 440, 441, 442, 389, 390, 391, 392, 393, 443, 447,
2151 554, 448, 454, 456, 557, 558, 401, 402, 403, 263,
2152 264, 265, 266, 267, 268, 269, 270, 271, 272, 455,
2153 458, 459, 566, 567, 355, 460, 464, 570, 461, 355,
2154 572, 477, 474, 462, 514, 466, 467, 469, 470, 471,
2155 475, 478, 479, 421, 488, 494, 355, 355, 505, 492,
2156 513, 355, 485, 515, 355, 497, 437, 438, 516, 523,
2157 539, 256, 524, 444, 256, 256, 256, 541, 529, 497,
2158 525, 517, 518, 489, 553, 533, 534, 563, 550, 551,
2159 548, 552, 560, 564, 565, 343, 344, 568, 569, 61,
2160 62, 345, 571, 205, 206, 207, 322, 538, 1, 2,
2161 323, 3, 4, 346, 347, 348, 124, 521, 139, 481,
2162 482, 483, 484, 136, 42, 123, 486, 487, 349, 350,
2163 91, 509, 546, 439, 0, 314, 0, 0, 0, 0,
2164 0, 0, 0, 0, 0, 351, 0, 0, 0, 0,
2165 489, 0, 0, 0, 0, 0, 0, 511, 512, 0,
2166 0, 166, 167, 168, 169, 170, 171, 172, 173, 174,
2167 175, 176, 177, 178, 179, 180, 236, 237, 61, 62,
2168 0, 101, 64, 65, 66, 67, 0, 1, 2, 0,
2169 3, 4, 535, 0, 536, 537, 0, 0, 0, 0,
2170 0, 0, 0, 238, 187, 188, 189, 190, 191, 192,
2171 193, 194, 195, 196, 197, 198, 68, 239, 0, 240,
2172 241, 242, 343, 344, 0, 0, 61, 62, 345, 0,
2173 105, -185, 106, 0, 0, 1, 2, 352, 3, 4,
2174 346, 347, 348, 0, 0, 0, -63, 1, 2, 0,
2175 3, 4, 0, 0, 0, 349, 350, 5, 6, 0,
2176 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2177 61, 62, 351, 101, 145, 146, 147, 67, 7, 1,
2178 2, 8, 3, 4, 0, 9, 0, 0, 166, 167,
2179 168, 169, 170, 171, 172, 173, 174, 175, 176, 177,
2180 178, 179, 180, 236, 237, 0, 0, 0, 68, 0,
2181 69, 0, 0, 70, 0, 0, 71, 0, 72, 102,
2182 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2183 238, 187, 188, 189, 190, 191, 192, 193, 194, 195,
2184 196, 197, 198, 0, 239, 0, 240, 241, 242, 61,
2185 62, 0, 0, 0, 0, 0, 0, 0, 1, 2,
2186 0, 3, 4, 233, 352, 0, 0, 0, 0, 0,
2187 0, 0, 0, 0, 0, 0, 0, 0, 234, 235,
2188 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2189 0, 61, 62, 0, 101, 64, 65, 66, 67, 0,
2190 1, 2, 69, 3, 4, 70, 0, 329, 71, 0,
2191 72, 166, 167, 168, 169, 170, 171, 172, 173, 174,
2192 175, 176, 177, 178, 179, 180, 236, 237, 0, 68,
2193 61, 62, 0, 101, 145, 146, 147, 67, 0, 1,
2194 2, 0, 3, 4, 0, 0, 0, 0, 0, 0,
2195 0, 0, 0, 238, 187, 188, 189, 190, 191, 192,
2196 193, 194, 195, 196, 197, 198, 0, 239, 68, 240,
2197 241, 242, 0, 0, 0, 343, 344, 0, 0, 0,
2198 105, 345, 106, 0, 243, 0, -184, 244, 0, 245,
2199 0, 246, 0, 346, 347, 348, 0, 0, 0, 0,
2200 0, -63, 1, 2, 0, 3, 4, 0, 349, 350,
2201 0, 0, 5, 6, 0, 0, 0, 0, 0, 0,
2202 0, 0, 0, 69, 0, 351, 70, 0, 0, 71,
2203 0, 72, 135, 7, 0, 0, 8, 0, 0, 0,
2204 9, 166, 167, 168, 169, 170, 171, 172, 173, 174,
2205 175, 176, 177, 178, 179, 180, 236, 237, 0, 0,
2206 0, 0, 69, 0, 0, 70, 0, 0, 71, 0,
2207 72, 334, 0, 0, 0, 0, 0, 0, 0, 0,
2208 0, 0, 0, 238, 187, 188, 189, 190, 191, 192,
2209 193, 194, 195, 196, 197, 198, 0, 239, 0, 240,
2210 241, 242, 61, 62, 0, 101, 145, 146, 147, 67,
2211 0, 1, 2, 0, 3, 4, 0, 352, 61, 62,
2212 0, 101, 64, 65, 66, 67, 0, 1, 2, 0,
2213 3, 4, 61, 62, 0, 101, 64, 65, 66, 67,
2214 68, 1, 2, 0, 3, 4, 128, 0, 0, 0,
2215 0, 0, 0, 0, 0, 0, 68, 0, 0, 0,
2216 313, 0, 61, 62, 0, 101, 64, 65, 66, 67,
2217 68, 1, 2, 0, 3, 4, 61, 62, 0, 101,
2218 64, 65, 66, 67, 0, 1, 2, 0, 3, 4,
2219 408, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2220 68, 0, 0, 0, 491, 0, 61, 62, 0, 63,
2221 64, 65, 66, 67, 68, 1, 2, 0, 3, 4,
2222 0, 0, 0, 61, 62, 0, 142, 64, 65, 66,
2223 67, 0, 1, 2, 69, 3, 4, 70, 0, 0,
2224 71, 0, 72, 396, 68, 0, 0, 0, 0, 0,
2225 69, 0, 0, 70, 0, 0, 71, 0, 72, 0,
2226 0, 68, 0, 0, 69, 0, 0, 70, 0, 0,
2227 71, 0, 72, 0, 61, 62, 0, 101, 145, 146,
2228 147, 67, 0, 1, 2, 0, 3, 4, 0, 0,
2229 0, 0, 0, 0, 69, 0, 0, 70, 0, 0,
2230 71, 0, 72, 0, 0, 0, 0, 0, 69, 0,
2231 0, 70, 68, 0, 71, 0, 72, 0, 61, 62,
2232 0, 101, 64, 65, 66, 67, 0, 1, 2, 0,
2233 3, 4, 0, 0, 0, 0, 0, 0, 69, 0,
2234 0, 70, 0, 0, 71, 0, 72, 274, 275, 0,
2235 0, 0, 0, 0, 0, 69, 68, 0, 70, 0,
2236 0, 71, 0, 72, 61, 62, 0, 255, 64, 65,
2237 66, 67, 0, 1, 2, 0, 3, 4, 61, 62,
2238 0, 101, 145, 146, 147, 67, 0, 1, 2, 0,
2239 3, 4, 0, 0, 0, 0, 0, 0, 0, 0,
2240 0, 0, 68, 0, 0, 0, 69, 0, 0, 70,
2241 0, 0, 71, 0, 72, 0, 68, 276, 277, 278,
2242 279, 280, 281, 282, 283, 284, 285, 286, 287, 288,
2243 289, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2244 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2245 69, 0, 0, 70, 0, 0, 71, 0, 72, 0,
2246 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2247 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2248 0, 0, 0, 0, 0, 0, 0, 0, 157, 0,
2249 0, 0, 0, 0, 0, 0, 69, 0, 0, 70,
2250 0, 0, 71, 0, 72, 0, 0, 158, 159, 0,
2251 69, 0, 0, 70, 0, 0, 71, 0, 332, 160,
2252 161, 162, 163, 164, 165, 166, 167, 168, 169, 170,
2253 171, 172, 173, 174, 175, 176, 177, 178, 179, 180,
2254 181, 182, 0, 0, 0, 0, 0, 0, 0, 0,
2255 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2256 0, 0, 183, 184, 185, 0, 0, 186, 187, 188,
2257 189, 190, 191, 192, 193, 194, 195, 196, 197, 198,
2258 199, 200, 201, 202, 203, 204
2259};
2260
2261static const yytype_int16 yycheck[] =
2262{
2263 0, 26, 162, 222, 150, 4, 185, 144, 121, 24,
2264 11, 0, 292, 150, 11, 163, 16, 244, 245, 409,
2265 30, 200, 201, 202, 203, 204, 18, 16, 207, 16,
2266 320, 321, 19, 25, 315, 11, 11, 137, 319, 49,
2267 17, 137, 137, 20, 144, 113, 114, 72, 3, 4,
2268 5, 6, 148, 148, 38, 39, 40, 41, 42, 43,
2269 44, 209, 46, 131, 132, 113, 114, 22, 23, 30,
2270 137, 96, 136, 49, 49, 100, 48, 543, 42, 146,
2271 44, 106, 130, 131, 132, 133, 111, 87, 38, 39,
2272 62, 557, 137, 137, 53, 45, 121, 258, 259, 136,
2273 261, 51, 492, 148, 148, 332, 137, 34, 133, 134,
2274 137, 137, 137, 15, 141, 146, 141, 407, 144, 256,
2275 16, 258, 259, 19, 261, 352, 113, 114, 307, 138,
2276 137, 140, 147, 294, 141, 160, 526, 146, 31, 0,
2277 33, 302, 303, 144, 131, 132, 136, 144, 147, 262,
2278 134, 135, 113, 114, 136, 435, 148, 294, 183, 184,
2279 185, 186, 136, 114, 153, 302, 303, 19, 558, 130,
2280 131, 132, 133, 142, 199, 200, 201, 202, 203, 204,
2281 205, 206, 207, 463, 137, 465, 113, 114, 141, 140,
2282 215, 370, 305, 372, 373, 374, 138, 18, 140, 360,
2283 361, 362, 144, 130, 131, 132, 133, 368, 38, 39,
2284 40, 11, 493, 43, 14, 134, 135, 378, 379, 3,
2285 4, 5, 6, 360, 361, 362, 137, 138, 19, 140,
2286 510, 368, 28, 29, 7, 8, 455, 262, 138, 19,
2287 140, 378, 379, 16, 17, 19, 19, 20, 273, 109,
2288 110, 397, 56, 57, 58, 59, 60, 61, 140, 420,
2289 397, 422, 107, 108, 425, 290, 547, 38, 549, 40,
2290 431, 432, 138, 4, 140, 138, 142, 140, 141, 4,
2291 305, 306, 307, 420, 33, 422, 143, 466, 425, 143,
2292 469, 470, 471, 4, 431, 432, 19, 458, 459, 137,
2293 461, 462, 137, 138, 141, 140, 467, 332, 9, 528,
2294 78, 79, 531, 146, 141, 9, 477, 342, 9, 51,
2295 146, 458, 459, 11, 461, 462, 140, 140, 140, 140,
2296 467, 140, 19, 140, 140, 140, 497, 140, 137, 137,
2297 477, 34, 137, 137, 505, 370, 371, 372, 373, 374,
2298 137, 137, 377, 55, 137, 140, 137, 146, 140, 137,
2299 497, 137, 137, 142, 34, 525, 19, 137, 505, 4,
2300 137, 137, 137, 324, 325, 326, 327, 328, 137, 137,
2301 541, 137, 137, 19, 544, 546, 337, 338, 339, 86,
2302 87, 88, 89, 90, 91, 92, 93, 94, 95, 141,
2303 14, 14, 563, 564, 541, 140, 4, 568, 137, 546,
2304 571, 436, 140, 137, 141, 137, 137, 137, 137, 137,
2305 137, 137, 137, 49, 449, 137, 563, 564, 137, 454,
2306 137, 568, 146, 137, 571, 460, 387, 388, 137, 19,
2307 49, 466, 137, 394, 469, 470, 471, 14, 144, 474,
2308 142, 141, 141, 453, 4, 141, 141, 14, 141, 141,
2309 144, 141, 137, 14, 137, 3, 4, 14, 67, 7,
2310 8, 9, 14, 124, 124, 124, 236, 520, 16, 17,
2311 237, 19, 20, 21, 22, 23, 87, 493, 106, 440,
2312 441, 442, 443, 100, 16, 84, 447, 448, 36, 37,
2313 54, 474, 527, 389, -1, 215, -1, -1, -1, -1,
2314 -1, -1, -1, -1, -1, 53, -1, -1, -1, -1,
2315 520, -1, -1, -1, -1, -1, -1, 478, 479, -1,
2316 -1, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2317 78, 79, 80, 81, 82, 83, 84, 85, 7, 8,
2318 -1, 10, 11, 12, 13, 14, -1, 16, 17, -1,
2319 19, 20, 513, -1, 515, 516, -1, -1, -1, -1,
2320 -1, -1, -1, 111, 112, 113, 114, 115, 116, 117,
2321 118, 119, 120, 121, 122, 123, 45, 125, -1, 127,
2322 128, 129, 3, 4, -1, -1, 7, 8, 9, -1,
2323 138, 0, 140, -1, -1, 16, 17, 145, 19, 20,
2324 21, 22, 23, -1, -1, -1, 15, 16, 17, -1,
2325 19, 20, -1, -1, -1, 36, 37, 26, 27, -1,
2326 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2327 7, 8, 53, 10, 11, 12, 13, 14, 47, 16,
2328 17, 50, 19, 20, -1, 54, -1, -1, 69, 70,
2329 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
2330 81, 82, 83, 84, 85, -1, -1, -1, 45, -1,
2331 139, -1, -1, 142, -1, -1, 145, -1, 147, 148,
2332 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2333 111, 112, 113, 114, 115, 116, 117, 118, 119, 120,
2334 121, 122, 123, -1, 125, -1, 127, 128, 129, 7,
2335 8, -1, -1, -1, -1, -1, -1, -1, 16, 17,
2336 -1, 19, 20, 21, 145, -1, -1, -1, -1, -1,
2337 -1, -1, -1, -1, -1, -1, -1, -1, 36, 37,
2338 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2339 -1, 7, 8, -1, 10, 11, 12, 13, 14, -1,
2340 16, 17, 139, 19, 20, 142, -1, 144, 145, -1,
2341 147, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2342 78, 79, 80, 81, 82, 83, 84, 85, -1, 45,
2343 7, 8, -1, 10, 11, 12, 13, 14, -1, 16,
2344 17, -1, 19, 20, -1, -1, -1, -1, -1, -1,
2345 -1, -1, -1, 111, 112, 113, 114, 115, 116, 117,
2346 118, 119, 120, 121, 122, 123, -1, 125, 45, 127,
2347 128, 129, -1, -1, -1, 3, 4, -1, -1, -1,
2348 138, 9, 140, -1, 142, -1, 0, 145, -1, 147,
2349 -1, 149, -1, 21, 22, 23, -1, -1, -1, -1,
2350 -1, 15, 16, 17, -1, 19, 20, -1, 36, 37,
2351 -1, -1, 26, 27, -1, -1, -1, -1, -1, -1,
2352 -1, -1, -1, 139, -1, 53, 142, -1, -1, 145,
2353 -1, 147, 148, 47, -1, -1, 50, -1, -1, -1,
2354 54, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2355 78, 79, 80, 81, 82, 83, 84, 85, -1, -1,
2356 -1, -1, 139, -1, -1, 142, -1, -1, 145, -1,
2357 147, 148, -1, -1, -1, -1, -1, -1, -1, -1,
2358 -1, -1, -1, 111, 112, 113, 114, 115, 116, 117,
2359 118, 119, 120, 121, 122, 123, -1, 125, -1, 127,
2360 128, 129, 7, 8, -1, 10, 11, 12, 13, 14,
2361 -1, 16, 17, -1, 19, 20, -1, 145, 7, 8,
2362 -1, 10, 11, 12, 13, 14, -1, 16, 17, -1,
2363 19, 20, 7, 8, -1, 10, 11, 12, 13, 14,
2364 45, 16, 17, -1, 19, 20, 35, -1, -1, -1,
2365 -1, -1, -1, -1, -1, -1, 45, -1, -1, -1,
2366 35, -1, 7, 8, -1, 10, 11, 12, 13, 14,
2367 45, 16, 17, -1, 19, 20, 7, 8, -1, 10,
2368 11, 12, 13, 14, -1, 16, 17, -1, 19, 20,
2369 35, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2370 45, -1, -1, -1, 35, -1, 7, 8, -1, 10,
2371 11, 12, 13, 14, 45, 16, 17, -1, 19, 20,
2372 -1, -1, -1, 7, 8, -1, 10, 11, 12, 13,
2373 14, -1, 16, 17, 139, 19, 20, 142, -1, -1,
2374 145, -1, 147, 148, 45, -1, -1, -1, -1, -1,
2375 139, -1, -1, 142, -1, -1, 145, -1, 147, -1,
2376 -1, 45, -1, -1, 139, -1, -1, 142, -1, -1,
2377 145, -1, 147, -1, 7, 8, -1, 10, 11, 12,
2378 13, 14, -1, 16, 17, -1, 19, 20, -1, -1,
2379 -1, -1, -1, -1, 139, -1, -1, 142, -1, -1,
2380 145, -1, 147, -1, -1, -1, -1, -1, 139, -1,
2381 -1, 142, 45, -1, 145, -1, 147, -1, 7, 8,
2382 -1, 10, 11, 12, 13, 14, -1, 16, 17, -1,
2383 19, 20, -1, -1, -1, -1, -1, -1, 139, -1,
2384 -1, 142, -1, -1, 145, -1, 147, 22, 23, -1,
2385 -1, -1, -1, -1, -1, 139, 45, -1, 142, -1,
2386 -1, 145, -1, 147, 7, 8, -1, 10, 11, 12,
2387 13, 14, -1, 16, 17, -1, 19, 20, 7, 8,
2388 -1, 10, 11, 12, 13, 14, -1, 16, 17, -1,
2389 19, 20, -1, -1, -1, -1, -1, -1, -1, -1,
2390 -1, -1, 45, -1, -1, -1, 139, -1, -1, 142,
2391 -1, -1, 145, -1, 147, -1, 45, 92, 93, 94,
2392 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
2393 105, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2394 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2395 139, -1, -1, 142, -1, -1, 145, -1, 147, -1,
2396 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2397 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2398 -1, -1, -1, -1, -1, -1, -1, -1, 32, -1,
2399 -1, -1, -1, -1, -1, -1, 139, -1, -1, 142,
2400 -1, -1, 145, -1, 147, -1, -1, 51, 52, -1,
2401 139, -1, -1, 142, -1, -1, 145, -1, 147, 63,
2402 64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
2403 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2404 84, 85, -1, -1, -1, -1, -1, -1, -1, -1,
2405 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2406 -1, -1, 106, 107, 108, -1, -1, 111, 112, 113,
2407 114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
2408 124, 125, 126, 127, 128, 129
2409};
2410
2411/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2412 symbol of state STATE-NUM. */
2413static const yytype_uint8 yystos[] =
2414{
2415 0, 16, 17, 19, 20, 26, 27, 47, 50, 54,
2416 158, 160, 161, 162, 163, 193, 194, 195, 197, 196,
2417 48, 62, 202, 136, 53, 136, 15, 136, 38, 39,
2418 40, 41, 42, 43, 44, 46, 134, 135, 164, 165,
2419 166, 0, 195, 42, 44, 167, 212, 38, 39, 40,
2420 43, 168, 209, 211, 218, 136, 136, 142, 203, 19,
2421 201, 7, 8, 10, 11, 12, 13, 14, 45, 139,
2422 142, 145, 147, 158, 161, 181, 182, 215, 166, 166,
2423 31, 33, 192, 166, 166, 18, 219, 220, 25, 148,
2424 210, 219, 19, 19, 19, 204, 140, 4, 4, 4,
2425 147, 10, 148, 182, 187, 138, 140, 192, 192, 38,
2426 40, 169, 28, 29, 191, 56, 57, 58, 59, 60,
2427 61, 170, 207, 207, 160, 223, 137, 144, 35, 182,
2428 183, 185, 186, 143, 143, 148, 187, 137, 148, 186,
2429 191, 191, 10, 182, 184, 11, 12, 13, 156, 157,
2430 182, 188, 4, 184, 24, 147, 208, 32, 51, 52,
2431 63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
2432 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
2433 83, 84, 85, 106, 107, 108, 111, 112, 113, 114,
2434 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
2435 125, 126, 127, 128, 129, 151, 152, 153, 221, 227,
2436 228, 229, 230, 19, 172, 137, 141, 182, 182, 146,
2437 148, 182, 141, 188, 182, 215, 22, 23, 3, 4,
2438 5, 6, 9, 21, 36, 37, 84, 85, 111, 125,
2439 127, 128, 129, 142, 145, 147, 149, 151, 152, 153,
2440 189, 215, 198, 161, 51, 10, 182, 217, 11, 14,
2441 11, 156, 170, 86, 87, 88, 89, 90, 91, 92,
2442 93, 94, 95, 154, 22, 23, 92, 93, 94, 95,
2443 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
2444 155, 182, 182, 217, 182, 182, 224, 217, 217, 217,
2445 217, 217, 182, 182, 217, 170, 109, 110, 113, 114,
2446 131, 132, 171, 35, 183, 174, 144, 146, 146, 174,
2447 199, 200, 154, 155, 140, 140, 140, 140, 140, 144,
2448 188, 190, 147, 190, 148, 190, 19, 140, 140, 140,
2449 137, 179, 140, 3, 4, 9, 21, 22, 23, 36,
2450 37, 53, 145, 189, 214, 215, 216, 216, 216, 216,
2451 184, 182, 182, 137, 176, 137, 176, 216, 142, 137,
2452 137, 137, 137, 137, 137, 216, 216, 34, 184, 182,
2453 217, 130, 133, 171, 173, 179, 179, 140, 140, 188,
2454 188, 188, 188, 188, 137, 144, 148, 182, 190, 146,
2455 148, 188, 188, 188, 30, 49, 177, 180, 35, 182,
2456 205, 206, 55, 213, 190, 137, 137, 216, 216, 216,
2457 11, 49, 11, 226, 216, 142, 217, 182, 217, 217,
2458 217, 137, 137, 182, 216, 216, 137, 188, 188, 226,
2459 137, 137, 137, 137, 188, 146, 148, 137, 137, 34,
2460 19, 4, 179, 172, 137, 141, 19, 146, 14, 14,
2461 140, 137, 137, 216, 4, 216, 137, 137, 216, 137,
2462 137, 137, 216, 216, 140, 137, 176, 182, 137, 137,
2463 141, 188, 188, 188, 188, 146, 188, 188, 182, 158,
2464 159, 35, 182, 174, 137, 216, 216, 182, 225, 216,
2465 216, 176, 176, 217, 216, 137, 217, 217, 217, 225,
2466 216, 188, 188, 137, 141, 137, 137, 141, 141, 141,
2467 172, 177, 178, 19, 137, 142, 216, 137, 141, 144,
2468 216, 141, 176, 141, 141, 188, 188, 188, 159, 49,
2469 175, 14, 144, 156, 222, 172, 182, 174, 144, 174,
2470 141, 141, 141, 4, 216, 214, 144, 156, 216, 34,
2471 137, 214, 172, 14, 14, 137, 216, 216, 14, 67,
2472 216, 14, 216
2473};
Reid Spencer68a24bd2005-08-27 18:50:39 +00002474
2475#define yyerrok (yyerrstatus = 0)
2476#define yyclearin (yychar = YYEMPTY)
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002477#define YYEMPTY (-2)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002478#define YYEOF 0
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002479
Reid Spencer68a24bd2005-08-27 18:50:39 +00002480#define YYACCEPT goto yyacceptlab
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002481#define YYABORT goto yyabortlab
2482#define YYERROR goto yyerrorlab
2483
2484
2485/* Like YYERROR except do call yyerror. This remains here temporarily
2486 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002487 Once GCC version 2 has supplanted version 1, this can go. */
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002488
Reid Spencer68a24bd2005-08-27 18:50:39 +00002489#define YYFAIL goto yyerrlab
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002490
Reid Spencer68a24bd2005-08-27 18:50:39 +00002491#define YYRECOVERING() (!!yyerrstatus)
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002492
2493#define YYBACKUP(Token, Value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002494do \
2495 if (yychar == YYEMPTY && yylen == 1) \
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002496 { \
2497 yychar = (Token); \
2498 yylval = (Value); \
2499 yytoken = YYTRANSLATE (yychar); \
2500 YYPOPSTACK (1); \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002501 goto yybackup; \
2502 } \
2503 else \
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002504 { \
2505 yyerror (YY_("syntax error: cannot back up")); \
2506 YYERROR; \
2507 } \
2508while (YYID (0))
2509
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002510
Reid Spencer68a24bd2005-08-27 18:50:39 +00002511#define YYTERROR 1
2512#define YYERRCODE 256
2513
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002514
2515/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2516 If N is 0, then set CURRENT to the empty location which ends
2517 the previous symbol: RHS[0] (always defined). */
2518
2519#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2520#ifndef YYLLOC_DEFAULT
2521# define YYLLOC_DEFAULT(Current, Rhs, N) \
2522 do \
2523 if (YYID (N)) \
2524 { \
2525 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2526 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2527 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2528 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2529 } \
2530 else \
2531 { \
2532 (Current).first_line = (Current).last_line = \
2533 YYRHSLOC (Rhs, 0).last_line; \
2534 (Current).first_column = (Current).last_column = \
2535 YYRHSLOC (Rhs, 0).last_column; \
2536 } \
2537 while (YYID (0))
Reid Spencer68a24bd2005-08-27 18:50:39 +00002538#endif
2539
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002540
2541/* YY_LOCATION_PRINT -- Print the location on the stream.
2542 This macro was not mandated originally: define only if we know
2543 we won't break user code: when these are the locations we know. */
2544
2545#ifndef YY_LOCATION_PRINT
2546# if YYLTYPE_IS_TRIVIAL
2547# define YY_LOCATION_PRINT(File, Loc) \
2548 fprintf (File, "%d.%d-%d.%d", \
2549 (Loc).first_line, (Loc).first_column, \
2550 (Loc).last_line, (Loc).last_column)
2551# else
2552# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2553# endif
2554#endif
2555
2556
2557/* YYLEX -- calling `yylex' with the right arguments. */
2558
Reid Spencer41dff5e2007-01-26 08:05:27 +00002559#ifdef YYLEX_PARAM
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002560# define YYLEX yylex (YYLEX_PARAM)
Reid Spencer41dff5e2007-01-26 08:05:27 +00002561#else
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002562# define YYLEX yylex ()
Christopher Lamb5c104242007-04-22 20:09:11 +00002563#endif
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002564
2565/* Enable debugging if requested. */
2566#if YYDEBUG
2567
2568# ifndef YYFPRINTF
2569# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2570# define YYFPRINTF fprintf
2571# endif
2572
2573# define YYDPRINTF(Args) \
2574do { \
2575 if (yydebug) \
2576 YYFPRINTF Args; \
2577} while (YYID (0))
2578
2579# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2580do { \
2581 if (yydebug) \
2582 { \
2583 YYFPRINTF (stderr, "%s ", Title); \
2584 yy_symbol_print (stderr, \
2585 Type, Value); \
2586 YYFPRINTF (stderr, "\n"); \
2587 } \
2588} while (YYID (0))
2589
2590
2591/*--------------------------------.
2592| Print this symbol on YYOUTPUT. |
2593`--------------------------------*/
2594
2595/*ARGSUSED*/
2596#if (defined __STDC__ || defined __C99__FUNC__ \
2597 || defined __cplusplus || defined _MSC_VER)
2598static void
2599yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
Christopher Lamb5c104242007-04-22 20:09:11 +00002600#else
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002601static void
2602yy_symbol_value_print (yyoutput, yytype, yyvaluep)
2603 FILE *yyoutput;
2604 int yytype;
2605 YYSTYPE const * const yyvaluep;
Christopher Lamb5c104242007-04-22 20:09:11 +00002606#endif
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002607{
2608 if (!yyvaluep)
2609 return;
2610# ifdef YYPRINT
2611 if (yytype < YYNTOKENS)
2612 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2613# else
2614 YYUSE (yyoutput);
2615# endif
2616 switch (yytype)
2617 {
2618 default:
2619 break;
2620 }
2621}
2622
2623
2624/*--------------------------------.
2625| Print this symbol on YYOUTPUT. |
2626`--------------------------------*/
2627
2628#if (defined __STDC__ || defined __C99__FUNC__ \
2629 || defined __cplusplus || defined _MSC_VER)
2630static void
2631yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
2632#else
2633static void
2634yy_symbol_print (yyoutput, yytype, yyvaluep)
2635 FILE *yyoutput;
2636 int yytype;
2637 YYSTYPE const * const yyvaluep;
Christopher Lamb2330e4d2007-04-21 08:16:25 +00002638#endif
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002639{
2640 if (yytype < YYNTOKENS)
2641 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2642 else
2643 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
Reid Spencerc67bdc22007-04-21 18:36:27 +00002644
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002645 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
2646 YYFPRINTF (yyoutput, ")");
2647}
Reid Spencerc67bdc22007-04-21 18:36:27 +00002648
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002649/*------------------------------------------------------------------.
2650| yy_stack_print -- Print the state stack from its BOTTOM up to its |
2651| TOP (included). |
2652`------------------------------------------------------------------*/
Reid Spencerc67bdc22007-04-21 18:36:27 +00002653
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002654#if (defined __STDC__ || defined __C99__FUNC__ \
2655 || defined __cplusplus || defined _MSC_VER)
2656static void
2657yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
2658#else
2659static void
2660yy_stack_print (bottom, top)
2661 yytype_int16 *bottom;
2662 yytype_int16 *top;
Christopher Lamb2330e4d2007-04-21 08:16:25 +00002663#endif
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002664{
2665 YYFPRINTF (stderr, "Stack now");
2666 for (; bottom <= top; ++bottom)
2667 YYFPRINTF (stderr, " %d", *bottom);
2668 YYFPRINTF (stderr, "\n");
2669}
Reid Spencerc67bdc22007-04-21 18:36:27 +00002670
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002671# define YY_STACK_PRINT(Bottom, Top) \
2672do { \
2673 if (yydebug) \
2674 yy_stack_print ((Bottom), (Top)); \
2675} while (YYID (0))
Reid Spencerc67bdc22007-04-21 18:36:27 +00002676
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002677
2678/*------------------------------------------------.
2679| Report that the YYRULE is going to be reduced. |
2680`------------------------------------------------*/
2681
2682#if (defined __STDC__ || defined __C99__FUNC__ \
2683 || defined __cplusplus || defined _MSC_VER)
2684static void
2685yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
2686#else
2687static void
2688yy_reduce_print (yyvsp, yyrule)
2689 YYSTYPE *yyvsp;
2690 int yyrule;
Chris Lattner32980692007-02-19 07:44:24 +00002691#endif
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002692{
2693 int yynrhs = yyr2[yyrule];
2694 int yyi;
2695 unsigned long int yylno = yyrline[yyrule];
2696 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
2697 yyrule - 1, yylno);
2698 /* The symbols being reduced. */
2699 for (yyi = 0; yyi < yynrhs; yyi++)
2700 {
2701 fprintf (stderr, " $%d = ", yyi + 1);
2702 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
2703 &(yyvsp[(yyi + 1) - (yynrhs)])
2704 );
2705 fprintf (stderr, "\n");
2706 }
2707}
Reid Spencer38c91a92007-02-28 02:24:54 +00002708
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002709# define YY_REDUCE_PRINT(Rule) \
2710do { \
2711 if (yydebug) \
2712 yy_reduce_print (yyvsp, Rule); \
2713} while (YYID (0))
Reid Spencer38c91a92007-02-28 02:24:54 +00002714
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002715/* Nonzero means print parse trace. It is left uninitialized so that
2716 multiple parsers can coexist. */
2717int yydebug;
2718#else /* !YYDEBUG */
2719# define YYDPRINTF(Args)
2720# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
2721# define YY_STACK_PRINT(Bottom, Top)
2722# define YY_REDUCE_PRINT(Rule)
2723#endif /* !YYDEBUG */
2724
2725
2726/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002727#ifndef YYINITDEPTH
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002728# define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00002729#endif
2730
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002731/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2732 if the built-in stack extension method is used).
Reid Spencer68a24bd2005-08-27 18:50:39 +00002733
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002734 Do not make this value too large; the results are undefined if
2735 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
2736 evaluated with infinite-precision integer arithmetic. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002737
2738#ifndef YYMAXDEPTH
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002739# define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00002740#endif
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002741
Reid Spencer68a24bd2005-08-27 18:50:39 +00002742
2743
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002744#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00002745
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002746# ifndef yystrlen
2747# if defined __GLIBC__ && defined _STRING_H
2748# define yystrlen strlen
2749# else
2750/* Return the length of YYSTR. */
2751#if (defined __STDC__ || defined __C99__FUNC__ \
2752 || defined __cplusplus || defined _MSC_VER)
2753static YYSIZE_T
2754yystrlen (const char *yystr)
Christopher Lamb5c104242007-04-22 20:09:11 +00002755#else
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002756static YYSIZE_T
2757yystrlen (yystr)
2758 const char *yystr;
2759#endif
2760{
2761 YYSIZE_T yylen;
2762 for (yylen = 0; yystr[yylen]; yylen++)
2763 continue;
2764 return yylen;
2765}
2766# endif
2767# endif
2768
2769# ifndef yystpcpy
2770# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
2771# define yystpcpy stpcpy
2772# else
2773/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2774 YYDEST. */
2775#if (defined __STDC__ || defined __C99__FUNC__ \
2776 || defined __cplusplus || defined _MSC_VER)
2777static char *
2778yystpcpy (char *yydest, const char *yysrc)
2779#else
2780static char *
2781yystpcpy (yydest, yysrc)
2782 char *yydest;
2783 const char *yysrc;
2784#endif
2785{
2786 char *yyd = yydest;
2787 const char *yys = yysrc;
2788
2789 while ((*yyd++ = *yys++) != '\0')
2790 continue;
2791
2792 return yyd - 1;
2793}
2794# endif
2795# endif
2796
2797# ifndef yytnamerr
2798/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
2799 quotes and backslashes, so that it's suitable for yyerror. The
2800 heuristic is that double-quoting is unnecessary unless the string
2801 contains an apostrophe, a comma, or backslash (other than
2802 backslash-backslash). YYSTR is taken from yytname. If YYRES is
2803 null, do not copy; instead, return the length of what the result
2804 would have been. */
2805static YYSIZE_T
2806yytnamerr (char *yyres, const char *yystr)
2807{
2808 if (*yystr == '"')
2809 {
2810 YYSIZE_T yyn = 0;
2811 char const *yyp = yystr;
2812
2813 for (;;)
2814 switch (*++yyp)
2815 {
2816 case '\'':
2817 case ',':
2818 goto do_not_strip_quotes;
2819
2820 case '\\':
2821 if (*++yyp != '\\')
2822 goto do_not_strip_quotes;
2823 /* Fall through. */
2824 default:
2825 if (yyres)
2826 yyres[yyn] = *yyp;
2827 yyn++;
2828 break;
2829
2830 case '"':
2831 if (yyres)
2832 yyres[yyn] = '\0';
2833 return yyn;
2834 }
2835 do_not_strip_quotes: ;
2836 }
2837
2838 if (! yyres)
2839 return yystrlen (yystr);
2840
2841 return yystpcpy (yyres, yystr) - yyres;
2842}
2843# endif
2844
2845/* Copy into YYRESULT an error message about the unexpected token
2846 YYCHAR while in state YYSTATE. Return the number of bytes copied,
2847 including the terminating null byte. If YYRESULT is null, do not
2848 copy anything; just return the number of bytes that would be
2849 copied. As a special case, return 0 if an ordinary "syntax error"
2850 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
2851 size calculation. */
2852static YYSIZE_T
2853yysyntax_error (char *yyresult, int yystate, int yychar)
2854{
2855 int yyn = yypact[yystate];
2856
2857 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
2858 return 0;
2859 else
2860 {
2861 int yytype = YYTRANSLATE (yychar);
2862 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
2863 YYSIZE_T yysize = yysize0;
2864 YYSIZE_T yysize1;
2865 int yysize_overflow = 0;
2866 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
2867 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
2868 int yyx;
2869
2870# if 0
2871 /* This is so xgettext sees the translatable formats that are
2872 constructed on the fly. */
2873 YY_("syntax error, unexpected %s");
2874 YY_("syntax error, unexpected %s, expecting %s");
2875 YY_("syntax error, unexpected %s, expecting %s or %s");
2876 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
2877 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
2878# endif
2879 char *yyfmt;
2880 char const *yyf;
2881 static char const yyunexpected[] = "syntax error, unexpected %s";
2882 static char const yyexpecting[] = ", expecting %s";
2883 static char const yyor[] = " or %s";
2884 char yyformat[sizeof yyunexpected
2885 + sizeof yyexpecting - 1
2886 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
2887 * (sizeof yyor - 1))];
2888 char const *yyprefix = yyexpecting;
2889
2890 /* Start YYX at -YYN if negative to avoid negative indexes in
2891 YYCHECK. */
2892 int yyxbegin = yyn < 0 ? -yyn : 0;
2893
2894 /* Stay within bounds of both yycheck and yytname. */
2895 int yychecklim = YYLAST - yyn + 1;
2896 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
2897 int yycount = 1;
2898
2899 yyarg[0] = yytname[yytype];
2900 yyfmt = yystpcpy (yyformat, yyunexpected);
2901
2902 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
2903 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
2904 {
2905 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
2906 {
2907 yycount = 1;
2908 yysize = yysize0;
2909 yyformat[sizeof yyunexpected - 1] = '\0';
2910 break;
2911 }
2912 yyarg[yycount++] = yytname[yyx];
2913 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
2914 yysize_overflow |= (yysize1 < yysize);
2915 yysize = yysize1;
2916 yyfmt = yystpcpy (yyfmt, yyprefix);
2917 yyprefix = yyor;
2918 }
2919
2920 yyf = YY_(yyformat);
2921 yysize1 = yysize + yystrlen (yyf);
2922 yysize_overflow |= (yysize1 < yysize);
2923 yysize = yysize1;
2924
2925 if (yysize_overflow)
2926 return YYSIZE_MAXIMUM;
2927
2928 if (yyresult)
2929 {
2930 /* Avoid sprintf, as that infringes on the user's name space.
2931 Don't have undefined behavior even if the translation
2932 produced a string with the wrong number of "%s"s. */
2933 char *yyp = yyresult;
2934 int yyi = 0;
2935 while ((*yyp = *yyf) != '\0')
2936 {
2937 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
2938 {
2939 yyp += yytnamerr (yyp, yyarg[yyi++]);
2940 yyf += 2;
2941 }
2942 else
2943 {
2944 yyp++;
2945 yyf++;
2946 }
2947 }
2948 }
2949 return yysize;
2950 }
2951}
2952#endif /* YYERROR_VERBOSE */
2953
2954
2955/*-----------------------------------------------.
2956| Release the memory associated to this symbol. |
2957`-----------------------------------------------*/
2958
2959/*ARGSUSED*/
2960#if (defined __STDC__ || defined __C99__FUNC__ \
2961 || defined __cplusplus || defined _MSC_VER)
2962static void
2963yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
2964#else
2965static void
2966yydestruct (yymsg, yytype, yyvaluep)
2967 const char *yymsg;
2968 int yytype;
2969 YYSTYPE *yyvaluep;
2970#endif
2971{
2972 YYUSE (yyvaluep);
2973
2974 if (!yymsg)
2975 yymsg = "Deleting";
2976 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
2977
2978 switch (yytype)
2979 {
2980
2981 default:
2982 break;
2983 }
2984}
2985
2986
2987/* Prevent warnings from -Wmissing-prototypes. */
2988
2989#ifdef YYPARSE_PARAM
2990#if defined __STDC__ || defined __cplusplus
2991int yyparse (void *YYPARSE_PARAM);
2992#else
2993int yyparse ();
2994#endif
2995#else /* ! YYPARSE_PARAM */
2996#if defined __STDC__ || defined __cplusplus
Reid Spencere812fb22006-01-19 01:21:04 +00002997int yyparse (void);
Christopher Lamb5c104242007-04-22 20:09:11 +00002998#else
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002999int yyparse ();
Christopher Lamb5c104242007-04-22 20:09:11 +00003000#endif
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003001#endif /* ! YYPARSE_PARAM */
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003002
Chris Lattner7d9801d2007-02-13 00:58:01 +00003003
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003004
3005/* The look-ahead symbol. */
3006int yychar;
3007
3008/* The semantic value of the look-ahead symbol. */
3009YYSTYPE yylval;
3010
3011/* Number of syntax errors so far. */
3012int yynerrs;
3013
3014
3015
3016/*----------.
3017| yyparse. |
3018`----------*/
3019
3020#ifdef YYPARSE_PARAM
3021#if (defined __STDC__ || defined __C99__FUNC__ \
3022 || defined __cplusplus || defined _MSC_VER)
3023int
3024yyparse (void *YYPARSE_PARAM)
3025#else
3026int
3027yyparse (YYPARSE_PARAM)
3028 void *YYPARSE_PARAM;
3029#endif
3030#else /* ! YYPARSE_PARAM */
3031#if (defined __STDC__ || defined __C99__FUNC__ \
3032 || defined __cplusplus || defined _MSC_VER)
3033int
3034yyparse (void)
3035#else
3036int
3037yyparse ()
3038
Christopher Lamb5c104242007-04-22 20:09:11 +00003039#endif
3040#endif
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003041{
3042
3043 int yystate;
3044 int yyn;
3045 int yyresult;
3046 /* Number of tokens to shift before error messages enabled. */
3047 int yyerrstatus;
3048 /* Look-ahead token as an internal (translated) token number. */
3049 int yytoken = 0;
3050#if YYERROR_VERBOSE
3051 /* Buffer for error messages, and its allocated size. */
3052 char yymsgbuf[128];
3053 char *yymsg = yymsgbuf;
3054 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
Christopher Lamb5c104242007-04-22 20:09:11 +00003055#endif
Chris Lattner7d9801d2007-02-13 00:58:01 +00003056
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003057 /* Three stacks and their tools:
3058 `yyss': related to states,
3059 `yyvs': related to semantic values,
3060 `yyls': related to locations.
3061
3062 Refer to the stacks thru separate pointers, to allow yyoverflow
3063 to reallocate them elsewhere. */
3064
3065 /* The state stack. */
3066 yytype_int16 yyssa[YYINITDEPTH];
3067 yytype_int16 *yyss = yyssa;
3068 yytype_int16 *yyssp;
3069
3070 /* The semantic value stack. */
3071 YYSTYPE yyvsa[YYINITDEPTH];
3072 YYSTYPE *yyvs = yyvsa;
3073 YYSTYPE *yyvsp;
3074
3075
3076
3077#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
3078
3079 YYSIZE_T yystacksize = YYINITDEPTH;
3080
3081 /* The variables used to return semantic value and location from the
3082 action routines. */
3083 YYSTYPE yyval;
3084
3085
3086 /* The number of symbols on the RHS of the reduced rule.
3087 Keep to zero when no symbol should be popped. */
3088 int yylen = 0;
3089
3090 YYDPRINTF ((stderr, "Starting parse\n"));
3091
Reid Spencer68a24bd2005-08-27 18:50:39 +00003092 yystate = 0;
3093 yyerrstatus = 0;
3094 yynerrs = 0;
3095 yychar = YYEMPTY; /* Cause a token to be read. */
3096
3097 /* Initialize stack pointers.
3098 Waste one element of value and location stack
3099 so that they stay on the same level as the state stack.
3100 The wasted elements are never initialized. */
3101
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003102 yyssp = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003103 yyvsp = yyvs;
3104
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003105 goto yysetstate;
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003106
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003107/*------------------------------------------------------------.
3108| yynewstate -- Push a new state, which is found in yystate. |
3109`------------------------------------------------------------*/
3110 yynewstate:
3111 /* In all cases, when you get here, the value and location stacks
3112 have just been pushed. So pushing a state here evens the stacks. */
3113 yyssp++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003114
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003115 yysetstate:
3116 *yyssp = yystate;
3117
3118 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003119 {
3120 /* Get the current used size of the three stacks, in elements. */
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003121 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003122
3123#ifdef yyoverflow
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003124 {
3125 /* Give user a chance to reallocate the stack. Use copies of
3126 these so that the &'s don't force the real ones into
3127 memory. */
3128 YYSTYPE *yyvs1 = yyvs;
3129 yytype_int16 *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003130
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003131
3132 /* Each stack pointer address is followed by the size of the
3133 data in use in that stack, in bytes. This used to be a
3134 conditional around just the two extra args, but that might
3135 be undefined if yyoverflow is a macro. */
3136 yyoverflow (YY_("memory exhausted"),
3137 &yyss1, yysize * sizeof (*yyssp),
3138 &yyvs1, yysize * sizeof (*yyvsp),
3139
3140 &yystacksize);
3141
3142 yyss = yyss1;
3143 yyvs = yyvs1;
3144 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00003145#else /* no yyoverflow */
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003146# ifndef YYSTACK_RELOCATE
3147 goto yyexhaustedlab;
3148# else
Reid Spencer68a24bd2005-08-27 18:50:39 +00003149 /* Extend the stack our own way. */
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003150 if (YYMAXDEPTH <= yystacksize)
3151 goto yyexhaustedlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003152 yystacksize *= 2;
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003153 if (YYMAXDEPTH < yystacksize)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003154 yystacksize = YYMAXDEPTH;
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003155
3156 {
3157 yytype_int16 *yyss1 = yyss;
3158 union yyalloc *yyptr =
3159 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3160 if (! yyptr)
3161 goto yyexhaustedlab;
3162 YYSTACK_RELOCATE (yyss);
3163 YYSTACK_RELOCATE (yyvs);
3164
3165# undef YYSTACK_RELOCATE
3166 if (yyss1 != yyssa)
3167 YYSTACK_FREE (yyss1);
3168 }
3169# endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00003170#endif /* no yyoverflow */
3171
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003172 yyssp = yyss + yysize - 1;
3173 yyvsp = yyvs + yysize - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003174
3175
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003176 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3177 (unsigned long int) yystacksize));
3178
3179 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003180 YYABORT;
3181 }
3182
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003183 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003184
3185 goto yybackup;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003186
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003187/*-----------.
3188| yybackup. |
3189`-----------*/
3190yybackup:
Andrew Lenharth6353e052006-12-08 18:07:09 +00003191
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003192 /* Do appropriate processing given the current state. Read a
3193 look-ahead token if we need one and don't already have one. */
Reid Spencer7780acb2007-04-16 06:56:07 +00003194
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003195 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003196 yyn = yypact[yystate];
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003197 if (yyn == YYPACT_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003198 goto yydefault;
3199
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003200 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003201
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003202 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003203 if (yychar == YYEMPTY)
3204 {
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003205 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003206 yychar = YYLEX;
3207 }
3208
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003209 if (yychar <= YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003210 {
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003211 yychar = yytoken = YYEOF;
3212 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003213 }
3214 else
3215 {
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003216 yytoken = YYTRANSLATE (yychar);
3217 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003218 }
3219
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003220 /* If the proper action on seeing token YYTOKEN is to reduce or to
3221 detect an error, take that action. */
3222 yyn += yytoken;
3223 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003224 goto yydefault;
3225 yyn = yytable[yyn];
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003226 if (yyn <= 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003227 {
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003228 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003229 goto yyerrlab;
3230 yyn = -yyn;
3231 goto yyreduce;
3232 }
3233
3234 if (yyn == YYFINAL)
3235 YYACCEPT;
3236
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003237 /* Count tokens shifted since error; after three, turn off error
3238 status. */
3239 if (yyerrstatus)
3240 yyerrstatus--;
Christopher Lamb5c104242007-04-22 20:09:11 +00003241
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003242 /* Shift the look-ahead token. */
3243 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Reid Spencer7780acb2007-04-16 06:56:07 +00003244
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003245 /* Discard the shifted token unless it is eof. */
Reid Spencer7780acb2007-04-16 06:56:07 +00003246 if (yychar != YYEOF)
3247 yychar = YYEMPTY;
3248
Chris Lattner9d2fda62007-02-13 05:53:56 +00003249 yystate = yyn;
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003250 *++yyvsp = yylval;
3251
Reid Spencer68a24bd2005-08-27 18:50:39 +00003252 goto yynewstate;
3253
Christopher Lamb5c104242007-04-22 20:09:11 +00003254
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003255/*-----------------------------------------------------------.
3256| yydefault -- do the default action for the current state. |
3257`-----------------------------------------------------------*/
3258yydefault:
Reid Spencer68a24bd2005-08-27 18:50:39 +00003259 yyn = yydefact[yystate];
3260 if (yyn == 0)
3261 goto yyerrlab;
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003262 goto yyreduce;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003263
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003264
3265/*-----------------------------.
3266| yyreduce -- Do a reduction. |
3267`-----------------------------*/
Reid Spencer68a24bd2005-08-27 18:50:39 +00003268yyreduce:
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003269 /* yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003270 yylen = yyr2[yyn];
3271
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003272 /* If YYLEN is nonzero, implement the default value of the action:
3273 `$$ = $1'.
3274
3275 Otherwise, the following line sets YYVAL to garbage.
3276 This behavior is undocumented and Bison
3277 users should not rely upon it. Assigning to YYVAL
3278 unconditionally makes the parser a bit smaller, and it avoids a
3279 GCC warning that YYVAL may be used uninitialized. */
3280 yyval = yyvsp[1-yylen];
3281
3282
3283 YY_REDUCE_PRINT (yyn);
3284 switch (yyn)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003285 {
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003286 case 29:
3287#line 1100 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3288 { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;}
3289 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003290
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003291 case 30:
3292#line 1100 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3293 { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;}
3294 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003295
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003296 case 31:
3297#line 1101 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3298 { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;}
3299 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003300
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003301 case 32:
3302#line 1101 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3303 { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;}
3304 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003305
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003306 case 33:
3307#line 1102 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3308 { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;}
3309 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003310
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003311 case 34:
3312#line 1102 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3313 { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;}
3314 break;
3315
3316 case 35:
3317#line 1103 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3318 { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;}
3319 break;
3320
3321 case 36:
3322#line 1103 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3323 { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;}
3324 break;
3325
3326 case 37:
3327#line 1104 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3328 { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;}
3329 break;
3330
3331 case 38:
3332#line 1104 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3333 { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;}
3334 break;
3335
3336 case 39:
3337#line 1108 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3338 { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;}
3339 break;
3340
3341 case 40:
3342#line 1108 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3343 { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;}
3344 break;
3345
3346 case 41:
3347#line 1109 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3348 { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;}
3349 break;
3350
3351 case 42:
3352#line 1109 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3353 { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;}
3354 break;
3355
3356 case 43:
3357#line 1110 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3358 { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;}
3359 break;
3360
3361 case 44:
3362#line 1110 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3363 { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;}
3364 break;
3365
3366 case 45:
3367#line 1111 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3368 { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;}
3369 break;
3370
3371 case 46:
3372#line 1111 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3373 { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;}
3374 break;
3375
3376 case 47:
3377#line 1112 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3378 { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;}
3379 break;
3380
3381 case 48:
3382#line 1112 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3383 { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;}
3384 break;
3385
3386 case 49:
3387#line 1113 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3388 { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;}
3389 break;
3390
3391 case 50:
3392#line 1113 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3393 { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;}
3394 break;
3395
3396 case 51:
3397#line 1114 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3398 { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;}
3399 break;
3400
3401 case 52:
3402#line 1114 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3403 { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;}
3404 break;
3405
3406 case 53:
3407#line 1115 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3408 { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;}
3409 break;
3410
3411 case 54:
3412#line 1116 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3413 { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;}
3414 break;
3415
3416 case 61:
3417#line 1125 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3418 { (yyval.StrVal) = 0; ;}
3419 break;
3420
3421 case 62:
3422#line 1129 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3423 {
3424 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003425 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003426 ;}
3427 break;
3428
3429 case 63:
3430#line 1133 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3431 {
3432 (yyval.StrVal) = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003433 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003434 ;}
3435 break;
3436
3437 case 67:
3438#line 1141 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3439 {
3440 (yyval.StrVal) = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003441 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003442 ;}
3443 break;
3444
3445 case 68:
3446#line 1146 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3447 {
3448 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003449 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003450 ;}
3451 break;
3452
3453 case 69:
3454#line 1152 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3455 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3456 break;
3457
3458 case 70:
3459#line 1153 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3460 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3461 break;
3462
3463 case 71:
3464#line 1154 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3465 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3466 break;
3467
3468 case 72:
3469#line 1155 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3470 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3471 break;
3472
3473 case 73:
3474#line 1156 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3475 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3476 break;
3477
3478 case 74:
3479#line 1160 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3480 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3481 break;
3482
3483 case 75:
3484#line 1161 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3485 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3486 break;
3487
3488 case 76:
3489#line 1162 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3490 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3491 break;
3492
3493 case 77:
3494#line 1166 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3495 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3496 break;
3497
3498 case 78:
3499#line 1167 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3500 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3501 break;
3502
3503 case 79:
3504#line 1168 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3505 { (yyval.Visibility) = GlobalValue::HiddenVisibility; ;}
3506 break;
3507
3508 case 80:
3509#line 1172 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3510 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3511 break;
3512
3513 case 81:
3514#line 1173 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3515 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3516 break;
3517
3518 case 82:
3519#line 1174 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3520 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3521 break;
3522
3523 case 83:
3524#line 1178 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3525 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3526 break;
3527
3528 case 84:
3529#line 1179 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3530 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3531 break;
3532
3533 case 85:
3534#line 1180 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3535 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3536 break;
3537
3538 case 86:
3539#line 1181 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3540 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3541 break;
3542
3543 case 87:
3544#line 1182 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3545 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3546 break;
3547
3548 case 88:
3549#line 1186 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3550 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3551 break;
3552
3553 case 89:
3554#line 1187 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3555 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3556 break;
3557
3558 case 90:
3559#line 1188 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3560 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3561 break;
3562
3563 case 91:
3564#line 1191 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3565 { (yyval.UIntVal) = CallingConv::C; ;}
3566 break;
3567
3568 case 92:
3569#line 1192 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3570 { (yyval.UIntVal) = CallingConv::C; ;}
3571 break;
3572
3573 case 93:
3574#line 1193 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3575 { (yyval.UIntVal) = CallingConv::Fast; ;}
3576 break;
3577
3578 case 94:
3579#line 1194 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3580 { (yyval.UIntVal) = CallingConv::Cold; ;}
3581 break;
3582
3583 case 95:
3584#line 1195 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3585 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
3586 break;
3587
3588 case 96:
3589#line 1196 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3590 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
3591 break;
3592
3593 case 97:
3594#line 1197 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3595 {
3596 if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
Reid Spencerb5334b02007-02-05 10:18:06 +00003597 GEN_ERROR("Calling conv too large");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003598 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003599 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003600 ;}
3601 break;
3602
3603 case 98:
3604#line 1204 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3605 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
3606 break;
3607
3608 case 99:
3609#line 1205 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3610 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
3611 break;
3612
3613 case 100:
3614#line 1206 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3615 { (yyval.ParamAttrs) = ParamAttr::InReg; ;}
3616 break;
3617
3618 case 101:
3619#line 1207 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3620 { (yyval.ParamAttrs) = ParamAttr::StructRet; ;}
3621 break;
3622
3623 case 102:
3624#line 1210 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3625 { (yyval.ParamAttrs) = ParamAttr::None; ;}
3626 break;
3627
3628 case 103:
3629#line 1211 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3630 {
3631 (yyval.ParamAttrs) = (yyvsp[(1) - (2)].ParamAttrs) | (yyvsp[(2) - (2)].ParamAttrs);
3632 ;}
3633 break;
3634
3635 case 104:
3636#line 1216 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3637 { (yyval.ParamAttrs) = ParamAttr::NoReturn; ;}
3638 break;
3639
3640 case 105:
3641#line 1217 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3642 { (yyval.ParamAttrs) = ParamAttr::NoUnwind; ;}
3643 break;
3644
3645 case 107:
3646#line 1221 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3647 { (yyval.ParamAttrs) = ParamAttr::None; ;}
3648 break;
3649
3650 case 108:
3651#line 1222 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3652 {
3653 (yyval.ParamAttrs) = (yyvsp[(1) - (2)].ParamAttrs) | (yyvsp[(2) - (2)].ParamAttrs);
3654 ;}
3655 break;
3656
3657 case 109:
3658#line 1229 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3659 { (yyval.UIntVal) = 0; ;}
3660 break;
3661
3662 case 110:
3663#line 1230 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3664 {
3665 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
3666 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00003667 GEN_ERROR("Alignment must be a power of two");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003668 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003669;}
3670 break;
3671
3672 case 111:
3673#line 1236 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3674 { (yyval.UIntVal) = 0; ;}
3675 break;
3676
3677 case 112:
3678#line 1237 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3679 {
3680 (yyval.UIntVal) = (yyvsp[(3) - (3)].UInt64Val);
3681 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencer66728ef2007-03-20 01:13:36 +00003682 GEN_ERROR("Alignment must be a power of two");
3683 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003684;}
3685 break;
3686
3687 case 113:
3688#line 1245 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3689 {
3690 for (unsigned i = 0, e = strlen((yyvsp[(2) - (2)].StrVal)); i != e; ++i)
3691 if ((yyvsp[(2) - (2)].StrVal)[i] == '"' || (yyvsp[(2) - (2)].StrVal)[i] == '\\')
Reid Spencerb5334b02007-02-05 10:18:06 +00003692 GEN_ERROR("Invalid character in section name");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003693 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003694 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003695;}
3696 break;
3697
3698 case 114:
3699#line 1253 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3700 { (yyval.StrVal) = 0; ;}
3701 break;
3702
3703 case 115:
3704#line 1254 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3705 { (yyval.StrVal) = (yyvsp[(1) - (1)].StrVal); ;}
3706 break;
3707
3708 case 116:
3709#line 1259 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3710 {;}
3711 break;
3712
3713 case 117:
3714#line 1260 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3715 {;}
3716 break;
3717
3718 case 118:
3719#line 1261 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3720 {
3721 CurGV->setSection((yyvsp[(1) - (1)].StrVal));
3722 free((yyvsp[(1) - (1)].StrVal));
Reid Spencer6f407902007-01-13 05:00:46 +00003723 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003724 ;}
3725 break;
3726
3727 case 119:
3728#line 1266 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3729 {
3730 if ((yyvsp[(2) - (2)].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[(2) - (2)].UInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00003731 GEN_ERROR("Alignment must be a power of two");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003732 CurGV->setAlignment((yyvsp[(2) - (2)].UInt64Val));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003733 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003734 ;}
3735 break;
3736
3737 case 124:
3738#line 1282 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3739 {
3740 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003741 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003742 ;}
3743 break;
3744
3745 case 125:
3746#line 1286 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3747 {
3748 (yyval.TypeVal) = new PATypeHolder((yyvsp[(1) - (1)].PrimType));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003749 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003750 ;}
3751 break;
3752
3753 case 126:
3754#line 1290 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3755 { // Pointer type?
3756 if (*(yyvsp[(1) - (2)].TypeVal) == Type::LabelTy)
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003757 GEN_ERROR("Cannot form a pointer to a basic block");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003758 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[(1) - (2)].TypeVal))));
3759 delete (yyvsp[(1) - (2)].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003760 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003761 ;}
3762 break;
3763
3764 case 127:
3765#line 1297 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3766 { // Named types are also simple types...
3767 const Type* tmp = getTypeVal((yyvsp[(1) - (1)].ValIDVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003768 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003769 (yyval.TypeVal) = new PATypeHolder(tmp);
3770 ;}
3771 break;
3772
3773 case 128:
3774#line 1302 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3775 { // Type UpReference
3776 if ((yyvsp[(2) - (2)].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003777 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003778 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[(2) - (2)].UInt64Val), OT)); // Add to vector...
3779 (yyval.TypeVal) = new PATypeHolder(OT);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003780 UR_OUT("New Upreference!\n");
3781 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003782 ;}
3783 break;
3784
3785 case 129:
3786#line 1310 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3787 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003788 std::vector<const Type*> Params;
Christopher Lamb5c104242007-04-22 20:09:11 +00003789 ParamAttrsVector Attrs;
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003790 if ((yyvsp[(5) - (5)].ParamAttrs) != ParamAttr::None) {
3791 ParamAttrsWithIndex X; X.index = 0; X.attrs = (yyvsp[(5) - (5)].ParamAttrs);
Christopher Lamb5c104242007-04-22 20:09:11 +00003792 Attrs.push_back(X);
3793 }
Reid Spencer7b5d4662007-04-09 06:16:21 +00003794 unsigned index = 1;
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003795 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00003796 for (; I != E; ++I, ++index) {
Reid Spencer66728ef2007-03-20 01:13:36 +00003797 const Type *Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00003798 Params.push_back(Ty);
3799 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00003800 if (I->Attrs != ParamAttr::None) {
3801 ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs;
3802 Attrs.push_back(X);
3803 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00003804 }
3805 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3806 if (isVarArg) Params.pop_back();
3807
Reid Spencer7b5d4662007-04-09 06:16:21 +00003808 ParamAttrsList *ActualAttrs = 0;
3809 if (!Attrs.empty())
Christopher Lamb5c104242007-04-22 20:09:11 +00003810 ActualAttrs = ParamAttrsList::get(Attrs);
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003811 FunctionType *FT = FunctionType::get(*(yyvsp[(1) - (5)].TypeVal), Params, isVarArg, ActualAttrs);
3812 delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list
3813 delete (yyvsp[(1) - (5)].TypeVal); // Delete the return type handle
3814 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencere4d87aa2006-12-23 06:05:41 +00003815 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003816 ;}
3817 break;
3818
3819 case 130:
3820#line 1340 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3821 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003822 std::vector<const Type*> Params;
Christopher Lamb5c104242007-04-22 20:09:11 +00003823 ParamAttrsVector Attrs;
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003824 if ((yyvsp[(5) - (5)].ParamAttrs) != ParamAttr::None) {
3825 ParamAttrsWithIndex X; X.index = 0; X.attrs = (yyvsp[(5) - (5)].ParamAttrs);
Christopher Lamb5c104242007-04-22 20:09:11 +00003826 Attrs.push_back(X);
3827 }
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003828 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00003829 unsigned index = 1;
3830 for ( ; I != E; ++I, ++index) {
Reid Spencer66728ef2007-03-20 01:13:36 +00003831 const Type* Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00003832 Params.push_back(Ty);
3833 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00003834 if (I->Attrs != ParamAttr::None) {
3835 ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs;
3836 Attrs.push_back(X);
3837 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003838 }
3839 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3840 if (isVarArg) Params.pop_back();
3841
Reid Spencer7b5d4662007-04-09 06:16:21 +00003842 ParamAttrsList *ActualAttrs = 0;
3843 if (!Attrs.empty())
Christopher Lamb5c104242007-04-22 20:09:11 +00003844 ActualAttrs = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00003845
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003846 FunctionType *FT = FunctionType::get((yyvsp[(1) - (5)].PrimType), Params, isVarArg, ActualAttrs);
3847 delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list
3848 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003849 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003850 ;}
3851 break;
3852
3853 case 131:
3854#line 1371 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3855 { // Sized array type?
3856 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
3857 delete (yyvsp[(4) - (5)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003858 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003859 ;}
3860 break;
3861
3862 case 132:
3863#line 1376 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3864 { // Vector type?
3865 const llvm::Type* ElemTy = (yyvsp[(4) - (5)].TypeVal)->get();
3866 if ((unsigned)(yyvsp[(2) - (5)].UInt64Val) != (yyvsp[(2) - (5)].UInt64Val))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003867 GEN_ERROR("Unsigned result not equal to signed result");
3868 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
Reid Spencer9d6565a2007-02-15 02:26:10 +00003869 GEN_ERROR("Element type of a VectorType must be primitive");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003870 if (!isPowerOf2_32((yyvsp[(2) - (5)].UInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00003871 GEN_ERROR("Vector length should be a power of 2");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003872 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(VectorType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
3873 delete (yyvsp[(4) - (5)].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003874 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003875 ;}
3876 break;
3877
3878 case 133:
3879#line 1388 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3880 { // Structure type?
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003881 std::vector<const Type*> Elements;
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003882 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(2) - (3)].TypeList)->begin(),
3883 E = (yyvsp[(2) - (3)].TypeList)->end(); I != E; ++I)
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003884 Elements.push_back(*I);
3885
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003886 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
3887 delete (yyvsp[(2) - (3)].TypeList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003888 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003889 ;}
3890 break;
3891
3892 case 134:
3893#line 1398 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3894 { // Empty structure type?
3895 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer14310612006-12-31 05:40:51 +00003896 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003897 ;}
3898 break;
3899
3900 case 135:
3901#line 1402 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3902 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003903 std::vector<const Type*> Elements;
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003904 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(3) - (5)].TypeList)->begin(),
3905 E = (yyvsp[(3) - (5)].TypeList)->end(); I != E; ++I)
Reid Spencer41dff5e2007-01-26 08:05:27 +00003906 Elements.push_back(*I);
3907
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003908 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
3909 delete (yyvsp[(3) - (5)].TypeList);
Reid Spencer14310612006-12-31 05:40:51 +00003910 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003911 ;}
3912 break;
3913
3914 case 136:
3915#line 1412 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3916 { // Empty structure type?
3917 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003918 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003919 ;}
3920 break;
3921
3922 case 137:
3923#line 1419 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3924 {
3925 (yyval.TypeWithAttrs).Ty = (yyvsp[(1) - (2)].TypeVal);
3926 (yyval.TypeWithAttrs).Attrs = (yyvsp[(2) - (2)].ParamAttrs);
3927 ;}
3928 break;
3929
3930 case 138:
3931#line 1426 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3932 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003933 if (!UpRefs.empty())
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003934 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (1)].TypeVal))->getDescription());
3935 if (!(*(yyvsp[(1) - (1)].TypeVal))->isFirstClassType())
Reid Spencerb5334b02007-02-05 10:18:06 +00003936 GEN_ERROR("LLVM functions cannot return aggregate types");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003937 (yyval.TypeVal) = (yyvsp[(1) - (1)].TypeVal);
3938 ;}
3939 break;
3940
3941 case 139:
3942#line 1433 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3943 {
3944 (yyval.TypeVal) = new PATypeHolder(Type::VoidTy);
3945 ;}
3946 break;
3947
3948 case 140:
3949#line 1438 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3950 {
3951 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
3952 (yyval.TypeWithAttrsList)->push_back((yyvsp[(1) - (1)].TypeWithAttrs));
Reid Spencer6f407902007-01-13 05:00:46 +00003953 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003954 ;}
3955 break;
3956
3957 case 141:
3958#line 1443 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3959 {
3960 ((yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList))->push_back((yyvsp[(3) - (3)].TypeWithAttrs));
Reid Spencer3da59db2006-11-27 01:05:10 +00003961 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003962 ;}
3963 break;
3964
3965 case 143:
3966#line 1451 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3967 {
3968 (yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList);
Reid Spencer18da0722007-04-11 02:44:20 +00003969 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003970 TWA.Ty = new PATypeHolder(Type::VoidTy);
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003971 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003972 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003973 ;}
3974 break;
3975
3976 case 144:
3977#line 1458 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3978 {
3979 (yyval.TypeWithAttrsList) = new TypeWithAttrsList;
Reid Spencer18da0722007-04-11 02:44:20 +00003980 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003981 TWA.Ty = new PATypeHolder(Type::VoidTy);
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003982 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003983 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003984 ;}
3985 break;
3986
3987 case 145:
3988#line 1465 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3989 {
3990 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
Reid Spencer41dff5e2007-01-26 08:05:27 +00003991 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003992 ;}
3993 break;
3994
3995 case 146:
3996#line 1473 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3997 {
3998 (yyval.TypeList) = new std::list<PATypeHolder>();
3999 (yyval.TypeList)->push_back(*(yyvsp[(1) - (1)].TypeVal));
4000 delete (yyvsp[(1) - (1)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004001 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004002 ;}
4003 break;
4004
4005 case 147:
4006#line 1479 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4007 {
4008 ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back(*(yyvsp[(3) - (3)].TypeVal));
4009 delete (yyvsp[(3) - (3)].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00004010 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004011 ;}
4012 break;
4013
4014 case 148:
4015#line 1491 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4016 { // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00004017 if (!UpRefs.empty())
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004018 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4019 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (4)].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004020 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00004021 GEN_ERROR("Cannot make array constant with type: '" +
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004022 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004023 const Type *ETy = ATy->getElementType();
4024 int NumElements = ATy->getNumElements();
4025
4026 // Verify that we have the correct size...
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004027 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004028 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004029 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00004030 itostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004031
4032 // Verify all elements are correct type!
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004033 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4034 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004035 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
4036 ETy->getDescription() +"' as required!\nIt is of type '"+
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004037 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004038 }
4039
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004040 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[(3) - (4)].ConstVector));
4041 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004042 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004043 ;}
4044 break;
4045
4046 case 149:
4047#line 1519 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4048 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004049 if (!UpRefs.empty())
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004050 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4051 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004052 if (ATy == 0)
4053 GEN_ERROR("Cannot make array constant with type: '" +
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004054 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004055
Andrew Lenharth6353e052006-12-08 18:07:09 +00004056 int NumElements = ATy->getNumElements();
4057 if (NumElements != -1 && NumElements != 0)
4058 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Reid Spencerb5334b02007-02-05 10:18:06 +00004059 " arguments, but has size of " + itostr(NumElements) +"");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004060 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
4061 delete (yyvsp[(1) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004062 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004063 ;}
4064 break;
4065
4066 case 150:
4067#line 1535 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4068 {
Reid Spencer14310612006-12-31 05:40:51 +00004069 if (!UpRefs.empty())
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004070 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4071 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004072 if (ATy == 0)
4073 GEN_ERROR("Cannot make array constant with type: '" +
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004074 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Reid Spencer61c83e02006-08-18 08:43:06 +00004075
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004076 int NumElements = ATy->getNumElements();
4077 const Type *ETy = ATy->getElementType();
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004078 char *EndStr = UnEscapeLexed((yyvsp[(3) - (3)].StrVal), true);
4079 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[(3) - (3)].StrVal)))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004080 GEN_ERROR("Can't build string constant of size " +
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004081 itostr((int)(EndStr-(yyvsp[(3) - (3)].StrVal))) +
Reid Spencerb5334b02007-02-05 10:18:06 +00004082 " when array has size " + itostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004083 std::vector<Constant*> Vals;
4084 if (ETy == Type::Int8Ty) {
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004085 for (unsigned char *C = (unsigned char *)(yyvsp[(3) - (3)].StrVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004086 C != (unsigned char*)EndStr; ++C)
4087 Vals.push_back(ConstantInt::get(ETy, *C));
4088 } else {
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004089 free((yyvsp[(3) - (3)].StrVal));
Reid Spencerb5334b02007-02-05 10:18:06 +00004090 GEN_ERROR("Cannot build string arrays of non byte sized elements");
Andrew Lenharth6353e052006-12-08 18:07:09 +00004091 }
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004092 free((yyvsp[(3) - (3)].StrVal));
4093 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
4094 delete (yyvsp[(1) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004095 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004096 ;}
4097 break;
4098
4099 case 151:
4100#line 1564 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4101 { // Nonempty unsized arr
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004102 if (!UpRefs.empty())
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004103 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4104 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[(1) - (4)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004105 if (PTy == 0)
4106 GEN_ERROR("Cannot make packed constant with type: '" +
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004107 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004108 const Type *ETy = PTy->getElementType();
4109 int NumElements = PTy->getNumElements();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004110
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004111 // Verify that we have the correct size...
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004112 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004113 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004114 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00004115 itostr(NumElements) + "");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004116
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004117 // Verify all elements are correct type!
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004118 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4119 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004120 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
4121 ETy->getDescription() +"' as required!\nIt is of type '"+
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004122 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004123 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00004124
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004125 (yyval.ConstVal) = ConstantVector::get(PTy, *(yyvsp[(3) - (4)].ConstVector));
4126 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004127 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004128 ;}
4129 break;
4130
4131 case 152:
4132#line 1592 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4133 {
4134 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (4)].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004135 if (STy == 0)
4136 GEN_ERROR("Cannot make struct constant with type: '" +
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004137 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004138
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004139 if ((yyvsp[(3) - (4)].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00004140 GEN_ERROR("Illegal number of initializers for structure type");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004141
4142 // Check to ensure that constants are compatible with the type initializer!
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004143 for (unsigned i = 0, e = (yyvsp[(3) - (4)].ConstVector)->size(); i != e; ++i)
4144 if ((*(yyvsp[(3) - (4)].ConstVector))[i]->getType() != STy->getElementType(i))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004145 GEN_ERROR("Expected type '" +
4146 STy->getElementType(i)->getDescription() +
4147 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00004148 " of structure initializer");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004149
4150 // Check to ensure that Type is not packed
4151 if (STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00004152 GEN_ERROR("Unpacked Initializer to vector type '" + STy->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004153
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004154 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(3) - (4)].ConstVector));
4155 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004156 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004157 ;}
4158 break;
4159
4160 case 153:
4161#line 1617 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4162 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004163 if (!UpRefs.empty())
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004164 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4165 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004166 if (STy == 0)
4167 GEN_ERROR("Cannot make struct constant with type: '" +
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004168 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004169
4170 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004171 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004172
4173 // Check to ensure that Type is not packed
4174 if (STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00004175 GEN_ERROR("Unpacked Initializer to vector type '" + STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004176
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004177 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4178 delete (yyvsp[(1) - (3)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004179 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004180 ;}
4181 break;
4182
4183 case 154:
4184#line 1636 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4185 {
4186 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (6)].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004187 if (STy == 0)
4188 GEN_ERROR("Cannot make struct constant with type: '" +
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004189 (*(yyvsp[(1) - (6)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004190
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004191 if ((yyvsp[(4) - (6)].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00004192 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004193
4194 // Check to ensure that constants are compatible with the type initializer!
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004195 for (unsigned i = 0, e = (yyvsp[(4) - (6)].ConstVector)->size(); i != e; ++i)
4196 if ((*(yyvsp[(4) - (6)].ConstVector))[i]->getType() != STy->getElementType(i))
Reid Spencer41dff5e2007-01-26 08:05:27 +00004197 GEN_ERROR("Expected type '" +
4198 STy->getElementType(i)->getDescription() +
4199 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00004200 " of structure initializer");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004201
4202 // Check to ensure that Type is packed
4203 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00004204 GEN_ERROR("Vector initializer to non-vector type '" +
4205 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004206
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004207 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(4) - (6)].ConstVector));
4208 delete (yyvsp[(1) - (6)].TypeVal); delete (yyvsp[(4) - (6)].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004209 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004210 ;}
4211 break;
4212
4213 case 155:
4214#line 1662 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4215 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004216 if (!UpRefs.empty())
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004217 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (5)].TypeVal))->getDescription());
4218 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (5)].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004219 if (STy == 0)
4220 GEN_ERROR("Cannot make struct constant with type: '" +
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004221 (*(yyvsp[(1) - (5)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004222
4223 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004224 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004225
4226 // Check to ensure that Type is packed
4227 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00004228 GEN_ERROR("Vector initializer to non-vector type '" +
4229 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004230
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004231 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4232 delete (yyvsp[(1) - (5)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004233 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004234 ;}
4235 break;
4236
4237 case 156:
4238#line 1682 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4239 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004240 if (!UpRefs.empty())
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004241 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4242 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004243 if (PTy == 0)
4244 GEN_ERROR("Cannot make null pointer constant with type: '" +
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004245 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004246
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004247 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
4248 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004249 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004250 ;}
4251 break;
4252
4253 case 157:
4254#line 1694 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4255 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004256 if (!UpRefs.empty())
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004257 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4258 (yyval.ConstVal) = UndefValue::get((yyvsp[(1) - (2)].TypeVal)->get());
4259 delete (yyvsp[(1) - (2)].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004260 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004261 ;}
4262 break;
4263
4264 case 158:
4265#line 1701 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4266 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004267 if (!UpRefs.empty())
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004268 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4269 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004270 if (Ty == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004271 GEN_ERROR("Global const reference must be a pointer type");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004272
4273 // ConstExprs can exist in the body of a function, thus creating
4274 // GlobalValues whenever they refer to a variable. Because we are in
Reid Spencer93c40032007-03-19 18:40:50 +00004275 // the context of a function, getExistingVal will search the functions
Reid Spencer68a24bd2005-08-27 18:50:39 +00004276 // symbol table instead of the module symbol table for the global symbol,
4277 // which throws things all off. To get around this, we just tell
Reid Spencer93c40032007-03-19 18:40:50 +00004278 // getExistingVal that we are at global scope here.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004279 //
4280 Function *SavedCurFn = CurFun.CurrentFunction;
4281 CurFun.CurrentFunction = 0;
4282
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004283 Value *V = getExistingVal(Ty, (yyvsp[(2) - (2)].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004284 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004285
4286 CurFun.CurrentFunction = SavedCurFn;
4287
4288 // If this is an initializer for a constant pointer, which is referencing a
4289 // (currently) undefined variable, create a stub now that shall be replaced
4290 // in the future with the right type of variable.
4291 //
4292 if (V == 0) {
Reid Spencera9720f52007-02-05 17:04:00 +00004293 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004294 const PointerType *PT = cast<PointerType>(Ty);
4295
4296 // First check to see if the forward references value is already created!
4297 PerModuleInfo::GlobalRefsType::iterator I =
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004298 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004299
4300 if (I != CurModule.GlobalRefs.end()) {
4301 V = I->second; // Placeholder already exists, use it...
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004302 (yyvsp[(2) - (2)].ValIDVal).destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004303 } else {
4304 std::string Name;
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004305 if ((yyvsp[(2) - (2)].ValIDVal).Type == ValID::GlobalName)
4306 Name = (yyvsp[(2) - (2)].ValIDVal).Name;
4307 else if ((yyvsp[(2) - (2)].ValIDVal).Type != ValID::GlobalID)
Reid Spencer41dff5e2007-01-26 08:05:27 +00004308 GEN_ERROR("Invalid reference to global");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004309
4310 // Create the forward referenced global.
4311 GlobalValue *GV;
4312 if (const FunctionType *FTy =
4313 dyn_cast<FunctionType>(PT->getElementType())) {
4314 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
4315 CurModule.CurrentModule);
4316 } else {
4317 GV = new GlobalVariable(PT->getElementType(), false,
4318 GlobalValue::ExternalLinkage, 0,
4319 Name, CurModule.CurrentModule);
4320 }
4321
4322 // Keep track of the fact that we have a forward ref to recycle it
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004323 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004324 V = GV;
4325 }
4326 }
4327
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004328 (yyval.ConstVal) = cast<GlobalValue>(V);
4329 delete (yyvsp[(1) - (2)].TypeVal); // Free the type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00004330 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004331 ;}
4332 break;
4333
4334 case 159:
4335#line 1767 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4336 {
Reid Spencer14310612006-12-31 05:40:51 +00004337 if (!UpRefs.empty())
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004338 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4339 if ((yyvsp[(1) - (2)].TypeVal)->get() != (yyvsp[(2) - (2)].ConstVal)->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004340 GEN_ERROR("Mismatched types for constant expression: " +
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004341 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + " and " + (yyvsp[(2) - (2)].ConstVal)->getType()->getDescription());
4342 (yyval.ConstVal) = (yyvsp[(2) - (2)].ConstVal);
4343 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004344 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004345 ;}
4346 break;
4347
4348 case 160:
4349#line 1777 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4350 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004351 if (!UpRefs.empty())
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004352 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4353 const Type *Ty = (yyvsp[(1) - (2)].TypeVal)->get();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004354 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
Reid Spencerb5334b02007-02-05 10:18:06 +00004355 GEN_ERROR("Cannot create a null initialized value of this type");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004356 (yyval.ConstVal) = Constant::getNullValue(Ty);
4357 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004358 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004359 ;}
4360 break;
4361
4362 case 161:
4363#line 1787 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4364 { // integral constants
4365 if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004366 GEN_ERROR("Constant value doesn't fit in type");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004367 (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val), true);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004368 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004369 ;}
4370 break;
4371
4372 case 162:
4373#line 1793 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4374 { // arbitrary precision integer constants
4375 uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth();
4376 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) {
Reid Spencer38c91a92007-02-28 02:24:54 +00004377 GEN_ERROR("Constant value does not fit in type");
Reid Spencer10794272007-03-01 19:41:47 +00004378 }
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004379 (yyvsp[(2) - (2)].APIntVal)->sextOrTrunc(BitWidth);
4380 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4381 delete (yyvsp[(2) - (2)].APIntVal);
Reid Spencer38c91a92007-02-28 02:24:54 +00004382 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004383 ;}
4384 break;
4385
4386 case 163:
4387#line 1803 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4388 { // integral constants
4389 if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004390 GEN_ERROR("Constant value doesn't fit in type");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004391 (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val), false);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004392 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004393 ;}
4394 break;
4395
4396 case 164:
4397#line 1809 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4398 { // arbitrary precision integer constants
4399 uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth();
4400 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) {
Reid Spencer38c91a92007-02-28 02:24:54 +00004401 GEN_ERROR("Constant value does not fit in type");
Reid Spencer10794272007-03-01 19:41:47 +00004402 }
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004403 (yyvsp[(2) - (2)].APIntVal)->zextOrTrunc(BitWidth);
4404 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4405 delete (yyvsp[(2) - (2)].APIntVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004406 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004407 ;}
4408 break;
4409
4410 case 165:
4411#line 1819 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4412 { // Boolean constants
4413 assert(cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() == 1 && "Not Bool?");
4414 (yyval.ConstVal) = ConstantInt::getTrue();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004415 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004416 ;}
4417 break;
4418
4419 case 166:
4420#line 1824 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4421 { // Boolean constants
4422 assert(cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() == 1 && "Not Bool?");
4423 (yyval.ConstVal) = ConstantInt::getFalse();
Reid Spencer38c91a92007-02-28 02:24:54 +00004424 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004425 ;}
4426 break;
4427
4428 case 167:
4429#line 1829 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4430 { // Float & Double constants
4431 if (!ConstantFP::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].FPVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004432 GEN_ERROR("Floating point constant invalid for type");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004433 (yyval.ConstVal) = ConstantFP::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].FPVal));
Reid Spencer6f407902007-01-13 05:00:46 +00004434 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004435 ;}
4436 break;
4437
4438 case 168:
4439#line 1837 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4440 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004441 if (!UpRefs.empty())
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004442 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (6)].TypeVal))->getDescription());
4443 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
4444 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
4445 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004446 GEN_ERROR("invalid cast opcode for cast from '" +
4447 Val->getType()->getDescription() + "' to '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00004448 DestTy->getDescription() + "'");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004449 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
4450 delete (yyvsp[(5) - (6)].TypeVal);
4451 ;}
4452 break;
4453
4454 case 169:
4455#line 1849 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4456 {
4457 if (!isa<PointerType>((yyvsp[(3) - (5)].ConstVal)->getType()))
Reid Spencerb5334b02007-02-05 10:18:06 +00004458 GEN_ERROR("GetElementPtr requires a pointer operand");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004459
4460 const Type *IdxTy =
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004461 GetElementPtrInst::getIndexedType((yyvsp[(3) - (5)].ConstVal)->getType(), &(*(yyvsp[(4) - (5)].ValueList))[0], (yyvsp[(4) - (5)].ValueList)->size(),
Chris Lattner7d9801d2007-02-13 00:58:01 +00004462 true);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004463 if (!IdxTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00004464 GEN_ERROR("Index list invalid for constant getelementptr");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004465
Chris Lattnerf7469af2007-01-31 04:44:08 +00004466 SmallVector<Constant*, 8> IdxVec;
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004467 for (unsigned i = 0, e = (yyvsp[(4) - (5)].ValueList)->size(); i != e; ++i)
4468 if (Constant *C = dyn_cast<Constant>((*(yyvsp[(4) - (5)].ValueList))[i]))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004469 IdxVec.push_back(C);
4470 else
Reid Spencerb5334b02007-02-05 10:18:06 +00004471 GEN_ERROR("Indices to constant getelementptr must be constants");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004472
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004473 delete (yyvsp[(4) - (5)].ValueList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004474
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004475 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[(3) - (5)].ConstVal), &IdxVec[0], IdxVec.size());
Andrew Lenharth6353e052006-12-08 18:07:09 +00004476 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004477 ;}
4478 break;
4479
4480 case 170:
4481#line 1871 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4482 {
4483 if ((yyvsp[(3) - (8)].ConstVal)->getType() != Type::Int1Ty)
Reid Spencerb5334b02007-02-05 10:18:06 +00004484 GEN_ERROR("Select condition must be of boolean type");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004485 if ((yyvsp[(5) - (8)].ConstVal)->getType() != (yyvsp[(7) - (8)].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004486 GEN_ERROR("Select operand types must match");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004487 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004488 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004489 ;}
4490 break;
4491
4492 case 171:
4493#line 1879 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4494 {
4495 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004496 GEN_ERROR("Binary operator types must match");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004497 CHECK_FOR_ERROR;
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004498 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
4499 ;}
4500 break;
4501
4502 case 172:
4503#line 1885 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4504 {
4505 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004506 GEN_ERROR("Logical operator types must match");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004507 if (!(yyvsp[(3) - (6)].ConstVal)->getType()->isInteger()) {
4508 if (Instruction::isShift((yyvsp[(1) - (6)].BinaryOpVal)) || !isa<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType()) ||
4509 !cast<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType())->getElementType()->isInteger())
Reid Spencerb5334b02007-02-05 10:18:06 +00004510 GEN_ERROR("Logical operator requires integral operands");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004511 }
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004512 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004513 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004514 ;}
4515 break;
4516
4517 case 173:
4518#line 1896 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4519 {
4520 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004521 GEN_ERROR("icmp operand types must match");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004522 (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[(2) - (7)].IPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
4523 ;}
4524 break;
4525
4526 case 174:
4527#line 1901 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4528 {
4529 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004530 GEN_ERROR("fcmp operand types must match");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004531 (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[(2) - (7)].FPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
4532 ;}
4533 break;
4534
4535 case 175:
4536#line 1906 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4537 {
4538 if (!ExtractElementInst::isValidOperands((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004539 GEN_ERROR("Invalid extractelement operands");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004540 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004541 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004542 ;}
4543 break;
4544
4545 case 176:
4546#line 1912 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4547 {
4548 if (!InsertElementInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004549 GEN_ERROR("Invalid insertelement operands");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004550 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004551 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004552 ;}
4553 break;
4554
4555 case 177:
4556#line 1918 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4557 {
4558 if (!ShuffleVectorInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004559 GEN_ERROR("Invalid shufflevector operands");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004560 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004561 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004562 ;}
4563 break;
4564
4565 case 178:
4566#line 1927 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4567 {
4568 ((yyval.ConstVector) = (yyvsp[(1) - (3)].ConstVector))->push_back((yyvsp[(3) - (3)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004569 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004570 ;}
4571 break;
4572
4573 case 179:
4574#line 1931 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4575 {
4576 (yyval.ConstVector) = new std::vector<Constant*>();
4577 (yyval.ConstVector)->push_back((yyvsp[(1) - (1)].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004578 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004579 ;}
4580 break;
4581
4582 case 180:
4583#line 1939 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4584 { (yyval.BoolVal) = false; ;}
4585 break;
4586
4587 case 181:
4588#line 1939 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4589 { (yyval.BoolVal) = true; ;}
4590 break;
4591
4592 case 182:
4593#line 1942 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4594 { (yyval.BoolVal) = true; ;}
4595 break;
4596
4597 case 183:
4598#line 1942 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4599 { (yyval.BoolVal) = false; ;}
4600 break;
4601
4602 case 184:
4603#line 1953 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4604 {
4605 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Reid Spencer67d8ed92007-03-22 02:14:08 +00004606 CurModule.ModuleDone();
4607 CHECK_FOR_ERROR;
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004608 ;}
4609 break;
4610
4611 case 185:
4612#line 1958 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4613 {
4614 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004615 CurModule.ModuleDone();
4616 CHECK_FOR_ERROR;
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004617 ;}
4618 break;
4619
4620 case 188:
4621#line 1971 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4622 { CurFun.isDeclare = false; ;}
4623 break;
4624
4625 case 189:
4626#line 1971 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4627 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004628 CurFun.FunctionDone();
4629 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004630 ;}
4631 break;
4632
4633 case 190:
4634#line 1975 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4635 { CurFun.isDeclare = true; ;}
4636 break;
4637
4638 case 191:
4639#line 1975 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4640 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004641 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004642 ;}
4643 break;
4644
4645 case 192:
4646#line 1978 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4647 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004648 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004649 ;}
4650 break;
4651
4652 case 193:
4653#line 1981 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4654 {
Reid Spencer14310612006-12-31 05:40:51 +00004655 if (!UpRefs.empty())
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004656 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (3)].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004657 // Eagerly resolve types. This is not an optimization, this is a
4658 // requirement that is due to the fact that we could have this:
4659 //
4660 // %list = type { %list * }
4661 // %list = type { %list * } ; repeated type decl
4662 //
4663 // If types are not resolved eagerly, then the two types will not be
4664 // determined to be the same type!
4665 //
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004666 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), *(yyvsp[(3) - (3)].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004667
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004668 if (!setTypeName(*(yyvsp[(3) - (3)].TypeVal), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00004669 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004670 // If this is a named type that is not a redefinition, add it to the slot
4671 // table.
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004672 CurModule.Types.push_back(*(yyvsp[(3) - (3)].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004673 }
Reid Spencera132e042006-12-03 05:46:11 +00004674
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004675 delete (yyvsp[(3) - (3)].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004676 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004677 ;}
4678 break;
Reid Spencer38c91a92007-02-28 02:24:54 +00004679
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004680 case 194:
4681#line 2005 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4682 {
4683 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), (yyvsp[(3) - (3)].PrimType));
4684
4685 if (!setTypeName((yyvsp[(3) - (3)].PrimType), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004686 CHECK_FOR_ERROR
4687 // If this is a named type that is not a redefinition, add it to the slot
4688 // table.
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004689 CurModule.Types.push_back((yyvsp[(3) - (3)].PrimType));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004690 }
4691 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004692 ;}
4693 break;
4694
4695 case 195:
4696#line 2016 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4697 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004698 /* "Externally Visible" Linkage */
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004699 if ((yyvsp[(5) - (5)].ConstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004700 GEN_ERROR("Global value initializer is not a constant");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004701 CurGV = ParseGlobalVariable((yyvsp[(1) - (5)].StrVal), GlobalValue::ExternalLinkage,
4702 (yyvsp[(2) - (5)].Visibility), (yyvsp[(4) - (5)].BoolVal), (yyvsp[(5) - (5)].ConstVal)->getType(), (yyvsp[(5) - (5)].ConstVal), (yyvsp[(3) - (5)].BoolVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004703 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004704 ;}
4705 break;
4706
4707 case 196:
4708#line 2023 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4709 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004710 CurGV = 0;
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004711 ;}
4712 break;
4713
4714 case 197:
4715#line 2026 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4716 {
4717 if ((yyvsp[(6) - (6)].ConstVal) == 0)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004718 GEN_ERROR("Global value initializer is not a constant");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004719 CurGV = ParseGlobalVariable((yyvsp[(1) - (6)].StrVal), (yyvsp[(2) - (6)].Linkage), (yyvsp[(3) - (6)].Visibility), (yyvsp[(5) - (6)].BoolVal), (yyvsp[(6) - (6)].ConstVal)->getType(), (yyvsp[(6) - (6)].ConstVal), (yyvsp[(4) - (6)].BoolVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004720 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004721 ;}
4722 break;
4723
4724 case 198:
4725#line 2031 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4726 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004727 CurGV = 0;
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004728 ;}
4729 break;
4730
4731 case 199:
4732#line 2034 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4733 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004734 if (!UpRefs.empty())
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004735 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(6) - (6)].TypeVal))->getDescription());
4736 CurGV = ParseGlobalVariable((yyvsp[(1) - (6)].StrVal), (yyvsp[(2) - (6)].Linkage), (yyvsp[(3) - (6)].Visibility), (yyvsp[(5) - (6)].BoolVal), *(yyvsp[(6) - (6)].TypeVal), 0, (yyvsp[(4) - (6)].BoolVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004737 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004738 delete (yyvsp[(6) - (6)].TypeVal);
4739 ;}
4740 break;
4741
4742 case 200:
4743#line 2040 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4744 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004745 CurGV = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004746 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004747 ;}
4748 break;
4749
4750 case 201:
4751#line 2044 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4752 {
4753 std::string Name((yyvsp[(1) - (6)].StrVal));
4754 if (Name.empty())
4755 GEN_ERROR("Alias name cannot be empty")
4756 const PointerType *PFTy = 0;
4757 const FunctionType *Ty = 0;
4758 Value* V = 0;
4759 const Type* VTy = 0;
4760 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(5) - (6)].TypeVal)->get())) ||
4761 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4762 VTy = (yyvsp[(5) - (6)].TypeVal)->get();
4763 V = getExistingVal(VTy, (yyvsp[(6) - (6)].ValIDVal));
4764 } else {
4765 VTy = PFTy;
4766 V = getExistingVal(PFTy, (yyvsp[(6) - (6)].ValIDVal));
4767 }
4768 if (V == 0)
4769 GEN_ERROR(std::string("Invalid aliasee for alias: ") + (yyvsp[(1) - (6)].StrVal));
4770 GlobalValue* Aliasee;
4771 if (Aliasee = dyn_cast<GlobalValue>(V)) {
4772 GlobalAlias* GA = new GlobalAlias(VTy, (yyvsp[(4) - (6)].Linkage), Name, Aliasee, CurModule.CurrentModule);
4773 GA->setVisibility((yyvsp[(2) - (6)].Visibility));
4774 InsertValue(GA, CurModule.Values);
4775 } else
4776 GEN_ERROR("Aliases can be created only to global values");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004777 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004778 delete (yyvsp[(5) - (6)].TypeVal);
4779 ;}
4780 break;
4781
4782 case 202:
4783#line 2072 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4784 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004785 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004786 ;}
4787 break;
4788
4789 case 203:
4790#line 2075 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4791 {
4792 CHECK_FOR_ERROR
4793 ;}
4794 break;
4795
4796 case 204:
4797#line 2081 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4798 {
Chris Lattner66316012006-01-24 04:14:29 +00004799 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004800 char *EndStr = UnEscapeLexed((yyvsp[(1) - (1)].StrVal), true);
4801 std::string NewAsm((yyvsp[(1) - (1)].StrVal), EndStr);
4802 free((yyvsp[(1) - (1)].StrVal));
Chris Lattner66316012006-01-24 04:14:29 +00004803
4804 if (AsmSoFar.empty())
4805 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
4806 else
4807 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Reid Spencer61c83e02006-08-18 08:43:06 +00004808 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004809;}
4810 break;
4811
4812 case 205:
4813#line 2094 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4814 {
4815 CurModule.CurrentModule->setTargetTriple((yyvsp[(3) - (3)].StrVal));
4816 free((yyvsp[(3) - (3)].StrVal));
4817 ;}
4818 break;
4819
4820 case 206:
4821#line 2098 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4822 {
4823 CurModule.CurrentModule->setDataLayout((yyvsp[(3) - (3)].StrVal));
4824 free((yyvsp[(3) - (3)].StrVal));
4825 ;}
4826 break;
4827
4828 case 208:
4829#line 2105 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4830 {
4831 CurModule.CurrentModule->addLibrary((yyvsp[(3) - (3)].StrVal));
4832 free((yyvsp[(3) - (3)].StrVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004833 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004834 ;}
4835 break;
4836
4837 case 209:
4838#line 2110 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4839 {
4840 CurModule.CurrentModule->addLibrary((yyvsp[(1) - (1)].StrVal));
4841 free((yyvsp[(1) - (1)].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004842 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004843 ;}
4844 break;
4845
4846 case 210:
4847#line 2115 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4848 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004849 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004850 ;}
4851 break;
4852
4853 case 211:
4854#line 2124 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4855 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004856 if (!UpRefs.empty())
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004857 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
4858 if (*(yyvsp[(3) - (5)].TypeVal) == Type::VoidTy)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004859 GEN_ERROR("void typed arguments are invalid");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004860 ArgListEntry E; E.Attrs = (yyvsp[(4) - (5)].ParamAttrs); E.Ty = (yyvsp[(3) - (5)].TypeVal); E.Name = (yyvsp[(5) - (5)].StrVal);
4861 (yyval.ArgList) = (yyvsp[(1) - (5)].ArgList);
4862 (yyvsp[(1) - (5)].ArgList)->push_back(E);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004863 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004864 ;}
4865 break;
4866
4867 case 212:
4868#line 2134 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4869 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004870 if (!UpRefs.empty())
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004871 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4872 if (*(yyvsp[(1) - (3)].TypeVal) == Type::VoidTy)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004873 GEN_ERROR("void typed arguments are invalid");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004874 ArgListEntry E; E.Attrs = (yyvsp[(2) - (3)].ParamAttrs); E.Ty = (yyvsp[(1) - (3)].TypeVal); E.Name = (yyvsp[(3) - (3)].StrVal);
4875 (yyval.ArgList) = new ArgListType;
4876 (yyval.ArgList)->push_back(E);
Reid Spencer6f407902007-01-13 05:00:46 +00004877 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004878 ;}
4879 break;
4880
4881 case 213:
4882#line 2145 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4883 {
4884 (yyval.ArgList) = (yyvsp[(1) - (1)].ArgList);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004885 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004886 ;}
4887 break;
4888
4889 case 214:
4890#line 2149 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4891 {
4892 (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004893 struct ArgListEntry E;
4894 E.Ty = new PATypeHolder(Type::VoidTy);
4895 E.Name = 0;
4896 E.Attrs = ParamAttr::None;
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004897 (yyval.ArgList)->push_back(E);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004898 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004899 ;}
4900 break;
4901
4902 case 215:
4903#line 2158 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4904 {
4905 (yyval.ArgList) = new ArgListType;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004906 struct ArgListEntry E;
4907 E.Ty = new PATypeHolder(Type::VoidTy);
4908 E.Name = 0;
Reid Spencer18da0722007-04-11 02:44:20 +00004909 E.Attrs = ParamAttr::None;
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004910 (yyval.ArgList)->push_back(E);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004911 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004912 ;}
4913 break;
4914
4915 case 216:
4916#line 2167 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4917 {
4918 (yyval.ArgList) = 0;
Reid Spencer61c83e02006-08-18 08:43:06 +00004919 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004920 ;}
4921 break;
4922
4923 case 217:
4924#line 2173 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4925 {
4926 UnEscapeLexed((yyvsp[(3) - (9)].StrVal));
4927 std::string FunctionName((yyvsp[(3) - (9)].StrVal));
4928 free((yyvsp[(3) - (9)].StrVal)); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004929
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004930 // Check the function result for abstractness if this is a define. We should
4931 // have no abstract types at this point
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004932 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[(2) - (9)].TypeVal)))
4933 GEN_ERROR("Reference to abstract result: "+ (yyvsp[(2) - (9)].TypeVal)->get()->getDescription());
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004934
Reid Spencer68a24bd2005-08-27 18:50:39 +00004935 std::vector<const Type*> ParamTypeList;
Christopher Lamb5c104242007-04-22 20:09:11 +00004936 ParamAttrsVector Attrs;
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004937 if ((yyvsp[(7) - (9)].ParamAttrs) != ParamAttr::None) {
4938 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = (yyvsp[(7) - (9)].ParamAttrs);
Christopher Lamb5c104242007-04-22 20:09:11 +00004939 Attrs.push_back(PAWI);
4940 }
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004941 if ((yyvsp[(5) - (9)].ArgList)) { // If there are arguments...
Reid Spencer7b5d4662007-04-09 06:16:21 +00004942 unsigned index = 1;
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004943 for (ArgListType::iterator I = (yyvsp[(5) - (9)].ArgList)->begin(); I != (yyvsp[(5) - (9)].ArgList)->end(); ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00004944 const Type* Ty = I->Ty->get();
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004945 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
4946 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00004947 ParamTypeList.push_back(Ty);
4948 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00004949 if (I->Attrs != ParamAttr::None) {
4950 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
4951 Attrs.push_back(PAWI);
4952 }
Reid Spencer14310612006-12-31 05:40:51 +00004953 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004954 }
4955
4956 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
4957 if (isVarArg) ParamTypeList.pop_back();
4958
Christopher Lamb5c104242007-04-22 20:09:11 +00004959 ParamAttrsList *PAL = 0;
4960 if (!Attrs.empty())
4961 PAL = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00004962
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004963 FunctionType *FT = FunctionType::get(*(yyvsp[(2) - (9)].TypeVal), ParamTypeList, isVarArg, PAL);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004964 const PointerType *PFT = PointerType::get(FT);
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004965 delete (yyvsp[(2) - (9)].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004966
4967 ValID ID;
4968 if (!FunctionName.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004969 ID = ValID::createGlobalName((char*)FunctionName.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004970 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00004971 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004972 }
4973
4974 Function *Fn = 0;
4975 // See if this function was forward referenced. If so, recycle the object.
4976 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4977 // Move the function to the end of the list, from whereever it was
4978 // previously inserted.
4979 Fn = cast<Function>(FWRef);
4980 CurModule.CurrentModule->getFunctionList().remove(Fn);
4981 CurModule.CurrentModule->getFunctionList().push_back(Fn);
4982 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
Reid Spenceref9b9a72007-02-05 20:47:22 +00004983 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
4984 if (Fn->getFunctionType() != FT ) {
4985 // The existing function doesn't have the same type. This is an overload
4986 // error.
4987 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
4988 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004989 // Neither the existing or the current function is a declaration and they
4990 // have the same name and same type. Clearly this is a redefinition.
4991 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +00004992 } if (Fn->isDeclaration()) {
4993 // Make sure to strip off any argument names so we can't get conflicts.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004994 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
4995 AI != AE; ++AI)
4996 AI->setName("");
Reid Spenceref9b9a72007-02-05 20:47:22 +00004997 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004998 } else { // Not already defined?
4999 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
5000 CurModule.CurrentModule);
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00005001
Reid Spencer68a24bd2005-08-27 18:50:39 +00005002 InsertValue(Fn, CurModule.Values);
5003 }
5004
5005 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00005006
5007 if (CurFun.isDeclare) {
5008 // If we have declaration, always overwrite linkage. This will allow us to
5009 // correctly handle cases, when pointer to function is passed as argument to
5010 // another function.
5011 Fn->setLinkage(CurFun.Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005012 Fn->setVisibility(CurFun.Visibility);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00005013 }
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005014 Fn->setCallingConv((yyvsp[(1) - (9)].UIntVal));
5015 Fn->setAlignment((yyvsp[(9) - (9)].UIntVal));
5016 if ((yyvsp[(8) - (9)].StrVal)) {
5017 Fn->setSection((yyvsp[(8) - (9)].StrVal));
5018 free((yyvsp[(8) - (9)].StrVal));
Chris Lattnere869eef2005-11-12 00:11:49 +00005019 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005020
5021 // Add all of the arguments we parsed to the function...
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005022 if ((yyvsp[(5) - (9)].ArgList)) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00005023 if (isVarArg) { // Nuke the last entry
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005024 assert((yyvsp[(5) - (9)].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[(5) - (9)].ArgList)->back().Name == 0 &&
Reid Spencera9720f52007-02-05 17:04:00 +00005025 "Not a varargs marker!");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005026 delete (yyvsp[(5) - (9)].ArgList)->back().Ty;
5027 (yyvsp[(5) - (9)].ArgList)->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00005028 }
5029 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00005030 Function::arg_iterator ArgEnd = Fn->arg_end();
Reid Spencer14310612006-12-31 05:40:51 +00005031 unsigned Idx = 1;
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005032 for (ArgListType::iterator I = (yyvsp[(5) - (9)].ArgList)->begin();
5033 I != (yyvsp[(5) - (9)].ArgList)->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencer14310612006-12-31 05:40:51 +00005034 delete I->Ty; // Delete the typeholder...
Reid Spenceref9b9a72007-02-05 20:47:22 +00005035 setValueName(ArgIt, I->Name); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00005036 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005037 InsertValue(ArgIt);
Reid Spencer14310612006-12-31 05:40:51 +00005038 Idx++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005039 }
Reid Spencera132e042006-12-03 05:46:11 +00005040
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005041 delete (yyvsp[(5) - (9)].ArgList); // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00005042 }
Reid Spencer61c83e02006-08-18 08:43:06 +00005043 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005044;}
5045 break;
5046
5047 case 220:
5048#line 2296 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5049 {
5050 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005051
5052 // Make sure that we keep track of the linkage type even if there was a
5053 // previous "declare".
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005054 (yyval.FunctionVal)->setLinkage((yyvsp[(1) - (4)].Linkage));
5055 (yyval.FunctionVal)->setVisibility((yyvsp[(2) - (4)].Visibility));
5056;}
5057 break;
5058
5059 case 223:
5060#line 2307 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5061 {
5062 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005063 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005064;}
5065 break;
5066
5067 case 224:
5068#line 2312 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5069 {
5070 CurFun.CurrentFunction->setLinkage((yyvsp[(1) - (3)].Linkage));
5071 CurFun.CurrentFunction->setVisibility((yyvsp[(2) - (3)].Visibility));
5072 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer41dff5e2007-01-26 08:05:27 +00005073 CurFun.FunctionDone();
5074 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005075 ;}
5076 break;
5077
5078 case 225:
5079#line 2324 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5080 {
5081 (yyval.BoolVal) = false;
Reid Spencer41dff5e2007-01-26 08:05:27 +00005082 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005083 ;}
5084 break;
5085
5086 case 226:
5087#line 2328 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5088 {
5089 (yyval.BoolVal) = true;
Reid Spencer61c83e02006-08-18 08:43:06 +00005090 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005091 ;}
5092 break;
5093
5094 case 227:
5095#line 2333 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5096 { // A reference to a direct constant
5097 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SInt64Val));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005098 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005099 ;}
5100 break;
5101
5102 case 228:
5103#line 2337 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5104 {
5105 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].UInt64Val));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005106 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005107 ;}
5108 break;
5109
5110 case 229:
5111#line 2341 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5112 { // Perhaps it's an FP constant?
5113 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].FPVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005114 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005115 ;}
5116 break;
5117
5118 case 230:
5119#line 2345 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5120 {
5121 (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue());
Reid Spencere4d87aa2006-12-23 06:05:41 +00005122 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005123 ;}
5124 break;
5125
5126 case 231:
5127#line 2349 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5128 {
5129 (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse());
Reid Spencere4d87aa2006-12-23 06:05:41 +00005130 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005131 ;}
5132 break;
5133
5134 case 232:
5135#line 2353 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5136 {
5137 (yyval.ValIDVal) = ValID::createNull();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005138 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005139 ;}
5140 break;
5141
5142 case 233:
5143#line 2357 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5144 {
5145 (yyval.ValIDVal) = ValID::createUndef();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005146 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005147 ;}
5148 break;
5149
5150 case 234:
5151#line 2361 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5152 { // A vector zero constant.
5153 (yyval.ValIDVal) = ValID::createZeroInit();
Reid Spencer61c83e02006-08-18 08:43:06 +00005154 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005155 ;}
5156 break;
5157
5158 case 235:
5159#line 2365 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5160 { // Nonempty unsized packed vector
5161 const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0]->getType();
5162 int NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005163
Reid Spencer9d6565a2007-02-15 02:26:10 +00005164 VectorType* pt = VectorType::get(ETy, NumElements);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005165 PATypeHolder* PTy = new PATypeHolder(
Reid Spencera132e042006-12-03 05:46:11 +00005166 HandleUpRefs(
Reid Spencer9d6565a2007-02-15 02:26:10 +00005167 VectorType::get(
Reid Spencera132e042006-12-03 05:46:11 +00005168 ETy,
5169 NumElements)
5170 )
5171 );
Reid Spencer68a24bd2005-08-27 18:50:39 +00005172
5173 // Verify all elements are correct type!
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005174 for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
5175 if (ETy != (*(yyvsp[(2) - (3)].ConstVector))[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00005176 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00005177 ETy->getDescription() +"' as required!\nIt is of type '" +
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005178 (*(yyvsp[(2) - (3)].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005179 }
5180
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005181 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, *(yyvsp[(2) - (3)].ConstVector)));
5182 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
Reid Spencer832254e2007-02-02 02:16:23 +00005183 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005184 ;}
5185 break;
5186
5187 case 236:
5188#line 2390 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5189 {
5190 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].ConstVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005191 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005192 ;}
5193 break;
5194
5195 case 237:
5196#line 2394 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5197 {
5198 char *End = UnEscapeLexed((yyvsp[(3) - (5)].StrVal), true);
5199 std::string AsmStr = std::string((yyvsp[(3) - (5)].StrVal), End);
5200 End = UnEscapeLexed((yyvsp[(5) - (5)].StrVal), true);
5201 std::string Constraints = std::string((yyvsp[(5) - (5)].StrVal), End);
5202 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[(2) - (5)].BoolVal));
5203 free((yyvsp[(3) - (5)].StrVal));
5204 free((yyvsp[(5) - (5)].StrVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005205 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005206 ;}
5207 break;
5208
5209 case 238:
5210#line 2408 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5211 { // Is it an integer reference...?
5212 (yyval.ValIDVal) = ValID::createLocalID((yyvsp[(1) - (1)].UIntVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005213 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005214 ;}
5215 break;
5216
5217 case 239:
5218#line 2412 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5219 {
5220 (yyval.ValIDVal) = ValID::createGlobalID((yyvsp[(1) - (1)].UIntVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005221 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005222 ;}
5223 break;
5224
5225 case 240:
5226#line 2416 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5227 { // Is it a named reference...?
5228 (yyval.ValIDVal) = ValID::createLocalName((yyvsp[(1) - (1)].StrVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005229 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005230 ;}
5231 break;
5232
5233 case 241:
5234#line 2420 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5235 { // Is it a named reference...?
5236 (yyval.ValIDVal) = ValID::createGlobalName((yyvsp[(1) - (1)].StrVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005237 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005238 ;}
5239 break;
5240
5241 case 244:
5242#line 2432 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5243 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005244 if (!UpRefs.empty())
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005245 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
5246 (yyval.ValueVal) = getVal(*(yyvsp[(1) - (2)].TypeVal), (yyvsp[(2) - (2)].ValIDVal));
5247 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005248 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005249 ;}
5250 break;
5251
5252 case 245:
5253#line 2441 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5254 {
5255 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005256 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005257 ;}
5258 break;
5259
5260 case 246:
5261#line 2445 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5262 { // Do not allow functions with 0 basic blocks
5263 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005264 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005265 ;}
5266 break;
5267
5268 case 247:
5269#line 2454 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5270 {
5271 setValueName((yyvsp[(3) - (3)].TermInstVal), (yyvsp[(2) - (3)].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005272 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005273 InsertValue((yyvsp[(3) - (3)].TermInstVal));
5274 (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal));
5275 (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005276 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005277 ;}
5278 break;
5279
5280 case 248:
5281#line 2463 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5282 {
5283 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[(2) - (2)].InstVal)))
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005284 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
5285 if (CI2->getParent() == 0)
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005286 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back(CI2);
5287 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back((yyvsp[(2) - (2)].InstVal));
5288 (yyval.BasicBlockVal) = (yyvsp[(1) - (2)].BasicBlockVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005289 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005290 ;}
5291 break;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005292
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005293 case 249:
5294#line 2472 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5295 { // Empty space between instruction lists
5296 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
5297 CHECK_FOR_ERROR
5298 ;}
5299 break;
5300
5301 case 250:
5302#line 2476 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5303 { // Labelled (named) basic block
5304 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName((yyvsp[(1) - (1)].StrVal)));
5305 CHECK_FOR_ERROR
5306 ;}
5307 break;
5308
5309 case 251:
5310#line 2481 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5311 { // Return with a result...
5312 (yyval.TermInstVal) = new ReturnInst((yyvsp[(2) - (2)].ValueVal));
5313 CHECK_FOR_ERROR
5314 ;}
5315 break;
5316
5317 case 252:
5318#line 2485 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5319 { // Return with no result...
5320 (yyval.TermInstVal) = new ReturnInst();
5321 CHECK_FOR_ERROR
5322 ;}
5323 break;
5324
5325 case 253:
5326#line 2489 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5327 { // Unconditional Branch...
5328 BasicBlock* tmpBB = getBBVal((yyvsp[(3) - (3)].ValIDVal));
5329 CHECK_FOR_ERROR
5330 (yyval.TermInstVal) = new BranchInst(tmpBB);
5331 ;}
5332 break;
5333
5334 case 254:
5335#line 2494 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5336 {
5337 assert(cast<IntegerType>((yyvsp[(2) - (9)].PrimType))->getBitWidth() == 1 && "Not Bool?");
5338 BasicBlock* tmpBBA = getBBVal((yyvsp[(6) - (9)].ValIDVal));
5339 CHECK_FOR_ERROR
5340 BasicBlock* tmpBBB = getBBVal((yyvsp[(9) - (9)].ValIDVal));
5341 CHECK_FOR_ERROR
5342 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[(3) - (9)].ValIDVal));
5343 CHECK_FOR_ERROR
5344 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5345 ;}
5346 break;
5347
5348 case 255:
5349#line 2504 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5350 {
5351 Value* tmpVal = getVal((yyvsp[(2) - (9)].PrimType), (yyvsp[(3) - (9)].ValIDVal));
5352 CHECK_FOR_ERROR
5353 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (9)].ValIDVal));
5354 CHECK_FOR_ERROR
5355 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[(8) - (9)].JumpTable)->size());
5356 (yyval.TermInstVal) = S;
5357
5358 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[(8) - (9)].JumpTable)->begin(),
5359 E = (yyvsp[(8) - (9)].JumpTable)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005360 for (; I != E; ++I) {
5361 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5362 S->addCase(CI, I->second);
5363 else
Reid Spencerb5334b02007-02-05 10:18:06 +00005364 GEN_ERROR("Switch case is constant, but not a simple integer");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005365 }
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005366 delete (yyvsp[(8) - (9)].JumpTable);
Reid Spencer61c83e02006-08-18 08:43:06 +00005367 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005368 ;}
5369 break;
5370
5371 case 256:
5372#line 2523 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5373 {
5374 Value* tmpVal = getVal((yyvsp[(2) - (8)].PrimType), (yyvsp[(3) - (8)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005375 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005376 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (8)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005377 CHECK_FOR_ERROR
5378 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005379 (yyval.TermInstVal) = S;
Reid Spencer61c83e02006-08-18 08:43:06 +00005380 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005381 ;}
5382 break;
5383
5384 case 257:
5385#line 2533 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5386 {
Reid Spencer3822ff52006-11-08 06:47:33 +00005387
Reid Spencer14310612006-12-31 05:40:51 +00005388 // Handle the short syntax
5389 const PointerType *PFTy = 0;
5390 const FunctionType *Ty = 0;
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005391 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (14)].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00005392 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5393 // Pull out the types of all of the arguments...
5394 std::vector<const Type*> ParamTypes;
Christopher Lamb5c104242007-04-22 20:09:11 +00005395 ParamAttrsVector Attrs;
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005396 if ((yyvsp[(8) - (14)].ParamAttrs) != ParamAttr::None) {
Christopher Lamb5c104242007-04-22 20:09:11 +00005397 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = 8;
5398 Attrs.push_back(PAWI);
5399 }
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005400 ValueRefList::iterator I = (yyvsp[(6) - (14)].ValueRefList)->begin(), E = (yyvsp[(6) - (14)].ValueRefList)->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00005401 unsigned index = 1;
5402 for (; I != E; ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005403 const Type *Ty = I->Val->getType();
5404 if (Ty == Type::VoidTy)
5405 GEN_ERROR("Short call syntax cannot be used with varargs");
5406 ParamTypes.push_back(Ty);
Christopher Lamb5c104242007-04-22 20:09:11 +00005407 if (I->Attrs != ParamAttr::None) {
5408 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
5409 Attrs.push_back(PAWI);
5410 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005411 }
5412
Christopher Lamb5c104242007-04-22 20:09:11 +00005413 ParamAttrsList *PAL = 0;
5414 if (!Attrs.empty())
5415 PAL = ParamAttrsList::get(Attrs);
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005416 Ty = FunctionType::get((yyvsp[(3) - (14)].TypeVal)->get(), ParamTypes, false, PAL);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005417 PFTy = PointerType::get(Ty);
5418 }
5419
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005420 delete (yyvsp[(3) - (14)].TypeVal);
Reid Spencer66728ef2007-03-20 01:13:36 +00005421
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005422 Value *V = getVal(PFTy, (yyvsp[(4) - (14)].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005423 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005424 BasicBlock *Normal = getBBVal((yyvsp[(11) - (14)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005425 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005426 BasicBlock *Except = getBBVal((yyvsp[(14) - (14)].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005427 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005428
Reid Spencer14310612006-12-31 05:40:51 +00005429 // Check the arguments
5430 ValueList Args;
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005431 if ((yyvsp[(6) - (14)].ValueRefList)->empty()) { // Has no arguments?
Reid Spencer14310612006-12-31 05:40:51 +00005432 // Make sure no arguments is a good thing!
5433 if (Ty->getNumParams() != 0)
5434 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00005435 "expects arguments");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005436 } else { // Has arguments?
5437 // Loop through FunctionType's arguments and ensure they are specified
5438 // correctly!
Reid Spencer68a24bd2005-08-27 18:50:39 +00005439 FunctionType::param_iterator I = Ty->param_begin();
5440 FunctionType::param_iterator E = Ty->param_end();
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005441 ValueRefList::iterator ArgI = (yyvsp[(6) - (14)].ValueRefList)->begin(), ArgE = (yyvsp[(6) - (14)].ValueRefList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005442
Reid Spencer14310612006-12-31 05:40:51 +00005443 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5444 if (ArgI->Val->getType() != *I)
5445 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005446 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00005447 Args.push_back(ArgI->Val);
5448 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005449
Reid Spencer14310612006-12-31 05:40:51 +00005450 if (Ty->isVarArg()) {
5451 if (I == E)
5452 for (; ArgI != ArgE; ++ArgI)
5453 Args.push_back(ArgI->Val); // push the remaining varargs
5454 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00005455 GEN_ERROR("Invalid number of parameters detected");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005456 }
Reid Spencer14310612006-12-31 05:40:51 +00005457
5458 // Create the InvokeInst
Chris Lattner9d2fda62007-02-13 05:53:56 +00005459 InvokeInst *II = new InvokeInst(V, Normal, Except, &Args[0], Args.size());
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005460 II->setCallingConv((yyvsp[(2) - (14)].UIntVal));
5461 (yyval.TermInstVal) = II;
5462 delete (yyvsp[(6) - (14)].ValueRefList);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005463 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005464 ;}
5465 break;
5466
5467 case 258:
5468#line 2612 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5469 {
5470 (yyval.TermInstVal) = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005471 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005472 ;}
5473 break;
5474
5475 case 259:
5476#line 2616 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5477 {
5478 (yyval.TermInstVal) = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005479 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005480 ;}
5481 break;
5482
5483 case 260:
5484#line 2623 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5485 {
5486 (yyval.JumpTable) = (yyvsp[(1) - (6)].JumpTable);
5487 Constant *V = cast<Constant>(getExistingVal((yyvsp[(2) - (6)].PrimType), (yyvsp[(3) - (6)].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005488 CHECK_FOR_ERROR
5489 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005490 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005491
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005492 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (6)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005493 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005494 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5495 ;}
5496 break;
5497
5498 case 261:
5499#line 2634 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5500 {
5501 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
5502 Constant *V = cast<Constant>(getExistingVal((yyvsp[(1) - (5)].PrimType), (yyvsp[(2) - (5)].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005503 CHECK_FOR_ERROR
5504
5505 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005506 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005507
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005508 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005509 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005510 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5511 ;}
5512 break;
5513
5514 case 262:
5515#line 2647 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5516 {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005517 // Is this definition named?? if so, assign the name...
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005518 setValueName((yyvsp[(2) - (2)].InstVal), (yyvsp[(1) - (2)].StrVal));
Reid Spenceref9b9a72007-02-05 20:47:22 +00005519 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005520 InsertValue((yyvsp[(2) - (2)].InstVal));
5521 (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
Reid Spenceref9b9a72007-02-05 20:47:22 +00005522 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005523 ;}
5524 break;
5525
5526 case 263:
5527#line 2657 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5528 { // Used for PHI nodes
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005529 if (!UpRefs.empty())
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005530 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (6)].TypeVal))->getDescription());
5531 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
5532 Value* tmpVal = getVal(*(yyvsp[(1) - (6)].TypeVal), (yyvsp[(3) - (6)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005533 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005534 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (6)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005535 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005536 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5537 delete (yyvsp[(1) - (6)].TypeVal);
5538 ;}
5539 break;
5540
5541 case 264:
5542#line 2668 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5543 {
5544 (yyval.PHIList) = (yyvsp[(1) - (7)].PHIList);
5545 Value* tmpVal = getVal((yyvsp[(1) - (7)].PHIList)->front().first->getType(), (yyvsp[(4) - (7)].ValIDVal));
Reid Spencer6f407902007-01-13 05:00:46 +00005546 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005547 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (7)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005548 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005549 (yyvsp[(1) - (7)].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5550 ;}
5551 break;
5552
5553 case 265:
5554#line 2678 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5555 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005556 if (!UpRefs.empty())
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005557 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005558 // Used for call and invoke instructions
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005559 (yyval.ValueRefList) = new ValueRefList();
5560 ValueRefListEntry E; E.Attrs = (yyvsp[(3) - (3)].ParamAttrs); E.Val = getVal((yyvsp[(1) - (3)].TypeVal)->get(), (yyvsp[(2) - (3)].ValIDVal));
5561 (yyval.ValueRefList)->push_back(E);
5562 delete (yyvsp[(1) - (3)].TypeVal);
5563 ;}
5564 break;
5565
5566 case 266:
5567#line 2687 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5568 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005569 if (!UpRefs.empty())
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005570 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
5571 (yyval.ValueRefList) = (yyvsp[(1) - (5)].ValueRefList);
5572 ValueRefListEntry E; E.Attrs = (yyvsp[(5) - (5)].ParamAttrs); E.Val = getVal((yyvsp[(3) - (5)].TypeVal)->get(), (yyvsp[(4) - (5)].ValIDVal));
5573 (yyval.ValueRefList)->push_back(E);
5574 delete (yyvsp[(3) - (5)].TypeVal);
Reid Spencer14310612006-12-31 05:40:51 +00005575 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005576 ;}
5577 break;
5578
5579 case 267:
5580#line 2696 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5581 { (yyval.ValueRefList) = new ValueRefList(); ;}
5582 break;
5583
5584 case 268:
5585#line 2699 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5586 { (yyval.ValueList) = new std::vector<Value*>(); ;}
5587 break;
5588
5589 case 269:
5590#line 2700 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5591 {
5592 (yyval.ValueList) = (yyvsp[(1) - (3)].ValueList);
5593 (yyval.ValueList)->push_back((yyvsp[(3) - (3)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005594 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005595 ;}
5596 break;
5597
5598 case 270:
5599#line 2707 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5600 {
5601 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005602 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005603 ;}
5604 break;
5605
5606 case 271:
5607#line 2711 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5608 {
5609 (yyval.BoolVal) = false;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005610 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005611 ;}
5612 break;
5613
5614 case 272:
5615#line 2716 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5616 {
Reid Spencer14310612006-12-31 05:40:51 +00005617 if (!UpRefs.empty())
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005618 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
5619 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger() && !(*(yyvsp[(2) - (5)].TypeVal))->isFloatingPoint() &&
5620 !isa<VectorType>((*(yyvsp[(2) - (5)].TypeVal)).get()))
Reid Spencere4d87aa2006-12-23 06:05:41 +00005621 GEN_ERROR(
Reid Spencerb5334b02007-02-05 10:18:06 +00005622 "Arithmetic operator requires integer, FP, or packed operands");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005623 if (isa<VectorType>((*(yyvsp[(2) - (5)].TypeVal)).get()) &&
5624 ((yyvsp[(1) - (5)].BinaryOpVal) == Instruction::URem ||
5625 (yyvsp[(1) - (5)].BinaryOpVal) == Instruction::SRem ||
5626 (yyvsp[(1) - (5)].BinaryOpVal) == Instruction::FRem))
Chris Lattner32980692007-02-19 07:44:24 +00005627 GEN_ERROR("Remainder not supported on vector types");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005628 Value* val1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005629 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005630 Value* val2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005631 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005632 (yyval.InstVal) = BinaryOperator::create((yyvsp[(1) - (5)].BinaryOpVal), val1, val2);
5633 if ((yyval.InstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005634 GEN_ERROR("binary operator returned null");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005635 delete (yyvsp[(2) - (5)].TypeVal);
5636 ;}
5637 break;
5638
5639 case 273:
5640#line 2737 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5641 {
Reid Spencer14310612006-12-31 05:40:51 +00005642 if (!UpRefs.empty())
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005643 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
5644 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger()) {
5645 if (Instruction::isShift((yyvsp[(1) - (5)].BinaryOpVal)) || !isa<VectorType>((yyvsp[(2) - (5)].TypeVal)->get()) ||
5646 !cast<VectorType>((yyvsp[(2) - (5)].TypeVal)->get())->getElementType()->isInteger())
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005647 GEN_ERROR("Logical operator requires integral operands");
5648 }
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005649 Value* tmpVal1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005650 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005651 Value* tmpVal2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005652 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005653 (yyval.InstVal) = BinaryOperator::create((yyvsp[(1) - (5)].BinaryOpVal), tmpVal1, tmpVal2);
5654 if ((yyval.InstVal) == 0)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005655 GEN_ERROR("binary operator returned null");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005656 delete (yyvsp[(2) - (5)].TypeVal);
5657 ;}
5658 break;
5659
5660 case 274:
5661#line 2754 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5662 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005663 if (!UpRefs.empty())
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005664 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
5665 if (isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005666 GEN_ERROR("Vector types not supported by icmp instruction");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005667 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005668 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005669 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005670 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005671 (yyval.InstVal) = CmpInst::create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].IPredicate), tmpVal1, tmpVal2);
5672 if ((yyval.InstVal) == 0)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005673 GEN_ERROR("icmp operator returned null");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005674 delete (yyvsp[(3) - (6)].TypeVal);
5675 ;}
5676 break;
5677
5678 case 275:
5679#line 2768 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5680 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005681 if (!UpRefs.empty())
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005682 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
5683 if (isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005684 GEN_ERROR("Vector types not supported by fcmp instruction");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005685 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005686 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005687 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005688 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005689 (yyval.InstVal) = CmpInst::create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].FPredicate), tmpVal1, tmpVal2);
5690 if ((yyval.InstVal) == 0)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005691 GEN_ERROR("fcmp operator returned null");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005692 delete (yyvsp[(3) - (6)].TypeVal);
5693 ;}
5694 break;
5695
5696 case 276:
5697#line 2782 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5698 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005699 if (!UpRefs.empty())
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005700 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
5701 Value* Val = (yyvsp[(2) - (4)].ValueVal);
5702 const Type* DestTy = (yyvsp[(4) - (4)].TypeVal)->get();
5703 if (!CastInst::castIsValid((yyvsp[(1) - (4)].CastOpVal), Val, DestTy))
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005704 GEN_ERROR("invalid cast opcode for cast from '" +
5705 Val->getType()->getDescription() + "' to '" +
5706 DestTy->getDescription() + "'");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005707 (yyval.InstVal) = CastInst::create((yyvsp[(1) - (4)].CastOpVal), Val, DestTy);
5708 delete (yyvsp[(4) - (4)].TypeVal);
5709 ;}
5710 break;
5711
5712 case 277:
5713#line 2794 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5714 {
5715 if ((yyvsp[(2) - (6)].ValueVal)->getType() != Type::Int1Ty)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005716 GEN_ERROR("select condition must be boolean");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005717 if ((yyvsp[(4) - (6)].ValueVal)->getType() != (yyvsp[(6) - (6)].ValueVal)->getType())
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005718 GEN_ERROR("select value types should match");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005719 (yyval.InstVal) = new SelectInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005720 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005721 ;}
5722 break;
5723
5724 case 278:
5725#line 2802 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5726 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005727 if (!UpRefs.empty())
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005728 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
5729 (yyval.InstVal) = new VAArgInst((yyvsp[(2) - (4)].ValueVal), *(yyvsp[(4) - (4)].TypeVal));
5730 delete (yyvsp[(4) - (4)].TypeVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005731 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005732 ;}
5733 break;
5734
5735 case 279:
5736#line 2809 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5737 {
5738 if (!ExtractElementInst::isValidOperands((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal)))
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005739 GEN_ERROR("Invalid extractelement operands");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005740 (yyval.InstVal) = new ExtractElementInst((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005741 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005742 ;}
5743 break;
5744
5745 case 280:
5746#line 2815 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5747 {
5748 if (!InsertElementInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005749 GEN_ERROR("Invalid insertelement operands");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005750 (yyval.InstVal) = new InsertElementInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005751 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005752 ;}
5753 break;
5754
5755 case 281:
5756#line 2821 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5757 {
5758 if (!ShuffleVectorInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005759 GEN_ERROR("Invalid shufflevector operands");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005760 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005761 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005762 ;}
5763 break;
5764
5765 case 282:
5766#line 2827 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5767 {
5768 const Type *Ty = (yyvsp[(2) - (2)].PHIList)->front().first->getType();
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005769 if (!Ty->isFirstClassType())
5770 GEN_ERROR("PHI node operands must be of first class type");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005771 (yyval.InstVal) = new PHINode(Ty);
5772 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[(2) - (2)].PHIList)->size());
5773 while ((yyvsp[(2) - (2)].PHIList)->begin() != (yyvsp[(2) - (2)].PHIList)->end()) {
5774 if ((yyvsp[(2) - (2)].PHIList)->front().first->getType() != Ty)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005775 GEN_ERROR("All elements of a PHI node must be of the same type");
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005776 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[(2) - (2)].PHIList)->front().first, (yyvsp[(2) - (2)].PHIList)->front().second);
5777 (yyvsp[(2) - (2)].PHIList)->pop_front();
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005778 }
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005779 delete (yyvsp[(2) - (2)].PHIList); // Free the list...
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005780 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005781 ;}
5782 break;
5783
5784 case 283:
5785#line 2843 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5786 {
Reid Spencer14310612006-12-31 05:40:51 +00005787
5788 // Handle the short syntax
Andrew Lenharth6353e052006-12-08 18:07:09 +00005789 const PointerType *PFTy = 0;
5790 const FunctionType *Ty = 0;
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005791 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (8)].TypeVal)->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00005792 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5793 // Pull out the types of all of the arguments...
5794 std::vector<const Type*> ParamTypes;
Christopher Lamb5c104242007-04-22 20:09:11 +00005795 ParamAttrsVector Attrs;
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005796 if ((yyvsp[(8) - (8)].ParamAttrs) != ParamAttr::None) {
5797 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = (yyvsp[(8) - (8)].ParamAttrs);
Christopher Lamb5c104242007-04-22 20:09:11 +00005798 Attrs.push_back(PAWI);
5799 }
Reid Spencer7b5d4662007-04-09 06:16:21 +00005800 unsigned index = 1;
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005801 ValueRefList::iterator I = (yyvsp[(6) - (8)].ValueRefList)->begin(), E = (yyvsp[(6) - (8)].ValueRefList)->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00005802 for (; I != E; ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005803 const Type *Ty = I->Val->getType();
5804 if (Ty == Type::VoidTy)
5805 GEN_ERROR("Short call syntax cannot be used with varargs");
5806 ParamTypes.push_back(Ty);
Christopher Lamb5c104242007-04-22 20:09:11 +00005807 if (I->Attrs != ParamAttr::None) {
5808 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
5809 Attrs.push_back(PAWI);
5810 }
Andrew Lenharth6353e052006-12-08 18:07:09 +00005811 }
5812
Christopher Lamb5c104242007-04-22 20:09:11 +00005813 ParamAttrsList *PAL = 0;
5814 if (!Attrs.empty())
5815 PAL = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00005816
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005817 Ty = FunctionType::get((yyvsp[(3) - (8)].TypeVal)->get(), ParamTypes, false, PAL);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005818 PFTy = PointerType::get(Ty);
5819 }
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005820
5821 Value *V = getVal(PFTy, (yyvsp[(4) - (8)].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005822 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005823
Reid Spencer7780acb2007-04-16 06:56:07 +00005824 // Check for call to invalid intrinsic to avoid crashing later.
5825 if (Function *theF = dyn_cast<Function>(V)) {
Reid Spencered48de22007-04-16 22:02:23 +00005826 if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) &&
Reid Spencer36fdde12007-04-16 20:35:38 +00005827 (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) &&
5828 !theF->getIntrinsicID(true))
Reid Spencer7780acb2007-04-16 06:56:07 +00005829 GEN_ERROR("Call to invalid LLVM intrinsic function '" +
5830 theF->getName() + "'");
5831 }
5832
Reid Spencer14310612006-12-31 05:40:51 +00005833 // Check the arguments
5834 ValueList Args;
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005835 if ((yyvsp[(6) - (8)].ValueRefList)->empty()) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00005836 // Make sure no arguments is a good thing!
5837 if (Ty->getNumParams() != 0)
5838 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00005839 "expects arguments");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005840 } else { // Has arguments?
5841 // Loop through FunctionType's arguments and ensure they are specified
5842 // correctly!
5843 //
5844 FunctionType::param_iterator I = Ty->param_begin();
5845 FunctionType::param_iterator E = Ty->param_end();
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005846 ValueRefList::iterator ArgI = (yyvsp[(6) - (8)].ValueRefList)->begin(), ArgE = (yyvsp[(6) - (8)].ValueRefList)->end();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005847
Reid Spencer14310612006-12-31 05:40:51 +00005848 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5849 if (ArgI->Val->getType() != *I)
5850 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005851 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00005852 Args.push_back(ArgI->Val);
5853 }
5854 if (Ty->isVarArg()) {
5855 if (I == E)
5856 for (; ArgI != ArgE; ++ArgI)
5857 Args.push_back(ArgI->Val); // push the remaining varargs
5858 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00005859 GEN_ERROR("Invalid number of parameters detected");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005860 }
Reid Spencer14310612006-12-31 05:40:51 +00005861 // Create the call node
Chris Lattner9d2fda62007-02-13 05:53:56 +00005862 CallInst *CI = new CallInst(V, &Args[0], Args.size());
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005863 CI->setTailCall((yyvsp[(1) - (8)].BoolVal));
5864 CI->setCallingConv((yyvsp[(2) - (8)].UIntVal));
5865 (yyval.InstVal) = CI;
5866 delete (yyvsp[(6) - (8)].ValueRefList);
5867 delete (yyvsp[(3) - (8)].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00005868 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005869 ;}
5870 break;
5871
5872 case 284:
5873#line 2927 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5874 {
5875 (yyval.InstVal) = (yyvsp[(1) - (1)].InstVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005876 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005877 ;}
5878 break;
5879
5880 case 285:
5881#line 2932 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5882 {
5883 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005884 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005885 ;}
5886 break;
5887
5888 case 286:
5889#line 2936 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5890 {
5891 (yyval.BoolVal) = false;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005892 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005893 ;}
5894 break;
5895
5896 case 287:
5897#line 2943 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5898 {
Reid Spencer14310612006-12-31 05:40:51 +00005899 if (!UpRefs.empty())
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005900 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
5901 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
5902 delete (yyvsp[(2) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005903 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005904 ;}
5905 break;
5906
5907 case 288:
5908#line 2950 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5909 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005910 if (!UpRefs.empty())
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005911 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
5912 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005913 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005914 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
5915 delete (yyvsp[(2) - (6)].TypeVal);
5916 ;}
5917 break;
5918
5919 case 289:
5920#line 2958 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5921 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005922 if (!UpRefs.empty())
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005923 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
5924 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
5925 delete (yyvsp[(2) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005926 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005927 ;}
5928 break;
5929
5930 case 290:
5931#line 2965 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5932 {
Reid Spencer14310612006-12-31 05:40:51 +00005933 if (!UpRefs.empty())
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005934 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
5935 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005936 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005937 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
5938 delete (yyvsp[(2) - (6)].TypeVal);
5939 ;}
5940 break;
5941
5942 case 291:
5943#line 2973 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5944 {
5945 if (!isa<PointerType>((yyvsp[(2) - (2)].ValueVal)->getType()))
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005946 GEN_ERROR("Trying to free nonpointer type " +
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005947 (yyvsp[(2) - (2)].ValueVal)->getType()->getDescription() + "");
5948 (yyval.InstVal) = new FreeInst((yyvsp[(2) - (2)].ValueVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005949 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005950 ;}
5951 break;
5952
5953 case 292:
5954#line 2981 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5955 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005956 if (!UpRefs.empty())
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005957 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
5958 if (!isa<PointerType>((yyvsp[(3) - (5)].TypeVal)->get()))
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005959 GEN_ERROR("Can't load from nonpointer type: " +
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005960 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
5961 if (!cast<PointerType>((yyvsp[(3) - (5)].TypeVal)->get())->getElementType()->isFirstClassType())
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005962 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005963 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
5964 Value* tmpVal = getVal(*(yyvsp[(3) - (5)].TypeVal), (yyvsp[(4) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005965 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005966 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[(1) - (5)].BoolVal), (yyvsp[(5) - (5)].UIntVal));
5967 delete (yyvsp[(3) - (5)].TypeVal);
5968 ;}
5969 break;
5970
5971 case 293:
5972#line 2995 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5973 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005974 if (!UpRefs.empty())
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005975 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
5976 const PointerType *PT = dyn_cast<PointerType>((yyvsp[(5) - (7)].TypeVal)->get());
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005977 if (!PT)
5978 GEN_ERROR("Can't store to a nonpointer type: " +
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005979 (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005980 const Type *ElTy = PT->getElementType();
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005981 if (ElTy != (yyvsp[(3) - (7)].ValueVal)->getType())
5982 GEN_ERROR("Can't store '" + (yyvsp[(3) - (7)].ValueVal)->getType()->getDescription() +
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005983 "' into space of type '" + ElTy->getDescription() + "'");
5984
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005985 Value* tmpVal = getVal(*(yyvsp[(5) - (7)].TypeVal), (yyvsp[(6) - (7)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005986 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005987 (yyval.InstVal) = new StoreInst((yyvsp[(3) - (7)].ValueVal), tmpVal, (yyvsp[(1) - (7)].BoolVal), (yyvsp[(7) - (7)].UIntVal));
5988 delete (yyvsp[(5) - (7)].TypeVal);
5989 ;}
5990 break;
5991
5992 case 294:
5993#line 3012 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5994 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005995 if (!UpRefs.empty())
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005996 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (4)].TypeVal))->getDescription());
5997 if (!isa<PointerType>((yyvsp[(2) - (4)].TypeVal)->get()))
Reid Spencerb5334b02007-02-05 10:18:06 +00005998 GEN_ERROR("getelementptr insn requires pointer operand");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005999
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00006000 if (!GetElementPtrInst::getIndexedType(*(yyvsp[(2) - (4)].TypeVal), &(*(yyvsp[(4) - (4)].ValueList))[0], (yyvsp[(4) - (4)].ValueList)->size(), true))
Reid Spencer61c83e02006-08-18 08:43:06 +00006001 GEN_ERROR("Invalid getelementptr indices for type '" +
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00006002 (*(yyvsp[(2) - (4)].TypeVal))->getDescription()+ "'");
6003 Value* tmpVal = getVal(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(3) - (4)].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00006004 CHECK_FOR_ERROR
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00006005 (yyval.InstVal) = new GetElementPtrInst(tmpVal, &(*(yyvsp[(4) - (4)].ValueList))[0], (yyvsp[(4) - (4)].ValueList)->size());
6006 delete (yyvsp[(2) - (4)].TypeVal);
6007 delete (yyvsp[(4) - (4)].ValueList);
6008 ;}
6009 break;
Reid Spencer7780acb2007-04-16 06:56:07 +00006010
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00006011
6012/* Line 1267 of yacc.c. */
6013#line 6014 "llvmAsmParser.tab.c"
6014 default: break;
Christopher Lamb5c104242007-04-22 20:09:11 +00006015 }
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00006016 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
6017
6018 YYPOPSTACK (yylen);
6019 yylen = 0;
6020 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006021
6022 *++yyvsp = yyval;
6023
6024
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00006025 /* Now `shift' the result of the reduction. Determine what state
6026 that goes to, based on the state we popped back to and the rule
6027 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00006028
6029 yyn = yyr1[yyn];
6030
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00006031 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
6032 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00006033 yystate = yytable[yystate];
6034 else
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00006035 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00006036
6037 goto yynewstate;
6038
6039
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00006040/*------------------------------------.
6041| yyerrlab -- here on detecting error |
6042`------------------------------------*/
6043yyerrlab:
6044 /* If not already recovering from an error, report this error. */
6045 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00006046 {
6047 ++yynerrs;
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00006048#if ! YYERROR_VERBOSE
6049 yyerror (YY_("syntax error"));
6050#else
6051 {
6052 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
6053 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
6054 {
6055 YYSIZE_T yyalloc = 2 * yysize;
6056 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
6057 yyalloc = YYSTACK_ALLOC_MAXIMUM;
6058 if (yymsg != yymsgbuf)
6059 YYSTACK_FREE (yymsg);
6060 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
6061 if (yymsg)
6062 yymsg_alloc = yyalloc;
6063 else
6064 {
6065 yymsg = yymsgbuf;
6066 yymsg_alloc = sizeof yymsgbuf;
6067 }
6068 }
Christopher Lamb5c104242007-04-22 20:09:11 +00006069
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00006070 if (0 < yysize && yysize <= yymsg_alloc)
6071 {
6072 (void) yysyntax_error (yymsg, yystate, yychar);
6073 yyerror (yymsg);
6074 }
6075 else
6076 {
6077 yyerror (YY_("syntax error"));
6078 if (yysize != 0)
6079 goto yyexhaustedlab;
6080 }
6081 }
6082#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00006083 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00006084
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00006085
Reid Spencer41dff5e2007-01-26 08:05:27 +00006086
6087 if (yyerrstatus == 3)
6088 {
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00006089 /* If just tried and failed to reuse look-ahead token after an
6090 error, discard it. */
Reid Spencer41dff5e2007-01-26 08:05:27 +00006091
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00006092 if (yychar <= YYEOF)
6093 {
6094 /* Return failure if at end of input. */
6095 if (yychar == YYEOF)
6096 YYABORT;
6097 }
6098 else
6099 {
6100 yydestruct ("Error: discarding",
6101 yytoken, &yylval);
6102 yychar = YYEMPTY;
6103 }
6104 }
6105
6106 /* Else will try to reuse look-ahead token after shifting the error
6107 token. */
6108 goto yyerrlab1;
6109
6110
6111/*---------------------------------------------------.
6112| yyerrorlab -- error raised explicitly by YYERROR. |
6113`---------------------------------------------------*/
6114yyerrorlab:
6115
6116 /* Pacify compilers like GCC when the user code never invokes
6117 YYERROR and the label yyerrorlab therefore never appears in user
6118 code. */
6119 if (/*CONSTCOND*/ 0)
6120 goto yyerrorlab;
6121
6122 /* Do not reclaim the symbols of the rule which action triggered
6123 this YYERROR. */
6124 YYPOPSTACK (yylen);
6125 yylen = 0;
6126 YY_STACK_PRINT (yyss, yyssp);
6127 yystate = *yyssp;
6128 goto yyerrlab1;
6129
6130
6131/*-------------------------------------------------------------.
6132| yyerrlab1 -- common code for both syntax error and YYERROR. |
6133`-------------------------------------------------------------*/
6134yyerrlab1:
6135 yyerrstatus = 3; /* Each real token shifted decrements this. */
6136
6137 for (;;)
6138 {
6139 yyn = yypact[yystate];
6140 if (yyn != YYPACT_NINF)
6141 {
6142 yyn += YYTERROR;
6143 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6144 {
6145 yyn = yytable[yyn];
6146 if (0 < yyn)
6147 break;
6148 }
6149 }
6150
6151 /* Pop the current state because it cannot handle the error token. */
6152 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00006153 YYABORT;
6154
Reid Spencere4d87aa2006-12-23 06:05:41 +00006155
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00006156 yydestruct ("Error: popping",
6157 yystos[yystate], yyvsp);
6158 YYPOPSTACK (1);
6159 yystate = *yyssp;
6160 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006161 }
6162
6163 if (yyn == YYFINAL)
6164 YYACCEPT;
6165
Reid Spencer68a24bd2005-08-27 18:50:39 +00006166 *++yyvsp = yylval;
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00006167
6168
6169 /* Shift the error token. */
6170 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spencer41dff5e2007-01-26 08:05:27 +00006171
Reid Spencer68a24bd2005-08-27 18:50:39 +00006172 yystate = yyn;
6173 goto yynewstate;
6174
Christopher Lamb5c104242007-04-22 20:09:11 +00006175
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00006176/*-------------------------------------.
6177| yyacceptlab -- YYACCEPT comes here. |
6178`-------------------------------------*/
6179yyacceptlab:
6180 yyresult = 0;
6181 goto yyreturn;
6182
6183/*-----------------------------------.
6184| yyabortlab -- YYABORT comes here. |
6185`-----------------------------------*/
6186yyabortlab:
6187 yyresult = 1;
6188 goto yyreturn;
6189
6190#ifndef yyoverflow
6191/*-------------------------------------------------.
6192| yyexhaustedlab -- memory exhaustion comes here. |
6193`-------------------------------------------------*/
6194yyexhaustedlab:
6195 yyerror (YY_("memory exhausted"));
6196 yyresult = 2;
6197 /* Fall through. */
Christopher Lamb5c104242007-04-22 20:09:11 +00006198#endif
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00006199
6200yyreturn:
6201 if (yychar != YYEOF && yychar != YYEMPTY)
6202 yydestruct ("Cleanup: discarding lookahead",
6203 yytoken, &yylval);
6204 /* Do not reclaim the symbols of the rule which action triggered
6205 this YYABORT or YYACCEPT. */
6206 YYPOPSTACK (yylen);
6207 YY_STACK_PRINT (yyss, yyssp);
6208 while (yyssp != yyss)
6209 {
6210 yydestruct ("Cleanup: popping",
6211 yystos[*yyssp], yyvsp);
6212 YYPOPSTACK (1);
Christopher Lamb5c104242007-04-22 20:09:11 +00006213 }
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00006214#ifndef yyoverflow
6215 if (yyss != yyssa)
6216 YYSTACK_FREE (yyss);
6217#endif
6218#if YYERROR_VERBOSE
6219 if (yymsg != yymsgbuf)
6220 YYSTACK_FREE (yymsg);
6221#endif
6222 /* Make sure YYID is used. */
6223 return YYID (yyresult);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006224}
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00006225
6226
6227#line 3029 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00006228
6229
Reid Spencer14310612006-12-31 05:40:51 +00006230// common code from the two 'RunVMAsmParser' functions
6231static Module* RunParser(Module * M) {
6232
6233 llvmAsmlineno = 1; // Reset the current line number...
6234 CurModule.CurrentModule = M;
6235#if YYDEBUG
6236 yydebug = Debug;
6237#endif
6238
6239 // Check to make sure the parser succeeded
6240 if (yyparse()) {
6241 if (ParserResult)
6242 delete ParserResult;
6243 return 0;
6244 }
6245
Reid Spencer0d60b5a2007-03-30 01:37:39 +00006246 // Emit an error if there are any unresolved types left.
6247 if (!CurModule.LateResolveTypes.empty()) {
6248 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
6249 if (DID.Type == ValID::LocalName) {
6250 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
6251 } else {
6252 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
6253 }
6254 if (ParserResult)
6255 delete ParserResult;
6256 return 0;
6257 }
6258
6259 // Emit an error if there are any unresolved values left.
6260 if (!CurModule.LateResolveValues.empty()) {
6261 Value *V = CurModule.LateResolveValues.back();
6262 std::map<Value*, std::pair<ValID, int> >::iterator I =
6263 CurModule.PlaceHolderInfo.find(V);
6264
6265 if (I != CurModule.PlaceHolderInfo.end()) {
6266 ValID &DID = I->second.first;
6267 if (DID.Type == ValID::LocalName) {
6268 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
6269 } else {
6270 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
6271 }
6272 if (ParserResult)
6273 delete ParserResult;
6274 return 0;
6275 }
6276 }
6277
Reid Spencer14310612006-12-31 05:40:51 +00006278 // Check to make sure that parsing produced a result
6279 if (!ParserResult)
6280 return 0;
6281
6282 // Reset ParserResult variable while saving its value for the result.
6283 Module *Result = ParserResult;
6284 ParserResult = 0;
6285
6286 return Result;
6287}
6288
Reid Spencer61c83e02006-08-18 08:43:06 +00006289void llvm::GenerateError(const std::string &message, int LineNo) {
6290 if (LineNo == -1) LineNo = llvmAsmlineno;
6291 // TODO: column number in exception
6292 if (TheParseError)
6293 TheParseError->setError(CurFilename, message, LineNo);
6294 TriggerError = 1;
6295}
Reid Spencer68a24bd2005-08-27 18:50:39 +00006296
6297int yyerror(const char *ErrorMsg) {
6298 std::string where
6299 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
6300 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
Reid Spenceref9b9a72007-02-05 20:47:22 +00006301 std::string errMsg = where + "error: " + std::string(ErrorMsg);
6302 if (yychar != YYEMPTY && yychar != 0)
6303 errMsg += " while reading token: '" + std::string(llvmAsmtext, llvmAsmleng)+
6304 "'";
Reid Spencer61c83e02006-08-18 08:43:06 +00006305 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006306 return 0;
6307}
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00006308