blob: 30049cf2bfc1aa3161ad4273d3a2394aa5f8580f [file] [log] [blame]
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00001/* A Bison parser, made by GNU Bison 2.3. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003/* Skeleton implementation for Bison's Yacc-like parsers in C
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +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 Korobeynikovb9b977d2007-11-14 09:53:48 +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 Korobeynikovb9b977d2007-11-14 09:53:48 +000063#define yylex llvmAsmlex
Reid Spencer68a24bd2005-08-27 18:50:39 +000064#define yyerror llvmAsmerror
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +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 Korobeynikovb9b977d2007-11-14 09:53:48 +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 X86_FP80 = 269,
89 FP128 = 270,
90 PPC_FP128 = 271,
91 LABEL = 272,
92 TYPE = 273,
93 LOCALVAR = 274,
94 GLOBALVAR = 275,
95 LABELSTR = 276,
96 STRINGCONSTANT = 277,
97 ATSTRINGCONSTANT = 278,
98 PCTSTRINGCONSTANT = 279,
99 ZEROINITIALIZER = 280,
100 TRUETOK = 281,
101 FALSETOK = 282,
102 BEGINTOK = 283,
103 ENDTOK = 284,
104 DECLARE = 285,
105 DEFINE = 286,
106 GLOBAL = 287,
107 CONSTANT = 288,
108 SECTION = 289,
109 ALIAS = 290,
110 VOLATILE = 291,
111 THREAD_LOCAL = 292,
112 TO = 293,
113 DOTDOTDOT = 294,
114 NULL_TOK = 295,
115 UNDEF = 296,
116 INTERNAL = 297,
117 LINKONCE = 298,
118 WEAK = 299,
119 APPENDING = 300,
120 DLLIMPORT = 301,
121 DLLEXPORT = 302,
122 EXTERN_WEAK = 303,
123 OPAQUE = 304,
124 EXTERNAL = 305,
125 TARGET = 306,
126 TRIPLE = 307,
127 ALIGN = 308,
128 DEPLIBS = 309,
129 CALL = 310,
130 TAIL = 311,
131 ASM_TOK = 312,
132 MODULE = 313,
133 SIDEEFFECT = 314,
134 CC_TOK = 315,
135 CCC_TOK = 316,
136 FASTCC_TOK = 317,
137 COLDCC_TOK = 318,
138 X86_STDCALLCC_TOK = 319,
139 X86_FASTCALLCC_TOK = 320,
140 DATALAYOUT = 321,
141 RET = 322,
142 BR = 323,
143 SWITCH = 324,
144 INVOKE = 325,
145 UNWIND = 326,
146 UNREACHABLE = 327,
147 ADD = 328,
148 SUB = 329,
149 MUL = 330,
150 UDIV = 331,
151 SDIV = 332,
152 FDIV = 333,
153 UREM = 334,
154 SREM = 335,
155 FREM = 336,
156 AND = 337,
157 OR = 338,
158 XOR = 339,
159 SHL = 340,
160 LSHR = 341,
161 ASHR = 342,
162 ICMP = 343,
163 FCMP = 344,
164 EQ = 345,
165 NE = 346,
166 SLT = 347,
167 SGT = 348,
168 SLE = 349,
169 SGE = 350,
170 ULT = 351,
171 UGT = 352,
172 ULE = 353,
173 UGE = 354,
174 OEQ = 355,
175 ONE = 356,
176 OLT = 357,
177 OGT = 358,
178 OLE = 359,
179 OGE = 360,
180 ORD = 361,
181 UNO = 362,
182 UEQ = 363,
183 UNE = 364,
184 MALLOC = 365,
185 ALLOCA = 366,
186 FREE = 367,
187 LOAD = 368,
188 STORE = 369,
189 GETELEMENTPTR = 370,
190 TRUNC = 371,
191 ZEXT = 372,
192 SEXT = 373,
193 FPTRUNC = 374,
194 FPEXT = 375,
195 BITCAST = 376,
196 UITOFP = 377,
197 SITOFP = 378,
198 FPTOUI = 379,
199 FPTOSI = 380,
200 INTTOPTR = 381,
201 PTRTOINT = 382,
202 PHI_TOK = 383,
203 SELECT = 384,
204 VAARG = 385,
205 EXTRACTELEMENT = 386,
206 INSERTELEMENT = 387,
207 SHUFFLEVECTOR = 388,
208 SIGNEXT = 389,
209 ZEROEXT = 390,
210 NORETURN = 391,
211 INREG = 392,
212 SRET = 393,
213 NOUNWIND = 394,
214 NOALIAS = 395,
215 BYVAL = 396,
216 NEST = 397,
Duncan Sandsdc024672007-11-27 13:23:08 +0000217 READNONE = 398,
218 READONLY = 399,
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +0000219 DEFAULT = 400,
220 HIDDEN = 401,
221 PROTECTED = 402
222 };
223#endif
224/* Tokens. */
225#define ESINT64VAL 258
226#define EUINT64VAL 259
227#define ESAPINTVAL 260
228#define EUAPINTVAL 261
229#define LOCALVAL_ID 262
230#define GLOBALVAL_ID 263
231#define FPVAL 264
232#define VOID 265
233#define INTTYPE 266
234#define FLOAT 267
235#define DOUBLE 268
236#define X86_FP80 269
237#define FP128 270
238#define PPC_FP128 271
239#define LABEL 272
240#define TYPE 273
241#define LOCALVAR 274
242#define GLOBALVAR 275
243#define LABELSTR 276
244#define STRINGCONSTANT 277
245#define ATSTRINGCONSTANT 278
246#define PCTSTRINGCONSTANT 279
247#define ZEROINITIALIZER 280
248#define TRUETOK 281
249#define FALSETOK 282
250#define BEGINTOK 283
251#define ENDTOK 284
252#define DECLARE 285
253#define DEFINE 286
254#define GLOBAL 287
255#define CONSTANT 288
256#define SECTION 289
257#define ALIAS 290
258#define VOLATILE 291
259#define THREAD_LOCAL 292
260#define TO 293
261#define DOTDOTDOT 294
262#define NULL_TOK 295
263#define UNDEF 296
264#define INTERNAL 297
265#define LINKONCE 298
266#define WEAK 299
267#define APPENDING 300
268#define DLLIMPORT 301
269#define DLLEXPORT 302
270#define EXTERN_WEAK 303
271#define OPAQUE 304
272#define EXTERNAL 305
273#define TARGET 306
274#define TRIPLE 307
275#define ALIGN 308
276#define DEPLIBS 309
277#define CALL 310
278#define TAIL 311
279#define ASM_TOK 312
280#define MODULE 313
281#define SIDEEFFECT 314
282#define CC_TOK 315
283#define CCC_TOK 316
284#define FASTCC_TOK 317
285#define COLDCC_TOK 318
286#define X86_STDCALLCC_TOK 319
287#define X86_FASTCALLCC_TOK 320
288#define DATALAYOUT 321
289#define RET 322
290#define BR 323
291#define SWITCH 324
292#define INVOKE 325
293#define UNWIND 326
294#define UNREACHABLE 327
295#define ADD 328
296#define SUB 329
297#define MUL 330
298#define UDIV 331
299#define SDIV 332
300#define FDIV 333
301#define UREM 334
302#define SREM 335
303#define FREM 336
304#define AND 337
305#define OR 338
306#define XOR 339
307#define SHL 340
308#define LSHR 341
309#define ASHR 342
310#define ICMP 343
311#define FCMP 344
312#define EQ 345
313#define NE 346
314#define SLT 347
315#define SGT 348
316#define SLE 349
317#define SGE 350
318#define ULT 351
319#define UGT 352
320#define ULE 353
321#define UGE 354
322#define OEQ 355
323#define ONE 356
324#define OLT 357
325#define OGT 358
326#define OLE 359
327#define OGE 360
328#define ORD 361
329#define UNO 362
330#define UEQ 363
331#define UNE 364
332#define MALLOC 365
333#define ALLOCA 366
334#define FREE 367
335#define LOAD 368
336#define STORE 369
337#define GETELEMENTPTR 370
338#define TRUNC 371
339#define ZEXT 372
340#define SEXT 373
341#define FPTRUNC 374
342#define FPEXT 375
343#define BITCAST 376
344#define UITOFP 377
345#define SITOFP 378
346#define FPTOUI 379
347#define FPTOSI 380
348#define INTTOPTR 381
349#define PTRTOINT 382
350#define PHI_TOK 383
351#define SELECT 384
352#define VAARG 385
353#define EXTRACTELEMENT 386
354#define INSERTELEMENT 387
355#define SHUFFLEVECTOR 388
356#define SIGNEXT 389
357#define ZEROEXT 390
358#define NORETURN 391
359#define INREG 392
360#define SRET 393
361#define NOUNWIND 394
362#define NOALIAS 395
363#define BYVAL 396
364#define NEST 397
Duncan Sandsdc024672007-11-27 13:23:08 +0000365#define READNONE 398
366#define READONLY 399
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +0000367#define DEFAULT 400
368#define HIDDEN 401
369#define PROTECTED 402
370
371
372
373
374/* Copy the first part of user declarations. */
Anton Korobeynikovc36284e2007-12-03 19:17:47 +0000375#line 14 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000376
377#include "ParserInternals.h"
378#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000379#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000380#include "llvm/Instructions.h"
381#include "llvm/Module.h"
Reid Spenceref9b9a72007-02-05 20:47:22 +0000382#include "llvm/ValueSymbolTable.h"
Chandler Carruth02202192007-08-04 01:56:21 +0000383#include "llvm/AutoUpgrade.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000384#include "llvm/Support/GetElementPtrTypeIterator.h"
Reid Spencer14310612006-12-31 05:40:51 +0000385#include "llvm/Support/CommandLine.h"
Chris Lattnerf7469af2007-01-31 04:44:08 +0000386#include "llvm/ADT/SmallVector.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000387#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000388#include "llvm/Support/MathExtras.h"
Reid Spencer481169e2006-12-01 00:33:46 +0000389#include "llvm/Support/Streams.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000390#include <algorithm>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000391#include <list>
Chris Lattner8adde282007-02-11 21:40:10 +0000392#include <map>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000393#include <utility>
394
Reid Spencere4f47592006-08-18 17:32:55 +0000395// The following is a gross hack. In order to rid the libAsmParser library of
396// exceptions, we have to have a way of getting the yyparse function to go into
397// an error situation. So, whenever we want an error to occur, the GenerateError
398// function (see bottom of file) sets TriggerError. Then, at the end of each
399// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
400// (a goto) to put YACC in error state. Furthermore, several calls to
401// GenerateError are made from inside productions and they must simulate the
402// previous exception behavior by exiting the production immediately. We have
403// replaced these with the GEN_ERROR macro which calls GeneratError and then
404// immediately invokes YYERROR. This would be so much cleaner if it was a
405// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000406static bool TriggerError = false;
Reid Spencerf63697d2006-10-09 17:36:59 +0000407#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000408#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
409
Reid Spencer68a24bd2005-08-27 18:50:39 +0000410int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
411int yylex(); // declaration" of xxx warnings.
412int yyparse();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000413using namespace llvm;
414
415static Module *ParserResult;
416
417// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
418// relating to upreferences in the input stream.
419//
420//#define DEBUG_UPREFS 1
421#ifdef DEBUG_UPREFS
Bill Wendlinge8156192006-12-07 01:30:32 +0000422#define UR_OUT(X) cerr << X
Reid Spencer68a24bd2005-08-27 18:50:39 +0000423#else
424#define UR_OUT(X)
425#endif
426
427#define YYERROR_VERBOSE 1
428
Chris Lattnerb475c422005-11-12 18:22:38 +0000429static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000430
431
432// This contains info used when building the body of a function. It is
433// destroyed when the function is completed.
434//
435typedef std::vector<Value *> ValueList; // Numbered defs
Reid Spencer14310612006-12-31 05:40:51 +0000436
Reid Spencer68a24bd2005-08-27 18:50:39 +0000437static void
Reid Spencer93c40032007-03-19 18:40:50 +0000438ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000439
440static struct PerModuleInfo {
441 Module *CurrentModule;
Reid Spencer93c40032007-03-19 18:40:50 +0000442 ValueList Values; // Module level numbered definitions
443 ValueList LateResolveValues;
Reid Spencer861d9d62006-11-28 07:29:44 +0000444 std::vector<PATypeHolder> Types;
445 std::map<ValID, PATypeHolder> LateResolveTypes;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000446
447 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000448 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000449 /// that we can resolve them later and print error messages as appropriate.
450 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
451
452 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
453 // references to global values. Global values may be referenced before they
454 // are defined, and if so, the temporary object that they represent is held
455 // here. This is used for forward references of GlobalValues.
456 //
457 typedef std::map<std::pair<const PointerType *,
458 ValID>, GlobalValue*> GlobalRefsType;
459 GlobalRefsType GlobalRefs;
460
461 void ModuleDone() {
462 // If we could not resolve some functions at function compilation time
463 // (calls to functions before they are defined), resolve them now... Types
464 // are resolved when the constant pool has been completely parsed.
465 //
466 ResolveDefinitions(LateResolveValues);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000467 if (TriggerError)
468 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000469
470 // Check to make sure that all global value forward references have been
471 // resolved!
472 //
473 if (!GlobalRefs.empty()) {
474 std::string UndefinedReferences = "Unresolved global references exist:\n";
475
476 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
477 I != E; ++I) {
478 UndefinedReferences += " " + I->first.first->getDescription() + " " +
479 I->first.second.getName() + "\n";
480 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000481 GenerateError(UndefinedReferences);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000482 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000483 }
484
Chandler Carruth02202192007-08-04 01:56:21 +0000485 // Look for intrinsic functions and CallInst that need to be upgraded
486 for (Module::iterator FI = CurrentModule->begin(),
487 FE = CurrentModule->end(); FI != FE; )
488 UpgradeCallsToIntrinsic(FI++); // must be post-increment, as we remove
489
Reid Spencer68a24bd2005-08-27 18:50:39 +0000490 Values.clear(); // Clear out function local definitions
491 Types.clear();
492 CurrentModule = 0;
493 }
494
Reid Spencer68a24bd2005-08-27 18:50:39 +0000495 // GetForwardRefForGlobal - Check to see if there is a forward reference
496 // for this global. If so, remove it from the GlobalRefs map and return it.
497 // If not, just return null.
498 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
499 // Check to see if there is a forward reference to this global variable...
500 // if there is, eliminate it and patch the reference to use the new def'n.
501 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
502 GlobalValue *Ret = 0;
503 if (I != GlobalRefs.end()) {
504 Ret = I->second;
505 GlobalRefs.erase(I);
506 }
507 return Ret;
508 }
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000509
510 bool TypeIsUnresolved(PATypeHolder* PATy) {
511 // If it isn't abstract, its resolved
512 const Type* Ty = PATy->get();
513 if (!Ty->isAbstract())
514 return false;
515 // Traverse the type looking for abstract types. If it isn't abstract then
516 // we don't need to traverse that leg of the type.
517 std::vector<const Type*> WorkList, SeenList;
518 WorkList.push_back(Ty);
519 while (!WorkList.empty()) {
520 const Type* Ty = WorkList.back();
521 SeenList.push_back(Ty);
522 WorkList.pop_back();
523 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
524 // Check to see if this is an unresolved type
525 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
526 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
527 for ( ; I != E; ++I) {
528 if (I->second.get() == OpTy)
529 return true;
530 }
531 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
532 const Type* TheTy = SeqTy->getElementType();
533 if (TheTy->isAbstract() && TheTy != Ty) {
534 std::vector<const Type*>::iterator I = SeenList.begin(),
535 E = SeenList.end();
536 for ( ; I != E; ++I)
537 if (*I == TheTy)
538 break;
539 if (I == E)
540 WorkList.push_back(TheTy);
541 }
542 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
543 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
544 const Type* TheTy = StrTy->getElementType(i);
545 if (TheTy->isAbstract() && TheTy != Ty) {
546 std::vector<const Type*>::iterator I = SeenList.begin(),
547 E = SeenList.end();
548 for ( ; I != E; ++I)
549 if (*I == TheTy)
550 break;
551 if (I == E)
552 WorkList.push_back(TheTy);
553 }
554 }
555 }
556 }
557 return false;
558 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000559} CurModule;
560
561static struct PerFunctionInfo {
562 Function *CurrentFunction; // Pointer to current function being created
563
Reid Spencer93c40032007-03-19 18:40:50 +0000564 ValueList Values; // Keep track of #'d definitions
565 unsigned NextValNum;
566 ValueList LateResolveValues;
Reid Spenceref9b9a72007-02-05 20:47:22 +0000567 bool isDeclare; // Is this function a forward declararation?
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000568 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000569 GlobalValue::VisibilityTypes Visibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000570
571 /// BBForwardRefs - When we see forward references to basic blocks, keep
572 /// track of them here.
Reid Spencer93c40032007-03-19 18:40:50 +0000573 std::map<ValID, BasicBlock*> BBForwardRefs;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000574
575 inline PerFunctionInfo() {
576 CurrentFunction = 0;
577 isDeclare = false;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000578 Linkage = GlobalValue::ExternalLinkage;
579 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000580 }
581
582 inline void FunctionStart(Function *M) {
583 CurrentFunction = M;
Reid Spencer93c40032007-03-19 18:40:50 +0000584 NextValNum = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000585 }
586
587 void FunctionDone() {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000588 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000589 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000590 GenerateError("Undefined reference to label " +
Reid Spencer93c40032007-03-19 18:40:50 +0000591 BBForwardRefs.begin()->second->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000592 return;
593 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000594
595 // Resolve all forward references now.
596 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
597
598 Values.clear(); // Clear out function local definitions
Reid Spencer93c40032007-03-19 18:40:50 +0000599 BBForwardRefs.clear();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000600 CurrentFunction = 0;
601 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000602 Linkage = GlobalValue::ExternalLinkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000603 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000604 }
605} CurFun; // Info for the current function...
606
607static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
608
609
610//===----------------------------------------------------------------------===//
611// Code to handle definitions of all the types
612//===----------------------------------------------------------------------===//
613
Reid Spencer93c40032007-03-19 18:40:50 +0000614static void InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) {
615 // Things that have names or are void typed don't get slot numbers
616 if (V->hasName() || (V->getType() == Type::VoidTy))
617 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000618
Reid Spencer93c40032007-03-19 18:40:50 +0000619 // In the case of function values, we have to allow for the forward reference
620 // of basic blocks, which are included in the numbering. Consequently, we keep
621 // track of the next insertion location with NextValNum. When a BB gets
622 // inserted, it could change the size of the CurFun.Values vector.
623 if (&ValueTab == &CurFun.Values) {
624 if (ValueTab.size() <= CurFun.NextValNum)
625 ValueTab.resize(CurFun.NextValNum+1);
626 ValueTab[CurFun.NextValNum++] = V;
627 return;
628 }
629 // For all other lists, its okay to just tack it on the back of the vector.
630 ValueTab.push_back(V);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000631}
632
633static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
634 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000635 case ValID::LocalID: // Is it a numbered definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000636 // Module constants occupy the lowest numbered slots...
Reid Spencer41dff5e2007-01-26 08:05:27 +0000637 if (D.Num < CurModule.Types.size())
638 return CurModule.Types[D.Num];
Reid Spencer68a24bd2005-08-27 18:50:39 +0000639 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000640 case ValID::LocalName: // Is it a named definition?
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000641 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.getName())) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000642 D.destroy(); // Free old strdup'd memory...
643 return N;
644 }
645 break;
646 default:
Reid Spencerb5334b02007-02-05 10:18:06 +0000647 GenerateError("Internal parser error: Invalid symbol type reference");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000648 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000649 }
650
651 // If we reached here, we referenced either a symbol that we don't know about
652 // or an id number that hasn't been read yet. We may be referencing something
653 // forward, so just create an entry to be resolved later and get to it...
654 //
655 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
656
657
658 if (inFunctionScope()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000659 if (D.Type == ValID::LocalName) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000660 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000661 return 0;
662 } else {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000663 GenerateError("Reference to an undefined type: #" + utostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000664 return 0;
665 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000666 }
667
Reid Spencer861d9d62006-11-28 07:29:44 +0000668 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000669 if (I != CurModule.LateResolveTypes.end())
Reid Spencer861d9d62006-11-28 07:29:44 +0000670 return I->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000671
Reid Spencer861d9d62006-11-28 07:29:44 +0000672 Type *Typ = OpaqueType::get();
673 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
674 return Typ;
Reid Spencera132e042006-12-03 05:46:11 +0000675 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000676
Reid Spencer93c40032007-03-19 18:40:50 +0000677// getExistingVal - Look up the value specified by the provided type and
Reid Spencer68a24bd2005-08-27 18:50:39 +0000678// the provided ValID. If the value exists and has already been defined, return
679// it. Otherwise return null.
680//
Reid Spencer93c40032007-03-19 18:40:50 +0000681static Value *getExistingVal(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000682 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000683 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000684 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000685 return 0;
686 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000687
688 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000689 case ValID::LocalID: { // Is it a numbered definition?
Reid Spencer41dff5e2007-01-26 08:05:27 +0000690 // Check that the number is within bounds.
Reid Spencer93c40032007-03-19 18:40:50 +0000691 if (D.Num >= CurFun.Values.size())
692 return 0;
693 Value *Result = CurFun.Values[D.Num];
694 if (Ty != Result->getType()) {
695 GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" +
696 Result->getType()->getDescription() + "' does not match "
697 "expected type, '" + Ty->getDescription() + "'");
698 return 0;
699 }
700 return Result;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000701 }
702 case ValID::GlobalID: { // Is it a numbered definition?
Reid Spencer93c40032007-03-19 18:40:50 +0000703 if (D.Num >= CurModule.Values.size())
Reid Spenceref9b9a72007-02-05 20:47:22 +0000704 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000705 Value *Result = CurModule.Values[D.Num];
706 if (Ty != Result->getType()) {
707 GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" +
708 Result->getType()->getDescription() + "' does not match "
709 "expected type, '" + Ty->getDescription() + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +0000710 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000711 }
712 return Result;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000713 }
Reid Spencer41dff5e2007-01-26 08:05:27 +0000714
715 case ValID::LocalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000716 if (!inFunctionScope())
717 return 0;
718 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000719 Value *N = SymTab.lookup(D.getName());
Reid Spenceref9b9a72007-02-05 20:47:22 +0000720 if (N == 0)
721 return 0;
722 if (N->getType() != Ty)
723 return 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000724
725 D.destroy(); // Free old strdup'd memory...
726 return N;
727 }
728 case ValID::GlobalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000729 ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000730 Value *N = SymTab.lookup(D.getName());
Reid Spenceref9b9a72007-02-05 20:47:22 +0000731 if (N == 0)
732 return 0;
733 if (N->getType() != Ty)
734 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000735
736 D.destroy(); // Free old strdup'd memory...
737 return N;
738 }
739
740 // Check to make sure that "Ty" is an integral type, and that our
741 // value will fit into the specified type...
742 case ValID::ConstSIntVal: // Is it a constant pool reference??
Reid Spencerb83eb642006-10-20 07:07:24 +0000743 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000744 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000745 itostr(D.ConstPool64) + "' is invalid for type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000746 Ty->getDescription() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000747 return 0;
748 }
Reid Spencer49d273e2007-03-19 20:40:51 +0000749 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000750
751 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Reid Spencerb83eb642006-10-20 07:07:24 +0000752 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
753 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000754 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
Reid Spencerb5334b02007-02-05 10:18:06 +0000755 "' is invalid or out of range");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000756 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000757 } else { // This is really a signed reference. Transmogrify.
Reid Spencer49d273e2007-03-19 20:40:51 +0000758 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000759 }
760 } else {
Reid Spencerb83eb642006-10-20 07:07:24 +0000761 return ConstantInt::get(Ty, D.UConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000762 }
763
764 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Dale Johannesencdd509a2007-09-07 21:07:57 +0000765 if (!ConstantFP::isValueValidForType(Ty, *D.ConstPoolFP)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000766 GenerateError("FP constant invalid for type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000767 return 0;
768 }
Dale Johannesenc72cd7e2007-09-11 18:33:39 +0000769 // Lexer has no type info, so builds all float and double FP constants
770 // as double. Fix this here. Long double does not need this.
771 if (&D.ConstPoolFP->getSemantics() == &APFloat::IEEEdouble &&
772 Ty==Type::FloatTy)
Dale Johannesencdd509a2007-09-07 21:07:57 +0000773 D.ConstPoolFP->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
774 return ConstantFP::get(Ty, *D.ConstPoolFP);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000775
776 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000777 if (!isa<PointerType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000778 GenerateError("Cannot create a a non pointer null");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000779 return 0;
780 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000781 return ConstantPointerNull::get(cast<PointerType>(Ty));
782
783 case ValID::ConstUndefVal: // Is it an undef value?
784 return UndefValue::get(Ty);
785
Chris Lattner7aa61892005-12-21 17:53:23 +0000786 case ValID::ConstZeroVal: // Is it a zero value?
787 return Constant::getNullValue(Ty);
788
Reid Spencer68a24bd2005-08-27 18:50:39 +0000789 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000790 if (D.ConstantValue->getType() != Ty) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000791 GenerateError("Constant expression type different from required type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000792 return 0;
793 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000794 return D.ConstantValue;
795
Chris Lattner0e9c3762006-01-25 22:27:16 +0000796 case ValID::InlineAsmVal: { // Inline asm expression
797 const PointerType *PTy = dyn_cast<PointerType>(Ty);
798 const FunctionType *FTy =
799 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000800 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000801 GenerateError("Invalid type for asm constraint string");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000802 return 0;
803 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000804 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
805 D.IAD->HasSideEffects);
806 D.destroy(); // Free InlineAsmDescriptor.
807 return IA;
808 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000809 default:
Reid Spencera9720f52007-02-05 17:04:00 +0000810 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000811 return 0;
812 } // End of switch
813
Reid Spencera9720f52007-02-05 17:04:00 +0000814 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000815 return 0;
816}
817
Reid Spencer93c40032007-03-19 18:40:50 +0000818// getVal - This function is identical to getExistingVal, except that if a
Reid Spencer68a24bd2005-08-27 18:50:39 +0000819// value is not already defined, it "improvises" by creating a placeholder var
820// that looks and acts just like the requested variable. When the value is
821// defined later, all uses of the placeholder variable are replaced with the
822// real thing.
823//
824static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000825 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000826 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000827 return 0;
828 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000829
830 // See if the value has already been defined.
Reid Spencer93c40032007-03-19 18:40:50 +0000831 Value *V = getExistingVal(Ty, ID);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000832 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000833 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000834
Reid Spencer5b7e7532006-09-28 19:28:24 +0000835 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000836 GenerateError("Invalid use of a composite type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000837 return 0;
838 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000839
840 // If we reached here, we referenced either a symbol that we don't know about
841 // or an id number that hasn't been read yet. We may be referencing something
842 // forward, so just create an entry to be resolved later and get to it...
843 //
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000844 switch (ID.Type) {
845 case ValID::GlobalName:
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000846 case ValID::GlobalID: {
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000847 const PointerType *PTy = dyn_cast<PointerType>(Ty);
848 if (!PTy) {
849 GenerateError("Invalid type for reference to global" );
850 return 0;
851 }
852 const Type* ElTy = PTy->getElementType();
853 if (const FunctionType *FTy = dyn_cast<FunctionType>(ElTy))
854 V = new Function(FTy, GlobalValue::ExternalLinkage);
855 else
856 V = new GlobalVariable(ElTy, false, GlobalValue::ExternalLinkage);
857 break;
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000858 }
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000859 default:
860 V = new Argument(Ty);
861 }
862
Reid Spencer68a24bd2005-08-27 18:50:39 +0000863 // Remember where this forward reference came from. FIXME, shouldn't we try
864 // to recycle these things??
865 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
Duncan Sandsdc024672007-11-27 13:23:08 +0000866 LLLgetLineNo())));
Reid Spencer68a24bd2005-08-27 18:50:39 +0000867
868 if (inFunctionScope())
869 InsertValue(V, CurFun.LateResolveValues);
870 else
871 InsertValue(V, CurModule.LateResolveValues);
872 return V;
873}
874
Reid Spencer93c40032007-03-19 18:40:50 +0000875/// defineBBVal - This is a definition of a new basic block with the specified
876/// identifier which must be the same as CurFun.NextValNum, if its numeric.
877static BasicBlock *defineBBVal(const ValID &ID) {
Reid Spencera9720f52007-02-05 17:04:00 +0000878 assert(inFunctionScope() && "Can't get basic block at global scope!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000879
Reid Spencer68a24bd2005-08-27 18:50:39 +0000880 BasicBlock *BB = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000881
Reid Spencer93c40032007-03-19 18:40:50 +0000882 // First, see if this was forward referenced
Reid Spencer68a24bd2005-08-27 18:50:39 +0000883
Reid Spencer93c40032007-03-19 18:40:50 +0000884 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
885 if (BBI != CurFun.BBForwardRefs.end()) {
886 BB = BBI->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000887 // The forward declaration could have been inserted anywhere in the
888 // function: insert it into the correct place now.
889 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
890 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
Reid Spencer93c40032007-03-19 18:40:50 +0000891
Reid Spencer66728ef2007-03-20 01:13:36 +0000892 // We're about to erase the entry, save the key so we can clean it up.
893 ValID Tmp = BBI->first;
894
Reid Spencer93c40032007-03-19 18:40:50 +0000895 // Erase the forward ref from the map as its no longer "forward"
896 CurFun.BBForwardRefs.erase(ID);
897
Reid Spencer66728ef2007-03-20 01:13:36 +0000898 // The key has been removed from the map but so we don't want to leave
899 // strdup'd memory around so destroy it too.
900 Tmp.destroy();
901
Reid Spencer93c40032007-03-19 18:40:50 +0000902 // If its a numbered definition, bump the number and set the BB value.
903 if (ID.Type == ValID::LocalID) {
904 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
905 InsertValue(BB);
906 }
907
908 ID.destroy();
909 return BB;
910 }
911
912 // We haven't seen this BB before and its first mention is a definition.
913 // Just create it and return it.
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000914 std::string Name (ID.Type == ValID::LocalName ? ID.getName() : "");
Reid Spencer93c40032007-03-19 18:40:50 +0000915 BB = new BasicBlock(Name, CurFun.CurrentFunction);
916 if (ID.Type == ValID::LocalID) {
917 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
918 InsertValue(BB);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000919 }
Reid Spencer93c40032007-03-19 18:40:50 +0000920
921 ID.destroy(); // Free strdup'd memory
922 return BB;
923}
924
925/// getBBVal - get an existing BB value or create a forward reference for it.
926///
927static BasicBlock *getBBVal(const ValID &ID) {
928 assert(inFunctionScope() && "Can't get basic block at global scope!");
929
930 BasicBlock *BB = 0;
931
932 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
933 if (BBI != CurFun.BBForwardRefs.end()) {
934 BB = BBI->second;
935 } if (ID.Type == ValID::LocalName) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000936 std::string Name = ID.getName();
Reid Spencer93c40032007-03-19 18:40:50 +0000937 Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
938 if (N)
939 if (N->getType()->getTypeID() == Type::LabelTyID)
940 BB = cast<BasicBlock>(N);
941 else
942 GenerateError("Reference to label '" + Name + "' is actually of type '"+
943 N->getType()->getDescription() + "'");
944 } else if (ID.Type == ValID::LocalID) {
945 if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) {
946 if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID)
947 BB = cast<BasicBlock>(CurFun.Values[ID.Num]);
948 else
949 GenerateError("Reference to label '%" + utostr(ID.Num) +
950 "' is actually of type '"+
951 CurFun.Values[ID.Num]->getType()->getDescription() + "'");
952 }
953 } else {
954 GenerateError("Illegal label reference " + ID.getName());
955 return 0;
956 }
957
958 // If its already been defined, return it now.
959 if (BB) {
960 ID.destroy(); // Free strdup'd memory.
961 return BB;
962 }
963
964 // Otherwise, this block has not been seen before, create it.
965 std::string Name;
966 if (ID.Type == ValID::LocalName)
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000967 Name = ID.getName();
Reid Spencer93c40032007-03-19 18:40:50 +0000968 BB = new BasicBlock(Name, CurFun.CurrentFunction);
969
970 // Insert it in the forward refs map.
971 CurFun.BBForwardRefs[ID] = BB;
972
Reid Spencer68a24bd2005-08-27 18:50:39 +0000973 return BB;
974}
975
976
977//===----------------------------------------------------------------------===//
978// Code to handle forward references in instructions
979//===----------------------------------------------------------------------===//
980//
981// This code handles the late binding needed with statements that reference
982// values not defined yet... for example, a forward branch, or the PHI node for
983// a loop body.
984//
985// This keeps a table (CurFun.LateResolveValues) of all such forward references
986// and back patchs after we are done.
987//
988
989// ResolveDefinitions - If we could not resolve some defs at parsing
990// time (forward branches, phi functions for loops, etc...) resolve the
991// defs now...
992//
993static void
Reid Spencer93c40032007-03-19 18:40:50 +0000994ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000995 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
Reid Spencer93c40032007-03-19 18:40:50 +0000996 while (!LateResolvers.empty()) {
997 Value *V = LateResolvers.back();
998 LateResolvers.pop_back();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000999
Reid Spencer93c40032007-03-19 18:40:50 +00001000 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
1001 CurModule.PlaceHolderInfo.find(V);
1002 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001003
Reid Spencer93c40032007-03-19 18:40:50 +00001004 ValID &DID = PHI->second.first;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001005
Reid Spencer93c40032007-03-19 18:40:50 +00001006 Value *TheRealValue = getExistingVal(V->getType(), DID);
1007 if (TriggerError)
1008 return;
1009 if (TheRealValue) {
1010 V->replaceAllUsesWith(TheRealValue);
1011 delete V;
1012 CurModule.PlaceHolderInfo.erase(PHI);
1013 } else if (FutureLateResolvers) {
1014 // Functions have their unresolved items forwarded to the module late
1015 // resolver table
1016 InsertValue(V, *FutureLateResolvers);
1017 } else {
1018 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
1019 GenerateError("Reference to an invalid definition: '" +DID.getName()+
1020 "' of type '" + V->getType()->getDescription() + "'",
1021 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +00001022 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001023 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00001024 GenerateError("Reference to an invalid definition: #" +
1025 itostr(DID.Num) + " of type '" +
1026 V->getType()->getDescription() + "'",
1027 PHI->second.second);
1028 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001029 }
1030 }
1031 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001032 LateResolvers.clear();
1033}
1034
1035// ResolveTypeTo - A brand new type was just declared. This means that (if
1036// name is not null) things referencing Name can be resolved. Otherwise, things
1037// refering to the number can be resolved. Do this now.
1038//
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001039static void ResolveTypeTo(std::string *Name, const Type *ToTy) {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001040 ValID D;
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001041 if (Name)
1042 D = ValID::createLocalName(*Name);
1043 else
1044 D = ValID::createLocalID(CurModule.Types.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001045
Reid Spencer861d9d62006-11-28 07:29:44 +00001046 std::map<ValID, PATypeHolder>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +00001047 CurModule.LateResolveTypes.find(D);
1048 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer861d9d62006-11-28 07:29:44 +00001049 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001050 CurModule.LateResolveTypes.erase(I);
1051 }
1052}
1053
1054// setValueName - Set the specified value to the name given. The name may be
1055// null potentially, in which case this is a noop. The string passed in is
1056// assumed to be a malloc'd string buffer, and is free'd by this function.
1057//
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001058static void setValueName(Value *V, std::string *NameStr) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001059 if (!NameStr) return;
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001060 std::string Name(*NameStr); // Copy string
1061 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001062
Reid Spencer41dff5e2007-01-26 08:05:27 +00001063 if (V->getType() == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001064 GenerateError("Can't assign name '" + Name+"' to value with void type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001065 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001066 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00001067
Reid Spencera9720f52007-02-05 17:04:00 +00001068 assert(inFunctionScope() && "Must be in function scope!");
Reid Spenceref9b9a72007-02-05 20:47:22 +00001069 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1070 if (ST.lookup(Name)) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001071 GenerateError("Redefinition of value '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001072 V->getType()->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001073 return;
1074 }
1075
1076 // Set the name.
1077 V->setName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001078}
1079
1080/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1081/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +00001082static GlobalVariable *
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001083ParseGlobalVariable(std::string *NameStr,
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001084 GlobalValue::LinkageTypes Linkage,
1085 GlobalValue::VisibilityTypes Visibility,
Chris Lattnerb475c422005-11-12 18:22:38 +00001086 bool isConstantGlobal, const Type *Ty,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001087 Constant *Initializer, bool IsThreadLocal) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001088 if (isa<FunctionType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001089 GenerateError("Cannot declare global vars of function type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001090 return 0;
1091 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001092
1093 const PointerType *PTy = PointerType::get(Ty);
1094
1095 std::string Name;
1096 if (NameStr) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001097 Name = *NameStr; // Copy string
1098 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001099 }
1100
1101 // See if this global value was forward referenced. If so, recycle the
1102 // object.
1103 ValID ID;
1104 if (!Name.empty()) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001105 ID = ValID::createGlobalName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001106 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00001107 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001108 }
1109
1110 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1111 // Move the global to the end of the list, from whereever it was
1112 // previously inserted.
1113 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1114 CurModule.CurrentModule->getGlobalList().remove(GV);
1115 CurModule.CurrentModule->getGlobalList().push_back(GV);
1116 GV->setInitializer(Initializer);
1117 GV->setLinkage(Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001118 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001119 GV->setConstant(isConstantGlobal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001120 GV->setThreadLocal(IsThreadLocal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001121 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001122 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001123 }
1124
Reid Spenceref9b9a72007-02-05 20:47:22 +00001125 // If this global has a name
Reid Spencer68a24bd2005-08-27 18:50:39 +00001126 if (!Name.empty()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00001127 // if the global we're parsing has an initializer (is a definition) and
1128 // has external linkage.
1129 if (Initializer && Linkage != GlobalValue::InternalLinkage)
1130 // If there is already a global with external linkage with this name
1131 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
1132 // If we allow this GVar to get created, it will be renamed in the
1133 // symbol table because it conflicts with an existing GVar. We can't
1134 // allow redefinition of GVars whose linking indicates that their name
1135 // must stay the same. Issue the error.
1136 GenerateError("Redefinition of global variable named '" + Name +
1137 "' of type '" + Ty->getDescription() + "'");
1138 return 0;
1139 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001140 }
1141
1142 // Otherwise there is no existing GV to use, create one now.
1143 GlobalVariable *GV =
1144 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001145 CurModule.CurrentModule, IsThreadLocal);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001146 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001147 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001148 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001149}
1150
1151// setTypeName - Set the specified type to the name given. The name may be
1152// null potentially, in which case this is a noop. The string passed in is
1153// assumed to be a malloc'd string buffer, and is freed by this function.
1154//
1155// This function returns true if the type has already been defined, but is
1156// allowed to be redefined in the specified context. If the name is a new name
1157// for the type plane, it is inserted and false is returned.
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001158static bool setTypeName(const Type *T, std::string *NameStr) {
Reid Spencera9720f52007-02-05 17:04:00 +00001159 assert(!inFunctionScope() && "Can't give types function-local names!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001160 if (NameStr == 0) return false;
1161
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001162 std::string Name(*NameStr); // Copy string
1163 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001164
1165 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +00001166 if (T == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001167 GenerateError("Can't assign name '" + Name + "' to the void type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001168 return false;
1169 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001170
1171 // Set the type name, checking for conflicts as we do so.
1172 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1173
1174 if (AlreadyExists) { // Inserting a name that is already defined???
1175 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
Reid Spencera9720f52007-02-05 17:04:00 +00001176 assert(Existing && "Conflict but no matching type?!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001177
1178 // There is only one case where this is allowed: when we are refining an
1179 // opaque type. In this case, Existing will be an opaque type.
1180 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1181 // We ARE replacing an opaque type!
1182 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1183 return true;
1184 }
1185
1186 // Otherwise, this is an attempt to redefine a type. That's okay if
1187 // the redefinition is identical to the original. This will be so if
1188 // Existing and T point to the same Type object. In this one case we
1189 // allow the equivalent redefinition.
1190 if (Existing == T) return true; // Yes, it's equal.
1191
1192 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer63c34452007-01-05 21:51:07 +00001193 GenerateError("Redefinition of type named '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001194 T->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001195 }
1196
1197 return false;
1198}
1199
1200//===----------------------------------------------------------------------===//
1201// Code for handling upreferences in type names...
1202//
1203
1204// TypeContains - Returns true if Ty directly contains E in it.
1205//
1206static bool TypeContains(const Type *Ty, const Type *E) {
1207 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1208 E) != Ty->subtype_end();
1209}
1210
1211namespace {
1212 struct UpRefRecord {
1213 // NestingLevel - The number of nesting levels that need to be popped before
1214 // this type is resolved.
1215 unsigned NestingLevel;
1216
1217 // LastContainedTy - This is the type at the current binding level for the
1218 // type. Every time we reduce the nesting level, this gets updated.
1219 const Type *LastContainedTy;
1220
1221 // UpRefTy - This is the actual opaque type that the upreference is
1222 // represented with.
1223 OpaqueType *UpRefTy;
1224
1225 UpRefRecord(unsigned NL, OpaqueType *URTy)
1226 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1227 };
1228}
1229
1230// UpRefs - A list of the outstanding upreferences that need to be resolved.
1231static std::vector<UpRefRecord> UpRefs;
1232
1233/// HandleUpRefs - Every time we finish a new layer of types, this function is
1234/// called. It loops through the UpRefs vector, which is a list of the
1235/// currently active types. For each type, if the up reference is contained in
1236/// the newly completed type, we decrement the level count. When the level
1237/// count reaches zero, the upreferenced type is the type that is passed in:
1238/// thus we can complete the cycle.
1239///
1240static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001241 // If Ty isn't abstract, or if there are no up-references in it, then there is
1242 // nothing to resolve here.
1243 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1244
Reid Spencer68a24bd2005-08-27 18:50:39 +00001245 PATypeHolder Ty(ty);
1246 UR_OUT("Type '" << Ty->getDescription() <<
1247 "' newly formed. Resolving upreferences.\n" <<
1248 UpRefs.size() << " upreferences active!\n");
1249
1250 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1251 // to zero), we resolve them all together before we resolve them to Ty. At
1252 // the end of the loop, if there is anything to resolve to Ty, it will be in
1253 // this variable.
1254 OpaqueType *TypeToResolve = 0;
1255
1256 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1257 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1258 << UpRefs[i].second->getDescription() << ") = "
1259 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1260 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1261 // Decrement level of upreference
1262 unsigned Level = --UpRefs[i].NestingLevel;
1263 UpRefs[i].LastContainedTy = Ty;
1264 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1265 if (Level == 0) { // Upreference should be resolved!
1266 if (!TypeToResolve) {
1267 TypeToResolve = UpRefs[i].UpRefTy;
1268 } else {
1269 UR_OUT(" * Resolving upreference for "
1270 << UpRefs[i].second->getDescription() << "\n";
1271 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1272 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1273 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1274 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1275 }
1276 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1277 --i; // Do not skip the next element...
1278 }
1279 }
1280 }
1281
1282 if (TypeToResolve) {
1283 UR_OUT(" * Resolving upreference for "
1284 << UpRefs[i].second->getDescription() << "\n";
1285 std::string OldName = TypeToResolve->getDescription());
1286 TypeToResolve->refineAbstractTypeTo(Ty);
1287 }
1288
1289 return Ty;
1290}
1291
Reid Spencer68a24bd2005-08-27 18:50:39 +00001292//===----------------------------------------------------------------------===//
1293// RunVMAsmParser - Define an interface to this parser
1294//===----------------------------------------------------------------------===//
1295//
Reid Spencer14310612006-12-31 05:40:51 +00001296static Module* RunParser(Module * M);
1297
Duncan Sandsdc024672007-11-27 13:23:08 +00001298Module *llvm::RunVMAsmParser(llvm::MemoryBuffer *MB) {
1299 InitLLLexer(MB);
1300 Module *M = RunParser(new Module(LLLgetFilename()));
1301 FreeLexer();
1302 return M;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001303}
1304
1305
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00001306
1307/* Enabling traces. */
1308#ifndef YYDEBUG
1309# define YYDEBUG 0
1310#endif
1311
1312/* Enabling verbose error messages. */
1313#ifdef YYERROR_VERBOSE
1314# undef YYERROR_VERBOSE
1315# define YYERROR_VERBOSE 1
1316#else
1317# define YYERROR_VERBOSE 0
1318#endif
1319
1320/* Enabling the token table. */
1321#ifndef YYTOKEN_TABLE
1322# define YYTOKEN_TABLE 0
1323#endif
1324
1325#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
1326typedef union YYSTYPE
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00001327#line 945 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00001328{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001329 llvm::Module *ModuleVal;
1330 llvm::Function *FunctionVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001331 llvm::BasicBlock *BasicBlockVal;
1332 llvm::TerminatorInst *TermInstVal;
1333 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001334 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001335
Reid Spencera132e042006-12-03 05:46:11 +00001336 const llvm::Type *PrimType;
Reid Spencer14310612006-12-31 05:40:51 +00001337 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencera132e042006-12-03 05:46:11 +00001338 llvm::PATypeHolder *TypeVal;
1339 llvm::Value *ValueVal;
Reid Spencera132e042006-12-03 05:46:11 +00001340 std::vector<llvm::Value*> *ValueList;
Reid Spencer14310612006-12-31 05:40:51 +00001341 llvm::ArgListType *ArgList;
1342 llvm::TypeWithAttrs TypeWithAttrs;
1343 llvm::TypeWithAttrsList *TypeWithAttrsList;
Dale Johanneseneb57ea72007-11-05 21:20:28 +00001344 llvm::ParamList *ParamList;
Reid Spencer14310612006-12-31 05:40:51 +00001345
Reid Spencer68a24bd2005-08-27 18:50:39 +00001346 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001347 std::list<std::pair<llvm::Value*,
1348 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001349 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001350 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001351
1352 llvm::GlobalValue::LinkageTypes Linkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001353 llvm::GlobalValue::VisibilityTypes Visibility;
Reid Spencer7b5d4662007-04-09 06:16:21 +00001354 uint16_t ParamAttrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00001355 llvm::APInt *APIntVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001356 int64_t SInt64Val;
1357 uint64_t UInt64Val;
1358 int SIntVal;
1359 unsigned UIntVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00001360 llvm::APFloat *FPVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001361 bool BoolVal;
1362
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001363 std::string *StrVal; // This memory must be deleted
1364 llvm::ValID ValIDVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001365
Reid Spencera132e042006-12-03 05:46:11 +00001366 llvm::Instruction::BinaryOps BinaryOpVal;
1367 llvm::Instruction::TermOps TermOpVal;
1368 llvm::Instruction::MemoryOps MemOpVal;
1369 llvm::Instruction::CastOps CastOpVal;
1370 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencera132e042006-12-03 05:46:11 +00001371 llvm::ICmpInst::Predicate IPredicate;
1372 llvm::FCmpInst::Predicate FPredicate;
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00001373}
Duncan Sandsdc024672007-11-27 13:23:08 +00001374/* Line 187 of yacc.c. */
1375#line 1376 "llvmAsmParser.tab.c"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00001376 YYSTYPE;
1377# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1378# define YYSTYPE_IS_DECLARED 1
1379# define YYSTYPE_IS_TRIVIAL 1
Reid Spencer68a24bd2005-08-27 18:50:39 +00001380#endif
1381
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001382
Reid Spencer68a24bd2005-08-27 18:50:39 +00001383
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00001384/* Copy the second part of user declarations. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001385
1386
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00001387/* Line 216 of yacc.c. */
Duncan Sandsdc024672007-11-27 13:23:08 +00001388#line 1389 "llvmAsmParser.tab.c"
Reid Spencerb8f85052007-07-31 03:50:36 +00001389
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00001390#ifdef short
1391# undef short
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001392#endif
1393
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00001394#ifdef YYTYPE_UINT8
1395typedef YYTYPE_UINT8 yytype_uint8;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001396#else
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00001397typedef unsigned char yytype_uint8;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001398#endif
1399
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00001400#ifdef YYTYPE_INT8
1401typedef YYTYPE_INT8 yytype_int8;
1402#elif (defined __STDC__ || defined __C99__FUNC__ \
1403 || defined __cplusplus || defined _MSC_VER)
1404typedef signed char yytype_int8;
1405#else
1406typedef short int yytype_int8;
1407#endif
1408
1409#ifdef YYTYPE_UINT16
1410typedef YYTYPE_UINT16 yytype_uint16;
1411#else
1412typedef unsigned short int yytype_uint16;
1413#endif
1414
1415#ifdef YYTYPE_INT16
1416typedef YYTYPE_INT16 yytype_int16;
1417#else
1418typedef short int yytype_int16;
1419#endif
1420
1421#ifndef YYSIZE_T
1422# ifdef __SIZE_TYPE__
1423# define YYSIZE_T __SIZE_TYPE__
1424# elif defined size_t
1425# define YYSIZE_T size_t
1426# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
1427 || defined __cplusplus || defined _MSC_VER)
1428# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1429# define YYSIZE_T size_t
1430# else
1431# define YYSIZE_T unsigned int
1432# endif
1433#endif
1434
1435#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
1436
1437#ifndef YY_
Duncan Sandsdc024672007-11-27 13:23:08 +00001438# if YYENABLE_NLS
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00001439# if ENABLE_NLS
1440# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1441# define YY_(msgid) dgettext ("bison-runtime", msgid)
1442# endif
1443# endif
1444# ifndef YY_
1445# define YY_(msgid) msgid
1446# endif
1447#endif
1448
1449/* Suppress unused-variable warnings by "using" E. */
1450#if ! defined lint || defined __GNUC__
1451# define YYUSE(e) ((void) (e))
1452#else
1453# define YYUSE(e) /* empty */
1454#endif
1455
1456/* Identity function, used to suppress warnings about constant conditions. */
1457#ifndef lint
1458# define YYID(n) (n)
1459#else
1460#if (defined __STDC__ || defined __C99__FUNC__ \
1461 || defined __cplusplus || defined _MSC_VER)
1462static int
1463YYID (int i)
1464#else
1465static int
1466YYID (i)
1467 int i;
1468#endif
1469{
1470 return i;
1471}
1472#endif
1473
1474#if ! defined yyoverflow || YYERROR_VERBOSE
1475
1476/* The parser invokes alloca or malloc; define the necessary symbols. */
1477
1478# ifdef YYSTACK_USE_ALLOCA
1479# if YYSTACK_USE_ALLOCA
1480# ifdef __GNUC__
1481# define YYSTACK_ALLOC __builtin_alloca
1482# elif defined __BUILTIN_VA_ARG_INCR
1483# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
1484# elif defined _AIX
1485# define YYSTACK_ALLOC __alloca
1486# elif defined _MSC_VER
1487# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
1488# define alloca _alloca
1489# else
1490# define YYSTACK_ALLOC alloca
1491# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1492 || defined __cplusplus || defined _MSC_VER)
1493# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1494# ifndef _STDLIB_H
1495# define _STDLIB_H 1
1496# endif
1497# endif
1498# endif
1499# endif
1500# endif
1501
1502# ifdef YYSTACK_ALLOC
1503 /* Pacify GCC's `empty if-body' warning. */
1504# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
1505# ifndef YYSTACK_ALLOC_MAXIMUM
1506 /* The OS might guarantee only one guard page at the bottom of the stack,
1507 and a page size can be as small as 4096 bytes. So we cannot safely
1508 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1509 to allow for a few compiler-allocated temporary stack slots. */
1510# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
1511# endif
1512# else
1513# define YYSTACK_ALLOC YYMALLOC
1514# define YYSTACK_FREE YYFREE
1515# ifndef YYSTACK_ALLOC_MAXIMUM
1516# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
1517# endif
1518# if (defined __cplusplus && ! defined _STDLIB_H \
1519 && ! ((defined YYMALLOC || defined malloc) \
1520 && (defined YYFREE || defined free)))
1521# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1522# ifndef _STDLIB_H
1523# define _STDLIB_H 1
1524# endif
1525# endif
1526# ifndef YYMALLOC
1527# define YYMALLOC malloc
1528# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1529 || defined __cplusplus || defined _MSC_VER)
1530void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1531# endif
1532# endif
1533# ifndef YYFREE
1534# define YYFREE free
1535# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1536 || defined __cplusplus || defined _MSC_VER)
1537void free (void *); /* INFRINGES ON USER NAME SPACE */
1538# endif
1539# endif
1540# endif
1541#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
1542
1543
1544#if (! defined yyoverflow \
1545 && (! defined __cplusplus \
1546 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
1547
1548/* A type that is properly aligned for any stack member. */
1549union yyalloc
1550{
1551 yytype_int16 yyss;
1552 YYSTYPE yyvs;
1553 };
1554
1555/* The size of the maximum gap between one aligned stack and the next. */
1556# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1557
1558/* The size of an array large to enough to hold all stacks, each with
1559 N elements. */
1560# define YYSTACK_BYTES(N) \
1561 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
1562 + YYSTACK_GAP_MAXIMUM)
1563
1564/* Copy COUNT objects from FROM to TO. The source and destination do
1565 not overlap. */
1566# ifndef YYCOPY
1567# if defined __GNUC__ && 1 < __GNUC__
1568# define YYCOPY(To, From, Count) \
1569 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1570# else
1571# define YYCOPY(To, From, Count) \
1572 do \
1573 { \
1574 YYSIZE_T yyi; \
1575 for (yyi = 0; yyi < (Count); yyi++) \
1576 (To)[yyi] = (From)[yyi]; \
1577 } \
1578 while (YYID (0))
1579# endif
1580# endif
1581
1582/* Relocate STACK from its old location to the new one. The
1583 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1584 elements in the stack, and YYPTR gives the new location of the
1585 stack. Advance YYPTR to a properly aligned location for the next
1586 stack. */
1587# define YYSTACK_RELOCATE(Stack) \
1588 do \
1589 { \
1590 YYSIZE_T yynewbytes; \
1591 YYCOPY (&yyptr->Stack, Stack, yysize); \
1592 Stack = &yyptr->Stack; \
1593 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1594 yyptr += yynewbytes / sizeof (*yyptr); \
1595 } \
1596 while (YYID (0))
1597
1598#endif
1599
1600/* YYFINAL -- State number of the termination state. */
1601#define YYFINAL 43
1602/* YYLAST -- Last index in YYTABLE. */
Duncan Sandsdc024672007-11-27 13:23:08 +00001603#define YYLAST 1816
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00001604
1605/* YYNTOKENS -- Number of terminals. */
1606#define YYNTOKENS 162
1607/* YYNNTS -- Number of nonterminals. */
1608#define YYNNTS 82
1609/* YYNRULES -- Number of rules. */
1610#define YYNRULES 314
1611/* YYNRULES -- Number of states. */
Duncan Sandsdc024672007-11-27 13:23:08 +00001612#define YYNSTATES 608
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00001613
1614/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1615#define YYUNDEFTOK 2
1616#define YYMAXUTOK 402
1617
1618#define YYTRANSLATE(YYX) \
1619 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1620
1621/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1622static const yytype_uint8 yytranslate[] =
1623{
1624 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1625 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1626 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1627 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1628 152, 153, 150, 2, 149, 2, 2, 2, 2, 2,
1629 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1630 157, 148, 158, 2, 2, 2, 2, 2, 2, 2,
1631 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1632 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1633 2, 154, 151, 156, 2, 2, 2, 2, 2, 161,
1634 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1635 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1636 155, 2, 2, 159, 2, 160, 2, 2, 2, 2,
1637 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1638 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1639 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1640 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1641 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1642 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1643 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1644 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1645 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1646 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1647 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1648 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1649 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1650 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1651 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1652 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1653 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1654 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1655 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1656 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1657 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1658 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1659 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
1660 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
1661 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1662 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
1663 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
1664 145, 146, 147
1665};
1666
1667#if YYDEBUG
1668/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1669 YYRHS. */
1670static const yytype_uint16 yyprhs[] =
1671{
1672 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1673 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1674 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1675 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
1676 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
1677 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
1678 119, 121, 123, 125, 127, 129, 130, 133, 134, 136,
1679 138, 140, 141, 144, 146, 148, 150, 152, 154, 156,
1680 158, 160, 161, 163, 165, 167, 168, 170, 172, 173,
1681 175, 177, 179, 181, 182, 184, 186, 187, 189, 191,
1682 193, 195, 197, 200, 202, 204, 206, 208, 210, 212,
1683 214, 216, 218, 219, 222, 224, 226, 228, 230, 232,
1684 234, 235, 238, 239, 242, 243, 247, 250, 251, 253,
1685 254, 258, 260, 263, 265, 267, 269, 271, 273, 275,
1686 277, 279, 281, 284, 286, 289, 295, 301, 307, 313,
1687 317, 320, 326, 331, 334, 336, 338, 340, 344, 346,
1688 350, 352, 353, 355, 359, 364, 368, 372, 377, 382,
1689 386, 393, 399, 402, 405, 408, 411, 414, 417, 420,
1690 423, 426, 429, 432, 435, 442, 448, 457, 464, 471,
1691 479, 487, 494, 503, 512, 516, 518, 520, 522, 524,
1692 525, 528, 535, 537, 538, 540, 543, 544, 548, 549,
1693 553, 557, 561, 565, 566, 574, 575, 584, 585, 594,
1694 600, 603, 607, 609, 613, 617, 621, 625, 627, 628,
1695 634, 638, 640, 644, 646, 647, 657, 659, 661, 666,
1696 668, 670, 673, 677, 678, 680, 682, 684, 686, 688,
1697 690, 692, 694, 696, 700, 702, 708, 710, 712, 714,
1698 716, 718, 720, 723, 726, 729, 733, 736, 737, 739,
1699 742, 745, 749, 759, 769, 778, 793, 795, 797, 804,
Duncan Sandsdc024672007-11-27 13:23:08 +00001700 810, 813, 820, 828, 833, 838, 845, 852, 853, 854,
1701 858, 861, 863, 869, 875, 882, 889, 894, 901, 906,
1702 911, 918, 925, 928, 937, 939, 941, 942, 946, 953,
1703 957, 964, 967, 973, 981
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00001704};
1705
1706/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1707static const yytype_int16 yyrhs[] =
1708{
1709 206, 0, -1, 73, -1, 74, -1, 75, -1, 76,
1710 -1, 77, -1, 78, -1, 79, -1, 80, -1, 81,
1711 -1, 85, -1, 86, -1, 87, -1, 82, -1, 83,
1712 -1, 84, -1, 116, -1, 117, -1, 118, -1, 119,
1713 -1, 120, -1, 121, -1, 122, -1, 123, -1, 124,
1714 -1, 125, -1, 126, -1, 127, -1, 90, -1, 91,
1715 -1, 92, -1, 93, -1, 94, -1, 95, -1, 96,
1716 -1, 97, -1, 98, -1, 99, -1, 100, -1, 101,
1717 -1, 102, -1, 103, -1, 104, -1, 105, -1, 106,
1718 -1, 107, -1, 108, -1, 109, -1, 96, -1, 97,
1719 -1, 98, -1, 99, -1, 26, -1, 27, -1, 11,
1720 -1, 12, -1, 13, -1, 16, -1, 15, -1, 14,
1721 -1, 19, -1, 22, -1, 24, -1, 170, -1, -1,
1722 170, 148, -1, -1, 20, -1, 23, -1, 175, -1,
1723 -1, 173, 148, -1, 42, -1, 44, -1, 43, -1,
1724 45, -1, 47, -1, 46, -1, 48, -1, 50, -1,
1725 -1, 145, -1, 146, -1, 147, -1, -1, 46, -1,
1726 48, -1, -1, 42, -1, 43, -1, 44, -1, 47,
1727 -1, -1, 44, -1, 42, -1, -1, 61, -1, 62,
1728 -1, 63, -1, 64, -1, 65, -1, 60, 4, -1,
1729 135, -1, 117, -1, 134, -1, 118, -1, 137, -1,
1730 138, -1, 140, -1, 141, -1, 142, -1, -1, 184,
1731 183, -1, 136, -1, 139, -1, 135, -1, 134, -1,
Duncan Sandsdc024672007-11-27 13:23:08 +00001732 143, -1, 144, -1, -1, 186, 185, -1, -1, 53,
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00001733 4, -1, -1, 149, 53, 4, -1, 34, 22, -1,
1734 -1, 189, -1, -1, 149, 192, 191, -1, 189, -1,
1735 53, 4, -1, 11, -1, 12, -1, 13, -1, 16,
1736 -1, 15, -1, 14, -1, 17, -1, 49, -1, 193,
1737 -1, 194, 150, -1, 228, -1, 151, 4, -1, 194,
1738 152, 198, 153, 186, -1, 10, 152, 198, 153, 186,
1739 -1, 154, 4, 155, 194, 156, -1, 157, 4, 155,
1740 194, 158, -1, 159, 199, 160, -1, 159, 160, -1,
1741 157, 159, 199, 160, 158, -1, 157, 159, 160, 158,
1742 -1, 194, 184, -1, 194, -1, 10, -1, 195, -1,
1743 197, 149, 195, -1, 197, -1, 197, 149, 39, -1,
1744 39, -1, -1, 194, -1, 199, 149, 194, -1, 194,
1745 154, 202, 156, -1, 194, 154, 156, -1, 194, 161,
1746 22, -1, 194, 157, 202, 158, -1, 194, 159, 202,
1747 160, -1, 194, 159, 160, -1, 194, 157, 159, 202,
1748 160, 158, -1, 194, 157, 159, 160, 158, -1, 194,
1749 40, -1, 194, 41, -1, 194, 228, -1, 194, 201,
1750 -1, 194, 25, -1, 168, 3, -1, 168, 5, -1,
1751 168, 4, -1, 168, 6, -1, 11, 26, -1, 11,
1752 27, -1, 169, 9, -1, 165, 152, 200, 38, 194,
1753 153, -1, 115, 152, 200, 239, 153, -1, 129, 152,
1754 200, 149, 200, 149, 200, 153, -1, 163, 152, 200,
1755 149, 200, 153, -1, 164, 152, 200, 149, 200, 153,
1756 -1, 88, 166, 152, 200, 149, 200, 153, -1, 89,
1757 167, 152, 200, 149, 200, 153, -1, 131, 152, 200,
1758 149, 200, 153, -1, 132, 152, 200, 149, 200, 149,
1759 200, 153, -1, 133, 152, 200, 149, 200, 149, 200,
1760 153, -1, 202, 149, 200, -1, 200, -1, 32, -1,
1761 33, -1, 37, -1, -1, 196, 228, -1, 121, 152,
1762 205, 38, 194, 153, -1, 207, -1, -1, 208, -1,
1763 207, 208, -1, -1, 31, 209, 224, -1, -1, 30,
1764 210, 225, -1, 58, 57, 214, -1, 172, 18, 194,
1765 -1, 172, 18, 10, -1, -1, 174, 178, 204, 203,
1766 200, 211, 191, -1, -1, 174, 176, 178, 204, 203,
1767 200, 212, 191, -1, -1, 174, 177, 178, 204, 203,
1768 194, 213, 191, -1, 174, 178, 35, 181, 205, -1,
1769 51, 215, -1, 54, 148, 216, -1, 22, -1, 52,
1770 148, 22, -1, 66, 148, 22, -1, 154, 217, 156,
1771 -1, 217, 149, 22, -1, 22, -1, -1, 218, 149,
1772 194, 184, 171, -1, 194, 184, 171, -1, 218, -1,
1773 218, 149, 39, -1, 39, -1, -1, 182, 196, 173,
1774 152, 219, 153, 186, 190, 187, -1, 28, -1, 159,
1775 -1, 180, 178, 220, 221, -1, 29, -1, 160, -1,
1776 231, 223, -1, 179, 178, 220, -1, -1, 59, -1,
1777 3, -1, 4, -1, 9, -1, 26, -1, 27, -1,
1778 40, -1, 41, -1, 25, -1, 157, 202, 158, -1,
1779 201, -1, 57, 226, 22, 149, 22, -1, 7, -1,
1780 8, -1, 170, -1, 173, -1, 228, -1, 227, -1,
1781 194, 229, -1, 231, 232, -1, 222, 232, -1, 233,
1782 172, 234, -1, 233, 236, -1, -1, 21, -1, 67,
1783 230, -1, 67, 10, -1, 68, 17, 229, -1, 68,
1784 11, 229, 149, 17, 229, 149, 17, 229, -1, 69,
1785 168, 229, 149, 17, 229, 154, 235, 156, -1, 69,
1786 168, 229, 149, 17, 229, 154, 156, -1, 70, 182,
1787 196, 229, 152, 238, 153, 186, 38, 17, 229, 71,
1788 17, 229, -1, 71, -1, 72, -1, 235, 168, 227,
1789 149, 17, 229, -1, 168, 227, 149, 17, 229, -1,
1790 172, 241, -1, 194, 154, 229, 149, 229, 156, -1,
Duncan Sandsdc024672007-11-27 13:23:08 +00001791 237, 149, 154, 229, 149, 229, 156, -1, 194, 184,
1792 229, 184, -1, 17, 184, 229, 184, -1, 238, 149,
1793 194, 184, 229, 184, -1, 238, 149, 17, 184, 229,
1794 184, -1, -1, -1, 239, 149, 230, -1, 56, 55,
1795 -1, 55, -1, 163, 194, 229, 149, 229, -1, 164,
1796 194, 229, 149, 229, -1, 88, 166, 194, 229, 149,
1797 229, -1, 89, 167, 194, 229, 149, 229, -1, 165,
1798 230, 38, 194, -1, 129, 230, 149, 230, 149, 230,
1799 -1, 130, 230, 149, 194, -1, 131, 230, 149, 230,
1800 -1, 132, 230, 149, 230, 149, 230, -1, 133, 230,
1801 149, 230, 149, 230, -1, 128, 237, -1, 240, 182,
1802 196, 229, 152, 238, 153, 186, -1, 243, -1, 36,
1803 -1, -1, 110, 194, 188, -1, 110, 194, 149, 11,
1804 229, 188, -1, 111, 194, 188, -1, 111, 194, 149,
1805 11, 229, 188, -1, 112, 230, -1, 242, 113, 194,
1806 229, 188, -1, 242, 114, 230, 149, 194, 229, 188,
1807 -1, 115, 194, 229, 239, -1
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00001808};
1809
1810/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1811static const yytype_uint16 yyrline[] =
1812{
Duncan Sandsdc024672007-11-27 13:23:08 +00001813 0, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105,
1814 1105, 1106, 1106, 1106, 1106, 1106, 1106, 1107, 1107, 1107,
1815 1107, 1107, 1107, 1108, 1108, 1108, 1108, 1108, 1108, 1111,
1816 1111, 1112, 1112, 1113, 1113, 1114, 1114, 1115, 1115, 1119,
1817 1119, 1120, 1120, 1121, 1121, 1122, 1122, 1123, 1123, 1124,
1818 1124, 1125, 1125, 1126, 1127, 1132, 1133, 1133, 1133, 1133,
1819 1133, 1135, 1135, 1135, 1136, 1136, 1140, 1144, 1149, 1149,
1820 1151, 1152, 1157, 1163, 1164, 1165, 1166, 1167, 1171, 1172,
1821 1173, 1177, 1178, 1179, 1180, 1184, 1185, 1186, 1190, 1191,
1822 1192, 1193, 1194, 1198, 1199, 1200, 1203, 1204, 1205, 1206,
1823 1207, 1208, 1209, 1216, 1217, 1218, 1219, 1220, 1221, 1222,
1824 1223, 1224, 1227, 1228, 1233, 1234, 1235, 1236, 1237, 1238,
1825 1241, 1242, 1249, 1250, 1256, 1257, 1265, 1273, 1274, 1279,
1826 1280, 1281, 1286, 1299, 1299, 1299, 1299, 1299, 1299, 1299,
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00001827 1302, 1306, 1310, 1317, 1322, 1330, 1356, 1378, 1383, 1393,
1828 1403, 1407, 1417, 1424, 1433, 1440, 1445, 1450, 1457, 1458,
1829 1465, 1472, 1480, 1486, 1498, 1526, 1542, 1569, 1597, 1623,
1830 1643, 1669, 1689, 1701, 1708, 1774, 1784, 1794, 1800, 1810,
1831 1816, 1826, 1831, 1836, 1849, 1861, 1883, 1891, 1897, 1908,
1832 1913, 1918, 1924, 1930, 1939, 1943, 1951, 1951, 1954, 1954,
1833 1957, 1969, 1990, 1995, 2003, 2004, 2008, 2008, 2012, 2012,
1834 2015, 2018, 2042, 2053, 2053, 2064, 2063, 2073, 2072, 2083,
1835 2123, 2126, 2132, 2142, 2146, 2151, 2153, 2158, 2163, 2172,
1836 2182, 2193, 2197, 2206, 2215, 2220, 2350, 2350, 2352, 2361,
1837 2361, 2363, 2368, 2380, 2384, 2389, 2393, 2397, 2401, 2405,
1838 2409, 2413, 2417, 2421, 2446, 2450, 2460, 2464, 2468, 2473,
1839 2480, 2480, 2486, 2495, 2499, 2508, 2517, 2526, 2530, 2537,
1840 2541, 2545, 2550, 2560, 2579, 2588, 2672, 2676, 2683, 2694,
1841 2707, 2717, 2728, 2738, 2749, 2757, 2767, 2774, 2777, 2778,
1842 2785, 2789, 2794, 2810, 2827, 2841, 2855, 2867, 2875, 2882,
1843 2888, 2894, 2900, 2915, 3006, 3011, 3015, 3022, 3029, 3037,
1844 3044, 3052, 3060, 3074, 3091
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00001845};
1846#endif
1847
1848#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1849/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1850 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1851static const char *const yytname[] =
1852{
1853 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "ESAPINTVAL",
1854 "EUAPINTVAL", "LOCALVAL_ID", "GLOBALVAL_ID", "FPVAL", "VOID", "INTTYPE",
1855 "FLOAT", "DOUBLE", "X86_FP80", "FP128", "PPC_FP128", "LABEL", "TYPE",
1856 "LOCALVAR", "GLOBALVAR", "LABELSTR", "STRINGCONSTANT",
1857 "ATSTRINGCONSTANT", "PCTSTRINGCONSTANT", "ZEROINITIALIZER", "TRUETOK",
1858 "FALSETOK", "BEGINTOK", "ENDTOK", "DECLARE", "DEFINE", "GLOBAL",
1859 "CONSTANT", "SECTION", "ALIAS", "VOLATILE", "THREAD_LOCAL", "TO",
1860 "DOTDOTDOT", "NULL_TOK", "UNDEF", "INTERNAL", "LINKONCE", "WEAK",
1861 "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
1862 "EXTERNAL", "TARGET", "TRIPLE", "ALIGN", "DEPLIBS", "CALL", "TAIL",
1863 "ASM_TOK", "MODULE", "SIDEEFFECT", "CC_TOK", "CCC_TOK", "FASTCC_TOK",
1864 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
1865 "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE", "ADD", "SUB",
1866 "MUL", "UDIV", "SDIV", "FDIV", "UREM", "SREM", "FREM", "AND", "OR",
1867 "XOR", "SHL", "LSHR", "ASHR", "ICMP", "FCMP", "EQ", "NE", "SLT", "SGT",
1868 "SLE", "SGE", "ULT", "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT",
1869 "OLE", "OGE", "ORD", "UNO", "UEQ", "UNE", "MALLOC", "ALLOCA", "FREE",
1870 "LOAD", "STORE", "GETELEMENTPTR", "TRUNC", "ZEXT", "SEXT", "FPTRUNC",
1871 "FPEXT", "BITCAST", "UITOFP", "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR",
1872 "PTRTOINT", "PHI_TOK", "SELECT", "VAARG", "EXTRACTELEMENT",
1873 "INSERTELEMENT", "SHUFFLEVECTOR", "SIGNEXT", "ZEROEXT", "NORETURN",
Duncan Sandsdc024672007-11-27 13:23:08 +00001874 "INREG", "SRET", "NOUNWIND", "NOALIAS", "BYVAL", "NEST", "READNONE",
1875 "READONLY", "DEFAULT", "HIDDEN", "PROTECTED", "'='", "','", "'*'",
1876 "'\\\\'", "'('", "')'", "'['", "'x'", "']'", "'<'", "'>'", "'{'", "'}'",
1877 "'c'", "$accept", "ArithmeticOps", "LogicalOps", "CastOps",
1878 "IPredicates", "FPredicates", "IntType", "FPType", "LocalName",
1879 "OptLocalName", "OptLocalAssign", "GlobalName", "OptGlobalAssign",
1880 "GlobalAssign", "GVInternalLinkage", "GVExternalLinkage",
1881 "GVVisibilityStyle", "FunctionDeclareLinkage", "FunctionDefineLinkage",
1882 "AliasLinkage", "OptCallingConv", "ParamAttr", "OptParamAttrs",
1883 "FuncAttr", "OptFuncAttrs", "OptAlign", "OptCAlign", "SectionString",
1884 "OptSection", "GlobalVarAttributes", "GlobalVarAttribute", "PrimType",
1885 "Types", "ArgType", "ResultTypes", "ArgTypeList", "ArgTypeListI",
1886 "TypeListI", "ConstVal", "ConstExpr", "ConstVector", "GlobalType",
1887 "ThreadLocal", "AliaseeRef", "Module", "DefinitionList", "Definition",
1888 "@1", "@2", "@3", "@4", "@5", "AsmBlock", "TargetDefinition",
1889 "LibrariesDefinition", "LibList", "ArgListH", "ArgList",
1890 "FunctionHeaderH", "BEGIN", "FunctionHeader", "END", "Function",
1891 "FunctionProto", "OptSideEffect", "ConstValueRef", "SymbolicValueRef",
1892 "ValueRef", "ResolvedVal", "BasicBlockList", "BasicBlock",
1893 "InstructionList", "BBTerminatorInst", "JumpTable", "Inst", "PHIList",
1894 "ParamList", "IndexList", "OptTailCall", "InstVal", "OptVolatile",
1895 "MemoryInst", 0
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00001896};
1897#endif
1898
1899# ifdef YYPRINT
1900/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1901 token YYLEX-NUM. */
1902static const yytype_uint16 yytoknum[] =
1903{
1904 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1905 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1906 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1907 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1908 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1909 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1910 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1911 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1912 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1913 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1914 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
1915 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
1916 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
1917 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
1918 395, 396, 397, 398, 399, 400, 401, 402, 61, 44,
1919 42, 92, 40, 41, 91, 120, 93, 60, 62, 123,
1920 125, 99
1921};
1922# endif
1923
1924/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1925static const yytype_uint8 yyr1[] =
1926{
1927 0, 162, 163, 163, 163, 163, 163, 163, 163, 163,
1928 163, 164, 164, 164, 164, 164, 164, 165, 165, 165,
1929 165, 165, 165, 165, 165, 165, 165, 165, 165, 166,
1930 166, 166, 166, 166, 166, 166, 166, 166, 166, 167,
1931 167, 167, 167, 167, 167, 167, 167, 167, 167, 167,
1932 167, 167, 167, 167, 167, 168, 169, 169, 169, 169,
1933 169, 170, 170, 170, 171, 171, 172, 172, 173, 173,
1934 174, 174, 175, 176, 176, 176, 176, 176, 177, 177,
1935 177, 178, 178, 178, 178, 179, 179, 179, 180, 180,
1936 180, 180, 180, 181, 181, 181, 182, 182, 182, 182,
1937 182, 182, 182, 183, 183, 183, 183, 183, 183, 183,
1938 183, 183, 184, 184, 185, 185, 185, 185, 185, 185,
1939 186, 186, 187, 187, 188, 188, 189, 190, 190, 191,
1940 191, 192, 192, 193, 193, 193, 193, 193, 193, 193,
1941 194, 194, 194, 194, 194, 194, 194, 194, 194, 194,
1942 194, 194, 194, 195, 196, 196, 197, 197, 198, 198,
1943 198, 198, 199, 199, 200, 200, 200, 200, 200, 200,
1944 200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
1945 200, 200, 200, 200, 201, 201, 201, 201, 201, 201,
1946 201, 201, 201, 201, 202, 202, 203, 203, 204, 204,
1947 205, 205, 206, 206, 207, 207, 209, 208, 210, 208,
1948 208, 208, 208, 211, 208, 212, 208, 213, 208, 208,
1949 208, 208, 214, 215, 215, 216, 217, 217, 217, 218,
1950 218, 219, 219, 219, 219, 220, 221, 221, 222, 223,
1951 223, 224, 225, 226, 226, 227, 227, 227, 227, 227,
1952 227, 227, 227, 227, 227, 227, 228, 228, 228, 228,
1953 229, 229, 230, 231, 231, 232, 233, 233, 233, 234,
1954 234, 234, 234, 234, 234, 234, 234, 234, 235, 235,
1955 236, 237, 237, 238, 238, 238, 238, 238, 239, 239,
1956 240, 240, 241, 241, 241, 241, 241, 241, 241, 241,
1957 241, 241, 241, 241, 241, 242, 242, 243, 243, 243,
1958 243, 243, 243, 243, 243
1959};
1960
1961/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
1962static const yytype_uint8 yyr2[] =
1963{
1964 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1965 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1966 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1967 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1968 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1969 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1970 1, 1, 1, 1, 1, 0, 2, 0, 1, 1,
1971 1, 0, 2, 1, 1, 1, 1, 1, 1, 1,
1972 1, 0, 1, 1, 1, 0, 1, 1, 0, 1,
1973 1, 1, 1, 0, 1, 1, 0, 1, 1, 1,
1974 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
1975 1, 1, 0, 2, 1, 1, 1, 1, 1, 1,
1976 0, 2, 0, 2, 0, 3, 2, 0, 1, 0,
1977 3, 1, 2, 1, 1, 1, 1, 1, 1, 1,
1978 1, 1, 2, 1, 2, 5, 5, 5, 5, 3,
1979 2, 5, 4, 2, 1, 1, 1, 3, 1, 3,
1980 1, 0, 1, 3, 4, 3, 3, 4, 4, 3,
1981 6, 5, 2, 2, 2, 2, 2, 2, 2, 2,
1982 2, 2, 2, 2, 6, 5, 8, 6, 6, 7,
1983 7, 6, 8, 8, 3, 1, 1, 1, 1, 0,
1984 2, 6, 1, 0, 1, 2, 0, 3, 0, 3,
1985 3, 3, 3, 0, 7, 0, 8, 0, 8, 5,
1986 2, 3, 1, 3, 3, 3, 3, 1, 0, 5,
1987 3, 1, 3, 1, 0, 9, 1, 1, 4, 1,
1988 1, 2, 3, 0, 1, 1, 1, 1, 1, 1,
1989 1, 1, 1, 3, 1, 5, 1, 1, 1, 1,
1990 1, 1, 2, 2, 2, 3, 2, 0, 1, 2,
1991 2, 3, 9, 9, 8, 14, 1, 1, 6, 5,
Duncan Sandsdc024672007-11-27 13:23:08 +00001992 2, 6, 7, 4, 4, 6, 6, 0, 0, 3,
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00001993 2, 1, 5, 5, 6, 6, 4, 6, 4, 4,
1994 6, 6, 2, 8, 1, 1, 0, 3, 6, 3,
1995 6, 2, 5, 7, 4
1996};
1997
1998/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
1999 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
2000 means the default is an error. */
2001static const yytype_uint16 yydefact[] =
2002{
2003 71, 61, 68, 62, 69, 63, 208, 206, 0, 0,
2004 0, 0, 0, 0, 81, 70, 0, 71, 204, 85,
2005 88, 0, 0, 220, 0, 0, 66, 0, 72, 73,
2006 75, 74, 76, 78, 77, 79, 80, 82, 83, 84,
2007 81, 81, 199, 1, 205, 86, 87, 81, 209, 89,
2008 90, 91, 92, 81, 267, 207, 267, 0, 0, 228,
2009 221, 222, 210, 256, 257, 212, 133, 134, 135, 138,
2010 137, 136, 139, 140, 0, 0, 0, 0, 258, 259,
2011 141, 211, 143, 199, 199, 93, 198, 0, 96, 96,
2012 268, 264, 67, 239, 240, 241, 263, 223, 224, 227,
2013 0, 161, 144, 0, 0, 0, 0, 150, 162, 0,
2014 142, 161, 0, 0, 95, 94, 0, 196, 197, 0,
2015 0, 97, 98, 99, 100, 101, 0, 242, 0, 306,
2016 266, 0, 225, 160, 112, 156, 158, 0, 0, 0,
2017 0, 0, 0, 149, 0, 0, 0, 155, 0, 154,
2018 0, 219, 133, 134, 135, 138, 137, 136, 0, 0,
2019 0, 213, 102, 0, 236, 237, 238, 305, 291, 0,
2020 0, 0, 0, 96, 276, 277, 2, 3, 4, 5,
2021 6, 7, 8, 9, 10, 14, 15, 16, 11, 12,
2022 13, 0, 0, 0, 0, 0, 0, 17, 18, 19,
2023 20, 21, 22, 23, 24, 25, 26, 27, 28, 0,
2024 0, 0, 0, 0, 0, 0, 0, 0, 265, 96,
2025 280, 0, 304, 226, 153, 0, 120, 0, 0, 152,
2026 0, 163, 120, 215, 217, 0, 200, 181, 182, 177,
2027 179, 178, 180, 183, 176, 172, 173, 0, 0, 0,
2028 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2029 0, 175, 174, 129, 0, 290, 270, 0, 269, 0,
2030 0, 55, 0, 0, 29, 30, 31, 32, 33, 34,
2031 35, 36, 37, 38, 0, 53, 54, 49, 50, 51,
2032 52, 39, 40, 41, 42, 43, 44, 45, 46, 47,
2033 48, 0, 124, 124, 311, 0, 0, 302, 0, 0,
2034 0, 0, 0, 0, 0, 0, 0, 0, 0, 104,
2035 106, 105, 103, 107, 108, 109, 110, 111, 113, 159,
2036 157, 146, 147, 148, 151, 145, 129, 129, 0, 0,
2037 0, 0, 0, 0, 0, 0, 165, 195, 0, 0,
2038 0, 169, 0, 166, 0, 0, 0, 0, 214, 234,
2039 245, 246, 247, 252, 248, 249, 250, 251, 243, 0,
2040 254, 261, 260, 262, 0, 271, 0, 0, 0, 0,
2041 0, 307, 0, 309, 288, 0, 0, 0, 0, 0,
2042 0, 0, 0, 0, 0, 0, 0, 0, 117, 116,
Duncan Sandsdc024672007-11-27 13:23:08 +00002043 114, 115, 118, 119, 121, 216, 218, 0, 0, 0,
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002044 288, 0, 0, 0, 0, 0, 164, 150, 162, 0,
2045 167, 168, 0, 0, 0, 0, 0, 131, 129, 233,
2046 112, 231, 0, 244, 0, 0, 0, 0, 0, 0,
2047 0, 0, 0, 0, 314, 0, 0, 0, 298, 299,
2048 0, 0, 0, 0, 296, 0, 124, 0, 0, 0,
2049 0, 0, 0, 0, 0, 0, 194, 171, 0, 0,
2050 0, 0, 126, 132, 130, 65, 0, 120, 0, 253,
2051 0, 0, 287, 0, 0, 124, 125, 124, 0, 0,
2052 0, 0, 0, 0, 292, 293, 287, 0, 312, 0,
2053 201, 0, 0, 185, 0, 0, 0, 0, 170, 0,
2054 0, 0, 64, 230, 232, 112, 127, 0, 0, 0,
Duncan Sandsdc024672007-11-27 13:23:08 +00002055 112, 112, 0, 294, 295, 308, 310, 289, 0, 0,
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002056 297, 300, 301, 0, 124, 0, 0, 0, 191, 0,
2057 0, 187, 188, 184, 65, 128, 122, 255, 0, 0,
Duncan Sandsdc024672007-11-27 13:23:08 +00002058 0, 0, 0, 120, 281, 0, 120, 313, 189, 190,
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002059 0, 0, 0, 229, 0, 235, 0, 274, 0, 0,
Duncan Sandsdc024672007-11-27 13:23:08 +00002060 104, 106, 112, 112, 112, 112, 0, 282, 303, 186,
2061 192, 193, 123, 272, 0, 273, 0, 284, 283, 0,
2062 0, 0, 0, 0, 112, 112, 0, 0, 0, 286,
2063 285, 0, 279, 0, 0, 278, 0, 275
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002064};
2065
2066/* YYDEFGOTO[NTERM-NUM]. */
2067static const yytype_int16 yydefgoto[] =
2068{
2069 -1, 258, 259, 260, 284, 301, 158, 159, 78, 513,
2070 12, 79, 14, 15, 40, 41, 42, 47, 53, 116,
2071 126, 328, 224, 404, 331, 565, 381, 427, 546, 358,
2072 428, 80, 160, 135, 150, 136, 137, 109, 347, 370,
2073 348, 119, 87, 151, 16, 17, 18, 20, 19, 263,
2074 336, 337, 62, 23, 60, 100, 431, 432, 127, 166,
2075 54, 95, 55, 48, 434, 371, 82, 373, 268, 56,
2076 91, 92, 218, 569, 130, 307, 522, 444, 219, 220,
2077 221, 222
2078};
2079
2080/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2081 STATE-NUM. */
Duncan Sandsdc024672007-11-27 13:23:08 +00002082#define YYPACT_NINF -546
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002083static const yytype_int16 yypact[] =
2084{
Duncan Sandsdc024672007-11-27 13:23:08 +00002085 47, -546, -546, -546, -546, -546, -546, -546, -17, -95,
2086 52, -90, 86, 14, 183, -546, 135, 1758, -546, -10,
2087 64, 18, 33, -546, 5, 180, -546, 1341, -546, -546,
2088 -546, -546, -546, -546, -546, -546, -546, -546, -546, -546,
2089 76, 76, 59, -546, -546, -546, -546, 76, -546, -546,
2090 -546, -546, -546, 76, 193, -546, 13, 202, 224, 233,
2091 -546, -546, -546, -546, -546, 111, -546, -546, -546, -546,
2092 -546, -546, -546, -546, 260, 261, 1, 378, -546, -546,
2093 -546, -7, -546, 231, 231, 150, -546, 55, 309, 309,
2094 -546, -546, 100, -546, -546, -546, -546, -546, -546, -546,
2095 -99, 1088, -546, 116, 122, 988, 111, -546, -7, -106,
2096 -546, 1088, 55, 55, -546, -546, 1142, -546, -546, 1359,
2097 274, -546, -546, -546, -546, -546, 1414, -546, -18, 1624,
2098 -546, 257, -546, -546, -7, -546, 131, 128, 1454, 1454,
2099 129, -105, 1454, -546, 136, 1359, 1454, 111, 141, -7,
2100 237, -546, 214, 279, 285, 289, 291, 294, 145, 299,
2101 803, -546, -546, 103, -546, -546, -546, -546, -546, 254,
2102 1512, 57, 301, 309, -546, -546, -546, -546, -546, -546,
2103 -546, -546, -546, -546, -546, -546, -546, -546, -546, -546,
2104 -546, 596, 646, 1454, 1454, 1454, 1454, -546, -546, -546,
2105 -546, -546, -546, -546, -546, -546, -546, -546, -546, 1454,
2106 1454, 1454, 1454, 1454, 1454, 1454, 1454, 1454, -546, 309,
2107 -546, 61, -546, -546, 132, 1182, -546, -57, -69, -546,
2108 155, -7, -546, -546, -7, 1142, -546, -546, -546, -546,
2109 -546, -546, -546, -546, -546, -546, -546, 596, 646, 162,
2110 163, 164, 166, 167, 1242, 1530, 1028, 303, 169, 174,
2111 179, -546, -546, 185, 191, -546, 111, 644, -546, 780,
2112 780, -546, 780, 1414, -546, -546, -546, -546, -546, -546,
2113 -546, -546, -546, -546, 1454, -546, -546, -546, -546, -546,
2114 -546, -546, -546, -546, -546, -546, -546, -546, -546, -546,
2115 -546, 1454, 30, 48, -546, 644, -21, 197, 199, 203,
2116 204, 205, 206, 644, 644, 313, 1414, 1454, 1454, -546,
2117 -546, -546, -546, -546, -546, -546, -546, -546, -546, -546,
2118 -546, 201, -546, -546, -546, 201, 185, 185, 320, 207,
2119 208, 1359, 1359, 1359, 1359, 1359, -546, -546, -65, 1068,
2120 -86, -546, -104, -546, 1359, 1359, 1359, -20, -546, 1261,
2121 -546, -546, -546, -546, -546, -546, -546, -546, 273, 1359,
2122 -546, -546, -546, -546, 217, -546, 218, 780, 644, 644,
2123 8, -546, 11, -546, -546, 780, 221, 1454, 1454, 1454,
2124 1454, 1454, 227, 234, 1454, 780, 644, 235, -546, -546,
2125 -546, -546, -546, -546, -546, -546, -546, 1454, 1359, 1359,
2126 -546, 247, 258, 263, 265, 1359, -546, 259, 803, -101,
2127 -546, -546, 269, 270, 344, 398, 419, -546, 185, -546,
2128 -7, 276, 275, -546, 404, -76, 412, 413, 282, 288,
2129 292, 780, 440, 780, 297, 300, 780, 302, -7, -546,
2130 304, 308, 780, 780, -7, 306, 310, 1454, -35, 311,
2131 314, -73, 1359, 1359, 1359, 1359, -546, -546, 315, 1359,
2132 1359, 1454, -546, -546, -546, 298, 1301, -546, 319, -546,
2133 780, 780, 1570, 780, 780, 310, -546, 310, 1454, 780,
2134 322, 1454, 1454, 1454, -546, -546, 1570, 399, -546, 644,
2135 -546, 1359, 1359, -546, 323, 316, 325, 327, -546, 324,
2136 326, 60, -546, -546, -546, -7, 3, 460, 334, 330,
2137 82, -7, -13, -546, -546, -546, -546, -546, 332, 780,
2138 -546, -546, -546, 12, 310, 336, 337, 1359, -546, 1359,
2139 1359, -546, -546, -546, 298, -546, 438, -546, 475, -4,
2140 493, 493, 1610, -546, -546, 338, -546, -546, -546, -546,
2141 342, 345, 346, -546, 501, -546, 780, -546, 940, 2,
2142 354, 355, -546, -546, 82, -7, 72, -546, 201, -546,
2143 -546, -546, -546, -546, 359, -546, 940, 132, 132, 493,
2144 493, 492, 494, 361, -546, -546, 780, 780, 497, 132,
2145 132, 450, -546, 780, 505, -546, 780, -546
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002146};
2147
2148/* YYPGOTO[NTERM-NUM]. */
2149static const yytype_int16 yypgoto[] =
2150{
Duncan Sandsdc024672007-11-27 13:23:08 +00002151 -546, 394, 395, 396, 280, 283, -170, -546, 0, -16,
2152 444, 15, -546, -546, -546, -546, -1, -546, -546, -546,
2153 -157, -546, -418, -546, -229, -546, -292, 23, -546, -307,
2154 -546, -546, -26, 305, -120, -546, 429, 436, -59, -156,
2155 -235, 126, 168, 307, -546, -546, 526, -546, -546, -546,
2156 -546, -546, -546, -546, -546, -546, -546, -546, 456, -546,
2157 -546, -546, -546, -546, -546, -545, -142, 108, -186, -546,
2158 490, -546, -546, -546, -546, -546, 51, 138, -546, -546,
2159 -546, -546
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002160};
2161
2162/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2163 positive, shift that token. If negative, reduce the rule which
2164 number is the opposite. If zero, do what YYDEFACT says.
2165 If YYTABLE_NINF, syntax error. */
2166#define YYTABLE_NINF -204
2167static const yytype_int16 yytable[] =
2168{
Duncan Sandsdc024672007-11-27 13:23:08 +00002169 11, 81, 272, 335, 261, 104, 163, 271, 236, 304,
2170 164, 383, 475, 271, 425, 13, 273, 11, 262, 441,
2171 350, 352, 443, 584, 308, 309, 310, 311, 312, 405,
2172 406, 315, 13, 426, 90, 21, 45, 425, 46, 83,
2173 84, 593, 93, 142, 142, 415, 88, -203, 415, 22,
2174 131, 108, 89, 24, 143, 230, 421, 132, 26, 468,
2175 161, 442, 316, 415, 442, -67, 1, 2, 269, 3,
2176 4, 5, 420, 415, 270, 134, 488, 6, 7, 108,
2177 503, 110, 479, 111, 415, 134, 233, 117, 118, 333,
2178 149, 416, 11, 110, 85, 111, 86, 544, 8, 332,
2179 149, 9, 550, 551, 27, 10, 49, 50, 51, 25,
2180 591, 52, 227, 228, 419, 110, 231, 111, 500, 1,
2181 234, 474, 3, 2, 5, 372, 4, 372, 372, 110,
2182 372, 111, 397, 385, 435, 43, 552, 398, 399, 400,
2183 553, 165, 401, 110, 267, 111, 402, 403, 239, 240,
2184 241, 242, 567, 377, 587, 588, 589, 590, 585, 59,
2185 105, 552, 28, 372, 498, 556, 57, 302, 303, 267,
2186 305, 372, 372, 94, 317, 318, 599, 600, 264, 380,
2187 110, 58, 111, 306, 267, 267, 267, 267, 267, 313,
2188 314, 267, 114, 525, 115, 526, 395, 382, 110, 134,
2189 111, 447, 61, 449, 450, 451, 398, 399, 400, 149,
2190 110, 401, 111, 543, 90, 402, 403, -55, -55, -55,
2191 -55, 37, 38, 39, 97, 29, 30, 31, 32, 33,
2192 34, 35, -139, 36, -139, 372, 372, 372, 145, 146,
2193 237, 238, 557, 372, 63, 64, 98, 149, 516, 319,
2194 320, 112, 113, 372, 372, 99, 1, 2, 378, 3,
2195 4, 5, 261, 101, 102, 103, 321, 322, 86, 323,
2196 324, 138, 325, 326, 327, 379, 262, 139, 162, 223,
2197 225, 226, 410, 411, 412, 413, 414, 229, -56, 232,
2198 149, 396, 267, 235, -57, 422, 423, 424, -60, 372,
2199 -59, 372, 527, -58, 372, 530, 531, 532, 243, 265,
2200 372, 372, 271, 334, 341, 342, 343, 1, 344, 345,
2201 3, 354, 5, 418, 576, 353, 355, 578, 37, 38,
2202 39, 356, 433, 430, 357, 398, 399, 400, 372, 372,
2203 401, 372, 372, 359, 402, 403, 386, 372, 387, 459,
2204 460, 394, 388, 389, 390, 391, 466, 372, 407, 408,
2205 409, 267, 448, 267, 267, 267, 436, 437, 454, 120,
2206 121, 122, 123, 124, 125, 446, 452, 374, 375, 568,
2207 376, 458, 471, 453, 457, 63, 64, 372, 106, 66,
2208 67, 68, 69, 70, 71, 72, 462, 1, 2, 586,
2209 3, 4, 5, 504, 505, 506, 507, 463, 372, 372,
2210 509, 510, 464, 384, 465, 319, 320, 467, 469, 470,
2211 472, 392, 393, 473, 372, 476, 478, 73, 477, 480,
2212 481, 499, 321, 322, 482, 323, 324, 483, 325, 326,
2213 327, 484, 535, 536, 486, 511, 488, 372, 372, 489,
2214 515, 491, 442, 492, 372, 372, 521, 493, 496, 497,
2215 501, 372, 267, 502, 372, 267, 267, 267, 517, 538,
2216 521, 529, 537, 508, 539, 512, 540, 541, 560, 542,
2217 561, 562, 547, 548, 549, 438, 439, 440, 554, 558,
2218 559, 564, 566, 445, 577, 579, 360, 361, 580, 581,
2219 63, 64, 362, 455, 456, 582, -18, -19, 592, 596,
2220 598, 597, 1, 2, 603, 3, 4, 5, 363, 364,
2221 365, 604, 606, 215, 216, 217, 575, 339, 563, 74,
2222 330, 340, 75, 366, 367, 76, 129, 77, 107, 545,
2223 144, 141, 338, 44, 512, 128, 96, 533, 461, 485,
2224 368, 487, 0, 0, 490, 0, 0, 0, 0, 0,
2225 494, 495, 0, 0, 0, 0, 176, 177, 178, 179,
2226 180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
2227 190, 247, 248, 0, 0, 0, 0, 0, 518, 519,
2228 0, 523, 524, 0, 0, 0, 0, 528, 0, 0,
2229 0, 0, 0, 0, 0, 0, 0, 534, 249, 197,
2230 570, 571, 200, 201, 202, 203, 204, 205, 206, 207,
2231 208, 0, 250, 0, 251, 252, 253, 321, 322, 0,
2232 323, 324, 0, 325, 326, 327, 0, 555, 0, 0,
2233 0, 0, 0, 0, 0, 0, 0, 360, 361, 0,
2234 369, 63, 64, 362, 0, 0, 0, 0, 572, 573,
2235 0, 0, 0, 1, 2, 0, 3, 4, 5, 363,
2236 364, 365, 285, 286, 583, 0, 0, 0, 0, 0,
2237 0, 0, 0, 0, 366, 367, 274, 275, 276, 277,
2238 278, 279, 280, 281, 282, 283, 0, 594, 595, 0,
2239 0, 368, 0, 0, 601, 602, 0, 0, 0, 0,
2240 0, 605, 0, 0, 607, 0, 0, 176, 177, 178,
2241 179, 180, 181, 182, 183, 184, 185, 186, 187, 188,
2242 189, 190, 247, 248, 0, 0, 0, 0, 0, 0,
2243 0, 0, 287, 288, 289, 290, 291, 292, 293, 294,
2244 295, 296, 297, 298, 299, 300, 0, 0, 0, 249,
2245 197, 198, 199, 200, 201, 202, 203, 204, 205, 206,
2246 207, 208, 0, 250, 0, 251, 252, 253, 0, 0,
2247 0, 0, 0, 360, 361, 0, 0, 63, 64, 362,
2248 0, 0, 0, 0, 110, 0, 111, 0, 0, 1,
2249 2, 369, 3, 4, 5, 363, 364, 365, 0, 0,
2250 63, 64, 0, 0, 0, 0, 0, 0, 0, 0,
2251 366, 367, 1, 2, 0, 3, 4, 5, 244, 0,
2252 0, 0, 0, 0, 0, 0, 0, 368, 0, 0,
2253 0, 0, 0, 245, 246, 0, 0, 0, 0, 0,
2254 0, 0, 0, 176, 177, 178, 179, 180, 181, 182,
2255 183, 184, 185, 186, 187, 188, 189, 190, 247, 248,
2256 0, 0, 0, 0, 0, 0, 176, 177, 178, 179,
2257 180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
2258 190, 247, 248, 0, 0, 249, 197, 198, 199, 200,
2259 201, 202, 203, 204, 205, 206, 207, 208, 0, 250,
2260 0, 251, 252, 253, 0, 0, 0, 0, 249, 197,
2261 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
2262 208, 0, 250, 0, 251, 252, 253, 369, 0, 0,
2263 0, 0, 0, 360, 361, 0, 0, 0, 0, 362,
2264 0, 0, 0, 110, 0, 111, 0, 254, 0, 0,
2265 255, 0, 256, 0, 257, 363, 364, 365, 0, 0,
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002266 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Duncan Sandsdc024672007-11-27 13:23:08 +00002267 366, 367, 0, 0, 0, 0, 0, 0, 0, 0,
2268 0, 0, 0, 0, 0, 63, 64, 368, 106, 66,
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002269 67, 68, 69, 70, 71, 72, 0, 1, 2, 0,
Duncan Sandsdc024672007-11-27 13:23:08 +00002270 3, 4, 5, 176, 177, 178, 179, 180, 181, 182,
2271 183, 184, 185, 186, 187, 188, 189, 190, 247, 248,
2272 0, 0, 0, 0, 0, 63, 64, 73, 106, 152,
2273 153, 154, 155, 156, 157, 72, 0, 1, 2, 0,
2274 3, 4, 5, 0, 0, 249, 197, 198, 199, 200,
2275 201, 202, 203, 204, 205, 206, 207, 208, 0, 250,
2276 0, 251, 252, 253, 0, 63, 64, 73, 106, 152,
2277 153, 154, 155, 156, 157, 72, 0, 1, 2, 0,
2278 3, 4, 5, 0, 0, 63, 64, 369, 106, 66,
2279 67, 68, 69, 70, 71, 72, 0, 1, 2, 0,
2280 3, 4, 5, 0, 0, 0, 0, 73, 0, 0,
2281 0, 0, 0, 0, 0, 0, 0, 133, 0, 0,
2282 0, 0, 0, 0, 0, 0, 0, 73, 0, 74,
2283 0, 0, 75, 0, 0, 76, 0, 77, 140, 63,
2284 64, 0, 147, 66, 67, 68, 69, 70, 71, 72,
2285 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002286 0, 0, 0, 0, 0, 0, 0, 0, 0, 74,
Duncan Sandsdc024672007-11-27 13:23:08 +00002287 0, 0, 75, 0, 0, 76, 0, 77, 351, 63,
2288 64, 73, 106, 66, 67, 68, 69, 70, 71, 72,
2289 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
2290 0, 0, 0, 0, 0, 0, 0, 0, 0, 74,
2291 0, 329, 75, 0, 0, 76, 0, 77, 417, 0,
2292 0, 73, 0, 0, 0, 0, 0, 0, 0, 74,
2293 0, 0, 75, 0, 0, 76, 0, 77, 0, 63,
2294 64, 0, 106, 152, 153, 154, 155, 156, 157, 72,
2295 0, 1, 2, 148, 3, 4, 5, 0, 63, 64,
2296 0, 106, 66, 67, 68, 69, 70, 71, 72, 0,
2297 1, 2, 0, 3, 4, 5, 0, 0, 0, 0,
2298 0, 73, 0, 74, 0, 0, 75, 0, 0, 76,
2299 429, 77, 0, 0, 0, 0, 0, 0, 63, 64,
2300 73, 106, 66, 67, 68, 69, 70, 71, 72, 0,
2301 1, 2, 0, 3, 4, 5, 0, 0, 0, 0,
2302 0, 0, 0, 74, 0, 0, 75, 0, 0, 76,
2303 514, 77, 0, 0, 0, 0, 0, 0, 63, 64,
2304 73, 65, 66, 67, 68, 69, 70, 71, 72, 0,
2305 1, 2, 0, 3, 4, 5, 63, 64, 0, 106,
2306 152, 153, 154, 155, 156, 157, 72, 0, 1, 2,
2307 0, 3, 4, 5, 0, 0, 0, 0, 0, 0,
2308 73, 0, 0, 74, 0, 0, 75, 0, 346, 76,
2309 0, 77, 0, 0, 0, 0, 0, 0, 73, 0,
2310 0, 0, 74, 0, 0, 75, 0, 0, 76, 0,
2311 77, 63, 64, 0, 147, 66, 67, 68, 69, 70,
2312 71, 72, 0, 1, 2, 0, 3, 4, 5, 0,
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002313 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Duncan Sandsdc024672007-11-27 13:23:08 +00002314 0, 0, 74, 0, 0, 75, 0, 0, 76, 0,
2315 77, 63, 64, 73, 106, 66, 67, 68, 69, 70,
2316 71, 72, 0, 1, 2, 0, 3, 4, 5, 0,
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002317 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Duncan Sandsdc024672007-11-27 13:23:08 +00002318 0, 0, 74, 0, 0, 75, 0, 0, 76, 0,
2319 77, 0, 0, 73, 0, 0, 0, 0, 0, 0,
2320 74, 0, 0, 75, 0, 0, 76, 0, 77, 63,
2321 64, 0, 266, 66, 67, 68, 69, 70, 71, 72,
2322 0, 1, 2, 0, 3, 4, 5, 63, 64, 0,
2323 106, 152, 153, 154, 155, 156, 157, 72, 0, 1,
2324 2, 0, 3, 4, 5, 0, 0, 0, 0, 0,
2325 0, 73, 0, 0, 0, 74, 0, 0, 75, 0,
2326 0, 76, 0, 77, 0, 0, 0, 63, 64, 73,
2327 106, 66, 67, 68, 69, 70, 71, 520, 0, 1,
2328 2, 0, 3, 4, 5, 0, 0, 0, 0, 0,
2329 0, 0, 0, 0, 0, 74, 0, 0, 75, 0,
2330 0, 76, 0, 77, 0, 0, 0, 63, 64, 73,
2331 106, 66, 67, 68, 69, 70, 71, 574, 0, 1,
2332 2, 0, 3, 4, 5, 0, 0, 0, 0, 0,
2333 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2334 0, 0, 0, 0, 0, 0, 0, 0, 0, 73,
2335 167, 0, 0, 74, 0, 0, 75, 0, 0, 76,
2336 0, 77, 0, 0, 0, 0, 0, 0, 0, 168,
2337 169, 74, 0, 0, 75, 0, 0, 76, 0, 349,
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002338 0, 170, 171, 172, 173, 174, 175, 176, 177, 178,
2339 179, 180, 181, 182, 183, 184, 185, 186, 187, 188,
2340 189, 190, 191, 192, 0, 0, 0, 0, 0, 0,
Duncan Sandsdc024672007-11-27 13:23:08 +00002341 0, 74, 0, 0, 75, 0, 0, 76, 0, 77,
2342 0, 0, 0, 0, 193, 194, 195, 0, 0, 196,
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002343 197, 198, 199, 200, 201, 202, 203, 204, 205, 206,
Duncan Sandsdc024672007-11-27 13:23:08 +00002344 207, 208, 209, 210, 211, 212, 213, 214, -202, 0,
2345 0, 74, 0, 0, 75, 0, 0, 76, 0, 77,
2346 0, 0, 0, 0, 0, 0, -67, 1, 2, 0,
2347 3, 4, 5, 0, 0, 0, 0, 0, 6, 7,
2348 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2349 0, 0, 0, 0, 0, 0, 0, 0, 0, 8,
2350 0, 0, 9, 0, 0, 0, 10
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002351};
2352
2353static const yytype_int16 yycheck[] =
2354{
Duncan Sandsdc024672007-11-27 13:23:08 +00002355 0, 27, 172, 232, 160, 4, 126, 11, 150, 195,
2356 28, 303, 430, 11, 34, 0, 173, 17, 160, 11,
2357 255, 256, 11, 568, 210, 211, 212, 213, 214, 336,
2358 337, 217, 17, 53, 21, 52, 46, 34, 48, 40,
2359 41, 586, 29, 149, 149, 149, 47, 0, 149, 66,
2360 149, 77, 53, 148, 160, 160, 160, 156, 148, 160,
2361 119, 53, 219, 149, 53, 18, 19, 20, 11, 22,
2362 23, 24, 158, 149, 17, 101, 149, 30, 31, 105,
2363 153, 150, 158, 152, 149, 111, 145, 32, 33, 158,
2364 116, 156, 92, 150, 35, 152, 37, 515, 51, 156,
2365 126, 54, 520, 521, 18, 58, 42, 43, 44, 57,
2366 38, 47, 138, 139, 349, 150, 142, 152, 153, 19,
2367 146, 428, 22, 20, 24, 267, 23, 269, 270, 150,
2368 272, 152, 318, 154, 369, 0, 149, 134, 135, 136,
2369 153, 159, 139, 150, 170, 152, 143, 144, 3, 4,
2370 5, 6, 156, 273, 572, 573, 574, 575, 156, 154,
2371 159, 149, 148, 305, 456, 153, 148, 193, 194, 195,
2372 196, 313, 314, 160, 113, 114, 594, 595, 163, 149,
2373 150, 148, 152, 209, 210, 211, 212, 213, 214, 215,
2374 216, 217, 42, 485, 44, 487, 316, 149, 150, 225,
2375 152, 387, 22, 389, 390, 391, 134, 135, 136, 235,
2376 150, 139, 152, 153, 21, 143, 144, 3, 4, 5,
2377 6, 145, 146, 147, 22, 42, 43, 44, 45, 46,
2378 47, 48, 150, 50, 152, 377, 378, 379, 112, 113,
2379 26, 27, 534, 385, 7, 8, 22, 273, 477, 117,
2380 118, 83, 84, 395, 396, 22, 19, 20, 284, 22,
2381 23, 24, 418, 152, 4, 4, 134, 135, 37, 137,
2382 138, 155, 140, 141, 142, 301, 418, 155, 4, 22,
2383 149, 153, 341, 342, 343, 344, 345, 158, 9, 153,
2384 316, 317, 318, 152, 9, 354, 355, 356, 9, 441,
2385 9, 443, 488, 9, 446, 491, 492, 493, 9, 55,
2386 452, 453, 11, 158, 152, 152, 152, 19, 152, 152,
2387 22, 152, 24, 349, 553, 22, 152, 556, 145, 146,
2388 147, 152, 59, 359, 149, 134, 135, 136, 480, 481,
2389 139, 483, 484, 152, 143, 144, 149, 489, 149, 408,
2390 409, 38, 149, 149, 149, 149, 415, 499, 38, 152,
2391 152, 387, 388, 389, 390, 391, 149, 149, 394, 60,
2392 61, 62, 63, 64, 65, 154, 149, 269, 270, 549,
2393 272, 407, 38, 149, 149, 7, 8, 529, 10, 11,
2394 12, 13, 14, 15, 16, 17, 149, 19, 20, 569,
2395 22, 23, 24, 462, 463, 464, 465, 149, 550, 551,
2396 469, 470, 149, 305, 149, 117, 118, 158, 149, 149,
2397 22, 313, 314, 4, 566, 149, 22, 49, 153, 17,
2398 17, 457, 134, 135, 152, 137, 138, 149, 140, 141,
2399 142, 149, 501, 502, 4, 471, 149, 589, 590, 149,
2400 476, 149, 53, 149, 596, 597, 482, 149, 152, 149,
2401 149, 603, 488, 149, 606, 491, 492, 493, 149, 153,
2402 496, 149, 149, 158, 149, 475, 149, 153, 537, 153,
2403 539, 540, 22, 149, 154, 377, 378, 379, 156, 153,
2404 153, 53, 17, 385, 156, 153, 3, 4, 153, 153,
2405 7, 8, 9, 395, 396, 4, 152, 152, 149, 17,
2406 149, 17, 19, 20, 17, 22, 23, 24, 25, 26,
2407 27, 71, 17, 129, 129, 129, 552, 247, 544, 151,
2408 225, 248, 154, 40, 41, 157, 92, 159, 160, 516,
2409 111, 105, 235, 17, 544, 89, 56, 496, 410, 441,
2410 57, 443, -1, -1, 446, -1, -1, -1, -1, -1,
2411 452, 453, -1, -1, -1, -1, 73, 74, 75, 76,
2412 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
2413 87, 88, 89, -1, -1, -1, -1, -1, 480, 481,
2414 -1, 483, 484, -1, -1, -1, -1, 489, -1, -1,
2415 -1, -1, -1, -1, -1, -1, -1, 499, 115, 116,
2416 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
2417 127, -1, 129, -1, 131, 132, 133, 134, 135, -1,
2418 137, 138, -1, 140, 141, 142, -1, 529, -1, -1,
2419 -1, -1, -1, -1, -1, -1, -1, 3, 4, -1,
2420 157, 7, 8, 9, -1, -1, -1, -1, 550, 551,
2421 -1, -1, -1, 19, 20, -1, 22, 23, 24, 25,
2422 26, 27, 26, 27, 566, -1, -1, -1, -1, -1,
2423 -1, -1, -1, -1, 40, 41, 90, 91, 92, 93,
2424 94, 95, 96, 97, 98, 99, -1, 589, 590, -1,
2425 -1, 57, -1, -1, 596, 597, -1, -1, -1, -1,
2426 -1, 603, -1, -1, 606, -1, -1, 73, 74, 75,
2427 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
2428 86, 87, 88, 89, -1, -1, -1, -1, -1, -1,
2429 -1, -1, 96, 97, 98, 99, 100, 101, 102, 103,
2430 104, 105, 106, 107, 108, 109, -1, -1, -1, 115,
2431 116, 117, 118, 119, 120, 121, 122, 123, 124, 125,
2432 126, 127, -1, 129, -1, 131, 132, 133, -1, -1,
2433 -1, -1, -1, 3, 4, -1, -1, 7, 8, 9,
2434 -1, -1, -1, -1, 150, -1, 152, -1, -1, 19,
2435 20, 157, 22, 23, 24, 25, 26, 27, -1, -1,
2436 7, 8, -1, -1, -1, -1, -1, -1, -1, -1,
2437 40, 41, 19, 20, -1, 22, 23, 24, 25, -1,
2438 -1, -1, -1, -1, -1, -1, -1, 57, -1, -1,
2439 -1, -1, -1, 40, 41, -1, -1, -1, -1, -1,
2440 -1, -1, -1, 73, 74, 75, 76, 77, 78, 79,
2441 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
2442 -1, -1, -1, -1, -1, -1, 73, 74, 75, 76,
2443 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
2444 87, 88, 89, -1, -1, 115, 116, 117, 118, 119,
2445 120, 121, 122, 123, 124, 125, 126, 127, -1, 129,
2446 -1, 131, 132, 133, -1, -1, -1, -1, 115, 116,
2447 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
2448 127, -1, 129, -1, 131, 132, 133, 157, -1, -1,
2449 -1, -1, -1, 3, 4, -1, -1, -1, -1, 9,
2450 -1, -1, -1, 150, -1, 152, -1, 154, -1, -1,
2451 157, -1, 159, -1, 161, 25, 26, 27, -1, -1,
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002452 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Duncan Sandsdc024672007-11-27 13:23:08 +00002453 40, 41, -1, -1, -1, -1, -1, -1, -1, -1,
2454 -1, -1, -1, -1, -1, 7, 8, 57, 10, 11,
2455 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
2456 22, 23, 24, 73, 74, 75, 76, 77, 78, 79,
2457 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
2458 -1, -1, -1, -1, -1, 7, 8, 49, 10, 11,
2459 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
2460 22, 23, 24, -1, -1, 115, 116, 117, 118, 119,
2461 120, 121, 122, 123, 124, 125, 126, 127, -1, 129,
2462 -1, 131, 132, 133, -1, 7, 8, 49, 10, 11,
2463 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
2464 22, 23, 24, -1, -1, 7, 8, 157, 10, 11,
2465 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
2466 22, 23, 24, -1, -1, -1, -1, 49, -1, -1,
2467 -1, -1, -1, -1, -1, -1, -1, 39, -1, -1,
2468 -1, -1, -1, -1, -1, -1, -1, 49, -1, 151,
2469 -1, -1, 154, -1, -1, 157, -1, 159, 160, 7,
2470 8, -1, 10, 11, 12, 13, 14, 15, 16, 17,
2471 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
2472 -1, -1, -1, -1, -1, -1, -1, -1, -1, 151,
2473 -1, -1, 154, -1, -1, 157, -1, 159, 160, 7,
2474 8, 49, 10, 11, 12, 13, 14, 15, 16, 17,
2475 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
2476 -1, -1, -1, -1, -1, -1, -1, -1, -1, 151,
2477 -1, 39, 154, -1, -1, 157, -1, 159, 160, -1,
2478 -1, 49, -1, -1, -1, -1, -1, -1, -1, 151,
2479 -1, -1, 154, -1, -1, 157, -1, 159, -1, 7,
2480 8, -1, 10, 11, 12, 13, 14, 15, 16, 17,
2481 -1, 19, 20, 121, 22, 23, 24, -1, 7, 8,
2482 -1, 10, 11, 12, 13, 14, 15, 16, 17, -1,
2483 19, 20, -1, 22, 23, 24, -1, -1, -1, -1,
2484 -1, 49, -1, 151, -1, -1, 154, -1, -1, 157,
2485 39, 159, -1, -1, -1, -1, -1, -1, 7, 8,
2486 49, 10, 11, 12, 13, 14, 15, 16, 17, -1,
2487 19, 20, -1, 22, 23, 24, -1, -1, -1, -1,
2488 -1, -1, -1, 151, -1, -1, 154, -1, -1, 157,
2489 39, 159, -1, -1, -1, -1, -1, -1, 7, 8,
2490 49, 10, 11, 12, 13, 14, 15, 16, 17, -1,
2491 19, 20, -1, 22, 23, 24, 7, 8, -1, 10,
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002492 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
2493 -1, 22, 23, 24, -1, -1, -1, -1, -1, -1,
Duncan Sandsdc024672007-11-27 13:23:08 +00002494 49, -1, -1, 151, -1, -1, 154, -1, 156, 157,
2495 -1, 159, -1, -1, -1, -1, -1, -1, 49, -1,
2496 -1, -1, 151, -1, -1, 154, -1, -1, 157, -1,
2497 159, 7, 8, -1, 10, 11, 12, 13, 14, 15,
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002498 16, 17, -1, 19, 20, -1, 22, 23, 24, -1,
2499 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Duncan Sandsdc024672007-11-27 13:23:08 +00002500 -1, -1, 151, -1, -1, 154, -1, -1, 157, -1,
2501 159, 7, 8, 49, 10, 11, 12, 13, 14, 15,
2502 16, 17, -1, 19, 20, -1, 22, 23, 24, -1,
2503 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2504 -1, -1, 151, -1, -1, 154, -1, -1, 157, -1,
2505 159, -1, -1, 49, -1, -1, -1, -1, -1, -1,
2506 151, -1, -1, 154, -1, -1, 157, -1, 159, 7,
2507 8, -1, 10, 11, 12, 13, 14, 15, 16, 17,
2508 -1, 19, 20, -1, 22, 23, 24, 7, 8, -1,
2509 10, 11, 12, 13, 14, 15, 16, 17, -1, 19,
2510 20, -1, 22, 23, 24, -1, -1, -1, -1, -1,
2511 -1, 49, -1, -1, -1, 151, -1, -1, 154, -1,
2512 -1, 157, -1, 159, -1, -1, -1, 7, 8, 49,
2513 10, 11, 12, 13, 14, 15, 16, 17, -1, 19,
2514 20, -1, 22, 23, 24, -1, -1, -1, -1, -1,
2515 -1, -1, -1, -1, -1, 151, -1, -1, 154, -1,
2516 -1, 157, -1, 159, -1, -1, -1, 7, 8, 49,
2517 10, 11, 12, 13, 14, 15, 16, 17, -1, 19,
2518 20, -1, 22, 23, 24, -1, -1, -1, -1, -1,
2519 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2520 -1, -1, -1, -1, -1, -1, -1, -1, -1, 49,
2521 36, -1, -1, 151, -1, -1, 154, -1, -1, 157,
2522 -1, 159, -1, -1, -1, -1, -1, -1, -1, 55,
2523 56, 151, -1, -1, 154, -1, -1, 157, -1, 159,
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002524 -1, 67, 68, 69, 70, 71, 72, 73, 74, 75,
2525 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
2526 86, 87, 88, 89, -1, -1, -1, -1, -1, -1,
Duncan Sandsdc024672007-11-27 13:23:08 +00002527 -1, 151, -1, -1, 154, -1, -1, 157, -1, 159,
2528 -1, -1, -1, -1, 110, 111, 112, -1, -1, 115,
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002529 116, 117, 118, 119, 120, 121, 122, 123, 124, 125,
Duncan Sandsdc024672007-11-27 13:23:08 +00002530 126, 127, 128, 129, 130, 131, 132, 133, 0, -1,
2531 -1, 151, -1, -1, 154, -1, -1, 157, -1, 159,
2532 -1, -1, -1, -1, -1, -1, 18, 19, 20, -1,
2533 22, 23, 24, -1, -1, -1, -1, -1, 30, 31,
2534 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2535 -1, -1, -1, -1, -1, -1, -1, -1, -1, 51,
2536 -1, -1, 54, -1, -1, -1, 58
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002537};
2538
2539/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2540 symbol of state STATE-NUM. */
2541static const yytype_uint8 yystos[] =
2542{
2543 0, 19, 20, 22, 23, 24, 30, 31, 51, 54,
2544 58, 170, 172, 173, 174, 175, 206, 207, 208, 210,
2545 209, 52, 66, 215, 148, 57, 148, 18, 148, 42,
2546 43, 44, 45, 46, 47, 48, 50, 145, 146, 147,
2547 176, 177, 178, 0, 208, 46, 48, 179, 225, 42,
2548 43, 44, 47, 180, 222, 224, 231, 148, 148, 154,
2549 216, 22, 214, 7, 8, 10, 11, 12, 13, 14,
2550 15, 16, 17, 49, 151, 154, 157, 159, 170, 173,
2551 193, 194, 228, 178, 178, 35, 37, 204, 178, 178,
2552 21, 232, 233, 29, 160, 223, 232, 22, 22, 22,
2553 217, 152, 4, 4, 4, 159, 10, 160, 194, 199,
2554 150, 152, 204, 204, 42, 44, 181, 32, 33, 203,
2555 60, 61, 62, 63, 64, 65, 182, 220, 220, 172,
2556 236, 149, 156, 39, 194, 195, 197, 198, 155, 155,
2557 160, 199, 149, 160, 198, 203, 203, 10, 121, 194,
2558 196, 205, 11, 12, 13, 14, 15, 16, 168, 169,
2559 194, 200, 4, 196, 28, 159, 221, 36, 55, 56,
2560 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
2561 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
2562 87, 88, 89, 110, 111, 112, 115, 116, 117, 118,
2563 119, 120, 121, 122, 123, 124, 125, 126, 127, 128,
2564 129, 130, 131, 132, 133, 163, 164, 165, 234, 240,
2565 241, 242, 243, 22, 184, 149, 153, 194, 194, 158,
2566 160, 194, 153, 200, 194, 152, 228, 26, 27, 3,
2567 4, 5, 6, 9, 25, 40, 41, 88, 89, 115,
2568 129, 131, 132, 133, 154, 157, 159, 161, 163, 164,
2569 165, 201, 228, 211, 173, 55, 10, 194, 230, 11,
2570 17, 11, 168, 182, 90, 91, 92, 93, 94, 95,
2571 96, 97, 98, 99, 166, 26, 27, 96, 97, 98,
2572 99, 100, 101, 102, 103, 104, 105, 106, 107, 108,
2573 109, 167, 194, 194, 230, 194, 194, 237, 230, 230,
2574 230, 230, 230, 194, 194, 230, 182, 113, 114, 117,
2575 118, 134, 135, 137, 138, 140, 141, 142, 183, 39,
2576 195, 186, 156, 158, 158, 186, 212, 213, 205, 166,
2577 167, 152, 152, 152, 152, 152, 156, 200, 202, 159,
2578 202, 160, 202, 22, 152, 152, 152, 149, 191, 152,
2579 3, 4, 9, 25, 26, 27, 40, 41, 57, 157,
2580 201, 227, 228, 229, 229, 229, 229, 196, 194, 194,
2581 149, 188, 149, 188, 229, 154, 149, 149, 149, 149,
2582 149, 149, 229, 229, 38, 196, 194, 230, 134, 135,
2583 136, 139, 143, 144, 185, 191, 191, 38, 152, 152,
2584 200, 200, 200, 200, 200, 149, 156, 160, 194, 202,
2585 158, 160, 200, 200, 200, 34, 53, 189, 192, 39,
2586 194, 218, 219, 59, 226, 202, 149, 149, 229, 229,
2587 229, 11, 53, 11, 239, 229, 154, 230, 194, 230,
2588 230, 230, 149, 149, 194, 229, 229, 149, 194, 200,
2589 200, 239, 149, 149, 149, 149, 200, 158, 160, 149,
2590 149, 38, 22, 4, 191, 184, 149, 153, 22, 158,
2591 17, 17, 152, 149, 149, 229, 4, 229, 149, 149,
2592 229, 149, 149, 149, 229, 229, 152, 149, 188, 194,
2593 153, 149, 149, 153, 200, 200, 200, 200, 158, 200,
2594 200, 194, 170, 171, 39, 194, 186, 149, 229, 229,
2595 17, 194, 238, 229, 229, 188, 188, 230, 229, 149,
2596 230, 230, 230, 238, 229, 200, 200, 149, 153, 149,
2597 149, 153, 153, 153, 184, 189, 190, 22, 149, 154,
Duncan Sandsdc024672007-11-27 13:23:08 +00002598 184, 184, 149, 153, 156, 229, 153, 188, 153, 153,
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002599 200, 200, 200, 171, 53, 187, 17, 156, 168, 235,
Duncan Sandsdc024672007-11-27 13:23:08 +00002600 117, 118, 229, 229, 17, 194, 186, 156, 186, 153,
2601 153, 153, 4, 229, 227, 156, 168, 184, 184, 184,
2602 184, 38, 149, 227, 229, 229, 17, 17, 149, 184,
2603 184, 229, 229, 17, 71, 229, 17, 229
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002604};
David Greene718fda32007-08-01 03:59:32 +00002605
Reid Spencer68a24bd2005-08-27 18:50:39 +00002606#define yyerrok (yyerrstatus = 0)
2607#define yyclearin (yychar = YYEMPTY)
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002608#define YYEMPTY (-2)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002609#define YYEOF 0
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002610
Reid Spencer68a24bd2005-08-27 18:50:39 +00002611#define YYACCEPT goto yyacceptlab
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002612#define YYABORT goto yyabortlab
2613#define YYERROR goto yyerrorlab
2614
2615
2616/* Like YYERROR except do call yyerror. This remains here temporarily
2617 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002618 Once GCC version 2 has supplanted version 1, this can go. */
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002619
Reid Spencer68a24bd2005-08-27 18:50:39 +00002620#define YYFAIL goto yyerrlab
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002621
Reid Spencer68a24bd2005-08-27 18:50:39 +00002622#define YYRECOVERING() (!!yyerrstatus)
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002623
2624#define YYBACKUP(Token, Value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002625do \
2626 if (yychar == YYEMPTY && yylen == 1) \
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002627 { \
2628 yychar = (Token); \
2629 yylval = (Value); \
2630 yytoken = YYTRANSLATE (yychar); \
2631 YYPOPSTACK (1); \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002632 goto yybackup; \
2633 } \
2634 else \
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002635 { \
2636 yyerror (YY_("syntax error: cannot back up")); \
2637 YYERROR; \
2638 } \
2639while (YYID (0))
2640
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002641
Reid Spencer68a24bd2005-08-27 18:50:39 +00002642#define YYTERROR 1
2643#define YYERRCODE 256
2644
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002645
2646/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2647 If N is 0, then set CURRENT to the empty location which ends
2648 the previous symbol: RHS[0] (always defined). */
2649
2650#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2651#ifndef YYLLOC_DEFAULT
2652# define YYLLOC_DEFAULT(Current, Rhs, N) \
2653 do \
2654 if (YYID (N)) \
2655 { \
2656 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2657 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2658 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2659 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2660 } \
2661 else \
2662 { \
2663 (Current).first_line = (Current).last_line = \
2664 YYRHSLOC (Rhs, 0).last_line; \
2665 (Current).first_column = (Current).last_column = \
2666 YYRHSLOC (Rhs, 0).last_column; \
2667 } \
2668 while (YYID (0))
Reid Spencer68a24bd2005-08-27 18:50:39 +00002669#endif
2670
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002671
2672/* YY_LOCATION_PRINT -- Print the location on the stream.
2673 This macro was not mandated originally: define only if we know
2674 we won't break user code: when these are the locations we know. */
2675
2676#ifndef YY_LOCATION_PRINT
Duncan Sandsdc024672007-11-27 13:23:08 +00002677# if YYLTYPE_IS_TRIVIAL
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002678# define YY_LOCATION_PRINT(File, Loc) \
2679 fprintf (File, "%d.%d-%d.%d", \
2680 (Loc).first_line, (Loc).first_column, \
2681 (Loc).last_line, (Loc).last_column)
2682# else
2683# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2684# endif
2685#endif
2686
2687
2688/* YYLEX -- calling `yylex' with the right arguments. */
2689
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002690#ifdef YYLEX_PARAM
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002691# define YYLEX yylex (YYLEX_PARAM)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002692#else
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002693# define YYLEX yylex ()
Dale Johannesencdd509a2007-09-07 21:07:57 +00002694#endif
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002695
2696/* Enable debugging if requested. */
2697#if YYDEBUG
2698
2699# ifndef YYFPRINTF
2700# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2701# define YYFPRINTF fprintf
2702# endif
2703
2704# define YYDPRINTF(Args) \
2705do { \
2706 if (yydebug) \
2707 YYFPRINTF Args; \
2708} while (YYID (0))
2709
2710# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2711do { \
2712 if (yydebug) \
2713 { \
2714 YYFPRINTF (stderr, "%s ", Title); \
2715 yy_symbol_print (stderr, \
2716 Type, Value); \
2717 YYFPRINTF (stderr, "\n"); \
2718 } \
2719} while (YYID (0))
2720
2721
2722/*--------------------------------.
2723| Print this symbol on YYOUTPUT. |
2724`--------------------------------*/
2725
2726/*ARGSUSED*/
2727#if (defined __STDC__ || defined __C99__FUNC__ \
2728 || defined __cplusplus || defined _MSC_VER)
2729static void
2730yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
Dale Johannesencdd509a2007-09-07 21:07:57 +00002731#else
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002732static void
2733yy_symbol_value_print (yyoutput, yytype, yyvaluep)
2734 FILE *yyoutput;
2735 int yytype;
2736 YYSTYPE const * const yyvaluep;
Dale Johannesencdd509a2007-09-07 21:07:57 +00002737#endif
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002738{
2739 if (!yyvaluep)
2740 return;
2741# ifdef YYPRINT
2742 if (yytype < YYNTOKENS)
2743 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2744# else
2745 YYUSE (yyoutput);
2746# endif
2747 switch (yytype)
2748 {
2749 default:
2750 break;
2751 }
2752}
2753
2754
2755/*--------------------------------.
2756| Print this symbol on YYOUTPUT. |
2757`--------------------------------*/
2758
2759#if (defined __STDC__ || defined __C99__FUNC__ \
2760 || defined __cplusplus || defined _MSC_VER)
2761static void
2762yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
2763#else
2764static void
2765yy_symbol_print (yyoutput, yytype, yyvaluep)
2766 FILE *yyoutput;
2767 int yytype;
2768 YYSTYPE const * const yyvaluep;
Chris Lattner0275cff2007-08-06 21:00:46 +00002769#endif
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002770{
2771 if (yytype < YYNTOKENS)
2772 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2773 else
2774 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
David Greene5fd22a82007-09-04 18:46:50 +00002775
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002776 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
2777 YYFPRINTF (yyoutput, ")");
2778}
David Greene5fd22a82007-09-04 18:46:50 +00002779
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002780/*------------------------------------------------------------------.
2781| yy_stack_print -- Print the state stack from its BOTTOM up to its |
2782| TOP (included). |
2783`------------------------------------------------------------------*/
David Greene5fd22a82007-09-04 18:46:50 +00002784
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002785#if (defined __STDC__ || defined __C99__FUNC__ \
2786 || defined __cplusplus || defined _MSC_VER)
2787static void
2788yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
2789#else
2790static void
2791yy_stack_print (bottom, top)
2792 yytype_int16 *bottom;
2793 yytype_int16 *top;
Chris Lattner0275cff2007-08-06 21:00:46 +00002794#endif
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002795{
2796 YYFPRINTF (stderr, "Stack now");
2797 for (; bottom <= top; ++bottom)
2798 YYFPRINTF (stderr, " %d", *bottom);
2799 YYFPRINTF (stderr, "\n");
2800}
David Greene5fd22a82007-09-04 18:46:50 +00002801
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002802# define YY_STACK_PRINT(Bottom, Top) \
2803do { \
2804 if (yydebug) \
2805 yy_stack_print ((Bottom), (Top)); \
2806} while (YYID (0))
David Greene5fd22a82007-09-04 18:46:50 +00002807
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002808
2809/*------------------------------------------------.
2810| Report that the YYRULE is going to be reduced. |
2811`------------------------------------------------*/
2812
2813#if (defined __STDC__ || defined __C99__FUNC__ \
2814 || defined __cplusplus || defined _MSC_VER)
2815static void
2816yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
2817#else
2818static void
2819yy_reduce_print (yyvsp, yyrule)
2820 YYSTYPE *yyvsp;
2821 int yyrule;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002822#endif
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002823{
2824 int yynrhs = yyr2[yyrule];
2825 int yyi;
2826 unsigned long int yylno = yyrline[yyrule];
2827 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
2828 yyrule - 1, yylno);
2829 /* The symbols being reduced. */
2830 for (yyi = 0; yyi < yynrhs; yyi++)
2831 {
2832 fprintf (stderr, " $%d = ", yyi + 1);
2833 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
2834 &(yyvsp[(yyi + 1) - (yynrhs)])
2835 );
2836 fprintf (stderr, "\n");
2837 }
2838}
Chandler Carruth02202192007-08-04 01:56:21 +00002839
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002840# define YY_REDUCE_PRINT(Rule) \
2841do { \
2842 if (yydebug) \
2843 yy_reduce_print (yyvsp, Rule); \
2844} while (YYID (0))
Chandler Carruth02202192007-08-04 01:56:21 +00002845
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002846/* Nonzero means print parse trace. It is left uninitialized so that
2847 multiple parsers can coexist. */
2848int yydebug;
2849#else /* !YYDEBUG */
2850# define YYDPRINTF(Args)
2851# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
2852# define YY_STACK_PRINT(Bottom, Top)
2853# define YY_REDUCE_PRINT(Rule)
2854#endif /* !YYDEBUG */
2855
2856
2857/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002858#ifndef YYINITDEPTH
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002859# define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00002860#endif
2861
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002862/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2863 if the built-in stack extension method is used).
Reid Spencer68a24bd2005-08-27 18:50:39 +00002864
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002865 Do not make this value too large; the results are undefined if
2866 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
2867 evaluated with infinite-precision integer arithmetic. */
David Greene718fda32007-08-01 03:59:32 +00002868
Reid Spencer68a24bd2005-08-27 18:50:39 +00002869#ifndef YYMAXDEPTH
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002870# define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00002871#endif
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002872
Reid Spencer68a24bd2005-08-27 18:50:39 +00002873
2874
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002875#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00002876
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002877# ifndef yystrlen
2878# if defined __GLIBC__ && defined _STRING_H
2879# define yystrlen strlen
2880# else
2881/* Return the length of YYSTR. */
2882#if (defined __STDC__ || defined __C99__FUNC__ \
2883 || defined __cplusplus || defined _MSC_VER)
2884static YYSIZE_T
2885yystrlen (const char *yystr)
Dale Johannesencdd509a2007-09-07 21:07:57 +00002886#else
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002887static YYSIZE_T
2888yystrlen (yystr)
2889 const char *yystr;
2890#endif
2891{
2892 YYSIZE_T yylen;
2893 for (yylen = 0; yystr[yylen]; yylen++)
2894 continue;
2895 return yylen;
2896}
2897# endif
2898# endif
2899
2900# ifndef yystpcpy
2901# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
2902# define yystpcpy stpcpy
2903# else
2904/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2905 YYDEST. */
2906#if (defined __STDC__ || defined __C99__FUNC__ \
2907 || defined __cplusplus || defined _MSC_VER)
2908static char *
2909yystpcpy (char *yydest, const char *yysrc)
2910#else
2911static char *
2912yystpcpy (yydest, yysrc)
2913 char *yydest;
2914 const char *yysrc;
2915#endif
2916{
2917 char *yyd = yydest;
2918 const char *yys = yysrc;
2919
2920 while ((*yyd++ = *yys++) != '\0')
2921 continue;
2922
2923 return yyd - 1;
2924}
2925# endif
2926# endif
2927
2928# ifndef yytnamerr
2929/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
2930 quotes and backslashes, so that it's suitable for yyerror. The
2931 heuristic is that double-quoting is unnecessary unless the string
2932 contains an apostrophe, a comma, or backslash (other than
2933 backslash-backslash). YYSTR is taken from yytname. If YYRES is
2934 null, do not copy; instead, return the length of what the result
2935 would have been. */
2936static YYSIZE_T
2937yytnamerr (char *yyres, const char *yystr)
2938{
2939 if (*yystr == '"')
2940 {
2941 YYSIZE_T yyn = 0;
2942 char const *yyp = yystr;
2943
2944 for (;;)
2945 switch (*++yyp)
2946 {
2947 case '\'':
2948 case ',':
2949 goto do_not_strip_quotes;
2950
2951 case '\\':
2952 if (*++yyp != '\\')
2953 goto do_not_strip_quotes;
2954 /* Fall through. */
2955 default:
2956 if (yyres)
2957 yyres[yyn] = *yyp;
2958 yyn++;
2959 break;
2960
2961 case '"':
2962 if (yyres)
2963 yyres[yyn] = '\0';
2964 return yyn;
2965 }
2966 do_not_strip_quotes: ;
2967 }
2968
2969 if (! yyres)
2970 return yystrlen (yystr);
2971
2972 return yystpcpy (yyres, yystr) - yyres;
2973}
2974# endif
2975
2976/* Copy into YYRESULT an error message about the unexpected token
2977 YYCHAR while in state YYSTATE. Return the number of bytes copied,
2978 including the terminating null byte. If YYRESULT is null, do not
2979 copy anything; just return the number of bytes that would be
2980 copied. As a special case, return 0 if an ordinary "syntax error"
2981 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
2982 size calculation. */
2983static YYSIZE_T
2984yysyntax_error (char *yyresult, int yystate, int yychar)
2985{
2986 int yyn = yypact[yystate];
2987
2988 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
2989 return 0;
2990 else
2991 {
2992 int yytype = YYTRANSLATE (yychar);
2993 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
2994 YYSIZE_T yysize = yysize0;
2995 YYSIZE_T yysize1;
2996 int yysize_overflow = 0;
2997 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
2998 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
2999 int yyx;
3000
3001# if 0
3002 /* This is so xgettext sees the translatable formats that are
3003 constructed on the fly. */
3004 YY_("syntax error, unexpected %s");
3005 YY_("syntax error, unexpected %s, expecting %s");
3006 YY_("syntax error, unexpected %s, expecting %s or %s");
3007 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
3008 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
3009# endif
3010 char *yyfmt;
3011 char const *yyf;
3012 static char const yyunexpected[] = "syntax error, unexpected %s";
3013 static char const yyexpecting[] = ", expecting %s";
3014 static char const yyor[] = " or %s";
3015 char yyformat[sizeof yyunexpected
3016 + sizeof yyexpecting - 1
3017 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
3018 * (sizeof yyor - 1))];
3019 char const *yyprefix = yyexpecting;
3020
3021 /* Start YYX at -YYN if negative to avoid negative indexes in
3022 YYCHECK. */
3023 int yyxbegin = yyn < 0 ? -yyn : 0;
3024
3025 /* Stay within bounds of both yycheck and yytname. */
3026 int yychecklim = YYLAST - yyn + 1;
3027 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
3028 int yycount = 1;
3029
3030 yyarg[0] = yytname[yytype];
3031 yyfmt = yystpcpy (yyformat, yyunexpected);
3032
3033 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
3034 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
3035 {
3036 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
3037 {
3038 yycount = 1;
3039 yysize = yysize0;
3040 yyformat[sizeof yyunexpected - 1] = '\0';
3041 break;
3042 }
3043 yyarg[yycount++] = yytname[yyx];
3044 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
3045 yysize_overflow |= (yysize1 < yysize);
3046 yysize = yysize1;
3047 yyfmt = yystpcpy (yyfmt, yyprefix);
3048 yyprefix = yyor;
3049 }
3050
3051 yyf = YY_(yyformat);
3052 yysize1 = yysize + yystrlen (yyf);
3053 yysize_overflow |= (yysize1 < yysize);
3054 yysize = yysize1;
3055
3056 if (yysize_overflow)
3057 return YYSIZE_MAXIMUM;
3058
3059 if (yyresult)
3060 {
3061 /* Avoid sprintf, as that infringes on the user's name space.
3062 Don't have undefined behavior even if the translation
3063 produced a string with the wrong number of "%s"s. */
3064 char *yyp = yyresult;
3065 int yyi = 0;
3066 while ((*yyp = *yyf) != '\0')
3067 {
3068 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
3069 {
3070 yyp += yytnamerr (yyp, yyarg[yyi++]);
3071 yyf += 2;
3072 }
3073 else
3074 {
3075 yyp++;
3076 yyf++;
3077 }
3078 }
3079 }
3080 return yysize;
3081 }
3082}
3083#endif /* YYERROR_VERBOSE */
3084
3085
3086/*-----------------------------------------------.
3087| Release the memory associated to this symbol. |
3088`-----------------------------------------------*/
3089
3090/*ARGSUSED*/
3091#if (defined __STDC__ || defined __C99__FUNC__ \
3092 || defined __cplusplus || defined _MSC_VER)
3093static void
3094yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
3095#else
3096static void
3097yydestruct (yymsg, yytype, yyvaluep)
3098 const char *yymsg;
3099 int yytype;
3100 YYSTYPE *yyvaluep;
3101#endif
3102{
3103 YYUSE (yyvaluep);
3104
3105 if (!yymsg)
3106 yymsg = "Deleting";
3107 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
3108
3109 switch (yytype)
3110 {
3111
3112 default:
3113 break;
3114 }
3115}
3116
3117
3118/* Prevent warnings from -Wmissing-prototypes. */
3119
3120#ifdef YYPARSE_PARAM
3121#if defined __STDC__ || defined __cplusplus
3122int yyparse (void *YYPARSE_PARAM);
3123#else
3124int yyparse ();
3125#endif
3126#else /* ! YYPARSE_PARAM */
3127#if defined __STDC__ || defined __cplusplus
David Greene5fd22a82007-09-04 18:46:50 +00003128int yyparse (void);
Dale Johannesencdd509a2007-09-07 21:07:57 +00003129#else
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003130int yyparse ();
Dale Johannesencdd509a2007-09-07 21:07:57 +00003131#endif
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003132#endif /* ! YYPARSE_PARAM */
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003133
Chandler Carruth02202192007-08-04 01:56:21 +00003134
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003135
3136/* The look-ahead symbol. */
3137int yychar;
3138
3139/* The semantic value of the look-ahead symbol. */
3140YYSTYPE yylval;
3141
3142/* Number of syntax errors so far. */
3143int yynerrs;
3144
3145
3146
3147/*----------.
3148| yyparse. |
3149`----------*/
3150
3151#ifdef YYPARSE_PARAM
3152#if (defined __STDC__ || defined __C99__FUNC__ \
3153 || defined __cplusplus || defined _MSC_VER)
3154int
3155yyparse (void *YYPARSE_PARAM)
3156#else
3157int
3158yyparse (YYPARSE_PARAM)
3159 void *YYPARSE_PARAM;
3160#endif
3161#else /* ! YYPARSE_PARAM */
3162#if (defined __STDC__ || defined __C99__FUNC__ \
3163 || defined __cplusplus || defined _MSC_VER)
3164int
3165yyparse (void)
3166#else
3167int
3168yyparse ()
3169
Dale Johannesencdd509a2007-09-07 21:07:57 +00003170#endif
3171#endif
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003172{
3173
3174 int yystate;
3175 int yyn;
3176 int yyresult;
3177 /* Number of tokens to shift before error messages enabled. */
3178 int yyerrstatus;
3179 /* Look-ahead token as an internal (translated) token number. */
3180 int yytoken = 0;
3181#if YYERROR_VERBOSE
3182 /* Buffer for error messages, and its allocated size. */
3183 char yymsgbuf[128];
3184 char *yymsg = yymsgbuf;
3185 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
Dale Johannesencdd509a2007-09-07 21:07:57 +00003186#endif
Chandler Carruth02202192007-08-04 01:56:21 +00003187
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003188 /* Three stacks and their tools:
3189 `yyss': related to states,
3190 `yyvs': related to semantic values,
3191 `yyls': related to locations.
3192
3193 Refer to the stacks thru separate pointers, to allow yyoverflow
3194 to reallocate them elsewhere. */
3195
3196 /* The state stack. */
3197 yytype_int16 yyssa[YYINITDEPTH];
3198 yytype_int16 *yyss = yyssa;
3199 yytype_int16 *yyssp;
3200
3201 /* The semantic value stack. */
3202 YYSTYPE yyvsa[YYINITDEPTH];
3203 YYSTYPE *yyvs = yyvsa;
3204 YYSTYPE *yyvsp;
3205
3206
3207
3208#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
3209
3210 YYSIZE_T yystacksize = YYINITDEPTH;
3211
3212 /* The variables used to return semantic value and location from the
3213 action routines. */
3214 YYSTYPE yyval;
3215
3216
3217 /* The number of symbols on the RHS of the reduced rule.
3218 Keep to zero when no symbol should be popped. */
3219 int yylen = 0;
3220
3221 YYDPRINTF ((stderr, "Starting parse\n"));
3222
Reid Spencer68a24bd2005-08-27 18:50:39 +00003223 yystate = 0;
3224 yyerrstatus = 0;
3225 yynerrs = 0;
3226 yychar = YYEMPTY; /* Cause a token to be read. */
3227
3228 /* Initialize stack pointers.
3229 Waste one element of value and location stack
3230 so that they stay on the same level as the state stack.
3231 The wasted elements are never initialized. */
3232
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003233 yyssp = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003234 yyvsp = yyvs;
3235
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003236 goto yysetstate;
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003237
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003238/*------------------------------------------------------------.
3239| yynewstate -- Push a new state, which is found in yystate. |
3240`------------------------------------------------------------*/
3241 yynewstate:
3242 /* In all cases, when you get here, the value and location stacks
3243 have just been pushed. So pushing a state here evens the stacks. */
3244 yyssp++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003245
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003246 yysetstate:
3247 *yyssp = yystate;
3248
3249 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003250 {
3251 /* Get the current used size of the three stacks, in elements. */
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003252 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003253
3254#ifdef yyoverflow
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003255 {
3256 /* Give user a chance to reallocate the stack. Use copies of
3257 these so that the &'s don't force the real ones into
3258 memory. */
3259 YYSTYPE *yyvs1 = yyvs;
3260 yytype_int16 *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003261
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003262
3263 /* Each stack pointer address is followed by the size of the
3264 data in use in that stack, in bytes. This used to be a
3265 conditional around just the two extra args, but that might
3266 be undefined if yyoverflow is a macro. */
3267 yyoverflow (YY_("memory exhausted"),
3268 &yyss1, yysize * sizeof (*yyssp),
3269 &yyvs1, yysize * sizeof (*yyvsp),
3270
3271 &yystacksize);
3272
3273 yyss = yyss1;
3274 yyvs = yyvs1;
3275 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00003276#else /* no yyoverflow */
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003277# ifndef YYSTACK_RELOCATE
3278 goto yyexhaustedlab;
3279# else
Reid Spencer68a24bd2005-08-27 18:50:39 +00003280 /* Extend the stack our own way. */
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003281 if (YYMAXDEPTH <= yystacksize)
3282 goto yyexhaustedlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003283 yystacksize *= 2;
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003284 if (YYMAXDEPTH < yystacksize)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003285 yystacksize = YYMAXDEPTH;
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003286
3287 {
3288 yytype_int16 *yyss1 = yyss;
3289 union yyalloc *yyptr =
3290 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3291 if (! yyptr)
3292 goto yyexhaustedlab;
3293 YYSTACK_RELOCATE (yyss);
3294 YYSTACK_RELOCATE (yyvs);
3295
3296# undef YYSTACK_RELOCATE
3297 if (yyss1 != yyssa)
3298 YYSTACK_FREE (yyss1);
3299 }
3300# endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00003301#endif /* no yyoverflow */
3302
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003303 yyssp = yyss + yysize - 1;
3304 yyvsp = yyvs + yysize - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003305
3306
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003307 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3308 (unsigned long int) yystacksize));
3309
3310 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003311 YYABORT;
3312 }
3313
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003314 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003315
3316 goto yybackup;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003317
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003318/*-----------.
3319| yybackup. |
3320`-----------*/
3321yybackup:
Andrew Lenharth6353e052006-12-08 18:07:09 +00003322
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003323 /* Do appropriate processing given the current state. Read a
3324 look-ahead token if we need one and don't already have one. */
Reid Spencer7780acb2007-04-16 06:56:07 +00003325
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003326 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003327 yyn = yypact[yystate];
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003328 if (yyn == YYPACT_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003329 goto yydefault;
3330
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003331 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003332
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003333 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003334 if (yychar == YYEMPTY)
3335 {
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003336 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003337 yychar = YYLEX;
3338 }
3339
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003340 if (yychar <= YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003341 {
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003342 yychar = yytoken = YYEOF;
3343 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003344 }
3345 else
3346 {
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003347 yytoken = YYTRANSLATE (yychar);
3348 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003349 }
3350
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003351 /* If the proper action on seeing token YYTOKEN is to reduce or to
3352 detect an error, take that action. */
3353 yyn += yytoken;
3354 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003355 goto yydefault;
3356 yyn = yytable[yyn];
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003357 if (yyn <= 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003358 {
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003359 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003360 goto yyerrlab;
3361 yyn = -yyn;
3362 goto yyreduce;
3363 }
3364
3365 if (yyn == YYFINAL)
3366 YYACCEPT;
3367
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003368 /* Count tokens shifted since error; after three, turn off error
3369 status. */
3370 if (yyerrstatus)
3371 yyerrstatus--;
Dale Johannesencdd509a2007-09-07 21:07:57 +00003372
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003373 /* Shift the look-ahead token. */
3374 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003375
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003376 /* Discard the shifted token unless it is eof. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003377 if (yychar != YYEOF)
3378 yychar = YYEMPTY;
3379
Chris Lattner0275cff2007-08-06 21:00:46 +00003380 yystate = yyn;
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003381 *++yyvsp = yylval;
3382
Reid Spencer68a24bd2005-08-27 18:50:39 +00003383 goto yynewstate;
3384
Dale Johannesencdd509a2007-09-07 21:07:57 +00003385
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003386/*-----------------------------------------------------------.
3387| yydefault -- do the default action for the current state. |
3388`-----------------------------------------------------------*/
3389yydefault:
Reid Spencer68a24bd2005-08-27 18:50:39 +00003390 yyn = yydefact[yystate];
3391 if (yyn == 0)
3392 goto yyerrlab;
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003393 goto yyreduce;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003394
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003395
3396/*-----------------------------.
3397| yyreduce -- Do a reduction. |
3398`-----------------------------*/
Reid Spencer68a24bd2005-08-27 18:50:39 +00003399yyreduce:
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003400 /* yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003401 yylen = yyr2[yyn];
3402
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003403 /* If YYLEN is nonzero, implement the default value of the action:
3404 `$$ = $1'.
3405
3406 Otherwise, the following line sets YYVAL to garbage.
3407 This behavior is undocumented and Bison
3408 users should not rely upon it. Assigning to YYVAL
3409 unconditionally makes the parser a bit smaller, and it avoids a
3410 GCC warning that YYVAL may be used uninitialized. */
3411 yyval = yyvsp[1-yylen];
3412
3413
3414 YY_REDUCE_PRINT (yyn);
3415 switch (yyn)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003416 {
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003417 case 29:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003418#line 1111 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003419 { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;}
3420 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003421
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003422 case 30:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003423#line 1111 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003424 { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;}
3425 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003426
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003427 case 31:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003428#line 1112 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003429 { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;}
3430 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003431
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003432 case 32:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003433#line 1112 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003434 { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;}
3435 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003436
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003437 case 33:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003438#line 1113 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003439 { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;}
3440 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003441
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003442 case 34:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003443#line 1113 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003444 { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;}
3445 break;
3446
3447 case 35:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003448#line 1114 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003449 { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;}
3450 break;
3451
3452 case 36:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003453#line 1114 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003454 { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;}
3455 break;
3456
3457 case 37:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003458#line 1115 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003459 { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;}
3460 break;
3461
3462 case 38:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003463#line 1115 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003464 { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;}
3465 break;
3466
3467 case 39:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003468#line 1119 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003469 { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;}
3470 break;
3471
3472 case 40:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003473#line 1119 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003474 { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;}
3475 break;
3476
3477 case 41:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003478#line 1120 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003479 { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;}
3480 break;
3481
3482 case 42:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003483#line 1120 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003484 { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;}
3485 break;
3486
3487 case 43:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003488#line 1121 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003489 { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;}
3490 break;
3491
3492 case 44:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003493#line 1121 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003494 { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;}
3495 break;
3496
3497 case 45:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003498#line 1122 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003499 { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;}
3500 break;
3501
3502 case 46:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003503#line 1122 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003504 { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;}
3505 break;
3506
3507 case 47:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003508#line 1123 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003509 { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;}
3510 break;
3511
3512 case 48:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003513#line 1123 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003514 { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;}
3515 break;
3516
3517 case 49:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003518#line 1124 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003519 { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;}
3520 break;
3521
3522 case 50:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003523#line 1124 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003524 { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;}
3525 break;
3526
3527 case 51:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003528#line 1125 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003529 { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;}
3530 break;
3531
3532 case 52:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003533#line 1125 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003534 { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;}
3535 break;
3536
3537 case 53:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003538#line 1126 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003539 { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;}
3540 break;
3541
3542 case 54:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003543#line 1127 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003544 { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;}
3545 break;
3546
3547 case 65:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003548#line 1136 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003549 { (yyval.StrVal) = 0; ;}
3550 break;
3551
3552 case 66:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003553#line 1140 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003554 {
3555 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003556 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003557 ;}
3558 break;
3559
3560 case 67:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003561#line 1144 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003562 {
3563 (yyval.StrVal) = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003564 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003565 ;}
3566 break;
3567
3568 case 71:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003569#line 1152 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003570 {
3571 (yyval.StrVal) = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003572 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003573 ;}
3574 break;
3575
3576 case 72:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003577#line 1157 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003578 {
3579 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003580 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003581 ;}
3582 break;
3583
3584 case 73:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003585#line 1163 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003586 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3587 break;
3588
3589 case 74:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003590#line 1164 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003591 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3592 break;
3593
3594 case 75:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003595#line 1165 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003596 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3597 break;
3598
3599 case 76:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003600#line 1166 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003601 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3602 break;
3603
3604 case 77:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003605#line 1167 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003606 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3607 break;
3608
3609 case 78:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003610#line 1171 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003611 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3612 break;
3613
3614 case 79:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003615#line 1172 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003616 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3617 break;
3618
3619 case 80:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003620#line 1173 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003621 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3622 break;
3623
3624 case 81:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003625#line 1177 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003626 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3627 break;
3628
3629 case 82:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003630#line 1178 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003631 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3632 break;
3633
3634 case 83:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003635#line 1179 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003636 { (yyval.Visibility) = GlobalValue::HiddenVisibility; ;}
3637 break;
3638
3639 case 84:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003640#line 1180 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003641 { (yyval.Visibility) = GlobalValue::ProtectedVisibility; ;}
3642 break;
3643
3644 case 85:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003645#line 1184 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003646 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3647 break;
3648
3649 case 86:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003650#line 1185 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003651 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3652 break;
3653
3654 case 87:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003655#line 1186 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003656 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3657 break;
3658
3659 case 88:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003660#line 1190 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003661 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3662 break;
3663
3664 case 89:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003665#line 1191 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003666 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3667 break;
3668
3669 case 90:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003670#line 1192 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003671 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3672 break;
3673
3674 case 91:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003675#line 1193 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003676 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3677 break;
3678
3679 case 92:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003680#line 1194 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003681 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3682 break;
3683
3684 case 93:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003685#line 1198 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003686 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3687 break;
3688
3689 case 94:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003690#line 1199 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003691 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3692 break;
3693
3694 case 95:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003695#line 1200 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003696 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3697 break;
3698
3699 case 96:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003700#line 1203 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003701 { (yyval.UIntVal) = CallingConv::C; ;}
3702 break;
3703
3704 case 97:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003705#line 1204 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003706 { (yyval.UIntVal) = CallingConv::C; ;}
3707 break;
3708
3709 case 98:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003710#line 1205 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003711 { (yyval.UIntVal) = CallingConv::Fast; ;}
3712 break;
3713
3714 case 99:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003715#line 1206 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003716 { (yyval.UIntVal) = CallingConv::Cold; ;}
3717 break;
3718
3719 case 100:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003720#line 1207 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003721 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
3722 break;
3723
3724 case 101:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003725#line 1208 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003726 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
3727 break;
3728
3729 case 102:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003730#line 1209 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003731 {
3732 if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003733 GEN_ERROR("Calling conv too large");
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003734 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003735 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003736 ;}
3737 break;
3738
3739 case 103:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003740#line 1216 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003741 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
3742 break;
3743
3744 case 104:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003745#line 1217 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003746 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
3747 break;
3748
3749 case 105:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003750#line 1218 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003751 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
3752 break;
3753
3754 case 106:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003755#line 1219 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003756 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
3757 break;
3758
3759 case 107:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003760#line 1220 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003761 { (yyval.ParamAttrs) = ParamAttr::InReg; ;}
3762 break;
3763
3764 case 108:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003765#line 1221 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003766 { (yyval.ParamAttrs) = ParamAttr::StructRet; ;}
3767 break;
3768
3769 case 109:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003770#line 1222 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003771 { (yyval.ParamAttrs) = ParamAttr::NoAlias; ;}
3772 break;
3773
3774 case 110:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003775#line 1223 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003776 { (yyval.ParamAttrs) = ParamAttr::ByVal; ;}
3777 break;
3778
3779 case 111:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003780#line 1224 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003781 { (yyval.ParamAttrs) = ParamAttr::Nest; ;}
3782 break;
3783
3784 case 112:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003785#line 1227 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003786 { (yyval.ParamAttrs) = ParamAttr::None; ;}
3787 break;
3788
3789 case 113:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003790#line 1228 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003791 {
3792 (yyval.ParamAttrs) = (yyvsp[(1) - (2)].ParamAttrs) | (yyvsp[(2) - (2)].ParamAttrs);
3793 ;}
3794 break;
3795
3796 case 114:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003797#line 1233 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003798 { (yyval.ParamAttrs) = ParamAttr::NoReturn; ;}
3799 break;
3800
3801 case 115:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003802#line 1234 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003803 { (yyval.ParamAttrs) = ParamAttr::NoUnwind; ;}
3804 break;
3805
3806 case 116:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003807#line 1235 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003808 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
3809 break;
3810
3811 case 117:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003812#line 1236 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003813 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
3814 break;
3815
3816 case 118:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003817#line 1237 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Duncan Sandsdc024672007-11-27 13:23:08 +00003818 { (yyval.ParamAttrs) = ParamAttr::ReadNone; ;}
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003819 break;
3820
3821 case 119:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003822#line 1238 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Duncan Sandsdc024672007-11-27 13:23:08 +00003823 { (yyval.ParamAttrs) = ParamAttr::ReadOnly; ;}
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003824 break;
3825
3826 case 120:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003827#line 1241 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003828 { (yyval.ParamAttrs) = ParamAttr::None; ;}
3829 break;
3830
3831 case 121:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003832#line 1242 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003833 {
3834 (yyval.ParamAttrs) = (yyvsp[(1) - (2)].ParamAttrs) | (yyvsp[(2) - (2)].ParamAttrs);
3835 ;}
3836 break;
3837
3838 case 122:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003839#line 1249 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003840 { (yyval.UIntVal) = 0; ;}
3841 break;
3842
3843 case 123:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003844#line 1250 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003845 {
3846 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
3847 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003848 GEN_ERROR("Alignment must be a power of two");
3849 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003850;}
3851 break;
3852
3853 case 124:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003854#line 1256 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003855 { (yyval.UIntVal) = 0; ;}
3856 break;
3857
3858 case 125:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003859#line 1257 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003860 {
3861 (yyval.UIntVal) = (yyvsp[(3) - (3)].UInt64Val);
3862 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003863 GEN_ERROR("Alignment must be a power of two");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003864 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003865;}
3866 break;
3867
3868 case 126:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003869#line 1265 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003870 {
3871 for (unsigned i = 0, e = (yyvsp[(2) - (2)].StrVal)->length(); i != e; ++i)
3872 if ((*(yyvsp[(2) - (2)].StrVal))[i] == '"' || (*(yyvsp[(2) - (2)].StrVal))[i] == '\\')
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003873 GEN_ERROR("Invalid character in section name");
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003874 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003875 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003876;}
3877 break;
3878
3879 case 127:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003880#line 1273 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003881 { (yyval.StrVal) = 0; ;}
3882 break;
3883
3884 case 128:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003885#line 1274 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003886 { (yyval.StrVal) = (yyvsp[(1) - (1)].StrVal); ;}
3887 break;
3888
3889 case 129:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003890#line 1279 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003891 {;}
3892 break;
3893
3894 case 130:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003895#line 1280 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003896 {;}
3897 break;
3898
3899 case 131:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003900#line 1281 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003901 {
3902 CurGV->setSection(*(yyvsp[(1) - (1)].StrVal));
3903 delete (yyvsp[(1) - (1)].StrVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003904 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003905 ;}
3906 break;
3907
3908 case 132:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003909#line 1286 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003910 {
3911 if ((yyvsp[(2) - (2)].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[(2) - (2)].UInt64Val)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003912 GEN_ERROR("Alignment must be a power of two");
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003913 CurGV->setAlignment((yyvsp[(2) - (2)].UInt64Val));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003914 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003915 ;}
3916 break;
3917
3918 case 140:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003919#line 1302 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003920 {
3921 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003922 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003923 ;}
3924 break;
3925
3926 case 141:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003927#line 1306 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003928 {
3929 (yyval.TypeVal) = new PATypeHolder((yyvsp[(1) - (1)].PrimType));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003930 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003931 ;}
3932 break;
3933
3934 case 142:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003935#line 1310 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003936 { // Pointer type?
3937 if (*(yyvsp[(1) - (2)].TypeVal) == Type::LabelTy)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003938 GEN_ERROR("Cannot form a pointer to a basic block");
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003939 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[(1) - (2)].TypeVal))));
3940 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003941 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003942 ;}
3943 break;
3944
3945 case 143:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003946#line 1317 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003947 { // Named types are also simple types...
3948 const Type* tmp = getTypeVal((yyvsp[(1) - (1)].ValIDVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003949 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003950 (yyval.TypeVal) = new PATypeHolder(tmp);
3951 ;}
3952 break;
3953
3954 case 144:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003955#line 1322 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003956 { // Type UpReference
3957 if ((yyvsp[(2) - (2)].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003958 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003959 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[(2) - (2)].UInt64Val), OT)); // Add to vector...
3960 (yyval.TypeVal) = new PATypeHolder(OT);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003961 UR_OUT("New Upreference!\n");
3962 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003963 ;}
3964 break;
3965
3966 case 145:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003967#line 1330 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003968 {
Duncan Sandsdc024672007-11-27 13:23:08 +00003969 // Allow but ignore attributes on function types; this permits auto-upgrade.
3970 // FIXME: remove in LLVM 3.0.
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003971 const Type* RetTy = *(yyvsp[(1) - (5)].TypeVal);
3972 if (!(RetTy->isFirstClassType() || isa<OpaqueType>(RetTy)))
3973 GEN_ERROR("LLVM Functions cannot return aggregates");
3974
Reid Spencer41dff5e2007-01-26 08:05:27 +00003975 std::vector<const Type*> Params;
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003976 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00003977 for (; I != E; ++I ) {
Reid Spencer66728ef2007-03-20 01:13:36 +00003978 const Type *Ty = I->Ty->get();
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003979 if (!(Ty->isFirstClassType() || isa<OpaqueType>(Ty)))
3980 GEN_ERROR("Function arguments must be value types!");
Reid Spencer66728ef2007-03-20 01:13:36 +00003981 Params.push_back(Ty);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003982 }
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003983 CHECK_FOR_ERROR
3984
Reid Spencer41dff5e2007-01-26 08:05:27 +00003985 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3986 if (isVarArg) Params.pop_back();
3987
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003988 FunctionType *FT = FunctionType::get(RetTy, Params, isVarArg);
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003989 delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list
3990 delete (yyvsp[(1) - (5)].TypeVal); // Delete the return type handle
3991 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencere4d87aa2006-12-23 06:05:41 +00003992 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003993 ;}
3994 break;
3995
3996 case 146:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003997#line 1356 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00003998 {
Duncan Sandsdc024672007-11-27 13:23:08 +00003999 // Allow but ignore attributes on function types; this permits auto-upgrade.
4000 // FIXME: remove in LLVM 3.0.
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004001 std::vector<const Type*> Params;
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004002 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00004003 for ( ; I != E; ++I ) {
Reid Spencer66728ef2007-03-20 01:13:36 +00004004 const Type* Ty = I->Ty->get();
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004005 if (!(Ty->isFirstClassType() || isa<OpaqueType>(Ty)))
4006 GEN_ERROR("Function arguments must be value types!");
Reid Spencer66728ef2007-03-20 01:13:36 +00004007 Params.push_back(Ty);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004008 }
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004009 CHECK_FOR_ERROR
4010
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004011 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4012 if (isVarArg) Params.pop_back();
4013
Duncan Sandsdc024672007-11-27 13:23:08 +00004014 FunctionType *FT = FunctionType::get((yyvsp[(1) - (5)].PrimType), Params, isVarArg);
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004015 delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list
4016 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004017 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004018 ;}
4019 break;
4020
4021 case 147:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004022#line 1378 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004023 { // Sized array type?
4024 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
4025 delete (yyvsp[(4) - (5)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004026 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004027 ;}
4028 break;
4029
4030 case 148:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004031#line 1383 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004032 { // Vector type?
4033 const llvm::Type* ElemTy = (yyvsp[(4) - (5)].TypeVal)->get();
4034 if ((unsigned)(yyvsp[(2) - (5)].UInt64Val) != (yyvsp[(2) - (5)].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004035 GEN_ERROR("Unsigned result not equal to signed result");
4036 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
4037 GEN_ERROR("Element type of a VectorType must be primitive");
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004038 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(VectorType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
4039 delete (yyvsp[(4) - (5)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004040 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004041 ;}
4042 break;
4043
4044 case 149:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004045#line 1393 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004046 { // Structure type?
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004047 std::vector<const Type*> Elements;
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004048 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(2) - (3)].TypeList)->begin(),
4049 E = (yyvsp[(2) - (3)].TypeList)->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004050 Elements.push_back(*I);
4051
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004052 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
4053 delete (yyvsp[(2) - (3)].TypeList);
Reid Spencer14310612006-12-31 05:40:51 +00004054 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004055 ;}
4056 break;
4057
4058 case 150:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004059#line 1403 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004060 { // Empty structure type?
4061 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer14310612006-12-31 05:40:51 +00004062 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004063 ;}
4064 break;
4065
4066 case 151:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004067#line 1407 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004068 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004069 std::vector<const Type*> Elements;
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004070 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(3) - (5)].TypeList)->begin(),
4071 E = (yyvsp[(3) - (5)].TypeList)->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004072 Elements.push_back(*I);
4073
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004074 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
4075 delete (yyvsp[(3) - (5)].TypeList);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004076 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004077 ;}
4078 break;
4079
4080 case 152:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004081#line 1417 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004082 { // Empty structure type?
4083 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004084 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004085 ;}
4086 break;
4087
4088 case 153:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004089#line 1424 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Duncan Sandsdc024672007-11-27 13:23:08 +00004090 {
4091 // Allow but ignore attributes on function types; this permits auto-upgrade.
4092 // FIXME: remove in LLVM 3.0.
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004093 (yyval.TypeWithAttrs).Ty = (yyvsp[(1) - (2)].TypeVal);
Duncan Sandsdc024672007-11-27 13:23:08 +00004094 (yyval.TypeWithAttrs).Attrs = ParamAttr::None;
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004095 ;}
4096 break;
4097
4098 case 154:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004099#line 1433 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004100 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004101 if (!UpRefs.empty())
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004102 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (1)].TypeVal))->getDescription());
4103 if (!(*(yyvsp[(1) - (1)].TypeVal))->isFirstClassType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004104 GEN_ERROR("LLVM functions cannot return aggregate types");
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004105 (yyval.TypeVal) = (yyvsp[(1) - (1)].TypeVal);
4106 ;}
4107 break;
4108
4109 case 155:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004110#line 1440 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004111 {
4112 (yyval.TypeVal) = new PATypeHolder(Type::VoidTy);
4113 ;}
4114 break;
4115
4116 case 156:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004117#line 1445 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004118 {
4119 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
4120 (yyval.TypeWithAttrsList)->push_back((yyvsp[(1) - (1)].TypeWithAttrs));
Reid Spencer3da59db2006-11-27 01:05:10 +00004121 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004122 ;}
4123 break;
4124
4125 case 157:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004126#line 1450 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004127 {
4128 ((yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList))->push_back((yyvsp[(3) - (3)].TypeWithAttrs));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004129 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004130 ;}
4131 break;
4132
4133 case 159:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004134#line 1458 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004135 {
4136 (yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList);
Reid Spencer18da0722007-04-11 02:44:20 +00004137 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004138 TWA.Ty = new PATypeHolder(Type::VoidTy);
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004139 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004140 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004141 ;}
4142 break;
4143
4144 case 160:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004145#line 1465 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004146 {
4147 (yyval.TypeWithAttrsList) = new TypeWithAttrsList;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004148 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
4149 TWA.Ty = new PATypeHolder(Type::VoidTy);
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004150 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004151 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004152 ;}
4153 break;
4154
4155 case 161:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004156#line 1472 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004157 {
4158 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004159 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004160 ;}
4161 break;
4162
4163 case 162:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004164#line 1480 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004165 {
4166 (yyval.TypeList) = new std::list<PATypeHolder>();
4167 (yyval.TypeList)->push_back(*(yyvsp[(1) - (1)].TypeVal));
4168 delete (yyvsp[(1) - (1)].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00004169 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004170 ;}
4171 break;
4172
4173 case 163:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004174#line 1486 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004175 {
4176 ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back(*(yyvsp[(3) - (3)].TypeVal));
4177 delete (yyvsp[(3) - (3)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004178 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004179 ;}
4180 break;
4181
4182 case 164:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004183#line 1498 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004184 { // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00004185 if (!UpRefs.empty())
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004186 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4187 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (4)].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004188 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00004189 GEN_ERROR("Cannot make array constant with type: '" +
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004190 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004191 const Type *ETy = ATy->getElementType();
4192 int NumElements = ATy->getNumElements();
4193
4194 // Verify that we have the correct size...
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004195 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004196 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004197 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00004198 itostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004199
4200 // Verify all elements are correct type!
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004201 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4202 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004203 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
4204 ETy->getDescription() +"' as required!\nIt is of type '"+
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004205 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004206 }
4207
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004208 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[(3) - (4)].ConstVector));
4209 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004210 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004211 ;}
4212 break;
4213
4214 case 165:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004215#line 1526 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004216 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004217 if (!UpRefs.empty())
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004218 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4219 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004220 if (ATy == 0)
4221 GEN_ERROR("Cannot make array constant with type: '" +
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004222 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004223
Andrew Lenharth6353e052006-12-08 18:07:09 +00004224 int NumElements = ATy->getNumElements();
4225 if (NumElements != -1 && NumElements != 0)
4226 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Reid Spencerb5334b02007-02-05 10:18:06 +00004227 " arguments, but has size of " + itostr(NumElements) +"");
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004228 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
4229 delete (yyvsp[(1) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004230 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004231 ;}
4232 break;
4233
4234 case 166:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004235#line 1542 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004236 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004237 if (!UpRefs.empty())
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004238 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4239 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004240 if (ATy == 0)
4241 GEN_ERROR("Cannot make array constant with type: '" +
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004242 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004243
4244 int NumElements = ATy->getNumElements();
4245 const Type *ETy = ATy->getElementType();
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004246 if (NumElements != -1 && NumElements != int((yyvsp[(3) - (3)].StrVal)->length()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004247 GEN_ERROR("Can't build string constant of size " +
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004248 itostr((int)((yyvsp[(3) - (3)].StrVal)->length())) +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004249 " when array has size " + itostr(NumElements) + "");
4250 std::vector<Constant*> Vals;
4251 if (ETy == Type::Int8Ty) {
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004252 for (unsigned i = 0; i < (yyvsp[(3) - (3)].StrVal)->length(); ++i)
4253 Vals.push_back(ConstantInt::get(ETy, (*(yyvsp[(3) - (3)].StrVal))[i]));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004254 } else {
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004255 delete (yyvsp[(3) - (3)].StrVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004256 GEN_ERROR("Cannot build string arrays of non byte sized elements");
4257 }
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004258 delete (yyvsp[(3) - (3)].StrVal);
4259 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
4260 delete (yyvsp[(1) - (3)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004261 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004262 ;}
4263 break;
4264
4265 case 167:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004266#line 1569 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004267 { // Nonempty unsized arr
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004268 if (!UpRefs.empty())
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004269 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4270 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[(1) - (4)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004271 if (PTy == 0)
4272 GEN_ERROR("Cannot make packed constant with type: '" +
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004273 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004274 const Type *ETy = PTy->getElementType();
4275 int NumElements = PTy->getNumElements();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004276
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004277 // Verify that we have the correct size...
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004278 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004279 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004280 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00004281 itostr(NumElements) + "");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004282
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004283 // Verify all elements are correct type!
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004284 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4285 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004286 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
4287 ETy->getDescription() +"' as required!\nIt is of type '"+
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004288 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004289 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00004290
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004291 (yyval.ConstVal) = ConstantVector::get(PTy, *(yyvsp[(3) - (4)].ConstVector));
4292 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004293 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004294 ;}
4295 break;
4296
4297 case 168:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004298#line 1597 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004299 {
4300 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (4)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004301 if (STy == 0)
4302 GEN_ERROR("Cannot make struct constant with type: '" +
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004303 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004304
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004305 if ((yyvsp[(3) - (4)].ConstVector)->size() != STy->getNumContainedTypes())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004306 GEN_ERROR("Illegal number of initializers for structure type");
4307
4308 // Check to ensure that constants are compatible with the type initializer!
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004309 for (unsigned i = 0, e = (yyvsp[(3) - (4)].ConstVector)->size(); i != e; ++i)
4310 if ((*(yyvsp[(3) - (4)].ConstVector))[i]->getType() != STy->getElementType(i))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004311 GEN_ERROR("Expected type '" +
4312 STy->getElementType(i)->getDescription() +
4313 "' for element #" + utostr(i) +
4314 " of structure initializer");
4315
4316 // Check to ensure that Type is not packed
4317 if (STy->isPacked())
4318 GEN_ERROR("Unpacked Initializer to vector type '" +
4319 STy->getDescription() + "'");
4320
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004321 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(3) - (4)].ConstVector));
4322 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004323 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004324 ;}
4325 break;
4326
4327 case 169:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004328#line 1623 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004329 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004330 if (!UpRefs.empty())
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004331 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4332 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004333 if (STy == 0)
4334 GEN_ERROR("Cannot make struct constant with type: '" +
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004335 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004336
4337 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004338 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004339
4340 // Check to ensure that Type is not packed
4341 if (STy->isPacked())
Chris Lattner6cdc6822007-04-26 05:31:05 +00004342 GEN_ERROR("Unpacked Initializer to vector type '" +
4343 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004344
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004345 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4346 delete (yyvsp[(1) - (3)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004347 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004348 ;}
4349 break;
4350
4351 case 170:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004352#line 1643 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004353 {
4354 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (6)].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004355 if (STy == 0)
4356 GEN_ERROR("Cannot make struct constant with type: '" +
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004357 (*(yyvsp[(1) - (6)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004358
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004359 if ((yyvsp[(4) - (6)].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00004360 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004361
4362 // Check to ensure that constants are compatible with the type initializer!
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004363 for (unsigned i = 0, e = (yyvsp[(4) - (6)].ConstVector)->size(); i != e; ++i)
4364 if ((*(yyvsp[(4) - (6)].ConstVector))[i]->getType() != STy->getElementType(i))
Reid Spencer41dff5e2007-01-26 08:05:27 +00004365 GEN_ERROR("Expected type '" +
4366 STy->getElementType(i)->getDescription() +
4367 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00004368 " of structure initializer");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004369
4370 // Check to ensure that Type is packed
4371 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00004372 GEN_ERROR("Vector initializer to non-vector type '" +
4373 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004374
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004375 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(4) - (6)].ConstVector));
4376 delete (yyvsp[(1) - (6)].TypeVal); delete (yyvsp[(4) - (6)].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004377 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004378 ;}
4379 break;
4380
4381 case 171:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004382#line 1669 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004383 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004384 if (!UpRefs.empty())
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004385 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (5)].TypeVal))->getDescription());
4386 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (5)].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004387 if (STy == 0)
4388 GEN_ERROR("Cannot make struct constant with type: '" +
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004389 (*(yyvsp[(1) - (5)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004390
4391 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004392 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004393
4394 // Check to ensure that Type is packed
4395 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00004396 GEN_ERROR("Vector initializer to non-vector type '" +
4397 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004398
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004399 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4400 delete (yyvsp[(1) - (5)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004401 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004402 ;}
4403 break;
4404
4405 case 172:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004406#line 1689 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004407 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004408 if (!UpRefs.empty())
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004409 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4410 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004411 if (PTy == 0)
4412 GEN_ERROR("Cannot make null pointer constant with type: '" +
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004413 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004414
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004415 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
4416 delete (yyvsp[(1) - (2)].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004417 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004418 ;}
4419 break;
4420
4421 case 173:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004422#line 1701 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004423 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004424 if (!UpRefs.empty())
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004425 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4426 (yyval.ConstVal) = UndefValue::get((yyvsp[(1) - (2)].TypeVal)->get());
4427 delete (yyvsp[(1) - (2)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004428 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004429 ;}
4430 break;
4431
4432 case 174:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004433#line 1708 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004434 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004435 if (!UpRefs.empty())
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004436 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4437 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004438 if (Ty == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004439 GEN_ERROR("Global const reference must be a pointer type");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004440
4441 // ConstExprs can exist in the body of a function, thus creating
4442 // GlobalValues whenever they refer to a variable. Because we are in
Reid Spencer93c40032007-03-19 18:40:50 +00004443 // the context of a function, getExistingVal will search the functions
Reid Spencer68a24bd2005-08-27 18:50:39 +00004444 // symbol table instead of the module symbol table for the global symbol,
4445 // which throws things all off. To get around this, we just tell
Reid Spencer93c40032007-03-19 18:40:50 +00004446 // getExistingVal that we are at global scope here.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004447 //
4448 Function *SavedCurFn = CurFun.CurrentFunction;
4449 CurFun.CurrentFunction = 0;
4450
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004451 Value *V = getExistingVal(Ty, (yyvsp[(2) - (2)].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004452 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004453
4454 CurFun.CurrentFunction = SavedCurFn;
4455
4456 // If this is an initializer for a constant pointer, which is referencing a
4457 // (currently) undefined variable, create a stub now that shall be replaced
4458 // in the future with the right type of variable.
4459 //
4460 if (V == 0) {
Reid Spencera9720f52007-02-05 17:04:00 +00004461 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004462 const PointerType *PT = cast<PointerType>(Ty);
4463
4464 // First check to see if the forward references value is already created!
4465 PerModuleInfo::GlobalRefsType::iterator I =
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004466 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004467
4468 if (I != CurModule.GlobalRefs.end()) {
4469 V = I->second; // Placeholder already exists, use it...
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004470 (yyvsp[(2) - (2)].ValIDVal).destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004471 } else {
4472 std::string Name;
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004473 if ((yyvsp[(2) - (2)].ValIDVal).Type == ValID::GlobalName)
4474 Name = (yyvsp[(2) - (2)].ValIDVal).getName();
4475 else if ((yyvsp[(2) - (2)].ValIDVal).Type != ValID::GlobalID)
Reid Spencer41dff5e2007-01-26 08:05:27 +00004476 GEN_ERROR("Invalid reference to global");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004477
4478 // Create the forward referenced global.
4479 GlobalValue *GV;
4480 if (const FunctionType *FTy =
4481 dyn_cast<FunctionType>(PT->getElementType())) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00004482 GV = new Function(FTy, GlobalValue::ExternalWeakLinkage, Name,
Reid Spencer68a24bd2005-08-27 18:50:39 +00004483 CurModule.CurrentModule);
4484 } else {
4485 GV = new GlobalVariable(PT->getElementType(), false,
Chris Lattner6cdc6822007-04-26 05:31:05 +00004486 GlobalValue::ExternalWeakLinkage, 0,
Reid Spencer68a24bd2005-08-27 18:50:39 +00004487 Name, CurModule.CurrentModule);
4488 }
4489
4490 // Keep track of the fact that we have a forward ref to recycle it
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004491 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004492 V = GV;
4493 }
4494 }
4495
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004496 (yyval.ConstVal) = cast<GlobalValue>(V);
4497 delete (yyvsp[(1) - (2)].TypeVal); // Free the type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00004498 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004499 ;}
4500 break;
4501
4502 case 175:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004503#line 1774 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004504 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004505 if (!UpRefs.empty())
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004506 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4507 if ((yyvsp[(1) - (2)].TypeVal)->get() != (yyvsp[(2) - (2)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004508 GEN_ERROR("Mismatched types for constant expression: " +
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004509 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + " and " + (yyvsp[(2) - (2)].ConstVal)->getType()->getDescription());
4510 (yyval.ConstVal) = (yyvsp[(2) - (2)].ConstVal);
4511 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004512 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004513 ;}
4514 break;
4515
4516 case 176:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004517#line 1784 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004518 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004519 if (!UpRefs.empty())
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004520 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4521 const Type *Ty = (yyvsp[(1) - (2)].TypeVal)->get();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004522 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4523 GEN_ERROR("Cannot create a null initialized value of this type");
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004524 (yyval.ConstVal) = Constant::getNullValue(Ty);
4525 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004526 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004527 ;}
4528 break;
4529
4530 case 177:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004531#line 1794 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004532 { // integral constants
4533 if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004534 GEN_ERROR("Constant value doesn't fit in type");
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004535 (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val), true);
Reid Spencer38c91a92007-02-28 02:24:54 +00004536 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004537 ;}
4538 break;
4539
4540 case 178:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004541#line 1800 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004542 { // arbitrary precision integer constants
4543 uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth();
4544 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004545 GEN_ERROR("Constant value does not fit in type");
4546 }
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004547 (yyvsp[(2) - (2)].APIntVal)->sextOrTrunc(BitWidth);
4548 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4549 delete (yyvsp[(2) - (2)].APIntVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004550 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004551 ;}
4552 break;
4553
4554 case 179:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004555#line 1810 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004556 { // integral constants
4557 if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004558 GEN_ERROR("Constant value doesn't fit in type");
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004559 (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val), false);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004560 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004561 ;}
4562 break;
4563
4564 case 180:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004565#line 1816 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004566 { // arbitrary precision integer constants
4567 uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth();
4568 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004569 GEN_ERROR("Constant value does not fit in type");
4570 }
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004571 (yyvsp[(2) - (2)].APIntVal)->zextOrTrunc(BitWidth);
4572 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4573 delete (yyvsp[(2) - (2)].APIntVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004574 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004575 ;}
4576 break;
4577
4578 case 181:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004579#line 1826 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004580 { // Boolean constants
4581 assert(cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() == 1 && "Not Bool?");
4582 (yyval.ConstVal) = ConstantInt::getTrue();
Reid Spencer38c91a92007-02-28 02:24:54 +00004583 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004584 ;}
4585 break;
4586
4587 case 182:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004588#line 1831 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004589 { // Boolean constants
4590 assert(cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() == 1 && "Not Bool?");
4591 (yyval.ConstVal) = ConstantInt::getFalse();
Reid Spencer6f407902007-01-13 05:00:46 +00004592 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004593 ;}
4594 break;
4595
4596 case 183:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004597#line 1836 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004598 { // Floating point constants
4599 if (!ConstantFP::isValueValidForType((yyvsp[(1) - (2)].PrimType), *(yyvsp[(2) - (2)].FPVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004600 GEN_ERROR("Floating point constant invalid for type");
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004601 // Lexer has no type info, so builds all float and double FP constants
4602 // as double. Fix this here. Long double is done right.
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004603 if (&(yyvsp[(2) - (2)].FPVal)->getSemantics()==&APFloat::IEEEdouble && (yyvsp[(1) - (2)].PrimType)==Type::FloatTy)
4604 (yyvsp[(2) - (2)].FPVal)->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
4605 (yyval.ConstVal) = ConstantFP::get((yyvsp[(1) - (2)].PrimType), *(yyvsp[(2) - (2)].FPVal));
4606 delete (yyvsp[(2) - (2)].FPVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004607 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004608 ;}
4609 break;
4610
4611 case 184:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004612#line 1849 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004613 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004614 if (!UpRefs.empty())
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004615 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (6)].TypeVal))->getDescription());
4616 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
4617 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
4618 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004619 GEN_ERROR("invalid cast opcode for cast from '" +
4620 Val->getType()->getDescription() + "' to '" +
4621 DestTy->getDescription() + "'");
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004622 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
4623 delete (yyvsp[(5) - (6)].TypeVal);
4624 ;}
4625 break;
4626
4627 case 185:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004628#line 1861 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004629 {
4630 if (!isa<PointerType>((yyvsp[(3) - (5)].ConstVal)->getType()))
Reid Spencerb5334b02007-02-05 10:18:06 +00004631 GEN_ERROR("GetElementPtr requires a pointer operand");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004632
4633 const Type *IdxTy =
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004634 GetElementPtrInst::getIndexedType((yyvsp[(3) - (5)].ConstVal)->getType(), (yyvsp[(4) - (5)].ValueList)->begin(), (yyvsp[(4) - (5)].ValueList)->end(),
Chris Lattner7d9801d2007-02-13 00:58:01 +00004635 true);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004636 if (!IdxTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00004637 GEN_ERROR("Index list invalid for constant getelementptr");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004638
Chris Lattnerf7469af2007-01-31 04:44:08 +00004639 SmallVector<Constant*, 8> IdxVec;
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004640 for (unsigned i = 0, e = (yyvsp[(4) - (5)].ValueList)->size(); i != e; ++i)
4641 if (Constant *C = dyn_cast<Constant>((*(yyvsp[(4) - (5)].ValueList))[i]))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004642 IdxVec.push_back(C);
4643 else
Reid Spencerb5334b02007-02-05 10:18:06 +00004644 GEN_ERROR("Indices to constant getelementptr must be constants");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004645
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004646 delete (yyvsp[(4) - (5)].ValueList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004647
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004648 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[(3) - (5)].ConstVal), &IdxVec[0], IdxVec.size());
Andrew Lenharth6353e052006-12-08 18:07:09 +00004649 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004650 ;}
4651 break;
4652
4653 case 186:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004654#line 1883 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004655 {
4656 if ((yyvsp[(3) - (8)].ConstVal)->getType() != Type::Int1Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004657 GEN_ERROR("Select condition must be of boolean type");
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004658 if ((yyvsp[(5) - (8)].ConstVal)->getType() != (yyvsp[(7) - (8)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004659 GEN_ERROR("Select operand types must match");
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004660 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004661 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004662 ;}
4663 break;
4664
4665 case 187:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004666#line 1891 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004667 {
4668 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004669 GEN_ERROR("Binary operator types must match");
4670 CHECK_FOR_ERROR;
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004671 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
4672 ;}
4673 break;
4674
4675 case 188:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004676#line 1897 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004677 {
4678 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004679 GEN_ERROR("Logical operator types must match");
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004680 if (!(yyvsp[(3) - (6)].ConstVal)->getType()->isInteger()) {
4681 if (Instruction::isShift((yyvsp[(1) - (6)].BinaryOpVal)) || !isa<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType()) ||
4682 !cast<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004683 GEN_ERROR("Logical operator requires integral operands");
4684 }
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004685 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004686 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004687 ;}
4688 break;
4689
4690 case 189:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004691#line 1908 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004692 {
4693 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004694 GEN_ERROR("icmp operand types must match");
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004695 (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[(2) - (7)].IPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
4696 ;}
4697 break;
4698
4699 case 190:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004700#line 1913 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004701 {
4702 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004703 GEN_ERROR("fcmp operand types must match");
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004704 (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[(2) - (7)].FPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
4705 ;}
4706 break;
4707
4708 case 191:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004709#line 1918 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004710 {
4711 if (!ExtractElementInst::isValidOperands((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004712 GEN_ERROR("Invalid extractelement operands");
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004713 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004714 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004715 ;}
4716 break;
4717
4718 case 192:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004719#line 1924 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004720 {
4721 if (!InsertElementInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004722 GEN_ERROR("Invalid insertelement operands");
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004723 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004724 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004725 ;}
4726 break;
4727
4728 case 193:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004729#line 1930 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004730 {
4731 if (!ShuffleVectorInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004732 GEN_ERROR("Invalid shufflevector operands");
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004733 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004734 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004735 ;}
4736 break;
4737
4738 case 194:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004739#line 1939 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004740 {
4741 ((yyval.ConstVector) = (yyvsp[(1) - (3)].ConstVector))->push_back((yyvsp[(3) - (3)].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004742 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004743 ;}
4744 break;
4745
4746 case 195:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004747#line 1943 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004748 {
4749 (yyval.ConstVector) = new std::vector<Constant*>();
4750 (yyval.ConstVector)->push_back((yyvsp[(1) - (1)].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004751 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004752 ;}
4753 break;
4754
4755 case 196:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004756#line 1951 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004757 { (yyval.BoolVal) = false; ;}
4758 break;
4759
4760 case 197:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004761#line 1951 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004762 { (yyval.BoolVal) = true; ;}
4763 break;
4764
4765 case 198:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004766#line 1954 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004767 { (yyval.BoolVal) = true; ;}
4768 break;
4769
4770 case 199:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004771#line 1954 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004772 { (yyval.BoolVal) = false; ;}
4773 break;
4774
4775 case 200:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004776#line 1957 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004777 {
4778 const Type* VTy = (yyvsp[(1) - (2)].TypeVal)->get();
4779 Value *V = getVal(VTy, (yyvsp[(2) - (2)].ValIDVal));
Chris Lattner0275cff2007-08-06 21:00:46 +00004780 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004781 GlobalValue* Aliasee = dyn_cast<GlobalValue>(V);
4782 if (!Aliasee)
4783 GEN_ERROR("Aliases can be created only to global values");
4784
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004785 (yyval.ConstVal) = Aliasee;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004786 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004787 delete (yyvsp[(1) - (2)].TypeVal);
4788 ;}
4789 break;
4790
4791 case 201:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004792#line 1969 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004793 {
4794 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
4795 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
4796 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004797 GEN_ERROR("invalid cast opcode for cast from '" +
4798 Val->getType()->getDescription() + "' to '" +
4799 DestTy->getDescription() + "'");
4800
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004801 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004802 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004803 delete (yyvsp[(5) - (6)].TypeVal);
4804 ;}
4805 break;
4806
4807 case 202:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004808#line 1990 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004809 {
4810 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Reid Spencer1013b4d2007-07-31 14:41:17 +00004811 CurModule.ModuleDone();
4812 CHECK_FOR_ERROR;
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004813 ;}
4814 break;
4815
4816 case 203:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004817#line 1995 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004818 {
4819 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004820 CurModule.ModuleDone();
4821 CHECK_FOR_ERROR;
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004822 ;}
4823 break;
4824
4825 case 206:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004826#line 2008 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004827 { CurFun.isDeclare = false; ;}
4828 break;
4829
4830 case 207:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004831#line 2008 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004832 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004833 CurFun.FunctionDone();
4834 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004835 ;}
4836 break;
4837
4838 case 208:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004839#line 2012 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004840 { CurFun.isDeclare = true; ;}
4841 break;
4842
4843 case 209:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004844#line 2012 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004845 {
Reid Spencer1013b4d2007-07-31 14:41:17 +00004846 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004847 ;}
4848 break;
4849
4850 case 210:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004851#line 2015 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004852 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004853 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004854 ;}
4855 break;
4856
4857 case 211:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004858#line 2018 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004859 {
Reid Spencer14310612006-12-31 05:40:51 +00004860 if (!UpRefs.empty())
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004861 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (3)].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004862 // Eagerly resolve types. This is not an optimization, this is a
4863 // requirement that is due to the fact that we could have this:
4864 //
4865 // %list = type { %list * }
4866 // %list = type { %list * } ; repeated type decl
4867 //
4868 // If types are not resolved eagerly, then the two types will not be
4869 // determined to be the same type!
4870 //
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004871 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), *(yyvsp[(3) - (3)].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004872
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004873 if (!setTypeName(*(yyvsp[(3) - (3)].TypeVal), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00004874 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004875 // If this is a named type that is not a redefinition, add it to the slot
4876 // table.
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004877 CurModule.Types.push_back(*(yyvsp[(3) - (3)].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004878 }
Reid Spencera132e042006-12-03 05:46:11 +00004879
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004880 delete (yyvsp[(3) - (3)].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004881 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004882 ;}
4883 break;
Reid Spencerb8f85052007-07-31 03:50:36 +00004884
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004885 case 212:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004886#line 2042 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004887 {
4888 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), (yyvsp[(3) - (3)].PrimType));
4889
4890 if (!setTypeName((yyvsp[(3) - (3)].PrimType), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004891 CHECK_FOR_ERROR
4892 // If this is a named type that is not a redefinition, add it to the slot
4893 // table.
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004894 CurModule.Types.push_back((yyvsp[(3) - (3)].PrimType));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004895 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004896 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004897 ;}
4898 break;
4899
4900 case 213:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004901#line 2053 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004902 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004903 /* "Externally Visible" Linkage */
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004904 if ((yyvsp[(5) - (5)].ConstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004905 GEN_ERROR("Global value initializer is not a constant");
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004906 CurGV = ParseGlobalVariable((yyvsp[(1) - (5)].StrVal), GlobalValue::ExternalLinkage,
4907 (yyvsp[(2) - (5)].Visibility), (yyvsp[(4) - (5)].BoolVal), (yyvsp[(5) - (5)].ConstVal)->getType(), (yyvsp[(5) - (5)].ConstVal), (yyvsp[(3) - (5)].BoolVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004908 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004909 ;}
4910 break;
4911
4912 case 214:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004913#line 2060 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004914 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004915 CurGV = 0;
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004916 ;}
4917 break;
4918
4919 case 215:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004920#line 2064 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004921 {
4922 if ((yyvsp[(6) - (6)].ConstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004923 GEN_ERROR("Global value initializer is not a constant");
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004924 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));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004925 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004926 ;}
4927 break;
4928
4929 case 216:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004930#line 2069 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004931 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004932 CurGV = 0;
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004933 ;}
4934 break;
4935
4936 case 217:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004937#line 2073 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004938 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004939 if (!UpRefs.empty())
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004940 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(6) - (6)].TypeVal))->getDescription());
4941 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));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004942 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004943 delete (yyvsp[(6) - (6)].TypeVal);
4944 ;}
4945 break;
4946
4947 case 218:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004948#line 2079 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004949 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004950 CurGV = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004951 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004952 ;}
4953 break;
4954
4955 case 219:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00004956#line 2083 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004957 {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00004958 std::string Name;
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004959 if ((yyvsp[(1) - (5)].StrVal)) {
4960 Name = *(yyvsp[(1) - (5)].StrVal);
4961 delete (yyvsp[(1) - (5)].StrVal);
Reid Spencer0a8a16b2007-05-22 18:52:55 +00004962 }
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004963 if (Name.empty())
4964 GEN_ERROR("Alias name cannot be empty");
4965
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004966 Constant* Aliasee = (yyvsp[(5) - (5)].ConstVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004967 if (Aliasee == 0)
Reid Spencer0a8a16b2007-05-22 18:52:55 +00004968 GEN_ERROR(std::string("Invalid aliasee for alias: ") + Name);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004969
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004970 GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), (yyvsp[(4) - (5)].Linkage), Name, Aliasee,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004971 CurModule.CurrentModule);
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004972 GA->setVisibility((yyvsp[(2) - (5)].Visibility));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004973 InsertValue(GA, CurModule.Values);
Chris Lattner569f7372007-09-10 23:24:14 +00004974
4975
4976 // If there was a forward reference of this alias, resolve it now.
4977
4978 ValID ID;
4979 if (!Name.empty())
4980 ID = ValID::createGlobalName(Name);
4981 else
4982 ID = ValID::createGlobalID(CurModule.Values.size()-1);
4983
4984 if (GlobalValue *FWGV =
4985 CurModule.GetForwardRefForGlobal(GA->getType(), ID)) {
4986 // Replace uses of the fwdref with the actual alias.
4987 FWGV->replaceAllUsesWith(GA);
4988 if (GlobalVariable *GV = dyn_cast<GlobalVariable>(FWGV))
4989 GV->eraseFromParent();
4990 else
4991 cast<Function>(FWGV)->eraseFromParent();
4992 }
4993 ID.destroy();
4994
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004995 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00004996 ;}
4997 break;
4998
4999 case 220:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005000#line 2123 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005001 {
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00005002 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005003 ;}
5004 break;
5005
5006 case 221:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005007#line 2126 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005008 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005009 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005010 ;}
5011 break;
5012
5013 case 222:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005014#line 2132 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005015 {
Chris Lattner66316012006-01-24 04:14:29 +00005016 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Chris Lattner66316012006-01-24 04:14:29 +00005017 if (AsmSoFar.empty())
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005018 CurModule.CurrentModule->setModuleInlineAsm(*(yyvsp[(1) - (1)].StrVal));
Chris Lattner66316012006-01-24 04:14:29 +00005019 else
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005020 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+*(yyvsp[(1) - (1)].StrVal));
5021 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005022 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005023;}
5024 break;
5025
5026 case 223:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005027#line 2142 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005028 {
5029 CurModule.CurrentModule->setTargetTriple(*(yyvsp[(3) - (3)].StrVal));
5030 delete (yyvsp[(3) - (3)].StrVal);
5031 ;}
5032 break;
5033
5034 case 224:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005035#line 2146 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005036 {
5037 CurModule.CurrentModule->setDataLayout(*(yyvsp[(3) - (3)].StrVal));
5038 delete (yyvsp[(3) - (3)].StrVal);
5039 ;}
5040 break;
5041
5042 case 226:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005043#line 2153 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005044 {
5045 CurModule.CurrentModule->addLibrary(*(yyvsp[(3) - (3)].StrVal));
5046 delete (yyvsp[(3) - (3)].StrVal);
Reid Spencer1013b4d2007-07-31 14:41:17 +00005047 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005048 ;}
5049 break;
5050
5051 case 227:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005052#line 2158 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005053 {
5054 CurModule.CurrentModule->addLibrary(*(yyvsp[(1) - (1)].StrVal));
5055 delete (yyvsp[(1) - (1)].StrVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005056 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005057 ;}
5058 break;
5059
5060 case 228:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005061#line 2163 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005062 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005063 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005064 ;}
5065 break;
5066
5067 case 229:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005068#line 2172 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005069 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005070 if (!UpRefs.empty())
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005071 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
5072 if (*(yyvsp[(3) - (5)].TypeVal) == Type::VoidTy)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005073 GEN_ERROR("void typed arguments are invalid");
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005074 ArgListEntry E; E.Attrs = (yyvsp[(4) - (5)].ParamAttrs); E.Ty = (yyvsp[(3) - (5)].TypeVal); E.Name = (yyvsp[(5) - (5)].StrVal);
5075 (yyval.ArgList) = (yyvsp[(1) - (5)].ArgList);
5076 (yyvsp[(1) - (5)].ArgList)->push_back(E);
Reid Spencer6f407902007-01-13 05:00:46 +00005077 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005078 ;}
5079 break;
5080
5081 case 230:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005082#line 2182 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005083 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005084 if (!UpRefs.empty())
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005085 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
5086 if (*(yyvsp[(1) - (3)].TypeVal) == Type::VoidTy)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005087 GEN_ERROR("void typed arguments are invalid");
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005088 ArgListEntry E; E.Attrs = (yyvsp[(2) - (3)].ParamAttrs); E.Ty = (yyvsp[(1) - (3)].TypeVal); E.Name = (yyvsp[(3) - (3)].StrVal);
5089 (yyval.ArgList) = new ArgListType;
5090 (yyval.ArgList)->push_back(E);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005091 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005092 ;}
5093 break;
5094
5095 case 231:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005096#line 2193 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005097 {
5098 (yyval.ArgList) = (yyvsp[(1) - (1)].ArgList);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005099 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005100 ;}
5101 break;
5102
5103 case 232:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005104#line 2197 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005105 {
5106 (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005107 struct ArgListEntry E;
5108 E.Ty = new PATypeHolder(Type::VoidTy);
5109 E.Name = 0;
Reid Spencer18da0722007-04-11 02:44:20 +00005110 E.Attrs = ParamAttr::None;
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005111 (yyval.ArgList)->push_back(E);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005112 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005113 ;}
5114 break;
5115
5116 case 233:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005117#line 2206 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005118 {
5119 (yyval.ArgList) = new ArgListType;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005120 struct ArgListEntry E;
5121 E.Ty = new PATypeHolder(Type::VoidTy);
5122 E.Name = 0;
5123 E.Attrs = ParamAttr::None;
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005124 (yyval.ArgList)->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00005125 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005126 ;}
5127 break;
5128
5129 case 234:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005130#line 2215 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005131 {
5132 (yyval.ArgList) = 0;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005133 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005134 ;}
5135 break;
5136
5137 case 235:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005138#line 2221 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005139 {
5140 std::string FunctionName(*(yyvsp[(3) - (9)].StrVal));
5141 delete (yyvsp[(3) - (9)].StrVal); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00005142
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00005143 // Check the function result for abstractness if this is a define. We should
5144 // have no abstract types at this point
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005145 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[(2) - (9)].TypeVal)))
5146 GEN_ERROR("Reference to abstract result: "+ (yyvsp[(2) - (9)].TypeVal)->get()->getDescription());
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00005147
Reid Spencer68a24bd2005-08-27 18:50:39 +00005148 std::vector<const Type*> ParamTypeList;
Christopher Lamb5c104242007-04-22 20:09:11 +00005149 ParamAttrsVector Attrs;
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005150 if ((yyvsp[(7) - (9)].ParamAttrs) != ParamAttr::None) {
Duncan Sandsdc024672007-11-27 13:23:08 +00005151 ParamAttrsWithIndex PAWI;
5152 PAWI.index = 0;
5153 PAWI.attrs = (yyvsp[(7) - (9)].ParamAttrs);
Christopher Lamb5c104242007-04-22 20:09:11 +00005154 Attrs.push_back(PAWI);
5155 }
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005156 if ((yyvsp[(5) - (9)].ArgList)) { // If there are arguments...
Reid Spencer7b5d4662007-04-09 06:16:21 +00005157 unsigned index = 1;
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005158 for (ArgListType::iterator I = (yyvsp[(5) - (9)].ArgList)->begin(); I != (yyvsp[(5) - (9)].ArgList)->end(); ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005159 const Type* Ty = I->Ty->get();
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00005160 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
5161 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00005162 ParamTypeList.push_back(Ty);
5163 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00005164 if (I->Attrs != ParamAttr::None) {
Duncan Sandsdc024672007-11-27 13:23:08 +00005165 ParamAttrsWithIndex PAWI;
5166 PAWI.index = index;
5167 PAWI.attrs = I->Attrs;
Christopher Lamb5c104242007-04-22 20:09:11 +00005168 Attrs.push_back(PAWI);
5169 }
Reid Spencer14310612006-12-31 05:40:51 +00005170 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005171 }
5172
5173 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
5174 if (isVarArg) ParamTypeList.pop_back();
5175
Duncan Sandsafa3b6d2007-11-28 17:07:01 +00005176 const ParamAttrsList *PAL = 0;
Christopher Lamb5c104242007-04-22 20:09:11 +00005177 if (!Attrs.empty())
5178 PAL = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00005179
Duncan Sandsdc024672007-11-27 13:23:08 +00005180 FunctionType *FT = FunctionType::get(*(yyvsp[(2) - (9)].TypeVal), ParamTypeList, isVarArg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005181 const PointerType *PFT = PointerType::get(FT);
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005182 delete (yyvsp[(2) - (9)].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005183
5184 ValID ID;
5185 if (!FunctionName.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00005186 ID = ValID::createGlobalName((char*)FunctionName.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005187 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00005188 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005189 }
5190
5191 Function *Fn = 0;
5192 // See if this function was forward referenced. If so, recycle the object.
5193 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
5194 // Move the function to the end of the list, from whereever it was
5195 // previously inserted.
5196 Fn = cast<Function>(FWRef);
Duncan Sandsdc024672007-11-27 13:23:08 +00005197 assert(!Fn->getParamAttrs() && "Forward reference has parameter attributes!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005198 CurModule.CurrentModule->getFunctionList().remove(Fn);
5199 CurModule.CurrentModule->getFunctionList().push_back(Fn);
5200 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
Reid Spenceref9b9a72007-02-05 20:47:22 +00005201 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
Duncan Sandsdc024672007-11-27 13:23:08 +00005202 if (Fn->getFunctionType() != FT ) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005203 // The existing function doesn't have the same type. This is an overload
5204 // error.
5205 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
Duncan Sandsdc024672007-11-27 13:23:08 +00005206 } else if (Fn->getParamAttrs() != PAL) {
5207 // The existing function doesn't have the same parameter attributes.
5208 // This is an overload error.
5209 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
Reid Spenceref9b9a72007-02-05 20:47:22 +00005210 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00005211 // Neither the existing or the current function is a declaration and they
5212 // have the same name and same type. Clearly this is a redefinition.
5213 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
Duncan Sandsdc024672007-11-27 13:23:08 +00005214 } else if (Fn->isDeclaration()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005215 // Make sure to strip off any argument names so we can't get conflicts.
Reid Spencer68a24bd2005-08-27 18:50:39 +00005216 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
5217 AI != AE; ++AI)
5218 AI->setName("");
Reid Spenceref9b9a72007-02-05 20:47:22 +00005219 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005220 } else { // Not already defined?
Chris Lattner6cdc6822007-04-26 05:31:05 +00005221 Fn = new Function(FT, GlobalValue::ExternalWeakLinkage, FunctionName,
Reid Spencer68a24bd2005-08-27 18:50:39 +00005222 CurModule.CurrentModule);
5223 InsertValue(Fn, CurModule.Values);
5224 }
5225
5226 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00005227
5228 if (CurFun.isDeclare) {
5229 // If we have declaration, always overwrite linkage. This will allow us to
5230 // correctly handle cases, when pointer to function is passed as argument to
5231 // another function.
5232 Fn->setLinkage(CurFun.Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005233 Fn->setVisibility(CurFun.Visibility);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00005234 }
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005235 Fn->setCallingConv((yyvsp[(1) - (9)].UIntVal));
Duncan Sandsdc024672007-11-27 13:23:08 +00005236 Fn->setParamAttrs(PAL);
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005237 Fn->setAlignment((yyvsp[(9) - (9)].UIntVal));
5238 if ((yyvsp[(8) - (9)].StrVal)) {
5239 Fn->setSection(*(yyvsp[(8) - (9)].StrVal));
5240 delete (yyvsp[(8) - (9)].StrVal);
Chris Lattnere869eef2005-11-12 00:11:49 +00005241 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005242
5243 // Add all of the arguments we parsed to the function...
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005244 if ((yyvsp[(5) - (9)].ArgList)) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00005245 if (isVarArg) { // Nuke the last entry
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005246 assert((yyvsp[(5) - (9)].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[(5) - (9)].ArgList)->back().Name == 0 &&
Reid Spencera9720f52007-02-05 17:04:00 +00005247 "Not a varargs marker!");
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005248 delete (yyvsp[(5) - (9)].ArgList)->back().Ty;
5249 (yyvsp[(5) - (9)].ArgList)->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00005250 }
5251 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00005252 Function::arg_iterator ArgEnd = Fn->arg_end();
Reid Spencer14310612006-12-31 05:40:51 +00005253 unsigned Idx = 1;
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005254 for (ArgListType::iterator I = (yyvsp[(5) - (9)].ArgList)->begin();
5255 I != (yyvsp[(5) - (9)].ArgList)->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencer14310612006-12-31 05:40:51 +00005256 delete I->Ty; // Delete the typeholder...
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005257 setValueName(ArgIt, I->Name); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00005258 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005259 InsertValue(ArgIt);
Reid Spencer14310612006-12-31 05:40:51 +00005260 Idx++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005261 }
Reid Spencera132e042006-12-03 05:46:11 +00005262
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005263 delete (yyvsp[(5) - (9)].ArgList); // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00005264 }
Reid Spencer61c83e02006-08-18 08:43:06 +00005265 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005266;}
5267 break;
5268
5269 case 238:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005270#line 2352 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005271 {
5272 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005273
5274 // Make sure that we keep track of the linkage type even if there was a
5275 // previous "declare".
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005276 (yyval.FunctionVal)->setLinkage((yyvsp[(1) - (4)].Linkage));
5277 (yyval.FunctionVal)->setVisibility((yyvsp[(2) - (4)].Visibility));
5278;}
5279 break;
5280
5281 case 241:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005282#line 2363 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005283 {
5284 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005285 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005286;}
5287 break;
5288
5289 case 242:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005290#line 2368 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005291 {
5292 CurFun.CurrentFunction->setLinkage((yyvsp[(1) - (3)].Linkage));
5293 CurFun.CurrentFunction->setVisibility((yyvsp[(2) - (3)].Visibility));
5294 (yyval.FunctionVal) = CurFun.CurrentFunction;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005295 CurFun.FunctionDone();
Reid Spencer41dff5e2007-01-26 08:05:27 +00005296 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005297 ;}
5298 break;
5299
5300 case 243:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005301#line 2380 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005302 {
5303 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00005304 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005305 ;}
5306 break;
5307
5308 case 244:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005309#line 2384 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005310 {
5311 (yyval.BoolVal) = true;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005312 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005313 ;}
5314 break;
5315
5316 case 245:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005317#line 2389 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005318 { // A reference to a direct constant
5319 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SInt64Val));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005320 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005321 ;}
5322 break;
5323
5324 case 246:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005325#line 2393 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005326 {
5327 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].UInt64Val));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005328 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005329 ;}
5330 break;
5331
5332 case 247:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005333#line 2397 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005334 { // Perhaps it's an FP constant?
5335 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].FPVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00005336 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005337 ;}
5338 break;
5339
5340 case 248:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005341#line 2401 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005342 {
5343 (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue());
Reid Spencere4d87aa2006-12-23 06:05:41 +00005344 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005345 ;}
5346 break;
5347
5348 case 249:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005349#line 2405 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005350 {
5351 (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse());
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005352 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005353 ;}
5354 break;
5355
5356 case 250:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005357#line 2409 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005358 {
5359 (yyval.ValIDVal) = ValID::createNull();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005360 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005361 ;}
5362 break;
5363
5364 case 251:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005365#line 2413 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005366 {
5367 (yyval.ValIDVal) = ValID::createUndef();
Reid Spencer61c83e02006-08-18 08:43:06 +00005368 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005369 ;}
5370 break;
5371
5372 case 252:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005373#line 2417 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005374 { // A vector zero constant.
5375 (yyval.ValIDVal) = ValID::createZeroInit();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005376 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005377 ;}
5378 break;
5379
5380 case 253:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005381#line 2421 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005382 { // Nonempty unsized packed vector
5383 const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0]->getType();
5384 int NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005385
Reid Spencer9d6565a2007-02-15 02:26:10 +00005386 VectorType* pt = VectorType::get(ETy, NumElements);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005387 PATypeHolder* PTy = new PATypeHolder(
Reid Spencera132e042006-12-03 05:46:11 +00005388 HandleUpRefs(
Reid Spencer9d6565a2007-02-15 02:26:10 +00005389 VectorType::get(
Reid Spencera132e042006-12-03 05:46:11 +00005390 ETy,
5391 NumElements)
5392 )
5393 );
Reid Spencer68a24bd2005-08-27 18:50:39 +00005394
5395 // Verify all elements are correct type!
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005396 for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
5397 if (ETy != (*(yyvsp[(2) - (3)].ConstVector))[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00005398 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00005399 ETy->getDescription() +"' as required!\nIt is of type '" +
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005400 (*(yyvsp[(2) - (3)].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005401 }
5402
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005403 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, *(yyvsp[(2) - (3)].ConstVector)));
5404 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
Reid Spencer832254e2007-02-02 02:16:23 +00005405 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005406 ;}
5407 break;
5408
5409 case 254:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005410#line 2446 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005411 {
5412 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].ConstVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005413 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005414 ;}
5415 break;
5416
5417 case 255:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005418#line 2450 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005419 {
5420 (yyval.ValIDVal) = ValID::createInlineAsm(*(yyvsp[(3) - (5)].StrVal), *(yyvsp[(5) - (5)].StrVal), (yyvsp[(2) - (5)].BoolVal));
5421 delete (yyvsp[(3) - (5)].StrVal);
5422 delete (yyvsp[(5) - (5)].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005423 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005424 ;}
5425 break;
5426
5427 case 256:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005428#line 2460 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005429 { // Is it an integer reference...?
5430 (yyval.ValIDVal) = ValID::createLocalID((yyvsp[(1) - (1)].UIntVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005431 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005432 ;}
5433 break;
5434
5435 case 257:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005436#line 2464 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005437 {
5438 (yyval.ValIDVal) = ValID::createGlobalID((yyvsp[(1) - (1)].UIntVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005439 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005440 ;}
5441 break;
5442
5443 case 258:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005444#line 2468 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005445 { // Is it a named reference...?
5446 (yyval.ValIDVal) = ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal));
5447 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005448 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005449 ;}
5450 break;
5451
5452 case 259:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005453#line 2473 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005454 { // Is it a named reference...?
5455 (yyval.ValIDVal) = ValID::createGlobalName(*(yyvsp[(1) - (1)].StrVal));
5456 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005457 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005458 ;}
5459 break;
5460
5461 case 262:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005462#line 2486 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005463 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005464 if (!UpRefs.empty())
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005465 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
5466 (yyval.ValueVal) = getVal(*(yyvsp[(1) - (2)].TypeVal), (yyvsp[(2) - (2)].ValIDVal));
5467 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005468 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005469 ;}
5470 break;
5471
5472 case 263:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005473#line 2495 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005474 {
5475 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005476 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005477 ;}
5478 break;
5479
5480 case 264:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005481#line 2499 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005482 { // Do not allow functions with 0 basic blocks
5483 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005484 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005485 ;}
5486 break;
5487
5488 case 265:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005489#line 2508 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005490 {
5491 setValueName((yyvsp[(3) - (3)].TermInstVal), (yyvsp[(2) - (3)].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005492 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005493 InsertValue((yyvsp[(3) - (3)].TermInstVal));
5494 (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal));
5495 (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005496 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005497 ;}
5498 break;
5499
5500 case 266:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005501#line 2517 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005502 {
5503 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[(2) - (2)].InstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005504 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
5505 if (CI2->getParent() == 0)
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005506 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back(CI2);
5507 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back((yyvsp[(2) - (2)].InstVal));
5508 (yyval.BasicBlockVal) = (yyvsp[(1) - (2)].BasicBlockVal);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005509 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005510 ;}
5511 break;
5512
5513 case 267:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005514#line 2526 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005515 { // Empty space between instruction lists
5516 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
Reid Spencered951ea2007-05-19 07:22:10 +00005517 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005518 ;}
5519 break;
5520
5521 case 268:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005522#line 2530 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005523 { // Labelled (named) basic block
5524 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal)));
5525 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencered951ea2007-05-19 07:22:10 +00005526 CHECK_FOR_ERROR
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005527
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005528 ;}
5529 break;
Reid Spencerb8f85052007-07-31 03:50:36 +00005530
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005531 case 269:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005532#line 2537 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005533 { // Return with a result...
5534 (yyval.TermInstVal) = new ReturnInst((yyvsp[(2) - (2)].ValueVal));
5535 CHECK_FOR_ERROR
5536 ;}
5537 break;
5538
5539 case 270:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005540#line 2541 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005541 { // Return with no result...
5542 (yyval.TermInstVal) = new ReturnInst();
5543 CHECK_FOR_ERROR
5544 ;}
5545 break;
5546
5547 case 271:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005548#line 2545 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005549 { // Unconditional Branch...
5550 BasicBlock* tmpBB = getBBVal((yyvsp[(3) - (3)].ValIDVal));
5551 CHECK_FOR_ERROR
5552 (yyval.TermInstVal) = new BranchInst(tmpBB);
5553 ;}
5554 break;
5555
5556 case 272:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005557#line 2550 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005558 {
5559 assert(cast<IntegerType>((yyvsp[(2) - (9)].PrimType))->getBitWidth() == 1 && "Not Bool?");
5560 BasicBlock* tmpBBA = getBBVal((yyvsp[(6) - (9)].ValIDVal));
5561 CHECK_FOR_ERROR
5562 BasicBlock* tmpBBB = getBBVal((yyvsp[(9) - (9)].ValIDVal));
5563 CHECK_FOR_ERROR
5564 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[(3) - (9)].ValIDVal));
5565 CHECK_FOR_ERROR
5566 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5567 ;}
5568 break;
5569
5570 case 273:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005571#line 2560 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005572 {
5573 Value* tmpVal = getVal((yyvsp[(2) - (9)].PrimType), (yyvsp[(3) - (9)].ValIDVal));
5574 CHECK_FOR_ERROR
5575 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (9)].ValIDVal));
5576 CHECK_FOR_ERROR
5577 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[(8) - (9)].JumpTable)->size());
5578 (yyval.TermInstVal) = S;
5579
5580 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[(8) - (9)].JumpTable)->begin(),
5581 E = (yyvsp[(8) - (9)].JumpTable)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005582 for (; I != E; ++I) {
5583 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5584 S->addCase(CI, I->second);
5585 else
Reid Spencerb5334b02007-02-05 10:18:06 +00005586 GEN_ERROR("Switch case is constant, but not a simple integer");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005587 }
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005588 delete (yyvsp[(8) - (9)].JumpTable);
Reid Spencer61c83e02006-08-18 08:43:06 +00005589 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005590 ;}
5591 break;
5592
5593 case 274:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005594#line 2579 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005595 {
5596 Value* tmpVal = getVal((yyvsp[(2) - (8)].PrimType), (yyvsp[(3) - (8)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005597 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005598 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (8)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005599 CHECK_FOR_ERROR
5600 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005601 (yyval.TermInstVal) = S;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005602 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005603 ;}
5604 break;
5605
5606 case 275:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005607#line 2589 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005608 {
Reid Spencer3822ff52006-11-08 06:47:33 +00005609
Reid Spencer14310612006-12-31 05:40:51 +00005610 // Handle the short syntax
5611 const PointerType *PFTy = 0;
5612 const FunctionType *Ty = 0;
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005613 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (14)].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00005614 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5615 // Pull out the types of all of the arguments...
5616 std::vector<const Type*> ParamTypes;
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005617 ParamList::iterator I = (yyvsp[(6) - (14)].ParamList)->begin(), E = (yyvsp[(6) - (14)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00005618 for (; I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00005619 const Type *Ty = I->Val->getType();
5620 if (Ty == Type::VoidTy)
5621 GEN_ERROR("Short call syntax cannot be used with varargs");
5622 ParamTypes.push_back(Ty);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005623 }
Duncan Sandsdc024672007-11-27 13:23:08 +00005624 Ty = FunctionType::get((yyvsp[(3) - (14)].TypeVal)->get(), ParamTypes, false);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005625 PFTy = PointerType::get(Ty);
5626 }
5627
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005628 delete (yyvsp[(3) - (14)].TypeVal);
Reid Spencer66728ef2007-03-20 01:13:36 +00005629
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005630 Value *V = getVal(PFTy, (yyvsp[(4) - (14)].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005631 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005632 BasicBlock *Normal = getBBVal((yyvsp[(11) - (14)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005633 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005634 BasicBlock *Except = getBBVal((yyvsp[(14) - (14)].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005635 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005636
Duncan Sandsdc024672007-11-27 13:23:08 +00005637 ParamAttrsVector Attrs;
5638 if ((yyvsp[(8) - (14)].ParamAttrs) != ParamAttr::None) {
5639 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = (yyvsp[(8) - (14)].ParamAttrs);
5640 Attrs.push_back(PAWI);
5641 }
5642
Reid Spencer14310612006-12-31 05:40:51 +00005643 // Check the arguments
5644 ValueList Args;
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005645 if ((yyvsp[(6) - (14)].ParamList)->empty()) { // Has no arguments?
Reid Spencer14310612006-12-31 05:40:51 +00005646 // Make sure no arguments is a good thing!
5647 if (Ty->getNumParams() != 0)
5648 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00005649 "expects arguments");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005650 } else { // Has arguments?
5651 // Loop through FunctionType's arguments and ensure they are specified
5652 // correctly!
Reid Spencer68a24bd2005-08-27 18:50:39 +00005653 FunctionType::param_iterator I = Ty->param_begin();
5654 FunctionType::param_iterator E = Ty->param_end();
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005655 ParamList::iterator ArgI = (yyvsp[(6) - (14)].ParamList)->begin(), ArgE = (yyvsp[(6) - (14)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00005656 unsigned index = 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005657
Duncan Sandsdc024672007-11-27 13:23:08 +00005658 for (; ArgI != ArgE && I != E; ++ArgI, ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005659 if (ArgI->Val->getType() != *I)
5660 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005661 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00005662 Args.push_back(ArgI->Val);
Duncan Sandsdc024672007-11-27 13:23:08 +00005663 if (ArgI->Attrs != ParamAttr::None) {
5664 ParamAttrsWithIndex PAWI;
5665 PAWI.index = index;
5666 PAWI.attrs = ArgI->Attrs;
5667 Attrs.push_back(PAWI);
5668 }
Reid Spencer14310612006-12-31 05:40:51 +00005669 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005670
Reid Spencer14310612006-12-31 05:40:51 +00005671 if (Ty->isVarArg()) {
5672 if (I == E)
5673 for (; ArgI != ArgE; ++ArgI)
5674 Args.push_back(ArgI->Val); // push the remaining varargs
5675 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00005676 GEN_ERROR("Invalid number of parameters detected");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005677 }
Reid Spencer14310612006-12-31 05:40:51 +00005678
Duncan Sandsafa3b6d2007-11-28 17:07:01 +00005679 const ParamAttrsList *PAL = 0;
Duncan Sandsdc024672007-11-27 13:23:08 +00005680 if (!Attrs.empty())
5681 PAL = ParamAttrsList::get(Attrs);
5682
Reid Spencer14310612006-12-31 05:40:51 +00005683 // Create the InvokeInst
Chris Lattnerd80fb8b2007-08-29 16:15:23 +00005684 InvokeInst *II = new InvokeInst(V, Normal, Except, Args.begin(), Args.end());
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005685 II->setCallingConv((yyvsp[(2) - (14)].UIntVal));
Duncan Sandsdc024672007-11-27 13:23:08 +00005686 II->setParamAttrs(PAL);
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005687 (yyval.TermInstVal) = II;
5688 delete (yyvsp[(6) - (14)].ParamList);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005689 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005690 ;}
5691 break;
5692
5693 case 276:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005694#line 2672 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005695 {
5696 (yyval.TermInstVal) = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005697 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005698 ;}
5699 break;
5700
5701 case 277:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005702#line 2676 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005703 {
5704 (yyval.TermInstVal) = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005705 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005706 ;}
5707 break;
5708
5709 case 278:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005710#line 2683 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005711 {
5712 (yyval.JumpTable) = (yyvsp[(1) - (6)].JumpTable);
5713 Constant *V = cast<Constant>(getExistingVal((yyvsp[(2) - (6)].PrimType), (yyvsp[(3) - (6)].ValIDVal)));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005714 CHECK_FOR_ERROR
5715 if (V == 0)
5716 GEN_ERROR("May only switch on a constant pool value");
5717
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005718 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (6)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005719 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005720 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5721 ;}
5722 break;
5723
5724 case 279:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005725#line 2694 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005726 {
5727 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
5728 Constant *V = cast<Constant>(getExistingVal((yyvsp[(1) - (5)].PrimType), (yyvsp[(2) - (5)].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005729 CHECK_FOR_ERROR
5730
5731 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005732 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005733
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005734 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005735 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005736 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5737 ;}
5738 break;
5739
5740 case 280:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005741#line 2707 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005742 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005743 // Is this definition named?? if so, assign the name...
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005744 setValueName((yyvsp[(2) - (2)].InstVal), (yyvsp[(1) - (2)].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005745 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005746 InsertValue((yyvsp[(2) - (2)].InstVal));
5747 (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005748 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005749 ;}
5750 break;
5751
5752 case 281:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005753#line 2717 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005754 { // Used for PHI nodes
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005755 if (!UpRefs.empty())
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005756 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (6)].TypeVal))->getDescription());
5757 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
5758 Value* tmpVal = getVal(*(yyvsp[(1) - (6)].TypeVal), (yyvsp[(3) - (6)].ValIDVal));
Reid Spencer6f407902007-01-13 05:00:46 +00005759 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005760 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (6)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005761 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005762 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5763 delete (yyvsp[(1) - (6)].TypeVal);
5764 ;}
5765 break;
5766
5767 case 282:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005768#line 2728 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005769 {
5770 (yyval.PHIList) = (yyvsp[(1) - (7)].PHIList);
5771 Value* tmpVal = getVal((yyvsp[(1) - (7)].PHIList)->front().first->getType(), (yyvsp[(4) - (7)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005772 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005773 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (7)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005774 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005775 (yyvsp[(1) - (7)].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5776 ;}
5777 break;
5778
5779 case 283:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005780#line 2738 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Duncan Sandsdc024672007-11-27 13:23:08 +00005781 {
5782 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005783 if (!UpRefs.empty())
Duncan Sandsdc024672007-11-27 13:23:08 +00005784 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005785 // Used for call and invoke instructions
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005786 (yyval.ParamList) = new ParamList();
Duncan Sandsdc024672007-11-27 13:23:08 +00005787 ParamListEntry E; E.Attrs = (yyvsp[(2) - (4)].ParamAttrs) | (yyvsp[(4) - (4)].ParamAttrs); E.Val = getVal((yyvsp[(1) - (4)].TypeVal)->get(), (yyvsp[(3) - (4)].ValIDVal));
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005788 (yyval.ParamList)->push_back(E);
Duncan Sandsdc024672007-11-27 13:23:08 +00005789 delete (yyvsp[(1) - (4)].TypeVal);
5790 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005791 ;}
5792 break;
5793
5794 case 284:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005795#line 2749 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005796 {
Duncan Sandsdc024672007-11-27 13:23:08 +00005797 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Dale Johanneseneb57ea72007-11-05 21:20:28 +00005798 // Labels are only valid in ASMs
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005799 (yyval.ParamList) = new ParamList();
Duncan Sandsdc024672007-11-27 13:23:08 +00005800 ParamListEntry E; E.Attrs = (yyvsp[(2) - (4)].ParamAttrs) | (yyvsp[(4) - (4)].ParamAttrs); E.Val = getBBVal((yyvsp[(3) - (4)].ValIDVal));
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005801 (yyval.ParamList)->push_back(E);
Duncan Sandsdc024672007-11-27 13:23:08 +00005802 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005803 ;}
5804 break;
5805
5806 case 285:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005807#line 2757 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005808 {
Duncan Sandsdc024672007-11-27 13:23:08 +00005809 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005810 if (!UpRefs.empty())
Duncan Sandsdc024672007-11-27 13:23:08 +00005811 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
5812 (yyval.ParamList) = (yyvsp[(1) - (6)].ParamList);
5813 ParamListEntry E; E.Attrs = (yyvsp[(4) - (6)].ParamAttrs) | (yyvsp[(6) - (6)].ParamAttrs); E.Val = getVal((yyvsp[(3) - (6)].TypeVal)->get(), (yyvsp[(5) - (6)].ValIDVal));
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005814 (yyval.ParamList)->push_back(E);
Duncan Sandsdc024672007-11-27 13:23:08 +00005815 delete (yyvsp[(3) - (6)].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005816 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005817 ;}
5818 break;
5819
5820 case 286:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005821#line 2767 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005822 {
Duncan Sandsdc024672007-11-27 13:23:08 +00005823 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
5824 (yyval.ParamList) = (yyvsp[(1) - (6)].ParamList);
5825 ParamListEntry E; E.Attrs = (yyvsp[(4) - (6)].ParamAttrs) | (yyvsp[(6) - (6)].ParamAttrs); E.Val = getBBVal((yyvsp[(5) - (6)].ValIDVal));
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005826 (yyval.ParamList)->push_back(E);
Dale Johanneseneb57ea72007-11-05 21:20:28 +00005827 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005828 ;}
5829 break;
5830
5831 case 287:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005832#line 2774 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005833 { (yyval.ParamList) = new ParamList(); ;}
5834 break;
5835
5836 case 288:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005837#line 2777 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005838 { (yyval.ValueList) = new std::vector<Value*>(); ;}
5839 break;
5840
5841 case 289:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005842#line 2778 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005843 {
5844 (yyval.ValueList) = (yyvsp[(1) - (3)].ValueList);
5845 (yyval.ValueList)->push_back((yyvsp[(3) - (3)].ValueVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00005846 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005847 ;}
5848 break;
5849
5850 case 290:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005851#line 2785 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005852 {
5853 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005854 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005855 ;}
5856 break;
5857
5858 case 291:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005859#line 2789 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005860 {
5861 (yyval.BoolVal) = false;
Andrew Lenharth6353e052006-12-08 18:07:09 +00005862 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005863 ;}
5864 break;
5865
5866 case 292:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005867#line 2794 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005868 {
Reid Spencer14310612006-12-31 05:40:51 +00005869 if (!UpRefs.empty())
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005870 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
5871 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger() && !(*(yyvsp[(2) - (5)].TypeVal))->isFloatingPoint() &&
5872 !isa<VectorType>((*(yyvsp[(2) - (5)].TypeVal)).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005873 GEN_ERROR(
5874 "Arithmetic operator requires integer, FP, or packed operands");
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005875 Value* val1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005876 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005877 Value* val2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005878 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005879 (yyval.InstVal) = BinaryOperator::create((yyvsp[(1) - (5)].BinaryOpVal), val1, val2);
5880 if ((yyval.InstVal) == 0)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005881 GEN_ERROR("binary operator returned null");
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005882 delete (yyvsp[(2) - (5)].TypeVal);
5883 ;}
5884 break;
5885
5886 case 293:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005887#line 2810 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005888 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005889 if (!UpRefs.empty())
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005890 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
5891 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger()) {
5892 if (Instruction::isShift((yyvsp[(1) - (5)].BinaryOpVal)) || !isa<VectorType>((yyvsp[(2) - (5)].TypeVal)->get()) ||
5893 !cast<VectorType>((yyvsp[(2) - (5)].TypeVal)->get())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005894 GEN_ERROR("Logical operator requires integral operands");
5895 }
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005896 Value* tmpVal1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005897 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005898 Value* tmpVal2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005899 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005900 (yyval.InstVal) = BinaryOperator::create((yyvsp[(1) - (5)].BinaryOpVal), tmpVal1, tmpVal2);
5901 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005902 GEN_ERROR("binary operator returned null");
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005903 delete (yyvsp[(2) - (5)].TypeVal);
5904 ;}
5905 break;
5906
5907 case 294:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005908#line 2827 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005909 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005910 if (!UpRefs.empty())
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005911 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
5912 if (isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005913 GEN_ERROR("Vector types not supported by icmp instruction");
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005914 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005915 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005916 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005917 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005918 (yyval.InstVal) = CmpInst::create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].IPredicate), tmpVal1, tmpVal2);
5919 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005920 GEN_ERROR("icmp operator returned null");
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005921 delete (yyvsp[(3) - (6)].TypeVal);
5922 ;}
5923 break;
5924
5925 case 295:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005926#line 2841 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005927 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005928 if (!UpRefs.empty())
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005929 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
5930 if (isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005931 GEN_ERROR("Vector types not supported by fcmp instruction");
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005932 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005933 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005934 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005935 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005936 (yyval.InstVal) = CmpInst::create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].FPredicate), tmpVal1, tmpVal2);
5937 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005938 GEN_ERROR("fcmp operator returned null");
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005939 delete (yyvsp[(3) - (6)].TypeVal);
5940 ;}
5941 break;
5942
5943 case 296:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005944#line 2855 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005945 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005946 if (!UpRefs.empty())
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005947 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
5948 Value* Val = (yyvsp[(2) - (4)].ValueVal);
5949 const Type* DestTy = (yyvsp[(4) - (4)].TypeVal)->get();
5950 if (!CastInst::castIsValid((yyvsp[(1) - (4)].CastOpVal), Val, DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005951 GEN_ERROR("invalid cast opcode for cast from '" +
5952 Val->getType()->getDescription() + "' to '" +
5953 DestTy->getDescription() + "'");
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005954 (yyval.InstVal) = CastInst::create((yyvsp[(1) - (4)].CastOpVal), Val, DestTy);
5955 delete (yyvsp[(4) - (4)].TypeVal);
5956 ;}
5957 break;
5958
5959 case 297:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005960#line 2867 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005961 {
5962 if ((yyvsp[(2) - (6)].ValueVal)->getType() != Type::Int1Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005963 GEN_ERROR("select condition must be boolean");
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005964 if ((yyvsp[(4) - (6)].ValueVal)->getType() != (yyvsp[(6) - (6)].ValueVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005965 GEN_ERROR("select value types should match");
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005966 (yyval.InstVal) = new SelectInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005967 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005968 ;}
5969 break;
5970
5971 case 298:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005972#line 2875 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005973 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005974 if (!UpRefs.empty())
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005975 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
5976 (yyval.InstVal) = new VAArgInst((yyvsp[(2) - (4)].ValueVal), *(yyvsp[(4) - (4)].TypeVal));
5977 delete (yyvsp[(4) - (4)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005978 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005979 ;}
5980 break;
5981
5982 case 299:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005983#line 2882 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005984 {
5985 if (!ExtractElementInst::isValidOperands((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005986 GEN_ERROR("Invalid extractelement operands");
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005987 (yyval.InstVal) = new ExtractElementInst((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005988 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005989 ;}
5990 break;
5991
5992 case 300:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00005993#line 2888 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005994 {
5995 if (!InsertElementInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005996 GEN_ERROR("Invalid insertelement operands");
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005997 (yyval.InstVal) = new InsertElementInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005998 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005999 ;}
6000 break;
6001
6002 case 301:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00006003#line 2894 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006004 {
6005 if (!ShuffleVectorInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006006 GEN_ERROR("Invalid shufflevector operands");
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006007 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006008 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006009 ;}
6010 break;
6011
6012 case 302:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00006013#line 2900 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006014 {
6015 const Type *Ty = (yyvsp[(2) - (2)].PHIList)->front().first->getType();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006016 if (!Ty->isFirstClassType())
6017 GEN_ERROR("PHI node operands must be of first class type");
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006018 (yyval.InstVal) = new PHINode(Ty);
6019 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[(2) - (2)].PHIList)->size());
6020 while ((yyvsp[(2) - (2)].PHIList)->begin() != (yyvsp[(2) - (2)].PHIList)->end()) {
6021 if ((yyvsp[(2) - (2)].PHIList)->front().first->getType() != Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006022 GEN_ERROR("All elements of a PHI node must be of the same type");
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006023 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[(2) - (2)].PHIList)->front().first, (yyvsp[(2) - (2)].PHIList)->front().second);
6024 (yyvsp[(2) - (2)].PHIList)->pop_front();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006025 }
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006026 delete (yyvsp[(2) - (2)].PHIList); // Free the list...
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006027 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006028 ;}
6029 break;
6030
6031 case 303:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00006032#line 2916 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006033 {
Reid Spencer14310612006-12-31 05:40:51 +00006034
6035 // Handle the short syntax
Andrew Lenharth6353e052006-12-08 18:07:09 +00006036 const PointerType *PFTy = 0;
6037 const FunctionType *Ty = 0;
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006038 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (8)].TypeVal)->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00006039 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6040 // Pull out the types of all of the arguments...
6041 std::vector<const Type*> ParamTypes;
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006042 ParamList::iterator I = (yyvsp[(6) - (8)].ParamList)->begin(), E = (yyvsp[(6) - (8)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00006043 for (; I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00006044 const Type *Ty = I->Val->getType();
6045 if (Ty == Type::VoidTy)
6046 GEN_ERROR("Short call syntax cannot be used with varargs");
6047 ParamTypes.push_back(Ty);
Andrew Lenharth6353e052006-12-08 18:07:09 +00006048 }
Duncan Sandsdc024672007-11-27 13:23:08 +00006049 Ty = FunctionType::get((yyvsp[(3) - (8)].TypeVal)->get(), ParamTypes, false);
Andrew Lenharth6353e052006-12-08 18:07:09 +00006050 PFTy = PointerType::get(Ty);
6051 }
Chris Lattner6cdc6822007-04-26 05:31:05 +00006052
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006053 Value *V = getVal(PFTy, (yyvsp[(4) - (8)].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00006054 CHECK_FOR_ERROR
Chris Lattner6cdc6822007-04-26 05:31:05 +00006055
Reid Spencer7780acb2007-04-16 06:56:07 +00006056 // Check for call to invalid intrinsic to avoid crashing later.
6057 if (Function *theF = dyn_cast<Function>(V)) {
Reid Spencered48de22007-04-16 22:02:23 +00006058 if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) &&
Reid Spencer36fdde12007-04-16 20:35:38 +00006059 (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) &&
6060 !theF->getIntrinsicID(true))
Reid Spencer7780acb2007-04-16 06:56:07 +00006061 GEN_ERROR("Call to invalid LLVM intrinsic function '" +
6062 theF->getName() + "'");
6063 }
6064
Duncan Sandsdc024672007-11-27 13:23:08 +00006065 // Set up the ParamAttrs for the function
6066 ParamAttrsVector Attrs;
6067 if ((yyvsp[(8) - (8)].ParamAttrs) != ParamAttr::None) {
6068 ParamAttrsWithIndex PAWI;
6069 PAWI.index = 0;
6070 PAWI.attrs = (yyvsp[(8) - (8)].ParamAttrs);
6071 Attrs.push_back(PAWI);
6072 }
Reid Spencer14310612006-12-31 05:40:51 +00006073 // Check the arguments
6074 ValueList Args;
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006075 if ((yyvsp[(6) - (8)].ParamList)->empty()) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00006076 // Make sure no arguments is a good thing!
6077 if (Ty->getNumParams() != 0)
6078 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00006079 "expects arguments");
Andrew Lenharth6353e052006-12-08 18:07:09 +00006080 } else { // Has arguments?
6081 // Loop through FunctionType's arguments and ensure they are specified
Duncan Sandsdc024672007-11-27 13:23:08 +00006082 // correctly. Also, gather any parameter attributes.
Andrew Lenharth6353e052006-12-08 18:07:09 +00006083 FunctionType::param_iterator I = Ty->param_begin();
6084 FunctionType::param_iterator E = Ty->param_end();
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006085 ParamList::iterator ArgI = (yyvsp[(6) - (8)].ParamList)->begin(), ArgE = (yyvsp[(6) - (8)].ParamList)->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00006086 unsigned index = 1;
Andrew Lenharth6353e052006-12-08 18:07:09 +00006087
Duncan Sandsdc024672007-11-27 13:23:08 +00006088 for (; ArgI != ArgE && I != E; ++ArgI, ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00006089 if (ArgI->Val->getType() != *I)
6090 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00006091 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00006092 Args.push_back(ArgI->Val);
Duncan Sandsdc024672007-11-27 13:23:08 +00006093 if (ArgI->Attrs != ParamAttr::None) {
6094 ParamAttrsWithIndex PAWI;
6095 PAWI.index = index;
6096 PAWI.attrs = ArgI->Attrs;
6097 Attrs.push_back(PAWI);
6098 }
Reid Spencer14310612006-12-31 05:40:51 +00006099 }
6100 if (Ty->isVarArg()) {
6101 if (I == E)
6102 for (; ArgI != ArgE; ++ArgI)
6103 Args.push_back(ArgI->Val); // push the remaining varargs
6104 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00006105 GEN_ERROR("Invalid number of parameters detected");
Andrew Lenharth6353e052006-12-08 18:07:09 +00006106 }
Duncan Sandsdc024672007-11-27 13:23:08 +00006107
6108 // Finish off the ParamAttrs and check them
Duncan Sandsafa3b6d2007-11-28 17:07:01 +00006109 const ParamAttrsList *PAL = 0;
Duncan Sandsdc024672007-11-27 13:23:08 +00006110 if (!Attrs.empty())
6111 PAL = ParamAttrsList::get(Attrs);
6112
Reid Spencer14310612006-12-31 05:40:51 +00006113 // Create the call node
David Greene718fda32007-08-01 03:59:32 +00006114 CallInst *CI = new CallInst(V, Args.begin(), Args.end());
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006115 CI->setTailCall((yyvsp[(1) - (8)].BoolVal));
6116 CI->setCallingConv((yyvsp[(2) - (8)].UIntVal));
Duncan Sandsdc024672007-11-27 13:23:08 +00006117 CI->setParamAttrs(PAL);
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006118 (yyval.InstVal) = CI;
6119 delete (yyvsp[(6) - (8)].ParamList);
6120 delete (yyvsp[(3) - (8)].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00006121 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006122 ;}
6123 break;
6124
6125 case 304:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00006126#line 3006 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006127 {
6128 (yyval.InstVal) = (yyvsp[(1) - (1)].InstVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00006129 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006130 ;}
6131 break;
6132
6133 case 305:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00006134#line 3011 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006135 {
6136 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00006137 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006138 ;}
6139 break;
6140
6141 case 306:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00006142#line 3015 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006143 {
6144 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00006145 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006146 ;}
6147 break;
6148
6149 case 307:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00006150#line 3022 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006151 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006152 if (!UpRefs.empty())
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006153 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
6154 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
6155 delete (yyvsp[(2) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00006156 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006157 ;}
6158 break;
6159
6160 case 308:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00006161#line 3029 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006162 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006163 if (!UpRefs.empty())
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006164 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
6165 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00006166 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006167 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
6168 delete (yyvsp[(2) - (6)].TypeVal);
6169 ;}
6170 break;
6171
6172 case 309:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00006173#line 3037 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006174 {
Reid Spencer14310612006-12-31 05:40:51 +00006175 if (!UpRefs.empty())
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006176 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
6177 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
6178 delete (yyvsp[(2) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00006179 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006180 ;}
6181 break;
6182
6183 case 310:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00006184#line 3044 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006185 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006186 if (!UpRefs.empty())
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006187 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
6188 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006189 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006190 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
6191 delete (yyvsp[(2) - (6)].TypeVal);
6192 ;}
6193 break;
6194
6195 case 311:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00006196#line 3052 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006197 {
6198 if (!isa<PointerType>((yyvsp[(2) - (2)].ValueVal)->getType()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006199 GEN_ERROR("Trying to free nonpointer type " +
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006200 (yyvsp[(2) - (2)].ValueVal)->getType()->getDescription() + "");
6201 (yyval.InstVal) = new FreeInst((yyvsp[(2) - (2)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006202 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006203 ;}
6204 break;
6205
6206 case 312:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00006207#line 3060 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006208 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006209 if (!UpRefs.empty())
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006210 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6211 if (!isa<PointerType>((yyvsp[(3) - (5)].TypeVal)->get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006212 GEN_ERROR("Can't load from nonpointer type: " +
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006213 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6214 if (!cast<PointerType>((yyvsp[(3) - (5)].TypeVal)->get())->getElementType()->isFirstClassType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006215 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006216 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6217 Value* tmpVal = getVal(*(yyvsp[(3) - (5)].TypeVal), (yyvsp[(4) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006218 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006219 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[(1) - (5)].BoolVal), (yyvsp[(5) - (5)].UIntVal));
6220 delete (yyvsp[(3) - (5)].TypeVal);
6221 ;}
6222 break;
6223
6224 case 313:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00006225#line 3074 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006226 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006227 if (!UpRefs.empty())
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006228 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
6229 const PointerType *PT = dyn_cast<PointerType>((yyvsp[(5) - (7)].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006230 if (!PT)
6231 GEN_ERROR("Can't store to a nonpointer type: " +
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006232 (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006233 const Type *ElTy = PT->getElementType();
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006234 if (ElTy != (yyvsp[(3) - (7)].ValueVal)->getType())
6235 GEN_ERROR("Can't store '" + (yyvsp[(3) - (7)].ValueVal)->getType()->getDescription() +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006236 "' into space of type '" + ElTy->getDescription() + "'");
6237
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006238 Value* tmpVal = getVal(*(yyvsp[(5) - (7)].TypeVal), (yyvsp[(6) - (7)].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006239 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006240 (yyval.InstVal) = new StoreInst((yyvsp[(3) - (7)].ValueVal), tmpVal, (yyvsp[(1) - (7)].BoolVal), (yyvsp[(7) - (7)].UIntVal));
6241 delete (yyvsp[(5) - (7)].TypeVal);
6242 ;}
6243 break;
6244
6245 case 314:
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00006246#line 3091 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006247 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006248 if (!UpRefs.empty())
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006249 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (4)].TypeVal))->getDescription());
6250 if (!isa<PointerType>((yyvsp[(2) - (4)].TypeVal)->get()))
Reid Spencerb5334b02007-02-05 10:18:06 +00006251 GEN_ERROR("getelementptr insn requires pointer operand");
Reid Spencer68a24bd2005-08-27 18:50:39 +00006252
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006253 if (!GetElementPtrInst::getIndexedType(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(4) - (4)].ValueList)->begin(), (yyvsp[(4) - (4)].ValueList)->end(), true))
Reid Spencer61c83e02006-08-18 08:43:06 +00006254 GEN_ERROR("Invalid getelementptr indices for type '" +
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006255 (*(yyvsp[(2) - (4)].TypeVal))->getDescription()+ "'");
6256 Value* tmpVal = getVal(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(3) - (4)].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00006257 CHECK_FOR_ERROR
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006258 (yyval.InstVal) = new GetElementPtrInst(tmpVal, (yyvsp[(4) - (4)].ValueList)->begin(), (yyvsp[(4) - (4)].ValueList)->end());
6259 delete (yyvsp[(2) - (4)].TypeVal);
6260 delete (yyvsp[(4) - (4)].ValueList);
6261 ;}
6262 break;
Reid Spencer7780acb2007-04-16 06:56:07 +00006263
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006264
6265/* Line 1267 of yacc.c. */
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00006266#line 6267 "llvmAsmParser.tab.c"
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006267 default: break;
Dale Johannesencdd509a2007-09-07 21:07:57 +00006268 }
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006269 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
6270
6271 YYPOPSTACK (yylen);
6272 yylen = 0;
6273 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006274
6275 *++yyvsp = yyval;
6276
6277
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006278 /* Now `shift' the result of the reduction. Determine what state
6279 that goes to, based on the state we popped back to and the rule
6280 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00006281
6282 yyn = yyr1[yyn];
6283
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006284 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
6285 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00006286 yystate = yytable[yystate];
6287 else
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006288 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00006289
6290 goto yynewstate;
6291
6292
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006293/*------------------------------------.
6294| yyerrlab -- here on detecting error |
6295`------------------------------------*/
6296yyerrlab:
6297 /* If not already recovering from an error, report this error. */
6298 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00006299 {
6300 ++yynerrs;
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006301#if ! YYERROR_VERBOSE
6302 yyerror (YY_("syntax error"));
6303#else
6304 {
6305 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
6306 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
6307 {
6308 YYSIZE_T yyalloc = 2 * yysize;
6309 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
6310 yyalloc = YYSTACK_ALLOC_MAXIMUM;
6311 if (yymsg != yymsgbuf)
6312 YYSTACK_FREE (yymsg);
6313 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
6314 if (yymsg)
6315 yymsg_alloc = yyalloc;
6316 else
6317 {
6318 yymsg = yymsgbuf;
6319 yymsg_alloc = sizeof yymsgbuf;
6320 }
6321 }
Dale Johannesencdd509a2007-09-07 21:07:57 +00006322
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006323 if (0 < yysize && yysize <= yymsg_alloc)
6324 {
6325 (void) yysyntax_error (yymsg, yystate, yychar);
6326 yyerror (yymsg);
6327 }
6328 else
6329 {
6330 yyerror (YY_("syntax error"));
6331 if (yysize != 0)
6332 goto yyexhaustedlab;
6333 }
6334 }
6335#endif
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006336 }
6337
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006338
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006339
6340 if (yyerrstatus == 3)
6341 {
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006342 /* If just tried and failed to reuse look-ahead token after an
6343 error, discard it. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006344
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006345 if (yychar <= YYEOF)
6346 {
6347 /* Return failure if at end of input. */
6348 if (yychar == YYEOF)
6349 YYABORT;
6350 }
6351 else
6352 {
6353 yydestruct ("Error: discarding",
6354 yytoken, &yylval);
6355 yychar = YYEMPTY;
6356 }
6357 }
6358
6359 /* Else will try to reuse look-ahead token after shifting the error
6360 token. */
6361 goto yyerrlab1;
6362
6363
6364/*---------------------------------------------------.
6365| yyerrorlab -- error raised explicitly by YYERROR. |
6366`---------------------------------------------------*/
6367yyerrorlab:
6368
6369 /* Pacify compilers like GCC when the user code never invokes
6370 YYERROR and the label yyerrorlab therefore never appears in user
6371 code. */
6372 if (/*CONSTCOND*/ 0)
6373 goto yyerrorlab;
6374
6375 /* Do not reclaim the symbols of the rule which action triggered
6376 this YYERROR. */
6377 YYPOPSTACK (yylen);
6378 yylen = 0;
6379 YY_STACK_PRINT (yyss, yyssp);
6380 yystate = *yyssp;
6381 goto yyerrlab1;
6382
6383
6384/*-------------------------------------------------------------.
6385| yyerrlab1 -- common code for both syntax error and YYERROR. |
6386`-------------------------------------------------------------*/
6387yyerrlab1:
6388 yyerrstatus = 3; /* Each real token shifted decrements this. */
6389
6390 for (;;)
6391 {
6392 yyn = yypact[yystate];
6393 if (yyn != YYPACT_NINF)
6394 {
6395 yyn += YYTERROR;
6396 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6397 {
6398 yyn = yytable[yyn];
6399 if (0 < yyn)
6400 break;
6401 }
6402 }
6403
6404 /* Pop the current state because it cannot handle the error token. */
6405 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00006406 YYABORT;
6407
Dale Johannesencdd509a2007-09-07 21:07:57 +00006408
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006409 yydestruct ("Error: popping",
6410 yystos[yystate], yyvsp);
6411 YYPOPSTACK (1);
6412 yystate = *yyssp;
6413 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006414 }
6415
6416 if (yyn == YYFINAL)
6417 YYACCEPT;
6418
Reid Spencer68a24bd2005-08-27 18:50:39 +00006419 *++yyvsp = yylval;
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006420
6421
6422 /* Shift the error token. */
6423 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spencerb8f85052007-07-31 03:50:36 +00006424
Reid Spencer68a24bd2005-08-27 18:50:39 +00006425 yystate = yyn;
6426 goto yynewstate;
6427
David Greene5fd22a82007-09-04 18:46:50 +00006428
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006429/*-------------------------------------.
6430| yyacceptlab -- YYACCEPT comes here. |
6431`-------------------------------------*/
6432yyacceptlab:
6433 yyresult = 0;
6434 goto yyreturn;
6435
6436/*-----------------------------------.
6437| yyabortlab -- YYABORT comes here. |
6438`-----------------------------------*/
6439yyabortlab:
6440 yyresult = 1;
6441 goto yyreturn;
6442
6443#ifndef yyoverflow
6444/*-------------------------------------------------.
6445| yyexhaustedlab -- memory exhaustion comes here. |
6446`-------------------------------------------------*/
6447yyexhaustedlab:
6448 yyerror (YY_("memory exhausted"));
6449 yyresult = 2;
6450 /* Fall through. */
David Greene5fd22a82007-09-04 18:46:50 +00006451#endif
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006452
6453yyreturn:
6454 if (yychar != YYEOF && yychar != YYEMPTY)
6455 yydestruct ("Cleanup: discarding lookahead",
6456 yytoken, &yylval);
6457 /* Do not reclaim the symbols of the rule which action triggered
6458 this YYABORT or YYACCEPT. */
6459 YYPOPSTACK (yylen);
6460 YY_STACK_PRINT (yyss, yyssp);
6461 while (yyssp != yyss)
6462 {
6463 yydestruct ("Cleanup: popping",
6464 yystos[*yyssp], yyvsp);
6465 YYPOPSTACK (1);
Dale Johannesencdd509a2007-09-07 21:07:57 +00006466 }
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006467#ifndef yyoverflow
6468 if (yyss != yyssa)
6469 YYSTACK_FREE (yyss);
6470#endif
6471#if YYERROR_VERBOSE
6472 if (yymsg != yymsgbuf)
6473 YYSTACK_FREE (yymsg);
6474#endif
6475 /* Make sure YYID is used. */
6476 return YYID (yyresult);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006477}
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006478
6479
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00006480#line 3108 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00006481
6482
Reid Spencer14310612006-12-31 05:40:51 +00006483// common code from the two 'RunVMAsmParser' functions
6484static Module* RunParser(Module * M) {
Reid Spencer14310612006-12-31 05:40:51 +00006485 CurModule.CurrentModule = M;
Reid Spencer14310612006-12-31 05:40:51 +00006486 // Check to make sure the parser succeeded
6487 if (yyparse()) {
6488 if (ParserResult)
6489 delete ParserResult;
6490 return 0;
6491 }
6492
Reid Spencer0d60b5a2007-03-30 01:37:39 +00006493 // Emit an error if there are any unresolved types left.
6494 if (!CurModule.LateResolveTypes.empty()) {
6495 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
6496 if (DID.Type == ValID::LocalName) {
6497 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
6498 } else {
6499 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
6500 }
6501 if (ParserResult)
6502 delete ParserResult;
6503 return 0;
6504 }
6505
6506 // Emit an error if there are any unresolved values left.
6507 if (!CurModule.LateResolveValues.empty()) {
6508 Value *V = CurModule.LateResolveValues.back();
6509 std::map<Value*, std::pair<ValID, int> >::iterator I =
6510 CurModule.PlaceHolderInfo.find(V);
6511
6512 if (I != CurModule.PlaceHolderInfo.end()) {
6513 ValID &DID = I->second.first;
6514 if (DID.Type == ValID::LocalName) {
6515 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
6516 } else {
6517 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
6518 }
6519 if (ParserResult)
6520 delete ParserResult;
6521 return 0;
6522 }
6523 }
6524
Reid Spencer14310612006-12-31 05:40:51 +00006525 // Check to make sure that parsing produced a result
6526 if (!ParserResult)
6527 return 0;
6528
6529 // Reset ParserResult variable while saving its value for the result.
6530 Module *Result = ParserResult;
6531 ParserResult = 0;
6532
6533 return Result;
6534}
6535
Reid Spencer61c83e02006-08-18 08:43:06 +00006536void llvm::GenerateError(const std::string &message, int LineNo) {
Duncan Sandsdc024672007-11-27 13:23:08 +00006537 if (LineNo == -1) LineNo = LLLgetLineNo();
Reid Spencer61c83e02006-08-18 08:43:06 +00006538 // TODO: column number in exception
6539 if (TheParseError)
Duncan Sandsdc024672007-11-27 13:23:08 +00006540 TheParseError->setError(LLLgetFilename(), message, LineNo);
Reid Spencer61c83e02006-08-18 08:43:06 +00006541 TriggerError = 1;
6542}
Reid Spencer68a24bd2005-08-27 18:50:39 +00006543
6544int yyerror(const char *ErrorMsg) {
Duncan Sandsdc024672007-11-27 13:23:08 +00006545 std::string where = LLLgetFilename() + ":" + utostr(LLLgetLineNo()) + ": ";
Reid Spenceref9b9a72007-02-05 20:47:22 +00006546 std::string errMsg = where + "error: " + std::string(ErrorMsg);
Duncan Sandsdc024672007-11-27 13:23:08 +00006547 if (yychar != YYEMPTY && yychar != 0) {
6548 errMsg += " while reading token: '";
6549 errMsg += std::string(LLLgetTokenStart(),
6550 LLLgetTokenStart()+LLLgetTokenLength()) + "'";
6551 }
Reid Spencer61c83e02006-08-18 08:43:06 +00006552 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006553 return 0;
6554}
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00006555