blob: 7af40bb6f40b757fbd24e2b736f70b85a52e14a6 [file] [log] [blame]
Jeff Cohen361c3ef2007-01-21 19:19:31 +00001/* A Bison parser, made from /usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y, by GNU bison 1.75. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003/* Skeleton parser for Yacc-like parsing with Bison,
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc.
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00005
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00006 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
Anton Korobeynikov178a3522007-01-12 19:22:51 +000010
Reid Spencerb0fcf8f2007-01-17 02:48:45 +000011 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
Jeff Cohen361c3ef2007-01-21 19:19:31 +000018 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
Reid Spencerb0fcf8f2007-01-17 02:48:45 +000020
21/* As a special exception, when this file is copied by Bison into a
22 Bison output file, you may use that output file without restriction.
23 This special exception was added by the Free Software Foundation
24 in version 1.24 of Bison. */
25
26/* Written by Richard Stallman by simplifying the original so called
27 ``semantic'' parser. */
28
29/* All symbols defined below should begin with yy or YY, to avoid
30 infringing on user name space. This should be done even for local
31 variables, as they might otherwise be expanded by user macros.
32 There are some unavoidable exceptions within include files to
33 define necessary library symbols; they are noted "INFRINGES ON
34 USER NAME SPACE" below. */
35
36/* Identify Bison output. */
Jeff Cohen361c3ef2007-01-21 19:19:31 +000037#define YYBISON 1
Reid Spencerb0fcf8f2007-01-17 02:48:45 +000038
39/* Pure parsers. */
Jeff Cohen361c3ef2007-01-21 19:19:31 +000040#define YYPURE 0
Reid Spencerb0fcf8f2007-01-17 02:48:45 +000041
42/* Using locations. */
43#define YYLSP_NEEDED 0
44
Jeff Cohen361c3ef2007-01-21 19:19:31 +000045/* If NAME_PREFIX is specified substitute the variables and functions
46 names. */
Reid Spencer68a24bd2005-08-27 18:50:39 +000047#define yyparse llvmAsmparse
Reid Spencerb0fcf8f2007-01-17 02:48:45 +000048#define yylex llvmAsmlex
Reid Spencer68a24bd2005-08-27 18:50:39 +000049#define yyerror llvmAsmerror
Reid Spencerb0fcf8f2007-01-17 02:48:45 +000050#define yylval llvmAsmlval
51#define yychar llvmAsmchar
Reid Spencer68a24bd2005-08-27 18:50:39 +000052#define yydebug llvmAsmdebug
53#define yynerrs llvmAsmnerrs
54
Reid Spencerb0fcf8f2007-01-17 02:48:45 +000055
56/* Tokens. */
57#ifndef YYTOKENTYPE
58# define YYTOKENTYPE
59 /* Put the tokens into the symbol table, so that GDB and other debuggers
60 know about them. */
61 enum yytokentype {
62 ESINT64VAL = 258,
63 EUINT64VAL = 259,
64 SINTVAL = 260,
65 UINTVAL = 261,
66 FPVAL = 262,
67 VOID = 263,
68 INTTYPE = 264,
69 FLOAT = 265,
70 DOUBLE = 266,
71 LABEL = 267,
72 TYPE = 268,
73 VAR_ID = 269,
74 LABELSTR = 270,
75 STRINGCONSTANT = 271,
76 IMPLEMENTATION = 272,
77 ZEROINITIALIZER = 273,
78 TRUETOK = 274,
79 FALSETOK = 275,
80 BEGINTOK = 276,
81 ENDTOK = 277,
82 DECLARE = 278,
83 DEFINE = 279,
84 GLOBAL = 280,
85 CONSTANT = 281,
86 SECTION = 282,
87 VOLATILE = 283,
88 TO = 284,
89 DOTDOTDOT = 285,
90 NULL_TOK = 286,
91 UNDEF = 287,
92 INTERNAL = 288,
93 LINKONCE = 289,
94 WEAK = 290,
95 APPENDING = 291,
96 DLLIMPORT = 292,
97 DLLEXPORT = 293,
98 EXTERN_WEAK = 294,
99 OPAQUE = 295,
100 EXTERNAL = 296,
101 TARGET = 297,
102 TRIPLE = 298,
103 ENDIAN = 299,
104 POINTERSIZE = 300,
105 LITTLE = 301,
106 BIG = 302,
107 ALIGN = 303,
108 DEPLIBS = 304,
109 CALL = 305,
110 TAIL = 306,
111 ASM_TOK = 307,
112 MODULE = 308,
113 SIDEEFFECT = 309,
114 CC_TOK = 310,
115 CCC_TOK = 311,
116 CSRETCC_TOK = 312,
117 FASTCC_TOK = 313,
118 COLDCC_TOK = 314,
119 X86_STDCALLCC_TOK = 315,
120 X86_FASTCALLCC_TOK = 316,
121 DATALAYOUT = 317,
122 RET = 318,
123 BR = 319,
124 SWITCH = 320,
125 INVOKE = 321,
126 UNWIND = 322,
127 UNREACHABLE = 323,
128 ADD = 324,
129 SUB = 325,
130 MUL = 326,
131 UDIV = 327,
132 SDIV = 328,
133 FDIV = 329,
134 UREM = 330,
135 SREM = 331,
136 FREM = 332,
137 AND = 333,
138 OR = 334,
139 XOR = 335,
140 ICMP = 336,
141 FCMP = 337,
142 EQ = 338,
143 NE = 339,
144 SLT = 340,
145 SGT = 341,
146 SLE = 342,
147 SGE = 343,
148 ULT = 344,
149 UGT = 345,
150 ULE = 346,
151 UGE = 347,
152 OEQ = 348,
153 ONE = 349,
154 OLT = 350,
155 OGT = 351,
156 OLE = 352,
157 OGE = 353,
158 ORD = 354,
159 UNO = 355,
160 UEQ = 356,
161 UNE = 357,
162 MALLOC = 358,
163 ALLOCA = 359,
164 FREE = 360,
165 LOAD = 361,
166 STORE = 362,
167 GETELEMENTPTR = 363,
168 TRUNC = 364,
169 ZEXT = 365,
170 SEXT = 366,
171 FPTRUNC = 367,
172 FPEXT = 368,
173 BITCAST = 369,
174 UITOFP = 370,
175 SITOFP = 371,
176 FPTOUI = 372,
177 FPTOSI = 373,
178 INTTOPTR = 374,
179 PTRTOINT = 375,
180 PHI_TOK = 376,
181 SELECT = 377,
182 SHL = 378,
183 LSHR = 379,
184 ASHR = 380,
185 VAARG = 381,
186 EXTRACTELEMENT = 382,
187 INSERTELEMENT = 383,
188 SHUFFLEVECTOR = 384,
189 NORETURN = 385,
190 DEFAULT = 386,
191 HIDDEN = 387
192 };
193#endif
Reid Spencerb0fcf8f2007-01-17 02:48:45 +0000194#define ESINT64VAL 258
195#define EUINT64VAL 259
196#define SINTVAL 260
197#define UINTVAL 261
198#define FPVAL 262
199#define VOID 263
200#define INTTYPE 264
201#define FLOAT 265
202#define DOUBLE 266
203#define LABEL 267
204#define TYPE 268
205#define VAR_ID 269
206#define LABELSTR 270
207#define STRINGCONSTANT 271
208#define IMPLEMENTATION 272
209#define ZEROINITIALIZER 273
210#define TRUETOK 274
211#define FALSETOK 275
212#define BEGINTOK 276
213#define ENDTOK 277
214#define DECLARE 278
215#define DEFINE 279
216#define GLOBAL 280
217#define CONSTANT 281
218#define SECTION 282
219#define VOLATILE 283
220#define TO 284
221#define DOTDOTDOT 285
222#define NULL_TOK 286
223#define UNDEF 287
224#define INTERNAL 288
225#define LINKONCE 289
226#define WEAK 290
227#define APPENDING 291
228#define DLLIMPORT 292
229#define DLLEXPORT 293
230#define EXTERN_WEAK 294
231#define OPAQUE 295
232#define EXTERNAL 296
233#define TARGET 297
234#define TRIPLE 298
235#define ENDIAN 299
236#define POINTERSIZE 300
237#define LITTLE 301
238#define BIG 302
239#define ALIGN 303
240#define DEPLIBS 304
241#define CALL 305
242#define TAIL 306
243#define ASM_TOK 307
244#define MODULE 308
245#define SIDEEFFECT 309
246#define CC_TOK 310
247#define CCC_TOK 311
248#define CSRETCC_TOK 312
249#define FASTCC_TOK 313
250#define COLDCC_TOK 314
251#define X86_STDCALLCC_TOK 315
252#define X86_FASTCALLCC_TOK 316
253#define DATALAYOUT 317
254#define RET 318
255#define BR 319
256#define SWITCH 320
257#define INVOKE 321
258#define UNWIND 322
259#define UNREACHABLE 323
260#define ADD 324
261#define SUB 325
262#define MUL 326
263#define UDIV 327
264#define SDIV 328
265#define FDIV 329
266#define UREM 330
267#define SREM 331
268#define FREM 332
269#define AND 333
270#define OR 334
271#define XOR 335
272#define ICMP 336
273#define FCMP 337
274#define EQ 338
275#define NE 339
276#define SLT 340
277#define SGT 341
278#define SLE 342
279#define SGE 343
280#define ULT 344
281#define UGT 345
282#define ULE 346
283#define UGE 347
284#define OEQ 348
285#define ONE 349
286#define OLT 350
287#define OGT 351
288#define OLE 352
289#define OGE 353
290#define ORD 354
291#define UNO 355
292#define UEQ 356
293#define UNE 357
294#define MALLOC 358
295#define ALLOCA 359
296#define FREE 360
297#define LOAD 361
298#define STORE 362
299#define GETELEMENTPTR 363
300#define TRUNC 364
301#define ZEXT 365
302#define SEXT 366
303#define FPTRUNC 367
304#define FPEXT 368
305#define BITCAST 369
306#define UITOFP 370
307#define SITOFP 371
308#define FPTOUI 372
309#define FPTOSI 373
310#define INTTOPTR 374
311#define PTRTOINT 375
312#define PHI_TOK 376
313#define SELECT 377
314#define SHL 378
315#define LSHR 379
316#define ASHR 380
317#define VAARG 381
318#define EXTRACTELEMENT 382
319#define INSERTELEMENT 383
320#define SHUFFLEVECTOR 384
321#define NORETURN 385
322#define DEFAULT 386
323#define HIDDEN 387
324
325
326
327
328/* Copy the first part of user declarations. */
Jeff Cohen361c3ef2007-01-21 19:19:31 +0000329#line 14 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000330
331#include "ParserInternals.h"
332#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000333#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000334#include "llvm/Instructions.h"
335#include "llvm/Module.h"
336#include "llvm/SymbolTable.h"
337#include "llvm/Support/GetElementPtrTypeIterator.h"
Reid Spencer14310612006-12-31 05:40:51 +0000338#include "llvm/Support/CommandLine.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000339#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000340#include "llvm/Support/MathExtras.h"
Reid Spencer481169e2006-12-01 00:33:46 +0000341#include "llvm/Support/Streams.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000342#include <algorithm>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000343#include <list>
344#include <utility>
Reid Spencer14310612006-12-31 05:40:51 +0000345#ifndef NDEBUG
346#define YYDEBUG 1
347#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000348
Reid Spencere4f47592006-08-18 17:32:55 +0000349// The following is a gross hack. In order to rid the libAsmParser library of
350// exceptions, we have to have a way of getting the yyparse function to go into
351// an error situation. So, whenever we want an error to occur, the GenerateError
352// function (see bottom of file) sets TriggerError. Then, at the end of each
353// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
354// (a goto) to put YACC in error state. Furthermore, several calls to
355// GenerateError are made from inside productions and they must simulate the
356// previous exception behavior by exiting the production immediately. We have
357// replaced these with the GEN_ERROR macro which calls GeneratError and then
358// immediately invokes YYERROR. This would be so much cleaner if it was a
359// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000360static bool TriggerError = false;
Reid Spencerf63697d2006-10-09 17:36:59 +0000361#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000362#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
363
Reid Spencer68a24bd2005-08-27 18:50:39 +0000364int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
365int yylex(); // declaration" of xxx warnings.
366int yyparse();
367
368namespace llvm {
369 std::string CurFilename;
Reid Spencer14310612006-12-31 05:40:51 +0000370#if YYDEBUG
371static cl::opt<bool>
372Debug("debug-yacc", cl::desc("Print yacc debug state changes"),
373 cl::Hidden, cl::init(false));
374#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000375}
376using namespace llvm;
377
378static Module *ParserResult;
379
380// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
381// relating to upreferences in the input stream.
382//
383//#define DEBUG_UPREFS 1
384#ifdef DEBUG_UPREFS
Bill Wendlinge8156192006-12-07 01:30:32 +0000385#define UR_OUT(X) cerr << X
Reid Spencer68a24bd2005-08-27 18:50:39 +0000386#else
387#define UR_OUT(X)
388#endif
389
390#define YYERROR_VERBOSE 1
391
Chris Lattnerb475c422005-11-12 18:22:38 +0000392static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000393
394
395// This contains info used when building the body of a function. It is
396// destroyed when the function is completed.
397//
398typedef std::vector<Value *> ValueList; // Numbered defs
Reid Spencer14310612006-12-31 05:40:51 +0000399
Reid Spencer68a24bd2005-08-27 18:50:39 +0000400static void
401ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
402 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
403
404static struct PerModuleInfo {
405 Module *CurrentModule;
406 std::map<const Type *, ValueList> Values; // Module level numbered definitions
407 std::map<const Type *,ValueList> LateResolveValues;
Reid Spencer861d9d62006-11-28 07:29:44 +0000408 std::vector<PATypeHolder> Types;
409 std::map<ValID, PATypeHolder> LateResolveTypes;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000410
411 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000412 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000413 /// that we can resolve them later and print error messages as appropriate.
414 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
415
416 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
417 // references to global values. Global values may be referenced before they
418 // are defined, and if so, the temporary object that they represent is held
419 // here. This is used for forward references of GlobalValues.
420 //
421 typedef std::map<std::pair<const PointerType *,
422 ValID>, GlobalValue*> GlobalRefsType;
423 GlobalRefsType GlobalRefs;
424
425 void ModuleDone() {
426 // If we could not resolve some functions at function compilation time
427 // (calls to functions before they are defined), resolve them now... Types
428 // are resolved when the constant pool has been completely parsed.
429 //
430 ResolveDefinitions(LateResolveValues);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000431 if (TriggerError)
432 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000433
434 // Check to make sure that all global value forward references have been
435 // resolved!
436 //
437 if (!GlobalRefs.empty()) {
438 std::string UndefinedReferences = "Unresolved global references exist:\n";
439
440 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
441 I != E; ++I) {
442 UndefinedReferences += " " + I->first.first->getDescription() + " " +
443 I->first.second.getName() + "\n";
444 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000445 GenerateError(UndefinedReferences);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000446 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000447 }
448
449 Values.clear(); // Clear out function local definitions
450 Types.clear();
451 CurrentModule = 0;
452 }
453
Reid Spencer68a24bd2005-08-27 18:50:39 +0000454 // GetForwardRefForGlobal - Check to see if there is a forward reference
455 // for this global. If so, remove it from the GlobalRefs map and return it.
456 // If not, just return null.
457 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
458 // Check to see if there is a forward reference to this global variable...
459 // if there is, eliminate it and patch the reference to use the new def'n.
460 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
461 GlobalValue *Ret = 0;
462 if (I != GlobalRefs.end()) {
463 Ret = I->second;
464 GlobalRefs.erase(I);
465 }
466 return Ret;
467 }
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000468
469 bool TypeIsUnresolved(PATypeHolder* PATy) {
470 // If it isn't abstract, its resolved
471 const Type* Ty = PATy->get();
472 if (!Ty->isAbstract())
473 return false;
474 // Traverse the type looking for abstract types. If it isn't abstract then
475 // we don't need to traverse that leg of the type.
476 std::vector<const Type*> WorkList, SeenList;
477 WorkList.push_back(Ty);
478 while (!WorkList.empty()) {
479 const Type* Ty = WorkList.back();
480 SeenList.push_back(Ty);
481 WorkList.pop_back();
482 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
483 // Check to see if this is an unresolved type
484 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
485 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
486 for ( ; I != E; ++I) {
487 if (I->second.get() == OpTy)
488 return true;
489 }
490 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
491 const Type* TheTy = SeqTy->getElementType();
492 if (TheTy->isAbstract() && TheTy != Ty) {
493 std::vector<const Type*>::iterator I = SeenList.begin(),
494 E = SeenList.end();
495 for ( ; I != E; ++I)
496 if (*I == TheTy)
497 break;
498 if (I == E)
499 WorkList.push_back(TheTy);
500 }
501 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
502 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
503 const Type* TheTy = StrTy->getElementType(i);
504 if (TheTy->isAbstract() && TheTy != Ty) {
505 std::vector<const Type*>::iterator I = SeenList.begin(),
506 E = SeenList.end();
507 for ( ; I != E; ++I)
508 if (*I == TheTy)
509 break;
510 if (I == E)
511 WorkList.push_back(TheTy);
512 }
513 }
514 }
515 }
516 return false;
517 }
518
519
Reid Spencer68a24bd2005-08-27 18:50:39 +0000520} CurModule;
521
522static struct PerFunctionInfo {
523 Function *CurrentFunction; // Pointer to current function being created
524
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000525 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
Reid Spencer68a24bd2005-08-27 18:50:39 +0000526 std::map<const Type*, ValueList> LateResolveValues;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000527 bool isDeclare; // Is this function a forward declararation?
528 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000529 GlobalValue::VisibilityTypes Visibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000530
531 /// BBForwardRefs - When we see forward references to basic blocks, keep
532 /// track of them here.
533 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
534 std::vector<BasicBlock*> NumberedBlocks;
535 unsigned NextBBNum;
536
537 inline PerFunctionInfo() {
538 CurrentFunction = 0;
539 isDeclare = false;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000540 Linkage = GlobalValue::ExternalLinkage;
541 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000542 }
543
544 inline void FunctionStart(Function *M) {
545 CurrentFunction = M;
546 NextBBNum = 0;
547 }
548
549 void FunctionDone() {
550 NumberedBlocks.clear();
551
552 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000553 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000554 GenerateError("Undefined reference to label " +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000555 BBForwardRefs.begin()->first->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000556 return;
557 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000558
559 // Resolve all forward references now.
560 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
561
562 Values.clear(); // Clear out function local definitions
563 CurrentFunction = 0;
564 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000565 Linkage = GlobalValue::ExternalLinkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000566 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000567 }
568} CurFun; // Info for the current function...
569
570static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
571
572
573//===----------------------------------------------------------------------===//
574// Code to handle definitions of all the types
575//===----------------------------------------------------------------------===//
576
577static int InsertValue(Value *V,
578 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
579 if (V->hasName()) return -1; // Is this a numbered definition?
580
581 // Yes, insert the value into the value table...
582 ValueList &List = ValueTab[V->getType()];
583 List.push_back(V);
584 return List.size()-1;
585}
586
587static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
588 switch (D.Type) {
589 case ValID::NumberVal: // Is it a numbered definition?
590 // Module constants occupy the lowest numbered slots...
591 if ((unsigned)D.Num < CurModule.Types.size())
Reid Spencer861d9d62006-11-28 07:29:44 +0000592 return CurModule.Types[(unsigned)D.Num];
Reid Spencer68a24bd2005-08-27 18:50:39 +0000593 break;
594 case ValID::NameVal: // Is it a named definition?
595 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
596 D.destroy(); // Free old strdup'd memory...
597 return N;
598 }
599 break;
600 default:
Reid Spencer61c83e02006-08-18 08:43:06 +0000601 GenerateError("Internal parser error: Invalid symbol type reference!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000602 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000603 }
604
605 // If we reached here, we referenced either a symbol that we don't know about
606 // or an id number that hasn't been read yet. We may be referencing something
607 // forward, so just create an entry to be resolved later and get to it...
608 //
609 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
610
611
612 if (inFunctionScope()) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000613 if (D.Type == ValID::NameVal) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000614 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000615 return 0;
616 } else {
Reid Spencer61c83e02006-08-18 08:43:06 +0000617 GenerateError("Reference to an undefined type: #" + itostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000618 return 0;
619 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000620 }
621
Reid Spencer861d9d62006-11-28 07:29:44 +0000622 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000623 if (I != CurModule.LateResolveTypes.end())
Reid Spencer861d9d62006-11-28 07:29:44 +0000624 return I->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000625
Reid Spencer861d9d62006-11-28 07:29:44 +0000626 Type *Typ = OpaqueType::get();
627 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
628 return Typ;
Reid Spencera132e042006-12-03 05:46:11 +0000629 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000630
631static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
632 SymbolTable &SymTab =
Reid Spencer78d033e2007-01-06 07:24:44 +0000633 inFunctionScope() ? CurFun.CurrentFunction->getValueSymbolTable() :
634 CurModule.CurrentModule->getValueSymbolTable();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000635 return SymTab.lookup(Ty, Name);
636}
637
638// getValNonImprovising - Look up the value specified by the provided type and
639// the provided ValID. If the value exists and has already been defined, return
640// it. Otherwise return null.
641//
642static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000643 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000644 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000645 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000646 return 0;
647 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000648
649 switch (D.Type) {
650 case ValID::NumberVal: { // Is it a numbered definition?
651 unsigned Num = (unsigned)D.Num;
652
653 // Module constants occupy the lowest numbered slots...
654 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
655 if (VI != CurModule.Values.end()) {
656 if (Num < VI->second.size())
657 return VI->second[Num];
658 Num -= VI->second.size();
659 }
660
661 // Make sure that our type is within bounds
662 VI = CurFun.Values.find(Ty);
663 if (VI == CurFun.Values.end()) return 0;
664
665 // Check that the number is within bounds...
666 if (VI->second.size() <= Num) return 0;
667
668 return VI->second[Num];
669 }
670
671 case ValID::NameVal: { // Is it a named definition?
672 Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
673 if (N == 0) return 0;
674
675 D.destroy(); // Free old strdup'd memory...
676 return N;
677 }
678
679 // Check to make sure that "Ty" is an integral type, and that our
680 // value will fit into the specified type...
681 case ValID::ConstSIntVal: // Is it a constant pool reference??
Reid Spencerb83eb642006-10-20 07:07:24 +0000682 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000683 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000684 itostr(D.ConstPool64) + "' is invalid for type '" +
685 Ty->getDescription() + "'!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000686 return 0;
687 }
Reid Spencerb83eb642006-10-20 07:07:24 +0000688 return ConstantInt::get(Ty, D.ConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000689
690 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Reid Spencerb83eb642006-10-20 07:07:24 +0000691 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
692 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000693 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000694 "' is invalid or out of range!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000695 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000696 } else { // This is really a signed reference. Transmogrify.
Reid Spencerb83eb642006-10-20 07:07:24 +0000697 return ConstantInt::get(Ty, D.ConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000698 }
699 } else {
Reid Spencerb83eb642006-10-20 07:07:24 +0000700 return ConstantInt::get(Ty, D.UConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000701 }
702
703 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000704 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000705 GenerateError("FP constant invalid for type!!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000706 return 0;
707 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000708 return ConstantFP::get(Ty, D.ConstPoolFP);
709
710 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000711 if (!isa<PointerType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000712 GenerateError("Cannot create a a non pointer null!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000713 return 0;
714 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000715 return ConstantPointerNull::get(cast<PointerType>(Ty));
716
717 case ValID::ConstUndefVal: // Is it an undef value?
718 return UndefValue::get(Ty);
719
Chris Lattner7aa61892005-12-21 17:53:23 +0000720 case ValID::ConstZeroVal: // Is it a zero value?
721 return Constant::getNullValue(Ty);
722
Reid Spencer68a24bd2005-08-27 18:50:39 +0000723 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000724 if (D.ConstantValue->getType() != Ty) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000725 GenerateError("Constant expression type different from required type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000726 return 0;
727 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000728 return D.ConstantValue;
729
Chris Lattner0e9c3762006-01-25 22:27:16 +0000730 case ValID::InlineAsmVal: { // Inline asm expression
731 const PointerType *PTy = dyn_cast<PointerType>(Ty);
732 const FunctionType *FTy =
733 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000734 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000735 GenerateError("Invalid type for asm constraint string!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000736 return 0;
737 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000738 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
739 D.IAD->HasSideEffects);
740 D.destroy(); // Free InlineAsmDescriptor.
741 return IA;
742 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000743 default:
744 assert(0 && "Unhandled case!");
745 return 0;
746 } // End of switch
747
748 assert(0 && "Unhandled case!");
749 return 0;
750}
751
752// getVal - This function is identical to getValNonImprovising, except that if a
753// value is not already defined, it "improvises" by creating a placeholder var
754// that looks and acts just like the requested variable. When the value is
755// defined later, all uses of the placeholder variable are replaced with the
756// real thing.
757//
758static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000759 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000760 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000761 return 0;
762 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000763
764 // See if the value has already been defined.
765 Value *V = getValNonImprovising(Ty, ID);
766 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000767 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000768
Reid Spencer5b7e7532006-09-28 19:28:24 +0000769 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000770 GenerateError("Invalid use of a composite type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000771 return 0;
772 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000773
774 // If we reached here, we referenced either a symbol that we don't know about
775 // or an id number that hasn't been read yet. We may be referencing something
776 // forward, so just create an entry to be resolved later and get to it...
777 //
778 V = new Argument(Ty);
779
780 // Remember where this forward reference came from. FIXME, shouldn't we try
781 // to recycle these things??
782 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
783 llvmAsmlineno)));
784
785 if (inFunctionScope())
786 InsertValue(V, CurFun.LateResolveValues);
787 else
788 InsertValue(V, CurModule.LateResolveValues);
789 return V;
790}
791
792/// getBBVal - This is used for two purposes:
793/// * If isDefinition is true, a new basic block with the specified ID is being
794/// defined.
795/// * If isDefinition is true, this is a reference to a basic block, which may
796/// or may not be a forward reference.
797///
798static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
799 assert(inFunctionScope() && "Can't get basic block at global scope!");
800
801 std::string Name;
802 BasicBlock *BB = 0;
803 switch (ID.Type) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000804 default:
805 GenerateError("Illegal label reference " + ID.getName());
806 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000807 case ValID::NumberVal: // Is it a numbered definition?
808 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
809 CurFun.NumberedBlocks.resize(ID.Num+1);
810 BB = CurFun.NumberedBlocks[ID.Num];
811 break;
812 case ValID::NameVal: // Is it a named definition?
813 Name = ID.Name;
814 if (Value *N = CurFun.CurrentFunction->
Reid Spencer78d033e2007-01-06 07:24:44 +0000815 getValueSymbolTable().lookup(Type::LabelTy, Name))
Reid Spencer68a24bd2005-08-27 18:50:39 +0000816 BB = cast<BasicBlock>(N);
817 break;
818 }
819
820 // See if the block has already been defined.
821 if (BB) {
822 // If this is the definition of the block, make sure the existing value was
823 // just a forward reference. If it was a forward reference, there will be
824 // an entry for it in the PlaceHolderInfo map.
Reid Spencer5b7e7532006-09-28 19:28:24 +0000825 if (isDefinition && !CurFun.BBForwardRefs.erase(BB)) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000826 // The existing value was a definition, not a forward reference.
Reid Spencer61c83e02006-08-18 08:43:06 +0000827 GenerateError("Redefinition of label " + ID.getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000828 return 0;
829 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000830
831 ID.destroy(); // Free strdup'd memory.
832 return BB;
833 }
834
835 // Otherwise this block has not been seen before.
836 BB = new BasicBlock("", CurFun.CurrentFunction);
837 if (ID.Type == ValID::NameVal) {
838 BB->setName(ID.Name);
839 } else {
840 CurFun.NumberedBlocks[ID.Num] = BB;
841 }
842
843 // If this is not a definition, keep track of it so we can use it as a forward
844 // reference.
845 if (!isDefinition) {
846 // Remember where this forward reference came from.
847 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
848 } else {
849 // The forward declaration could have been inserted anywhere in the
850 // function: insert it into the correct place now.
851 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
852 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
853 }
854 ID.destroy();
855 return BB;
856}
857
858
859//===----------------------------------------------------------------------===//
860// Code to handle forward references in instructions
861//===----------------------------------------------------------------------===//
862//
863// This code handles the late binding needed with statements that reference
864// values not defined yet... for example, a forward branch, or the PHI node for
865// a loop body.
866//
867// This keeps a table (CurFun.LateResolveValues) of all such forward references
868// and back patchs after we are done.
869//
870
871// ResolveDefinitions - If we could not resolve some defs at parsing
872// time (forward branches, phi functions for loops, etc...) resolve the
873// defs now...
874//
875static void
876ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
877 std::map<const Type*,ValueList> *FutureLateResolvers) {
878 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
879 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
880 E = LateResolvers.end(); LRI != E; ++LRI) {
881 ValueList &List = LRI->second;
882 while (!List.empty()) {
883 Value *V = List.back();
884 List.pop_back();
885
886 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
887 CurModule.PlaceHolderInfo.find(V);
888 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
889
890 ValID &DID = PHI->second.first;
891
892 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000893 if (TriggerError)
894 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000895 if (TheRealValue) {
896 V->replaceAllUsesWith(TheRealValue);
897 delete V;
898 CurModule.PlaceHolderInfo.erase(PHI);
899 } else if (FutureLateResolvers) {
900 // Functions have their unresolved items forwarded to the module late
901 // resolver table
902 InsertValue(V, *FutureLateResolvers);
903 } else {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000904 if (DID.Type == ValID::NameVal) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000905 GenerateError("Reference to an invalid definition: '" +DID.getName()+
Reid Spencer68a24bd2005-08-27 18:50:39 +0000906 "' of type '" + V->getType()->getDescription() + "'",
907 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000908 return;
909 } else {
Reid Spencer61c83e02006-08-18 08:43:06 +0000910 GenerateError("Reference to an invalid definition: #" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000911 itostr(DID.Num) + " of type '" +
912 V->getType()->getDescription() + "'",
913 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000914 return;
915 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000916 }
917 }
918 }
919
920 LateResolvers.clear();
921}
922
923// ResolveTypeTo - A brand new type was just declared. This means that (if
924// name is not null) things referencing Name can be resolved. Otherwise, things
925// refering to the number can be resolved. Do this now.
926//
927static void ResolveTypeTo(char *Name, const Type *ToTy) {
928 ValID D;
929 if (Name) D = ValID::create(Name);
930 else D = ValID::create((int)CurModule.Types.size());
931
Reid Spencer861d9d62006-11-28 07:29:44 +0000932 std::map<ValID, PATypeHolder>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +0000933 CurModule.LateResolveTypes.find(D);
934 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer861d9d62006-11-28 07:29:44 +0000935 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000936 CurModule.LateResolveTypes.erase(I);
937 }
938}
939
940// setValueName - Set the specified value to the name given. The name may be
941// null potentially, in which case this is a noop. The string passed in is
942// assumed to be a malloc'd string buffer, and is free'd by this function.
943//
944static void setValueName(Value *V, char *NameStr) {
945 if (NameStr) {
946 std::string Name(NameStr); // Copy string
947 free(NameStr); // Free old string
948
Reid Spencer5b7e7532006-09-28 19:28:24 +0000949 if (V->getType() == Type::VoidTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000950 GenerateError("Can't assign name '" + Name+"' to value with void type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000951 return;
952 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000953
954 assert(inFunctionScope() && "Must be in function scope!");
Reid Spencer78d033e2007-01-06 07:24:44 +0000955 SymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
Reid Spencer5b7e7532006-09-28 19:28:24 +0000956 if (ST.lookup(V->getType(), Name)) {
Reid Spencer63c34452007-01-05 21:51:07 +0000957 GenerateError("Redefinition of value '" + Name + "' of type '" +
958 V->getType()->getDescription() + "'!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000959 return;
960 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000961
962 // Set the name.
963 V->setName(Name);
964 }
965}
966
967/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
968/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +0000969static GlobalVariable *
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000970ParseGlobalVariable(char *NameStr,
971 GlobalValue::LinkageTypes Linkage,
972 GlobalValue::VisibilityTypes Visibility,
Chris Lattnerb475c422005-11-12 18:22:38 +0000973 bool isConstantGlobal, const Type *Ty,
974 Constant *Initializer) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000975 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000976 GenerateError("Cannot declare global vars of function type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000977 return 0;
978 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000979
980 const PointerType *PTy = PointerType::get(Ty);
981
982 std::string Name;
983 if (NameStr) {
984 Name = NameStr; // Copy string
985 free(NameStr); // Free old string
986 }
987
988 // See if this global value was forward referenced. If so, recycle the
989 // object.
990 ValID ID;
991 if (!Name.empty()) {
992 ID = ValID::create((char*)Name.c_str());
993 } else {
994 ID = ValID::create((int)CurModule.Values[PTy].size());
995 }
996
997 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
998 // Move the global to the end of the list, from whereever it was
999 // previously inserted.
1000 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1001 CurModule.CurrentModule->getGlobalList().remove(GV);
1002 CurModule.CurrentModule->getGlobalList().push_back(GV);
1003 GV->setInitializer(Initializer);
1004 GV->setLinkage(Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001005 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001006 GV->setConstant(isConstantGlobal);
1007 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001008 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001009 }
1010
1011 // If this global has a name, check to see if there is already a definition
Reid Spencer63c34452007-01-05 21:51:07 +00001012 // of this global in the module. If so, it is an error.
Reid Spencer68a24bd2005-08-27 18:50:39 +00001013 if (!Name.empty()) {
1014 // We are a simple redefinition of a value, check to see if it is defined
1015 // the same as the old one.
Reid Spencer63c34452007-01-05 21:51:07 +00001016 if (CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +00001017 GenerateError("Redefinition of global variable named '" + Name +
Reid Spencer63c34452007-01-05 21:51:07 +00001018 "' of type '" + Ty->getDescription() + "'!");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001019 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001020 }
1021 }
1022
1023 // Otherwise there is no existing GV to use, create one now.
1024 GlobalVariable *GV =
1025 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
1026 CurModule.CurrentModule);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001027 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001028 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001029 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001030}
1031
1032// setTypeName - Set the specified type to the name given. The name may be
1033// null potentially, in which case this is a noop. The string passed in is
1034// assumed to be a malloc'd string buffer, and is freed by this function.
1035//
1036// This function returns true if the type has already been defined, but is
1037// allowed to be redefined in the specified context. If the name is a new name
1038// for the type plane, it is inserted and false is returned.
1039static bool setTypeName(const Type *T, char *NameStr) {
1040 assert(!inFunctionScope() && "Can't give types function-local names!");
1041 if (NameStr == 0) return false;
1042
1043 std::string Name(NameStr); // Copy string
1044 free(NameStr); // Free old string
1045
1046 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +00001047 if (T == Type::VoidTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +00001048 GenerateError("Can't assign name '" + Name + "' to the void type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001049 return false;
1050 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001051
1052 // Set the type name, checking for conflicts as we do so.
1053 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1054
1055 if (AlreadyExists) { // Inserting a name that is already defined???
1056 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
1057 assert(Existing && "Conflict but no matching type?");
1058
1059 // There is only one case where this is allowed: when we are refining an
1060 // opaque type. In this case, Existing will be an opaque type.
1061 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1062 // We ARE replacing an opaque type!
1063 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1064 return true;
1065 }
1066
1067 // Otherwise, this is an attempt to redefine a type. That's okay if
1068 // the redefinition is identical to the original. This will be so if
1069 // Existing and T point to the same Type object. In this one case we
1070 // allow the equivalent redefinition.
1071 if (Existing == T) return true; // Yes, it's equal.
1072
1073 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer63c34452007-01-05 21:51:07 +00001074 GenerateError("Redefinition of type named '" + Name + "' of type '" +
1075 T->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001076 }
1077
1078 return false;
1079}
1080
1081//===----------------------------------------------------------------------===//
1082// Code for handling upreferences in type names...
1083//
1084
1085// TypeContains - Returns true if Ty directly contains E in it.
1086//
1087static bool TypeContains(const Type *Ty, const Type *E) {
1088 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1089 E) != Ty->subtype_end();
1090}
1091
1092namespace {
1093 struct UpRefRecord {
1094 // NestingLevel - The number of nesting levels that need to be popped before
1095 // this type is resolved.
1096 unsigned NestingLevel;
1097
1098 // LastContainedTy - This is the type at the current binding level for the
1099 // type. Every time we reduce the nesting level, this gets updated.
1100 const Type *LastContainedTy;
1101
1102 // UpRefTy - This is the actual opaque type that the upreference is
1103 // represented with.
1104 OpaqueType *UpRefTy;
1105
1106 UpRefRecord(unsigned NL, OpaqueType *URTy)
1107 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1108 };
1109}
1110
1111// UpRefs - A list of the outstanding upreferences that need to be resolved.
1112static std::vector<UpRefRecord> UpRefs;
1113
1114/// HandleUpRefs - Every time we finish a new layer of types, this function is
1115/// called. It loops through the UpRefs vector, which is a list of the
1116/// currently active types. For each type, if the up reference is contained in
1117/// the newly completed type, we decrement the level count. When the level
1118/// count reaches zero, the upreferenced type is the type that is passed in:
1119/// thus we can complete the cycle.
1120///
1121static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001122 // If Ty isn't abstract, or if there are no up-references in it, then there is
1123 // nothing to resolve here.
1124 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1125
Reid Spencer68a24bd2005-08-27 18:50:39 +00001126 PATypeHolder Ty(ty);
1127 UR_OUT("Type '" << Ty->getDescription() <<
1128 "' newly formed. Resolving upreferences.\n" <<
1129 UpRefs.size() << " upreferences active!\n");
1130
1131 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1132 // to zero), we resolve them all together before we resolve them to Ty. At
1133 // the end of the loop, if there is anything to resolve to Ty, it will be in
1134 // this variable.
1135 OpaqueType *TypeToResolve = 0;
1136
1137 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1138 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1139 << UpRefs[i].second->getDescription() << ") = "
1140 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1141 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1142 // Decrement level of upreference
1143 unsigned Level = --UpRefs[i].NestingLevel;
1144 UpRefs[i].LastContainedTy = Ty;
1145 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1146 if (Level == 0) { // Upreference should be resolved!
1147 if (!TypeToResolve) {
1148 TypeToResolve = UpRefs[i].UpRefTy;
1149 } else {
1150 UR_OUT(" * Resolving upreference for "
1151 << UpRefs[i].second->getDescription() << "\n";
1152 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1153 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1154 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1155 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1156 }
1157 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1158 --i; // Do not skip the next element...
1159 }
1160 }
1161 }
1162
1163 if (TypeToResolve) {
1164 UR_OUT(" * Resolving upreference for "
1165 << UpRefs[i].second->getDescription() << "\n";
1166 std::string OldName = TypeToResolve->getDescription());
1167 TypeToResolve->refineAbstractTypeTo(Ty);
1168 }
1169
1170 return Ty;
1171}
1172
Reid Spencer68a24bd2005-08-27 18:50:39 +00001173//===----------------------------------------------------------------------===//
1174// RunVMAsmParser - Define an interface to this parser
1175//===----------------------------------------------------------------------===//
1176//
Reid Spencer14310612006-12-31 05:40:51 +00001177static Module* RunParser(Module * M);
1178
Reid Spencer68a24bd2005-08-27 18:50:39 +00001179Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1180 set_scan_file(F);
1181
1182 CurFilename = Filename;
1183 return RunParser(new Module(CurFilename));
1184}
1185
1186Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1187 set_scan_string(AsmString);
1188
1189 CurFilename = "from_memory";
1190 if (M == NULL) {
1191 return RunParser(new Module (CurFilename));
1192 } else {
1193 return RunParser(M);
1194 }
1195}
1196
1197
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001198
1199/* Enabling traces. */
1200#ifndef YYDEBUG
1201# define YYDEBUG 0
1202#endif
1203
1204/* Enabling verbose error messages. */
1205#ifdef YYERROR_VERBOSE
1206# undef YYERROR_VERBOSE
1207# define YYERROR_VERBOSE 1
1208#else
1209# define YYERROR_VERBOSE 0
1210#endif
1211
Jeff Cohen361c3ef2007-01-21 19:19:31 +00001212#ifndef YYSTYPE
1213#line 883 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
1214typedef union {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001215 llvm::Module *ModuleVal;
1216 llvm::Function *FunctionVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001217 llvm::BasicBlock *BasicBlockVal;
1218 llvm::TerminatorInst *TermInstVal;
1219 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001220 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001221
Reid Spencera132e042006-12-03 05:46:11 +00001222 const llvm::Type *PrimType;
Reid Spencer14310612006-12-31 05:40:51 +00001223 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencera132e042006-12-03 05:46:11 +00001224 llvm::PATypeHolder *TypeVal;
1225 llvm::Value *ValueVal;
Reid Spencera132e042006-12-03 05:46:11 +00001226 std::vector<llvm::Value*> *ValueList;
Reid Spencer14310612006-12-31 05:40:51 +00001227 llvm::ArgListType *ArgList;
1228 llvm::TypeWithAttrs TypeWithAttrs;
1229 llvm::TypeWithAttrsList *TypeWithAttrsList;
1230 llvm::ValueRefList *ValueRefList;
1231
Reid Spencer68a24bd2005-08-27 18:50:39 +00001232 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001233 std::list<std::pair<llvm::Value*,
1234 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001235 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001236 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001237
1238 llvm::GlobalValue::LinkageTypes Linkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001239 llvm::GlobalValue::VisibilityTypes Visibility;
Reid Spencer14310612006-12-31 05:40:51 +00001240 llvm::FunctionType::ParameterAttributes ParamAttrs;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001241 int64_t SInt64Val;
1242 uint64_t UInt64Val;
1243 int SIntVal;
1244 unsigned UIntVal;
1245 double FPVal;
1246 bool BoolVal;
1247
1248 char *StrVal; // This memory is strdup'd!
Reid Spencer1628cec2006-10-26 06:15:43 +00001249 llvm::ValID ValIDVal; // strdup'd memory maybe!
Reid Spencer68a24bd2005-08-27 18:50:39 +00001250
Reid Spencera132e042006-12-03 05:46:11 +00001251 llvm::Instruction::BinaryOps BinaryOpVal;
1252 llvm::Instruction::TermOps TermOpVal;
1253 llvm::Instruction::MemoryOps MemOpVal;
1254 llvm::Instruction::CastOps CastOpVal;
1255 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencer1628cec2006-10-26 06:15:43 +00001256 llvm::Module::Endianness Endianness;
Reid Spencera132e042006-12-03 05:46:11 +00001257 llvm::ICmpInst::Predicate IPredicate;
1258 llvm::FCmpInst::Predicate FPredicate;
Jeff Cohen361c3ef2007-01-21 19:19:31 +00001259} yystype;
1260/* Line 188 of /usr/local/share/bison/yacc.c. */
1261#line 1262 "llvmAsmParser.tab.c"
1262# define YYSTYPE yystype
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001263# define YYSTYPE_IS_TRIVIAL 1
Reid Spencer68a24bd2005-08-27 18:50:39 +00001264#endif
1265
Jeff Cohen361c3ef2007-01-21 19:19:31 +00001266#ifndef YYLTYPE
1267typedef struct yyltype
1268{
1269 int first_line;
1270 int first_column;
1271 int last_line;
1272 int last_column;
1273} yyltype;
1274# define YYLTYPE yyltype
1275# define YYLTYPE_IS_TRIVIAL 1
1276#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001277
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001278/* Copy the second part of user declarations. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001279
1280
Jeff Cohen361c3ef2007-01-21 19:19:31 +00001281/* Line 213 of /usr/local/share/bison/yacc.c. */
1282#line 1283 "llvmAsmParser.tab.c"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001283
1284#if ! defined (yyoverflow) || YYERROR_VERBOSE
1285
1286/* The parser invokes alloca or malloc; define the necessary symbols. */
1287
Jeff Cohen361c3ef2007-01-21 19:19:31 +00001288# if YYSTACK_USE_ALLOCA
1289# define YYSTACK_ALLOC alloca
1290# else
1291# ifndef YYSTACK_USE_ALLOCA
1292# if defined (alloca) || defined (_ALLOCA_H)
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001293# define YYSTACK_ALLOC alloca
Jeff Cohen361c3ef2007-01-21 19:19:31 +00001294# else
1295# ifdef __GNUC__
1296# define YYSTACK_ALLOC __builtin_alloca
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001297# endif
1298# endif
1299# endif
1300# endif
1301
1302# ifdef YYSTACK_ALLOC
1303 /* Pacify GCC's `empty if-body' warning. */
1304# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001305# else
Jeff Cohen361c3ef2007-01-21 19:19:31 +00001306# if defined (__STDC__) || defined (__cplusplus)
1307# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1308# define YYSIZE_T size_t
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001309# endif
Jeff Cohen361c3ef2007-01-21 19:19:31 +00001310# define YYSTACK_ALLOC malloc
1311# define YYSTACK_FREE free
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001312# endif
1313#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
1314
1315
1316#if (! defined (yyoverflow) \
1317 && (! defined (__cplusplus) \
Jeff Cohen361c3ef2007-01-21 19:19:31 +00001318 || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001319
1320/* A type that is properly aligned for any stack member. */
1321union yyalloc
1322{
Jeff Cohen361c3ef2007-01-21 19:19:31 +00001323 short yyss;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001324 YYSTYPE yyvs;
1325 };
1326
1327/* The size of the maximum gap between one aligned stack and the next. */
Jeff Cohen361c3ef2007-01-21 19:19:31 +00001328# define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001329
1330/* The size of an array large to enough to hold all stacks, each with
1331 N elements. */
1332# define YYSTACK_BYTES(N) \
Jeff Cohen361c3ef2007-01-21 19:19:31 +00001333 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
1334 + YYSTACK_GAP_MAX)
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001335
1336/* Copy COUNT objects from FROM to TO. The source and destination do
1337 not overlap. */
1338# ifndef YYCOPY
Jeff Cohen361c3ef2007-01-21 19:19:31 +00001339# if 1 < __GNUC__
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001340# define YYCOPY(To, From, Count) \
1341 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1342# else
1343# define YYCOPY(To, From, Count) \
1344 do \
1345 { \
Jeff Cohen361c3ef2007-01-21 19:19:31 +00001346 register YYSIZE_T yyi; \
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001347 for (yyi = 0; yyi < (Count); yyi++) \
Jeff Cohen361c3ef2007-01-21 19:19:31 +00001348 (To)[yyi] = (From)[yyi]; \
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001349 } \
1350 while (0)
1351# endif
1352# endif
1353
1354/* Relocate STACK from its old location to the new one. The
1355 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1356 elements in the stack, and YYPTR gives the new location of the
1357 stack. Advance YYPTR to a properly aligned location for the next
1358 stack. */
1359# define YYSTACK_RELOCATE(Stack) \
1360 do \
1361 { \
1362 YYSIZE_T yynewbytes; \
1363 YYCOPY (&yyptr->Stack, Stack, yysize); \
1364 Stack = &yyptr->Stack; \
Jeff Cohen361c3ef2007-01-21 19:19:31 +00001365 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX; \
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001366 yyptr += yynewbytes / sizeof (*yyptr); \
1367 } \
1368 while (0)
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001369
1370#endif
1371
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001372#if defined (__STDC__) || defined (__cplusplus)
1373 typedef signed char yysigned_char;
Reid Spencer6f407902007-01-13 05:00:46 +00001374#else
Jeff Cohen361c3ef2007-01-21 19:19:31 +00001375 typedef short yysigned_char;
Reid Spencer6f407902007-01-13 05:00:46 +00001376#endif
1377
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001378/* YYFINAL -- State number of the termination state. */
1379#define YYFINAL 36
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001380#define YYLAST 1357
1381
1382/* YYNTOKENS -- Number of terminals. */
1383#define YYNTOKENS 147
1384/* YYNNTS -- Number of nonterminals. */
1385#define YYNNTS 79
1386/* YYNRULES -- Number of rules. */
1387#define YYNRULES 285
1388/* YYNRULES -- Number of states. */
1389#define YYNSTATES 569
1390
1391/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1392#define YYUNDEFTOK 2
1393#define YYMAXUTOK 387
1394
Jeff Cohen361c3ef2007-01-21 19:19:31 +00001395#define YYTRANSLATE(X) \
1396 ((unsigned)(X) <= YYMAXUTOK ? yytranslate[X] : YYUNDEFTOK)
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001397
1398/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1399static const unsigned char yytranslate[] =
1400{
1401 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1402 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1403 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1404 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1405 137, 138, 135, 2, 134, 2, 2, 2, 2, 2,
1406 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1407 142, 133, 143, 2, 2, 2, 2, 2, 2, 2,
1408 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1409 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1410 2, 139, 136, 141, 2, 2, 2, 2, 2, 146,
1411 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1412 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1413 140, 2, 2, 144, 2, 145, 2, 2, 2, 2,
1414 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1415 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1416 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1417 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1418 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1419 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1420 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1421 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1422 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1423 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1424 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1425 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1426 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1427 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1428 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1429 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1430 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1431 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1432 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1433 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1434 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1435 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1436 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
1437 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
1438 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1439 125, 126, 127, 128, 129, 130, 131, 132
1440};
1441
1442#if YYDEBUG
1443/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1444 YYRHS. */
Jeff Cohen361c3ef2007-01-21 19:19:31 +00001445static const unsigned short yyprhs[] =
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001446{
1447 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1448 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1449 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1450 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
1451 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
1452 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
1453 119, 122, 123, 125, 127, 129, 131, 133, 135, 137,
1454 139, 140, 142, 143, 145, 147, 148, 150, 152, 154,
1455 156, 157, 159, 161, 163, 165, 167, 169, 172, 174,
1456 176, 177, 180, 182, 184, 185, 188, 189, 192, 193,
1457 197, 200, 201, 203, 204, 208, 210, 213, 215, 217,
1458 219, 221, 223, 225, 228, 230, 233, 239, 245, 251,
1459 257, 261, 264, 270, 275, 278, 280, 282, 284, 288,
1460 290, 294, 296, 297, 299, 303, 308, 312, 316, 321,
1461 326, 330, 337, 343, 346, 349, 352, 355, 358, 361,
1462 364, 367, 370, 373, 380, 386, 395, 402, 409, 417,
1463 425, 432, 439, 448, 457, 461, 463, 465, 467, 469,
1464 470, 472, 475, 476, 480, 481, 485, 489, 491, 495,
1465 499, 500, 507, 508, 516, 517, 525, 528, 532, 534,
1466 536, 538, 542, 546, 550, 554, 558, 562, 564, 565,
1467 567, 569, 571, 572, 578, 582, 584, 588, 590, 591,
1468 601, 603, 605, 610, 612, 614, 617, 621, 622, 624,
1469 626, 628, 630, 632, 634, 636, 638, 640, 644, 646,
1470 652, 654, 656, 658, 660, 663, 666, 669, 673, 676,
1471 677, 679, 682, 685, 689, 699, 709, 718, 733, 735,
1472 737, 744, 750, 753, 760, 768, 772, 778, 779, 780,
1473 784, 787, 789, 795, 801, 808, 815, 820, 825, 832,
1474 837, 842, 849, 856, 859, 868, 870, 872, 873, 877,
1475 884, 888, 895, 898, 903, 910
1476};
1477
1478/* YYRHS -- A `-1'-separated list of the rules' RHS. */
Jeff Cohen361c3ef2007-01-21 19:19:31 +00001479static const short yyrhs[] =
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001480{
1481 185, 0, -1, 5, -1, 6, -1, 69, -1, 70,
1482 -1, 71, -1, 72, -1, 73, -1, 74, -1, 75,
1483 -1, 76, -1, 77, -1, 78, -1, 79, -1, 80,
1484 -1, 109, -1, 110, -1, 111, -1, 112, -1, 113,
1485 -1, 114, -1, 115, -1, 116, -1, 117, -1, 118,
1486 -1, 119, -1, 120, -1, 123, -1, 124, -1, 125,
1487 -1, 83, -1, 84, -1, 85, -1, 86, -1, 87,
1488 -1, 88, -1, 89, -1, 90, -1, 91, -1, 92,
1489 -1, 93, -1, 94, -1, 95, -1, 96, -1, 97,
1490 -1, 98, -1, 99, -1, 100, -1, 101, -1, 102,
1491 -1, 89, -1, 90, -1, 91, -1, 92, -1, 19,
1492 -1, 20, -1, 9, -1, 10, -1, 11, -1, 198,
1493 133, -1, -1, 33, -1, 35, -1, 34, -1, 36,
1494 -1, 38, -1, 37, -1, 39, -1, 41, -1, -1,
1495 132, -1, -1, 37, -1, 39, -1, -1, 33, -1,
1496 34, -1, 35, -1, 38, -1, -1, 56, -1, 57,
1497 -1, 58, -1, 59, -1, 60, -1, 61, -1, 55,
1498 4, -1, 110, -1, 111, -1, -1, 165, 164, -1,
1499 130, -1, 164, -1, -1, 167, 166, -1, -1, 48,
1500 4, -1, -1, 134, 48, 4, -1, 27, 16, -1,
1501 -1, 170, -1, -1, 134, 173, 172, -1, 170, -1,
1502 48, 4, -1, 9, -1, 10, -1, 11, -1, 12,
1503 -1, 40, -1, 174, -1, 175, 135, -1, 210, -1,
1504 136, 4, -1, 175, 137, 179, 138, 167, -1, 8,
1505 137, 179, 138, 167, -1, 139, 4, 140, 175, 141,
1506 -1, 142, 4, 140, 175, 143, -1, 144, 180, 145,
1507 -1, 144, 145, -1, 142, 144, 180, 145, 143, -1,
1508 142, 144, 145, 143, -1, 175, 165, -1, 175, -1,
1509 8, -1, 176, -1, 178, 134, 176, -1, 178, -1,
1510 178, 134, 30, -1, 30, -1, -1, 175, -1, 180,
1511 134, 175, -1, 175, 139, 183, 141, -1, 175, 139,
1512 141, -1, 175, 146, 16, -1, 175, 142, 183, 143,
1513 -1, 175, 144, 183, 145, -1, 175, 144, 145, -1,
1514 175, 142, 144, 183, 145, 143, -1, 175, 142, 144,
1515 145, 143, -1, 175, 31, -1, 175, 32, -1, 175,
1516 210, -1, 175, 182, -1, 175, 18, -1, 155, 3,
1517 -1, 155, 4, -1, 9, 19, -1, 9, 20, -1,
1518 156, 7, -1, 151, 137, 181, 29, 175, 138, -1,
1519 108, 137, 181, 221, 138, -1, 122, 137, 181, 134,
1520 181, 134, 181, 138, -1, 149, 137, 181, 134, 181,
1521 138, -1, 150, 137, 181, 134, 181, 138, -1, 81,
1522 153, 137, 181, 134, 181, 138, -1, 82, 154, 137,
1523 181, 134, 181, 138, -1, 152, 137, 181, 134, 181,
1524 138, -1, 127, 137, 181, 134, 181, 138, -1, 128,
1525 137, 181, 134, 181, 134, 181, 138, -1, 129, 137,
1526 181, 134, 181, 134, 181, 138, -1, 183, 134, 181,
1527 -1, 181, -1, 25, -1, 26, -1, 186, -1, -1,
1528 187, -1, 186, 187, -1, -1, 24, 188, 206, -1,
1529 -1, 23, 189, 207, -1, 53, 52, 193, -1, 17,
1530 -1, 157, 13, 175, -1, 157, 13, 8, -1, -1,
1531 157, 160, 184, 181, 190, 172, -1, -1, 157, 158,
1532 160, 184, 181, 191, 172, -1, -1, 157, 159, 160,
1533 184, 175, 192, 172, -1, 42, 195, -1, 49, 133,
1534 196, -1, 16, -1, 47, -1, 46, -1, 44, 133,
1535 194, -1, 45, 133, 4, -1, 43, 133, 16, -1,
1536 62, 133, 16, -1, 139, 197, 141, -1, 197, 134,
1537 16, -1, 16, -1, -1, 14, -1, 16, -1, 198,
1538 -1, -1, 200, 134, 175, 165, 199, -1, 175, 165,
1539 199, -1, 200, -1, 200, 134, 30, -1, 30, -1,
1540 -1, 163, 177, 198, 137, 201, 138, 167, 171, 168,
1541 -1, 21, -1, 144, -1, 162, 160, 202, 203, -1,
1542 22, -1, 145, -1, 213, 205, -1, 161, 160, 202,
1543 -1, -1, 54, -1, 3, -1, 4, -1, 7, -1,
1544 19, -1, 20, -1, 31, -1, 32, -1, 18, -1,
1545 142, 183, 143, -1, 182, -1, 52, 208, 16, 134,
1546 16, -1, 148, -1, 198, -1, 210, -1, 209, -1,
1547 175, 211, -1, 213, 214, -1, 204, 214, -1, 215,
1548 157, 216, -1, 215, 218, -1, -1, 15, -1, 63,
1549 212, -1, 63, 8, -1, 64, 12, 211, -1, 64,
1550 9, 211, 134, 12, 211, 134, 12, 211, -1, 65,
1551 155, 211, 134, 12, 211, 139, 217, 141, -1, 65,
1552 155, 211, 134, 12, 211, 139, 141, -1, 66, 163,
1553 177, 211, 137, 220, 138, 167, 29, 12, 211, 67,
1554 12, 211, -1, 67, -1, 68, -1, 217, 155, 209,
1555 134, 12, 211, -1, 155, 209, 134, 12, 211, -1,
1556 157, 223, -1, 175, 139, 211, 134, 211, 141, -1,
1557 219, 134, 139, 211, 134, 211, 141, -1, 175, 211,
1558 165, -1, 220, 134, 175, 211, 165, -1, -1, -1,
1559 221, 134, 212, -1, 51, 50, -1, 50, -1, 149,
1560 175, 211, 134, 211, -1, 150, 175, 211, 134, 211,
1561 -1, 81, 153, 175, 211, 134, 211, -1, 82, 154,
1562 175, 211, 134, 211, -1, 152, 212, 134, 212, -1,
1563 151, 212, 29, 175, -1, 122, 212, 134, 212, 134,
1564 212, -1, 126, 212, 134, 175, -1, 127, 212, 134,
1565 212, -1, 128, 212, 134, 212, 134, 212, -1, 129,
1566 212, 134, 212, 134, 212, -1, 121, 219, -1, 222,
1567 163, 177, 211, 137, 220, 138, 167, -1, 225, -1,
1568 28, -1, -1, 103, 175, 169, -1, 103, 175, 134,
1569 9, 211, 169, -1, 104, 175, 169, -1, 104, 175,
1570 134, 9, 211, 169, -1, 105, 212, -1, 224, 106,
1571 175, 211, -1, 224, 107, 212, 134, 175, 211, -1,
1572 108, 175, 211, 221, -1
1573};
1574
1575/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
Jeff Cohen361c3ef2007-01-21 19:19:31 +00001576static const unsigned short yyrline[] =
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001577{
1578 0, 1031, 1031, 1032, 1042, 1042, 1042, 1042, 1042, 1042,
1579 1042, 1042, 1042, 1043, 1043, 1043, 1044, 1044, 1044, 1044,
Jeff Cohen361c3ef2007-01-21 19:19:31 +00001580 1044, 1044, 1044, 1045, 1045, 1045, 1045, 1045, 1046, 1046,
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001581 1046, 1048, 1048, 1049, 1049, 1050, 1050, 1051, 1051, 1052,
1582 1052, 1056, 1056, 1057, 1057, 1058, 1058, 1059, 1059, 1060,
1583 1060, 1061, 1061, 1062, 1062, 1063, 1064, 1069, 1070, 1070,
1584 1073, 1077, 1083, 1084, 1085, 1086, 1087, 1091, 1092, 1093,
1585 1097, 1098, 1102, 1103, 1104, 1108, 1109, 1110, 1111, 1112,
Jeff Cohen361c3ef2007-01-21 19:19:31 +00001586 1115, 1115, 1116, 1117, 1118, 1119, 1120, 1121, 1129, 1130,
1587 1133, 1134, 1139, 1140, 1143, 1144, 1151, 1151, 1158, 1158,
1588 1167, 1175, 1175, 1181, 1181, 1183, 1188, 1201, 1201, 1201,
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001589 1201, 1204, 1208, 1212, 1219, 1224, 1232, 1250, 1268, 1273,
1590 1285, 1295, 1299, 1309, 1316, 1323, 1330, 1335, 1340, 1347,
1591 1348, 1355, 1362, 1370, 1375, 1386, 1414, 1430, 1459, 1487,
1592 1512, 1531, 1556, 1575, 1587, 1594, 1657, 1667, 1677, 1683,
1593 1689, 1694, 1699, 1707, 1719, 1740, 1748, 1754, 1765, 1770,
1594 1775, 1784, 1790, 1796, 1805, 1809, 1817, 1817, 1828, 1833,
1595 1841, 1842, 1846, 1846, 1850, 1850, 1853, 1856, 1868, 1892,
1596 1903, 1903, 1912, 1912, 1920, 1920, 1930, 1933, 1939, 1952,
1597 1953, 1955, 1959, 1968, 1972, 1977, 1979, 1984, 1989, 1998,
1598 1998, 1999, 1999, 2001, 2011, 2022, 2026, 2035, 2044, 2049,
1599 2155, 2155, 2157, 2166, 2166, 2168, 2173, 2185, 2189, 2194,
1600 2198, 2202, 2206, 2210, 2214, 2218, 2222, 2226, 2251, 2255,
1601 2269, 2273, 2279, 2279, 2285, 2294, 2298, 2307, 2318, 2327,
1602 2339, 2352, 2356, 2360, 2365, 2375, 2394, 2403, 2470, 2474,
1603 2481, 2492, 2505, 2514, 2525, 2535, 2543, 2551, 2554, 2555,
1604 2562, 2566, 2571, 2592, 2609, 2622, 2635, 2644, 2656, 2664,
1605 2671, 2677, 2683, 2689, 2704, 2767, 2772, 2776, 2783, 2790,
1606 2798, 2805, 2813, 2821, 2835, 2852
1607};
1608#endif
1609
Jeff Cohen361c3ef2007-01-21 19:19:31 +00001610#if YYDEBUG || YYERROR_VERBOSE
1611/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001612 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1613static const char *const yytname[] =
1614{
Jeff Cohen361c3ef2007-01-21 19:19:31 +00001615 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL",
1616 "UINTVAL", "FPVAL", "VOID", "INTTYPE", "FLOAT", "DOUBLE", "LABEL",
1617 "TYPE", "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION",
1618 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
1619 "DECLARE", "DEFINE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO",
1620 "DOTDOTDOT", "NULL_TOK", "UNDEF", "INTERNAL", "LINKONCE", "WEAK",
1621 "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
1622 "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE",
1623 "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE",
1624 "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK",
1625 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
1626 "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE", "ADD", "SUB",
1627 "MUL", "UDIV", "SDIV", "FDIV", "UREM", "SREM", "FREM", "AND", "OR",
1628 "XOR", "ICMP", "FCMP", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT",
1629 "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD",
1630 "UNO", "UEQ", "UNE", "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE",
1631 "GETELEMENTPTR", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT", "BITCAST",
1632 "UITOFP", "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR", "PTRTOINT",
1633 "PHI_TOK", "SELECT", "SHL", "LSHR", "ASHR", "VAARG", "EXTRACTELEMENT",
1634 "INSERTELEMENT", "SHUFFLEVECTOR", "NORETURN", "DEFAULT", "HIDDEN",
1635 "'='", "','", "'*'", "'\\\\'", "'('", "')'", "'['", "'x'", "']'", "'<'",
1636 "'>'", "'{'", "'}'", "'c'", "$accept", "INTVAL", "ArithmeticOps",
1637 "LogicalOps", "CastOps", "ShiftOps", "IPredicates", "FPredicates",
1638 "IntType", "FPType", "OptAssign", "GVInternalLinkage",
1639 "GVExternalLinkage", "GVVisibilityStyle", "FunctionDeclareLinkage",
1640 "FunctionDefineLinkage", "OptCallingConv", "ParamAttr", "OptParamAttrs",
1641 "FuncAttr", "OptFuncAttrs", "OptAlign", "OptCAlign", "SectionString",
1642 "OptSection", "GlobalVarAttributes", "GlobalVarAttribute", "PrimType",
1643 "Types", "ArgType", "ResultTypes", "ArgTypeList", "ArgTypeListI",
1644 "TypeListI", "ConstVal", "ConstExpr", "ConstVector", "GlobalType",
1645 "Module", "DefinitionList", "Definition", "@1", "@2", "@3", "@4", "@5",
1646 "AsmBlock", "BigOrLittle", "TargetDefinition", "LibrariesDefinition",
1647 "LibList", "Name", "OptName", "ArgListH", "ArgList", "FunctionHeaderH",
1648 "BEGIN", "FunctionHeader", "END", "Function", "FunctionProto",
1649 "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef",
1650 "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList",
1651 "BBTerminatorInst", "JumpTable", "Inst", "PHIList", "ValueRefList",
1652 "IndexList", "OptTailCall", "InstVal", "OptVolatile", "MemoryInst", 0
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001653};
1654#endif
1655
1656# ifdef YYPRINT
1657/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1658 token YYLEX-NUM. */
Jeff Cohen361c3ef2007-01-21 19:19:31 +00001659static const unsigned short yytoknum[] =
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001660{
1661 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1662 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1663 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1664 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1665 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1666 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1667 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1668 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1669 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1670 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1671 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
1672 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
1673 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
1674 385, 386, 387, 61, 44, 42, 92, 40, 41, 91,
1675 120, 93, 60, 62, 123, 125, 99
1676};
1677# endif
1678
1679/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1680static const unsigned char yyr1[] =
1681{
1682 0, 147, 148, 148, 149, 149, 149, 149, 149, 149,
1683 149, 149, 149, 150, 150, 150, 151, 151, 151, 151,
1684 151, 151, 151, 151, 151, 151, 151, 151, 152, 152,
1685 152, 153, 153, 153, 153, 153, 153, 153, 153, 153,
1686 153, 154, 154, 154, 154, 154, 154, 154, 154, 154,
1687 154, 154, 154, 154, 154, 154, 154, 155, 156, 156,
1688 157, 157, 158, 158, 158, 158, 158, 159, 159, 159,
1689 160, 160, 161, 161, 161, 162, 162, 162, 162, 162,
1690 163, 163, 163, 163, 163, 163, 163, 163, 164, 164,
1691 165, 165, 166, 166, 167, 167, 168, 168, 169, 169,
1692 170, 171, 171, 172, 172, 173, 173, 174, 174, 174,
1693 174, 175, 175, 175, 175, 175, 175, 175, 175, 175,
1694 175, 175, 175, 175, 176, 177, 177, 178, 178, 179,
1695 179, 179, 179, 180, 180, 181, 181, 181, 181, 181,
1696 181, 181, 181, 181, 181, 181, 181, 181, 181, 181,
1697 181, 181, 181, 182, 182, 182, 182, 182, 182, 182,
1698 182, 182, 182, 182, 183, 183, 184, 184, 185, 185,
1699 186, 186, 188, 187, 189, 187, 187, 187, 187, 187,
1700 190, 187, 191, 187, 192, 187, 187, 187, 193, 194,
1701 194, 195, 195, 195, 195, 196, 197, 197, 197, 198,
1702 198, 199, 199, 200, 200, 201, 201, 201, 201, 202,
1703 203, 203, 204, 205, 205, 206, 207, 208, 208, 209,
1704 209, 209, 209, 209, 209, 209, 209, 209, 209, 209,
1705 210, 210, 211, 211, 212, 213, 213, 214, 215, 215,
1706 215, 216, 216, 216, 216, 216, 216, 216, 216, 216,
1707 217, 217, 218, 219, 219, 220, 220, 220, 221, 221,
1708 222, 222, 223, 223, 223, 223, 223, 223, 223, 223,
1709 223, 223, 223, 223, 223, 223, 224, 224, 225, 225,
1710 225, 225, 225, 225, 225, 225
1711};
1712
1713/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
1714static const unsigned char yyr2[] =
1715{
1716 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1717 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1718 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1719 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1720 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1721 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1722 2, 0, 1, 1, 1, 1, 1, 1, 1, 1,
1723 0, 1, 0, 1, 1, 0, 1, 1, 1, 1,
1724 0, 1, 1, 1, 1, 1, 1, 2, 1, 1,
1725 0, 2, 1, 1, 0, 2, 0, 2, 0, 3,
1726 2, 0, 1, 0, 3, 1, 2, 1, 1, 1,
1727 1, 1, 1, 2, 1, 2, 5, 5, 5, 5,
1728 3, 2, 5, 4, 2, 1, 1, 1, 3, 1,
1729 3, 1, 0, 1, 3, 4, 3, 3, 4, 4,
1730 3, 6, 5, 2, 2, 2, 2, 2, 2, 2,
1731 2, 2, 2, 6, 5, 8, 6, 6, 7, 7,
1732 6, 6, 8, 8, 3, 1, 1, 1, 1, 0,
1733 1, 2, 0, 3, 0, 3, 3, 1, 3, 3,
1734 0, 6, 0, 7, 0, 7, 2, 3, 1, 1,
1735 1, 3, 3, 3, 3, 3, 3, 1, 0, 1,
1736 1, 1, 0, 5, 3, 1, 3, 1, 0, 9,
1737 1, 1, 4, 1, 1, 2, 3, 0, 1, 1,
1738 1, 1, 1, 1, 1, 1, 1, 3, 1, 5,
1739 1, 1, 1, 1, 2, 2, 2, 3, 2, 0,
1740 1, 2, 2, 3, 9, 9, 8, 14, 1, 1,
1741 6, 5, 2, 6, 7, 3, 5, 0, 0, 3,
1742 2, 1, 5, 5, 6, 6, 4, 4, 6, 4,
1743 4, 6, 6, 2, 8, 1, 1, 0, 3, 6,
1744 3, 6, 2, 4, 6, 4
1745};
1746
1747/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
1748 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
1749 means the default is an error. */
Jeff Cohen361c3ef2007-01-21 19:19:31 +00001750static const unsigned short yydefact[] =
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001751{
1752 61, 199, 200, 177, 174, 172, 0, 0, 0, 70,
1753 0, 61, 170, 0, 72, 75, 0, 0, 0, 0,
1754 186, 0, 0, 0, 62, 64, 63, 65, 67, 66,
1755 68, 69, 71, 70, 70, 0, 1, 171, 60, 73,
1756 74, 70, 175, 76, 77, 78, 79, 70, 239, 173,
1757 239, 0, 0, 0, 0, 198, 187, 188, 176, 2,
1758 3, 179, 107, 108, 109, 110, 111, 0, 0, 0,
1759 0, 230, 112, 178, 231, 114, 0, 0, 166, 167,
1760 0, 80, 80, 240, 236, 61, 213, 214, 215, 235,
1761 193, 190, 189, 191, 192, 194, 197, 0, 132, 115,
1762 0, 0, 0, 0, 121, 133, 0, 113, 132, 0,
1763 0, 107, 108, 109, 0, 0, 0, 180, 0, 81,
1764 82, 83, 84, 85, 86, 0, 216, 0, 277, 238,
1765 0, 195, 131, 90, 127, 129, 0, 0, 0, 0,
1766 0, 0, 120, 0, 182, 184, 150, 151, 148, 149,
1767 152, 147, 143, 144, 4, 5, 6, 7, 8, 9,
1768 10, 11, 12, 13, 14, 15, 0, 0, 0, 16,
1769 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1770 27, 0, 28, 29, 30, 0, 0, 0, 0, 0,
1771 0, 0, 0, 0, 0, 0, 146, 145, 103, 87,
1772 126, 125, 0, 210, 211, 212, 276, 261, 0, 0,
1773 0, 0, 80, 248, 249, 0, 0, 0, 0, 0,
1774 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1775 0, 237, 80, 252, 0, 275, 196, 124, 0, 94,
1776 0, 0, 123, 0, 134, 94, 103, 103, 31, 32,
1777 33, 34, 35, 36, 37, 38, 39, 40, 0, 55,
1778 56, 51, 52, 53, 54, 41, 42, 43, 44, 45,
1779 46, 47, 48, 49, 50, 0, 0, 0, 0, 0,
1780 0, 136, 165, 0, 0, 0, 140, 0, 137, 0,
1781 0, 0, 0, 0, 181, 0, 260, 242, 0, 241,
1782 0, 0, 57, 0, 0, 0, 0, 98, 98, 282,
1783 0, 0, 273, 0, 0, 0, 0, 0, 0, 0,
1784 0, 0, 0, 0, 0, 88, 89, 91, 130, 128,
1785 117, 118, 119, 122, 116, 183, 185, 0, 0, 258,
1786 0, 0, 0, 0, 0, 135, 121, 133, 0, 138,
1787 139, 0, 0, 0, 0, 0, 0, 105, 103, 208,
1788 219, 220, 221, 226, 222, 223, 224, 225, 217, 0,
1789 228, 233, 232, 234, 0, 243, 0, 0, 0, 0,
1790 0, 278, 0, 280, 258, 0, 0, 0, 0, 0,
1791 0, 0, 0, 0, 0, 0, 0, 0, 0, 92,
1792 93, 95, 0, 0, 0, 0, 0, 0, 0, 164,
1793 142, 0, 0, 0, 0, 0, 100, 106, 104, 207,
1794 90, 205, 0, 218, 0, 0, 0, 0, 0, 0,
1795 0, 0, 0, 0, 285, 0, 0, 0, 269, 270,
1796 0, 0, 0, 0, 267, 266, 0, 283, 0, 0,
1797 0, 0, 154, 0, 0, 0, 0, 141, 0, 0,
1798 0, 0, 202, 0, 94, 0, 227, 0, 0, 257,
1799 0, 0, 98, 99, 98, 0, 0, 0, 0, 0,
1800 262, 263, 257, 0, 0, 0, 259, 0, 161, 0,
1801 0, 156, 157, 153, 160, 201, 204, 206, 90, 101,
1802 0, 0, 0, 0, 0, 264, 265, 0, 279, 281,
1803 0, 0, 268, 271, 272, 0, 284, 158, 159, 0,
1804 0, 0, 202, 102, 96, 229, 0, 0, 90, 0,
1805 94, 253, 0, 94, 155, 162, 163, 203, 0, 209,
1806 0, 246, 0, 0, 255, 0, 0, 254, 274, 97,
1807 244, 0, 245, 0, 90, 0, 0, 0, 256, 0,
1808 0, 0, 0, 251, 0, 0, 250, 0, 247
1809};
1810
1811/* YYDEFGOTO[NTERM-NUM]. */
Jeff Cohen361c3ef2007-01-21 19:19:31 +00001812static const short yydefgoto[] =
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001813{
1814 -1, 71, 192, 193, 194, 195, 258, 275, 114, 115,
1815 9, 33, 34, 35, 41, 47, 125, 327, 237, 401,
1816 330, 539, 381, 357, 524, 294, 358, 72, 116, 134,
1817 202, 135, 136, 106, 282, 370, 283, 80, 10, 11,
1818 12, 15, 14, 198, 246, 247, 58, 93, 20, 56,
1819 97, 74, 496, 421, 422, 126, 205, 48, 88, 49,
1820 42, 424, 371, 75, 373, 299, 50, 84, 85, 231,
1821 543, 129, 312, 504, 404, 232, 233, 234, 235
1822};
1823
1824/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
1825 STATE-NUM. */
1826#define YYPACT_NINF -413
Jeff Cohen361c3ef2007-01-21 19:19:31 +00001827static const short yypact[] =
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001828{
1829 401, -413, -413, -413, -413, -413, 110, -107, 30, 67,
1830 77, 527, -413, -43, 2, 238, -16, 8, 47, 84,
1831 -413, -4, 132, 791, -413, -413, -413, -413, -413, -413,
1832 -413, -413, -413, 91, 91, 149, -413, -413, -413, -413,
1833 -413, 91, -413, -413, -413, -413, -413, 91, 147, -413,
1834 20, 210, 208, 280, 226, 273, -413, -413, -413, -413,
1835 -413, 160, -413, -413, -413, -413, -413, 295, 299, 3,
1836 7, -413, -413, 140, -413, -413, 149, 149, -413, -413,
1837 954, 192, 192, -413, -413, 184, -413, -413, -413, -413,
1838 -413, -413, -413, -413, -413, -413, -413, -65, 549, -413,
1839 167, 171, 22, 160, -413, 140, -81, -413, 549, 954,
1840 1045, 95, 311, 312, 284, 313, 602, -413, 317, -413,
1841 -413, -413, -413, -413, -413, 1125, -413, -7, 1228, -413,
1842 306, -413, -413, 140, -413, 191, 193, 1045, 1045, 186,
1843 -64, 1045, -413, 194, -413, 140, -413, -413, -413, -413,
1844 -413, -413, -413, -413, -413, -413, -413, -413, -413, -413,
1845 -413, -413, -413, -413, -413, -413, 251, 501, 207, -413,
1846 -413, -413, -413, -413, -413, -413, -413, -413, -413, -413,
1847 -413, 209, -413, -413, -413, 214, 215, 216, 49, 1138,
1848 120, 314, 219, 222, 224, 225, -413, -413, 230, -413,
1849 160, 140, 184, -413, -413, -413, -413, -413, 315, 1185,
1850 175, 357, 192, -413, -413, 251, 501, 1045, 1045, 1045,
1851 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045,
1852 1045, -413, 192, -413, 195, -413, -413, 203, 693, -413,
1853 126, 46, -413, 228, 140, -413, 230, 230, -413, -413,
1854 -413, -413, -413, -413, -413, -413, -413, -413, 231, -413,
1855 -413, -413, -413, -413, -413, -413, -413, -413, -413, -413,
1856 -413, -413, -413, -413, -413, 235, 954, 954, 954, 954,
1857 954, -413, -413, 29, 500, -24, -413, -27, -413, 954,
1858 954, 954, 954, 39, -413, 241, -413, 160, 746, -413,
1859 873, 873, -413, 873, 1125, 1045, 1045, 123, 159, -413,
1860 746, 146, 233, 245, 248, 249, 250, 252, 746, 746,
1861 356, 253, 1125, 1045, 1045, -413, -413, -413, -413, -413,
1862 -18, -413, -413, -413, -18, -413, -413, 954, 954, -413,
1863 254, 255, 256, 259, 954, -413, 262, 602, -12, -413,
1864 -413, 265, 274, 367, 275, 391, 407, -413, 230, 774,
1865 -413, -413, -413, -413, -413, -413, -413, -413, 358, 954,
1866 -413, -413, -413, -413, 282, -413, 285, 873, 746, 746,
1867 35, -413, 43, -413, -413, 873, 281, 1045, 1045, 1045,
1868 1045, 1045, 289, 292, 1045, 1045, 873, 746, 293, -413,
1869 -413, -413, 294, 301, -25, 954, 954, 954, 954, -413,
1870 -413, 271, 954, 954, 1045, 954, -413, -413, -413, -413,
1871 140, 302, 303, -413, 417, 25, 427, 428, 305, 310,
1872 318, 873, 441, 873, 319, 322, 873, 323, 140, -413,
1873 324, 325, 873, 873, 140, -413, 309, -413, 1045, 954,
1874 954, 1045, -413, 326, 328, 327, 335, -413, 332, 333,
1875 131, 336, 34, 1028, -413, 339, -413, 873, 873, 1045,
1876 873, 873, 341, -413, 341, 873, 342, 1045, 1045, 1045,
1877 -413, -413, 1045, 746, 340, 345, -413, 954, -413, 954,
1878 954, -413, -413, -413, -413, -413, -413, -413, 140, 10,
1879 431, 343, 346, 746, 63, -413, -413, 400, -413, -413,
1880 338, 873, -413, -413, -413, 144, -413, -413, -413, 351,
1881 352, 354, 34, -413, 403, -413, 472, -3, -413, 1045,
1882 -413, -413, 355, -413, -413, -413, -413, -413, 489, -413,
1883 873, -413, 1000, 15, 203, 746, 66, -413, -18, -413,
1884 -413, 361, -413, 1000, -413, 485, 486, 368, 203, 873,
1885 873, 491, 434, -413, 873, 492, -413, 873, -413
1886};
1887
1888/* YYPGOTO[NTERM-NUM]. */
Jeff Cohen361c3ef2007-01-21 19:19:31 +00001889static const short yypgoto[] =
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001890{
1891 -413, -413, 379, 385, 389, 390, 304, 307, -210, -413,
1892 439, -413, -413, 145, -413, -413, -192, -305, -412, -413,
1893 -235, -413, -303, 26, -413, -201, -413, -413, -14, 288,
1894 -255, -413, 420, 429, -58, -112, -187, 239, -413, -413,
1895 518, -413, -413, -413, -413, -413, -413, -413, -413, -413,
1896 -413, 0, 11, -413, -413, 448, -413, -413, -413, -413,
1897 -413, -413, -403, -73, 103, -151, -413, 482, -413, -413,
1898 -413, -413, -413, 53, 153, -413, -413, -413, -413
1899};
1900
1901/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
1902 positive, shift that token. If negative, reduce the rule which
1903 number is the opposite. If zero, do what YYDEFACT says.
Jeff Cohen361c3ef2007-01-21 19:19:31 +00001904 If YYTABLE_NINF, parse error. */
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001905#define YYTABLE_NINF -170
Jeff Cohen361c3ef2007-01-21 19:19:31 +00001906static const short yytable[] =
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00001907{
1908 13, 303, 285, 287, 196, 383, 302, 101, 462, 73,
1909 334, 13, 59, 60, 203, 103, 62, 63, 64, 65,
1910 304, 1, 117, 2, 302, 400, 21, 59, 60, 400,
1911 103, 62, 63, 64, 65, 83, 1, 355, 2, 39,
1912 322, 40, 86, 197, 431, 335, 336, 66, 1, 377,
1913 2, 144, 433, 141, 59, 60, 105, 103, 111, 112,
1914 113, 65, 66, 1, 142, 2, 355, 396, 309, 130,
1915 141, 313, 314, 315, 316, 317, 131, 36, 320, 321,
1916 23, 243, 22, 432, 133, 13, 522, 356, 105, 66,
1917 38, 432, 325, 326, 133, 555, 145, 348, -57, -57,
1918 24, 25, 26, 27, 28, 29, 30, 344, 31, 451,
1919 344, 201, 399, 452, 146, 147, 544, 51, 350, 349,
1920 325, 326, 344, 240, 241, 59, 60, 244, 103, 111,
1921 112, 113, 65, 411, 1, 55, 2, 204, 541, 551,
1922 399, 52, 558, 67, 325, 326, 68, 102, 57, 69,
1923 557, 70, 104, 16, 17, 18, 552, 418, 67, 344,
1924 66, 68, 83, 344, 69, 87, 70, 139, 466, 508,
1925 345, 509, 19, 398, 78, 79, 325, 326, 76, 77,
1926 53, 107, 425, 108, 300, 67, 81, 301, 68, 332,
1927 281, 69, 82, 70, 400, 298, 399, 529, 1, 32,
1928 2, 530, 295, 307, 308, 298, 310, 311, 298, 298,
1929 298, 298, 298, 318, 319, 298, 298, 54, 339, 340,
1930 341, 342, 343, 32, 133, 372, 90, 372, 372, 499,
1931 372, 351, 352, 353, 354, 196, 437, 372, 439, 440,
1932 441, 400, 95, 400, 445, 372, 372, 118, 119, 120,
1933 121, 122, 123, 124, 91, 92, 67, 380, 107, 68,
1934 108, 107, 69, 108, 70, 286, 107, 331, 108, 493,
1935 347, 43, 44, 45, 197, 107, 46, 108, 529, 402,
1936 403, 107, 533, 108, 94, 385, 409, 148, 149, 96,
1937 201, 378, 379, 382, 107, 546, 108, 98, 548, 99,
1938 486, 323, 324, 100, 372, 372, 372, 137, 201, 397,
1939 298, 138, 372, 325, 326, 109, 110, 542, -58, -59,
1940 150, 199, 236, 372, 372, 238, 512, 513, 514, 242,
1941 288, 239, 245, 553, 248, 249, 250, 251, 252, 253,
1942 254, 255, 256, 257, 276, 420, 277, 453, 454, 455,
1943 456, 278, 279, 280, 458, 459, 289, 461, 372, 290,
1944 372, 291, 292, 372, 293, 296, 302, 386, 337, 372,
1945 372, 333, 338, 298, 438, 298, 298, 298, 359, 387,
1946 444, 298, 388, 389, 390, 394, 391, 395, 405, 406,
1947 407, 484, 485, 408, 372, 372, 414, 372, 372, 412,
1948 460, -169, 372, 374, 375, 410, 376, 416, 413, 415,
1949 372, 417, 423, 384, 457, 1, 426, 2, 3, 427,
1950 436, 392, 393, 442, 4, 5, 443, 448, 449, 519,
1951 372, 520, 521, 465, 483, 450, 463, 298, 372, 467,
1952 468, 464, 469, 6, 470, 473, 482, 525, 432, 498,
1953 7, 538, 471, 451, 8, 503, 475, 477, 478, 479,
1954 487, 489, 495, 298, 298, 298, 488, 372, 503, 490,
1955 491, 492, 372, 500, 494, 507, 511, 526, 517, 531,
1956 428, 429, 430, 518, 540, 527, 372, 372, 435, 534,
1957 535, 372, 536, 549, 372, 556, 547, 559, 560, 446,
1958 447, 565, 561, 564, 567, 59, 60, 227, 103, 111,
1959 112, 113, 65, 228, 1, 545, 2, 229, 230, 305,
1960 259, 260, 495, 306, 128, 523, 329, -168, 143, 37,
1961 127, 140, 89, 537, 472, 515, 474, 434, 0, 476,
1962 66, 1, 0, 2, 3, 480, 481, 0, 0, 0,
1963 4, 5, 0, 0, 59, 60, 0, 103, 62, 63,
1964 64, 65, 0, 1, 0, 2, 0, 0, 0, 6,
1965 501, 502, 0, 505, 506, 0, 7, 0, 510, 132,
1966 8, 0, 0, 0, 0, 0, 516, 0, 0, 66,
1967 261, 262, 263, 264, 265, 266, 267, 268, 269, 270,
1968 271, 272, 273, 274, 0, 0, 528, 59, 60, 0,
1969 0, 0, 0, 0, 532, 0, 1, 0, 2, 0,
1970 151, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1971 0, 0, 0, 152, 153, 0, 67, 0, 0, 68,
1972 0, 0, 69, 550, 70, 346, 0, 0, 554, 0,
1973 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1974 0, 0, 562, 563, 0, 0, 0, 566, 0, 0,
1975 568, 154, 155, 156, 157, 158, 159, 160, 161, 162,
1976 163, 164, 165, 166, 167, 67, 0, 0, 68, 0,
1977 0, 69, 0, 70, 0, 0, 0, 0, 59, 60,
1978 0, 103, 62, 63, 64, 65, 0, 1, 0, 2,
1979 168, 169, 170, 171, 172, 173, 174, 175, 176, 177,
1980 178, 179, 180, 328, 181, 182, 183, 184, 0, 185,
1981 186, 187, 0, 66, 0, 0, 0, 107, 0, 108,
1982 0, 188, 0, 0, 189, 0, 190, 0, 191, 360,
1983 361, 59, 60, 362, 0, 0, 0, 0, 0, 0,
1984 1, 0, 2, 0, 363, 364, 365, 0, 0, 0,
1985 0, 0, 0, 0, 0, 0, 0, 366, 367, 59,
1986 60, 0, 103, 62, 63, 64, 65, 0, 1, 0,
1987 2, 0, 0, 0, 0, 0, 59, 60, 368, 61,
1988 62, 63, 64, 65, 419, 1, 0, 2, 0, 0,
1989 0, 0, 0, 0, 66, 154, 155, 156, 157, 158,
1990 159, 160, 161, 162, 163, 164, 165, 166, 167, 67,
1991 0, 66, 68, 0, 0, 69, 0, 70, 0, 0,
1992 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1993 0, 0, 0, 0, 168, 169, 170, 171, 172, 173,
1994 174, 175, 176, 177, 178, 179, 180, 0, 181, 182,
1995 183, 184, 0, 185, 186, 187, 360, 361, 59, 60,
1996 362, 107, 0, 108, 0, 0, 0, 1, 369, 2,
1997 0, 363, 364, 365, 0, 0, 0, 0, 0, 0,
1998 0, 0, 0, 0, 366, 367, 0, 0, 0, 0,
1999 67, 0, 0, 68, 0, 0, 69, 0, 70, 0,
2000 0, 0, 0, 0, 0, 368, 0, 67, 0, 0,
2001 68, 0, 0, 69, 0, 70, 0, 0, 0, 0,
2002 0, 0, 154, 155, 156, 157, 158, 159, 160, 161,
2003 162, 163, 164, 165, 166, 167, 0, 0, 0, 59,
2004 60, 0, 103, 111, 112, 113, 65, 0, 1, 0,
2005 2, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2006 0, 168, 169, 170, 171, 172, 173, 174, 175, 176,
2007 177, 178, 179, 180, 66, 181, 182, 183, 184, 0,
2008 185, 186, 187, 360, 361, 0, 0, 362, 0, 0,
2009 0, 0, 0, 0, 0, 369, 0, 0, 363, 364,
2010 365, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2011 0, 366, 367, 59, 60, 0, 103, 62, 63, 64,
2012 65, 0, 1, 0, 2, 0, 0, 0, 0, 0,
2013 59, 60, 368, 103, 62, 63, 64, 65, 497, 1,
2014 0, 2, 0, 0, 0, 0, 0, 0, 66, 154,
2015 155, 156, 157, 158, 159, 160, 161, 162, 163, 164,
2016 165, 166, 167, 0, 0, 66, 0, 0, 0, 0,
2017 67, 0, 0, 68, 0, 0, 69, 0, 70, 0,
2018 0, 0, 0, 0, 0, 0, 0, 0, 168, 169,
2019 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
2020 180, 0, 181, 182, 183, 184, 0, 185, 186, 187,
2021 59, 60, 0, 200, 62, 63, 64, 65, 0, 1,
2022 0, 2, 369, 59, 60, 0, 103, 111, 112, 113,
2023 65, 0, 1, 0, 2, 0, 0, 0, 0, 0,
2024 0, 0, 0, 0, 67, 66, 0, 68, 0, 0,
2025 69, 0, 70, 0, 0, 0, 0, 0, 66, 0,
2026 0, 67, 0, 0, 68, 0, 0, 69, 0, 70,
2027 59, 60, 0, 297, 62, 63, 64, 65, 0, 1,
2028 0, 2, 0, 0, 0, 0, 0, 0, 0, 0,
2029 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2030 0, 0, 0, 0, 0, 66, 0, 0, 0, 0,
2031 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2032 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2033 0, 0, 0, 0, 0, 0, 206, 0, 0, 0,
2034 0, 67, 0, 0, 68, 0, 0, 69, 0, 70,
2035 0, 0, 0, 0, 67, 0, 0, 68, 207, 208,
2036 69, 0, 284, 0, 0, 0, 0, 0, 0, 0,
2037 0, 209, 210, 211, 212, 213, 214, 154, 155, 156,
2038 157, 158, 159, 160, 161, 162, 163, 164, 165, 215,
2039 216, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2040 0, 67, 0, 0, 68, 0, 0, 69, 0, 70,
2041 0, 217, 218, 219, 0, 0, 220, 169, 170, 171,
2042 172, 173, 174, 175, 176, 177, 178, 179, 180, 221,
2043 222, 182, 183, 184, 223, 224, 225, 226
2044};
2045
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002046static const short yycheck[] =
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002047{
2048 0, 211, 189, 190, 116, 308, 9, 4, 420, 23,
2049 245, 11, 5, 6, 21, 8, 9, 10, 11, 12,
2050 212, 14, 80, 16, 9, 330, 133, 5, 6, 334,
2051 8, 9, 10, 11, 12, 15, 14, 27, 16, 37,
2052 232, 39, 22, 116, 9, 246, 247, 40, 14, 304,
2053 16, 109, 9, 134, 5, 6, 70, 8, 9, 10,
2054 11, 12, 40, 14, 145, 16, 27, 322, 219, 134,
2055 134, 222, 223, 224, 225, 226, 141, 0, 229, 230,
2056 13, 145, 52, 48, 98, 85, 498, 48, 102, 40,
2057 133, 48, 110, 111, 108, 29, 110, 284, 3, 4,
2058 33, 34, 35, 36, 37, 38, 39, 134, 41, 134,
2059 134, 125, 130, 138, 19, 20, 528, 133, 145, 143,
2060 110, 111, 134, 137, 138, 5, 6, 141, 8, 9,
2061 10, 11, 12, 145, 14, 139, 16, 144, 141, 542,
2062 130, 133, 554, 136, 110, 111, 139, 144, 16, 142,
2063 553, 144, 145, 43, 44, 45, 141, 358, 136, 134,
2064 40, 139, 15, 134, 142, 145, 144, 145, 143, 472,
2065 141, 474, 62, 324, 25, 26, 110, 111, 33, 34,
2066 133, 135, 369, 137, 9, 136, 41, 12, 139, 143,
2067 141, 142, 47, 144, 499, 209, 130, 134, 14, 132,
2068 16, 138, 202, 217, 218, 219, 220, 221, 222, 223,
2069 224, 225, 226, 227, 228, 229, 230, 133, 276, 277,
2070 278, 279, 280, 132, 238, 298, 16, 300, 301, 464,
2071 303, 289, 290, 291, 292, 347, 387, 310, 389, 390,
2072 391, 546, 16, 548, 395, 318, 319, 55, 56, 57,
2073 58, 59, 60, 61, 46, 47, 136, 134, 135, 139,
2074 137, 135, 142, 137, 144, 145, 135, 141, 137, 138,
2075 284, 33, 34, 35, 347, 135, 38, 137, 134, 337,
2076 338, 135, 138, 137, 4, 139, 344, 3, 4, 16,
2077 304, 305, 306, 134, 135, 530, 137, 137, 533, 4,
2078 451, 106, 107, 4, 377, 378, 379, 140, 322, 323,
2079 324, 140, 385, 110, 111, 76, 77, 527, 7, 7,
2080 7, 4, 16, 396, 397, 134, 477, 478, 479, 143,
2081 16, 138, 138, 543, 83, 84, 85, 86, 87, 88,
2082 89, 90, 91, 92, 137, 359, 137, 405, 406, 407,
2083 408, 137, 137, 137, 412, 413, 137, 415, 431, 137,
2084 433, 137, 137, 436, 134, 50, 9, 134, 137, 442,
2085 443, 143, 137, 387, 388, 389, 390, 391, 137, 134,
2086 394, 395, 134, 134, 134, 29, 134, 134, 134, 134,
2087 134, 449, 450, 134, 467, 468, 29, 470, 471, 134,
2088 414, 0, 475, 300, 301, 143, 303, 16, 134, 134,
2089 483, 4, 54, 310, 143, 14, 134, 16, 17, 134,
2090 139, 318, 319, 134, 23, 24, 134, 134, 134, 487,
2091 503, 489, 490, 16, 448, 134, 134, 451, 511, 12,
2092 12, 138, 137, 42, 134, 4, 137, 16, 48, 463,
2093 49, 48, 134, 134, 53, 469, 134, 134, 134, 134,
2094 134, 134, 462, 477, 478, 479, 138, 540, 482, 134,
2095 138, 138, 545, 134, 138, 134, 134, 134, 138, 141,
2096 377, 378, 379, 138, 12, 139, 559, 560, 385, 138,
2097 138, 564, 138, 4, 567, 134, 141, 12, 12, 396,
2098 397, 67, 134, 12, 12, 5, 6, 128, 8, 9,
2099 10, 11, 12, 128, 14, 529, 16, 128, 128, 215,
2100 19, 20, 522, 216, 85, 499, 238, 0, 108, 11,
2101 82, 102, 50, 522, 431, 482, 433, 384, -1, 436,
2102 40, 14, -1, 16, 17, 442, 443, -1, -1, -1,
2103 23, 24, -1, -1, 5, 6, -1, 8, 9, 10,
2104 11, 12, -1, 14, -1, 16, -1, -1, -1, 42,
2105 467, 468, -1, 470, 471, -1, 49, -1, 475, 30,
2106 53, -1, -1, -1, -1, -1, 483, -1, -1, 40,
2107 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
2108 99, 100, 101, 102, -1, -1, 503, 5, 6, -1,
2109 -1, -1, -1, -1, 511, -1, 14, -1, 16, -1,
2110 18, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2111 -1, -1, -1, 31, 32, -1, 136, -1, -1, 139,
2112 -1, -1, 142, 540, 144, 145, -1, -1, 545, -1,
2113 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2114 -1, -1, 559, 560, -1, -1, -1, 564, -1, -1,
2115 567, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2116 78, 79, 80, 81, 82, 136, -1, -1, 139, -1,
2117 -1, 142, -1, 144, -1, -1, -1, -1, 5, 6,
2118 -1, 8, 9, 10, 11, 12, -1, 14, -1, 16,
2119 108, 109, 110, 111, 112, 113, 114, 115, 116, 117,
2120 118, 119, 120, 30, 122, 123, 124, 125, -1, 127,
2121 128, 129, -1, 40, -1, -1, -1, 135, -1, 137,
2122 -1, 139, -1, -1, 142, -1, 144, -1, 146, 3,
2123 4, 5, 6, 7, -1, -1, -1, -1, -1, -1,
2124 14, -1, 16, -1, 18, 19, 20, -1, -1, -1,
2125 -1, -1, -1, -1, -1, -1, -1, 31, 32, 5,
2126 6, -1, 8, 9, 10, 11, 12, -1, 14, -1,
2127 16, -1, -1, -1, -1, -1, 5, 6, 52, 8,
2128 9, 10, 11, 12, 30, 14, -1, 16, -1, -1,
2129 -1, -1, -1, -1, 40, 69, 70, 71, 72, 73,
2130 74, 75, 76, 77, 78, 79, 80, 81, 82, 136,
2131 -1, 40, 139, -1, -1, 142, -1, 144, -1, -1,
2132 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2133 -1, -1, -1, -1, 108, 109, 110, 111, 112, 113,
2134 114, 115, 116, 117, 118, 119, 120, -1, 122, 123,
2135 124, 125, -1, 127, 128, 129, 3, 4, 5, 6,
2136 7, 135, -1, 137, -1, -1, -1, 14, 142, 16,
2137 -1, 18, 19, 20, -1, -1, -1, -1, -1, -1,
2138 -1, -1, -1, -1, 31, 32, -1, -1, -1, -1,
2139 136, -1, -1, 139, -1, -1, 142, -1, 144, -1,
2140 -1, -1, -1, -1, -1, 52, -1, 136, -1, -1,
2141 139, -1, -1, 142, -1, 144, -1, -1, -1, -1,
2142 -1, -1, 69, 70, 71, 72, 73, 74, 75, 76,
2143 77, 78, 79, 80, 81, 82, -1, -1, -1, 5,
2144 6, -1, 8, 9, 10, 11, 12, -1, 14, -1,
2145 16, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2146 -1, 108, 109, 110, 111, 112, 113, 114, 115, 116,
2147 117, 118, 119, 120, 40, 122, 123, 124, 125, -1,
2148 127, 128, 129, 3, 4, -1, -1, 7, -1, -1,
2149 -1, -1, -1, -1, -1, 142, -1, -1, 18, 19,
2150 20, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2151 -1, 31, 32, 5, 6, -1, 8, 9, 10, 11,
2152 12, -1, 14, -1, 16, -1, -1, -1, -1, -1,
2153 5, 6, 52, 8, 9, 10, 11, 12, 30, 14,
2154 -1, 16, -1, -1, -1, -1, -1, -1, 40, 69,
2155 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
2156 80, 81, 82, -1, -1, 40, -1, -1, -1, -1,
2157 136, -1, -1, 139, -1, -1, 142, -1, 144, -1,
2158 -1, -1, -1, -1, -1, -1, -1, -1, 108, 109,
2159 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
2160 120, -1, 122, 123, 124, 125, -1, 127, 128, 129,
2161 5, 6, -1, 8, 9, 10, 11, 12, -1, 14,
2162 -1, 16, 142, 5, 6, -1, 8, 9, 10, 11,
2163 12, -1, 14, -1, 16, -1, -1, -1, -1, -1,
2164 -1, -1, -1, -1, 136, 40, -1, 139, -1, -1,
2165 142, -1, 144, -1, -1, -1, -1, -1, 40, -1,
2166 -1, 136, -1, -1, 139, -1, -1, 142, -1, 144,
2167 5, 6, -1, 8, 9, 10, 11, 12, -1, 14,
2168 -1, 16, -1, -1, -1, -1, -1, -1, -1, -1,
2169 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2170 -1, -1, -1, -1, -1, 40, -1, -1, -1, -1,
2171 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2172 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2173 -1, -1, -1, -1, -1, -1, 28, -1, -1, -1,
2174 -1, 136, -1, -1, 139, -1, -1, 142, -1, 144,
2175 -1, -1, -1, -1, 136, -1, -1, 139, 50, 51,
2176 142, -1, 144, -1, -1, -1, -1, -1, -1, -1,
2177 -1, 63, 64, 65, 66, 67, 68, 69, 70, 71,
2178 72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
2179 82, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2180 -1, 136, -1, -1, 139, -1, -1, 142, -1, 144,
2181 -1, 103, 104, 105, -1, -1, 108, 109, 110, 111,
2182 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
2183 122, 123, 124, 125, 126, 127, 128, 129
2184};
2185
2186/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2187 symbol of state STATE-NUM. */
2188static const unsigned char yystos[] =
2189{
2190 0, 14, 16, 17, 23, 24, 42, 49, 53, 157,
2191 185, 186, 187, 198, 189, 188, 43, 44, 45, 62,
2192 195, 133, 52, 13, 33, 34, 35, 36, 37, 38,
2193 39, 41, 132, 158, 159, 160, 0, 187, 133, 37,
2194 39, 161, 207, 33, 34, 35, 38, 162, 204, 206,
2195 213, 133, 133, 133, 133, 139, 196, 16, 193, 5,
2196 6, 8, 9, 10, 11, 12, 40, 136, 139, 142,
2197 144, 148, 174, 175, 198, 210, 160, 160, 25, 26,
2198 184, 160, 160, 15, 214, 215, 22, 145, 205, 214,
2199 16, 46, 47, 194, 4, 16, 16, 197, 137, 4,
2200 4, 4, 144, 8, 145, 175, 180, 135, 137, 184,
2201 184, 9, 10, 11, 155, 156, 175, 181, 55, 56,
2202 57, 58, 59, 60, 61, 163, 202, 202, 157, 218,
2203 134, 141, 30, 175, 176, 178, 179, 140, 140, 145,
2204 180, 134, 145, 179, 181, 175, 19, 20, 3, 4,
2205 7, 18, 31, 32, 69, 70, 71, 72, 73, 74,
2206 75, 76, 77, 78, 79, 80, 81, 82, 108, 109,
2207 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
2208 120, 122, 123, 124, 125, 127, 128, 129, 139, 142,
2209 144, 146, 149, 150, 151, 152, 182, 210, 190, 4,
2210 8, 175, 177, 21, 144, 203, 28, 50, 51, 63,
2211 64, 65, 66, 67, 68, 81, 82, 103, 104, 105,
2212 108, 121, 122, 126, 127, 128, 129, 149, 150, 151,
2213 152, 216, 222, 223, 224, 225, 16, 165, 134, 138,
2214 175, 175, 143, 145, 175, 138, 191, 192, 83, 84,
2215 85, 86, 87, 88, 89, 90, 91, 92, 153, 19,
2216 20, 89, 90, 91, 92, 93, 94, 95, 96, 97,
2217 98, 99, 100, 101, 102, 154, 137, 137, 137, 137,
2218 137, 141, 181, 183, 144, 183, 145, 183, 16, 137,
2219 137, 137, 137, 134, 172, 198, 50, 8, 175, 212,
2220 9, 12, 9, 155, 163, 153, 154, 175, 175, 212,
2221 175, 175, 219, 212, 212, 212, 212, 212, 175, 175,
2222 212, 212, 163, 106, 107, 110, 111, 164, 30, 176,
2223 167, 141, 143, 143, 167, 172, 172, 137, 137, 181,
2224 181, 181, 181, 181, 134, 141, 145, 175, 183, 143,
2225 145, 181, 181, 181, 181, 27, 48, 170, 173, 137,
2226 3, 4, 7, 18, 19, 20, 31, 32, 52, 142,
2227 182, 209, 210, 211, 211, 211, 211, 177, 175, 175,
2228 134, 169, 134, 169, 211, 139, 134, 134, 134, 134,
2229 134, 134, 211, 211, 29, 134, 177, 175, 212, 130,
2230 164, 166, 181, 181, 221, 134, 134, 134, 134, 181,
2231 143, 145, 134, 134, 29, 134, 16, 4, 172, 30,
2232 175, 200, 201, 54, 208, 183, 134, 134, 211, 211,
2233 211, 9, 48, 9, 221, 211, 139, 212, 175, 212,
2234 212, 212, 134, 134, 175, 212, 211, 211, 134, 134,
2235 134, 134, 138, 181, 181, 181, 181, 143, 181, 181,
2236 175, 181, 165, 134, 138, 16, 143, 12, 12, 137,
2237 134, 134, 211, 4, 211, 134, 211, 134, 134, 134,
2238 211, 211, 137, 175, 181, 181, 212, 134, 138, 134,
2239 134, 138, 138, 138, 138, 198, 199, 30, 175, 167,
2240 134, 211, 211, 175, 220, 211, 211, 134, 169, 169,
2241 211, 134, 212, 212, 212, 220, 211, 138, 138, 181,
2242 181, 181, 165, 170, 171, 16, 134, 139, 211, 134,
2243 138, 141, 211, 138, 138, 138, 138, 199, 48, 168,
2244 12, 141, 155, 217, 165, 175, 167, 141, 167, 4,
2245 211, 209, 141, 155, 211, 29, 134, 209, 165, 12,
2246 12, 134, 211, 211, 12, 67, 211, 12, 211
2247};
Reid Spencer68a24bd2005-08-27 18:50:39 +00002248
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002249#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
2250# define YYSIZE_T __SIZE_TYPE__
2251#endif
2252#if ! defined (YYSIZE_T) && defined (size_t)
2253# define YYSIZE_T size_t
2254#endif
2255#if ! defined (YYSIZE_T)
2256# if defined (__STDC__) || defined (__cplusplus)
2257# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
2258# define YYSIZE_T size_t
2259# endif
2260#endif
2261#if ! defined (YYSIZE_T)
2262# define YYSIZE_T unsigned int
2263#endif
2264
Reid Spencer68a24bd2005-08-27 18:50:39 +00002265#define yyerrok (yyerrstatus = 0)
2266#define yyclearin (yychar = YYEMPTY)
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002267#define YYEMPTY -2
Reid Spencer68a24bd2005-08-27 18:50:39 +00002268#define YYEOF 0
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002269
Reid Spencer68a24bd2005-08-27 18:50:39 +00002270#define YYACCEPT goto yyacceptlab
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002271#define YYABORT goto yyabortlab
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002272#define YYERROR goto yyerrlab1
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002273
2274/* Like YYERROR except do call yyerror. This remains here temporarily
2275 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002276 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002277
Reid Spencer68a24bd2005-08-27 18:50:39 +00002278#define YYFAIL goto yyerrlab
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002279
Reid Spencer68a24bd2005-08-27 18:50:39 +00002280#define YYRECOVERING() (!!yyerrstatus)
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002281
2282#define YYBACKUP(Token, Value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002283do \
2284 if (yychar == YYEMPTY && yylen == 1) \
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002285 { \
2286 yychar = (Token); \
2287 yylval = (Value); \
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002288 yychar1 = YYTRANSLATE (yychar); \
Reid Spencer6f407902007-01-13 05:00:46 +00002289 YYPOPSTACK; \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002290 goto yybackup; \
2291 } \
2292 else \
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002293 { \
2294 yyerror ("syntax error: cannot back up"); \
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002295 YYERROR; \
2296 } \
Reid Spencer6f407902007-01-13 05:00:46 +00002297while (0)
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002298
Reid Spencer68a24bd2005-08-27 18:50:39 +00002299#define YYTERROR 1
2300#define YYERRCODE 256
2301
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002302/* YYLLOC_DEFAULT -- Compute the default location (before the actions
2303 are run). */
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002304
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002305#ifndef YYLLOC_DEFAULT
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002306# define YYLLOC_DEFAULT(Current, Rhs, N) \
2307 Current.first_line = Rhs[1].first_line; \
2308 Current.first_column = Rhs[1].first_column; \
2309 Current.last_line = Rhs[N].last_line; \
2310 Current.last_column = Rhs[N].last_column;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002311#endif
2312
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002313/* YYLEX -- calling `yylex' with the right arguments. */
2314
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002315#define YYLEX yylex ()
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002316
2317/* Enable debugging if requested. */
2318#if YYDEBUG
2319
2320# ifndef YYFPRINTF
2321# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2322# define YYFPRINTF fprintf
2323# endif
2324
2325# define YYDPRINTF(Args) \
2326do { \
2327 if (yydebug) \
2328 YYFPRINTF Args; \
2329} while (0)
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002330# define YYDSYMPRINT(Args) \
2331do { \
2332 if (yydebug) \
2333 yysymprint Args; \
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002334} while (0)
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002335/* Nonzero means print parse trace. It is left uninitialized so that
2336 multiple parsers can coexist. */
2337int yydebug;
2338#else /* !YYDEBUG */
2339# define YYDPRINTF(Args)
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002340# define YYDSYMPRINT(Args)
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002341#endif /* !YYDEBUG */
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002342
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002343/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002344#ifndef YYINITDEPTH
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002345# define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00002346#endif
2347
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002348/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2349 if the built-in stack extension method is used).
Reid Spencer68a24bd2005-08-27 18:50:39 +00002350
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002351 Do not make this value too large; the results are undefined if
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002352 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002353 evaluated with infinite-precision integer arithmetic. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002354
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002355#if YYMAXDEPTH == 0
2356# undef YYMAXDEPTH
2357#endif
2358
Reid Spencer68a24bd2005-08-27 18:50:39 +00002359#ifndef YYMAXDEPTH
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002360# define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00002361#endif
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002362
Reid Spencer68a24bd2005-08-27 18:50:39 +00002363
2364
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002365#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00002366
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002367# ifndef yystrlen
2368# if defined (__GLIBC__) && defined (_STRING_H)
2369# define yystrlen strlen
2370# else
2371/* Return the length of YYSTR. */
2372static YYSIZE_T
2373# if defined (__STDC__) || defined (__cplusplus)
2374yystrlen (const char *yystr)
2375# else
2376yystrlen (yystr)
2377 const char *yystr;
2378# endif
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002379{
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002380 register const char *yys = yystr;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002381
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002382 while (*yys++ != '\0')
2383 continue;
2384
2385 return yys - yystr - 1;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002386}
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002387# endif
2388# endif
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002389
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002390# ifndef yystpcpy
2391# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
2392# define yystpcpy stpcpy
2393# else
2394/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2395 YYDEST. */
2396static char *
2397# if defined (__STDC__) || defined (__cplusplus)
2398yystpcpy (char *yydest, const char *yysrc)
2399# else
2400yystpcpy (yydest, yysrc)
2401 char *yydest;
2402 const char *yysrc;
2403# endif
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002404{
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002405 register char *yyd = yydest;
2406 register const char *yys = yysrc;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002407
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002408 while ((*yyd++ = *yys++) != '\0')
2409 continue;
2410
2411 return yyd - 1;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002412}
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002413# endif
2414# endif
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002415
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002416#endif /* !YYERROR_VERBOSE */
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002417
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002418
2419
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002420#if YYDEBUG
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002421/*-----------------------------.
2422| Print this symbol on YYOUT. |
2423`-----------------------------*/
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002424
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002425static void
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002426#if defined (__STDC__) || defined (__cplusplus)
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002427yysymprint (FILE* yyout, int yytype, YYSTYPE yyvalue)
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002428#else
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002429yysymprint (yyout, yytype, yyvalue)
2430 FILE* yyout;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002431 int yytype;
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002432 YYSTYPE yyvalue;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002433#endif
2434{
2435 /* Pacify ``unused variable'' warnings. */
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002436 (void) yyvalue;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002437
2438 if (yytype < YYNTOKENS)
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002439 {
2440 YYFPRINTF (yyout, "token %s (", yytname[yytype]);
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002441# ifdef YYPRINT
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002442 YYPRINT (yyout, yytoknum[yytype], yyvalue);
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002443# endif
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002444 }
2445 else
2446 YYFPRINTF (yyout, "nterm %s (", yytname[yytype]);
2447
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002448 switch (yytype)
2449 {
2450 default:
2451 break;
2452 }
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002453 YYFPRINTF (yyout, ")");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002454}
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002455#endif /* YYDEBUG. */
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002456
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002457
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002458/*-----------------------------------------------.
2459| Release the memory associated to this symbol. |
2460`-----------------------------------------------*/
2461
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002462static void
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002463#if defined (__STDC__) || defined (__cplusplus)
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002464yydestruct (int yytype, YYSTYPE yyvalue)
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002465#else
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002466yydestruct (yytype, yyvalue)
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002467 int yytype;
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002468 YYSTYPE yyvalue;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002469#endif
2470{
2471 /* Pacify ``unused variable'' warnings. */
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002472 (void) yyvalue;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002473
2474 switch (yytype)
2475 {
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002476 default:
2477 break;
2478 }
2479}
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002480
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002481
2482
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002483/* The user can define YYPARSE_PARAM as the name of an argument to be passed
2484 into yyparse. The argument should have type void *.
2485 It should actually point to an object.
2486 Grammar actions can access the variable by casting it
2487 to the proper pointer type. */
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002488
2489#ifdef YYPARSE_PARAM
2490# if defined (__STDC__) || defined (__cplusplus)
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002491# define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
2492# define YYPARSE_PARAM_DECL
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002493# else
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002494# define YYPARSE_PARAM_ARG YYPARSE_PARAM
2495# define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002496# endif
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002497#else /* !YYPARSE_PARAM */
2498# define YYPARSE_PARAM_ARG
2499# define YYPARSE_PARAM_DECL
2500#endif /* !YYPARSE_PARAM */
2501
2502/* Prevent warning if -Wstrict-prototypes. */
2503#ifdef __GNUC__
2504# ifdef YYPARSE_PARAM
2505int yyparse (void *);
2506# else
Reid Spencere812fb22006-01-19 01:21:04 +00002507int yyparse (void);
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002508# endif
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002509#endif
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002510
2511
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002512/* The lookahead symbol. */
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002513int yychar;
2514
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002515/* The semantic value of the lookahead symbol. */
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002516YYSTYPE yylval;
2517
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002518/* Number of parse errors so far. */
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002519int yynerrs;
2520
2521
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002522int
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002523yyparse (YYPARSE_PARAM_ARG)
2524 YYPARSE_PARAM_DECL
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002525{
2526
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002527 register int yystate;
2528 register int yyn;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002529 int yyresult;
2530 /* Number of tokens to shift before error messages enabled. */
2531 int yyerrstatus;
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002532 /* Lookahead token as an internal (translated) token number. */
2533 int yychar1 = 0;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002534
2535 /* Three stacks and their tools:
2536 `yyss': related to states,
2537 `yyvs': related to semantic values,
2538 `yyls': related to locations.
2539
2540 Refer to the stacks thru separate pointers, to allow yyoverflow
2541 to reallocate them elsewhere. */
2542
2543 /* The state stack. */
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002544 short yyssa[YYINITDEPTH];
2545 short *yyss = yyssa;
2546 register short *yyssp;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002547
2548 /* The semantic value stack. */
2549 YYSTYPE yyvsa[YYINITDEPTH];
2550 YYSTYPE *yyvs = yyvsa;
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002551 register YYSTYPE *yyvsp;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002552
2553
2554
Reid Spencer6f407902007-01-13 05:00:46 +00002555#define YYPOPSTACK (yyvsp--, yyssp--)
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002556
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002557 YYSIZE_T yystacksize = YYINITDEPTH;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002558
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002559 /* The variables used to return semantic value and location from the
2560 action routines. */
2561 YYSTYPE yyval;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002562
2563
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002564 /* When reducing, the number of symbols on the RHS of the reduced
2565 rule. */
Reid Spencer6f407902007-01-13 05:00:46 +00002566 int yylen;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002567
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002568 YYDPRINTF ((stderr, "Starting parse\n"));
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002569
Reid Spencer68a24bd2005-08-27 18:50:39 +00002570 yystate = 0;
2571 yyerrstatus = 0;
2572 yynerrs = 0;
2573 yychar = YYEMPTY; /* Cause a token to be read. */
2574
2575 /* Initialize stack pointers.
2576 Waste one element of value and location stack
2577 so that they stay on the same level as the state stack.
2578 The wasted elements are never initialized. */
2579
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002580 yyssp = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002581 yyvsp = yyvs;
2582
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002583 goto yysetstate;
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002584
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002585/*------------------------------------------------------------.
2586| yynewstate -- Push a new state, which is found in yystate. |
2587`------------------------------------------------------------*/
2588 yynewstate:
2589 /* In all cases, when you get here, the value and location stacks
2590 have just been pushed. so pushing a state here evens the stacks.
2591 */
2592 yyssp++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002593
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002594 yysetstate:
2595 *yyssp = yystate;
2596
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002597 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002598 {
2599 /* Get the current used size of the three stacks, in elements. */
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002600 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002601
2602#ifdef yyoverflow
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002603 {
2604 /* Give user a chance to reallocate the stack. Use copies of
2605 these so that the &'s don't force the real ones into
2606 memory. */
2607 YYSTYPE *yyvs1 = yyvs;
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002608 short *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002609
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002610
2611 /* Each stack pointer address is followed by the size of the
2612 data in use in that stack, in bytes. This used to be a
2613 conditional around just the two extra args, but that might
2614 be undefined if yyoverflow is a macro. */
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002615 yyoverflow ("parser stack overflow",
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002616 &yyss1, yysize * sizeof (*yyssp),
2617 &yyvs1, yysize * sizeof (*yyvsp),
2618
2619 &yystacksize);
2620
2621 yyss = yyss1;
2622 yyvs = yyvs1;
2623 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002624#else /* no yyoverflow */
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002625# ifndef YYSTACK_RELOCATE
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002626 goto yyoverflowlab;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002627# else
Reid Spencer68a24bd2005-08-27 18:50:39 +00002628 /* Extend the stack our own way. */
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002629 if (yystacksize >= YYMAXDEPTH)
2630 goto yyoverflowlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002631 yystacksize *= 2;
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002632 if (yystacksize > YYMAXDEPTH)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002633 yystacksize = YYMAXDEPTH;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002634
2635 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002636 short *yyss1 = yyss;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002637 union yyalloc *yyptr =
2638 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
2639 if (! yyptr)
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002640 goto yyoverflowlab;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002641 YYSTACK_RELOCATE (yyss);
2642 YYSTACK_RELOCATE (yyvs);
2643
2644# undef YYSTACK_RELOCATE
2645 if (yyss1 != yyssa)
2646 YYSTACK_FREE (yyss1);
2647 }
2648# endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002649#endif /* no yyoverflow */
2650
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002651 yyssp = yyss + yysize - 1;
2652 yyvsp = yyvs + yysize - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002653
2654
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002655 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
2656 (unsigned long int) yystacksize));
2657
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002658 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002659 YYABORT;
2660 }
2661
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002662 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002663
2664 goto yybackup;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002665
2666/*-----------.
2667| yybackup. |
2668`-----------*/
2669yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002670
Reid Spencer6f407902007-01-13 05:00:46 +00002671/* Do appropriate processing given the current state. */
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002672/* Read a lookahead token if we need one and don't already have one. */
Reid Spencer6f407902007-01-13 05:00:46 +00002673/* yyresume: */
Andrew Lenharth6353e052006-12-08 18:07:09 +00002674
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002675 /* First try to decide what to do without reference to lookahead token. */
Reid Spencer6f407902007-01-13 05:00:46 +00002676
Reid Spencer68a24bd2005-08-27 18:50:39 +00002677 yyn = yypact[yystate];
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002678 if (yyn == YYPACT_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002679 goto yydefault;
2680
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002681 /* Not known => get a lookahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002682
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002683 /* yychar is either YYEMPTY or YYEOF
2684 or a valid token in external form. */
2685
Reid Spencer68a24bd2005-08-27 18:50:39 +00002686 if (yychar == YYEMPTY)
2687 {
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002688 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002689 yychar = YYLEX;
2690 }
2691
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002692 /* Convert token to internal form (in yychar1) for indexing tables with. */
2693
2694 if (yychar <= 0) /* This means end of input. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002695 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002696 yychar1 = 0;
2697 yychar = YYEOF; /* Don't call YYLEX any more. */
2698
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002699 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002700 }
2701 else
2702 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002703 yychar1 = YYTRANSLATE (yychar);
2704
2705 /* We have to keep this `#if YYDEBUG', since we use variables
2706 which are defined only if `YYDEBUG' is set. */
2707 YYDPRINTF ((stderr, "Next token is "));
2708 YYDSYMPRINT ((stderr, yychar1, yylval));
2709 YYDPRINTF ((stderr, "\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002710 }
2711
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002712 /* If the proper action on seeing token YYCHAR1 is to reduce or to
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002713 detect an error, take that action. */
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002714 yyn += yychar1;
2715 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yychar1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002716 goto yydefault;
2717 yyn = yytable[yyn];
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002718 if (yyn <= 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002719 {
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002720 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002721 goto yyerrlab;
2722 yyn = -yyn;
2723 goto yyreduce;
2724 }
2725
2726 if (yyn == YYFINAL)
2727 YYACCEPT;
2728
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002729 /* Shift the lookahead token. */
2730 YYDPRINTF ((stderr, "Shifting token %d (%s), ",
2731 yychar, yytname[yychar1]));
Reid Spencer6f407902007-01-13 05:00:46 +00002732
2733 /* Discard the token being shifted unless it is eof. */
2734 if (yychar != YYEOF)
2735 yychar = YYEMPTY;
2736
2737 *++yyvsp = yylval;
2738
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002739
2740 /* Count tokens shifted since error; after three, turn off error
2741 status. */
2742 if (yyerrstatus)
2743 yyerrstatus--;
Chris Lattner0fab59c2007-01-12 18:33:30 +00002744
Reid Spencer68a24bd2005-08-27 18:50:39 +00002745 yystate = yyn;
2746 goto yynewstate;
2747
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002748
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002749/*-----------------------------------------------------------.
2750| yydefault -- do the default action for the current state. |
2751`-----------------------------------------------------------*/
2752yydefault:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002753 yyn = yydefact[yystate];
2754 if (yyn == 0)
2755 goto yyerrlab;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002756 goto yyreduce;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002757
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002758
2759/*-----------------------------.
2760| yyreduce -- Do a reduction. |
2761`-----------------------------*/
Reid Spencer68a24bd2005-08-27 18:50:39 +00002762yyreduce:
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002763 /* yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002764 yylen = yyr2[yyn];
2765
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002766 /* If YYLEN is nonzero, implement the default value of the action:
2767 `$$ = $1'.
2768
2769 Otherwise, the following line sets YYVAL to garbage.
2770 This behavior is undocumented and Bison
2771 users should not rely upon it. Assigning to YYVAL
2772 unconditionally makes the parser a bit smaller, and it avoids a
2773 GCC warning that YYVAL may be used uninitialized. */
2774 yyval = yyvsp[1-yylen];
2775
2776
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002777
2778#if YYDEBUG
2779 /* We have to keep this `#if YYDEBUG', since we use variables which
2780 are defined only if `YYDEBUG' is set. */
2781 if (yydebug)
2782 {
2783 int yyi;
2784
2785 YYFPRINTF (stderr, "Reducing via rule %d (line %d), ",
2786 yyn - 1, yyrline[yyn]);
2787
2788 /* Print the symbols being reduced, and their result. */
2789 for (yyi = yyprhs[yyn]; yyrhs[yyi] >= 0; yyi++)
2790 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
2791 YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2792 }
2793#endif
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002794 switch (yyn)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002795 {
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002796 case 3:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002797#line 1032 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002798 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002799 if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX) // Outside of my range!
Reid Spencer61c83e02006-08-18 08:43:06 +00002800 GEN_ERROR("Value too large for type!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002801 yyval.SIntVal = (int32_t)yyvsp[0].UIntVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00002802 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002803}
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002804 break;
2805
2806 case 31:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002807#line 1048 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
2808 { yyval.IPredicate = ICmpInst::ICMP_EQ; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002809 break;
2810
2811 case 32:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002812#line 1048 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
2813 { yyval.IPredicate = ICmpInst::ICMP_NE; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002814 break;
2815
2816 case 33:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002817#line 1049 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
2818 { yyval.IPredicate = ICmpInst::ICMP_SLT; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002819 break;
2820
2821 case 34:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002822#line 1049 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
2823 { yyval.IPredicate = ICmpInst::ICMP_SGT; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002824 break;
2825
2826 case 35:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002827#line 1050 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
2828 { yyval.IPredicate = ICmpInst::ICMP_SLE; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002829 break;
2830
2831 case 36:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002832#line 1050 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
2833 { yyval.IPredicate = ICmpInst::ICMP_SGE; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002834 break;
2835
2836 case 37:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002837#line 1051 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
2838 { yyval.IPredicate = ICmpInst::ICMP_ULT; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002839 break;
2840
2841 case 38:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002842#line 1051 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
2843 { yyval.IPredicate = ICmpInst::ICMP_UGT; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002844 break;
2845
2846 case 39:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002847#line 1052 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
2848 { yyval.IPredicate = ICmpInst::ICMP_ULE; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002849 break;
2850
2851 case 40:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002852#line 1052 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
2853 { yyval.IPredicate = ICmpInst::ICMP_UGE; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002854 break;
2855
2856 case 41:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002857#line 1056 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
2858 { yyval.FPredicate = FCmpInst::FCMP_OEQ; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002859 break;
2860
2861 case 42:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002862#line 1056 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
2863 { yyval.FPredicate = FCmpInst::FCMP_ONE; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002864 break;
2865
2866 case 43:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002867#line 1057 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
2868 { yyval.FPredicate = FCmpInst::FCMP_OLT; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002869 break;
2870
2871 case 44:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002872#line 1057 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
2873 { yyval.FPredicate = FCmpInst::FCMP_OGT; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002874 break;
2875
2876 case 45:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002877#line 1058 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
2878 { yyval.FPredicate = FCmpInst::FCMP_OLE; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002879 break;
2880
2881 case 46:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002882#line 1058 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
2883 { yyval.FPredicate = FCmpInst::FCMP_OGE; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002884 break;
2885
2886 case 47:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002887#line 1059 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
2888 { yyval.FPredicate = FCmpInst::FCMP_ORD; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002889 break;
2890
2891 case 48:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002892#line 1059 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
2893 { yyval.FPredicate = FCmpInst::FCMP_UNO; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002894 break;
2895
2896 case 49:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002897#line 1060 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
2898 { yyval.FPredicate = FCmpInst::FCMP_UEQ; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002899 break;
2900
2901 case 50:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002902#line 1060 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
2903 { yyval.FPredicate = FCmpInst::FCMP_UNE; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002904 break;
2905
2906 case 51:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002907#line 1061 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
2908 { yyval.FPredicate = FCmpInst::FCMP_ULT; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002909 break;
2910
2911 case 52:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002912#line 1061 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
2913 { yyval.FPredicate = FCmpInst::FCMP_UGT; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002914 break;
2915
2916 case 53:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002917#line 1062 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
2918 { yyval.FPredicate = FCmpInst::FCMP_ULE; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002919 break;
2920
2921 case 54:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002922#line 1062 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
2923 { yyval.FPredicate = FCmpInst::FCMP_UGE; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002924 break;
2925
2926 case 55:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002927#line 1063 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
2928 { yyval.FPredicate = FCmpInst::FCMP_TRUE; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002929 break;
2930
2931 case 56:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002932#line 1064 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
2933 { yyval.FPredicate = FCmpInst::FCMP_FALSE; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002934 break;
2935
2936 case 60:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002937#line 1073 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002938 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002939 yyval.StrVal = yyvsp[-1].StrVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00002940 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002941 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002942 break;
2943
2944 case 61:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002945#line 1077 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002946 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002947 yyval.StrVal = 0;
Reid Spencere4d87aa2006-12-23 06:05:41 +00002948 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002949 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002950 break;
2951
2952 case 62:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002953#line 1083 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
2954 { yyval.Linkage = GlobalValue::InternalLinkage; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002955 break;
2956
2957 case 63:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002958#line 1084 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
2959 { yyval.Linkage = GlobalValue::WeakLinkage; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002960 break;
2961
2962 case 64:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002963#line 1085 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
2964 { yyval.Linkage = GlobalValue::LinkOnceLinkage; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002965 break;
2966
2967 case 65:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002968#line 1086 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
2969 { yyval.Linkage = GlobalValue::AppendingLinkage; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002970 break;
2971
2972 case 66:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002973#line 1087 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
2974 { yyval.Linkage = GlobalValue::DLLExportLinkage; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002975 break;
2976
2977 case 67:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002978#line 1091 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
2979 { yyval.Linkage = GlobalValue::DLLImportLinkage; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002980 break;
2981
2982 case 68:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002983#line 1092 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
2984 { yyval.Linkage = GlobalValue::ExternalWeakLinkage; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002985 break;
2986
2987 case 69:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002988#line 1093 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
2989 { yyval.Linkage = GlobalValue::ExternalLinkage; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002990 break;
2991
2992 case 70:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002993#line 1097 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
2994 { yyval.Visibility = GlobalValue::DefaultVisibility; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002995 break;
2996
2997 case 71:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00002998#line 1098 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
2999 { yyval.Visibility = GlobalValue::HiddenVisibility; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003000 break;
3001
3002 case 72:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003003#line 1102 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
3004 { yyval.Linkage = GlobalValue::ExternalLinkage; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003005 break;
3006
3007 case 73:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003008#line 1103 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
3009 { yyval.Linkage = GlobalValue::DLLImportLinkage; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003010 break;
3011
3012 case 74:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003013#line 1104 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
3014 { yyval.Linkage = GlobalValue::ExternalWeakLinkage; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003015 break;
3016
3017 case 75:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003018#line 1108 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
3019 { yyval.Linkage = GlobalValue::ExternalLinkage; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003020 break;
3021
3022 case 76:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003023#line 1109 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
3024 { yyval.Linkage = GlobalValue::InternalLinkage; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003025 break;
3026
3027 case 77:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003028#line 1110 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
3029 { yyval.Linkage = GlobalValue::LinkOnceLinkage; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003030 break;
3031
3032 case 78:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003033#line 1111 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
3034 { yyval.Linkage = GlobalValue::WeakLinkage; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003035 break;
3036
3037 case 79:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003038#line 1112 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
3039 { yyval.Linkage = GlobalValue::DLLExportLinkage; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003040 break;
3041
3042 case 80:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003043#line 1115 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
3044 { yyval.UIntVal = CallingConv::C; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003045 break;
3046
3047 case 81:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003048#line 1116 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
3049 { yyval.UIntVal = CallingConv::C; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003050 break;
3051
3052 case 82:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003053#line 1117 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
3054 { yyval.UIntVal = CallingConv::CSRet; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003055 break;
3056
3057 case 83:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003058#line 1118 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
3059 { yyval.UIntVal = CallingConv::Fast; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003060 break;
3061
3062 case 84:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003063#line 1119 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
3064 { yyval.UIntVal = CallingConv::Cold; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003065 break;
3066
3067 case 85:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003068#line 1120 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
3069 { yyval.UIntVal = CallingConv::X86_StdCall; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003070 break;
3071
3072 case 86:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003073#line 1121 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
3074 { yyval.UIntVal = CallingConv::X86_FastCall; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003075 break;
3076
3077 case 87:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003078#line 1122 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003079 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003080 if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
Reid Spencer61c83e02006-08-18 08:43:06 +00003081 GEN_ERROR("Calling conv too large!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003082 yyval.UIntVal = yyvsp[0].UInt64Val;
Reid Spencer61c83e02006-08-18 08:43:06 +00003083 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003084 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003085 break;
3086
3087 case 88:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003088#line 1129 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
3089 { yyval.ParamAttrs = FunctionType::ZExtAttribute; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003090 break;
3091
3092 case 89:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003093#line 1130 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
3094 { yyval.ParamAttrs = FunctionType::SExtAttribute; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003095 break;
3096
3097 case 90:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003098#line 1133 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
3099 { yyval.ParamAttrs = FunctionType::NoAttributeSet; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003100 break;
3101
3102 case 91:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003103#line 1134 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003104 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003105 yyval.ParamAttrs = FunctionType::ParameterAttributes(yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs);
3106 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003107 break;
3108
3109 case 92:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003110#line 1139 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
3111 { yyval.ParamAttrs = FunctionType::NoReturnAttribute; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003112 break;
3113
3114 case 94:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003115#line 1143 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
3116 { yyval.ParamAttrs = FunctionType::NoAttributeSet; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003117 break;
3118
3119 case 95:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003120#line 1144 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003121 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003122 yyval.ParamAttrs = FunctionType::ParameterAttributes(yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs);
3123 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003124 break;
3125
3126 case 96:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003127#line 1151 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
3128 { yyval.UIntVal = 0; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003129 break;
3130
3131 case 97:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003132#line 1152 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003133 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003134 yyval.UIntVal = yyvsp[0].UInt64Val;
3135 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
Reid Spencera54b7cb2007-01-12 07:05:14 +00003136 GEN_ERROR("Alignment must be a power of two!");
3137 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003138}
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003139 break;
3140
3141 case 98:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003142#line 1158 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
3143 { yyval.UIntVal = 0; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003144 break;
3145
3146 case 99:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003147#line 1159 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003148 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003149 yyval.UIntVal = yyvsp[0].UInt64Val;
3150 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
Reid Spencera54b7cb2007-01-12 07:05:14 +00003151 GEN_ERROR("Alignment must be a power of two!");
3152 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003153}
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003154 break;
3155
3156 case 100:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003157#line 1167 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003158 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003159 for (unsigned i = 0, e = strlen(yyvsp[0].StrVal); i != e; ++i)
3160 if (yyvsp[0].StrVal[i] == '"' || yyvsp[0].StrVal[i] == '\\')
Reid Spencere4d87aa2006-12-23 06:05:41 +00003161 GEN_ERROR("Invalid character in section name!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003162 yyval.StrVal = yyvsp[0].StrVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00003163 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003164}
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003165 break;
3166
3167 case 101:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003168#line 1175 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
3169 { yyval.StrVal = 0; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003170 break;
3171
3172 case 102:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003173#line 1176 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
3174 { yyval.StrVal = yyvsp[0].StrVal; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003175 break;
3176
3177 case 103:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003178#line 1181 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
3179 {}
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003180 break;
3181
3182 case 104:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003183#line 1182 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
3184 {}
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003185 break;
3186
3187 case 105:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003188#line 1183 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003189 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003190 CurGV->setSection(yyvsp[0].StrVal);
3191 free(yyvsp[0].StrVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003192 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003193 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003194 break;
3195
3196 case 106:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003197#line 1188 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003198 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003199 if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val))
Reid Spencere4d87aa2006-12-23 06:05:41 +00003200 GEN_ERROR("Alignment must be a power of two!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003201 CurGV->setAlignment(yyvsp[0].UInt64Val);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003202 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003203 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003204 break;
3205
3206 case 111:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003207#line 1204 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003208 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003209 yyval.TypeVal = new PATypeHolder(OpaqueType::get());
Reid Spencera132e042006-12-03 05:46:11 +00003210 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003211 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003212 break;
3213
3214 case 112:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003215#line 1208 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003216 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003217 yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
Reid Spencer6f407902007-01-13 05:00:46 +00003218 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003219 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003220 break;
3221
3222 case 113:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003223#line 1212 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003224 { // Pointer type?
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003225 if (*yyvsp[-1].TypeVal == Type::LabelTy)
Reid Spencer6f407902007-01-13 05:00:46 +00003226 GEN_ERROR("Cannot form a pointer to a basic block");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003227 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal)));
3228 delete yyvsp[-1].TypeVal;
Reid Spencera132e042006-12-03 05:46:11 +00003229 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003230 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003231 break;
3232
3233 case 114:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003234#line 1219 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003235 { // Named types are also simple types...
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003236 const Type* tmp = getTypeVal(yyvsp[0].ValIDVal);
Reid Spencer14310612006-12-31 05:40:51 +00003237 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003238 yyval.TypeVal = new PATypeHolder(tmp);
3239 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003240 break;
3241
3242 case 115:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003243#line 1224 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003244 { // Type UpReference
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003245 if (yyvsp[0].UInt64Val > (uint64_t)~0U) GEN_ERROR("Value out of range!");
Reid Spencer3da59db2006-11-27 01:05:10 +00003246 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003247 UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector...
3248 yyval.TypeVal = new PATypeHolder(OT);
Reid Spencer3da59db2006-11-27 01:05:10 +00003249 UR_OUT("New Upreference!\n");
Reid Spencer61c83e02006-08-18 08:43:06 +00003250 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003251 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003252 break;
3253
3254 case 116:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003255#line 1232 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003256 {
Reid Spencer3da59db2006-11-27 01:05:10 +00003257 std::vector<const Type*> Params;
Reid Spencer14310612006-12-31 05:40:51 +00003258 std::vector<FunctionType::ParameterAttributes> Attrs;
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003259 Attrs.push_back(yyvsp[0].ParamAttrs);
3260 for (TypeWithAttrsList::iterator I=yyvsp[-2].TypeWithAttrsList->begin(), E=yyvsp[-2].TypeWithAttrsList->end(); I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00003261 Params.push_back(I->Ty->get());
3262 if (I->Ty->get() != Type::VoidTy)
3263 Attrs.push_back(I->Attrs);
3264 }
Reid Spencer3da59db2006-11-27 01:05:10 +00003265 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3266 if (isVarArg) Params.pop_back();
3267
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003268 FunctionType *FT = FunctionType::get(*yyvsp[-4].TypeVal, Params, isVarArg, Attrs);
3269 delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list
3270 delete yyvsp[-4].TypeVal; // Delete the return type handle
3271 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT));
Reid Spencer6f407902007-01-13 05:00:46 +00003272 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003273 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003274 break;
3275
3276 case 117:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003277#line 1250 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003278 {
Reid Spencer6f407902007-01-13 05:00:46 +00003279 std::vector<const Type*> Params;
3280 std::vector<FunctionType::ParameterAttributes> Attrs;
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003281 Attrs.push_back(yyvsp[0].ParamAttrs);
3282 for (TypeWithAttrsList::iterator I=yyvsp[-2].TypeWithAttrsList->begin(), E=yyvsp[-2].TypeWithAttrsList->end(); I != E; ++I) {
Reid Spencer6f407902007-01-13 05:00:46 +00003283 Params.push_back(I->Ty->get());
3284 if (I->Ty->get() != Type::VoidTy)
3285 Attrs.push_back(I->Attrs);
3286 }
3287 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3288 if (isVarArg) Params.pop_back();
3289
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003290 FunctionType *FT = FunctionType::get(yyvsp[-4].PrimType, Params, isVarArg, Attrs);
3291 delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list
3292 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT));
Reid Spencere4d87aa2006-12-23 06:05:41 +00003293 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003294 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003295 break;
3296
3297 case 118:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003298#line 1268 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003299 { // Sized array type?
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003300 yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
3301 delete yyvsp[-1].TypeVal;
Reid Spencer14310612006-12-31 05:40:51 +00003302 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003303 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003304 break;
3305
3306 case 119:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003307#line 1273 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003308 { // Packed array type?
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003309 const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
3310 if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val)
Reid Spencere4d87aa2006-12-23 06:05:41 +00003311 GEN_ERROR("Unsigned result not equal to signed result");
Chris Lattner42a75512007-01-15 02:27:26 +00003312 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
Reid Spencera54b7cb2007-01-12 07:05:14 +00003313 GEN_ERROR("Element type of a PackedType must be primitive");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003314 if (!isPowerOf2_32(yyvsp[-3].UInt64Val))
Reid Spencere4d87aa2006-12-23 06:05:41 +00003315 GEN_ERROR("Vector length should be a power of 2!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003316 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PackedType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
3317 delete yyvsp[-1].TypeVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00003318 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003319 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003320 break;
3321
3322 case 120:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003323#line 1285 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003324 { // Structure type?
Reid Spencere4d87aa2006-12-23 06:05:41 +00003325 std::vector<const Type*> Elements;
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003326 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
3327 E = yyvsp[-1].TypeList->end(); I != E; ++I)
Reid Spencere4d87aa2006-12-23 06:05:41 +00003328 Elements.push_back(*I);
3329
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003330 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
3331 delete yyvsp[-1].TypeList;
Reid Spencere4d87aa2006-12-23 06:05:41 +00003332 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003333 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003334 break;
3335
3336 case 121:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003337#line 1295 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003338 { // Empty structure type?
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003339 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencere4d87aa2006-12-23 06:05:41 +00003340 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003341 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003342 break;
3343
3344 case 122:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003345#line 1299 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003346 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00003347 std::vector<const Type*> Elements;
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003348 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-2].TypeList->begin(),
3349 E = yyvsp[-2].TypeList->end(); I != E; ++I)
Reid Spencere4d87aa2006-12-23 06:05:41 +00003350 Elements.push_back(*I);
3351
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003352 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
3353 delete yyvsp[-2].TypeList;
Reid Spencere4d87aa2006-12-23 06:05:41 +00003354 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003355 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003356 break;
3357
3358 case 123:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003359#line 1309 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003360 { // Empty structure type?
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003361 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Reid Spencere4d87aa2006-12-23 06:05:41 +00003362 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003363 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003364 break;
3365
3366 case 124:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003367#line 1316 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003368 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003369 yyval.TypeWithAttrs.Ty = yyvsp[-1].TypeVal;
3370 yyval.TypeWithAttrs.Attrs = yyvsp[0].ParamAttrs;
3371 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003372 break;
3373
3374 case 125:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003375#line 1323 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003376 {
Reid Spencer6f407902007-01-13 05:00:46 +00003377 if (!UpRefs.empty())
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003378 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
3379 if (!(*yyvsp[0].TypeVal)->isFirstClassType())
Reid Spencer6f407902007-01-13 05:00:46 +00003380 GEN_ERROR("LLVM functions cannot return aggregate types!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003381 yyval.TypeVal = yyvsp[0].TypeVal;
3382 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003383 break;
3384
3385 case 126:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003386#line 1330 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003387 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003388 yyval.TypeVal = new PATypeHolder(Type::VoidTy);
3389 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003390 break;
3391
3392 case 127:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003393#line 1335 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003394 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003395 yyval.TypeWithAttrsList = new TypeWithAttrsList();
3396 yyval.TypeWithAttrsList->push_back(yyvsp[0].TypeWithAttrs);
Reid Spencer14310612006-12-31 05:40:51 +00003397 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003398 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003399 break;
3400
3401 case 128:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003402#line 1340 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003403 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003404 (yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList)->push_back(yyvsp[0].TypeWithAttrs);
Reid Spencer14310612006-12-31 05:40:51 +00003405 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003406 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003407 break;
3408
3409 case 130:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003410#line 1348 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003411 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003412 yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList;
Reid Spencer14310612006-12-31 05:40:51 +00003413 TypeWithAttrs TWA; TWA.Attrs = FunctionType::NoAttributeSet;
3414 TWA.Ty = new PATypeHolder(Type::VoidTy);
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003415 yyval.TypeWithAttrsList->push_back(TWA);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003416 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003417 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003418 break;
3419
3420 case 131:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003421#line 1355 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003422 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003423 yyval.TypeWithAttrsList = new TypeWithAttrsList;
Reid Spencer14310612006-12-31 05:40:51 +00003424 TypeWithAttrs TWA; TWA.Attrs = FunctionType::NoAttributeSet;
3425 TWA.Ty = new PATypeHolder(Type::VoidTy);
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003426 yyval.TypeWithAttrsList->push_back(TWA);
Reid Spencer14310612006-12-31 05:40:51 +00003427 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003428 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003429 break;
3430
3431 case 132:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003432#line 1362 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003433 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003434 yyval.TypeWithAttrsList = new TypeWithAttrsList();
Reid Spencer14310612006-12-31 05:40:51 +00003435 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003436 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003437 break;
3438
3439 case 133:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003440#line 1370 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003441 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003442 yyval.TypeList = new std::list<PATypeHolder>();
3443 yyval.TypeList->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
Reid Spencer6f407902007-01-13 05:00:46 +00003444 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003445 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003446 break;
3447
3448 case 134:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003449#line 1375 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003450 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003451 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
Reid Spencer3da59db2006-11-27 01:05:10 +00003452 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003453 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003454 break;
3455
3456 case 135:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003457#line 1386 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003458 { // Nonempty unsized arr
Reid Spencer6f407902007-01-13 05:00:46 +00003459 if (!UpRefs.empty())
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003460 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
3461 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
Reid Spencer6f407902007-01-13 05:00:46 +00003462 if (ATy == 0)
3463 GEN_ERROR("Cannot make array constant with type: '" +
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003464 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
Reid Spencer6f407902007-01-13 05:00:46 +00003465 const Type *ETy = ATy->getElementType();
3466 int NumElements = ATy->getNumElements();
3467
3468 // Verify that we have the correct size...
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003469 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
Reid Spencer6f407902007-01-13 05:00:46 +00003470 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003471 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
Reid Spencer6f407902007-01-13 05:00:46 +00003472 itostr(NumElements) + "!");
3473
3474 // Verify all elements are correct type!
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003475 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3476 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Reid Spencer6f407902007-01-13 05:00:46 +00003477 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3478 ETy->getDescription() +"' as required!\nIt is of type '"+
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003479 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Reid Spencer6f407902007-01-13 05:00:46 +00003480 }
3481
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003482 yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
3483 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Reid Spencer3da59db2006-11-27 01:05:10 +00003484 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003485 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003486 break;
3487
3488 case 136:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003489#line 1414 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003490 {
Reid Spencer14310612006-12-31 05:40:51 +00003491 if (!UpRefs.empty())
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003492 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3493 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003494 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003495 GEN_ERROR("Cannot make array constant with type: '" +
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003496 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003497
Andrew Lenharth6353e052006-12-08 18:07:09 +00003498 int NumElements = ATy->getNumElements();
3499 if (NumElements != -1 && NumElements != 0)
3500 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
3501 " arguments, but has size of " + itostr(NumElements) +"!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003502 yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
3503 delete yyvsp[-2].TypeVal;
Reid Spencer6f407902007-01-13 05:00:46 +00003504 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003505 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003506 break;
3507
3508 case 137:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003509#line 1430 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003510 {
Reid Spencer6f407902007-01-13 05:00:46 +00003511 if (!UpRefs.empty())
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003512 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3513 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
Reid Spencer6f407902007-01-13 05:00:46 +00003514 if (ATy == 0)
3515 GEN_ERROR("Cannot make array constant with type: '" +
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003516 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
Reid Spencer6f407902007-01-13 05:00:46 +00003517
3518 int NumElements = ATy->getNumElements();
3519 const Type *ETy = ATy->getElementType();
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003520 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
3521 if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal))
Reid Spencer6f407902007-01-13 05:00:46 +00003522 GEN_ERROR("Can't build string constant of size " +
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003523 itostr((int)(EndStr-yyvsp[0].StrVal)) +
Reid Spencer6f407902007-01-13 05:00:46 +00003524 " when array has size " + itostr(NumElements) + "!");
3525 std::vector<Constant*> Vals;
3526 if (ETy == Type::Int8Ty) {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003527 for (unsigned char *C = (unsigned char *)yyvsp[0].StrVal;
Reid Spencer6f407902007-01-13 05:00:46 +00003528 C != (unsigned char*)EndStr; ++C)
3529 Vals.push_back(ConstantInt::get(ETy, *C));
3530 } else {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003531 free(yyvsp[0].StrVal);
Reid Spencer6f407902007-01-13 05:00:46 +00003532 GEN_ERROR("Cannot build string arrays of non byte sized elements!");
3533 }
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003534 free(yyvsp[0].StrVal);
3535 yyval.ConstVal = ConstantArray::get(ATy, Vals);
3536 delete yyvsp[-2].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00003537 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003538 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003539 break;
3540
3541 case 138:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003542#line 1459 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003543 { // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00003544 if (!UpRefs.empty())
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003545 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
3546 const PackedType *PTy = dyn_cast<PackedType>(yyvsp[-3].TypeVal->get());
Reid Spencer6f407902007-01-13 05:00:46 +00003547 if (PTy == 0)
3548 GEN_ERROR("Cannot make packed constant with type: '" +
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003549 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
Reid Spencer6f407902007-01-13 05:00:46 +00003550 const Type *ETy = PTy->getElementType();
3551 int NumElements = PTy->getNumElements();
Reid Spencer61c83e02006-08-18 08:43:06 +00003552
Reid Spencer6f407902007-01-13 05:00:46 +00003553 // Verify that we have the correct size...
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003554 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
Reid Spencer6f407902007-01-13 05:00:46 +00003555 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003556 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
Reid Spencer6f407902007-01-13 05:00:46 +00003557 itostr(NumElements) + "!");
3558
3559 // Verify all elements are correct type!
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003560 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3561 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Reid Spencer6f407902007-01-13 05:00:46 +00003562 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3563 ETy->getDescription() +"' as required!\nIt is of type '"+
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003564 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Andrew Lenharth6353e052006-12-08 18:07:09 +00003565 }
Reid Spencer6f407902007-01-13 05:00:46 +00003566
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003567 yyval.ConstVal = ConstantPacked::get(PTy, *yyvsp[-1].ConstVector);
3568 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Reid Spencer61c83e02006-08-18 08:43:06 +00003569 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003570 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003571 break;
3572
3573 case 139:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003574#line 1487 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003575 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003576 const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
Reid Spencer6f407902007-01-13 05:00:46 +00003577 if (STy == 0)
3578 GEN_ERROR("Cannot make struct constant with type: '" +
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003579 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003580
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003581 if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
Reid Spencer6f407902007-01-13 05:00:46 +00003582 GEN_ERROR("Illegal number of initializers for structure type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003583
Reid Spencer6f407902007-01-13 05:00:46 +00003584 // Check to ensure that constants are compatible with the type initializer!
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003585 for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
3586 if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
Reid Spencer6f407902007-01-13 05:00:46 +00003587 GEN_ERROR("Expected type '" +
3588 STy->getElementType(i)->getDescription() +
3589 "' for element #" + utostr(i) +
3590 " of structure initializer!");
Andrew Lenharth6353e052006-12-08 18:07:09 +00003591
Reid Spencer6f407902007-01-13 05:00:46 +00003592 // Check to ensure that Type is not packed
3593 if (STy->isPacked())
3594 GEN_ERROR("Unpacked Initializer to packed type '" + STy->getDescription() + "'");
3595
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003596 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
3597 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Reid Spencer61c83e02006-08-18 08:43:06 +00003598 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003599 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003600 break;
3601
3602 case 140:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003603#line 1512 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003604 {
Reid Spencer6f407902007-01-13 05:00:46 +00003605 if (!UpRefs.empty())
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003606 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3607 const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
Andrew Lenharth6353e052006-12-08 18:07:09 +00003608 if (STy == 0)
3609 GEN_ERROR("Cannot make struct constant with type: '" +
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003610 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003611
Reid Spencer6f407902007-01-13 05:00:46 +00003612 if (STy->getNumContainedTypes() != 0)
Andrew Lenharth6353e052006-12-08 18:07:09 +00003613 GEN_ERROR("Illegal number of initializers for structure type!");
3614
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003615 // Check to ensure that Type is not packed
3616 if (STy->isPacked())
3617 GEN_ERROR("Unpacked Initializer to packed type '" + STy->getDescription() + "'");
3618
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003619 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
3620 delete yyvsp[-2].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00003621 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003622 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003623 break;
3624
3625 case 141:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003626#line 1531 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003627 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003628 const StructType *STy = dyn_cast<StructType>(yyvsp[-5].TypeVal->get());
Andrew Lenharth6353e052006-12-08 18:07:09 +00003629 if (STy == 0)
3630 GEN_ERROR("Cannot make struct constant with type: '" +
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003631 (*yyvsp[-5].TypeVal)->getDescription() + "'!");
Andrew Lenharth6353e052006-12-08 18:07:09 +00003632
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003633 if (yyvsp[-2].ConstVector->size() != STy->getNumContainedTypes())
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003634 GEN_ERROR("Illegal number of initializers for structure type!");
3635
3636 // Check to ensure that constants are compatible with the type initializer!
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003637 for (unsigned i = 0, e = yyvsp[-2].ConstVector->size(); i != e; ++i)
3638 if ((*yyvsp[-2].ConstVector)[i]->getType() != STy->getElementType(i))
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003639 GEN_ERROR("Expected type '" +
3640 STy->getElementType(i)->getDescription() +
3641 "' for element #" + utostr(i) +
3642 " of structure initializer!");
3643
3644 // Check to ensure that Type is packed
3645 if (!STy->isPacked())
3646 GEN_ERROR("Packed Initializer to unpacked type '" + STy->getDescription() + "'");
3647
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003648 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-2].ConstVector);
3649 delete yyvsp[-5].TypeVal; delete yyvsp[-2].ConstVector;
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003650 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003651 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003652 break;
3653
3654 case 142:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003655#line 1556 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003656 {
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003657 if (!UpRefs.empty())
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003658 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
3659 const StructType *STy = dyn_cast<StructType>(yyvsp[-4].TypeVal->get());
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003660 if (STy == 0)
3661 GEN_ERROR("Cannot make struct constant with type: '" +
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003662 (*yyvsp[-4].TypeVal)->getDescription() + "'!");
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003663
3664 if (STy->getNumContainedTypes() != 0)
3665 GEN_ERROR("Illegal number of initializers for structure type!");
3666
3667 // Check to ensure that Type is packed
3668 if (!STy->isPacked())
3669 GEN_ERROR("Packed Initializer to unpacked type '" + STy->getDescription() + "'");
3670
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003671 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
3672 delete yyvsp[-4].TypeVal;
Reid Spencer6f407902007-01-13 05:00:46 +00003673 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003674 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003675 break;
3676
3677 case 143:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003678#line 1575 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003679 {
Reid Spencer6f407902007-01-13 05:00:46 +00003680 if (!UpRefs.empty())
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003681 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3682 const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
Reid Spencer6f407902007-01-13 05:00:46 +00003683 if (PTy == 0)
3684 GEN_ERROR("Cannot make null pointer constant with type: '" +
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003685 (*yyvsp[-1].TypeVal)->getDescription() + "'!");
Reid Spencer6f407902007-01-13 05:00:46 +00003686
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003687 yyval.ConstVal = ConstantPointerNull::get(PTy);
3688 delete yyvsp[-1].TypeVal;
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003689 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003690 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003691 break;
3692
3693 case 144:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003694#line 1587 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003695 {
Reid Spencer14310612006-12-31 05:40:51 +00003696 if (!UpRefs.empty())
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003697 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3698 yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
3699 delete yyvsp[-1].TypeVal;
Andrew Lenharth6353e052006-12-08 18:07:09 +00003700 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003701 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003702 break;
3703
3704 case 145:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003705#line 1594 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003706 {
Reid Spencer14310612006-12-31 05:40:51 +00003707 if (!UpRefs.empty())
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003708 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3709 const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003710 if (Ty == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003711 GEN_ERROR("Global const reference must be a pointer type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003712
3713 // ConstExprs can exist in the body of a function, thus creating
3714 // GlobalValues whenever they refer to a variable. Because we are in
3715 // the context of a function, getValNonImprovising will search the functions
3716 // symbol table instead of the module symbol table for the global symbol,
3717 // which throws things all off. To get around this, we just tell
3718 // getValNonImprovising that we are at global scope here.
3719 //
3720 Function *SavedCurFn = CurFun.CurrentFunction;
3721 CurFun.CurrentFunction = 0;
3722
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003723 Value *V = getValNonImprovising(Ty, yyvsp[0].ValIDVal);
Reid Spencer5b7e7532006-09-28 19:28:24 +00003724 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003725
3726 CurFun.CurrentFunction = SavedCurFn;
3727
3728 // If this is an initializer for a constant pointer, which is referencing a
3729 // (currently) undefined variable, create a stub now that shall be replaced
3730 // in the future with the right type of variable.
3731 //
3732 if (V == 0) {
3733 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
3734 const PointerType *PT = cast<PointerType>(Ty);
3735
3736 // First check to see if the forward references value is already created!
3737 PerModuleInfo::GlobalRefsType::iterator I =
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003738 CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003739
3740 if (I != CurModule.GlobalRefs.end()) {
3741 V = I->second; // Placeholder already exists, use it...
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003742 yyvsp[0].ValIDVal.destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003743 } else {
3744 std::string Name;
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003745 if (yyvsp[0].ValIDVal.Type == ValID::NameVal) Name = yyvsp[0].ValIDVal.Name;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003746
3747 // Create the forward referenced global.
3748 GlobalValue *GV;
3749 if (const FunctionType *FTy =
3750 dyn_cast<FunctionType>(PT->getElementType())) {
3751 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
3752 CurModule.CurrentModule);
3753 } else {
3754 GV = new GlobalVariable(PT->getElementType(), false,
3755 GlobalValue::ExternalLinkage, 0,
3756 Name, CurModule.CurrentModule);
3757 }
3758
3759 // Keep track of the fact that we have a forward ref to recycle it
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003760 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003761 V = GV;
3762 }
3763 }
3764
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003765 yyval.ConstVal = cast<GlobalValue>(V);
3766 delete yyvsp[-1].TypeVal; // Free the type handle
Reid Spencer6f407902007-01-13 05:00:46 +00003767 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003768 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003769 break;
3770
3771 case 146:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003772#line 1657 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003773 {
Reid Spencer6f407902007-01-13 05:00:46 +00003774 if (!UpRefs.empty())
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003775 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3776 if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
Reid Spencer6f407902007-01-13 05:00:46 +00003777 GEN_ERROR("Mismatched types for constant expression: " +
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003778 (*yyvsp[-1].TypeVal)->getDescription() + " and " + yyvsp[0].ConstVal->getType()->getDescription());
3779 yyval.ConstVal = yyvsp[0].ConstVal;
3780 delete yyvsp[-1].TypeVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00003781 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003782 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003783 break;
3784
3785 case 147:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003786#line 1667 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003787 {
Reid Spencer14310612006-12-31 05:40:51 +00003788 if (!UpRefs.empty())
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003789 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3790 const Type *Ty = yyvsp[-1].TypeVal->get();
Reid Spencer6f407902007-01-13 05:00:46 +00003791 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
3792 GEN_ERROR("Cannot create a null initialized value of this type!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003793 yyval.ConstVal = Constant::getNullValue(Ty);
3794 delete yyvsp[-1].TypeVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00003795 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003796 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003797 break;
3798
3799 case 148:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003800#line 1677 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003801 { // integral constants
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003802 if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
Reid Spencer6f407902007-01-13 05:00:46 +00003803 GEN_ERROR("Constant value doesn't fit in type!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003804 yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003805 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003806 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003807 break;
3808
3809 case 149:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003810#line 1683 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003811 { // integral constants
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003812 if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
Reid Spencer14310612006-12-31 05:40:51 +00003813 GEN_ERROR("Constant value doesn't fit in type!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003814 yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val);
Reid Spencer14310612006-12-31 05:40:51 +00003815 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003816 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003817 break;
3818
3819 case 150:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003820#line 1689 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003821 { // Boolean constants
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003822 assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?");
3823 yyval.ConstVal = ConstantInt::getTrue();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003824 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003825 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003826 break;
3827
3828 case 151:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003829#line 1694 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003830 { // Boolean constants
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003831 assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?");
3832 yyval.ConstVal = ConstantInt::getFalse();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003833 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003834 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003835 break;
3836
3837 case 152:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003838#line 1699 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003839 { // Float & Double constants
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003840 if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal))
Reid Spencere4d87aa2006-12-23 06:05:41 +00003841 GEN_ERROR("Floating point constant invalid for type!!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003842 yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003843 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003844 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003845 break;
3846
3847 case 153:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003848#line 1707 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003849 {
Reid Spencer14310612006-12-31 05:40:51 +00003850 if (!UpRefs.empty())
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003851 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3852 Constant *Val = yyvsp[-3].ConstVal;
3853 const Type *DestTy = yyvsp[-1].TypeVal->get();
3854 if (!CastInst::castIsValid(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy))
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003855 GEN_ERROR("invalid cast opcode for cast from '" +
3856 Val->getType()->getDescription() + "' to '" +
3857 DestTy->getDescription() + "'!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003858 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy);
3859 delete yyvsp[-1].TypeVal;
3860 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003861 break;
3862
3863 case 154:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003864#line 1719 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003865 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003866 if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
Andrew Lenharth6353e052006-12-08 18:07:09 +00003867 GEN_ERROR("GetElementPtr requires a pointer operand!");
3868
3869 const Type *IdxTy =
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003870 GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), *yyvsp[-1].ValueList, true);
Andrew Lenharth6353e052006-12-08 18:07:09 +00003871 if (!IdxTy)
3872 GEN_ERROR("Index list invalid for constant getelementptr!");
3873
3874 std::vector<Constant*> IdxVec;
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003875 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
3876 if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
Andrew Lenharth6353e052006-12-08 18:07:09 +00003877 IdxVec.push_back(C);
3878 else
3879 GEN_ERROR("Indices to constant getelementptr must be constants!");
3880
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003881 delete yyvsp[-1].ValueList;
Andrew Lenharth6353e052006-12-08 18:07:09 +00003882
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003883 yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, IdxVec);
Reid Spencer6f407902007-01-13 05:00:46 +00003884 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003885 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003886 break;
3887
3888 case 155:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003889#line 1740 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003890 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003891 if (yyvsp[-5].ConstVal->getType() != Type::Int1Ty)
Reid Spencer6f407902007-01-13 05:00:46 +00003892 GEN_ERROR("Select condition must be of boolean type!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003893 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Reid Spencer6f407902007-01-13 05:00:46 +00003894 GEN_ERROR("Select operand types must match!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003895 yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003896 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003897 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003898 break;
3899
3900 case 156:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003901#line 1748 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003902 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003903 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Reid Spencer6f407902007-01-13 05:00:46 +00003904 GEN_ERROR("Binary operator types must match!");
3905 CHECK_FOR_ERROR;
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003906 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3907 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003908 break;
3909
3910 case 157:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003911#line 1754 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003912 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003913 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Reid Spencere4d87aa2006-12-23 06:05:41 +00003914 GEN_ERROR("Logical operator types must match!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003915 if (!yyvsp[-3].ConstVal->getType()->isInteger()) {
3916 if (!isa<PackedType>(yyvsp[-3].ConstVal->getType()) ||
3917 !cast<PackedType>(yyvsp[-3].ConstVal->getType())->getElementType()->isInteger())
Reid Spencere4d87aa2006-12-23 06:05:41 +00003918 GEN_ERROR("Logical operator requires integral operands!");
3919 }
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003920 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003921 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003922 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003923 break;
3924
3925 case 158:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003926#line 1765 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003927 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003928 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Reid Spencere4d87aa2006-12-23 06:05:41 +00003929 GEN_ERROR("icmp operand types must match!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003930 yyval.ConstVal = ConstantExpr::getICmp(yyvsp[-5].IPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3931 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003932 break;
3933
3934 case 159:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003935#line 1770 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003936 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003937 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Reid Spencer6f407902007-01-13 05:00:46 +00003938 GEN_ERROR("fcmp operand types must match!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003939 yyval.ConstVal = ConstantExpr::getFCmp(yyvsp[-5].FPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3940 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003941 break;
3942
3943 case 160:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003944#line 1775 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003945 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003946 if (yyvsp[-1].ConstVal->getType() != Type::Int8Ty)
Reid Spencer6f407902007-01-13 05:00:46 +00003947 GEN_ERROR("Shift count for shift constant must be i8 type!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003948 if (!yyvsp[-3].ConstVal->getType()->isInteger())
Reid Spencer6f407902007-01-13 05:00:46 +00003949 GEN_ERROR("Shift constant expression requires integer operand!");
3950 CHECK_FOR_ERROR;
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003951 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].OtherOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer6f407902007-01-13 05:00:46 +00003952 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003953 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003954 break;
3955
3956 case 161:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003957#line 1784 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003958 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003959 if (!ExtractElementInst::isValidOperands(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Reid Spencer6f407902007-01-13 05:00:46 +00003960 GEN_ERROR("Invalid extractelement operands!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003961 yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00003962 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003963 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003964 break;
3965
3966 case 162:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003967#line 1790 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003968 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003969 if (!InsertElementInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Reid Spencer6f407902007-01-13 05:00:46 +00003970 GEN_ERROR("Invalid insertelement operands!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003971 yyval.ConstVal = ConstantExpr::getInsertElement(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003972 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003973 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003974 break;
3975
3976 case 163:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003977#line 1796 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003978 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003979 if (!ShuffleVectorInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Reid Spencer6f407902007-01-13 05:00:46 +00003980 GEN_ERROR("Invalid shufflevector operands!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003981 yyval.ConstVal = ConstantExpr::getShuffleVector(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003982 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003983 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003984 break;
3985
3986 case 164:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003987#line 1805 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003988 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003989 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00003990 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003991 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003992 break;
3993
3994 case 165:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003995#line 1809 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003996 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00003997 yyval.ConstVector = new std::vector<Constant*>();
3998 yyval.ConstVector->push_back(yyvsp[0].ConstVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00003999 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004000 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004001 break;
4002
4003 case 166:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004004#line 1817 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
4005 { yyval.BoolVal = false; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004006 break;
4007
4008 case 167:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004009#line 1817 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
4010 { yyval.BoolVal = true; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004011 break;
4012
4013 case 168:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004014#line 1828 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004015 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004016 yyval.ModuleVal = ParserResult = CurModule.CurrentModule;
Reid Spencer6f407902007-01-13 05:00:46 +00004017 CurModule.ModuleDone();
4018 CHECK_FOR_ERROR;
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004019 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004020 break;
4021
4022 case 169:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004023#line 1833 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004024 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004025 yyval.ModuleVal = ParserResult = CurModule.CurrentModule;
Reid Spencer14310612006-12-31 05:40:51 +00004026 CurModule.ModuleDone();
4027 CHECK_FOR_ERROR;
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004028 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004029 break;
4030
4031 case 172:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004032#line 1846 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
4033 { CurFun.isDeclare = false; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004034 break;
4035
4036 case 173:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004037#line 1846 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004038 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004039 CurFun.FunctionDone();
Reid Spencer61c83e02006-08-18 08:43:06 +00004040 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004041 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004042 break;
4043
4044 case 174:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004045#line 1850 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
4046 { CurFun.isDeclare = true; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004047 break;
4048
4049 case 175:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004050#line 1850 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004051 {
Reid Spencer6f407902007-01-13 05:00:46 +00004052 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004053 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004054 break;
4055
4056 case 176:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004057#line 1853 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004058 {
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004059 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004060 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004061 break;
4062
4063 case 177:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004064#line 1856 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004065 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004066 // Emit an error if there are any unresolved types left.
4067 if (!CurModule.LateResolveTypes.empty()) {
4068 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
Reid Spencer61c83e02006-08-18 08:43:06 +00004069 if (DID.Type == ValID::NameVal) {
4070 GEN_ERROR("Reference to an undefined type: '"+DID.getName() + "'");
4071 } else {
4072 GEN_ERROR("Reference to an undefined type: #" + itostr(DID.Num));
4073 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004074 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004075 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004076 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004077 break;
4078
4079 case 178:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004080#line 1868 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004081 {
Reid Spencer14310612006-12-31 05:40:51 +00004082 if (!UpRefs.empty())
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004083 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004084 // Eagerly resolve types. This is not an optimization, this is a
4085 // requirement that is due to the fact that we could have this:
4086 //
4087 // %list = type { %list * }
4088 // %list = type { %list * } ; repeated type decl
4089 //
4090 // If types are not resolved eagerly, then the two types will not be
4091 // determined to be the same type!
4092 //
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004093 ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004094
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004095 if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00004096 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004097 // If this is a named type that is not a redefinition, add it to the slot
4098 // table.
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004099 CurModule.Types.push_back(*yyvsp[0].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004100 }
Reid Spencera132e042006-12-03 05:46:11 +00004101
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004102 delete yyvsp[0].TypeVal;
Reid Spencer6f407902007-01-13 05:00:46 +00004103 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004104 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004105 break;
Reid Spencer6f407902007-01-13 05:00:46 +00004106
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004107 case 179:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004108#line 1892 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004109 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004110 ResolveTypeTo(yyvsp[-2].StrVal, yyvsp[0].PrimType);
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004111
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004112 if (!setTypeName(yyvsp[0].PrimType, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
Reid Spencer6f407902007-01-13 05:00:46 +00004113 CHECK_FOR_ERROR
4114 // If this is a named type that is not a redefinition, add it to the slot
4115 // table.
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004116 CurModule.Types.push_back(yyvsp[0].PrimType);
Reid Spencer6f407902007-01-13 05:00:46 +00004117 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004118 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004119 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004120 break;
4121
4122 case 180:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004123#line 1903 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004124 { /* "Externally Visible" Linkage */
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004125 if (yyvsp[0].ConstVal == 0)
Reid Spencer6f407902007-01-13 05:00:46 +00004126 GEN_ERROR("Global value initializer is not a constant!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004127 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalLinkage,
4128 yyvsp[-2].Visibility, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal);
Reid Spencer14310612006-12-31 05:40:51 +00004129 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004130 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004131 break;
4132
4133 case 181:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004134#line 1909 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004135 {
Reid Spencer6f407902007-01-13 05:00:46 +00004136 CurGV = 0;
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004137 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004138 break;
4139
4140 case 182:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004141#line 1912 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004142 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004143 if (yyvsp[0].ConstVal == 0)
Reid Spencer6f407902007-01-13 05:00:46 +00004144 GEN_ERROR("Global value initializer is not a constant!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004145 CurGV = ParseGlobalVariable(yyvsp[-4].StrVal, yyvsp[-3].Linkage, yyvsp[-2].Visibility, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal);
Reid Spencer6f407902007-01-13 05:00:46 +00004146 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004147 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004148 break;
4149
4150 case 183:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004151#line 1917 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004152 {
Reid Spencer6f407902007-01-13 05:00:46 +00004153 CurGV = 0;
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004154 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004155 break;
4156
4157 case 184:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004158#line 1920 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004159 {
Reid Spencer6f407902007-01-13 05:00:46 +00004160 if (!UpRefs.empty())
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004161 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
4162 CurGV = ParseGlobalVariable(yyvsp[-4].StrVal, yyvsp[-3].Linkage, yyvsp[-2].Visibility, yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0);
Reid Spencer6f407902007-01-13 05:00:46 +00004163 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004164 delete yyvsp[0].TypeVal;
4165 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004166 break;
4167
4168 case 185:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004169#line 1926 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004170 {
Reid Spencere4d87aa2006-12-23 06:05:41 +00004171 CurGV = 0;
4172 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004173 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004174 break;
4175
4176 case 186:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004177#line 1930 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004178 {
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004179 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004180 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004181 break;
4182
4183 case 187:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004184#line 1933 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004185 {
Reid Spencer218ded22007-01-05 17:07:23 +00004186 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004187 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004188 break;
4189
4190 case 188:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004191#line 1939 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004192 {
Chris Lattner66316012006-01-24 04:14:29 +00004193 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004194 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
4195 std::string NewAsm(yyvsp[0].StrVal, EndStr);
4196 free(yyvsp[0].StrVal);
Chris Lattner66316012006-01-24 04:14:29 +00004197
4198 if (AsmSoFar.empty())
4199 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
4200 else
4201 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Reid Spencer61c83e02006-08-18 08:43:06 +00004202 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004203}
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004204 break;
4205
4206 case 189:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004207#line 1952 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
4208 { yyval.Endianness = Module::BigEndian; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004209 break;
4210
4211 case 190:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004212#line 1953 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
4213 { yyval.Endianness = Module::LittleEndian; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004214 break;
4215
4216 case 191:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004217#line 1955 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004218 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004219 CurModule.CurrentModule->setEndianness(yyvsp[0].Endianness);
Reid Spencer6f407902007-01-13 05:00:46 +00004220 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004221 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004222 break;
4223
4224 case 192:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004225#line 1959 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004226 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004227 if (yyvsp[0].UInt64Val == 32)
Reid Spencer6f407902007-01-13 05:00:46 +00004228 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004229 else if (yyvsp[0].UInt64Val == 64)
Reid Spencer6f407902007-01-13 05:00:46 +00004230 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
4231 else
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004232 GEN_ERROR("Invalid pointer size: '" + utostr(yyvsp[0].UInt64Val) + "'!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00004233 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004234 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004235 break;
4236
4237 case 193:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004238#line 1968 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004239 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004240 CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal);
4241 free(yyvsp[0].StrVal);
4242 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004243 break;
4244
4245 case 194:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004246#line 1972 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004247 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004248 CurModule.CurrentModule->setDataLayout(yyvsp[0].StrVal);
4249 free(yyvsp[0].StrVal);
4250 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004251 break;
4252
4253 case 196:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004254#line 1979 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004255 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004256 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
4257 free(yyvsp[0].StrVal);
Reid Spencer6f407902007-01-13 05:00:46 +00004258 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004259 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004260 break;
4261
4262 case 197:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004263#line 1984 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004264 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004265 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
4266 free(yyvsp[0].StrVal);
Reid Spencera54b7cb2007-01-12 07:05:14 +00004267 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004268 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004269 break;
4270
4271 case 198:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004272#line 1989 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004273 {
Reid Spencera54b7cb2007-01-12 07:05:14 +00004274 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004275 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004276 break;
4277
4278 case 202:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004279#line 1999 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
4280 { yyval.StrVal = 0; }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004281 break;
4282
4283 case 203:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004284#line 2001 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004285 {
Reid Spencer14310612006-12-31 05:40:51 +00004286 if (!UpRefs.empty())
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004287 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4288 if (*yyvsp[-2].TypeVal == Type::VoidTy)
Reid Spencer14310612006-12-31 05:40:51 +00004289 GEN_ERROR("void typed arguments are invalid!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004290 ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal;
4291 yyval.ArgList = yyvsp[-4].ArgList;
4292 yyvsp[-4].ArgList->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00004293 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004294 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004295 break;
4296
4297 case 204:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004298#line 2011 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004299 {
Reid Spencer14310612006-12-31 05:40:51 +00004300 if (!UpRefs.empty())
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004301 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4302 if (*yyvsp[-2].TypeVal == Type::VoidTy)
Reid Spencer14310612006-12-31 05:40:51 +00004303 GEN_ERROR("void typed arguments are invalid!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004304 ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal;
4305 yyval.ArgList = new ArgListType;
4306 yyval.ArgList->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00004307 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004308 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004309 break;
4310
4311 case 205:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004312#line 2022 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004313 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004314 yyval.ArgList = yyvsp[0].ArgList;
Reid Spencer6f407902007-01-13 05:00:46 +00004315 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004316 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004317 break;
4318
4319 case 206:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004320#line 2026 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004321 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004322 yyval.ArgList = yyvsp[-2].ArgList;
Reid Spencer6f407902007-01-13 05:00:46 +00004323 struct ArgListEntry E;
4324 E.Ty = new PATypeHolder(Type::VoidTy);
4325 E.Name = 0;
4326 E.Attrs = FunctionType::NoAttributeSet;
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004327 yyval.ArgList->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00004328 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004329 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004330 break;
4331
4332 case 207:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004333#line 2035 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004334 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004335 yyval.ArgList = new ArgListType;
Reid Spencer14310612006-12-31 05:40:51 +00004336 struct ArgListEntry E;
4337 E.Ty = new PATypeHolder(Type::VoidTy);
4338 E.Name = 0;
4339 E.Attrs = FunctionType::NoAttributeSet;
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004340 yyval.ArgList->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00004341 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004342 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004343 break;
4344
4345 case 208:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004346#line 2044 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004347 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004348 yyval.ArgList = 0;
Andrew Lenharth6353e052006-12-08 18:07:09 +00004349 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004350 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004351 break;
4352
4353 case 209:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004354#line 2050 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004355 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004356 UnEscapeLexed(yyvsp[-6].StrVal);
4357 std::string FunctionName(yyvsp[-6].StrVal);
4358 free(yyvsp[-6].StrVal); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004359
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004360 // Check the function result for abstractness if this is a define. We should
4361 // have no abstract types at this point
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004362 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(yyvsp[-7].TypeVal))
4363 GEN_ERROR("Reference to abstract result: "+ yyvsp[-7].TypeVal->get()->getDescription());
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004364
Reid Spencer68a24bd2005-08-27 18:50:39 +00004365 std::vector<const Type*> ParamTypeList;
Reid Spencer14310612006-12-31 05:40:51 +00004366 std::vector<FunctionType::ParameterAttributes> ParamAttrs;
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004367 ParamAttrs.push_back(yyvsp[-2].ParamAttrs);
4368 if (yyvsp[-4].ArgList) { // If there are arguments...
4369 for (ArgListType::iterator I = yyvsp[-4].ArgList->begin(); I != yyvsp[-4].ArgList->end(); ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00004370 const Type* Ty = I->Ty->get();
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004371 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
4372 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00004373 ParamTypeList.push_back(Ty);
4374 if (Ty != Type::VoidTy)
4375 ParamAttrs.push_back(I->Attrs);
4376 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004377 }
4378
4379 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
4380 if (isVarArg) ParamTypeList.pop_back();
4381
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004382 FunctionType *FT = FunctionType::get(*yyvsp[-7].TypeVal, ParamTypeList, isVarArg,
Reid Spencer14310612006-12-31 05:40:51 +00004383 ParamAttrs);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004384 const PointerType *PFT = PointerType::get(FT);
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004385 delete yyvsp[-7].TypeVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004386
4387 ValID ID;
4388 if (!FunctionName.empty()) {
4389 ID = ValID::create((char*)FunctionName.c_str());
4390 } else {
4391 ID = ValID::create((int)CurModule.Values[PFT].size());
4392 }
4393
4394 Function *Fn = 0;
4395 // See if this function was forward referenced. If so, recycle the object.
4396 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4397 // Move the function to the end of the list, from whereever it was
4398 // previously inserted.
4399 Fn = cast<Function>(FWRef);
4400 CurModule.CurrentModule->getFunctionList().remove(Fn);
4401 CurModule.CurrentModule->getFunctionList().push_back(Fn);
4402 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
4403 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
4404 // If this is the case, either we need to be a forward decl, or it needs
4405 // to be.
4406 if (!CurFun.isDeclare && !Fn->isExternal())
Reid Spencer61c83e02006-08-18 08:43:06 +00004407 GEN_ERROR("Redefinition of function '" + FunctionName + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004408
4409 // Make sure to strip off any argument names so we can't get conflicts.
4410 if (Fn->isExternal())
4411 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
4412 AI != AE; ++AI)
4413 AI->setName("");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004414 } else { // Not already defined?
4415 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
4416 CurModule.CurrentModule);
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004417
Reid Spencer68a24bd2005-08-27 18:50:39 +00004418 InsertValue(Fn, CurModule.Values);
4419 }
4420
4421 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004422
4423 if (CurFun.isDeclare) {
4424 // If we have declaration, always overwrite linkage. This will allow us to
4425 // correctly handle cases, when pointer to function is passed as argument to
4426 // another function.
4427 Fn->setLinkage(CurFun.Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004428 Fn->setVisibility(CurFun.Visibility);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004429 }
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004430 Fn->setCallingConv(yyvsp[-8].UIntVal);
4431 Fn->setAlignment(yyvsp[0].UIntVal);
4432 if (yyvsp[-1].StrVal) {
4433 Fn->setSection(yyvsp[-1].StrVal);
4434 free(yyvsp[-1].StrVal);
Chris Lattnere869eef2005-11-12 00:11:49 +00004435 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004436
4437 // Add all of the arguments we parsed to the function...
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004438 if (yyvsp[-4].ArgList) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00004439 if (isVarArg) { // Nuke the last entry
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004440 assert(yyvsp[-4].ArgList->back().Ty->get() == Type::VoidTy && yyvsp[-4].ArgList->back().Name == 0&&
Reid Spencera132e042006-12-03 05:46:11 +00004441 "Not a varargs marker!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004442 delete yyvsp[-4].ArgList->back().Ty;
4443 yyvsp[-4].ArgList->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00004444 }
4445 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spencer14310612006-12-31 05:40:51 +00004446 unsigned Idx = 1;
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004447 for (ArgListType::iterator I = yyvsp[-4].ArgList->begin(); I != yyvsp[-4].ArgList->end(); ++I, ++ArgIt) {
Reid Spencer14310612006-12-31 05:40:51 +00004448 delete I->Ty; // Delete the typeholder...
4449 setValueName(ArgIt, I->Name); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00004450 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004451 InsertValue(ArgIt);
Reid Spencer14310612006-12-31 05:40:51 +00004452 Idx++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004453 }
Reid Spencera132e042006-12-03 05:46:11 +00004454
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004455 delete yyvsp[-4].ArgList; // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00004456 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004457 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004458}
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004459 break;
4460
4461 case 212:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004462#line 2157 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004463 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004464 yyval.FunctionVal = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004465
4466 // Make sure that we keep track of the linkage type even if there was a
4467 // previous "declare".
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004468 yyval.FunctionVal->setLinkage(yyvsp[-3].Linkage);
4469 yyval.FunctionVal->setVisibility(yyvsp[-2].Visibility);
4470}
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004471 break;
4472
4473 case 215:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004474#line 2168 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004475 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004476 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Andrew Lenharth6353e052006-12-08 18:07:09 +00004477 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004478}
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004479 break;
4480
4481 case 216:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004482#line 2173 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004483 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004484 CurFun.CurrentFunction->setLinkage(yyvsp[-2].Linkage);
4485 CurFun.CurrentFunction->setVisibility(yyvsp[-1].Visibility);
4486 yyval.FunctionVal = CurFun.CurrentFunction;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004487 CurFun.FunctionDone();
Reid Spencer61c83e02006-08-18 08:43:06 +00004488 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004489 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004490 break;
4491
4492 case 217:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004493#line 2185 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004494 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004495 yyval.BoolVal = false;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004496 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004497 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004498 break;
4499
4500 case 218:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004501#line 2189 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004502 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004503 yyval.BoolVal = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004504 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004505 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004506 break;
4507
4508 case 219:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004509#line 2194 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004510 { // A reference to a direct constant
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004511 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
Reid Spencer6f407902007-01-13 05:00:46 +00004512 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004513 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004514 break;
4515
4516 case 220:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004517#line 2198 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004518 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004519 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004520 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004521 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004522 break;
4523
4524 case 221:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004525#line 2202 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004526 { // Perhaps it's an FP constant?
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004527 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004528 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004529 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004530 break;
4531
4532 case 222:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004533#line 2206 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004534 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004535 yyval.ValIDVal = ValID::create(ConstantInt::getTrue());
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004536 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004537 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004538 break;
4539
4540 case 223:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004541#line 2210 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004542 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004543 yyval.ValIDVal = ValID::create(ConstantInt::getFalse());
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004544 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004545 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004546 break;
4547
4548 case 224:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004549#line 2214 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004550 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004551 yyval.ValIDVal = ValID::createNull();
Reid Spencer61c83e02006-08-18 08:43:06 +00004552 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004553 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004554 break;
4555
4556 case 225:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004557#line 2218 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004558 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004559 yyval.ValIDVal = ValID::createUndef();
Reid Spencer61c83e02006-08-18 08:43:06 +00004560 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004561 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004562 break;
4563
4564 case 226:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004565#line 2222 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004566 { // A vector zero constant.
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004567 yyval.ValIDVal = ValID::createZeroInit();
Reid Spencer61c83e02006-08-18 08:43:06 +00004568 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004569 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004570 break;
4571
4572 case 227:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004573#line 2226 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004574 { // Nonempty unsized packed vector
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004575 const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
4576 int NumElements = yyvsp[-1].ConstVector->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004577
4578 PackedType* pt = PackedType::get(ETy, NumElements);
4579 PATypeHolder* PTy = new PATypeHolder(
Reid Spencera132e042006-12-03 05:46:11 +00004580 HandleUpRefs(
4581 PackedType::get(
4582 ETy,
4583 NumElements)
4584 )
4585 );
Reid Spencer68a24bd2005-08-27 18:50:39 +00004586
4587 // Verify all elements are correct type!
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004588 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
4589 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00004590 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00004591 ETy->getDescription() +"' as required!\nIt is of type '" +
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004592 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004593 }
4594
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004595 yyval.ValIDVal = ValID::create(ConstantPacked::get(pt, *yyvsp[-1].ConstVector));
4596 delete PTy; delete yyvsp[-1].ConstVector;
Reid Spencer6f407902007-01-13 05:00:46 +00004597 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004598 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004599 break;
Reid Spencer6f407902007-01-13 05:00:46 +00004600
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004601 case 228:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004602#line 2251 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004603 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004604 yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004605 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004606 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004607 break;
4608
4609 case 229:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004610#line 2255 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004611 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004612 char *End = UnEscapeLexed(yyvsp[-2].StrVal, true);
4613 std::string AsmStr = std::string(yyvsp[-2].StrVal, End);
4614 End = UnEscapeLexed(yyvsp[0].StrVal, true);
4615 std::string Constraints = std::string(yyvsp[0].StrVal, End);
4616 yyval.ValIDVal = ValID::createInlineAsm(AsmStr, Constraints, yyvsp[-3].BoolVal);
4617 free(yyvsp[-2].StrVal);
4618 free(yyvsp[0].StrVal);
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004619 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004620 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004621 break;
4622
4623 case 230:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004624#line 2269 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004625 { // Is it an integer reference...?
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004626 yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal);
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004627 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004628 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004629 break;
4630
4631 case 231:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004632#line 2273 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004633 { // Is it a named reference...?
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004634 yyval.ValIDVal = ValID::create(yyvsp[0].StrVal);
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004635 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004636 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004637 break;
4638
4639 case 234:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004640#line 2285 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004641 {
4642 if (!UpRefs.empty())
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004643 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4644 yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
4645 delete yyvsp[-1].TypeVal;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004646 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004647 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004648 break;
4649
4650 case 235:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004651#line 2294 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004652 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004653 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004654 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004655 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004656 break;
4657
4658 case 236:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004659#line 2298 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004660 { // Do not allow functions with 0 basic blocks
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004661 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004662 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004663 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004664 break;
4665
4666 case 237:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004667#line 2307 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004668 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004669 setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004670 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004671 InsertValue(yyvsp[0].TermInstVal);
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004672
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004673 yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
4674 InsertValue(yyvsp[-2].BasicBlockVal);
4675 yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004676 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004677 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004678 break;
4679
4680 case 238:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004681#line 2318 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004682 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004683 if (CastInst *CI1 = dyn_cast<CastInst>(yyvsp[0].InstVal))
Reid Spencer6f407902007-01-13 05:00:46 +00004684 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
4685 if (CI2->getParent() == 0)
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004686 yyvsp[-1].BasicBlockVal->getInstList().push_back(CI2);
4687 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
4688 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004689 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004690 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004691 break;
4692
4693 case 239:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004694#line 2327 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004695 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004696 yyval.BasicBlockVal = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004697 CHECK_FOR_ERROR
4698
4699 // Make sure to move the basic block to the correct location in the
4700 // function, instead of leaving it inserted wherever it was first
4701 // referenced.
4702 Function::BasicBlockListType &BBL =
4703 CurFun.CurrentFunction->getBasicBlockList();
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004704 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004705 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004706 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004707 break;
4708
4709 case 240:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004710#line 2339 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004711 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004712 yyval.BasicBlockVal = getBBVal(ValID::create(yyvsp[0].StrVal), true);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004713 CHECK_FOR_ERROR
4714
4715 // Make sure to move the basic block to the correct location in the
4716 // function, instead of leaving it inserted wherever it was first
4717 // referenced.
4718 Function::BasicBlockListType &BBL =
4719 CurFun.CurrentFunction->getBasicBlockList();
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004720 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00004721 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004722 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004723 break;
Reid Spencer3822ff52006-11-08 06:47:33 +00004724
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004725 case 241:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004726#line 2352 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004727 { // Return with a result...
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004728 yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004729 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004730 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004731 break;
4732
4733 case 242:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004734#line 2356 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004735 { // Return with no result...
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004736 yyval.TermInstVal = new ReturnInst();
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004737 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004738 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004739 break;
4740
4741 case 243:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004742#line 2360 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004743 { // Unconditional Branch...
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004744 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004745 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004746 yyval.TermInstVal = new BranchInst(tmpBB);
4747 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004748 break;
4749
4750 case 244:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004751#line 2365 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004752 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004753 assert(cast<IntegerType>(yyvsp[-7].PrimType)->getBitWidth() == 1 && "Not Bool?");
4754 BasicBlock* tmpBBA = getBBVal(yyvsp[-3].ValIDVal);
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004755 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004756 BasicBlock* tmpBBB = getBBVal(yyvsp[0].ValIDVal);
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004757 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004758 Value* tmpVal = getVal(Type::Int1Ty, yyvsp[-6].ValIDVal);
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004759 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004760 yyval.TermInstVal = new BranchInst(tmpBBA, tmpBBB, tmpVal);
4761 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004762 break;
4763
4764 case 245:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004765#line 2375 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004766 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004767 Value* tmpVal = getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal);
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004768 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004769 BasicBlock* tmpBB = getBBVal(yyvsp[-3].ValIDVal);
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004770 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004771 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, yyvsp[-1].JumpTable->size());
4772 yyval.TermInstVal = S;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004773
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004774 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
4775 E = yyvsp[-1].JumpTable->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004776 for (; I != E; ++I) {
4777 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
4778 S->addCase(CI, I->second);
4779 else
Reid Spencer61c83e02006-08-18 08:43:06 +00004780 GEN_ERROR("Switch case is constant, but not a simple integer!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004781 }
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004782 delete yyvsp[-1].JumpTable;
Reid Spencer61c83e02006-08-18 08:43:06 +00004783 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004784 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004785 break;
4786
4787 case 246:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004788#line 2394 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004789 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004790 Value* tmpVal = getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004791 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004792 BasicBlock* tmpBB = getBBVal(yyvsp[-2].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004793 CHECK_FOR_ERROR
4794 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004795 yyval.TermInstVal = S;
Reid Spencer61c83e02006-08-18 08:43:06 +00004796 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004797 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004798 break;
4799
4800 case 247:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004801#line 2404 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004802 {
Reid Spencer3822ff52006-11-08 06:47:33 +00004803
Reid Spencer14310612006-12-31 05:40:51 +00004804 // Handle the short syntax
4805 const PointerType *PFTy = 0;
4806 const FunctionType *Ty = 0;
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004807 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-11].TypeVal->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00004808 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4809 // Pull out the types of all of the arguments...
4810 std::vector<const Type*> ParamTypes;
Reid Spencer14310612006-12-31 05:40:51 +00004811 FunctionType::ParamAttrsList ParamAttrs;
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004812 ParamAttrs.push_back(yyvsp[-6].ParamAttrs);
4813 for (ValueRefList::iterator I = yyvsp[-8].ValueRefList->begin(), E = yyvsp[-8].ValueRefList->end(); I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00004814 const Type *Ty = I->Val->getType();
4815 if (Ty == Type::VoidTy)
4816 GEN_ERROR("Short call syntax cannot be used with varargs");
4817 ParamTypes.push_back(Ty);
4818 ParamAttrs.push_back(I->Attrs);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004819 }
4820
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004821 Ty = FunctionType::get(yyvsp[-11].TypeVal->get(), ParamTypes, false, ParamAttrs);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004822 PFTy = PointerType::get(Ty);
4823 }
4824
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004825 Value *V = getVal(PFTy, yyvsp[-10].ValIDVal); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00004826 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004827 BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004828 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004829 BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
Reid Spencer5b7e7532006-09-28 19:28:24 +00004830 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004831
Reid Spencer14310612006-12-31 05:40:51 +00004832 // Check the arguments
4833 ValueList Args;
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004834 if (yyvsp[-8].ValueRefList->empty()) { // Has no arguments?
Reid Spencer14310612006-12-31 05:40:51 +00004835 // Make sure no arguments is a good thing!
4836 if (Ty->getNumParams() != 0)
4837 GEN_ERROR("No arguments passed to a function that "
4838 "expects arguments!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004839 } else { // Has arguments?
4840 // Loop through FunctionType's arguments and ensure they are specified
4841 // correctly!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004842 FunctionType::param_iterator I = Ty->param_begin();
4843 FunctionType::param_iterator E = Ty->param_end();
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004844 ValueRefList::iterator ArgI = yyvsp[-8].ValueRefList->begin(), ArgE = yyvsp[-8].ValueRefList->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004845
Reid Spencer14310612006-12-31 05:40:51 +00004846 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
4847 if (ArgI->Val->getType() != *I)
4848 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencera132e042006-12-03 05:46:11 +00004849 (*I)->getDescription() + "'!");
Reid Spencer14310612006-12-31 05:40:51 +00004850 Args.push_back(ArgI->Val);
4851 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004852
Reid Spencer14310612006-12-31 05:40:51 +00004853 if (Ty->isVarArg()) {
4854 if (I == E)
4855 for (; ArgI != ArgE; ++ArgI)
4856 Args.push_back(ArgI->Val); // push the remaining varargs
4857 } else if (I != E || ArgI != ArgE)
Reid Spencer61c83e02006-08-18 08:43:06 +00004858 GEN_ERROR("Invalid number of parameters detected!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004859 }
Reid Spencer14310612006-12-31 05:40:51 +00004860
4861 // Create the InvokeInst
4862 InvokeInst *II = new InvokeInst(V, Normal, Except, Args);
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004863 II->setCallingConv(yyvsp[-12].UIntVal);
4864 yyval.TermInstVal = II;
4865 delete yyvsp[-8].ValueRefList;
Andrew Lenharth6353e052006-12-08 18:07:09 +00004866 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004867 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004868 break;
4869
4870 case 248:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004871#line 2470 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004872 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004873 yyval.TermInstVal = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00004874 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004875 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004876 break;
4877
4878 case 249:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004879#line 2474 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004880 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004881 yyval.TermInstVal = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00004882 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004883 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004884 break;
4885
4886 case 250:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004887#line 2481 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004888 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004889 yyval.JumpTable = yyvsp[-5].JumpTable;
4890 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004891 CHECK_FOR_ERROR
4892 if (V == 0)
4893 GEN_ERROR("May only switch on a constant pool value!");
4894
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004895 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004896 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004897 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
4898 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004899 break;
4900
4901 case 251:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004902#line 2492 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004903 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004904 yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
4905 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004906 CHECK_FOR_ERROR
4907
4908 if (V == 0)
4909 GEN_ERROR("May only switch on a constant pool value!");
4910
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004911 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004912 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004913 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
4914 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004915 break;
4916
4917 case 252:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004918#line 2505 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004919 {
Andrew Lenharth6353e052006-12-08 18:07:09 +00004920 // Is this definition named?? if so, assign the name...
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004921 setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004922 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004923 InsertValue(yyvsp[0].InstVal);
4924 yyval.InstVal = yyvsp[0].InstVal;
Andrew Lenharth6353e052006-12-08 18:07:09 +00004925 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004926}
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004927 break;
4928
4929 case 253:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004930#line 2514 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004931 { // Used for PHI nodes
Reid Spencer14310612006-12-31 05:40:51 +00004932 if (!UpRefs.empty())
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004933 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-5].TypeVal)->getDescription());
4934 yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
4935 Value* tmpVal = getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004936 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004937 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004938 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004939 yyval.PHIList->push_back(std::make_pair(tmpVal, tmpBB));
4940 delete yyvsp[-5].TypeVal;
4941 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004942 break;
4943
4944 case 254:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004945#line 2525 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004946 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004947 yyval.PHIList = yyvsp[-6].PHIList;
4948 Value* tmpVal = getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal);
Reid Spencer6f407902007-01-13 05:00:46 +00004949 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004950 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
Reid Spencer6f407902007-01-13 05:00:46 +00004951 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004952 yyvsp[-6].PHIList->push_back(std::make_pair(tmpVal, tmpBB));
4953 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004954 break;
4955
4956 case 255:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004957#line 2535 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004958 {
Reid Spencer6f407902007-01-13 05:00:46 +00004959 if (!UpRefs.empty())
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004960 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
Reid Spencer6f407902007-01-13 05:00:46 +00004961 // Used for call and invoke instructions
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004962 yyval.ValueRefList = new ValueRefList();
4963 ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal);
4964 yyval.ValueRefList->push_back(E);
4965 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004966 break;
4967
4968 case 256:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004969#line 2543 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004970 {
Reid Spencer14310612006-12-31 05:40:51 +00004971 if (!UpRefs.empty())
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004972 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4973 yyval.ValueRefList = yyvsp[-4].ValueRefList;
4974 ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal);
4975 yyval.ValueRefList->push_back(E);
Reid Spencer6f407902007-01-13 05:00:46 +00004976 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004977 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004978 break;
4979
4980 case 257:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004981#line 2551 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
4982 { yyval.ValueRefList = new ValueRefList(); }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004983 break;
4984
4985 case 258:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004986#line 2554 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
4987 { yyval.ValueList = new std::vector<Value*>(); }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004988 break;
4989
4990 case 259:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004991#line 2555 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004992 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004993 yyval.ValueList = yyvsp[-2].ValueList;
4994 yyval.ValueList->push_back(yyvsp[0].ValueVal);
Reid Spencer14310612006-12-31 05:40:51 +00004995 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00004996 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004997 break;
4998
4999 case 260:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005000#line 2562 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005001 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005002 yyval.BoolVal = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005003 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005004 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005005 break;
5006
5007 case 261:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005008#line 2566 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005009 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005010 yyval.BoolVal = false;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005011 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005012 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005013 break;
5014
5015 case 262:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005016#line 2571 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005017 {
Reid Spencer14310612006-12-31 05:40:51 +00005018 if (!UpRefs.empty())
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005019 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
5020 if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
5021 !isa<PackedType>((*yyvsp[-3].TypeVal).get()))
Reid Spencere4d87aa2006-12-23 06:05:41 +00005022 GEN_ERROR(
5023 "Arithmetic operator requires integer, FP, or packed operands!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005024 if (isa<PackedType>((*yyvsp[-3].TypeVal).get()) &&
5025 (yyvsp[-4].BinaryOpVal == Instruction::URem ||
5026 yyvsp[-4].BinaryOpVal == Instruction::SRem ||
5027 yyvsp[-4].BinaryOpVal == Instruction::FRem))
Reid Spencere4d87aa2006-12-23 06:05:41 +00005028 GEN_ERROR("U/S/FRem not supported on packed types!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005029 Value* val1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005030 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005031 Value* val2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005032 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005033 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, val1, val2);
5034 if (yyval.InstVal == 0)
Reid Spencere4d87aa2006-12-23 06:05:41 +00005035 GEN_ERROR("binary operator returned null!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005036 delete yyvsp[-3].TypeVal;
5037 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005038 break;
5039
5040 case 263:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005041#line 2592 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005042 {
Reid Spencer6f407902007-01-13 05:00:46 +00005043 if (!UpRefs.empty())
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005044 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
5045 if (!(*yyvsp[-3].TypeVal)->isInteger()) {
5046 if (!isa<PackedType>(yyvsp[-3].TypeVal->get()) ||
5047 !cast<PackedType>(yyvsp[-3].TypeVal->get())->getElementType()->isInteger())
Reid Spencer6f407902007-01-13 05:00:46 +00005048 GEN_ERROR("Logical operator requires integral operands!");
5049 }
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005050 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Reid Spencer6f407902007-01-13 05:00:46 +00005051 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005052 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Reid Spencer6f407902007-01-13 05:00:46 +00005053 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005054 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, tmpVal1, tmpVal2);
5055 if (yyval.InstVal == 0)
Reid Spencer6f407902007-01-13 05:00:46 +00005056 GEN_ERROR("binary operator returned null!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005057 delete yyvsp[-3].TypeVal;
5058 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005059 break;
5060
5061 case 264:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005062#line 2609 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005063 {
Reid Spencer14310612006-12-31 05:40:51 +00005064 if (!UpRefs.empty())
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005065 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
5066 if (isa<PackedType>((*yyvsp[-3].TypeVal).get()))
Reid Spencerac4a1dd2007-01-04 02:57:52 +00005067 GEN_ERROR("Packed types not supported by icmp instruction");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005068 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005069 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005070 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005071 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005072 yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].IPredicate, tmpVal1, tmpVal2);
5073 if (yyval.InstVal == 0)
Andrew Lenharth6353e052006-12-08 18:07:09 +00005074 GEN_ERROR("icmp operator returned null!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005075 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005076 break;
5077
5078 case 265:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005079#line 2622 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005080 {
Reid Spencer14310612006-12-31 05:40:51 +00005081 if (!UpRefs.empty())
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005082 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
5083 if (isa<PackedType>((*yyvsp[-3].TypeVal).get()))
Reid Spencerac4a1dd2007-01-04 02:57:52 +00005084 GEN_ERROR("Packed types not supported by fcmp instruction");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005085 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005086 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005087 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005088 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005089 yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].FPredicate, tmpVal1, tmpVal2);
5090 if (yyval.InstVal == 0)
Andrew Lenharth6353e052006-12-08 18:07:09 +00005091 GEN_ERROR("fcmp operator returned null!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005092 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005093 break;
5094
5095 case 266:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005096#line 2635 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005097 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005098 if (yyvsp[0].ValueVal->getType() != Type::Int8Ty)
Reid Spencer14310612006-12-31 05:40:51 +00005099 GEN_ERROR("Shift amount must be i8 type!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005100 if (!yyvsp[-2].ValueVal->getType()->isInteger())
Andrew Lenharth6353e052006-12-08 18:07:09 +00005101 GEN_ERROR("Shift constant expression requires integer operand!");
5102 CHECK_FOR_ERROR;
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005103 yyval.InstVal = new ShiftInst(yyvsp[-3].OtherOpVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005104 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005105 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005106 break;
5107
5108 case 267:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005109#line 2644 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005110 {
Reid Spencer14310612006-12-31 05:40:51 +00005111 if (!UpRefs.empty())
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005112 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
5113 Value* Val = yyvsp[-2].ValueVal;
5114 const Type* DestTy = yyvsp[0].TypeVal->get();
5115 if (!CastInst::castIsValid(yyvsp[-3].CastOpVal, Val, DestTy))
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005116 GEN_ERROR("invalid cast opcode for cast from '" +
5117 Val->getType()->getDescription() + "' to '" +
5118 DestTy->getDescription() + "'!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005119 yyval.InstVal = CastInst::create(yyvsp[-3].CastOpVal, Val, DestTy);
5120 delete yyvsp[0].TypeVal;
5121 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005122 break;
5123
5124 case 268:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005125#line 2656 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005126 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005127 if (yyvsp[-4].ValueVal->getType() != Type::Int1Ty)
Reid Spencer6f407902007-01-13 05:00:46 +00005128 GEN_ERROR("select condition must be boolean!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005129 if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
Reid Spencer6f407902007-01-13 05:00:46 +00005130 GEN_ERROR("select value types should match!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005131 yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Reid Spencer6f407902007-01-13 05:00:46 +00005132 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005133 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005134 break;
5135
5136 case 269:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005137#line 2664 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005138 {
Reid Spencer6f407902007-01-13 05:00:46 +00005139 if (!UpRefs.empty())
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005140 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
5141 yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
5142 delete yyvsp[0].TypeVal;
Andrew Lenharth6353e052006-12-08 18:07:09 +00005143 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005144 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005145 break;
5146
5147 case 270:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005148#line 2671 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005149 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005150 if (!ExtractElementInst::isValidOperands(yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Reid Spencer6f407902007-01-13 05:00:46 +00005151 GEN_ERROR("Invalid extractelement operands!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005152 yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005153 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005154 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005155 break;
5156
5157 case 271:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005158#line 2677 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005159 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005160 if (!InsertElementInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Reid Spencer6f407902007-01-13 05:00:46 +00005161 GEN_ERROR("Invalid insertelement operands!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005162 yyval.InstVal = new InsertElementInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005163 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005164 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005165 break;
5166
5167 case 272:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005168#line 2683 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005169 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005170 if (!ShuffleVectorInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Reid Spencer6f407902007-01-13 05:00:46 +00005171 GEN_ERROR("Invalid shufflevector operands!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005172 yyval.InstVal = new ShuffleVectorInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005173 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005174 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005175 break;
5176
5177 case 273:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005178#line 2689 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005179 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005180 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
Reid Spencer6f407902007-01-13 05:00:46 +00005181 if (!Ty->isFirstClassType())
5182 GEN_ERROR("PHI node operands must be of first class type!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005183 yyval.InstVal = new PHINode(Ty);
5184 ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
5185 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
5186 if (yyvsp[0].PHIList->front().first->getType() != Ty)
Reid Spencer6f407902007-01-13 05:00:46 +00005187 GEN_ERROR("All elements of a PHI node must be of the same type!");
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005188 cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
5189 yyvsp[0].PHIList->pop_front();
Reid Spencer6f407902007-01-13 05:00:46 +00005190 }
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005191 delete yyvsp[0].PHIList; // Free the list...
Reid Spencer61c83e02006-08-18 08:43:06 +00005192 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005193 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005194 break;
5195
5196 case 274:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005197#line 2705 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005198 {
Reid Spencer14310612006-12-31 05:40:51 +00005199
5200 // Handle the short syntax
Andrew Lenharth6353e052006-12-08 18:07:09 +00005201 const PointerType *PFTy = 0;
5202 const FunctionType *Ty = 0;
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005203 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-5].TypeVal->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00005204 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5205 // Pull out the types of all of the arguments...
5206 std::vector<const Type*> ParamTypes;
Reid Spencer14310612006-12-31 05:40:51 +00005207 FunctionType::ParamAttrsList ParamAttrs;
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005208 ParamAttrs.push_back(yyvsp[0].ParamAttrs);
5209 for (ValueRefList::iterator I = yyvsp[-2].ValueRefList->begin(), E = yyvsp[-2].ValueRefList->end(); I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00005210 const Type *Ty = I->Val->getType();
5211 if (Ty == Type::VoidTy)
5212 GEN_ERROR("Short call syntax cannot be used with varargs");
5213 ParamTypes.push_back(Ty);
5214 ParamAttrs.push_back(I->Attrs);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005215 }
5216
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005217 Ty = FunctionType::get(yyvsp[-5].TypeVal->get(), ParamTypes, false, ParamAttrs);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005218 PFTy = PointerType::get(Ty);
5219 }
5220
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005221 Value *V = getVal(PFTy, yyvsp[-4].ValIDVal); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005222 CHECK_FOR_ERROR
5223
Reid Spencer14310612006-12-31 05:40:51 +00005224 // Check the arguments
5225 ValueList Args;
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005226 if (yyvsp[-2].ValueRefList->empty()) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00005227 // Make sure no arguments is a good thing!
5228 if (Ty->getNumParams() != 0)
5229 GEN_ERROR("No arguments passed to a function that "
5230 "expects arguments!");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005231 } else { // Has arguments?
5232 // Loop through FunctionType's arguments and ensure they are specified
5233 // correctly!
5234 //
5235 FunctionType::param_iterator I = Ty->param_begin();
5236 FunctionType::param_iterator E = Ty->param_end();
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005237 ValueRefList::iterator ArgI = yyvsp[-2].ValueRefList->begin(), ArgE = yyvsp[-2].ValueRefList->end();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005238
Reid Spencer14310612006-12-31 05:40:51 +00005239 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5240 if (ArgI->Val->getType() != *I)
5241 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Andrew Lenharth6353e052006-12-08 18:07:09 +00005242 (*I)->getDescription() + "'!");
Reid Spencer14310612006-12-31 05:40:51 +00005243 Args.push_back(ArgI->Val);
5244 }
5245 if (Ty->isVarArg()) {
5246 if (I == E)
5247 for (; ArgI != ArgE; ++ArgI)
5248 Args.push_back(ArgI->Val); // push the remaining varargs
5249 } else if (I != E || ArgI != ArgE)
Andrew Lenharth6353e052006-12-08 18:07:09 +00005250 GEN_ERROR("Invalid number of parameters detected!");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005251 }
Reid Spencer14310612006-12-31 05:40:51 +00005252 // Create the call node
5253 CallInst *CI = new CallInst(V, Args);
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005254 CI->setTailCall(yyvsp[-7].BoolVal);
5255 CI->setCallingConv(yyvsp[-6].UIntVal);
5256 yyval.InstVal = CI;
5257 delete yyvsp[-2].ValueRefList;
Reid Spencer6f407902007-01-13 05:00:46 +00005258 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005259 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005260 break;
5261
5262 case 275:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005263#line 2767 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005264 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005265 yyval.InstVal = yyvsp[0].InstVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005266 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005267 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005268 break;
5269
5270 case 276:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005271#line 2772 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005272 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005273 yyval.BoolVal = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005274 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005275 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005276 break;
5277
5278 case 277:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005279#line 2776 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005280 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005281 yyval.BoolVal = false;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005282 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005283 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005284 break;
5285
5286 case 278:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005287#line 2783 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005288 {
Reid Spencer14310612006-12-31 05:40:51 +00005289 if (!UpRefs.empty())
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005290 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
5291 yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
5292 delete yyvsp[-1].TypeVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005293 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005294 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005295 break;
5296
5297 case 279:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005298#line 2790 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005299 {
Reid Spencer6f407902007-01-13 05:00:46 +00005300 if (!UpRefs.empty())
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005301 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
5302 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
Reid Spencer6f407902007-01-13 05:00:46 +00005303 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005304 yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
5305 delete yyvsp[-4].TypeVal;
5306 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005307 break;
5308
5309 case 280:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005310#line 2798 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005311 {
Reid Spencer14310612006-12-31 05:40:51 +00005312 if (!UpRefs.empty())
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005313 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
5314 yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
5315 delete yyvsp[-1].TypeVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005316 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005317 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005318 break;
5319
5320 case 281:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005321#line 2805 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005322 {
Reid Spencer14310612006-12-31 05:40:51 +00005323 if (!UpRefs.empty())
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005324 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
5325 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005326 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005327 yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
5328 delete yyvsp[-4].TypeVal;
5329 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005330 break;
5331
5332 case 282:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005333#line 2813 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005334 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005335 if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
Reid Spencer6f407902007-01-13 05:00:46 +00005336 GEN_ERROR("Trying to free nonpointer type " +
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005337 yyvsp[0].ValueVal->getType()->getDescription() + "!");
5338 yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005339 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005340 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005341 break;
5342
5343 case 283:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005344#line 2821 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005345 {
Reid Spencer6f407902007-01-13 05:00:46 +00005346 if (!UpRefs.empty())
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005347 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
5348 if (!isa<PointerType>(yyvsp[-1].TypeVal->get()))
Reid Spencer6f407902007-01-13 05:00:46 +00005349 GEN_ERROR("Can't load from nonpointer type: " +
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005350 (*yyvsp[-1].TypeVal)->getDescription());
5351 if (!cast<PointerType>(yyvsp[-1].TypeVal->get())->getElementType()->isFirstClassType())
Reid Spencer6f407902007-01-13 05:00:46 +00005352 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005353 (*yyvsp[-1].TypeVal)->getDescription());
5354 Value* tmpVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005355 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005356 yyval.InstVal = new LoadInst(tmpVal, "", yyvsp[-3].BoolVal);
5357 delete yyvsp[-1].TypeVal;
5358 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005359 break;
5360
5361 case 284:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005362#line 2835 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005363 {
Reid Spencer14310612006-12-31 05:40:51 +00005364 if (!UpRefs.empty())
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005365 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
5366 const PointerType *PT = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
Reid Spencer6f407902007-01-13 05:00:46 +00005367 if (!PT)
5368 GEN_ERROR("Can't store to a nonpointer type: " +
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005369 (*yyvsp[-1].TypeVal)->getDescription());
Reid Spencer6f407902007-01-13 05:00:46 +00005370 const Type *ElTy = PT->getElementType();
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005371 if (ElTy != yyvsp[-3].ValueVal->getType())
5372 GEN_ERROR("Can't store '" + yyvsp[-3].ValueVal->getType()->getDescription() +
Reid Spencer6f407902007-01-13 05:00:46 +00005373 "' into space of type '" + ElTy->getDescription() + "'!");
5374
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005375 Value* tmpVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005376 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005377 yyval.InstVal = new StoreInst(yyvsp[-3].ValueVal, tmpVal, yyvsp[-5].BoolVal);
5378 delete yyvsp[-1].TypeVal;
5379 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005380 break;
5381
5382 case 285:
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005383#line 2852 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005384 {
Reid Spencer14310612006-12-31 05:40:51 +00005385 if (!UpRefs.empty())
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005386 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
5387 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
Reid Spencer61c83e02006-08-18 08:43:06 +00005388 GEN_ERROR("getelementptr insn requires pointer operand!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005389
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005390 if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, *yyvsp[0].ValueList, true))
Reid Spencer61c83e02006-08-18 08:43:06 +00005391 GEN_ERROR("Invalid getelementptr indices for type '" +
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005392 (*yyvsp[-2].TypeVal)->getDescription()+ "'!");
5393 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005394 CHECK_FOR_ERROR
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005395 yyval.InstVal = new GetElementPtrInst(tmpVal, *yyvsp[0].ValueList);
5396 delete yyvsp[-2].TypeVal;
5397 delete yyvsp[0].ValueList;
5398 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005399 break;
5400
5401
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005402 }
5403
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005404/* Line 1016 of /usr/local/share/bison/yacc.c. */
5405#line 5406 "llvmAsmParser.tab.c"
Reid Spencer6f407902007-01-13 05:00:46 +00005406
5407 yyvsp -= yylen;
5408 yyssp -= yylen;
5409
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005410
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005411#if YYDEBUG
5412 if (yydebug)
5413 {
5414 short *yyssp1 = yyss - 1;
5415 YYFPRINTF (stderr, "state stack now");
5416 while (yyssp1 != yyssp)
5417 YYFPRINTF (stderr, " %d", *++yyssp1);
5418 YYFPRINTF (stderr, "\n");
5419 }
5420#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00005421
5422 *++yyvsp = yyval;
5423
5424
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005425 /* Now `shift' the result of the reduction. Determine what state
5426 that goes to, based on the state we popped back to and the rule
5427 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005428
5429 yyn = yyr1[yyn];
5430
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005431 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
5432 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005433 yystate = yytable[yystate];
5434 else
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005435 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00005436
5437 goto yynewstate;
5438
5439
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005440/*------------------------------------.
5441| yyerrlab -- here on detecting error |
5442`------------------------------------*/
5443yyerrlab:
5444 /* If not already recovering from an error, report this error. */
5445 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005446 {
5447 ++yynerrs;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005448#if YYERROR_VERBOSE
Reid Spencer6f407902007-01-13 05:00:46 +00005449 yyn = yypact[yystate];
Chris Lattner0fab59c2007-01-12 18:33:30 +00005450
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005451 if (YYPACT_NINF < yyn && yyn < YYLAST)
Reid Spencer6f407902007-01-13 05:00:46 +00005452 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005453 YYSIZE_T yysize = 0;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005454 int yytype = YYTRANSLATE (yychar);
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005455 char *yymsg;
5456 int yyx, yycount;
Reid Spencer6f407902007-01-13 05:00:46 +00005457
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005458 yycount = 0;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005459 /* Start YYX at -YYN if negative to avoid negative indexes in
5460 YYCHECK. */
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005461 for (yyx = yyn < 0 ? -yyn : 0;
5462 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005463 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005464 yysize += yystrlen (yytname[yyx]) + 15, yycount++;
5465 yysize += yystrlen ("parse error, unexpected ") + 1;
5466 yysize += yystrlen (yytname[yytype]);
5467 yymsg = (char *) YYSTACK_ALLOC (yysize);
5468 if (yymsg != 0)
Reid Spencer6f407902007-01-13 05:00:46 +00005469 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005470 char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
5471 yyp = yystpcpy (yyp, yytname[yytype]);
5472
5473 if (yycount < 5)
Reid Spencer6f407902007-01-13 05:00:46 +00005474 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005475 yycount = 0;
5476 for (yyx = yyn < 0 ? -yyn : 0;
5477 yyx < (int) (sizeof (yytname) / sizeof (char *));
5478 yyx++)
5479 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
5480 {
5481 const char *yyq = ! yycount ? ", expecting " : " or ";
5482 yyp = yystpcpy (yyp, yyq);
5483 yyp = yystpcpy (yyp, yytname[yyx]);
5484 yycount++;
5485 }
Reid Spencer6f407902007-01-13 05:00:46 +00005486 }
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005487 yyerror (yymsg);
5488 YYSTACK_FREE (yymsg);
Reid Spencer6f407902007-01-13 05:00:46 +00005489 }
5490 else
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005491 yyerror ("parse error; also virtual memory exhausted");
Reid Spencer6f407902007-01-13 05:00:46 +00005492 }
5493 else
5494#endif /* YYERROR_VERBOSE */
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005495 yyerror ("parse error");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005496 }
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005497 goto yyerrlab1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005498
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005499
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005500/*----------------------------------------------------.
5501| yyerrlab1 -- error raised explicitly by an action. |
5502`----------------------------------------------------*/
5503yyerrlab1:
Reid Spencer68a24bd2005-08-27 18:50:39 +00005504 if (yyerrstatus == 3)
5505 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005506 /* If just tried and failed to reuse lookahead token after an
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005507 error, discard it. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005508
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005509 /* Return failure if at end of input. */
5510 if (yychar == YYEOF)
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005511 {
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005512 /* Pop the error token. */
5513 YYPOPSTACK;
5514 /* Pop the rest of the stack. */
5515 while (yyssp > yyss)
5516 {
5517 YYDPRINTF ((stderr, "Error: popping "));
5518 YYDSYMPRINT ((stderr,
5519 yystos[*yyssp],
5520 *yyvsp));
5521 YYDPRINTF ((stderr, "\n"));
5522 yydestruct (yystos[*yyssp], *yyvsp);
5523 YYPOPSTACK;
5524 }
5525 YYABORT;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005526 }
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005527
5528 YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
5529 yychar, yytname[yychar1]));
5530 yydestruct (yychar1, yylval);
5531 yychar = YYEMPTY;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005532 }
5533
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005534 /* Else will try to reuse lookahead token after shifting the error
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005535 token. */
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005536
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005537 yyerrstatus = 3; /* Each real token shifted decrements this. */
5538
5539 for (;;)
5540 {
5541 yyn = yypact[yystate];
5542 if (yyn != YYPACT_NINF)
5543 {
5544 yyn += YYTERROR;
5545 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
5546 {
5547 yyn = yytable[yyn];
5548 if (0 < yyn)
5549 break;
5550 }
5551 }
5552
5553 /* Pop the current state because it cannot handle the error token. */
5554 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005555 YYABORT;
5556
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005557 YYDPRINTF ((stderr, "Error: popping "));
5558 YYDSYMPRINT ((stderr,
5559 yystos[*yyssp], *yyvsp));
5560 YYDPRINTF ((stderr, "\n"));
Reid Spencere4d87aa2006-12-23 06:05:41 +00005561
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005562 yydestruct (yystos[yystate], *yyvsp);
5563 yyvsp--;
5564 yystate = *--yyssp;
5565
5566
5567#if YYDEBUG
5568 if (yydebug)
5569 {
5570 short *yyssp1 = yyss - 1;
5571 YYFPRINTF (stderr, "Error: state stack now");
5572 while (yyssp1 != yyssp)
5573 YYFPRINTF (stderr, " %d", *++yyssp1);
5574 YYFPRINTF (stderr, "\n");
5575 }
5576#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00005577 }
5578
5579 if (yyn == YYFINAL)
5580 YYACCEPT;
5581
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005582 YYDPRINTF ((stderr, "Shifting error token, "));
5583
Reid Spencer68a24bd2005-08-27 18:50:39 +00005584 *++yyvsp = yylval;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005585
5586
Reid Spencer68a24bd2005-08-27 18:50:39 +00005587 yystate = yyn;
5588 goto yynewstate;
5589
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00005590
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005591/*-------------------------------------.
5592| yyacceptlab -- YYACCEPT comes here. |
5593`-------------------------------------*/
5594yyacceptlab:
5595 yyresult = 0;
5596 goto yyreturn;
5597
5598/*-----------------------------------.
5599| yyabortlab -- YYABORT comes here. |
5600`-----------------------------------*/
5601yyabortlab:
5602 yyresult = 1;
5603 goto yyreturn;
5604
5605#ifndef yyoverflow
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005606/*----------------------------------------------.
5607| yyoverflowlab -- parser overflow comes here. |
5608`----------------------------------------------*/
5609yyoverflowlab:
5610 yyerror ("parser stack overflow");
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005611 yyresult = 2;
5612 /* Fall through. */
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00005613#endif
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005614
5615yyreturn:
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005616#ifndef yyoverflow
5617 if (yyss != yyssa)
5618 YYSTACK_FREE (yyss);
5619#endif
5620 return yyresult;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005621}
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005622
5623
Jeff Cohen361c3ef2007-01-21 19:19:31 +00005624#line 2869 "/usr/home/jeffc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00005625
5626
Reid Spencer14310612006-12-31 05:40:51 +00005627// common code from the two 'RunVMAsmParser' functions
5628static Module* RunParser(Module * M) {
5629
5630 llvmAsmlineno = 1; // Reset the current line number...
5631 CurModule.CurrentModule = M;
5632#if YYDEBUG
5633 yydebug = Debug;
5634#endif
5635
5636 // Check to make sure the parser succeeded
5637 if (yyparse()) {
5638 if (ParserResult)
5639 delete ParserResult;
5640 return 0;
5641 }
5642
5643 // Check to make sure that parsing produced a result
5644 if (!ParserResult)
5645 return 0;
5646
5647 // Reset ParserResult variable while saving its value for the result.
5648 Module *Result = ParserResult;
5649 ParserResult = 0;
5650
5651 return Result;
5652}
5653
Reid Spencer61c83e02006-08-18 08:43:06 +00005654void llvm::GenerateError(const std::string &message, int LineNo) {
5655 if (LineNo == -1) LineNo = llvmAsmlineno;
5656 // TODO: column number in exception
5657 if (TheParseError)
5658 TheParseError->setError(CurFilename, message, LineNo);
5659 TriggerError = 1;
5660}
Reid Spencer68a24bd2005-08-27 18:50:39 +00005661
5662int yyerror(const char *ErrorMsg) {
5663 std::string where
5664 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
5665 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
5666 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
5667 if (yychar == YYEMPTY || yychar == 0)
5668 errMsg += "end-of-file.";
5669 else
5670 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
Reid Spencer61c83e02006-08-18 08:43:06 +00005671 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005672 return 0;
5673}
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00005674