blob: 6fc35d80c5b385196049827d48019fe6cbea93de [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001
Gabor Greif89f01162008-04-06 23:07:54 +00002/* A Bison parser, made from /Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y
3 by GNU Bison version 1.28 */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004
Gabor Greif89f01162008-04-06 23:07:54 +00005#define YYBISON 1 /* Identify Bison output. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006
7#define yyparse llvmAsmparse
Gabor Greif89f01162008-04-06 23:07:54 +00008#define yylex llvmAsmlex
Dan Gohmanf17a25c2007-07-18 16:29:46 +00009#define yyerror llvmAsmerror
Gabor Greif89f01162008-04-06 23:07:54 +000010#define yylval llvmAsmlval
11#define yychar llvmAsmchar
Dan Gohmanf17a25c2007-07-18 16:29:46 +000012#define yydebug llvmAsmdebug
13#define yynerrs llvmAsmnerrs
Gabor Greif89f01162008-04-06 23:07:54 +000014#define ESINT64VAL 257
15#define EUINT64VAL 258
16#define ESAPINTVAL 259
17#define EUAPINTVAL 260
18#define LOCALVAL_ID 261
19#define GLOBALVAL_ID 262
20#define FPVAL 263
21#define VOID 264
22#define INTTYPE 265
23#define FLOAT 266
24#define DOUBLE 267
25#define X86_FP80 268
26#define FP128 269
27#define PPC_FP128 270
28#define LABEL 271
29#define TYPE 272
30#define LOCALVAR 273
31#define GLOBALVAR 274
32#define LABELSTR 275
33#define STRINGCONSTANT 276
34#define ATSTRINGCONSTANT 277
35#define PCTSTRINGCONSTANT 278
36#define ZEROINITIALIZER 279
37#define TRUETOK 280
38#define FALSETOK 281
39#define BEGINTOK 282
40#define ENDTOK 283
41#define DECLARE 284
42#define DEFINE 285
43#define GLOBAL 286
44#define CONSTANT 287
45#define SECTION 288
46#define ALIAS 289
47#define VOLATILE 290
48#define THREAD_LOCAL 291
49#define TO 292
50#define DOTDOTDOT 293
51#define NULL_TOK 294
52#define UNDEF 295
53#define INTERNAL 296
54#define LINKONCE 297
55#define WEAK 298
56#define APPENDING 299
57#define DLLIMPORT 300
58#define DLLEXPORT 301
59#define EXTERN_WEAK 302
60#define OPAQUE 303
61#define EXTERNAL 304
62#define TARGET 305
63#define TRIPLE 306
64#define ALIGN 307
65#define ADDRSPACE 308
66#define DEPLIBS 309
67#define CALL 310
68#define TAIL 311
69#define ASM_TOK 312
70#define MODULE 313
71#define SIDEEFFECT 314
72#define CC_TOK 315
73#define CCC_TOK 316
74#define FASTCC_TOK 317
75#define COLDCC_TOK 318
76#define X86_STDCALLCC_TOK 319
77#define X86_FASTCALLCC_TOK 320
78#define DATALAYOUT 321
79#define UNWINDS 322
80#define RET 323
81#define BR 324
82#define SWITCH 325
83#define INVOKE 326
84#define UNWIND 327
85#define UNREACHABLE 328
86#define ADD 329
87#define SUB 330
88#define MUL 331
89#define UDIV 332
90#define SDIV 333
91#define FDIV 334
92#define UREM 335
93#define SREM 336
94#define FREM 337
95#define AND 338
96#define OR 339
97#define XOR 340
98#define SHL 341
99#define LSHR 342
100#define ASHR 343
101#define ICMP 344
102#define FCMP 345
103#define EQ 346
104#define NE 347
105#define SLT 348
106#define SGT 349
107#define SLE 350
108#define SGE 351
109#define ULT 352
110#define UGT 353
111#define ULE 354
112#define UGE 355
113#define OEQ 356
114#define ONE 357
115#define OLT 358
116#define OGT 359
117#define OLE 360
118#define OGE 361
119#define ORD 362
120#define UNO 363
121#define UEQ 364
122#define UNE 365
123#define MALLOC 366
124#define ALLOCA 367
125#define FREE 368
126#define LOAD 369
127#define STORE 370
128#define GETELEMENTPTR 371
129#define TRUNC 372
130#define ZEXT 373
131#define SEXT 374
132#define FPTRUNC 375
133#define FPEXT 376
134#define BITCAST 377
135#define UITOFP 378
136#define SITOFP 379
137#define FPTOUI 380
138#define FPTOSI 381
139#define INTTOPTR 382
140#define PTRTOINT 383
141#define PHI_TOK 384
142#define SELECT 385
143#define VAARG 386
144#define EXTRACTELEMENT 387
145#define INSERTELEMENT 388
146#define SHUFFLEVECTOR 389
147#define GETRESULT 390
148#define SIGNEXT 391
149#define ZEROEXT 392
150#define NORETURN 393
151#define INREG 394
152#define SRET 395
153#define NOUNWIND 396
154#define NOALIAS 397
155#define BYVAL 398
156#define NEST 399
157#define READNONE 400
158#define READONLY 401
159#define GC 402
160#define DEFAULT 403
161#define HIDDEN 404
162#define PROTECTED 405
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000163
Gabor Greif89f01162008-04-06 23:07:54 +0000164#line 14 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000165
166#include "ParserInternals.h"
167#include "llvm/CallingConv.h"
168#include "llvm/InlineAsm.h"
169#include "llvm/Instructions.h"
170#include "llvm/Module.h"
171#include "llvm/ValueSymbolTable.h"
Chandler Carruth563d4a42007-08-04 01:56:21 +0000172#include "llvm/AutoUpgrade.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000173#include "llvm/Support/GetElementPtrTypeIterator.h"
174#include "llvm/Support/CommandLine.h"
175#include "llvm/ADT/SmallVector.h"
176#include "llvm/ADT/STLExtras.h"
177#include "llvm/Support/MathExtras.h"
178#include "llvm/Support/Streams.h"
179#include <algorithm>
180#include <list>
181#include <map>
182#include <utility>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000183
184// The following is a gross hack. In order to rid the libAsmParser library of
185// exceptions, we have to have a way of getting the yyparse function to go into
186// an error situation. So, whenever we want an error to occur, the GenerateError
187// function (see bottom of file) sets TriggerError. Then, at the end of each
188// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
189// (a goto) to put YACC in error state. Furthermore, several calls to
190// GenerateError are made from inside productions and they must simulate the
191// previous exception behavior by exiting the production immediately. We have
192// replaced these with the GEN_ERROR macro which calls GeneratError and then
193// immediately invokes YYERROR. This would be so much cleaner if it was a
194// recursive descent parser.
195static bool TriggerError = false;
196#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
197#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
198
199int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
200int yylex(); // declaration" of xxx warnings.
201int yyparse();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000202using namespace llvm;
203
204static Module *ParserResult;
205
206// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
207// relating to upreferences in the input stream.
208//
209//#define DEBUG_UPREFS 1
210#ifdef DEBUG_UPREFS
211#define UR_OUT(X) cerr << X
212#else
213#define UR_OUT(X)
214#endif
215
216#define YYERROR_VERBOSE 1
217
218static GlobalVariable *CurGV;
219
220
221// This contains info used when building the body of a function. It is
222// destroyed when the function is completed.
223//
224typedef std::vector<Value *> ValueList; // Numbered defs
225
226static void
227ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0);
228
229static struct PerModuleInfo {
230 Module *CurrentModule;
231 ValueList Values; // Module level numbered definitions
232 ValueList LateResolveValues;
233 std::vector<PATypeHolder> Types;
234 std::map<ValID, PATypeHolder> LateResolveTypes;
235
236 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
237 /// how they were referenced and on which line of the input they came from so
238 /// that we can resolve them later and print error messages as appropriate.
239 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
240
241 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
242 // references to global values. Global values may be referenced before they
243 // are defined, and if so, the temporary object that they represent is held
244 // here. This is used for forward references of GlobalValues.
245 //
246 typedef std::map<std::pair<const PointerType *,
247 ValID>, GlobalValue*> GlobalRefsType;
248 GlobalRefsType GlobalRefs;
249
250 void ModuleDone() {
251 // If we could not resolve some functions at function compilation time
252 // (calls to functions before they are defined), resolve them now... Types
253 // are resolved when the constant pool has been completely parsed.
254 //
255 ResolveDefinitions(LateResolveValues);
256 if (TriggerError)
257 return;
258
259 // Check to make sure that all global value forward references have been
260 // resolved!
261 //
262 if (!GlobalRefs.empty()) {
263 std::string UndefinedReferences = "Unresolved global references exist:\n";
264
265 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
266 I != E; ++I) {
267 UndefinedReferences += " " + I->first.first->getDescription() + " " +
268 I->first.second.getName() + "\n";
269 }
270 GenerateError(UndefinedReferences);
271 return;
272 }
273
Chandler Carruth563d4a42007-08-04 01:56:21 +0000274 // Look for intrinsic functions and CallInst that need to be upgraded
275 for (Module::iterator FI = CurrentModule->begin(),
276 FE = CurrentModule->end(); FI != FE; )
277 UpgradeCallsToIntrinsic(FI++); // must be post-increment, as we remove
278
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000279 Values.clear(); // Clear out function local definitions
280 Types.clear();
281 CurrentModule = 0;
282 }
283
284 // GetForwardRefForGlobal - Check to see if there is a forward reference
285 // for this global. If so, remove it from the GlobalRefs map and return it.
286 // If not, just return null.
287 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
288 // Check to see if there is a forward reference to this global variable...
289 // if there is, eliminate it and patch the reference to use the new def'n.
290 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
291 GlobalValue *Ret = 0;
292 if (I != GlobalRefs.end()) {
293 Ret = I->second;
294 GlobalRefs.erase(I);
295 }
296 return Ret;
297 }
298
299 bool TypeIsUnresolved(PATypeHolder* PATy) {
300 // If it isn't abstract, its resolved
301 const Type* Ty = PATy->get();
302 if (!Ty->isAbstract())
303 return false;
304 // Traverse the type looking for abstract types. If it isn't abstract then
305 // we don't need to traverse that leg of the type.
306 std::vector<const Type*> WorkList, SeenList;
307 WorkList.push_back(Ty);
308 while (!WorkList.empty()) {
309 const Type* Ty = WorkList.back();
310 SeenList.push_back(Ty);
311 WorkList.pop_back();
312 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
313 // Check to see if this is an unresolved type
314 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
315 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
316 for ( ; I != E; ++I) {
317 if (I->second.get() == OpTy)
318 return true;
319 }
320 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
321 const Type* TheTy = SeqTy->getElementType();
322 if (TheTy->isAbstract() && TheTy != Ty) {
323 std::vector<const Type*>::iterator I = SeenList.begin(),
324 E = SeenList.end();
325 for ( ; I != E; ++I)
326 if (*I == TheTy)
327 break;
328 if (I == E)
329 WorkList.push_back(TheTy);
330 }
331 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
332 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
333 const Type* TheTy = StrTy->getElementType(i);
334 if (TheTy->isAbstract() && TheTy != Ty) {
335 std::vector<const Type*>::iterator I = SeenList.begin(),
336 E = SeenList.end();
337 for ( ; I != E; ++I)
338 if (*I == TheTy)
339 break;
340 if (I == E)
341 WorkList.push_back(TheTy);
342 }
343 }
344 }
345 }
346 return false;
347 }
348} CurModule;
349
350static struct PerFunctionInfo {
351 Function *CurrentFunction; // Pointer to current function being created
352
353 ValueList Values; // Keep track of #'d definitions
354 unsigned NextValNum;
355 ValueList LateResolveValues;
356 bool isDeclare; // Is this function a forward declararation?
357 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
358 GlobalValue::VisibilityTypes Visibility;
359
360 /// BBForwardRefs - When we see forward references to basic blocks, keep
361 /// track of them here.
362 std::map<ValID, BasicBlock*> BBForwardRefs;
363
364 inline PerFunctionInfo() {
365 CurrentFunction = 0;
366 isDeclare = false;
367 Linkage = GlobalValue::ExternalLinkage;
368 Visibility = GlobalValue::DefaultVisibility;
369 }
370
371 inline void FunctionStart(Function *M) {
372 CurrentFunction = M;
373 NextValNum = 0;
374 }
375
376 void FunctionDone() {
377 // Any forward referenced blocks left?
378 if (!BBForwardRefs.empty()) {
379 GenerateError("Undefined reference to label " +
380 BBForwardRefs.begin()->second->getName());
381 return;
382 }
383
384 // Resolve all forward references now.
385 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
386
387 Values.clear(); // Clear out function local definitions
388 BBForwardRefs.clear();
389 CurrentFunction = 0;
390 isDeclare = false;
391 Linkage = GlobalValue::ExternalLinkage;
392 Visibility = GlobalValue::DefaultVisibility;
393 }
394} CurFun; // Info for the current function...
395
396static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
397
398
399//===----------------------------------------------------------------------===//
400// Code to handle definitions of all the types
401//===----------------------------------------------------------------------===//
402
403static void InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) {
404 // Things that have names or are void typed don't get slot numbers
405 if (V->hasName() || (V->getType() == Type::VoidTy))
406 return;
407
408 // In the case of function values, we have to allow for the forward reference
409 // of basic blocks, which are included in the numbering. Consequently, we keep
410 // track of the next insertion location with NextValNum. When a BB gets
411 // inserted, it could change the size of the CurFun.Values vector.
412 if (&ValueTab == &CurFun.Values) {
413 if (ValueTab.size() <= CurFun.NextValNum)
414 ValueTab.resize(CurFun.NextValNum+1);
415 ValueTab[CurFun.NextValNum++] = V;
416 return;
417 }
418 // For all other lists, its okay to just tack it on the back of the vector.
419 ValueTab.push_back(V);
420}
421
422static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
423 switch (D.Type) {
424 case ValID::LocalID: // Is it a numbered definition?
425 // Module constants occupy the lowest numbered slots...
426 if (D.Num < CurModule.Types.size())
427 return CurModule.Types[D.Num];
428 break;
429 case ValID::LocalName: // Is it a named definition?
430 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.getName())) {
431 D.destroy(); // Free old strdup'd memory...
432 return N;
433 }
434 break;
435 default:
436 GenerateError("Internal parser error: Invalid symbol type reference");
437 return 0;
438 }
439
440 // If we reached here, we referenced either a symbol that we don't know about
441 // or an id number that hasn't been read yet. We may be referencing something
442 // forward, so just create an entry to be resolved later and get to it...
443 //
444 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
445
446
447 if (inFunctionScope()) {
448 if (D.Type == ValID::LocalName) {
449 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
450 return 0;
451 } else {
452 GenerateError("Reference to an undefined type: #" + utostr(D.Num));
453 return 0;
454 }
455 }
456
457 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
458 if (I != CurModule.LateResolveTypes.end())
459 return I->second;
460
461 Type *Typ = OpaqueType::get();
462 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
463 return Typ;
464 }
465
466// getExistingVal - Look up the value specified by the provided type and
467// the provided ValID. If the value exists and has already been defined, return
468// it. Otherwise return null.
469//
470static Value *getExistingVal(const Type *Ty, const ValID &D) {
471 if (isa<FunctionType>(Ty)) {
472 GenerateError("Functions are not values and "
473 "must be referenced as pointers");
474 return 0;
475 }
476
477 switch (D.Type) {
478 case ValID::LocalID: { // Is it a numbered definition?
479 // Check that the number is within bounds.
480 if (D.Num >= CurFun.Values.size())
481 return 0;
482 Value *Result = CurFun.Values[D.Num];
483 if (Ty != Result->getType()) {
484 GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" +
485 Result->getType()->getDescription() + "' does not match "
486 "expected type, '" + Ty->getDescription() + "'");
487 return 0;
488 }
489 return Result;
490 }
491 case ValID::GlobalID: { // Is it a numbered definition?
492 if (D.Num >= CurModule.Values.size())
493 return 0;
494 Value *Result = CurModule.Values[D.Num];
495 if (Ty != Result->getType()) {
496 GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" +
497 Result->getType()->getDescription() + "' does not match "
498 "expected type, '" + Ty->getDescription() + "'");
499 return 0;
500 }
501 return Result;
502 }
503
504 case ValID::LocalName: { // Is it a named definition?
505 if (!inFunctionScope())
506 return 0;
507 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
508 Value *N = SymTab.lookup(D.getName());
509 if (N == 0)
510 return 0;
511 if (N->getType() != Ty)
512 return 0;
513
514 D.destroy(); // Free old strdup'd memory...
515 return N;
516 }
517 case ValID::GlobalName: { // Is it a named definition?
518 ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
519 Value *N = SymTab.lookup(D.getName());
520 if (N == 0)
521 return 0;
522 if (N->getType() != Ty)
523 return 0;
524
525 D.destroy(); // Free old strdup'd memory...
526 return N;
527 }
528
529 // Check to make sure that "Ty" is an integral type, and that our
530 // value will fit into the specified type...
531 case ValID::ConstSIntVal: // Is it a constant pool reference??
Chris Lattner59363a32008-02-19 04:36:25 +0000532 if (!isa<IntegerType>(Ty) ||
533 !ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000534 GenerateError("Signed integral constant '" +
535 itostr(D.ConstPool64) + "' is invalid for type '" +
536 Ty->getDescription() + "'");
537 return 0;
538 }
539 return ConstantInt::get(Ty, D.ConstPool64, true);
540
541 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Chris Lattner59363a32008-02-19 04:36:25 +0000542 if (isa<IntegerType>(Ty) &&
543 ConstantInt::isValueValidForType(Ty, D.UConstPool64))
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000544 return ConstantInt::get(Ty, D.UConstPool64);
Chris Lattner59363a32008-02-19 04:36:25 +0000545
546 if (!isa<IntegerType>(Ty) ||
547 !ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
548 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
549 "' is invalid or out of range for type '" +
550 Ty->getDescription() + "'");
551 return 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000552 }
Chris Lattner59363a32008-02-19 04:36:25 +0000553 // This is really a signed reference. Transmogrify.
554 return ConstantInt::get(Ty, D.ConstPool64, true);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000555
556 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Chris Lattner59363a32008-02-19 04:36:25 +0000557 if (!Ty->isFloatingPoint() ||
558 !ConstantFP::isValueValidForType(Ty, *D.ConstPoolFP)) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000559 GenerateError("FP constant invalid for type");
560 return 0;
561 }
Dale Johannesen255b8fe2007-09-11 18:33:39 +0000562 // Lexer has no type info, so builds all float and double FP constants
563 // as double. Fix this here. Long double does not need this.
564 if (&D.ConstPoolFP->getSemantics() == &APFloat::IEEEdouble &&
565 Ty==Type::FloatTy)
Dale Johannesen3afee192007-09-07 21:07:57 +0000566 D.ConstPoolFP->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
567 return ConstantFP::get(Ty, *D.ConstPoolFP);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000568
569 case ValID::ConstNullVal: // Is it a null value?
570 if (!isa<PointerType>(Ty)) {
571 GenerateError("Cannot create a a non pointer null");
572 return 0;
573 }
574 return ConstantPointerNull::get(cast<PointerType>(Ty));
575
576 case ValID::ConstUndefVal: // Is it an undef value?
577 return UndefValue::get(Ty);
578
579 case ValID::ConstZeroVal: // Is it a zero value?
580 return Constant::getNullValue(Ty);
581
582 case ValID::ConstantVal: // Fully resolved constant?
583 if (D.ConstantValue->getType() != Ty) {
584 GenerateError("Constant expression type different from required type");
585 return 0;
586 }
587 return D.ConstantValue;
588
589 case ValID::InlineAsmVal: { // Inline asm expression
590 const PointerType *PTy = dyn_cast<PointerType>(Ty);
591 const FunctionType *FTy =
592 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
593 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
594 GenerateError("Invalid type for asm constraint string");
595 return 0;
596 }
597 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
598 D.IAD->HasSideEffects);
599 D.destroy(); // Free InlineAsmDescriptor.
600 return IA;
601 }
602 default:
603 assert(0 && "Unhandled case!");
604 return 0;
605 } // End of switch
606
607 assert(0 && "Unhandled case!");
608 return 0;
609}
610
611// getVal - This function is identical to getExistingVal, except that if a
612// value is not already defined, it "improvises" by creating a placeholder var
613// that looks and acts just like the requested variable. When the value is
614// defined later, all uses of the placeholder variable are replaced with the
615// real thing.
616//
617static Value *getVal(const Type *Ty, const ValID &ID) {
618 if (Ty == Type::LabelTy) {
619 GenerateError("Cannot use a basic block here");
620 return 0;
621 }
622
623 // See if the value has already been defined.
624 Value *V = getExistingVal(Ty, ID);
625 if (V) return V;
626 if (TriggerError) return 0;
627
628 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
629 GenerateError("Invalid use of a composite type");
630 return 0;
631 }
632
633 // If we reached here, we referenced either a symbol that we don't know about
634 // or an id number that hasn't been read yet. We may be referencing something
635 // forward, so just create an entry to be resolved later and get to it...
636 //
637 switch (ID.Type) {
638 case ValID::GlobalName:
639 case ValID::GlobalID: {
640 const PointerType *PTy = dyn_cast<PointerType>(Ty);
641 if (!PTy) {
642 GenerateError("Invalid type for reference to global" );
643 return 0;
644 }
645 const Type* ElTy = PTy->getElementType();
646 if (const FunctionType *FTy = dyn_cast<FunctionType>(ElTy))
Gabor Greif89f01162008-04-06 23:07:54 +0000647 V = Function::Create(FTy, GlobalValue::ExternalLinkage);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000648 else
Christopher Lamb0a243582007-12-11 09:02:08 +0000649 V = new GlobalVariable(ElTy, false, GlobalValue::ExternalLinkage, 0, "",
650 (Module*)0, false, PTy->getAddressSpace());
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000651 break;
652 }
653 default:
654 V = new Argument(Ty);
655 }
656
657 // Remember where this forward reference came from. FIXME, shouldn't we try
658 // to recycle these things??
659 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
Duncan Sandsf5588dc2007-11-27 13:23:08 +0000660 LLLgetLineNo())));
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000661
662 if (inFunctionScope())
663 InsertValue(V, CurFun.LateResolveValues);
664 else
665 InsertValue(V, CurModule.LateResolveValues);
666 return V;
667}
668
669/// defineBBVal - This is a definition of a new basic block with the specified
670/// identifier which must be the same as CurFun.NextValNum, if its numeric.
Devang Patel890cc572008-03-03 18:58:47 +0000671static BasicBlock *defineBBVal(const ValID &ID, BasicBlock *unwindDest) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000672 assert(inFunctionScope() && "Can't get basic block at global scope!");
673
674 BasicBlock *BB = 0;
675
676 // First, see if this was forward referenced
677
678 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
679 if (BBI != CurFun.BBForwardRefs.end()) {
680 BB = BBI->second;
681 // The forward declaration could have been inserted anywhere in the
682 // function: insert it into the correct place now.
683 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
684 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
685
686 // We're about to erase the entry, save the key so we can clean it up.
687 ValID Tmp = BBI->first;
688
689 // Erase the forward ref from the map as its no longer "forward"
690 CurFun.BBForwardRefs.erase(ID);
691
692 // The key has been removed from the map but so we don't want to leave
693 // strdup'd memory around so destroy it too.
694 Tmp.destroy();
695
696 // If its a numbered definition, bump the number and set the BB value.
697 if (ID.Type == ValID::LocalID) {
698 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
699 InsertValue(BB);
700 }
Devang Patel890cc572008-03-03 18:58:47 +0000701 } else {
702 // We haven't seen this BB before and its first mention is a definition.
703 // Just create it and return it.
704 std::string Name (ID.Type == ValID::LocalName ? ID.getName() : "");
Gabor Greif89f01162008-04-06 23:07:54 +0000705 BB = BasicBlock::Create(Name, CurFun.CurrentFunction);
Devang Patel890cc572008-03-03 18:58:47 +0000706 if (ID.Type == ValID::LocalID) {
707 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
708 InsertValue(BB);
709 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000710 }
711
Devang Patel890cc572008-03-03 18:58:47 +0000712 ID.destroy();
713 BB->setUnwindDest(unwindDest);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000714 return BB;
715}
716
717/// getBBVal - get an existing BB value or create a forward reference for it.
718///
719static BasicBlock *getBBVal(const ValID &ID) {
720 assert(inFunctionScope() && "Can't get basic block at global scope!");
721
722 BasicBlock *BB = 0;
723
724 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
725 if (BBI != CurFun.BBForwardRefs.end()) {
726 BB = BBI->second;
727 } if (ID.Type == ValID::LocalName) {
728 std::string Name = ID.getName();
729 Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
Anton Korobeynikov21c1eeb2008-02-20 12:10:37 +0000730 if (N) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000731 if (N->getType()->getTypeID() == Type::LabelTyID)
732 BB = cast<BasicBlock>(N);
733 else
734 GenerateError("Reference to label '" + Name + "' is actually of type '"+
735 N->getType()->getDescription() + "'");
Anton Korobeynikov21c1eeb2008-02-20 12:10:37 +0000736 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000737 } else if (ID.Type == ValID::LocalID) {
738 if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) {
739 if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID)
740 BB = cast<BasicBlock>(CurFun.Values[ID.Num]);
741 else
742 GenerateError("Reference to label '%" + utostr(ID.Num) +
743 "' is actually of type '"+
744 CurFun.Values[ID.Num]->getType()->getDescription() + "'");
745 }
746 } else {
747 GenerateError("Illegal label reference " + ID.getName());
748 return 0;
749 }
750
751 // If its already been defined, return it now.
752 if (BB) {
753 ID.destroy(); // Free strdup'd memory.
754 return BB;
755 }
756
757 // Otherwise, this block has not been seen before, create it.
758 std::string Name;
759 if (ID.Type == ValID::LocalName)
760 Name = ID.getName();
Gabor Greif89f01162008-04-06 23:07:54 +0000761 BB = BasicBlock::Create(Name, CurFun.CurrentFunction);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000762
763 // Insert it in the forward refs map.
764 CurFun.BBForwardRefs[ID] = BB;
765
766 return BB;
767}
768
769
770//===----------------------------------------------------------------------===//
771// Code to handle forward references in instructions
772//===----------------------------------------------------------------------===//
773//
774// This code handles the late binding needed with statements that reference
775// values not defined yet... for example, a forward branch, or the PHI node for
776// a loop body.
777//
778// This keeps a table (CurFun.LateResolveValues) of all such forward references
779// and back patchs after we are done.
780//
781
782// ResolveDefinitions - If we could not resolve some defs at parsing
783// time (forward branches, phi functions for loops, etc...) resolve the
784// defs now...
785//
786static void
787ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) {
788 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
789 while (!LateResolvers.empty()) {
790 Value *V = LateResolvers.back();
791 LateResolvers.pop_back();
792
793 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
794 CurModule.PlaceHolderInfo.find(V);
795 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
796
797 ValID &DID = PHI->second.first;
798
799 Value *TheRealValue = getExistingVal(V->getType(), DID);
800 if (TriggerError)
801 return;
802 if (TheRealValue) {
803 V->replaceAllUsesWith(TheRealValue);
804 delete V;
805 CurModule.PlaceHolderInfo.erase(PHI);
806 } else if (FutureLateResolvers) {
807 // Functions have their unresolved items forwarded to the module late
808 // resolver table
809 InsertValue(V, *FutureLateResolvers);
810 } else {
811 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
812 GenerateError("Reference to an invalid definition: '" +DID.getName()+
813 "' of type '" + V->getType()->getDescription() + "'",
814 PHI->second.second);
815 return;
816 } else {
817 GenerateError("Reference to an invalid definition: #" +
818 itostr(DID.Num) + " of type '" +
819 V->getType()->getDescription() + "'",
820 PHI->second.second);
821 return;
822 }
823 }
824 }
825 LateResolvers.clear();
826}
827
828// ResolveTypeTo - A brand new type was just declared. This means that (if
829// name is not null) things referencing Name can be resolved. Otherwise, things
830// refering to the number can be resolved. Do this now.
831//
832static void ResolveTypeTo(std::string *Name, const Type *ToTy) {
833 ValID D;
834 if (Name)
835 D = ValID::createLocalName(*Name);
836 else
837 D = ValID::createLocalID(CurModule.Types.size());
838
839 std::map<ValID, PATypeHolder>::iterator I =
840 CurModule.LateResolveTypes.find(D);
841 if (I != CurModule.LateResolveTypes.end()) {
842 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
843 CurModule.LateResolveTypes.erase(I);
844 }
845}
846
847// setValueName - Set the specified value to the name given. The name may be
848// null potentially, in which case this is a noop. The string passed in is
849// assumed to be a malloc'd string buffer, and is free'd by this function.
850//
851static void setValueName(Value *V, std::string *NameStr) {
852 if (!NameStr) return;
853 std::string Name(*NameStr); // Copy string
854 delete NameStr; // Free old string
855
856 if (V->getType() == Type::VoidTy) {
857 GenerateError("Can't assign name '" + Name+"' to value with void type");
858 return;
859 }
860
861 assert(inFunctionScope() && "Must be in function scope!");
862 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
863 if (ST.lookup(Name)) {
864 GenerateError("Redefinition of value '" + Name + "' of type '" +
865 V->getType()->getDescription() + "'");
866 return;
867 }
868
869 // Set the name.
870 V->setName(Name);
871}
872
873/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
874/// this is a declaration, otherwise it is a definition.
875static GlobalVariable *
876ParseGlobalVariable(std::string *NameStr,
877 GlobalValue::LinkageTypes Linkage,
878 GlobalValue::VisibilityTypes Visibility,
879 bool isConstantGlobal, const Type *Ty,
Christopher Lamb0a243582007-12-11 09:02:08 +0000880 Constant *Initializer, bool IsThreadLocal,
881 unsigned AddressSpace = 0) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000882 if (isa<FunctionType>(Ty)) {
883 GenerateError("Cannot declare global vars of function type");
884 return 0;
885 }
886
Christopher Lamb0a243582007-12-11 09:02:08 +0000887 const PointerType *PTy = PointerType::get(Ty, AddressSpace);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000888
889 std::string Name;
890 if (NameStr) {
891 Name = *NameStr; // Copy string
892 delete NameStr; // Free old string
893 }
894
895 // See if this global value was forward referenced. If so, recycle the
896 // object.
897 ValID ID;
898 if (!Name.empty()) {
899 ID = ValID::createGlobalName(Name);
900 } else {
901 ID = ValID::createGlobalID(CurModule.Values.size());
902 }
903
904 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
905 // Move the global to the end of the list, from whereever it was
906 // previously inserted.
907 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
908 CurModule.CurrentModule->getGlobalList().remove(GV);
909 CurModule.CurrentModule->getGlobalList().push_back(GV);
910 GV->setInitializer(Initializer);
911 GV->setLinkage(Linkage);
912 GV->setVisibility(Visibility);
913 GV->setConstant(isConstantGlobal);
914 GV->setThreadLocal(IsThreadLocal);
915 InsertValue(GV, CurModule.Values);
916 return GV;
917 }
918
919 // If this global has a name
920 if (!Name.empty()) {
921 // if the global we're parsing has an initializer (is a definition) and
922 // has external linkage.
923 if (Initializer && Linkage != GlobalValue::InternalLinkage)
924 // If there is already a global with external linkage with this name
925 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
926 // If we allow this GVar to get created, it will be renamed in the
927 // symbol table because it conflicts with an existing GVar. We can't
928 // allow redefinition of GVars whose linking indicates that their name
929 // must stay the same. Issue the error.
930 GenerateError("Redefinition of global variable named '" + Name +
931 "' of type '" + Ty->getDescription() + "'");
932 return 0;
933 }
934 }
935
936 // Otherwise there is no existing GV to use, create one now.
937 GlobalVariable *GV =
938 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
Christopher Lamb0a243582007-12-11 09:02:08 +0000939 CurModule.CurrentModule, IsThreadLocal, AddressSpace);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000940 GV->setVisibility(Visibility);
941 InsertValue(GV, CurModule.Values);
942 return GV;
943}
944
945// setTypeName - Set the specified type to the name given. The name may be
946// null potentially, in which case this is a noop. The string passed in is
947// assumed to be a malloc'd string buffer, and is freed by this function.
948//
949// This function returns true if the type has already been defined, but is
950// allowed to be redefined in the specified context. If the name is a new name
951// for the type plane, it is inserted and false is returned.
952static bool setTypeName(const Type *T, std::string *NameStr) {
953 assert(!inFunctionScope() && "Can't give types function-local names!");
954 if (NameStr == 0) return false;
955
956 std::string Name(*NameStr); // Copy string
957 delete NameStr; // Free old string
958
959 // We don't allow assigning names to void type
960 if (T == Type::VoidTy) {
961 GenerateError("Can't assign name '" + Name + "' to the void type");
962 return false;
963 }
964
965 // Set the type name, checking for conflicts as we do so.
966 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
967
968 if (AlreadyExists) { // Inserting a name that is already defined???
969 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
970 assert(Existing && "Conflict but no matching type?!");
971
972 // There is only one case where this is allowed: when we are refining an
973 // opaque type. In this case, Existing will be an opaque type.
974 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
975 // We ARE replacing an opaque type!
976 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
977 return true;
978 }
979
980 // Otherwise, this is an attempt to redefine a type. That's okay if
981 // the redefinition is identical to the original. This will be so if
982 // Existing and T point to the same Type object. In this one case we
983 // allow the equivalent redefinition.
984 if (Existing == T) return true; // Yes, it's equal.
985
986 // Any other kind of (non-equivalent) redefinition is an error.
987 GenerateError("Redefinition of type named '" + Name + "' of type '" +
988 T->getDescription() + "'");
989 }
990
991 return false;
992}
993
994//===----------------------------------------------------------------------===//
995// Code for handling upreferences in type names...
996//
997
998// TypeContains - Returns true if Ty directly contains E in it.
999//
1000static bool TypeContains(const Type *Ty, const Type *E) {
1001 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1002 E) != Ty->subtype_end();
1003}
1004
1005namespace {
1006 struct UpRefRecord {
1007 // NestingLevel - The number of nesting levels that need to be popped before
1008 // this type is resolved.
1009 unsigned NestingLevel;
1010
1011 // LastContainedTy - This is the type at the current binding level for the
1012 // type. Every time we reduce the nesting level, this gets updated.
1013 const Type *LastContainedTy;
1014
1015 // UpRefTy - This is the actual opaque type that the upreference is
1016 // represented with.
1017 OpaqueType *UpRefTy;
1018
1019 UpRefRecord(unsigned NL, OpaqueType *URTy)
1020 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1021 };
1022}
1023
1024// UpRefs - A list of the outstanding upreferences that need to be resolved.
1025static std::vector<UpRefRecord> UpRefs;
1026
1027/// HandleUpRefs - Every time we finish a new layer of types, this function is
1028/// called. It loops through the UpRefs vector, which is a list of the
1029/// currently active types. For each type, if the up reference is contained in
1030/// the newly completed type, we decrement the level count. When the level
1031/// count reaches zero, the upreferenced type is the type that is passed in:
1032/// thus we can complete the cycle.
1033///
1034static PATypeHolder HandleUpRefs(const Type *ty) {
1035 // If Ty isn't abstract, or if there are no up-references in it, then there is
1036 // nothing to resolve here.
1037 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1038
1039 PATypeHolder Ty(ty);
1040 UR_OUT("Type '" << Ty->getDescription() <<
1041 "' newly formed. Resolving upreferences.\n" <<
1042 UpRefs.size() << " upreferences active!\n");
1043
1044 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1045 // to zero), we resolve them all together before we resolve them to Ty. At
1046 // the end of the loop, if there is anything to resolve to Ty, it will be in
1047 // this variable.
1048 OpaqueType *TypeToResolve = 0;
1049
1050 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1051 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1052 << UpRefs[i].second->getDescription() << ") = "
1053 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1054 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1055 // Decrement level of upreference
1056 unsigned Level = --UpRefs[i].NestingLevel;
1057 UpRefs[i].LastContainedTy = Ty;
1058 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1059 if (Level == 0) { // Upreference should be resolved!
1060 if (!TypeToResolve) {
1061 TypeToResolve = UpRefs[i].UpRefTy;
1062 } else {
1063 UR_OUT(" * Resolving upreference for "
1064 << UpRefs[i].second->getDescription() << "\n";
1065 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1066 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1067 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1068 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1069 }
1070 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1071 --i; // Do not skip the next element...
1072 }
1073 }
1074 }
1075
1076 if (TypeToResolve) {
1077 UR_OUT(" * Resolving upreference for "
1078 << UpRefs[i].second->getDescription() << "\n";
1079 std::string OldName = TypeToResolve->getDescription());
1080 TypeToResolve->refineAbstractTypeTo(Ty);
1081 }
1082
1083 return Ty;
1084}
1085
1086//===----------------------------------------------------------------------===//
1087// RunVMAsmParser - Define an interface to this parser
1088//===----------------------------------------------------------------------===//
1089//
1090static Module* RunParser(Module * M);
1091
Duncan Sandsf5588dc2007-11-27 13:23:08 +00001092Module *llvm::RunVMAsmParser(llvm::MemoryBuffer *MB) {
1093 InitLLLexer(MB);
1094 Module *M = RunParser(new Module(LLLgetFilename()));
1095 FreeLexer();
1096 return M;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001097}
1098
1099
Gabor Greif89f01162008-04-06 23:07:54 +00001100#line 950 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
1101typedef union {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001102 llvm::Module *ModuleVal;
1103 llvm::Function *FunctionVal;
1104 llvm::BasicBlock *BasicBlockVal;
1105 llvm::TerminatorInst *TermInstVal;
1106 llvm::Instruction *InstVal;
1107 llvm::Constant *ConstVal;
1108
1109 const llvm::Type *PrimType;
1110 std::list<llvm::PATypeHolder> *TypeList;
1111 llvm::PATypeHolder *TypeVal;
1112 llvm::Value *ValueVal;
1113 std::vector<llvm::Value*> *ValueList;
1114 llvm::ArgListType *ArgList;
1115 llvm::TypeWithAttrs TypeWithAttrs;
1116 llvm::TypeWithAttrsList *TypeWithAttrsList;
Dale Johannesencfb19e62007-11-05 21:20:28 +00001117 llvm::ParamList *ParamList;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001118
1119 // Represent the RHS of PHI node
1120 std::list<std::pair<llvm::Value*,
1121 llvm::BasicBlock*> > *PHIList;
1122 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1123 std::vector<llvm::Constant*> *ConstVector;
1124
1125 llvm::GlobalValue::LinkageTypes Linkage;
1126 llvm::GlobalValue::VisibilityTypes Visibility;
Dale Johannesend915ee52008-02-19 21:40:51 +00001127 llvm::ParameterAttributes ParamAttrs;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001128 llvm::APInt *APIntVal;
1129 int64_t SInt64Val;
1130 uint64_t UInt64Val;
1131 int SIntVal;
1132 unsigned UIntVal;
Dale Johannesen3afee192007-09-07 21:07:57 +00001133 llvm::APFloat *FPVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001134 bool BoolVal;
1135
1136 std::string *StrVal; // This memory must be deleted
1137 llvm::ValID ValIDVal;
1138
1139 llvm::Instruction::BinaryOps BinaryOpVal;
1140 llvm::Instruction::TermOps TermOpVal;
1141 llvm::Instruction::MemoryOps MemOpVal;
1142 llvm::Instruction::CastOps CastOpVal;
1143 llvm::Instruction::OtherOps OtherOpVal;
1144 llvm::ICmpInst::Predicate IPredicate;
1145 llvm::FCmpInst::Predicate FPredicate;
Gabor Greif89f01162008-04-06 23:07:54 +00001146} YYSTYPE;
1147#include <stdio.h>
1148
1149#ifndef __cplusplus
1150#ifndef __STDC__
1151#define const
1152#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001153#endif
1154
1155
1156
Gabor Greif89f01162008-04-06 23:07:54 +00001157#define YYFINAL 635
1158#define YYFLAG -32768
1159#define YYNTBASE 166
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001160
Gabor Greif89f01162008-04-06 23:07:54 +00001161#define YYTRANSLATE(x) ((unsigned)(x) <= 405 ? yytranslate[x] : 250)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001162
Gabor Greif89f01162008-04-06 23:07:54 +00001163static const short yytranslate[] = { 0,
1164 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1165 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1166 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1167 2, 2, 2, 2, 2, 2, 2, 2, 2, 152,
1168 153, 156, 2, 155, 2, 2, 2, 2, 2, 2,
1169 2, 2, 2, 2, 2, 2, 2, 2, 2, 161,
1170 154, 162, 2, 2, 2, 2, 2, 2, 2, 2,
1171 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1172 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1173 158, 157, 160, 2, 2, 2, 2, 2, 165, 2,
1174 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1175 2, 2, 2, 2, 2, 2, 2, 2, 2, 159,
1176 2, 2, 163, 2, 164, 2, 2, 2, 2, 2,
1177 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1178 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1179 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1180 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1181 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1182 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1183 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1184 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1185 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1186 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1187 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1188 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1189 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
1190 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1191 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1192 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
1193 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
1194 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
1195 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1196 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1197 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1198 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
1199 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
1200 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
1201 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
1202 127, 128, 129, 130, 131, 132, 133, 134, 135, 136,
1203 137, 138, 139, 140, 141, 142, 143, 144, 145, 146,
1204 147, 148, 149, 150, 151
1205};
Reid Spenceraa8ae282007-07-31 03:50:36 +00001206
Gabor Greif89f01162008-04-06 23:07:54 +00001207#if YYDEBUG != 0
1208static const short yyprhs[] = { 0,
1209 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
1210 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
1211 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
1212 60, 62, 64, 66, 68, 70, 72, 74, 76, 78,
1213 80, 82, 84, 86, 88, 90, 92, 94, 96, 98,
1214 100, 102, 104, 106, 108, 110, 112, 114, 116, 118,
1215 120, 122, 124, 126, 127, 132, 133, 136, 137, 139,
1216 141, 143, 144, 147, 149, 151, 153, 155, 157, 159,
1217 161, 163, 164, 166, 168, 170, 171, 173, 175, 176,
1218 178, 180, 182, 184, 185, 187, 189, 190, 192, 194,
1219 196, 198, 200, 203, 205, 207, 209, 211, 213, 215,
1220 217, 219, 221, 224, 225, 228, 230, 232, 234, 236,
1221 238, 240, 241, 244, 245, 248, 249, 252, 253, 257,
1222 260, 261, 263, 264, 268, 270, 273, 275, 277, 279,
1223 281, 283, 285, 287, 289, 291, 295, 297, 300, 306,
1224 312, 318, 324, 328, 331, 337, 342, 345, 347, 349,
1225 351, 355, 357, 361, 363, 364, 366, 370, 375, 379,
1226 383, 388, 393, 397, 404, 410, 413, 416, 419, 422,
1227 425, 428, 431, 434, 437, 440, 443, 446, 453, 459,
1228 468, 475, 482, 490, 498, 505, 514, 523, 527, 529,
1229 531, 533, 535, 536, 539, 546, 548, 549, 551, 554,
1230 555, 559, 560, 564, 568, 572, 576, 577, 586, 587,
1231 597, 598, 608, 614, 617, 621, 623, 627, 631, 635,
1232 639, 641, 642, 648, 652, 654, 658, 660, 661, 672,
1233 674, 676, 681, 683, 685, 688, 692, 693, 695, 697,
1234 699, 701, 703, 705, 707, 709, 711, 715, 717, 723,
1235 725, 727, 729, 731, 733, 735, 738, 740, 744, 747,
1236 750, 754, 757, 758, 762, 764, 769, 772, 775, 779,
1237 789, 799, 808, 823, 825, 827, 834, 840, 843, 850,
1238 858, 863, 868, 875, 882, 883, 884, 888, 891, 893,
1239 899, 905, 912, 919, 924, 931, 936, 941, 948, 955,
1240 958, 967, 969, 971, 972, 976, 983, 987, 994, 997,
1241 1003, 1011, 1017
1242};
1243
1244static const short yyrhs[] = { 75,
1245 0, 76, 0, 77, 0, 78, 0, 79, 0, 80,
1246 0, 81, 0, 82, 0, 83, 0, 87, 0, 88,
1247 0, 89, 0, 84, 0, 85, 0, 86, 0, 118,
1248 0, 119, 0, 120, 0, 121, 0, 122, 0, 123,
1249 0, 124, 0, 125, 0, 126, 0, 127, 0, 128,
1250 0, 129, 0, 92, 0, 93, 0, 94, 0, 95,
1251 0, 96, 0, 97, 0, 98, 0, 99, 0, 100,
1252 0, 101, 0, 102, 0, 103, 0, 104, 0, 105,
1253 0, 106, 0, 107, 0, 108, 0, 109, 0, 110,
1254 0, 111, 0, 98, 0, 99, 0, 100, 0, 101,
1255 0, 26, 0, 27, 0, 11, 0, 12, 0, 13,
1256 0, 16, 0, 15, 0, 14, 0, 19, 0, 22,
1257 0, 24, 0, 173, 0, 0, 54, 152, 4, 153,
1258 0, 0, 173, 154, 0, 0, 20, 0, 23, 0,
1259 179, 0, 0, 177, 154, 0, 42, 0, 44, 0,
1260 43, 0, 45, 0, 47, 0, 46, 0, 48, 0,
1261 50, 0, 0, 149, 0, 150, 0, 151, 0, 0,
1262 46, 0, 48, 0, 0, 42, 0, 43, 0, 44,
1263 0, 47, 0, 0, 44, 0, 42, 0, 0, 62,
1264 0, 63, 0, 64, 0, 65, 0, 66, 0, 61,
1265 4, 0, 138, 0, 119, 0, 137, 0, 120, 0,
1266 140, 0, 141, 0, 143, 0, 144, 0, 145, 0,
1267 53, 4, 0, 0, 188, 187, 0, 139, 0, 142,
1268 0, 138, 0, 137, 0, 146, 0, 147, 0, 0,
1269 190, 189, 0, 0, 148, 22, 0, 0, 53, 4,
1270 0, 0, 155, 53, 4, 0, 34, 22, 0, 0,
1271 194, 0, 0, 155, 197, 196, 0, 194, 0, 53,
1272 4, 0, 11, 0, 12, 0, 13, 0, 16, 0,
1273 15, 0, 14, 0, 17, 0, 49, 0, 198, 0,
1274 199, 175, 156, 0, 233, 0, 157, 4, 0, 199,
1275 152, 203, 153, 190, 0, 10, 152, 203, 153, 190,
1276 0, 158, 4, 159, 199, 160, 0, 161, 4, 159,
1277 199, 162, 0, 163, 204, 164, 0, 163, 164, 0,
1278 161, 163, 204, 164, 162, 0, 161, 163, 164, 162,
1279 0, 199, 188, 0, 199, 0, 10, 0, 200, 0,
1280 202, 155, 200, 0, 202, 0, 202, 155, 39, 0,
1281 39, 0, 0, 199, 0, 204, 155, 199, 0, 199,
1282 158, 207, 160, 0, 199, 158, 160, 0, 199, 165,
1283 22, 0, 199, 161, 207, 162, 0, 199, 163, 207,
1284 164, 0, 199, 163, 164, 0, 199, 161, 163, 207,
1285 164, 162, 0, 199, 161, 163, 164, 162, 0, 199,
1286 40, 0, 199, 41, 0, 199, 233, 0, 199, 206,
1287 0, 199, 25, 0, 171, 3, 0, 171, 5, 0,
1288 171, 4, 0, 171, 6, 0, 11, 26, 0, 11,
1289 27, 0, 172, 9, 0, 168, 152, 205, 38, 199,
1290 153, 0, 117, 152, 205, 245, 153, 0, 131, 152,
1291 205, 155, 205, 155, 205, 153, 0, 166, 152, 205,
1292 155, 205, 153, 0, 167, 152, 205, 155, 205, 153,
1293 0, 90, 169, 152, 205, 155, 205, 153, 0, 91,
1294 170, 152, 205, 155, 205, 153, 0, 133, 152, 205,
1295 155, 205, 153, 0, 134, 152, 205, 155, 205, 155,
1296 205, 153, 0, 135, 152, 205, 155, 205, 155, 205,
1297 153, 0, 207, 155, 205, 0, 205, 0, 32, 0,
1298 33, 0, 37, 0, 0, 201, 233, 0, 123, 152,
1299 210, 38, 199, 153, 0, 212, 0, 0, 213, 0,
1300 212, 213, 0, 0, 31, 214, 229, 0, 0, 30,
1301 215, 230, 0, 59, 58, 219, 0, 176, 18, 199,
1302 0, 176, 18, 10, 0, 0, 178, 182, 209, 208,
1303 205, 175, 216, 196, 0, 0, 178, 180, 182, 209,
1304 208, 205, 175, 217, 196, 0, 0, 178, 181, 182,
1305 209, 208, 199, 175, 218, 196, 0, 178, 182, 35,
1306 185, 210, 0, 51, 220, 0, 55, 154, 221, 0,
1307 22, 0, 52, 154, 22, 0, 67, 154, 22, 0,
1308 158, 222, 160, 0, 222, 155, 22, 0, 22, 0,
1309 0, 223, 155, 199, 188, 174, 0, 199, 188, 174,
1310 0, 223, 0, 223, 155, 39, 0, 39, 0, 0,
1311 186, 201, 177, 152, 224, 153, 190, 195, 192, 191,
1312 0, 28, 0, 163, 0, 184, 182, 225, 226, 0,
1313 29, 0, 164, 0, 237, 228, 0, 183, 182, 225,
1314 0, 0, 60, 0, 3, 0, 4, 0, 9, 0,
1315 26, 0, 27, 0, 40, 0, 41, 0, 25, 0,
1316 161, 207, 162, 0, 206, 0, 58, 231, 22, 155,
1317 22, 0, 7, 0, 8, 0, 173, 0, 177, 0,
1318 233, 0, 232, 0, 199, 234, 0, 235, 0, 236,
1319 155, 235, 0, 237, 238, 0, 227, 238, 0, 239,
1320 176, 240, 0, 239, 242, 0, 0, 68, 38, 234,
1321 0, 21, 0, 21, 68, 38, 234, 0, 69, 236,
1322 0, 69, 10, 0, 70, 17, 234, 0, 70, 11,
1323 234, 155, 17, 234, 155, 17, 234, 0, 71, 171,
1324 234, 155, 17, 234, 158, 241, 160, 0, 71, 171,
1325 234, 155, 17, 234, 158, 160, 0, 72, 186, 201,
1326 234, 152, 244, 153, 190, 38, 17, 234, 73, 17,
1327 234, 0, 73, 0, 74, 0, 241, 171, 232, 155,
1328 17, 234, 0, 171, 232, 155, 17, 234, 0, 176,
1329 247, 0, 199, 158, 234, 155, 234, 160, 0, 243,
1330 155, 158, 234, 155, 234, 160, 0, 199, 188, 234,
1331 188, 0, 17, 188, 234, 188, 0, 244, 155, 199,
1332 188, 234, 188, 0, 244, 155, 17, 188, 234, 188,
1333 0, 0, 0, 245, 155, 235, 0, 57, 56, 0,
1334 56, 0, 166, 199, 234, 155, 234, 0, 167, 199,
1335 234, 155, 234, 0, 90, 169, 199, 234, 155, 234,
1336 0, 91, 170, 199, 234, 155, 234, 0, 168, 235,
1337 38, 199, 0, 131, 235, 155, 235, 155, 235, 0,
1338 132, 235, 155, 199, 0, 133, 235, 155, 235, 0,
1339 134, 235, 155, 235, 155, 235, 0, 135, 235, 155,
1340 235, 155, 235, 0, 130, 243, 0, 246, 186, 201,
1341 234, 152, 244, 153, 190, 0, 249, 0, 36, 0,
1342 0, 112, 199, 193, 0, 112, 199, 155, 11, 234,
1343 193, 0, 113, 199, 193, 0, 113, 199, 155, 11,
1344 234, 193, 0, 114, 235, 0, 248, 115, 199, 234,
1345 193, 0, 248, 116, 235, 155, 199, 234, 193, 0,
1346 136, 199, 233, 155, 4, 0, 117, 199, 234, 245,
1347 0
1348};
1349
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001350#endif
1351
Gabor Greif89f01162008-04-06 23:07:54 +00001352#if YYDEBUG != 0
1353static const short yyrline[] = { 0,
1354 1112, 1112, 1112, 1112, 1112, 1112, 1112, 1112, 1112, 1113,
1355 1113, 1113, 1113, 1113, 1113, 1114, 1114, 1114, 1114, 1114,
1356 1114, 1114, 1115, 1115, 1115, 1115, 1115, 1118, 1118, 1119,
1357 1119, 1120, 1120, 1121, 1121, 1122, 1122, 1126, 1126, 1127,
1358 1127, 1128, 1128, 1129, 1129, 1130, 1130, 1131, 1131, 1132,
1359 1132, 1133, 1134, 1139, 1140, 1140, 1140, 1140, 1140, 1142,
1360 1142, 1142, 1143, 1143, 1145, 1146, 1150, 1154, 1159, 1159,
1361 1161, 1162, 1167, 1173, 1174, 1175, 1176, 1177, 1181, 1182,
1362 1183, 1187, 1188, 1189, 1190, 1194, 1195, 1196, 1200, 1201,
1363 1202, 1203, 1204, 1208, 1209, 1210, 1213, 1213, 1214, 1215,
1364 1216, 1217, 1218, 1226, 1227, 1228, 1229, 1230, 1231, 1232,
1365 1233, 1234, 1235, 1239, 1240, 1245, 1246, 1247, 1248, 1249,
1366 1250, 1253, 1254, 1259, 1260, 1267, 1267, 1274, 1274, 1284,
1367 1292, 1292, 1298, 1298, 1300, 1305, 1318, 1318, 1318, 1318,
1368 1318, 1318, 1318, 1321, 1325, 1329, 1336, 1341, 1349, 1379,
1369 1404, 1409, 1419, 1429, 1433, 1443, 1450, 1459, 1466, 1471,
1370 1476, 1483, 1484, 1491, 1498, 1506, 1512, 1524, 1552, 1568,
1371 1595, 1623, 1649, 1669, 1695, 1715, 1727, 1734, 1800, 1810,
1372 1820, 1826, 1836, 1842, 1852, 1857, 1862, 1875, 1887, 1909,
1373 1917, 1923, 1934, 1939, 1944, 1950, 1956, 1965, 1969, 1977,
1374 1977, 1980, 1980, 1983, 1995, 2016, 2021, 2029, 2030, 2034,
1375 2034, 2038, 2038, 2041, 2044, 2068, 2079, 2087, 2090, 2096,
1376 2099, 2106, 2110, 2150, 2153, 2159, 2169, 2173, 2178, 2180,
1377 2185, 2190, 2199, 2209, 2220, 2224, 2233, 2242, 2247, 2373,
1378 2373, 2375, 2384, 2384, 2386, 2391, 2403, 2407, 2412, 2416,
1379 2420, 2424, 2428, 2432, 2436, 2440, 2444, 2469, 2473, 2483,
1380 2487, 2491, 2496, 2503, 2503, 2509, 2518, 2523, 2528, 2532,
1381 2541, 2550, 2559, 2563, 2567, 2572, 2578, 2586, 2590, 2595,
1382 2605, 2624, 2633, 2714, 2718, 2725, 2736, 2749, 2759, 2770,
1383 2780, 2791, 2799, 2809, 2816, 2819, 2820, 2827, 2831, 2836,
1384 2852, 2869, 2883, 2897, 2909, 2917, 2924, 2930, 2936, 2942,
1385 2957, 3043, 3048, 3052, 3059, 3066, 3074, 3081, 3089, 3097,
1386 3111, 3128, 3136
1387};
1388#endif
1389
1390
1391#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
1392
1393static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL",
1394"EUINT64VAL","ESAPINTVAL","EUAPINTVAL","LOCALVAL_ID","GLOBALVAL_ID","FPVAL",
1395"VOID","INTTYPE","FLOAT","DOUBLE","X86_FP80","FP128","PPC_FP128","LABEL","TYPE",
1396"LOCALVAR","GLOBALVAR","LABELSTR","STRINGCONSTANT","ATSTRINGCONSTANT","PCTSTRINGCONSTANT",
1397"ZEROINITIALIZER","TRUETOK","FALSETOK","BEGINTOK","ENDTOK","DECLARE","DEFINE",
1398"GLOBAL","CONSTANT","SECTION","ALIAS","VOLATILE","THREAD_LOCAL","TO","DOTDOTDOT",
1399"NULL_TOK","UNDEF","INTERNAL","LINKONCE","WEAK","APPENDING","DLLIMPORT","DLLEXPORT",
1400"EXTERN_WEAK","OPAQUE","EXTERNAL","TARGET","TRIPLE","ALIGN","ADDRSPACE","DEPLIBS",
1401"CALL","TAIL","ASM_TOK","MODULE","SIDEEFFECT","CC_TOK","CCC_TOK","FASTCC_TOK",
1402"COLDCC_TOK","X86_STDCALLCC_TOK","X86_FASTCALLCC_TOK","DATALAYOUT","UNWINDS",
1403"RET","BR","SWITCH","INVOKE","UNWIND","UNREACHABLE","ADD","SUB","MUL","UDIV",
1404"SDIV","FDIV","UREM","SREM","FREM","AND","OR","XOR","SHL","LSHR","ASHR","ICMP",
1405"FCMP","EQ","NE","SLT","SGT","SLE","SGE","ULT","UGT","ULE","UGE","OEQ","ONE",
1406"OLT","OGT","OLE","OGE","ORD","UNO","UEQ","UNE","MALLOC","ALLOCA","FREE","LOAD",
1407"STORE","GETELEMENTPTR","TRUNC","ZEXT","SEXT","FPTRUNC","FPEXT","BITCAST","UITOFP",
1408"SITOFP","FPTOUI","FPTOSI","INTTOPTR","PTRTOINT","PHI_TOK","SELECT","VAARG",
1409"EXTRACTELEMENT","INSERTELEMENT","SHUFFLEVECTOR","GETRESULT","SIGNEXT","ZEROEXT",
1410"NORETURN","INREG","SRET","NOUNWIND","NOALIAS","BYVAL","NEST","READNONE","READONLY",
1411"GC","DEFAULT","HIDDEN","PROTECTED","'('","')'","'='","','","'*'","'\\\\'","'['",
1412"'x'","']'","'<'","'>'","'{'","'}'","'c'","ArithmeticOps","LogicalOps","CastOps",
1413"IPredicates","FPredicates","IntType","FPType","LocalName","OptLocalName","OptAddrSpace",
1414"OptLocalAssign","GlobalName","OptGlobalAssign","GlobalAssign","GVInternalLinkage",
1415"GVExternalLinkage","GVVisibilityStyle","FunctionDeclareLinkage","FunctionDefineLinkage",
1416"AliasLinkage","OptCallingConv","ParamAttr","OptParamAttrs","FuncAttr","OptFuncAttrs",
1417"OptGC","OptAlign","OptCAlign","SectionString","OptSection","GlobalVarAttributes",
1418"GlobalVarAttribute","PrimType","Types","ArgType","ResultTypes","ArgTypeList",
1419"ArgTypeListI","TypeListI","ConstVal","ConstExpr","ConstVector","GlobalType",
1420"ThreadLocal","AliaseeRef","Module","DefinitionList","Definition","@1","@2",
1421"@3","@4","@5","AsmBlock","TargetDefinition","LibrariesDefinition","LibList",
1422"ArgListH","ArgList","FunctionHeaderH","BEGIN","FunctionHeader","END","Function",
1423"FunctionProto","OptSideEffect","ConstValueRef","SymbolicValueRef","ValueRef",
1424"ResolvedVal","ReturnedVal","BasicBlockList","BasicBlock","InstructionList",
1425"BBTerminatorInst","JumpTable","Inst","PHIList","ParamList","IndexList","OptTailCall",
1426"InstVal","OptVolatile","MemoryInst", NULL
1427};
1428#endif
1429
1430static const short yyr1[] = { 0,
1431 166, 166, 166, 166, 166, 166, 166, 166, 166, 167,
1432 167, 167, 167, 167, 167, 168, 168, 168, 168, 168,
1433 168, 168, 168, 168, 168, 168, 168, 169, 169, 169,
1434 169, 169, 169, 169, 169, 169, 169, 170, 170, 170,
1435 170, 170, 170, 170, 170, 170, 170, 170, 170, 170,
1436 170, 170, 170, 171, 172, 172, 172, 172, 172, 173,
1437 173, 173, 174, 174, 175, 175, 176, 176, 177, 177,
1438 178, 178, 179, 180, 180, 180, 180, 180, 181, 181,
1439 181, 182, 182, 182, 182, 183, 183, 183, 184, 184,
1440 184, 184, 184, 185, 185, 185, 186, 186, 186, 186,
1441 186, 186, 186, 187, 187, 187, 187, 187, 187, 187,
1442 187, 187, 187, 188, 188, 189, 189, 189, 189, 189,
1443 189, 190, 190, 191, 191, 192, 192, 193, 193, 194,
1444 195, 195, 196, 196, 197, 197, 198, 198, 198, 198,
1445 198, 198, 198, 199, 199, 199, 199, 199, 199, 199,
1446 199, 199, 199, 199, 199, 199, 200, 201, 201, 202,
1447 202, 203, 203, 203, 203, 204, 204, 205, 205, 205,
1448 205, 205, 205, 205, 205, 205, 205, 205, 205, 205,
1449 205, 205, 205, 205, 205, 205, 205, 206, 206, 206,
1450 206, 206, 206, 206, 206, 206, 206, 207, 207, 208,
1451 208, 209, 209, 210, 210, 211, 211, 212, 212, 214,
1452 213, 215, 213, 213, 213, 213, 216, 213, 217, 213,
1453 218, 213, 213, 213, 213, 219, 220, 220, 221, 222,
1454 222, 222, 223, 223, 224, 224, 224, 224, 225, 226,
1455 226, 227, 228, 228, 229, 230, 231, 231, 232, 232,
1456 232, 232, 232, 232, 232, 232, 232, 232, 232, 233,
1457 233, 233, 233, 234, 234, 235, 236, 236, 237, 237,
1458 238, 239, 239, 239, 239, 239, 240, 240, 240, 240,
1459 240, 240, 240, 240, 240, 241, 241, 242, 243, 243,
1460 244, 244, 244, 244, 244, 245, 245, 246, 246, 247,
1461 247, 247, 247, 247, 247, 247, 247, 247, 247, 247,
1462 247, 247, 248, 248, 249, 249, 249, 249, 249, 249,
1463 249, 249, 249
1464};
1465
1466static const short yyr2[] = { 0,
1467 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1468 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1469 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1470 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1471 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1472 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1473 1, 1, 1, 0, 4, 0, 2, 0, 1, 1,
1474 1, 0, 2, 1, 1, 1, 1, 1, 1, 1,
1475 1, 0, 1, 1, 1, 0, 1, 1, 0, 1,
1476 1, 1, 1, 0, 1, 1, 0, 1, 1, 1,
1477 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
1478 1, 1, 2, 0, 2, 1, 1, 1, 1, 1,
1479 1, 0, 2, 0, 2, 0, 2, 0, 3, 2,
1480 0, 1, 0, 3, 1, 2, 1, 1, 1, 1,
1481 1, 1, 1, 1, 1, 3, 1, 2, 5, 5,
1482 5, 5, 3, 2, 5, 4, 2, 1, 1, 1,
1483 3, 1, 3, 1, 0, 1, 3, 4, 3, 3,
1484 4, 4, 3, 6, 5, 2, 2, 2, 2, 2,
1485 2, 2, 2, 2, 2, 2, 2, 6, 5, 8,
1486 6, 6, 7, 7, 6, 8, 8, 3, 1, 1,
1487 1, 1, 0, 2, 6, 1, 0, 1, 2, 0,
1488 3, 0, 3, 3, 3, 3, 0, 8, 0, 9,
1489 0, 9, 5, 2, 3, 1, 3, 3, 3, 3,
1490 1, 0, 5, 3, 1, 3, 1, 0, 10, 1,
1491 1, 4, 1, 1, 2, 3, 0, 1, 1, 1,
1492 1, 1, 1, 1, 1, 1, 3, 1, 5, 1,
1493 1, 1, 1, 1, 1, 2, 1, 3, 2, 2,
1494 3, 2, 0, 3, 1, 4, 2, 2, 3, 9,
1495 9, 8, 14, 1, 1, 6, 5, 2, 6, 7,
1496 4, 4, 6, 6, 0, 0, 3, 2, 1, 5,
1497 5, 6, 6, 4, 6, 4, 4, 6, 6, 2,
1498 8, 1, 1, 0, 3, 6, 3, 6, 2, 5,
1499 7, 5, 4
1500};
1501
1502static const short yydefact[] = { 72,
1503 60, 69, 61, 70, 62, 212, 210, 0, 0, 0,
1504 0, 0, 0, 82, 71, 72, 208, 86, 89, 0,
1505 0, 224, 0, 0, 67, 0, 73, 74, 76, 75,
1506 77, 79, 78, 80, 81, 83, 84, 85, 82, 82,
1507 203, 209, 87, 88, 82, 213, 90, 91, 92, 93,
1508 82, 273, 211, 273, 0, 0, 232, 225, 226, 214,
1509 260, 261, 216, 137, 138, 139, 142, 141, 140, 143,
1510 144, 0, 0, 0, 0, 262, 263, 145, 215, 147,
1511 203, 203, 94, 202, 0, 97, 97, 275, 0, 270,
1512 68, 243, 244, 245, 269, 227, 228, 231, 0, 165,
1513 148, 0, 0, 0, 0, 154, 166, 0, 0, 165,
1514 0, 0, 0, 96, 95, 0, 200, 201, 0, 0,
1515 98, 99, 100, 101, 102, 0, 246, 0, 0, 0,
1516 314, 272, 0, 229, 164, 114, 160, 162, 0, 0,
1517 0, 0, 0, 0, 153, 0, 0, 146, 0, 0,
1518 159, 0, 158, 0, 223, 137, 138, 139, 142, 141,
1519 140, 0, 0, 66, 66, 103, 0, 240, 241, 242,
1520 0, 249, 250, 251, 256, 252, 253, 254, 255, 247,
1521 1, 2, 3, 4, 5, 6, 7, 8, 9, 13,
1522 14, 15, 10, 11, 12, 0, 0, 0, 16, 17,
1523 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
1524 0, 0, 0, 0, 0, 0, 0, 0, 258, 265,
1525 264, 274, 313, 299, 0, 0, 0, 0, 97, 284,
1526 285, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1527 0, 0, 0, 0, 0, 0, 0, 271, 97, 288,
1528 0, 312, 230, 157, 0, 122, 66, 66, 156, 0,
1529 167, 0, 122, 66, 66, 0, 204, 185, 186, 181,
1530 183, 182, 184, 187, 180, 176, 177, 0, 0, 0,
1531 0, 179, 178, 217, 0, 276, 248, 0, 28, 29,
1532 30, 31, 32, 33, 34, 35, 36, 37, 0, 52,
1533 53, 48, 49, 50, 51, 38, 39, 40, 41, 42,
1534 43, 44, 45, 46, 47, 0, 0, 0, 0, 0,
1535 0, 199, 0, 0, 0, 0, 298, 278, 66, 267,
1536 277, 0, 0, 54, 0, 0, 0, 0, 128, 128,
1537 319, 66, 66, 310, 0, 0, 0, 0, 0, 66,
1538 66, 66, 0, 0, 0, 0, 0, 105, 107, 106,
1539 104, 108, 109, 110, 111, 112, 115, 163, 161, 150,
1540 151, 152, 155, 65, 149, 219, 221, 0, 169, 0,
1541 0, 0, 173, 0, 170, 133, 238, 0, 0, 0,
1542 296, 0, 0, 0, 0, 0, 257, 0, 0, 0,
1543 266, 0, 0, 279, 0, 0, 66, 66, 0, 315,
1544 0, 317, 296, 0, 0, 0, 0, 0, 0, 0,
1545 0, 0, 0, 0, 0, 66, 0, 113, 119, 118,
1546 116, 117, 120, 121, 123, 133, 133, 0, 168, 154,
1547 166, 0, 171, 172, 0, 218, 237, 114, 235, 0,
1548 0, 0, 0, 0, 0, 0, 0, 0, 198, 0,
1549 0, 0, 268, 0, 0, 0, 0, 0, 0, 0,
1550 0, 323, 0, 0, 0, 306, 307, 0, 0, 0,
1551 0, 0, 304, 0, 128, 0, 220, 222, 66, 175,
1552 0, 0, 0, 135, 133, 64, 0, 122, 259, 0,
1553 0, 189, 0, 0, 0, 0, 0, 0, 0, 66,
1554 0, 0, 295, 0, 0, 128, 129, 128, 0, 0,
1555 0, 0, 0, 322, 300, 301, 295, 0, 320, 66,
1556 205, 174, 130, 136, 134, 63, 234, 236, 114, 131,
1557 0, 0, 297, 0, 195, 0, 0, 191, 192, 188,
1558 0, 0, 114, 114, 0, 302, 303, 316, 318, 0,
1559 0, 305, 308, 309, 0, 128, 64, 132, 126, 193,
1560 194, 0, 0, 0, 0, 0, 0, 0, 122, 0,
1561 289, 0, 122, 321, 233, 0, 124, 190, 196, 197,
1562 0, 282, 0, 0, 105, 107, 114, 114, 0, 114,
1563 114, 290, 311, 127, 0, 239, 280, 0, 281, 0,
1564 292, 291, 0, 0, 0, 125, 0, 0, 0, 114,
1565 114, 0, 0, 0, 294, 293, 287, 0, 0, 286,
1566 0, 283, 0, 0, 0
1567};
1568
1569static const short yydefgoto[] = { 216,
1570 217, 218, 299, 316, 162, 163, 76, 537, 111, 12,
1571 77, 14, 15, 39, 40, 41, 45, 51, 116, 126,
1572 367, 254, 435, 370, 606, 587, 410, 494, 569, 446,
1573 495, 78, 164, 137, 154, 138, 139, 108, 322, 219,
1574 323, 119, 85, 155, 633, 16, 17, 19, 18, 386,
1575 436, 437, 60, 22, 58, 99, 449, 450, 127, 170,
1576 52, 94, 53, 46, 288, 220, 80, 222, 330, 331,
1577 54, 90, 91, 248, 594, 132, 344, 555, 454, 249,
1578 250, 251, 252
1579};
1580
1581static const short yypact[] = { 504,
1582-32768,-32768,-32768,-32768,-32768,-32768,-32768, -13, -126, -26,
1583 -90, 107, -69, 256,-32768, 633,-32768, 126, 205, 19,
1584 29,-32768, 31, 125,-32768, 1570,-32768,-32768,-32768,-32768,
1585-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 174, 174,
1586 190,-32768,-32768,-32768, 174,-32768,-32768,-32768,-32768,-32768,
1587 174, 1,-32768, -2, 178, 202, 212,-32768,-32768,-32768,
1588-32768,-32768, 83,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1589-32768, 251, 257, 8, 33,-32768,-32768,-32768, 74,-32768,
1590 223, 223, 253,-32768, 82, 255, 255, 200, 235,-32768,
1591 245,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -88, 1124,
1592-32768, 128, 137, 813, 83,-32768, 74, -65, 134, 1124,
1593 154, 82, 82,-32768,-32768, 1370,-32768,-32768, 1610, 307,
1594-32768,-32768,-32768,-32768,-32768, 1650,-32768, -7, 289, 904,
1595 1865,-32768, 306,-32768,-32768, 74,-32768, 179, 176, 1690,
1596 1690, 177, -55, 1690,-32768, 338, 198,-32768, 1610, 1690,
1597 83, 191, 74, 365,-32768, 342, 344, 345, 351, 361,
1598 372, 273, 373, 1180, 332,-32768, 162,-32768,-32768,-32768,
1599 904,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 323,
1600-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1601-32768,-32768,-32768,-32768,-32768, 329, 489, 238,-32768,-32768,
1602-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1603 239, 246, 250, 258, 1610, 261, 263, 264,-32768,-32768,
1604-32768,-32768,-32768,-32768, 341, 1730, 102, 392, 255,-32768,
1605-32768, 329, 489, 1690, 1690, 1690, 1690, 1690, 1690, 1690,
1606 1690, 1690, 1690, 1690, 1690, 1690, 1690,-32768, 255,-32768,
1607 45,-32768,-32768, 221, 1450,-32768, 7, -29,-32768, 247,
1608 74, 265,-32768, 332, -30, 1370,-32768,-32768,-32768,-32768,
1609-32768,-32768,-32768,-32768,-32768,-32768,-32768, 1410, 1770, 853,
1610 386,-32768,-32768,-32768, 279,-32768,-32768, 395,-32768,-32768,
1611-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 280,-32768,
1612-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1613-32768,-32768,-32768,-32768,-32768, 282, 1610, 1610, 1610, 1610,
1614 1610,-32768, -67, 1610, 1610, 1610,-32768, 83, 764,-32768,
1615 285, 904, 904,-32768, 904, 1650, 1690, 1690, 43, 49,
1616-32768, 764, -31, 288, 292, 293, 295, 296, 297, 51,
1617 764, 764, 397, 1650, 1690, 1690, 449,-32768,-32768,-32768,
1618-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 146,
1619-32768,-32768,-32768,-32768, 146,-32768, 154, 416,-32768, -62,
1620 1078, -10,-32768, -15,-32768, 302, 1490, 303, 1610, 1610,
1621-32768, 304, 309, 312, 313, 1610,-32768, 314, 315, 423,
1622-32768, 1690, 316,-32768, 317, 904, 764, 764, 25,-32768,
1623 26,-32768,-32768, 904, 318, 1690, 1690, 1690, 1690, 1690,
1624 319, 320, 322, 1690, 904, 764, 325,-32768,-32768,-32768,
1625-32768,-32768,-32768,-32768,-32768, 302, 302, 1690,-32768, 321,
1626 1033, -11,-32768,-32768, 28,-32768,-32768, 74, 326, 331,
1627 456, 327, 330, 152, 1610, 1610, 1610, 1610,-32768, 1610,
1628 1610, 1690,-32768, 469, 470, 336, 335, 337, 904, 490,
1629 904, 340, 346, 904, 347, 74,-32768, 350, 354, 496,
1630 904, 904, 74, 362, 358, 1690,-32768,-32768, 23,-32768,
1631 355, 471, 502,-32768, 302, 113, 1530,-32768,-32768, 1610,
1632 1610,-32768, 1690, 364, 367, 370, 376, 379, 380, 54,
1633 904, 904, 1810, 904, 904, 358,-32768, 358, 904, 381,
1634 1690, 1690, 1690,-32768,-32768,-32768, 1810, 484,-32768, 764,
1635-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 74, -8,
1636 385, 387,-32768, 1610,-32768, 1610, 1610,-32768,-32768,-32768,
1637 384, 383, 114, 74, 180,-32768,-32768,-32768,-32768, 382,
1638 904,-32768,-32768,-32768, 197, 358, 113,-32768, 493,-32768,
1639-32768, 390, 394, 398, 531, 3, 621, 621,-32768, 1850,
1640-32768, 393,-32768,-32768,-32768, 546, 406,-32768,-32768,-32768,
1641 904,-32768, 1321, 9, 405, 408,-32768,-32768, 4, 114,
1642 74,-32768, 146,-32768, 540,-32768,-32768, 409,-32768, 1321,
1643 221, 221, 548, 621, 621,-32768, 549, 413, 904,-32768,
1644-32768, 904, 552, 497, 221, 221,-32768, 904, 554,-32768,
1645 904,-32768, 572, 574,-32768
1646};
1647
1648static const short yypgoto[] = { 445,
1649 446, 448, 348, 349, -227,-32768, 0, 14, -100, 492,
1650 13,-32768,-32768,-32768,-32768, 67,-32768,-32768,-32768, -166,
1651-32768, -443,-32768, -257,-32768,-32768, -337, 44,-32768, -406,
1652-32768,-32768, -24, 352, -108,-32768, 491, 498, -81, -147,
1653 -245, 80, 127, 339,-32768,-32768, 587,-32768,-32768,-32768,
1654-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 517,-32768,
1655-32768,-32768,-32768,-32768,-32768, -506, -70, 104, -232,-32768,
1656-32768, 555,-32768,-32768,-32768,-32768,-32768, 79, 195,-32768,
1657-32768,-32768,-32768
1658};
1659
1660
1661#define YYLAST 2013
1662
1663
1664static const short yytable[] = { 11,
1665 335, 79, 412, 341, 496, 375, 345, 346, 347, 348,
1666 349, 103, 13, 334, 353, 11, 282, 167, 88, 334,
1667 168, 88, 109, 109, 109, 492, 92, 23, 13, 487,
1668 488, 24, 380, 382, 384, 469, 471, 165, 20, 61,
1669 62, 613, 105, 64, 65, 66, 67, 68, 69, 70,
1670 107, 1, 2, 21, 3, 4, 5, 61, 62, 221,
1671 109, 492, 336, 25, 284, 89, 133, 264, 89, 1,
1672 2, 134, 3, 4, 5, 136, 109, 470, 470, 107,
1673 493, 71, 354, 267, 27, 136, 608, 396, 535, 144,
1674 11, 153, 396, 283, 397, 567, 109, 439, 145, 144,
1675 221, 153, 109, 618, 109, 81, 82, 109, 260, 577,
1676 578, 86, 332, 117, 118, 257, 258, 87, 333, 261,
1677 110, 110, 110, 427, 26, 265, 414, 109, 429, 430,
1678 431, 1, 372, 432, 3, 442, 5, 433, 434, 396,
1679 429, 430, 431, 396, 396, 432, 59, 529, 444, 433,
1680 434, 443, 491, 611, 612, 169, 614, 615, 110, 355,
1681 356, 93, 592, 376, 377, 357, 371, -143, 609, 463,
1682 104, 43, 55, 44, 110, 531, 625, 626, 558, 285,
1683 559, 2, 56, 475, 4, 477, 478, 479, 57, 72,
1684 73, 149, 150, 74, 110, 75, 106, 409, -66, 96,
1685 110, 329, 110, 411, -66, 110, 550, 112, 113, 339,
1686 340, 329, 342, 343, 329, 329, 329, 329, 329, 350,
1687 351, 352, 329, 97, 83, 110, 84, 406, 584, -66,
1688 136, 358, 359, 98, 100, 391, 392, 393, 394, 395,
1689 540, 153, 398, 399, 400, 425, 47, 48, 49, 360,
1690 361, 50, 362, 363, 101, 364, 365, 366, 221, 84,
1691 102, 221, 221, 1, 221, -143, 3, 129, 5, -143,
1692 543, 221, 130, 357, 286, 270, 271, 272, 273, 421,
1693 221, 221, 429, 430, 431, 146, 140, 432, 562, 563,
1694 564, 433, 434, 282, 114, 141, 115, 28, 29, 30,
1695 31, 32, 33, 34, 502, 35, 503, 452, 453, 148,
1696 166, 153, 407, 408, 459, 120, 121, 122, 123, 124,
1697 125, 599, 36, 37, 38, 603, 171, 253, 256, 153,
1698 426, 329, 579, 255, 580, 221, 221, 221, 259, 358,
1699 359, 262, 266, 221, -54, -54, -54, -54, 593, 583,
1700 263, 580, -55, -56, 221, 221, 441, 360, 361, -59,
1701 362, 363, 448, 364, 365, 366, 610, 268, 269, -58,
1702 283, 61, 62, 504, 505, 506, 507, 329, 508, 509,
1703 -57, 274, 287, 1, 2, 109, 3, 4, 5, 317,
1704 318, 329, 476, 329, 329, 329, 327, 319, 221, 483,
1705 221, 320, 334, 221, 36, 37, 38, 385, 373, 321,
1706 221, 221, 324, 489, 325, 326, 388, 374, 541, 542,
1707 289, 290, 291, 292, 293, 294, 295, 296, 297, 298,
1708 387, 389, 401, 390, 424, 403, 404, 510, 405, 402,
1709 221, 221, 415, 221, 221, 413, 416, 417, 221, 418,
1710 419, 420, 428, 438, 422, 423, 445, 451, 455, 221,
1711 462, 530, 572, 456, 573, 574, 457, 458, 460, 461,
1712 464, 465, 539, 480, 481, 474, 482, 499, 329, 486,
1713 497, 500, 490, 498, 501, 511, 512, 513, 554, 514,
1714 221, 515, 533, 517, 503, 536, 329, 329, 329, 524,
1715 519, 521, 554, -207, 522, 534, 221, 221, 523, 466,
1716 467, 468, 528, 527, 300, 301, 532, 473, 544, 545,
1717 221, -68, 1, 2, 546, 3, 4, 5, 484, 485,
1718 547, 548, 549, 6, 7, 561, 470, 570, 575, 571,
1719 576, 581, 588, 221, 221, 586, 589, 591, 221, 604,
1720 590, 221, 602, 605, 8, 601, -17, 221, 9, -18,
1721 221, 616, 10, 617, 619, 622, 536, 623, 628, 629,
1722 631, 634, 516, 635, 518, 245, 246, 520, 247, 337,
1723 585, 338, 131, 568, 525, 526, 302, 303, 304, 305,
1724 306, 307, 308, 309, 310, 311, 312, 313, 314, 315,
1725 147, 143, 42, 128, 378, 565, 369, 472, 95, 0,
1726 0, 0, 0, 0, 551, 552, 0, 556, 557, 0,
1727 0, 0, 560, 172, 173, 0, 0, 61, 62, 174,
1728 0, 0, -206, 566, 0, 0, 0, 0, 0, 1,
1729 2, 0, 3, 4, 5, 175, 176, 177, 0, 0,
1730 -68, 1, 2, 0, 3, 4, 5, 0, 0, 0,
1731 178, 179, 6, 7, 582, 0, 0, 0, 0, 0,
1732 0, 0, 0, 357, 0, 0, 0, 0, 180, 0,
1733 597, 598, 0, 8, 0, 0, 0, 9, 0, 0,
1734 0, 10, 0, 0, 607, 181, 182, 183, 184, 185,
1735 186, 187, 188, 189, 190, 191, 192, 193, 194, 195,
1736 196, 197, 0, 0, 0, 0, 0, 620, 621, 0,
1737 0, 0, 624, 0, 0, 627, 0, 0, 0, 0,
1738 0, 630, 0, 0, 632, 0, 0, 198, 199, 595,
1739 596, 202, 203, 204, 205, 206, 207, 208, 209, 210,
1740 0, 211, 0, 212, 213, 214, 0, 360, 361, 0,
1741 362, 363, 0, 364, 365, 366, 172, 173, 0, 0,
1742 61, 62, 174, 0, 0, 0, 0, 0, 0, 0,
1743 0, 215, 1, 2, 0, 3, 4, 5, 175, 176,
1744 177, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1745 0, 0, 0, 178, 179, 0, 0, 0, 0, 0,
1746 0, 0, 0, 0, 0, 0, 0, 109, 0, 61,
1747 62, 180, 105, 64, 65, 66, 67, 68, 69, 70,
1748 0, 1, 2, 0, 3, 4, 5, 0, 181, 182,
1749 183, 184, 185, 186, 187, 188, 189, 190, 191, 192,
1750 193, 194, 195, 196, 197, 0, 0, 0, 0, 61,
1751 62, 71, 105, 156, 157, 158, 159, 160, 161, 70,
1752 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
1753 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
1754 208, 209, 210, 0, 211, 0, 212, 213, 214, 0,
1755 0, 71, 0, 0, 0, 0, 172, 173, 0, 0,
1756 61, 62, 174, 0, 0, 110, 0, 0, 0, 0,
1757 0, 0, 1, 2, 215, 3, 4, 5, 175, 176,
1758 177, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1759 0, 0, 0, 178, 179, 0, 0, 0, 0, 0,
1760 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1761 0, 180, 0, 0, 0, 0, 0, 0, 0, 72,
1762 73, 0, 0, 74, 0, 75, 142, 0, 181, 182,
1763 183, 184, 185, 186, 187, 188, 189, 190, 191, 192,
1764 193, 194, 195, 196, 197, 0, 0, 0, 0, 0,
1765 0, 0, 0, 0, 0, 0, 0, 0, 0, 72,
1766 73, 0, 0, 74, 0, 75, 383, 0, 0, 0,
1767 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
1768 208, 209, 210, 0, 211, 0, 212, 213, 214, 61,
1769 62, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1770 0, 1, 2, 0, 3, 4, 5, 275, 0, 0,
1771 0, 0, 0, 0, 215, 0, 0, 0, 0, 0,
1772 0, 0, 276, 277, 0, 0, 0, 0, 0, 0,
1773 0, 0, 0, 0, 61, 62, 109, 105, 156, 157,
1774 158, 159, 160, 161, 70, 0, 1, 2, 0, 3,
1775 4, 5, 0, 0, 0, 0, 0, 181, 182, 183,
1776 184, 185, 186, 187, 188, 189, 190, 191, 192, 193,
1777 194, 195, 196, 197, 0, 0, 71, 0, 0, 0,
1778 61, 62, 0, 105, 64, 65, 66, 67, 68, 69,
1779 70, 0, 1, 2, 0, 3, 4, 5, 0, 198,
1780 199, 200, 201, 202, 203, 204, 205, 206, 207, 208,
1781 209, 210, 135, 211, 0, 212, 213, 214, 0, 0,
1782 0, 0, 71, 0, 0, 0, 0, 0, 0, 0,
1783 0, 0, 0, 0, 110, 0, 61, 62, -66, 0,
1784 278, 0, 0, 279, 0, 280, 0, 281, 1, 2,
1785 0, 3, 4, 5, 275, 0, 0, 0, 0, 0,
1786 0, 0, 0, 0, 0, 0, 0, 0, 0, 276,
1787 277, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1788 0, 0, 0, 109, 72, 73, 0, 0, 74, 0,
1789 75, 440, 0, 0, 0, 0, 0, 0, 0, 0,
1790 0, 0, 0, 0, 181, 182, 183, 184, 185, 186,
1791 187, 188, 189, 190, 191, 192, 193, 194, 195, 196,
1792 197, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1793 72, 73, 0, 0, 74, 0, 75, 0, 0, 0,
1794 0, 0, 0, 0, 0, 0, 198, 199, 200, 201,
1795 202, 203, 204, 205, 206, 207, 208, 209, 210, 0,
1796 211, 0, 212, 213, 214, 0, 0, 0, 0, 0,
1797 0, 0, 0, 172, 173, 0, 0, 0, 0, 174,
1798 0, 110, 0, 0, 0, 0, 0, 278, 0, 0,
1799 279, 0, 280, 0, 281, 175, 176, 177, 0, 0,
1800 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1801 178, 179, 0, 0, 0, 0, 0, 0, 0, 0,
1802 0, 0, 0, 0, 0, 0, 61, 62, 180, 151,
1803 64, 65, 66, 67, 68, 69, 70, 0, 1, 2,
1804 0, 3, 4, 5, 0, 181, 182, 183, 184, 185,
1805 186, 187, 188, 189, 190, 191, 192, 193, 194, 195,
1806 196, 197, 0, 0, 0, 0, 61, 62, 71, 105,
1807 156, 157, 158, 159, 160, 161, 70, 0, 1, 2,
1808 0, 3, 4, 5, 0, 0, 0, 198, 199, 200,
1809 201, 202, 203, 204, 205, 206, 207, 208, 209, 210,
1810 0, 211, 0, 212, 213, 214, 61, 62, 71, 105,
1811 64, 65, 66, 67, 68, 69, 70, 0, 1, 2,
1812 0, 3, 4, 5, 0, 0, 0, 0, 0, 0,
1813 0, 215, 0, 0, 0, 0, 0, 0, 368, 0,
1814 0, 0, 152, 0, 0, 0, 61, 62, 71, 105,
1815 64, 65, 66, 67, 68, 69, 70, 0, 1, 2,
1816 0, 3, 4, 5, 0, 0, 0, 0, 0, 0,
1817 0, 0, 0, 0, 0, 0, 72, 73, 447, 0,
1818 74, 0, 75, 0, 0, 0, 61, 62, 71, 105,
1819 64, 65, 66, 67, 68, 69, 70, 0, 1, 2,
1820 0, 3, 4, 5, 0, 0, 0, 0, 0, 0,
1821 0, 0, 0, 0, 0, 0, 72, 73, 538, 379,
1822 74, 0, 75, 0, 0, 0, 61, 62, 71, 63,
1823 64, 65, 66, 67, 68, 69, 70, 0, 1, 2,
1824 0, 3, 4, 5, 0, 0, 0, 0, 0, 0,
1825 0, 0, 0, 0, 0, 0, 72, 73, 0, 0,
1826 74, 0, 75, 0, 0, 0, 61, 62, 71, 105,
1827 156, 157, 158, 159, 160, 161, 70, 0, 1, 2,
1828 0, 3, 4, 5, 0, 0, 0, 0, 0, 0,
1829 0, 0, 0, 0, 0, 0, 72, 73, 0, 0,
1830 74, 0, 75, 0, 0, 0, 61, 62, 71, 151,
1831 64, 65, 66, 67, 68, 69, 70, 0, 1, 2,
1832 0, 3, 4, 5, 0, 0, 0, 0, 0, 0,
1833 0, 0, 0, 0, 0, 0, 72, 73, 0, 0,
1834 74, 0, 75, 0, 0, 0, 61, 62, 71, 105,
1835 64, 65, 66, 67, 68, 69, 70, 0, 1, 2,
1836 0, 3, 4, 5, 0, 0, 0, 0, 0, 0,
1837 0, 0, 0, 0, 0, 0, 72, 73, 0, 0,
1838 74, 0, 75, 0, 0, 0, 61, 62, 71, 328,
1839 64, 65, 66, 67, 68, 69, 70, 0, 1, 2,
1840 0, 3, 4, 5, 0, 0, 0, 0, 0, 0,
1841 0, 0, 0, 0, 0, 0, 72, 73, 0, 0,
1842 74, 0, 75, 0, 0, 0, 61, 62, 71, 105,
1843 156, 157, 158, 159, 160, 161, 70, 0, 1, 2,
1844 0, 3, 4, 5, 0, 0, 0, 0, 0, 0,
1845 0, 0, 0, 0, 0, 0, 72, 73, 0, 0,
1846 74, 0, 75, 0, 0, 0, 61, 62, 71, 105,
1847 64, 65, 66, 67, 68, 69, 553, 0, 1, 2,
1848 0, 3, 4, 5, 0, 0, 0, 0, 0, 0,
1849 0, 0, 0, 0, 0, 0, 72, 73, 0, 0,
1850 74, 0, 75, 0, 0, 0, 61, 62, 71, 105,
1851 64, 65, 66, 67, 68, 69, 600, 0, 1, 2,
1852 0, 3, 4, 5, 0, 0, 0, 0, 0, 0,
1853 0, 0, 0, 0, 0, 0, 72, 73, 0, 0,
1854 74, 0, 75, 0, 0, 0, 0, 0, 71, 0,
1855 223, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1856 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1857 224, 225, 0, 0, 0, 0, 72, 73, 0, 0,
1858 74, 0, 381, 226, 227, 228, 229, 230, 231, 181,
1859 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
1860 192, 193, 194, 195, 232, 233, 0, 0, 0, 0,
1861 0, 0, 0, 0, 0, 0, 72, 73, 0, 0,
1862 74, 0, 75, 0, 0, 0, 234, 235, 236, 0,
1863 0, 237, 199, 200, 201, 202, 203, 204, 205, 206,
1864 207, 208, 209, 210, 238, 239, 240, 241, 242, 243,
1865 244, 0, 0, 0, 0, 0, 72, 73, 0, 0,
1866 74, 0, 75
1867};
1868
1869static const short yycheck[] = { 0,
1870 228, 26, 340, 236, 448, 263, 239, 240, 241, 242,
1871 243, 4, 0, 11, 247, 16, 164, 126, 21, 11,
1872 28, 21, 54, 54, 54, 34, 29, 154, 16, 436,
1873 437, 58, 278, 279, 280, 11, 11, 119, 52, 7,
1874 8, 38, 10, 11, 12, 13, 14, 15, 16, 17,
1875 75, 19, 20, 67, 22, 23, 24, 7, 8, 130,
1876 54, 34, 229, 154, 165, 68, 155, 149, 68, 19,
1877 20, 160, 22, 23, 24, 100, 54, 53, 53, 104,
1878 53, 49, 249, 154, 154, 110, 593, 155, 495, 155,
1879 91, 116, 155, 164, 162, 539, 54, 160, 164, 155,
1880 171, 126, 54, 610, 54, 39, 40, 54, 164, 553,
1881 554, 45, 11, 32, 33, 140, 141, 51, 17, 144,
1882 152, 152, 152, 356, 18, 150, 158, 54, 137, 138,
1883 139, 19, 162, 142, 22, 381, 24, 146, 147, 155,
1884 137, 138, 139, 155, 155, 142, 22, 485, 164, 146,
1885 147, 162, 164, 597, 598, 163, 600, 601, 152, 115,
1886 116, 164, 160, 264, 265, 53, 160, 54, 160, 402,
1887 163, 46, 154, 48, 152, 153, 620, 621, 516, 167,
1888 518, 20, 154, 416, 23, 418, 419, 420, 158, 157,
1889 158, 112, 113, 161, 152, 163, 164, 155, 156, 22,
1890 152, 226, 152, 155, 156, 152, 153, 81, 82, 234,
1891 235, 236, 237, 238, 239, 240, 241, 242, 243, 244,
1892 245, 246, 247, 22, 35, 152, 37, 336, 566, 156,
1893 255, 119, 120, 22, 152, 317, 318, 319, 320, 321,
1894 498, 266, 324, 325, 326, 354, 42, 43, 44, 137,
1895 138, 47, 140, 141, 4, 143, 144, 145, 329, 37,
1896 4, 332, 333, 19, 335, 152, 22, 68, 24, 156,
1897 503, 342, 38, 53, 171, 3, 4, 5, 6, 350,
1898 351, 352, 137, 138, 139, 152, 159, 142, 521, 522,
1899 523, 146, 147, 441, 42, 159, 44, 42, 43, 44,
1900 45, 46, 47, 48, 153, 50, 155, 389, 390, 156,
1901 4, 336, 337, 338, 396, 61, 62, 63, 64, 65,
1902 66, 579, 149, 150, 151, 583, 38, 22, 153, 354,
1903 355, 356, 153, 155, 155, 406, 407, 408, 162, 119,
1904 120, 4, 152, 414, 3, 4, 5, 6, 576, 153,
1905 153, 155, 9, 9, 425, 426, 381, 137, 138, 9,
1906 140, 141, 387, 143, 144, 145, 594, 26, 27, 9,
1907 441, 7, 8, 455, 456, 457, 458, 402, 460, 461,
1908 9, 9, 60, 19, 20, 54, 22, 23, 24, 152,
1909 152, 416, 417, 418, 419, 420, 56, 152, 469, 424,
1910 471, 152, 11, 474, 149, 150, 151, 22, 162, 152,
1911 481, 482, 152, 438, 152, 152, 22, 153, 500, 501,
1912 92, 93, 94, 95, 96, 97, 98, 99, 100, 101,
1913 152, 152, 329, 152, 38, 332, 333, 462, 335, 155,
1914 511, 512, 155, 514, 515, 342, 155, 155, 519, 155,
1915 155, 155, 4, 38, 351, 352, 155, 155, 155, 530,
1916 38, 486, 544, 155, 546, 547, 155, 155, 155, 155,
1917 155, 155, 497, 155, 155, 158, 155, 22, 503, 155,
1918 155, 155, 162, 153, 155, 17, 17, 152, 513, 155,
1919 561, 155, 22, 4, 155, 496, 521, 522, 523, 4,
1920 155, 155, 527, 0, 155, 4, 577, 578, 155, 406,
1921 407, 408, 155, 152, 26, 27, 162, 414, 155, 153,
1922 591, 18, 19, 20, 155, 22, 23, 24, 425, 426,
1923 155, 153, 153, 30, 31, 155, 53, 153, 155, 153,
1924 158, 160, 153, 614, 615, 53, 153, 17, 619, 4,
1925 153, 622, 160, 148, 51, 580, 152, 628, 55, 152,
1926 631, 22, 59, 155, 17, 17, 567, 155, 17, 73,
1927 17, 0, 469, 0, 471, 131, 131, 474, 131, 232,
1928 567, 233, 91, 540, 481, 482, 98, 99, 100, 101,
1929 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
1930 110, 104, 16, 87, 266, 527, 255, 413, 54, -1,
1931 -1, -1, -1, -1, 511, 512, -1, 514, 515, -1,
1932 -1, -1, 519, 3, 4, -1, -1, 7, 8, 9,
1933 -1, -1, 0, 530, -1, -1, -1, -1, -1, 19,
1934 20, -1, 22, 23, 24, 25, 26, 27, -1, -1,
1935 18, 19, 20, -1, 22, 23, 24, -1, -1, -1,
1936 40, 41, 30, 31, 561, -1, -1, -1, -1, -1,
1937 -1, -1, -1, 53, -1, -1, -1, -1, 58, -1,
1938 577, 578, -1, 51, -1, -1, -1, 55, -1, -1,
1939 -1, 59, -1, -1, 591, 75, 76, 77, 78, 79,
1940 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
1941 90, 91, -1, -1, -1, -1, -1, 614, 615, -1,
1942 -1, -1, 619, -1, -1, 622, -1, -1, -1, -1,
1943 -1, 628, -1, -1, 631, -1, -1, 117, 118, 119,
1944 120, 121, 122, 123, 124, 125, 126, 127, 128, 129,
1945 -1, 131, -1, 133, 134, 135, -1, 137, 138, -1,
1946 140, 141, -1, 143, 144, 145, 3, 4, -1, -1,
1947 7, 8, 9, -1, -1, -1, -1, -1, -1, -1,
1948 -1, 161, 19, 20, -1, 22, 23, 24, 25, 26,
1949 27, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1950 -1, -1, -1, 40, 41, -1, -1, -1, -1, -1,
1951 -1, -1, -1, -1, -1, -1, -1, 54, -1, 7,
1952 8, 58, 10, 11, 12, 13, 14, 15, 16, 17,
1953 -1, 19, 20, -1, 22, 23, 24, -1, 75, 76,
1954 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1955 87, 88, 89, 90, 91, -1, -1, -1, -1, 7,
1956 8, 49, 10, 11, 12, 13, 14, 15, 16, 17,
1957 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
1958 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
1959 127, 128, 129, -1, 131, -1, 133, 134, 135, -1,
1960 -1, 49, -1, -1, -1, -1, 3, 4, -1, -1,
1961 7, 8, 9, -1, -1, 152, -1, -1, -1, -1,
1962 -1, -1, 19, 20, 161, 22, 23, 24, 25, 26,
1963 27, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1964 -1, -1, -1, 40, 41, -1, -1, -1, -1, -1,
1965 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1966 -1, 58, -1, -1, -1, -1, -1, -1, -1, 157,
1967 158, -1, -1, 161, -1, 163, 164, -1, 75, 76,
1968 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1969 87, 88, 89, 90, 91, -1, -1, -1, -1, -1,
1970 -1, -1, -1, -1, -1, -1, -1, -1, -1, 157,
1971 158, -1, -1, 161, -1, 163, 164, -1, -1, -1,
1972 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
1973 127, 128, 129, -1, 131, -1, 133, 134, 135, 7,
1974 8, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1975 -1, 19, 20, -1, 22, 23, 24, 25, -1, -1,
1976 -1, -1, -1, -1, 161, -1, -1, -1, -1, -1,
1977 -1, -1, 40, 41, -1, -1, -1, -1, -1, -1,
1978 -1, -1, -1, -1, 7, 8, 54, 10, 11, 12,
1979 13, 14, 15, 16, 17, -1, 19, 20, -1, 22,
1980 23, 24, -1, -1, -1, -1, -1, 75, 76, 77,
1981 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
1982 88, 89, 90, 91, -1, -1, 49, -1, -1, -1,
1983 7, 8, -1, 10, 11, 12, 13, 14, 15, 16,
1984 17, -1, 19, 20, -1, 22, 23, 24, -1, 117,
1985 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
1986 128, 129, 39, 131, -1, 133, 134, 135, -1, -1,
1987 -1, -1, 49, -1, -1, -1, -1, -1, -1, -1,
1988 -1, -1, -1, -1, 152, -1, 7, 8, 156, -1,
1989 158, -1, -1, 161, -1, 163, -1, 165, 19, 20,
1990 -1, 22, 23, 24, 25, -1, -1, -1, -1, -1,
1991 -1, -1, -1, -1, -1, -1, -1, -1, -1, 40,
1992 41, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1993 -1, -1, -1, 54, 157, 158, -1, -1, 161, -1,
1994 163, 164, -1, -1, -1, -1, -1, -1, -1, -1,
1995 -1, -1, -1, -1, 75, 76, 77, 78, 79, 80,
1996 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
1997 91, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1998 157, 158, -1, -1, 161, -1, 163, -1, -1, -1,
1999 -1, -1, -1, -1, -1, -1, 117, 118, 119, 120,
2000 121, 122, 123, 124, 125, 126, 127, 128, 129, -1,
2001 131, -1, 133, 134, 135, -1, -1, -1, -1, -1,
2002 -1, -1, -1, 3, 4, -1, -1, -1, -1, 9,
2003 -1, 152, -1, -1, -1, -1, -1, 158, -1, -1,
2004 161, -1, 163, -1, 165, 25, 26, 27, -1, -1,
2005 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2006 40, 41, -1, -1, -1, -1, -1, -1, -1, -1,
2007 -1, -1, -1, -1, -1, -1, 7, 8, 58, 10,
2008 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
2009 -1, 22, 23, 24, -1, 75, 76, 77, 78, 79,
2010 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
2011 90, 91, -1, -1, -1, -1, 7, 8, 49, 10,
2012 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
2013 -1, 22, 23, 24, -1, -1, -1, 117, 118, 119,
2014 120, 121, 122, 123, 124, 125, 126, 127, 128, 129,
2015 -1, 131, -1, 133, 134, 135, 7, 8, 49, 10,
2016 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
2017 -1, 22, 23, 24, -1, -1, -1, -1, -1, -1,
2018 -1, 161, -1, -1, -1, -1, -1, -1, 39, -1,
2019 -1, -1, 123, -1, -1, -1, 7, 8, 49, 10,
2020 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
2021 -1, 22, 23, 24, -1, -1, -1, -1, -1, -1,
2022 -1, -1, -1, -1, -1, -1, 157, 158, 39, -1,
2023 161, -1, 163, -1, -1, -1, 7, 8, 49, 10,
2024 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
2025 -1, 22, 23, 24, -1, -1, -1, -1, -1, -1,
2026 -1, -1, -1, -1, -1, -1, 157, 158, 39, 160,
2027 161, -1, 163, -1, -1, -1, 7, 8, 49, 10,
2028 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
2029 -1, 22, 23, 24, -1, -1, -1, -1, -1, -1,
2030 -1, -1, -1, -1, -1, -1, 157, 158, -1, -1,
2031 161, -1, 163, -1, -1, -1, 7, 8, 49, 10,
2032 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
2033 -1, 22, 23, 24, -1, -1, -1, -1, -1, -1,
2034 -1, -1, -1, -1, -1, -1, 157, 158, -1, -1,
2035 161, -1, 163, -1, -1, -1, 7, 8, 49, 10,
2036 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
2037 -1, 22, 23, 24, -1, -1, -1, -1, -1, -1,
2038 -1, -1, -1, -1, -1, -1, 157, 158, -1, -1,
2039 161, -1, 163, -1, -1, -1, 7, 8, 49, 10,
2040 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
2041 -1, 22, 23, 24, -1, -1, -1, -1, -1, -1,
2042 -1, -1, -1, -1, -1, -1, 157, 158, -1, -1,
2043 161, -1, 163, -1, -1, -1, 7, 8, 49, 10,
2044 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
2045 -1, 22, 23, 24, -1, -1, -1, -1, -1, -1,
2046 -1, -1, -1, -1, -1, -1, 157, 158, -1, -1,
2047 161, -1, 163, -1, -1, -1, 7, 8, 49, 10,
2048 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
2049 -1, 22, 23, 24, -1, -1, -1, -1, -1, -1,
2050 -1, -1, -1, -1, -1, -1, 157, 158, -1, -1,
2051 161, -1, 163, -1, -1, -1, 7, 8, 49, 10,
2052 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
2053 -1, 22, 23, 24, -1, -1, -1, -1, -1, -1,
2054 -1, -1, -1, -1, -1, -1, 157, 158, -1, -1,
2055 161, -1, 163, -1, -1, -1, 7, 8, 49, 10,
2056 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
2057 -1, 22, 23, 24, -1, -1, -1, -1, -1, -1,
2058 -1, -1, -1, -1, -1, -1, 157, 158, -1, -1,
2059 161, -1, 163, -1, -1, -1, -1, -1, 49, -1,
2060 36, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2061 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2062 56, 57, -1, -1, -1, -1, 157, 158, -1, -1,
2063 161, -1, 163, 69, 70, 71, 72, 73, 74, 75,
2064 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
2065 86, 87, 88, 89, 90, 91, -1, -1, -1, -1,
2066 -1, -1, -1, -1, -1, -1, 157, 158, -1, -1,
2067 161, -1, 163, -1, -1, -1, 112, 113, 114, -1,
2068 -1, 117, 118, 119, 120, 121, 122, 123, 124, 125,
2069 126, 127, 128, 129, 130, 131, 132, 133, 134, 135,
2070 136, -1, -1, -1, -1, -1, 157, 158, -1, -1,
2071 161, -1, 163
2072};
2073/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
2074#line 3 "/usr/share/bison.simple"
2075/* This file comes from bison-1.28. */
2076
2077/* Skeleton output parser for bison,
2078 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
2079
2080 This program is free software; you can redistribute it and/or modify
2081 it under the terms of the GNU General Public License as published by
2082 the Free Software Foundation; either version 2, or (at your option)
2083 any later version.
2084
2085 This program is distributed in the hope that it will be useful,
2086 but WITHOUT ANY WARRANTY; without even the implied warranty of
2087 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2088 GNU General Public License for more details.
2089
2090 You should have received a copy of the GNU General Public License
2091 along with this program; if not, write to the Free Software
2092 Foundation, Inc., 59 Temple Place - Suite 330,
2093 Boston, MA 02111-1307, USA. */
2094
2095/* As a special exception, when this file is copied by Bison into a
2096 Bison output file, you may use that output file without restriction.
2097 This special exception was added by the Free Software Foundation
2098 in version 1.24 of Bison. */
2099
2100/* This is the parser code that is written into each bison parser
2101 when the %semantic_parser declaration is not specified in the grammar.
2102 It was written by Richard Stallman by simplifying the hairy parser
2103 used when %semantic_parser is specified. */
2104
2105#ifndef YYSTACK_USE_ALLOCA
2106#ifdef alloca
2107#define YYSTACK_USE_ALLOCA
2108#else /* alloca not defined */
2109#ifdef __GNUC__
2110#define YYSTACK_USE_ALLOCA
2111#define alloca __builtin_alloca
2112#else /* not GNU C. */
2113#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
2114#define YYSTACK_USE_ALLOCA
2115#include <alloca.h>
2116#else /* not sparc */
2117/* We think this test detects Watcom and Microsoft C. */
2118/* This used to test MSDOS, but that is a bad idea
2119 since that symbol is in the user namespace. */
2120#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
2121#if 0 /* No need for malloc.h, which pollutes the namespace;
2122 instead, just don't use alloca. */
2123#include <malloc.h>
2124#endif
2125#else /* not MSDOS, or __TURBOC__ */
2126#if defined(_AIX)
2127/* I don't know what this was needed for, but it pollutes the namespace.
2128 So I turned it off. rms, 2 May 1997. */
2129/* #include <malloc.h> */
2130 #pragma alloca
2131#define YYSTACK_USE_ALLOCA
2132#else /* not MSDOS, or __TURBOC__, or _AIX */
2133#if 0
2134#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
2135 and on HPUX 10. Eventually we can turn this on. */
2136#define YYSTACK_USE_ALLOCA
2137#define alloca __builtin_alloca
2138#endif /* __hpux */
2139#endif
2140#endif /* not _AIX */
2141#endif /* not MSDOS, or __TURBOC__ */
2142#endif /* not sparc */
2143#endif /* not GNU C */
2144#endif /* alloca not defined */
2145#endif /* YYSTACK_USE_ALLOCA not defined */
2146
2147#ifdef YYSTACK_USE_ALLOCA
2148#define YYSTACK_ALLOC alloca
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002149#else
Gabor Greif89f01162008-04-06 23:07:54 +00002150#define YYSTACK_ALLOC malloc
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002151#endif
2152
Gabor Greif89f01162008-04-06 23:07:54 +00002153/* Note: there must be only one dollar sign in this file.
2154 It is replaced by the list of actions, each action
2155 as one case of the switch. */
David Greene9145dd22007-08-01 03:59:32 +00002156
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002157#define yyerrok (yyerrstatus = 0)
2158#define yyclearin (yychar = YYEMPTY)
Gabor Greif89f01162008-04-06 23:07:54 +00002159#define YYEMPTY -2
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002160#define YYEOF 0
2161#define YYACCEPT goto yyacceptlab
Gabor Greif89f01162008-04-06 23:07:54 +00002162#define YYABORT goto yyabortlab
2163#define YYERROR goto yyerrlab1
2164/* Like YYERROR except do call yyerror.
2165 This remains here temporarily to ease the
2166 transition to the new meaning of YYERROR, for GCC.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002167 Once GCC version 2 has supplanted version 1, this can go. */
2168#define YYFAIL goto yyerrlab
2169#define YYRECOVERING() (!!yyerrstatus)
Gabor Greif89f01162008-04-06 23:07:54 +00002170#define YYBACKUP(token, value) \
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002171do \
2172 if (yychar == YYEMPTY && yylen == 1) \
Gabor Greif89f01162008-04-06 23:07:54 +00002173 { yychar = (token), yylval = (value); \
2174 yychar1 = YYTRANSLATE (yychar); \
2175 YYPOPSTACK; \
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002176 goto yybackup; \
2177 } \
2178 else \
Gabor Greif89f01162008-04-06 23:07:54 +00002179 { yyerror ("syntax error: cannot back up"); YYERROR; } \
2180while (0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002181
2182#define YYTERROR 1
2183#define YYERRCODE 256
2184
Gabor Greif89f01162008-04-06 23:07:54 +00002185#ifndef YYPURE
2186#define YYLEX yylex()
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002187#endif
2188
Gabor Greif89f01162008-04-06 23:07:54 +00002189#ifdef YYPURE
2190#ifdef YYLSP_NEEDED
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002191#ifdef YYLEX_PARAM
Gabor Greif89f01162008-04-06 23:07:54 +00002192#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002193#else
Gabor Greif89f01162008-04-06 23:07:54 +00002194#define YYLEX yylex(&yylval, &yylloc)
2195#endif
2196#else /* not YYLSP_NEEDED */
2197#ifdef YYLEX_PARAM
2198#define YYLEX yylex(&yylval, YYLEX_PARAM)
2199#else
2200#define YYLEX yylex(&yylval)
2201#endif
2202#endif /* not YYLSP_NEEDED */
Scott Michel6d1aba82008-01-30 03:10:00 +00002203#endif
Chris Lattner59363a32008-02-19 04:36:25 +00002204
Gabor Greif89f01162008-04-06 23:07:54 +00002205/* If nonreentrant, generate the variables here */
Chris Lattner59363a32008-02-19 04:36:25 +00002206
Gabor Greif89f01162008-04-06 23:07:54 +00002207#ifndef YYPURE
Chris Lattner59363a32008-02-19 04:36:25 +00002208
Gabor Greif89f01162008-04-06 23:07:54 +00002209int yychar; /* the lookahead symbol */
2210YYSTYPE yylval; /* the semantic value of the */
2211 /* lookahead symbol */
Chris Lattner59363a32008-02-19 04:36:25 +00002212
Gabor Greif89f01162008-04-06 23:07:54 +00002213#ifdef YYLSP_NEEDED
2214YYLTYPE yylloc; /* location data for the lookahead */
2215 /* symbol */
Scott Michel6d1aba82008-01-30 03:10:00 +00002216#endif
Chris Lattner59363a32008-02-19 04:36:25 +00002217
Gabor Greif89f01162008-04-06 23:07:54 +00002218int yynerrs; /* number of parse errors so far */
2219#endif /* not YYPURE */
Chris Lattner59363a32008-02-19 04:36:25 +00002220
Gabor Greif89f01162008-04-06 23:07:54 +00002221#if YYDEBUG != 0
2222int yydebug; /* nonzero means print parse trace */
2223/* Since this is uninitialized, it does not stop multiple parsers
2224 from coexisting. */
Christopher Lamb0a243582007-12-11 09:02:08 +00002225#endif
Scott Michel5a6f17b2008-01-30 02:55:46 +00002226
Gabor Greif89f01162008-04-06 23:07:54 +00002227/* YYINITDEPTH indicates the initial size of the parser's stacks */
Scott Michel5a6f17b2008-01-30 02:55:46 +00002228
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002229#ifndef YYINITDEPTH
Gabor Greif89f01162008-04-06 23:07:54 +00002230#define YYINITDEPTH 200
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002231#endif
2232
Gabor Greif89f01162008-04-06 23:07:54 +00002233/* YYMAXDEPTH is the maximum size the stacks can grow to
2234 (effective only if the built-in stack extension method is used). */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002235
Gabor Greif89f01162008-04-06 23:07:54 +00002236#if YYMAXDEPTH == 0
2237#undef YYMAXDEPTH
2238#endif
David Greene9145dd22007-08-01 03:59:32 +00002239
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002240#ifndef YYMAXDEPTH
Gabor Greif89f01162008-04-06 23:07:54 +00002241#define YYMAXDEPTH 10000
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002242#endif
2243
Gabor Greif89f01162008-04-06 23:07:54 +00002244/* Define __yy_memcpy. Note that the size argument
2245 should be passed with type unsigned int, because that is what the non-GCC
2246 definitions require. With GCC, __builtin_memcpy takes an arg
2247 of type size_t, but it can handle unsigned int. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002248
Gabor Greif89f01162008-04-06 23:07:54 +00002249#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
2250#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
2251#else /* not GNU C or C++ */
2252#ifndef __cplusplus
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002253
Gabor Greif89f01162008-04-06 23:07:54 +00002254/* This is the most reliable way to avoid incompatibilities
2255 in available built-in functions on various systems. */
Chris Lattner59363a32008-02-19 04:36:25 +00002256static void
Gabor Greif89f01162008-04-06 23:07:54 +00002257__yy_memcpy (to, from, count)
2258 char *to;
2259 char *from;
2260 unsigned int count;
Chris Lattner59363a32008-02-19 04:36:25 +00002261{
Gabor Greif89f01162008-04-06 23:07:54 +00002262 register char *f = from;
2263 register char *t = to;
2264 register int i = count;
Chris Lattner59363a32008-02-19 04:36:25 +00002265
Gabor Greif89f01162008-04-06 23:07:54 +00002266 while (i-- > 0)
2267 *t++ = *f++;
Chris Lattner59363a32008-02-19 04:36:25 +00002268}
Chris Lattner59363a32008-02-19 04:36:25 +00002269
Gabor Greif89f01162008-04-06 23:07:54 +00002270#else /* __cplusplus */
2271
2272/* This is the most reliable way to avoid incompatibilities
2273 in available built-in functions on various systems. */
2274static void
2275__yy_memcpy (char *to, char *from, unsigned int count)
2276{
2277 register char *t = to;
2278 register char *f = from;
2279 register int i = count;
2280
2281 while (i-- > 0)
2282 *t++ = *f++;
2283}
2284
2285#endif
2286#endif
2287
2288#line 217 "/usr/share/bison.simple"
2289
2290/* The user can define YYPARSE_PARAM as the name of an argument to be passed
2291 into yyparse. The argument should have type void *.
2292 It should actually point to an object.
2293 Grammar actions can access the variable by casting it
2294 to the proper pointer type. */
Chris Lattner59363a32008-02-19 04:36:25 +00002295
2296#ifdef YYPARSE_PARAM
Gabor Greif89f01162008-04-06 23:07:54 +00002297#ifdef __cplusplus
2298#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
2299#define YYPARSE_PARAM_DECL
2300#else /* not __cplusplus */
2301#define YYPARSE_PARAM_ARG YYPARSE_PARAM
2302#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
2303#endif /* not __cplusplus */
2304#else /* not YYPARSE_PARAM */
2305#define YYPARSE_PARAM_ARG
2306#define YYPARSE_PARAM_DECL
2307#endif /* not YYPARSE_PARAM */
2308
2309/* Prevent warning if -Wstrict-prototypes. */
2310#ifdef __GNUC__
2311#ifdef YYPARSE_PARAM
2312int yyparse (void *);
Chris Lattner59363a32008-02-19 04:36:25 +00002313#else
David Greene48556392007-09-04 18:46:50 +00002314int yyparse (void);
Scott Michel6d1aba82008-01-30 03:10:00 +00002315#endif
2316#endif
Gabor Greif89f01162008-04-06 23:07:54 +00002317
2318int
2319yyparse(YYPARSE_PARAM_ARG)
2320 YYPARSE_PARAM_DECL
Chris Lattner59363a32008-02-19 04:36:25 +00002321{
Gabor Greif89f01162008-04-06 23:07:54 +00002322 register int yystate;
2323 register int yyn;
2324 register short *yyssp;
2325 register YYSTYPE *yyvsp;
2326 int yyerrstatus; /* number of tokens to shift before error messages enabled */
2327 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
2328
2329 short yyssa[YYINITDEPTH]; /* the state stack */
2330 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
2331
2332 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
2333 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
2334
2335#ifdef YYLSP_NEEDED
2336 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
2337 YYLTYPE *yyls = yylsa;
2338 YYLTYPE *yylsp;
2339
2340#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
2341#else
2342#define YYPOPSTACK (yyvsp--, yyssp--)
Scott Michel6d1aba82008-01-30 03:10:00 +00002343#endif
Scott Michel5a6f17b2008-01-30 02:55:46 +00002344
Gabor Greif89f01162008-04-06 23:07:54 +00002345 int yystacksize = YYINITDEPTH;
2346 int yyfree_stacks = 0;
Chris Lattner59363a32008-02-19 04:36:25 +00002347
Gabor Greif89f01162008-04-06 23:07:54 +00002348#ifdef YYPURE
2349 int yychar;
2350 YYSTYPE yylval;
2351 int yynerrs;
2352#ifdef YYLSP_NEEDED
2353 YYLTYPE yylloc;
2354#endif
2355#endif
Chris Lattner59363a32008-02-19 04:36:25 +00002356
Gabor Greif89f01162008-04-06 23:07:54 +00002357 YYSTYPE yyval; /* the variable used to return */
2358 /* semantic values from the action */
2359 /* routines */
Chris Lattner59363a32008-02-19 04:36:25 +00002360
Gabor Greif89f01162008-04-06 23:07:54 +00002361 int yylen;
Chris Lattner59363a32008-02-19 04:36:25 +00002362
Gabor Greif89f01162008-04-06 23:07:54 +00002363#if YYDEBUG != 0
2364 if (yydebug)
2365 fprintf(stderr, "Starting parse\n");
2366#endif
Chris Lattner59363a32008-02-19 04:36:25 +00002367
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002368 yystate = 0;
2369 yyerrstatus = 0;
2370 yynerrs = 0;
2371 yychar = YYEMPTY; /* Cause a token to be read. */
2372
2373 /* Initialize stack pointers.
2374 Waste one element of value and location stack
2375 so that they stay on the same level as the state stack.
2376 The wasted elements are never initialized. */
2377
Gabor Greif89f01162008-04-06 23:07:54 +00002378 yyssp = yyss - 1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002379 yyvsp = yyvs;
Gabor Greif89f01162008-04-06 23:07:54 +00002380#ifdef YYLSP_NEEDED
2381 yylsp = yyls;
2382#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002383
Gabor Greif89f01162008-04-06 23:07:54 +00002384/* Push a new state, which is found in yystate . */
2385/* In all cases, when you get here, the value and location stacks
2386 have just been pushed. so pushing a state here evens the stacks. */
2387yynewstate:
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002388
Gabor Greif89f01162008-04-06 23:07:54 +00002389 *++yyssp = yystate;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002390
Gabor Greif89f01162008-04-06 23:07:54 +00002391 if (yyssp >= yyss + yystacksize - 1)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002392 {
Gabor Greif89f01162008-04-06 23:07:54 +00002393 /* Give user a chance to reallocate the stack */
2394 /* Use copies of these so that the &'s don't force the real ones into memory. */
2395 YYSTYPE *yyvs1 = yyvs;
2396 short *yyss1 = yyss;
2397#ifdef YYLSP_NEEDED
2398 YYLTYPE *yyls1 = yyls;
2399#endif
2400
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002401 /* Get the current used size of the three stacks, in elements. */
Gabor Greif89f01162008-04-06 23:07:54 +00002402 int size = yyssp - yyss + 1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002403
2404#ifdef yyoverflow
Gabor Greif89f01162008-04-06 23:07:54 +00002405 /* Each stack pointer address is followed by the size of
2406 the data in use in that stack, in bytes. */
2407#ifdef YYLSP_NEEDED
2408 /* This used to be a conditional around just the two extra args,
2409 but that might be undefined if yyoverflow is a macro. */
2410 yyoverflow("parser stack overflow",
2411 &yyss1, size * sizeof (*yyssp),
2412 &yyvs1, size * sizeof (*yyvsp),
2413 &yyls1, size * sizeof (*yylsp),
2414 &yystacksize);
2415#else
2416 yyoverflow("parser stack overflow",
2417 &yyss1, size * sizeof (*yyssp),
2418 &yyvs1, size * sizeof (*yyvsp),
2419 &yystacksize);
2420#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002421
Gabor Greif89f01162008-04-06 23:07:54 +00002422 yyss = yyss1; yyvs = yyvs1;
2423#ifdef YYLSP_NEEDED
2424 yyls = yyls1;
2425#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002426#else /* no yyoverflow */
2427 /* Extend the stack our own way. */
Gabor Greif89f01162008-04-06 23:07:54 +00002428 if (yystacksize >= YYMAXDEPTH)
2429 {
2430 yyerror("parser stack overflow");
2431 if (yyfree_stacks)
2432 {
2433 free (yyss);
2434 free (yyvs);
2435#ifdef YYLSP_NEEDED
2436 free (yyls);
2437#endif
2438 }
2439 return 2;
2440 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002441 yystacksize *= 2;
Gabor Greif89f01162008-04-06 23:07:54 +00002442 if (yystacksize > YYMAXDEPTH)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002443 yystacksize = YYMAXDEPTH;
Gabor Greif89f01162008-04-06 23:07:54 +00002444#ifndef YYSTACK_USE_ALLOCA
2445 yyfree_stacks = 1;
2446#endif
2447 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
2448 __yy_memcpy ((char *)yyss, (char *)yyss1,
2449 size * (unsigned int) sizeof (*yyssp));
2450 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
2451 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
2452 size * (unsigned int) sizeof (*yyvsp));
2453#ifdef YYLSP_NEEDED
2454 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
2455 __yy_memcpy ((char *)yyls, (char *)yyls1,
2456 size * (unsigned int) sizeof (*yylsp));
2457#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002458#endif /* no yyoverflow */
2459
Gabor Greif89f01162008-04-06 23:07:54 +00002460 yyssp = yyss + size - 1;
2461 yyvsp = yyvs + size - 1;
2462#ifdef YYLSP_NEEDED
2463 yylsp = yyls + size - 1;
2464#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002465
Gabor Greif89f01162008-04-06 23:07:54 +00002466#if YYDEBUG != 0
2467 if (yydebug)
2468 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2469#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002470
Gabor Greif89f01162008-04-06 23:07:54 +00002471 if (yyssp >= yyss + yystacksize - 1)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002472 YYABORT;
2473 }
2474
Gabor Greif89f01162008-04-06 23:07:54 +00002475#if YYDEBUG != 0
2476 if (yydebug)
2477 fprintf(stderr, "Entering state %d\n", yystate);
2478#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002479
2480 goto yybackup;
Gabor Greif89f01162008-04-06 23:07:54 +00002481 yybackup:
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002482
Gabor Greif89f01162008-04-06 23:07:54 +00002483/* Do appropriate processing given the current state. */
2484/* Read a lookahead token if we need one and don't already have one. */
2485/* yyresume: */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002486
Gabor Greif89f01162008-04-06 23:07:54 +00002487 /* First try to decide what to do without reference to lookahead token. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002488
2489 yyn = yypact[yystate];
Gabor Greif89f01162008-04-06 23:07:54 +00002490 if (yyn == YYFLAG)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002491 goto yydefault;
2492
Gabor Greif89f01162008-04-06 23:07:54 +00002493 /* Not known => get a lookahead token if don't already have one. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002494
Gabor Greif89f01162008-04-06 23:07:54 +00002495 /* yychar is either YYEMPTY or YYEOF
2496 or a valid token in external form. */
2497
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002498 if (yychar == YYEMPTY)
2499 {
Gabor Greif89f01162008-04-06 23:07:54 +00002500#if YYDEBUG != 0
2501 if (yydebug)
2502 fprintf(stderr, "Reading a token: ");
2503#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002504 yychar = YYLEX;
2505 }
2506
Gabor Greif89f01162008-04-06 23:07:54 +00002507 /* Convert token to internal form (in yychar1) for indexing tables with */
2508
2509 if (yychar <= 0) /* This means end of input. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002510 {
Gabor Greif89f01162008-04-06 23:07:54 +00002511 yychar1 = 0;
2512 yychar = YYEOF; /* Don't call YYLEX any more */
2513
2514#if YYDEBUG != 0
2515 if (yydebug)
2516 fprintf(stderr, "Now at end of input.\n");
2517#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002518 }
2519 else
2520 {
Gabor Greif89f01162008-04-06 23:07:54 +00002521 yychar1 = YYTRANSLATE(yychar);
2522
2523#if YYDEBUG != 0
2524 if (yydebug)
2525 {
2526 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2527 /* Give the individual parser a way to print the precise meaning
2528 of a token, for further debugging info. */
2529#ifdef YYPRINT
2530 YYPRINT (stderr, yychar, yylval);
2531#endif
2532 fprintf (stderr, ")\n");
2533 }
2534#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002535 }
2536
Gabor Greif89f01162008-04-06 23:07:54 +00002537 yyn += yychar1;
2538 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002539 goto yydefault;
Gabor Greif89f01162008-04-06 23:07:54 +00002540
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002541 yyn = yytable[yyn];
Gabor Greif89f01162008-04-06 23:07:54 +00002542
2543 /* yyn is what to do for this token type in this state.
2544 Negative => reduce, -yyn is rule number.
2545 Positive => shift, yyn is new state.
2546 New state is final state => don't bother to shift,
2547 just return success.
2548 0, or most negative number => error. */
2549
2550 if (yyn < 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002551 {
Gabor Greif89f01162008-04-06 23:07:54 +00002552 if (yyn == YYFLAG)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002553 goto yyerrlab;
2554 yyn = -yyn;
2555 goto yyreduce;
2556 }
Gabor Greif89f01162008-04-06 23:07:54 +00002557 else if (yyn == 0)
2558 goto yyerrlab;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002559
2560 if (yyn == YYFINAL)
2561 YYACCEPT;
2562
Gabor Greif89f01162008-04-06 23:07:54 +00002563 /* Shift the lookahead token. */
Dale Johannesen3afee192007-09-07 21:07:57 +00002564
Gabor Greif89f01162008-04-06 23:07:54 +00002565#if YYDEBUG != 0
2566 if (yydebug)
2567 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2568#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002569
Gabor Greif89f01162008-04-06 23:07:54 +00002570 /* Discard the token being shifted unless it is eof. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002571 if (yychar != YYEOF)
2572 yychar = YYEMPTY;
2573
Chris Lattner59363a32008-02-19 04:36:25 +00002574 *++yyvsp = yylval;
Gabor Greif89f01162008-04-06 23:07:54 +00002575#ifdef YYLSP_NEEDED
2576 *++yylsp = yylloc;
2577#endif
Chris Lattner59363a32008-02-19 04:36:25 +00002578
Gabor Greif89f01162008-04-06 23:07:54 +00002579 /* count tokens shifted since error; after three, turn off error status. */
2580 if (yyerrstatus) yyerrstatus--;
2581
2582 yystate = yyn;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002583 goto yynewstate;
2584
Gabor Greif89f01162008-04-06 23:07:54 +00002585/* Do the default action for the current state. */
Chris Lattner59363a32008-02-19 04:36:25 +00002586yydefault:
Gabor Greif89f01162008-04-06 23:07:54 +00002587
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002588 yyn = yydefact[yystate];
2589 if (yyn == 0)
2590 goto yyerrlab;
2591
Gabor Greif89f01162008-04-06 23:07:54 +00002592/* Do a reduction. yyn is the number of a rule to reduce with. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002593yyreduce:
2594 yylen = yyr2[yyn];
Gabor Greif89f01162008-04-06 23:07:54 +00002595 if (yylen > 0)
2596 yyval = yyvsp[1-yylen]; /* implement default value of the action */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002597
Gabor Greif89f01162008-04-06 23:07:54 +00002598#if YYDEBUG != 0
2599 if (yydebug)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002600 {
Gabor Greif89f01162008-04-06 23:07:54 +00002601 int i;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002602
Gabor Greif89f01162008-04-06 23:07:54 +00002603 fprintf (stderr, "Reducing via rule %d (line %d), ",
2604 yyn, yyrline[yyn]);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002605
Gabor Greif89f01162008-04-06 23:07:54 +00002606 /* Print the symbols being reduced, and their result. */
2607 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2608 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2609 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2610 }
2611#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002612
2613
Gabor Greif89f01162008-04-06 23:07:54 +00002614 switch (yyn) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002615
Gabor Greif89f01162008-04-06 23:07:54 +00002616case 28:
2617#line 1118 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2618{ yyval.IPredicate = ICmpInst::ICMP_EQ; ;
2619 break;}
2620case 29:
2621#line 1118 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2622{ yyval.IPredicate = ICmpInst::ICMP_NE; ;
2623 break;}
2624case 30:
2625#line 1119 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2626{ yyval.IPredicate = ICmpInst::ICMP_SLT; ;
2627 break;}
2628case 31:
2629#line 1119 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2630{ yyval.IPredicate = ICmpInst::ICMP_SGT; ;
2631 break;}
2632case 32:
2633#line 1120 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2634{ yyval.IPredicate = ICmpInst::ICMP_SLE; ;
2635 break;}
2636case 33:
2637#line 1120 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2638{ yyval.IPredicate = ICmpInst::ICMP_SGE; ;
2639 break;}
2640case 34:
2641#line 1121 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2642{ yyval.IPredicate = ICmpInst::ICMP_ULT; ;
2643 break;}
2644case 35:
2645#line 1121 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2646{ yyval.IPredicate = ICmpInst::ICMP_UGT; ;
2647 break;}
2648case 36:
2649#line 1122 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2650{ yyval.IPredicate = ICmpInst::ICMP_ULE; ;
2651 break;}
2652case 37:
2653#line 1122 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2654{ yyval.IPredicate = ICmpInst::ICMP_UGE; ;
2655 break;}
2656case 38:
2657#line 1126 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2658{ yyval.FPredicate = FCmpInst::FCMP_OEQ; ;
2659 break;}
2660case 39:
2661#line 1126 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2662{ yyval.FPredicate = FCmpInst::FCMP_ONE; ;
2663 break;}
2664case 40:
2665#line 1127 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2666{ yyval.FPredicate = FCmpInst::FCMP_OLT; ;
2667 break;}
2668case 41:
2669#line 1127 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2670{ yyval.FPredicate = FCmpInst::FCMP_OGT; ;
2671 break;}
2672case 42:
2673#line 1128 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2674{ yyval.FPredicate = FCmpInst::FCMP_OLE; ;
2675 break;}
2676case 43:
2677#line 1128 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2678{ yyval.FPredicate = FCmpInst::FCMP_OGE; ;
2679 break;}
2680case 44:
2681#line 1129 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2682{ yyval.FPredicate = FCmpInst::FCMP_ORD; ;
2683 break;}
2684case 45:
2685#line 1129 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2686{ yyval.FPredicate = FCmpInst::FCMP_UNO; ;
2687 break;}
2688case 46:
2689#line 1130 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2690{ yyval.FPredicate = FCmpInst::FCMP_UEQ; ;
2691 break;}
2692case 47:
2693#line 1130 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2694{ yyval.FPredicate = FCmpInst::FCMP_UNE; ;
2695 break;}
2696case 48:
2697#line 1131 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2698{ yyval.FPredicate = FCmpInst::FCMP_ULT; ;
2699 break;}
2700case 49:
2701#line 1131 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2702{ yyval.FPredicate = FCmpInst::FCMP_UGT; ;
2703 break;}
2704case 50:
2705#line 1132 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2706{ yyval.FPredicate = FCmpInst::FCMP_ULE; ;
2707 break;}
2708case 51:
2709#line 1132 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2710{ yyval.FPredicate = FCmpInst::FCMP_UGE; ;
2711 break;}
2712case 52:
2713#line 1133 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2714{ yyval.FPredicate = FCmpInst::FCMP_TRUE; ;
2715 break;}
2716case 53:
2717#line 1134 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2718{ yyval.FPredicate = FCmpInst::FCMP_FALSE; ;
2719 break;}
2720case 64:
2721#line 1143 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2722{ yyval.StrVal = 0; ;
2723 break;}
2724case 65:
2725#line 1145 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2726{ yyval.UIntVal=yyvsp[-1].UInt64Val; ;
2727 break;}
2728case 66:
2729#line 1146 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2730{ yyval.UIntVal=0; ;
2731 break;}
2732case 67:
2733#line 1150 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2734{
2735 yyval.StrVal = yyvsp[-1].StrVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002736 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00002737 ;
2738 break;}
2739case 68:
2740#line 1154 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2741{
2742 yyval.StrVal = 0;
Christopher Lamb668d9a02007-12-12 08:45:45 +00002743 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00002744 ;
2745 break;}
2746case 72:
2747#line 1162 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2748{
2749 yyval.StrVal = 0;
Christopher Lamb668d9a02007-12-12 08:45:45 +00002750 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00002751 ;
2752 break;}
2753case 73:
2754#line 1167 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2755{
2756 yyval.StrVal = yyvsp[-1].StrVal;
Christopher Lamb668d9a02007-12-12 08:45:45 +00002757 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00002758 ;
2759 break;}
2760case 74:
2761#line 1173 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2762{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2763 break;}
2764case 75:
2765#line 1174 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2766{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2767 break;}
2768case 76:
2769#line 1175 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2770{ yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2771 break;}
2772case 77:
2773#line 1176 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2774{ yyval.Linkage = GlobalValue::AppendingLinkage; ;
2775 break;}
2776case 78:
2777#line 1177 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2778{ yyval.Linkage = GlobalValue::DLLExportLinkage; ;
2779 break;}
2780case 79:
2781#line 1181 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2782{ yyval.Linkage = GlobalValue::DLLImportLinkage; ;
2783 break;}
2784case 80:
2785#line 1182 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2786{ yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;
2787 break;}
2788case 81:
2789#line 1183 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2790{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2791 break;}
2792case 82:
2793#line 1187 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2794{ yyval.Visibility = GlobalValue::DefaultVisibility; ;
2795 break;}
2796case 83:
2797#line 1188 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2798{ yyval.Visibility = GlobalValue::DefaultVisibility; ;
2799 break;}
2800case 84:
2801#line 1189 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2802{ yyval.Visibility = GlobalValue::HiddenVisibility; ;
2803 break;}
2804case 85:
2805#line 1190 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2806{ yyval.Visibility = GlobalValue::ProtectedVisibility; ;
2807 break;}
2808case 86:
2809#line 1194 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2810{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2811 break;}
2812case 87:
2813#line 1195 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2814{ yyval.Linkage = GlobalValue::DLLImportLinkage; ;
2815 break;}
2816case 88:
2817#line 1196 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2818{ yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;
2819 break;}
2820case 89:
2821#line 1200 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2822{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2823 break;}
2824case 90:
2825#line 1201 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2826{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2827 break;}
2828case 91:
2829#line 1202 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2830{ yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2831 break;}
2832case 92:
2833#line 1203 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2834{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2835 break;}
2836case 93:
2837#line 1204 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2838{ yyval.Linkage = GlobalValue::DLLExportLinkage; ;
2839 break;}
2840case 94:
2841#line 1208 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2842{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2843 break;}
2844case 95:
2845#line 1209 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2846{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2847 break;}
2848case 96:
2849#line 1210 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2850{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2851 break;}
2852case 97:
2853#line 1213 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2854{ yyval.UIntVal = CallingConv::C; ;
2855 break;}
2856case 98:
2857#line 1214 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2858{ yyval.UIntVal = CallingConv::C; ;
2859 break;}
2860case 99:
2861#line 1215 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2862{ yyval.UIntVal = CallingConv::Fast; ;
2863 break;}
2864case 100:
2865#line 1216 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2866{ yyval.UIntVal = CallingConv::Cold; ;
2867 break;}
2868case 101:
2869#line 1217 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2870{ yyval.UIntVal = CallingConv::X86_StdCall; ;
2871 break;}
2872case 102:
2873#line 1218 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2874{ yyval.UIntVal = CallingConv::X86_FastCall; ;
2875 break;}
2876case 103:
2877#line 1219 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2878{
2879 if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002880 GEN_ERROR("Calling conv too large");
Gabor Greif89f01162008-04-06 23:07:54 +00002881 yyval.UIntVal = yyvsp[0].UInt64Val;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002882 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00002883 ;
2884 break;}
2885case 104:
2886#line 1226 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2887{ yyval.ParamAttrs = ParamAttr::ZExt; ;
2888 break;}
2889case 105:
2890#line 1227 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2891{ yyval.ParamAttrs = ParamAttr::ZExt; ;
2892 break;}
2893case 106:
2894#line 1228 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2895{ yyval.ParamAttrs = ParamAttr::SExt; ;
2896 break;}
2897case 107:
2898#line 1229 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2899{ yyval.ParamAttrs = ParamAttr::SExt; ;
2900 break;}
2901case 108:
2902#line 1230 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2903{ yyval.ParamAttrs = ParamAttr::InReg; ;
2904 break;}
2905case 109:
2906#line 1231 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2907{ yyval.ParamAttrs = ParamAttr::StructRet; ;
2908 break;}
2909case 110:
2910#line 1232 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2911{ yyval.ParamAttrs = ParamAttr::NoAlias; ;
2912 break;}
2913case 111:
2914#line 1233 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2915{ yyval.ParamAttrs = ParamAttr::ByVal; ;
2916 break;}
2917case 112:
2918#line 1234 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2919{ yyval.ParamAttrs = ParamAttr::Nest; ;
2920 break;}
2921case 113:
2922#line 1235 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2923{ yyval.ParamAttrs =
2924 ParamAttr::constructAlignmentFromInt(yyvsp[0].UInt64Val); ;
2925 break;}
2926case 114:
2927#line 1239 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2928{ yyval.ParamAttrs = ParamAttr::None; ;
2929 break;}
2930case 115:
2931#line 1240 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2932{
2933 yyval.ParamAttrs = yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs;
2934 ;
2935 break;}
2936case 116:
2937#line 1245 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2938{ yyval.ParamAttrs = ParamAttr::NoReturn; ;
2939 break;}
2940case 117:
2941#line 1246 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2942{ yyval.ParamAttrs = ParamAttr::NoUnwind; ;
2943 break;}
2944case 118:
2945#line 1247 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2946{ yyval.ParamAttrs = ParamAttr::ZExt; ;
2947 break;}
2948case 119:
2949#line 1248 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2950{ yyval.ParamAttrs = ParamAttr::SExt; ;
2951 break;}
2952case 120:
2953#line 1249 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2954{ yyval.ParamAttrs = ParamAttr::ReadNone; ;
2955 break;}
2956case 121:
2957#line 1250 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2958{ yyval.ParamAttrs = ParamAttr::ReadOnly; ;
2959 break;}
2960case 122:
2961#line 1253 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2962{ yyval.ParamAttrs = ParamAttr::None; ;
2963 break;}
2964case 123:
2965#line 1254 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2966{
2967 yyval.ParamAttrs = yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs;
2968 ;
2969 break;}
2970case 124:
2971#line 1259 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2972{ yyval.StrVal = 0; ;
2973 break;}
2974case 125:
2975#line 1260 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2976{
2977 yyval.StrVal = yyvsp[0].StrVal;
2978 ;
2979 break;}
2980case 126:
2981#line 1267 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2982{ yyval.UIntVal = 0; ;
2983 break;}
2984case 127:
2985#line 1268 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2986{
2987 yyval.UIntVal = yyvsp[0].UInt64Val;
2988 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002989 GEN_ERROR("Alignment must be a power of two");
2990 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00002991;
2992 break;}
2993case 128:
2994#line 1274 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2995{ yyval.UIntVal = 0; ;
2996 break;}
2997case 129:
2998#line 1275 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
2999{
3000 yyval.UIntVal = yyvsp[0].UInt64Val;
3001 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
Christopher Lamb668d9a02007-12-12 08:45:45 +00003002 GEN_ERROR("Alignment must be a power of two");
3003 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003004;
3005 break;}
3006case 130:
3007#line 1284 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3008{
3009 for (unsigned i = 0, e = yyvsp[0].StrVal->length(); i != e; ++i)
3010 if ((*yyvsp[0].StrVal)[i] == '"' || (*yyvsp[0].StrVal)[i] == '\\')
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003011 GEN_ERROR("Invalid character in section name");
Gabor Greif89f01162008-04-06 23:07:54 +00003012 yyval.StrVal = yyvsp[0].StrVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003013 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003014;
3015 break;}
3016case 131:
3017#line 1292 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3018{ yyval.StrVal = 0; ;
3019 break;}
3020case 132:
3021#line 1293 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3022{ yyval.StrVal = yyvsp[0].StrVal; ;
3023 break;}
3024case 133:
3025#line 1298 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3026{;
3027 break;}
3028case 134:
3029#line 1299 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3030{;
3031 break;}
3032case 135:
3033#line 1300 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3034{
3035 CurGV->setSection(*yyvsp[0].StrVal);
3036 delete yyvsp[0].StrVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003037 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003038 ;
3039 break;}
3040case 136:
3041#line 1305 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3042{
3043 if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003044 GEN_ERROR("Alignment must be a power of two");
Gabor Greif89f01162008-04-06 23:07:54 +00003045 CurGV->setAlignment(yyvsp[0].UInt64Val);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003046 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003047 ;
3048 break;}
3049case 144:
3050#line 1321 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3051{
3052 yyval.TypeVal = new PATypeHolder(OpaqueType::get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003053 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003054 ;
3055 break;}
3056case 145:
3057#line 1325 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3058{
3059 yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003060 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003061 ;
3062 break;}
3063case 146:
3064#line 1329 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3065{ // Pointer type?
3066 if (*yyvsp[-2].TypeVal == Type::LabelTy)
Christopher Lamb668d9a02007-12-12 08:45:45 +00003067 GEN_ERROR("Cannot form a pointer to a basic block");
Gabor Greif89f01162008-04-06 23:07:54 +00003068 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-2].TypeVal, yyvsp[-1].UIntVal)));
3069 delete yyvsp[-2].TypeVal;
Christopher Lamb668d9a02007-12-12 08:45:45 +00003070 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003071 ;
3072 break;}
3073case 147:
3074#line 1336 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3075{ // Named types are also simple types...
3076 const Type* tmp = getTypeVal(yyvsp[0].ValIDVal);
Christopher Lamb0a243582007-12-11 09:02:08 +00003077 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003078 yyval.TypeVal = new PATypeHolder(tmp);
3079 ;
3080 break;}
3081case 148:
3082#line 1341 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3083{ // Type UpReference
3084 if (yyvsp[0].UInt64Val > (uint64_t)~0U) GEN_ERROR("Value out of range");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003085 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Gabor Greif89f01162008-04-06 23:07:54 +00003086 UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector...
3087 yyval.TypeVal = new PATypeHolder(OT);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003088 UR_OUT("New Upreference!\n");
3089 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003090 ;
3091 break;}
3092case 149:
3093#line 1349 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3094{
Duncan Sandsf5588dc2007-11-27 13:23:08 +00003095 // Allow but ignore attributes on function types; this permits auto-upgrade.
3096 // FIXME: remove in LLVM 3.0.
Gabor Greif89f01162008-04-06 23:07:54 +00003097 const Type* RetTy = *yyvsp[-4].TypeVal;
Anton Korobeynikove286f6d2007-12-03 21:01:29 +00003098 if (!(RetTy->isFirstClassType() || RetTy == Type::VoidTy ||
3099 isa<OpaqueType>(RetTy)))
Anton Korobeynikov0cdd2692007-12-03 19:17:47 +00003100 GEN_ERROR("LLVM Functions cannot return aggregates");
Anton Korobeynikove286f6d2007-12-03 21:01:29 +00003101
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003102 std::vector<const Type*> Params;
Gabor Greif89f01162008-04-06 23:07:54 +00003103 TypeWithAttrsList::iterator I = yyvsp[-2].TypeWithAttrsList->begin(), E = yyvsp[-2].TypeWithAttrsList->end();
Duncan Sandsf5588dc2007-11-27 13:23:08 +00003104 for (; I != E; ++I ) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003105 const Type *Ty = I->Ty->get();
3106 Params.push_back(Ty);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003107 }
Anton Korobeynikove286f6d2007-12-03 21:01:29 +00003108
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003109 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3110 if (isVarArg) Params.pop_back();
3111
Anton Korobeynikove286f6d2007-12-03 21:01:29 +00003112 for (unsigned i = 0; i != Params.size(); ++i)
3113 if (!(Params[i]->isFirstClassType() || isa<OpaqueType>(Params[i])))
3114 GEN_ERROR("Function arguments must be value types!");
3115
3116 CHECK_FOR_ERROR
3117
Anton Korobeynikov0cdd2692007-12-03 19:17:47 +00003118 FunctionType *FT = FunctionType::get(RetTy, Params, isVarArg);
Gabor Greif89f01162008-04-06 23:07:54 +00003119 delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list
3120 delete yyvsp[-4].TypeVal; // Delete the return type handle
3121 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003122 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003123 ;
3124 break;}
3125case 150:
3126#line 1379 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3127{
Duncan Sandsf5588dc2007-11-27 13:23:08 +00003128 // Allow but ignore attributes on function types; this permits auto-upgrade.
3129 // FIXME: remove in LLVM 3.0.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003130 std::vector<const Type*> Params;
Gabor Greif89f01162008-04-06 23:07:54 +00003131 TypeWithAttrsList::iterator I = yyvsp[-2].TypeWithAttrsList->begin(), E = yyvsp[-2].TypeWithAttrsList->end();
Duncan Sandsf5588dc2007-11-27 13:23:08 +00003132 for ( ; I != E; ++I ) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003133 const Type* Ty = I->Ty->get();
3134 Params.push_back(Ty);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003135 }
Anton Korobeynikove286f6d2007-12-03 21:01:29 +00003136
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003137 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3138 if (isVarArg) Params.pop_back();
3139
Anton Korobeynikove286f6d2007-12-03 21:01:29 +00003140 for (unsigned i = 0; i != Params.size(); ++i)
3141 if (!(Params[i]->isFirstClassType() || isa<OpaqueType>(Params[i])))
3142 GEN_ERROR("Function arguments must be value types!");
3143
3144 CHECK_FOR_ERROR
3145
Gabor Greif89f01162008-04-06 23:07:54 +00003146 FunctionType *FT = FunctionType::get(yyvsp[-4].PrimType, Params, isVarArg);
3147 delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list
3148 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003149 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003150 ;
3151 break;}
3152case 151:
3153#line 1404 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3154{ // Sized array type?
3155 yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
3156 delete yyvsp[-1].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003157 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003158 ;
3159 break;}
3160case 152:
3161#line 1409 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3162{ // Vector type?
3163 const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
3164 if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003165 GEN_ERROR("Unsigned result not equal to signed result");
3166 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
3167 GEN_ERROR("Element type of a VectorType must be primitive");
Gabor Greif89f01162008-04-06 23:07:54 +00003168 yyval.TypeVal = new PATypeHolder(HandleUpRefs(VectorType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
3169 delete yyvsp[-1].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003170 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003171 ;
3172 break;}
3173case 153:
3174#line 1419 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3175{ // Structure type?
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003176 std::vector<const Type*> Elements;
Gabor Greif89f01162008-04-06 23:07:54 +00003177 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
3178 E = yyvsp[-1].TypeList->end(); I != E; ++I)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003179 Elements.push_back(*I);
3180
Gabor Greif89f01162008-04-06 23:07:54 +00003181 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
3182 delete yyvsp[-1].TypeList;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003183 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003184 ;
3185 break;}
3186case 154:
3187#line 1429 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3188{ // Empty structure type?
3189 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003190 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003191 ;
3192 break;}
3193case 155:
3194#line 1433 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3195{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003196 std::vector<const Type*> Elements;
Gabor Greif89f01162008-04-06 23:07:54 +00003197 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-2].TypeList->begin(),
3198 E = yyvsp[-2].TypeList->end(); I != E; ++I)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003199 Elements.push_back(*I);
3200
Gabor Greif89f01162008-04-06 23:07:54 +00003201 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
3202 delete yyvsp[-2].TypeList;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003203 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003204 ;
3205 break;}
3206case 156:
3207#line 1443 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3208{ // Empty structure type?
3209 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003210 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003211 ;
3212 break;}
3213case 157:
3214#line 1450 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3215{
Duncan Sandsf5588dc2007-11-27 13:23:08 +00003216 // Allow but ignore attributes on function types; this permits auto-upgrade.
3217 // FIXME: remove in LLVM 3.0.
Gabor Greif89f01162008-04-06 23:07:54 +00003218 yyval.TypeWithAttrs.Ty = yyvsp[-1].TypeVal;
3219 yyval.TypeWithAttrs.Attrs = ParamAttr::None;
3220 ;
3221 break;}
3222case 158:
3223#line 1459 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3224{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003225 if (!UpRefs.empty())
Gabor Greif89f01162008-04-06 23:07:54 +00003226 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
3227 if (!(*yyvsp[0].TypeVal)->isFirstClassType() && !isa<StructType>(yyvsp[0].TypeVal->get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003228 GEN_ERROR("LLVM functions cannot return aggregate types");
Gabor Greif89f01162008-04-06 23:07:54 +00003229 yyval.TypeVal = yyvsp[0].TypeVal;
3230 ;
3231 break;}
3232case 159:
3233#line 1466 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3234{
3235 yyval.TypeVal = new PATypeHolder(Type::VoidTy);
3236 ;
3237 break;}
3238case 160:
3239#line 1471 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3240{
3241 yyval.TypeWithAttrsList = new TypeWithAttrsList();
3242 yyval.TypeWithAttrsList->push_back(yyvsp[0].TypeWithAttrs);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003243 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003244 ;
3245 break;}
3246case 161:
3247#line 1476 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3248{
3249 (yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList)->push_back(yyvsp[0].TypeWithAttrs);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003250 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003251 ;
3252 break;}
3253case 163:
3254#line 1484 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3255{
3256 yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003257 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
3258 TWA.Ty = new PATypeHolder(Type::VoidTy);
Gabor Greif89f01162008-04-06 23:07:54 +00003259 yyval.TypeWithAttrsList->push_back(TWA);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003260 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003261 ;
3262 break;}
3263case 164:
3264#line 1491 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3265{
3266 yyval.TypeWithAttrsList = new TypeWithAttrsList;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003267 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
3268 TWA.Ty = new PATypeHolder(Type::VoidTy);
Gabor Greif89f01162008-04-06 23:07:54 +00003269 yyval.TypeWithAttrsList->push_back(TWA);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003270 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003271 ;
3272 break;}
3273case 165:
3274#line 1498 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3275{
3276 yyval.TypeWithAttrsList = new TypeWithAttrsList();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003277 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003278 ;
3279 break;}
3280case 166:
3281#line 1506 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3282{
3283 yyval.TypeList = new std::list<PATypeHolder>();
3284 yyval.TypeList->push_back(*yyvsp[0].TypeVal);
3285 delete yyvsp[0].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003286 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003287 ;
3288 break;}
3289case 167:
3290#line 1512 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3291{
3292 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal);
3293 delete yyvsp[0].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003294 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003295 ;
3296 break;}
3297case 168:
3298#line 1524 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3299{ // Nonempty unsized arr
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003300 if (!UpRefs.empty())
Gabor Greif89f01162008-04-06 23:07:54 +00003301 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
3302 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003303 if (ATy == 0)
3304 GEN_ERROR("Cannot make array constant with type: '" +
Gabor Greif89f01162008-04-06 23:07:54 +00003305 (*yyvsp[-3].TypeVal)->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003306 const Type *ETy = ATy->getElementType();
3307 int NumElements = ATy->getNumElements();
3308
3309 // Verify that we have the correct size...
Gabor Greif89f01162008-04-06 23:07:54 +00003310 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003311 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Gabor Greif89f01162008-04-06 23:07:54 +00003312 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003313 itostr(NumElements) + "");
3314
3315 // Verify all elements are correct type!
Gabor Greif89f01162008-04-06 23:07:54 +00003316 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3317 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003318 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3319 ETy->getDescription() +"' as required!\nIt is of type '"+
Gabor Greif89f01162008-04-06 23:07:54 +00003320 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003321 }
3322
Gabor Greif89f01162008-04-06 23:07:54 +00003323 yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
3324 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003325 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003326 ;
3327 break;}
3328case 169:
3329#line 1552 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3330{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003331 if (!UpRefs.empty())
Gabor Greif89f01162008-04-06 23:07:54 +00003332 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3333 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003334 if (ATy == 0)
3335 GEN_ERROR("Cannot make array constant with type: '" +
Gabor Greif89f01162008-04-06 23:07:54 +00003336 (*yyvsp[-2].TypeVal)->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003337
3338 int NumElements = ATy->getNumElements();
3339 if (NumElements != -1 && NumElements != 0)
3340 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
3341 " arguments, but has size of " + itostr(NumElements) +"");
Gabor Greif89f01162008-04-06 23:07:54 +00003342 yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
3343 delete yyvsp[-2].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003344 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003345 ;
3346 break;}
3347case 170:
3348#line 1568 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3349{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003350 if (!UpRefs.empty())
Gabor Greif89f01162008-04-06 23:07:54 +00003351 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3352 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003353 if (ATy == 0)
3354 GEN_ERROR("Cannot make array constant with type: '" +
Gabor Greif89f01162008-04-06 23:07:54 +00003355 (*yyvsp[-2].TypeVal)->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003356
3357 int NumElements = ATy->getNumElements();
3358 const Type *ETy = ATy->getElementType();
Gabor Greif89f01162008-04-06 23:07:54 +00003359 if (NumElements != -1 && NumElements != int(yyvsp[0].StrVal->length()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003360 GEN_ERROR("Can't build string constant of size " +
Gabor Greif89f01162008-04-06 23:07:54 +00003361 itostr((int)(yyvsp[0].StrVal->length())) +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003362 " when array has size " + itostr(NumElements) + "");
3363 std::vector<Constant*> Vals;
3364 if (ETy == Type::Int8Ty) {
Gabor Greif89f01162008-04-06 23:07:54 +00003365 for (unsigned i = 0; i < yyvsp[0].StrVal->length(); ++i)
3366 Vals.push_back(ConstantInt::get(ETy, (*yyvsp[0].StrVal)[i]));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003367 } else {
Gabor Greif89f01162008-04-06 23:07:54 +00003368 delete yyvsp[0].StrVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003369 GEN_ERROR("Cannot build string arrays of non byte sized elements");
3370 }
Gabor Greif89f01162008-04-06 23:07:54 +00003371 delete yyvsp[0].StrVal;
3372 yyval.ConstVal = ConstantArray::get(ATy, Vals);
3373 delete yyvsp[-2].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003374 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003375 ;
3376 break;}
3377case 171:
3378#line 1595 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3379{ // Nonempty unsized arr
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003380 if (!UpRefs.empty())
Gabor Greif89f01162008-04-06 23:07:54 +00003381 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
3382 const VectorType *PTy = dyn_cast<VectorType>(yyvsp[-3].TypeVal->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003383 if (PTy == 0)
3384 GEN_ERROR("Cannot make packed constant with type: '" +
Gabor Greif89f01162008-04-06 23:07:54 +00003385 (*yyvsp[-3].TypeVal)->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003386 const Type *ETy = PTy->getElementType();
3387 int NumElements = PTy->getNumElements();
3388
3389 // Verify that we have the correct size...
Gabor Greif89f01162008-04-06 23:07:54 +00003390 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003391 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Gabor Greif89f01162008-04-06 23:07:54 +00003392 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003393 itostr(NumElements) + "");
3394
3395 // Verify all elements are correct type!
Gabor Greif89f01162008-04-06 23:07:54 +00003396 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3397 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003398 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3399 ETy->getDescription() +"' as required!\nIt is of type '"+
Gabor Greif89f01162008-04-06 23:07:54 +00003400 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003401 }
3402
Gabor Greif89f01162008-04-06 23:07:54 +00003403 yyval.ConstVal = ConstantVector::get(PTy, *yyvsp[-1].ConstVector);
3404 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003405 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003406 ;
3407 break;}
3408case 172:
3409#line 1623 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3410{
3411 const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003412 if (STy == 0)
3413 GEN_ERROR("Cannot make struct constant with type: '" +
Gabor Greif89f01162008-04-06 23:07:54 +00003414 (*yyvsp[-3].TypeVal)->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003415
Gabor Greif89f01162008-04-06 23:07:54 +00003416 if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003417 GEN_ERROR("Illegal number of initializers for structure type");
3418
3419 // Check to ensure that constants are compatible with the type initializer!
Gabor Greif89f01162008-04-06 23:07:54 +00003420 for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
3421 if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003422 GEN_ERROR("Expected type '" +
3423 STy->getElementType(i)->getDescription() +
3424 "' for element #" + utostr(i) +
3425 " of structure initializer");
3426
3427 // Check to ensure that Type is not packed
3428 if (STy->isPacked())
3429 GEN_ERROR("Unpacked Initializer to vector type '" +
3430 STy->getDescription() + "'");
3431
Gabor Greif89f01162008-04-06 23:07:54 +00003432 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
3433 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003434 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003435 ;
3436 break;}
3437case 173:
3438#line 1649 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3439{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003440 if (!UpRefs.empty())
Gabor Greif89f01162008-04-06 23:07:54 +00003441 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3442 const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003443 if (STy == 0)
3444 GEN_ERROR("Cannot make struct constant with type: '" +
Gabor Greif89f01162008-04-06 23:07:54 +00003445 (*yyvsp[-2].TypeVal)->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003446
3447 if (STy->getNumContainedTypes() != 0)
3448 GEN_ERROR("Illegal number of initializers for structure type");
3449
3450 // Check to ensure that Type is not packed
3451 if (STy->isPacked())
3452 GEN_ERROR("Unpacked Initializer to vector type '" +
3453 STy->getDescription() + "'");
3454
Gabor Greif89f01162008-04-06 23:07:54 +00003455 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
3456 delete yyvsp[-2].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003457 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003458 ;
3459 break;}
3460case 174:
3461#line 1669 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3462{
3463 const StructType *STy = dyn_cast<StructType>(yyvsp[-5].TypeVal->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003464 if (STy == 0)
3465 GEN_ERROR("Cannot make struct constant with type: '" +
Gabor Greif89f01162008-04-06 23:07:54 +00003466 (*yyvsp[-5].TypeVal)->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003467
Gabor Greif89f01162008-04-06 23:07:54 +00003468 if (yyvsp[-2].ConstVector->size() != STy->getNumContainedTypes())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003469 GEN_ERROR("Illegal number of initializers for structure type");
3470
3471 // Check to ensure that constants are compatible with the type initializer!
Gabor Greif89f01162008-04-06 23:07:54 +00003472 for (unsigned i = 0, e = yyvsp[-2].ConstVector->size(); i != e; ++i)
3473 if ((*yyvsp[-2].ConstVector)[i]->getType() != STy->getElementType(i))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003474 GEN_ERROR("Expected type '" +
3475 STy->getElementType(i)->getDescription() +
3476 "' for element #" + utostr(i) +
3477 " of structure initializer");
3478
3479 // Check to ensure that Type is packed
3480 if (!STy->isPacked())
3481 GEN_ERROR("Vector initializer to non-vector type '" +
3482 STy->getDescription() + "'");
3483
Gabor Greif89f01162008-04-06 23:07:54 +00003484 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-2].ConstVector);
3485 delete yyvsp[-5].TypeVal; delete yyvsp[-2].ConstVector;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003486 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003487 ;
3488 break;}
3489case 175:
3490#line 1695 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3491{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003492 if (!UpRefs.empty())
Gabor Greif89f01162008-04-06 23:07:54 +00003493 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
3494 const StructType *STy = dyn_cast<StructType>(yyvsp[-4].TypeVal->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003495 if (STy == 0)
3496 GEN_ERROR("Cannot make struct constant with type: '" +
Gabor Greif89f01162008-04-06 23:07:54 +00003497 (*yyvsp[-4].TypeVal)->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003498
3499 if (STy->getNumContainedTypes() != 0)
3500 GEN_ERROR("Illegal number of initializers for structure type");
3501
3502 // Check to ensure that Type is packed
3503 if (!STy->isPacked())
3504 GEN_ERROR("Vector initializer to non-vector type '" +
3505 STy->getDescription() + "'");
3506
Gabor Greif89f01162008-04-06 23:07:54 +00003507 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
3508 delete yyvsp[-4].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003509 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003510 ;
3511 break;}
3512case 176:
3513#line 1715 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3514{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003515 if (!UpRefs.empty())
Gabor Greif89f01162008-04-06 23:07:54 +00003516 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3517 const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003518 if (PTy == 0)
3519 GEN_ERROR("Cannot make null pointer constant with type: '" +
Gabor Greif89f01162008-04-06 23:07:54 +00003520 (*yyvsp[-1].TypeVal)->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003521
Gabor Greif89f01162008-04-06 23:07:54 +00003522 yyval.ConstVal = ConstantPointerNull::get(PTy);
3523 delete yyvsp[-1].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003524 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003525 ;
3526 break;}
3527case 177:
3528#line 1727 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3529{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003530 if (!UpRefs.empty())
Gabor Greif89f01162008-04-06 23:07:54 +00003531 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3532 yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
3533 delete yyvsp[-1].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003534 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003535 ;
3536 break;}
3537case 178:
3538#line 1734 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3539{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003540 if (!UpRefs.empty())
Gabor Greif89f01162008-04-06 23:07:54 +00003541 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3542 const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003543 if (Ty == 0)
Gabor Greif89f01162008-04-06 23:07:54 +00003544 GEN_ERROR("Global const reference must be a pointer type " + (*yyvsp[-1].TypeVal)->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003545
3546 // ConstExprs can exist in the body of a function, thus creating
3547 // GlobalValues whenever they refer to a variable. Because we are in
3548 // the context of a function, getExistingVal will search the functions
3549 // symbol table instead of the module symbol table for the global symbol,
3550 // which throws things all off. To get around this, we just tell
3551 // getExistingVal that we are at global scope here.
3552 //
3553 Function *SavedCurFn = CurFun.CurrentFunction;
3554 CurFun.CurrentFunction = 0;
3555
Gabor Greif89f01162008-04-06 23:07:54 +00003556 Value *V = getExistingVal(Ty, yyvsp[0].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003557 CHECK_FOR_ERROR
3558
3559 CurFun.CurrentFunction = SavedCurFn;
3560
3561 // If this is an initializer for a constant pointer, which is referencing a
3562 // (currently) undefined variable, create a stub now that shall be replaced
3563 // in the future with the right type of variable.
3564 //
3565 if (V == 0) {
3566 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
3567 const PointerType *PT = cast<PointerType>(Ty);
3568
3569 // First check to see if the forward references value is already created!
3570 PerModuleInfo::GlobalRefsType::iterator I =
Gabor Greif89f01162008-04-06 23:07:54 +00003571 CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003572
3573 if (I != CurModule.GlobalRefs.end()) {
3574 V = I->second; // Placeholder already exists, use it...
Gabor Greif89f01162008-04-06 23:07:54 +00003575 yyvsp[0].ValIDVal.destroy();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003576 } else {
3577 std::string Name;
Gabor Greif89f01162008-04-06 23:07:54 +00003578 if (yyvsp[0].ValIDVal.Type == ValID::GlobalName)
3579 Name = yyvsp[0].ValIDVal.getName();
3580 else if (yyvsp[0].ValIDVal.Type != ValID::GlobalID)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003581 GEN_ERROR("Invalid reference to global");
3582
3583 // Create the forward referenced global.
3584 GlobalValue *GV;
3585 if (const FunctionType *FTy =
3586 dyn_cast<FunctionType>(PT->getElementType())) {
Gabor Greif89f01162008-04-06 23:07:54 +00003587 GV = Function::Create(FTy, GlobalValue::ExternalWeakLinkage, Name,
3588 CurModule.CurrentModule);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003589 } else {
3590 GV = new GlobalVariable(PT->getElementType(), false,
3591 GlobalValue::ExternalWeakLinkage, 0,
3592 Name, CurModule.CurrentModule);
3593 }
3594
3595 // Keep track of the fact that we have a forward ref to recycle it
Gabor Greif89f01162008-04-06 23:07:54 +00003596 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003597 V = GV;
3598 }
3599 }
3600
Gabor Greif89f01162008-04-06 23:07:54 +00003601 yyval.ConstVal = cast<GlobalValue>(V);
3602 delete yyvsp[-1].TypeVal; // Free the type handle
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003603 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003604 ;
3605 break;}
3606case 179:
3607#line 1800 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3608{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003609 if (!UpRefs.empty())
Gabor Greif89f01162008-04-06 23:07:54 +00003610 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3611 if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003612 GEN_ERROR("Mismatched types for constant expression: " +
Gabor Greif89f01162008-04-06 23:07:54 +00003613 (*yyvsp[-1].TypeVal)->getDescription() + " and " + yyvsp[0].ConstVal->getType()->getDescription());
3614 yyval.ConstVal = yyvsp[0].ConstVal;
3615 delete yyvsp[-1].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003616 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003617 ;
3618 break;}
3619case 180:
3620#line 1810 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3621{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003622 if (!UpRefs.empty())
Gabor Greif89f01162008-04-06 23:07:54 +00003623 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3624 const Type *Ty = yyvsp[-1].TypeVal->get();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003625 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
3626 GEN_ERROR("Cannot create a null initialized value of this type");
Gabor Greif89f01162008-04-06 23:07:54 +00003627 yyval.ConstVal = Constant::getNullValue(Ty);
3628 delete yyvsp[-1].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003629 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003630 ;
3631 break;}
3632case 181:
3633#line 1820 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3634{ // integral constants
3635 if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003636 GEN_ERROR("Constant value doesn't fit in type");
Gabor Greif89f01162008-04-06 23:07:54 +00003637 yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val, true);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003638 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003639 ;
3640 break;}
3641case 182:
3642#line 1826 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3643{ // arbitrary precision integer constants
3644 uint32_t BitWidth = cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth();
3645 if (yyvsp[0].APIntVal->getBitWidth() > BitWidth) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003646 GEN_ERROR("Constant value does not fit in type");
3647 }
Gabor Greif89f01162008-04-06 23:07:54 +00003648 yyvsp[0].APIntVal->sextOrTrunc(BitWidth);
3649 yyval.ConstVal = ConstantInt::get(*yyvsp[0].APIntVal);
3650 delete yyvsp[0].APIntVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003651 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003652 ;
3653 break;}
3654case 183:
3655#line 1836 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3656{ // integral constants
3657 if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003658 GEN_ERROR("Constant value doesn't fit in type");
Gabor Greif89f01162008-04-06 23:07:54 +00003659 yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val, false);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003660 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003661 ;
3662 break;}
3663case 184:
3664#line 1842 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3665{ // arbitrary precision integer constants
3666 uint32_t BitWidth = cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth();
3667 if (yyvsp[0].APIntVal->getBitWidth() > BitWidth) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003668 GEN_ERROR("Constant value does not fit in type");
3669 }
Gabor Greif89f01162008-04-06 23:07:54 +00003670 yyvsp[0].APIntVal->zextOrTrunc(BitWidth);
3671 yyval.ConstVal = ConstantInt::get(*yyvsp[0].APIntVal);
3672 delete yyvsp[0].APIntVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003673 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003674 ;
3675 break;}
3676case 185:
3677#line 1852 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3678{ // Boolean constants
3679 assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?");
3680 yyval.ConstVal = ConstantInt::getTrue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003681 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003682 ;
3683 break;}
3684case 186:
3685#line 1857 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3686{ // Boolean constants
3687 assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?");
3688 yyval.ConstVal = ConstantInt::getFalse();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003689 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003690 ;
3691 break;}
3692case 187:
3693#line 1862 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3694{ // Floating point constants
3695 if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, *yyvsp[0].FPVal))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003696 GEN_ERROR("Floating point constant invalid for type");
Dale Johannesen255b8fe2007-09-11 18:33:39 +00003697 // Lexer has no type info, so builds all float and double FP constants
3698 // as double. Fix this here. Long double is done right.
Gabor Greif89f01162008-04-06 23:07:54 +00003699 if (&yyvsp[0].FPVal->getSemantics()==&APFloat::IEEEdouble && yyvsp[-1].PrimType==Type::FloatTy)
3700 yyvsp[0].FPVal->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
3701 yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, *yyvsp[0].FPVal);
3702 delete yyvsp[0].FPVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003703 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003704 ;
3705 break;}
3706case 188:
3707#line 1875 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3708{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003709 if (!UpRefs.empty())
Gabor Greif89f01162008-04-06 23:07:54 +00003710 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3711 Constant *Val = yyvsp[-3].ConstVal;
3712 const Type *DestTy = yyvsp[-1].TypeVal->get();
3713 if (!CastInst::castIsValid(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003714 GEN_ERROR("invalid cast opcode for cast from '" +
3715 Val->getType()->getDescription() + "' to '" +
3716 DestTy->getDescription() + "'");
Gabor Greif89f01162008-04-06 23:07:54 +00003717 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy);
3718 delete yyvsp[-1].TypeVal;
3719 ;
3720 break;}
3721case 189:
3722#line 1887 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3723{
3724 if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003725 GEN_ERROR("GetElementPtr requires a pointer operand");
3726
3727 const Type *IdxTy =
Gabor Greif89f01162008-04-06 23:07:54 +00003728 GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end(),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003729 true);
3730 if (!IdxTy)
3731 GEN_ERROR("Index list invalid for constant getelementptr");
3732
3733 SmallVector<Constant*, 8> IdxVec;
Gabor Greif89f01162008-04-06 23:07:54 +00003734 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
3735 if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003736 IdxVec.push_back(C);
3737 else
3738 GEN_ERROR("Indices to constant getelementptr must be constants");
3739
Gabor Greif89f01162008-04-06 23:07:54 +00003740 delete yyvsp[-1].ValueList;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003741
Gabor Greif89f01162008-04-06 23:07:54 +00003742 yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, &IdxVec[0], IdxVec.size());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003743 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003744 ;
3745 break;}
3746case 190:
3747#line 1909 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3748{
3749 if (yyvsp[-5].ConstVal->getType() != Type::Int1Ty)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003750 GEN_ERROR("Select condition must be of boolean type");
Gabor Greif89f01162008-04-06 23:07:54 +00003751 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003752 GEN_ERROR("Select operand types must match");
Gabor Greif89f01162008-04-06 23:07:54 +00003753 yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003754 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003755 ;
3756 break;}
3757case 191:
3758#line 1917 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3759{
3760 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003761 GEN_ERROR("Binary operator types must match");
3762 CHECK_FOR_ERROR;
Gabor Greif89f01162008-04-06 23:07:54 +00003763 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3764 ;
3765 break;}
3766case 192:
3767#line 1923 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3768{
3769 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003770 GEN_ERROR("Logical operator types must match");
Gabor Greif89f01162008-04-06 23:07:54 +00003771 if (!yyvsp[-3].ConstVal->getType()->isInteger()) {
3772 if (Instruction::isShift(yyvsp[-5].BinaryOpVal) || !isa<VectorType>(yyvsp[-3].ConstVal->getType()) ||
3773 !cast<VectorType>(yyvsp[-3].ConstVal->getType())->getElementType()->isInteger())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003774 GEN_ERROR("Logical operator requires integral operands");
3775 }
Gabor Greif89f01162008-04-06 23:07:54 +00003776 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003777 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003778 ;
3779 break;}
3780case 193:
3781#line 1934 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3782{
3783 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003784 GEN_ERROR("icmp operand types must match");
Gabor Greif89f01162008-04-06 23:07:54 +00003785 yyval.ConstVal = ConstantExpr::getICmp(yyvsp[-5].IPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3786 ;
3787 break;}
3788case 194:
3789#line 1939 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3790{
3791 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003792 GEN_ERROR("fcmp operand types must match");
Gabor Greif89f01162008-04-06 23:07:54 +00003793 yyval.ConstVal = ConstantExpr::getFCmp(yyvsp[-5].FPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3794 ;
3795 break;}
3796case 195:
3797#line 1944 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3798{
3799 if (!ExtractElementInst::isValidOperands(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003800 GEN_ERROR("Invalid extractelement operands");
Gabor Greif89f01162008-04-06 23:07:54 +00003801 yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003802 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003803 ;
3804 break;}
3805case 196:
3806#line 1950 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3807{
3808 if (!InsertElementInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003809 GEN_ERROR("Invalid insertelement operands");
Gabor Greif89f01162008-04-06 23:07:54 +00003810 yyval.ConstVal = ConstantExpr::getInsertElement(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003811 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003812 ;
3813 break;}
3814case 197:
3815#line 1956 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3816{
3817 if (!ShuffleVectorInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003818 GEN_ERROR("Invalid shufflevector operands");
Gabor Greif89f01162008-04-06 23:07:54 +00003819 yyval.ConstVal = ConstantExpr::getShuffleVector(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003820 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003821 ;
3822 break;}
3823case 198:
3824#line 1965 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3825{
3826 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003827 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003828 ;
3829 break;}
3830case 199:
3831#line 1969 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3832{
3833 yyval.ConstVector = new std::vector<Constant*>();
3834 yyval.ConstVector->push_back(yyvsp[0].ConstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003835 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003836 ;
3837 break;}
3838case 200:
3839#line 1977 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3840{ yyval.BoolVal = false; ;
3841 break;}
3842case 201:
3843#line 1977 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3844{ yyval.BoolVal = true; ;
3845 break;}
3846case 202:
3847#line 1980 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3848{ yyval.BoolVal = true; ;
3849 break;}
3850case 203:
3851#line 1980 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3852{ yyval.BoolVal = false; ;
3853 break;}
3854case 204:
3855#line 1983 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3856{
3857 const Type* VTy = yyvsp[-1].TypeVal->get();
3858 Value *V = getVal(VTy, yyvsp[0].ValIDVal);
Chris Lattnerbb856a32007-08-06 21:00:46 +00003859 CHECK_FOR_ERROR
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003860 GlobalValue* Aliasee = dyn_cast<GlobalValue>(V);
3861 if (!Aliasee)
3862 GEN_ERROR("Aliases can be created only to global values");
3863
Gabor Greif89f01162008-04-06 23:07:54 +00003864 yyval.ConstVal = Aliasee;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003865 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003866 delete yyvsp[-1].TypeVal;
3867 ;
3868 break;}
3869case 205:
3870#line 1995 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3871{
3872 Constant *Val = yyvsp[-3].ConstVal;
3873 const Type *DestTy = yyvsp[-1].TypeVal->get();
3874 if (!CastInst::castIsValid(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003875 GEN_ERROR("invalid cast opcode for cast from '" +
3876 Val->getType()->getDescription() + "' to '" +
3877 DestTy->getDescription() + "'");
3878
Gabor Greif89f01162008-04-06 23:07:54 +00003879 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003880 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003881 delete yyvsp[-1].TypeVal;
3882 ;
3883 break;}
3884case 206:
3885#line 2016 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3886{
3887 yyval.ModuleVal = ParserResult = CurModule.CurrentModule;
Christopher Lamb668d9a02007-12-12 08:45:45 +00003888 CurModule.ModuleDone();
3889 CHECK_FOR_ERROR;
Gabor Greif89f01162008-04-06 23:07:54 +00003890 ;
3891 break;}
3892case 207:
3893#line 2021 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3894{
3895 yyval.ModuleVal = ParserResult = CurModule.CurrentModule;
Dale Johannesena79ecf32008-02-20 21:15:43 +00003896 CurModule.ModuleDone();
3897 CHECK_FOR_ERROR;
Gabor Greif89f01162008-04-06 23:07:54 +00003898 ;
3899 break;}
3900case 210:
3901#line 2034 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3902{ CurFun.isDeclare = false; ;
3903 break;}
3904case 211:
3905#line 2034 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3906{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003907 CurFun.FunctionDone();
3908 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003909 ;
3910 break;}
3911case 212:
3912#line 2038 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3913{ CurFun.isDeclare = true; ;
3914 break;}
3915case 213:
3916#line 2038 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3917{
Christopher Lamb668d9a02007-12-12 08:45:45 +00003918 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003919 ;
3920 break;}
3921case 214:
3922#line 2041 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3923{
Dale Johannesena79ecf32008-02-20 21:15:43 +00003924 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003925 ;
3926 break;}
3927case 215:
3928#line 2044 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3929{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003930 if (!UpRefs.empty())
Gabor Greif89f01162008-04-06 23:07:54 +00003931 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003932 // Eagerly resolve types. This is not an optimization, this is a
3933 // requirement that is due to the fact that we could have this:
3934 //
3935 // %list = type { %list * }
3936 // %list = type { %list * } ; repeated type decl
3937 //
3938 // If types are not resolved eagerly, then the two types will not be
3939 // determined to be the same type!
3940 //
Gabor Greif89f01162008-04-06 23:07:54 +00003941 ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003942
Gabor Greif89f01162008-04-06 23:07:54 +00003943 if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003944 CHECK_FOR_ERROR
3945 // If this is a named type that is not a redefinition, add it to the slot
3946 // table.
Gabor Greif89f01162008-04-06 23:07:54 +00003947 CurModule.Types.push_back(*yyvsp[0].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003948 }
3949
Gabor Greif89f01162008-04-06 23:07:54 +00003950 delete yyvsp[0].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003951 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003952 ;
3953 break;}
3954case 216:
3955#line 2068 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3956{
3957 ResolveTypeTo(yyvsp[-2].StrVal, yyvsp[0].PrimType);
Reid Spenceraa8ae282007-07-31 03:50:36 +00003958
Gabor Greif89f01162008-04-06 23:07:54 +00003959 if (!setTypeName(yyvsp[0].PrimType, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003960 CHECK_FOR_ERROR
3961 // If this is a named type that is not a redefinition, add it to the slot
3962 // table.
Gabor Greif89f01162008-04-06 23:07:54 +00003963 CurModule.Types.push_back(yyvsp[0].PrimType);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003964 }
3965 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003966 ;
3967 break;}
3968case 217:
3969#line 2080 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3970{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003971 /* "Externally Visible" Linkage */
Gabor Greif89f01162008-04-06 23:07:54 +00003972 if (yyvsp[-1].ConstVal == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003973 GEN_ERROR("Global value initializer is not a constant");
Gabor Greif89f01162008-04-06 23:07:54 +00003974 CurGV = ParseGlobalVariable(yyvsp[-5].StrVal, GlobalValue::ExternalLinkage,
3975 yyvsp[-4].Visibility, yyvsp[-2].BoolVal, yyvsp[-1].ConstVal->getType(), yyvsp[-1].ConstVal, yyvsp[-3].BoolVal, yyvsp[0].UIntVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003976 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003977 ;
3978 break;}
3979case 218:
3980#line 2087 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3981{
Christopher Lamb668d9a02007-12-12 08:45:45 +00003982 CurGV = 0;
Gabor Greif89f01162008-04-06 23:07:54 +00003983 ;
3984 break;}
3985case 219:
3986#line 2091 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3987{
3988 if (yyvsp[-1].ConstVal == 0)
Christopher Lamb668d9a02007-12-12 08:45:45 +00003989 GEN_ERROR("Global value initializer is not a constant");
Gabor Greif89f01162008-04-06 23:07:54 +00003990 CurGV = ParseGlobalVariable(yyvsp[-6].StrVal, yyvsp[-5].Linkage, yyvsp[-4].Visibility, yyvsp[-2].BoolVal, yyvsp[-1].ConstVal->getType(), yyvsp[-1].ConstVal, yyvsp[-3].BoolVal, yyvsp[0].UIntVal);
Christopher Lamb668d9a02007-12-12 08:45:45 +00003991 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00003992 ;
3993 break;}
3994case 220:
3995#line 2096 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
3996{
Christopher Lamb668d9a02007-12-12 08:45:45 +00003997 CurGV = 0;
Gabor Greif89f01162008-04-06 23:07:54 +00003998 ;
3999 break;}
4000case 221:
4001#line 2100 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4002{
Christopher Lamb668d9a02007-12-12 08:45:45 +00004003 if (!UpRefs.empty())
Gabor Greif89f01162008-04-06 23:07:54 +00004004 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4005 CurGV = ParseGlobalVariable(yyvsp[-6].StrVal, yyvsp[-5].Linkage, yyvsp[-4].Visibility, yyvsp[-2].BoolVal, *yyvsp[-1].TypeVal, 0, yyvsp[-3].BoolVal, yyvsp[0].UIntVal);
Christopher Lamb668d9a02007-12-12 08:45:45 +00004006 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004007 delete yyvsp[-1].TypeVal;
4008 ;
4009 break;}
4010case 222:
4011#line 2106 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4012{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004013 CurGV = 0;
4014 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004015 ;
4016 break;}
4017case 223:
4018#line 2110 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4019{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004020 std::string Name;
Gabor Greif89f01162008-04-06 23:07:54 +00004021 if (yyvsp[-4].StrVal) {
4022 Name = *yyvsp[-4].StrVal;
4023 delete yyvsp[-4].StrVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004024 }
4025 if (Name.empty())
4026 GEN_ERROR("Alias name cannot be empty");
4027
Gabor Greif89f01162008-04-06 23:07:54 +00004028 Constant* Aliasee = yyvsp[0].ConstVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004029 if (Aliasee == 0)
4030 GEN_ERROR(std::string("Invalid aliasee for alias: ") + Name);
4031
Gabor Greif89f01162008-04-06 23:07:54 +00004032 GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), yyvsp[-1].Linkage, Name, Aliasee,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004033 CurModule.CurrentModule);
Gabor Greif89f01162008-04-06 23:07:54 +00004034 GA->setVisibility(yyvsp[-3].Visibility);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004035 InsertValue(GA, CurModule.Values);
Chris Lattner5eefce32007-09-10 23:24:14 +00004036
4037
4038 // If there was a forward reference of this alias, resolve it now.
4039
4040 ValID ID;
4041 if (!Name.empty())
4042 ID = ValID::createGlobalName(Name);
4043 else
4044 ID = ValID::createGlobalID(CurModule.Values.size()-1);
4045
4046 if (GlobalValue *FWGV =
4047 CurModule.GetForwardRefForGlobal(GA->getType(), ID)) {
4048 // Replace uses of the fwdref with the actual alias.
4049 FWGV->replaceAllUsesWith(GA);
4050 if (GlobalVariable *GV = dyn_cast<GlobalVariable>(FWGV))
4051 GV->eraseFromParent();
4052 else
4053 cast<Function>(FWGV)->eraseFromParent();
4054 }
4055 ID.destroy();
4056
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004057 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004058 ;
4059 break;}
4060case 224:
4061#line 2150 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4062{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004063 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004064 ;
4065 break;}
4066case 225:
4067#line 2153 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4068{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004069 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004070 ;
4071 break;}
4072case 226:
4073#line 2159 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4074{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004075 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
4076 if (AsmSoFar.empty())
Gabor Greif89f01162008-04-06 23:07:54 +00004077 CurModule.CurrentModule->setModuleInlineAsm(*yyvsp[0].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004078 else
Gabor Greif89f01162008-04-06 23:07:54 +00004079 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+*yyvsp[0].StrVal);
4080 delete yyvsp[0].StrVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004081 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004082;
4083 break;}
4084case 227:
4085#line 2169 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4086{
4087 CurModule.CurrentModule->setTargetTriple(*yyvsp[0].StrVal);
4088 delete yyvsp[0].StrVal;
4089 ;
4090 break;}
4091case 228:
4092#line 2173 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4093{
4094 CurModule.CurrentModule->setDataLayout(*yyvsp[0].StrVal);
4095 delete yyvsp[0].StrVal;
4096 ;
4097 break;}
4098case 230:
4099#line 2180 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4100{
4101 CurModule.CurrentModule->addLibrary(*yyvsp[0].StrVal);
4102 delete yyvsp[0].StrVal;
Christopher Lamb668d9a02007-12-12 08:45:45 +00004103 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004104 ;
4105 break;}
4106case 231:
4107#line 2185 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4108{
4109 CurModule.CurrentModule->addLibrary(*yyvsp[0].StrVal);
4110 delete yyvsp[0].StrVal;
Reid Spencer47470022007-07-31 14:41:17 +00004111 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004112 ;
4113 break;}
4114case 232:
4115#line 2190 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4116{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004117 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004118 ;
4119 break;}
4120case 233:
4121#line 2199 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4122{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004123 if (!UpRefs.empty())
Gabor Greif89f01162008-04-06 23:07:54 +00004124 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4125 if (*yyvsp[-2].TypeVal == Type::VoidTy)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004126 GEN_ERROR("void typed arguments are invalid");
Gabor Greif89f01162008-04-06 23:07:54 +00004127 ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal;
4128 yyval.ArgList = yyvsp[-4].ArgList;
4129 yyvsp[-4].ArgList->push_back(E);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004130 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004131 ;
4132 break;}
4133case 234:
4134#line 2209 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4135{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004136 if (!UpRefs.empty())
Gabor Greif89f01162008-04-06 23:07:54 +00004137 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4138 if (*yyvsp[-2].TypeVal == Type::VoidTy)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004139 GEN_ERROR("void typed arguments are invalid");
Gabor Greif89f01162008-04-06 23:07:54 +00004140 ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal;
4141 yyval.ArgList = new ArgListType;
4142 yyval.ArgList->push_back(E);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004143 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004144 ;
4145 break;}
4146case 235:
4147#line 2220 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4148{
4149 yyval.ArgList = yyvsp[0].ArgList;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004150 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004151 ;
4152 break;}
4153case 236:
4154#line 2224 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4155{
4156 yyval.ArgList = yyvsp[-2].ArgList;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004157 struct ArgListEntry E;
4158 E.Ty = new PATypeHolder(Type::VoidTy);
4159 E.Name = 0;
4160 E.Attrs = ParamAttr::None;
Gabor Greif89f01162008-04-06 23:07:54 +00004161 yyval.ArgList->push_back(E);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004162 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004163 ;
4164 break;}
4165case 237:
4166#line 2233 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4167{
4168 yyval.ArgList = new ArgListType;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004169 struct ArgListEntry E;
4170 E.Ty = new PATypeHolder(Type::VoidTy);
4171 E.Name = 0;
4172 E.Attrs = ParamAttr::None;
Gabor Greif89f01162008-04-06 23:07:54 +00004173 yyval.ArgList->push_back(E);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004174 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004175 ;
4176 break;}
4177case 238:
4178#line 2242 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4179{
4180 yyval.ArgList = 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004181 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004182 ;
4183 break;}
4184case 239:
4185#line 2248 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4186{
4187 std::string FunctionName(*yyvsp[-7].StrVal);
4188 delete yyvsp[-7].StrVal; // Free strdup'd memory!
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004189
4190 // Check the function result for abstractness if this is a define. We should
4191 // have no abstract types at this point
Gabor Greif89f01162008-04-06 23:07:54 +00004192 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(yyvsp[-8].TypeVal))
4193 GEN_ERROR("Reference to abstract result: "+ yyvsp[-8].TypeVal->get()->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004194
4195 std::vector<const Type*> ParamTypeList;
Chris Lattner1c8733e2008-03-12 17:45:29 +00004196 SmallVector<ParamAttrsWithIndex, 8> Attrs;
Gabor Greif89f01162008-04-06 23:07:54 +00004197 if (yyvsp[-3].ParamAttrs != ParamAttr::None)
4198 Attrs.push_back(ParamAttrsWithIndex::get(0, yyvsp[-3].ParamAttrs));
4199 if (yyvsp[-5].ArgList) { // If there are arguments...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004200 unsigned index = 1;
Gabor Greif89f01162008-04-06 23:07:54 +00004201 for (ArgListType::iterator I = yyvsp[-5].ArgList->begin(); I != yyvsp[-5].ArgList->end(); ++I, ++index) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004202 const Type* Ty = I->Ty->get();
4203 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
4204 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
4205 ParamTypeList.push_back(Ty);
Chris Lattner1c8733e2008-03-12 17:45:29 +00004206 if (Ty != Type::VoidTy && I->Attrs != ParamAttr::None)
4207 Attrs.push_back(ParamAttrsWithIndex::get(index, I->Attrs));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004208 }
4209 }
4210
4211 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
4212 if (isVarArg) ParamTypeList.pop_back();
4213
Chris Lattner1c8733e2008-03-12 17:45:29 +00004214 PAListPtr PAL;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004215 if (!Attrs.empty())
Chris Lattner1c8733e2008-03-12 17:45:29 +00004216 PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004217
Gabor Greif89f01162008-04-06 23:07:54 +00004218 FunctionType *FT = FunctionType::get(*yyvsp[-8].TypeVal, ParamTypeList, isVarArg);
Christopher Lambfb623c62007-12-17 01:17:35 +00004219 const PointerType *PFT = PointerType::getUnqual(FT);
Gabor Greif89f01162008-04-06 23:07:54 +00004220 delete yyvsp[-8].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004221
4222 ValID ID;
4223 if (!FunctionName.empty()) {
4224 ID = ValID::createGlobalName((char*)FunctionName.c_str());
4225 } else {
4226 ID = ValID::createGlobalID(CurModule.Values.size());
4227 }
4228
4229 Function *Fn = 0;
4230 // See if this function was forward referenced. If so, recycle the object.
4231 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4232 // Move the function to the end of the list, from whereever it was
4233 // previously inserted.
4234 Fn = cast<Function>(FWRef);
Chris Lattner1c8733e2008-03-12 17:45:29 +00004235 assert(Fn->getParamAttrs().isEmpty() &&
4236 "Forward reference has parameter attributes!");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004237 CurModule.CurrentModule->getFunctionList().remove(Fn);
4238 CurModule.CurrentModule->getFunctionList().push_back(Fn);
4239 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
4240 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004241 if (Fn->getFunctionType() != FT ) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004242 // The existing function doesn't have the same type. This is an overload
4243 // error.
4244 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004245 } else if (Fn->getParamAttrs() != PAL) {
4246 // The existing function doesn't have the same parameter attributes.
4247 // This is an overload error.
4248 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004249 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
4250 // Neither the existing or the current function is a declaration and they
4251 // have the same name and same type. Clearly this is a redefinition.
4252 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004253 } else if (Fn->isDeclaration()) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004254 // Make sure to strip off any argument names so we can't get conflicts.
4255 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
4256 AI != AE; ++AI)
4257 AI->setName("");
4258 }
4259 } else { // Not already defined?
Gabor Greif89f01162008-04-06 23:07:54 +00004260 Fn = Function::Create(FT, GlobalValue::ExternalWeakLinkage, FunctionName,
4261 CurModule.CurrentModule);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004262 InsertValue(Fn, CurModule.Values);
4263 }
4264
4265 CurFun.FunctionStart(Fn);
4266
4267 if (CurFun.isDeclare) {
4268 // If we have declaration, always overwrite linkage. This will allow us to
4269 // correctly handle cases, when pointer to function is passed as argument to
4270 // another function.
4271 Fn->setLinkage(CurFun.Linkage);
4272 Fn->setVisibility(CurFun.Visibility);
4273 }
Gabor Greif89f01162008-04-06 23:07:54 +00004274 Fn->setCallingConv(yyvsp[-9].UIntVal);
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004275 Fn->setParamAttrs(PAL);
Gabor Greif89f01162008-04-06 23:07:54 +00004276 Fn->setAlignment(yyvsp[-1].UIntVal);
4277 if (yyvsp[-2].StrVal) {
4278 Fn->setSection(*yyvsp[-2].StrVal);
4279 delete yyvsp[-2].StrVal;
Gordon Henriksen13fe5e32007-12-10 03:18:06 +00004280 }
Gabor Greif89f01162008-04-06 23:07:54 +00004281 if (yyvsp[0].StrVal) {
4282 Fn->setCollector(yyvsp[0].StrVal->c_str());
4283 delete yyvsp[0].StrVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004284 }
4285
4286 // Add all of the arguments we parsed to the function...
Gabor Greif89f01162008-04-06 23:07:54 +00004287 if (yyvsp[-5].ArgList) { // Is null if empty...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004288 if (isVarArg) { // Nuke the last entry
Gabor Greif89f01162008-04-06 23:07:54 +00004289 assert(yyvsp[-5].ArgList->back().Ty->get() == Type::VoidTy && yyvsp[-5].ArgList->back().Name == 0 &&
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004290 "Not a varargs marker!");
Gabor Greif89f01162008-04-06 23:07:54 +00004291 delete yyvsp[-5].ArgList->back().Ty;
4292 yyvsp[-5].ArgList->pop_back(); // Delete the last entry
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004293 }
4294 Function::arg_iterator ArgIt = Fn->arg_begin();
4295 Function::arg_iterator ArgEnd = Fn->arg_end();
4296 unsigned Idx = 1;
Gabor Greif89f01162008-04-06 23:07:54 +00004297 for (ArgListType::iterator I = yyvsp[-5].ArgList->begin();
4298 I != yyvsp[-5].ArgList->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004299 delete I->Ty; // Delete the typeholder...
4300 setValueName(ArgIt, I->Name); // Insert arg into symtab...
4301 CHECK_FOR_ERROR
4302 InsertValue(ArgIt);
4303 Idx++;
4304 }
4305
Gabor Greif89f01162008-04-06 23:07:54 +00004306 delete yyvsp[-5].ArgList; // We're now done with the argument list
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004307 }
4308 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004309;
4310 break;}
4311case 242:
4312#line 2375 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4313{
4314 yyval.FunctionVal = CurFun.CurrentFunction;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004315
4316 // Make sure that we keep track of the linkage type even if there was a
4317 // previous "declare".
Gabor Greif89f01162008-04-06 23:07:54 +00004318 yyval.FunctionVal->setLinkage(yyvsp[-3].Linkage);
4319 yyval.FunctionVal->setVisibility(yyvsp[-2].Visibility);
4320;
4321 break;}
4322case 245:
4323#line 2386 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4324{
4325 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004326 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004327;
4328 break;}
4329case 246:
4330#line 2391 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4331{
4332 CurFun.CurrentFunction->setLinkage(yyvsp[-2].Linkage);
4333 CurFun.CurrentFunction->setVisibility(yyvsp[-1].Visibility);
4334 yyval.FunctionVal = CurFun.CurrentFunction;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004335 CurFun.FunctionDone();
4336 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004337 ;
4338 break;}
4339case 247:
4340#line 2403 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4341{
4342 yyval.BoolVal = false;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004343 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004344 ;
4345 break;}
4346case 248:
4347#line 2407 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4348{
4349 yyval.BoolVal = true;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004350 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004351 ;
4352 break;}
4353case 249:
4354#line 2412 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4355{ // A reference to a direct constant
4356 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004357 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004358 ;
4359 break;}
4360case 250:
4361#line 2416 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4362{
4363 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004364 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004365 ;
4366 break;}
4367case 251:
4368#line 2420 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4369{ // Perhaps it's an FP constant?
4370 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004371 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004372 ;
4373 break;}
4374case 252:
4375#line 2424 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4376{
4377 yyval.ValIDVal = ValID::create(ConstantInt::getTrue());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004378 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004379 ;
4380 break;}
4381case 253:
4382#line 2428 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4383{
4384 yyval.ValIDVal = ValID::create(ConstantInt::getFalse());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004385 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004386 ;
4387 break;}
4388case 254:
4389#line 2432 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4390{
4391 yyval.ValIDVal = ValID::createNull();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004392 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004393 ;
4394 break;}
4395case 255:
4396#line 2436 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4397{
4398 yyval.ValIDVal = ValID::createUndef();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004399 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004400 ;
4401 break;}
4402case 256:
4403#line 2440 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4404{ // A vector zero constant.
4405 yyval.ValIDVal = ValID::createZeroInit();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004406 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004407 ;
4408 break;}
4409case 257:
4410#line 2444 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4411{ // Nonempty unsized packed vector
4412 const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
4413 int NumElements = yyvsp[-1].ConstVector->size();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004414
4415 VectorType* pt = VectorType::get(ETy, NumElements);
4416 PATypeHolder* PTy = new PATypeHolder(
4417 HandleUpRefs(
4418 VectorType::get(
4419 ETy,
4420 NumElements)
4421 )
4422 );
4423
4424 // Verify all elements are correct type!
Gabor Greif89f01162008-04-06 23:07:54 +00004425 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
4426 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004427 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
4428 ETy->getDescription() +"' as required!\nIt is of type '" +
Gabor Greif89f01162008-04-06 23:07:54 +00004429 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004430 }
4431
Gabor Greif89f01162008-04-06 23:07:54 +00004432 yyval.ValIDVal = ValID::create(ConstantVector::get(pt, *yyvsp[-1].ConstVector));
4433 delete PTy; delete yyvsp[-1].ConstVector;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004434 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004435 ;
4436 break;}
4437case 258:
4438#line 2469 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4439{
4440 yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004441 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004442 ;
4443 break;}
4444case 259:
4445#line 2473 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4446{
4447 yyval.ValIDVal = ValID::createInlineAsm(*yyvsp[-2].StrVal, *yyvsp[0].StrVal, yyvsp[-3].BoolVal);
4448 delete yyvsp[-2].StrVal;
4449 delete yyvsp[0].StrVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004450 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004451 ;
4452 break;}
4453case 260:
4454#line 2483 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4455{ // Is it an integer reference...?
4456 yyval.ValIDVal = ValID::createLocalID(yyvsp[0].UIntVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004457 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004458 ;
4459 break;}
4460case 261:
4461#line 2487 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4462{
4463 yyval.ValIDVal = ValID::createGlobalID(yyvsp[0].UIntVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004464 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004465 ;
4466 break;}
4467case 262:
4468#line 2491 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4469{ // Is it a named reference...?
4470 yyval.ValIDVal = ValID::createLocalName(*yyvsp[0].StrVal);
4471 delete yyvsp[0].StrVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004472 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004473 ;
4474 break;}
4475case 263:
4476#line 2496 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4477{ // Is it a named reference...?
4478 yyval.ValIDVal = ValID::createGlobalName(*yyvsp[0].StrVal);
4479 delete yyvsp[0].StrVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004480 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004481 ;
4482 break;}
4483case 266:
4484#line 2509 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4485{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004486 if (!UpRefs.empty())
Gabor Greif89f01162008-04-06 23:07:54 +00004487 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4488 yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
4489 delete yyvsp[-1].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004490 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004491 ;
4492 break;}
4493case 267:
4494#line 2518 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4495{
4496 yyval.ValueList = new std::vector<Value *>();
4497 yyval.ValueList->push_back(yyvsp[0].ValueVal);
Devang Patelbf507402008-02-20 22:40:23 +00004498 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004499 ;
4500 break;}
4501case 268:
4502#line 2523 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4503{
4504 (yyval.ValueList=yyvsp[-2].ValueList)->push_back(yyvsp[0].ValueVal);
Devang Patelbf507402008-02-20 22:40:23 +00004505 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004506 ;
4507 break;}
4508case 269:
4509#line 2528 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4510{
4511 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004512 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004513 ;
4514 break;}
4515case 270:
4516#line 2532 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4517{ // Do not allow functions with 0 basic blocks
4518 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004519 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004520 ;
4521 break;}
4522case 271:
4523#line 2541 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4524{
4525 setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004526 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004527 InsertValue(yyvsp[0].TermInstVal);
4528 yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
4529 yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004530 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004531 ;
4532 break;}
4533case 272:
4534#line 2550 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4535{
4536 if (CastInst *CI1 = dyn_cast<CastInst>(yyvsp[0].InstVal))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004537 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
4538 if (CI2->getParent() == 0)
Gabor Greif89f01162008-04-06 23:07:54 +00004539 yyvsp[-1].BasicBlockVal->getInstList().push_back(CI2);
4540 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
4541 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004542 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004543 ;
4544 break;}
4545case 273:
4546#line 2559 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4547{ // Empty space between instruction lists
4548 yyval.BasicBlockVal = defineBBVal(ValID::createLocalID(CurFun.NextValNum), 0);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004549 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004550 ;
4551 break;}
4552case 274:
4553#line 2563 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4554{ // Only the unwind to block
4555 yyval.BasicBlockVal = defineBBVal(ValID::createLocalID(CurFun.NextValNum), getBBVal(yyvsp[0].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004556 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004557 ;
4558 break;}
4559case 275:
4560#line 2567 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4561{ // Labelled (named) basic block
4562 yyval.BasicBlockVal = defineBBVal(ValID::createLocalName(*yyvsp[0].StrVal), 0);
4563 delete yyvsp[0].StrVal;
Devang Patel890cc572008-03-03 18:58:47 +00004564 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004565 ;
4566 break;}
4567case 276:
4568#line 2572 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4569{
4570 yyval.BasicBlockVal = defineBBVal(ValID::createLocalName(*yyvsp[-3].StrVal), getBBVal(yyvsp[0].ValIDVal));
4571 delete yyvsp[-3].StrVal;
Devang Patel890cc572008-03-03 18:58:47 +00004572 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004573 ;
4574 break;}
4575case 277:
4576#line 2579 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4577{ // Return with a result...
4578 ValueList &VL = *yyvsp[0].ValueList;
Devang Patelb4851dc2008-02-26 23:19:08 +00004579 assert(!VL.empty() && "Invalid ret operands!");
Gabor Greif89f01162008-04-06 23:07:54 +00004580 yyval.TermInstVal = ReturnInst::Create(&VL[0], VL.size());
4581 delete yyvsp[0].ValueList;
Chris Lattner59363a32008-02-19 04:36:25 +00004582 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004583 ;
4584 break;}
4585case 278:
4586#line 2586 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4587{ // Return with no result...
4588 yyval.TermInstVal = ReturnInst::Create();
4589 CHECK_FOR_ERROR
4590 ;
4591 break;}
4592case 279:
4593#line 2590 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4594{ // Unconditional Branch...
4595 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
4596 CHECK_FOR_ERROR
4597 yyval.TermInstVal = BranchInst::Create(tmpBB);
4598 ;
4599 break;}
4600case 280:
4601#line 2595 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4602{
4603 assert(cast<IntegerType>(yyvsp[-7].PrimType)->getBitWidth() == 1 && "Not Bool?");
4604 BasicBlock* tmpBBA = getBBVal(yyvsp[-3].ValIDVal);
4605 CHECK_FOR_ERROR
4606 BasicBlock* tmpBBB = getBBVal(yyvsp[0].ValIDVal);
4607 CHECK_FOR_ERROR
4608 Value* tmpVal = getVal(Type::Int1Ty, yyvsp[-6].ValIDVal);
4609 CHECK_FOR_ERROR
4610 yyval.TermInstVal = BranchInst::Create(tmpBBA, tmpBBB, tmpVal);
4611 ;
4612 break;}
4613case 281:
4614#line 2605 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4615{
4616 Value* tmpVal = getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal);
4617 CHECK_FOR_ERROR
4618 BasicBlock* tmpBB = getBBVal(yyvsp[-3].ValIDVal);
4619 CHECK_FOR_ERROR
4620 SwitchInst *S = SwitchInst::Create(tmpVal, tmpBB, yyvsp[-1].JumpTable->size());
4621 yyval.TermInstVal = S;
Chris Lattner59363a32008-02-19 04:36:25 +00004622
Gabor Greif89f01162008-04-06 23:07:54 +00004623 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
4624 E = yyvsp[-1].JumpTable->end();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004625 for (; I != E; ++I) {
4626 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
4627 S->addCase(CI, I->second);
4628 else
4629 GEN_ERROR("Switch case is constant, but not a simple integer");
4630 }
Gabor Greif89f01162008-04-06 23:07:54 +00004631 delete yyvsp[-1].JumpTable;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004632 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004633 ;
4634 break;}
4635case 282:
4636#line 2624 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4637{
4638 Value* tmpVal = getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004639 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004640 BasicBlock* tmpBB = getBBVal(yyvsp[-2].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004641 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004642 SwitchInst *S = SwitchInst::Create(tmpVal, tmpBB, 0);
4643 yyval.TermInstVal = S;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004644 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004645 ;
4646 break;}
4647case 283:
4648#line 2634 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4649{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004650
4651 // Handle the short syntax
4652 const PointerType *PFTy = 0;
4653 const FunctionType *Ty = 0;
Gabor Greif89f01162008-04-06 23:07:54 +00004654 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-11].TypeVal->get())) ||
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004655 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4656 // Pull out the types of all of the arguments...
4657 std::vector<const Type*> ParamTypes;
Gabor Greif89f01162008-04-06 23:07:54 +00004658 ParamList::iterator I = yyvsp[-8].ParamList->begin(), E = yyvsp[-8].ParamList->end();
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004659 for (; I != E; ++I) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004660 const Type *Ty = I->Val->getType();
4661 if (Ty == Type::VoidTy)
4662 GEN_ERROR("Short call syntax cannot be used with varargs");
4663 ParamTypes.push_back(Ty);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004664 }
Gabor Greif89f01162008-04-06 23:07:54 +00004665 Ty = FunctionType::get(yyvsp[-11].TypeVal->get(), ParamTypes, false);
Christopher Lambfb623c62007-12-17 01:17:35 +00004666 PFTy = PointerType::getUnqual(Ty);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004667 }
4668
Gabor Greif89f01162008-04-06 23:07:54 +00004669 delete yyvsp[-11].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004670
Gabor Greif89f01162008-04-06 23:07:54 +00004671 Value *V = getVal(PFTy, yyvsp[-10].ValIDVal); // Get the function we're calling...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004672 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004673 BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004674 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004675 BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004676 CHECK_FOR_ERROR
4677
Chris Lattner1c8733e2008-03-12 17:45:29 +00004678 SmallVector<ParamAttrsWithIndex, 8> Attrs;
Gabor Greif89f01162008-04-06 23:07:54 +00004679 if (yyvsp[-6].ParamAttrs != ParamAttr::None)
4680 Attrs.push_back(ParamAttrsWithIndex::get(0, yyvsp[-6].ParamAttrs));
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004681
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004682 // Check the arguments
4683 ValueList Args;
Gabor Greif89f01162008-04-06 23:07:54 +00004684 if (yyvsp[-8].ParamList->empty()) { // Has no arguments?
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004685 // Make sure no arguments is a good thing!
4686 if (Ty->getNumParams() != 0)
4687 GEN_ERROR("No arguments passed to a function that "
4688 "expects arguments");
4689 } else { // Has arguments?
4690 // Loop through FunctionType's arguments and ensure they are specified
4691 // correctly!
4692 FunctionType::param_iterator I = Ty->param_begin();
4693 FunctionType::param_iterator E = Ty->param_end();
Gabor Greif89f01162008-04-06 23:07:54 +00004694 ParamList::iterator ArgI = yyvsp[-8].ParamList->begin(), ArgE = yyvsp[-8].ParamList->end();
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004695 unsigned index = 1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004696
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004697 for (; ArgI != ArgE && I != E; ++ArgI, ++I, ++index) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004698 if (ArgI->Val->getType() != *I)
4699 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
4700 (*I)->getDescription() + "'");
4701 Args.push_back(ArgI->Val);
Chris Lattner1c8733e2008-03-12 17:45:29 +00004702 if (ArgI->Attrs != ParamAttr::None)
4703 Attrs.push_back(ParamAttrsWithIndex::get(index, ArgI->Attrs));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004704 }
4705
4706 if (Ty->isVarArg()) {
4707 if (I == E)
Chris Lattner59363a32008-02-19 04:36:25 +00004708 for (; ArgI != ArgE; ++ArgI, ++index) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004709 Args.push_back(ArgI->Val); // push the remaining varargs
Chris Lattner1c8733e2008-03-12 17:45:29 +00004710 if (ArgI->Attrs != ParamAttr::None)
4711 Attrs.push_back(ParamAttrsWithIndex::get(index, ArgI->Attrs));
Chris Lattner59363a32008-02-19 04:36:25 +00004712 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004713 } else if (I != E || ArgI != ArgE)
4714 GEN_ERROR("Invalid number of parameters detected");
4715 }
4716
Chris Lattner1c8733e2008-03-12 17:45:29 +00004717 PAListPtr PAL;
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004718 if (!Attrs.empty())
Chris Lattner1c8733e2008-03-12 17:45:29 +00004719 PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004720
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004721 // Create the InvokeInst
Gabor Greif89f01162008-04-06 23:07:54 +00004722 InvokeInst *II = InvokeInst::Create(V, Normal, Except, Args.begin(),Args.end());
4723 II->setCallingConv(yyvsp[-12].UIntVal);
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004724 II->setParamAttrs(PAL);
Gabor Greif89f01162008-04-06 23:07:54 +00004725 yyval.TermInstVal = II;
4726 delete yyvsp[-8].ParamList;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004727 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004728 ;
4729 break;}
4730case 284:
4731#line 2714 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4732{
4733 yyval.TermInstVal = new UnwindInst();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004734 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004735 ;
4736 break;}
4737case 285:
4738#line 2718 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4739{
4740 yyval.TermInstVal = new UnreachableInst();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004741 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004742 ;
4743 break;}
4744case 286:
4745#line 2725 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4746{
4747 yyval.JumpTable = yyvsp[-5].JumpTable;
4748 Constant *V = cast<Constant>(getExistingVal(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004749 CHECK_FOR_ERROR
4750 if (V == 0)
4751 GEN_ERROR("May only switch on a constant pool value");
4752
Gabor Greif89f01162008-04-06 23:07:54 +00004753 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004754 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004755 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
4756 ;
4757 break;}
4758case 287:
4759#line 2736 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4760{
4761 yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
4762 Constant *V = cast<Constant>(getExistingVal(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004763 CHECK_FOR_ERROR
4764
4765 if (V == 0)
4766 GEN_ERROR("May only switch on a constant pool value");
4767
Gabor Greif89f01162008-04-06 23:07:54 +00004768 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004769 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004770 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
4771 ;
4772 break;}
4773case 288:
4774#line 2749 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4775{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004776 // Is this definition named?? if so, assign the name...
Gabor Greif89f01162008-04-06 23:07:54 +00004777 setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004778 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004779 InsertValue(yyvsp[0].InstVal);
4780 yyval.InstVal = yyvsp[0].InstVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004781 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004782 ;
4783 break;}
4784case 289:
4785#line 2759 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4786{ // Used for PHI nodes
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004787 if (!UpRefs.empty())
Gabor Greif89f01162008-04-06 23:07:54 +00004788 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-5].TypeVal)->getDescription());
4789 yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
4790 Value* tmpVal = getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004791 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004792 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004793 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004794 yyval.PHIList->push_back(std::make_pair(tmpVal, tmpBB));
4795 delete yyvsp[-5].TypeVal;
4796 ;
4797 break;}
4798case 290:
4799#line 2770 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4800{
4801 yyval.PHIList = yyvsp[-6].PHIList;
4802 Value* tmpVal = getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004803 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004804 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004805 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004806 yyvsp[-6].PHIList->push_back(std::make_pair(tmpVal, tmpBB));
4807 ;
4808 break;}
4809case 291:
4810#line 2780 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4811{
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004812 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004813 if (!UpRefs.empty())
Gabor Greif89f01162008-04-06 23:07:54 +00004814 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004815 // Used for call and invoke instructions
Gabor Greif89f01162008-04-06 23:07:54 +00004816 yyval.ParamList = new ParamList();
4817 ParamListEntry E; E.Attrs = yyvsp[-2].ParamAttrs | yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-3].TypeVal->get(), yyvsp[-1].ValIDVal);
4818 yyval.ParamList->push_back(E);
4819 delete yyvsp[-3].TypeVal;
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004820 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004821 ;
4822 break;}
4823case 292:
4824#line 2791 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4825{
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004826 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Dale Johannesencfb19e62007-11-05 21:20:28 +00004827 // Labels are only valid in ASMs
Gabor Greif89f01162008-04-06 23:07:54 +00004828 yyval.ParamList = new ParamList();
4829 ParamListEntry E; E.Attrs = yyvsp[-2].ParamAttrs | yyvsp[0].ParamAttrs; E.Val = getBBVal(yyvsp[-1].ValIDVal);
4830 yyval.ParamList->push_back(E);
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004831 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004832 ;
4833 break;}
4834case 293:
4835#line 2799 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4836{
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004837 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004838 if (!UpRefs.empty())
Gabor Greif89f01162008-04-06 23:07:54 +00004839 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4840 yyval.ParamList = yyvsp[-5].ParamList;
4841 ParamListEntry E; E.Attrs = yyvsp[-2].ParamAttrs | yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-3].TypeVal->get(), yyvsp[-1].ValIDVal);
4842 yyval.ParamList->push_back(E);
4843 delete yyvsp[-3].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004844 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004845 ;
4846 break;}
4847case 294:
4848#line 2809 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4849{
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004850 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Gabor Greif89f01162008-04-06 23:07:54 +00004851 yyval.ParamList = yyvsp[-5].ParamList;
4852 ParamListEntry E; E.Attrs = yyvsp[-2].ParamAttrs | yyvsp[0].ParamAttrs; E.Val = getBBVal(yyvsp[-1].ValIDVal);
4853 yyval.ParamList->push_back(E);
Dale Johannesencfb19e62007-11-05 21:20:28 +00004854 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004855 ;
4856 break;}
4857case 295:
4858#line 2816 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4859{ yyval.ParamList = new ParamList(); ;
4860 break;}
4861case 296:
4862#line 2819 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4863{ yyval.ValueList = new std::vector<Value*>(); ;
4864 break;}
4865case 297:
4866#line 2820 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4867{
4868 yyval.ValueList = yyvsp[-2].ValueList;
4869 yyval.ValueList->push_back(yyvsp[0].ValueVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004870 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004871 ;
4872 break;}
4873case 298:
4874#line 2827 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4875{
4876 yyval.BoolVal = true;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004877 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004878 ;
4879 break;}
4880case 299:
4881#line 2831 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4882{
4883 yyval.BoolVal = false;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004884 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004885 ;
4886 break;}
4887case 300:
4888#line 2836 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4889{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004890 if (!UpRefs.empty())
Gabor Greif89f01162008-04-06 23:07:54 +00004891 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4892 if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
4893 !isa<VectorType>((*yyvsp[-3].TypeVal).get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004894 GEN_ERROR(
4895 "Arithmetic operator requires integer, FP, or packed operands");
Gabor Greif89f01162008-04-06 23:07:54 +00004896 Value* val1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004897 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004898 Value* val2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004899 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004900 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, val1, val2);
4901 if (yyval.InstVal == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004902 GEN_ERROR("binary operator returned null");
Gabor Greif89f01162008-04-06 23:07:54 +00004903 delete yyvsp[-3].TypeVal;
4904 ;
4905 break;}
4906case 301:
4907#line 2852 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4908{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004909 if (!UpRefs.empty())
Gabor Greif89f01162008-04-06 23:07:54 +00004910 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4911 if (!(*yyvsp[-3].TypeVal)->isInteger()) {
4912 if (Instruction::isShift(yyvsp[-4].BinaryOpVal) || !isa<VectorType>(yyvsp[-3].TypeVal->get()) ||
4913 !cast<VectorType>(yyvsp[-3].TypeVal->get())->getElementType()->isInteger())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004914 GEN_ERROR("Logical operator requires integral operands");
4915 }
Gabor Greif89f01162008-04-06 23:07:54 +00004916 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004917 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004918 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004919 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004920 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, tmpVal1, tmpVal2);
4921 if (yyval.InstVal == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004922 GEN_ERROR("binary operator returned null");
Gabor Greif89f01162008-04-06 23:07:54 +00004923 delete yyvsp[-3].TypeVal;
4924 ;
4925 break;}
4926case 302:
4927#line 2869 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4928{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004929 if (!UpRefs.empty())
Gabor Greif89f01162008-04-06 23:07:54 +00004930 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4931 if (isa<VectorType>((*yyvsp[-3].TypeVal).get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004932 GEN_ERROR("Vector types not supported by icmp instruction");
Gabor Greif89f01162008-04-06 23:07:54 +00004933 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004934 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004935 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004936 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004937 yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].IPredicate, tmpVal1, tmpVal2);
4938 if (yyval.InstVal == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004939 GEN_ERROR("icmp operator returned null");
Gabor Greif89f01162008-04-06 23:07:54 +00004940 delete yyvsp[-3].TypeVal;
4941 ;
4942 break;}
4943case 303:
4944#line 2883 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4945{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004946 if (!UpRefs.empty())
Gabor Greif89f01162008-04-06 23:07:54 +00004947 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4948 if (isa<VectorType>((*yyvsp[-3].TypeVal).get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004949 GEN_ERROR("Vector types not supported by fcmp instruction");
Gabor Greif89f01162008-04-06 23:07:54 +00004950 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004951 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004952 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004953 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004954 yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].FPredicate, tmpVal1, tmpVal2);
4955 if (yyval.InstVal == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004956 GEN_ERROR("fcmp operator returned null");
Gabor Greif89f01162008-04-06 23:07:54 +00004957 delete yyvsp[-3].TypeVal;
4958 ;
4959 break;}
4960case 304:
4961#line 2897 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4962{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004963 if (!UpRefs.empty())
Gabor Greif89f01162008-04-06 23:07:54 +00004964 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
4965 Value* Val = yyvsp[-2].ValueVal;
4966 const Type* DestTy = yyvsp[0].TypeVal->get();
4967 if (!CastInst::castIsValid(yyvsp[-3].CastOpVal, Val, DestTy))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004968 GEN_ERROR("invalid cast opcode for cast from '" +
4969 Val->getType()->getDescription() + "' to '" +
4970 DestTy->getDescription() + "'");
Gabor Greif89f01162008-04-06 23:07:54 +00004971 yyval.InstVal = CastInst::create(yyvsp[-3].CastOpVal, Val, DestTy);
4972 delete yyvsp[0].TypeVal;
4973 ;
4974 break;}
4975case 305:
4976#line 2909 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4977{
4978 if (yyvsp[-4].ValueVal->getType() != Type::Int1Ty)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004979 GEN_ERROR("select condition must be boolean");
Gabor Greif89f01162008-04-06 23:07:54 +00004980 if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004981 GEN_ERROR("select value types should match");
Gabor Greif89f01162008-04-06 23:07:54 +00004982 yyval.InstVal = SelectInst::Create(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004983 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004984 ;
4985 break;}
4986case 306:
4987#line 2917 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4988{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004989 if (!UpRefs.empty())
Gabor Greif89f01162008-04-06 23:07:54 +00004990 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
4991 yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
4992 delete yyvsp[0].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004993 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00004994 ;
4995 break;}
4996case 307:
4997#line 2924 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
4998{
4999 if (!ExtractElementInst::isValidOperands(yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005000 GEN_ERROR("Invalid extractelement operands");
Gabor Greif89f01162008-04-06 23:07:54 +00005001 yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005002 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00005003 ;
5004 break;}
5005case 308:
5006#line 2930 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
5007{
5008 if (!InsertElementInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005009 GEN_ERROR("Invalid insertelement operands");
Gabor Greif89f01162008-04-06 23:07:54 +00005010 yyval.InstVal = InsertElementInst::Create(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005011 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00005012 ;
5013 break;}
5014case 309:
5015#line 2936 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
5016{
5017 if (!ShuffleVectorInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005018 GEN_ERROR("Invalid shufflevector operands");
Gabor Greif89f01162008-04-06 23:07:54 +00005019 yyval.InstVal = new ShuffleVectorInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005020 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00005021 ;
5022 break;}
5023case 310:
5024#line 2942 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
5025{
5026 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005027 if (!Ty->isFirstClassType())
5028 GEN_ERROR("PHI node operands must be of first class type");
Gabor Greif89f01162008-04-06 23:07:54 +00005029 yyval.InstVal = PHINode::Create(Ty);
5030 ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
5031 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
5032 if (yyvsp[0].PHIList->front().first->getType() != Ty)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005033 GEN_ERROR("All elements of a PHI node must be of the same type");
Gabor Greif89f01162008-04-06 23:07:54 +00005034 cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
5035 yyvsp[0].PHIList->pop_front();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005036 }
Gabor Greif89f01162008-04-06 23:07:54 +00005037 delete yyvsp[0].PHIList; // Free the list...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005038 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00005039 ;
5040 break;}
5041case 311:
5042#line 2958 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
5043{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005044
5045 // Handle the short syntax
5046 const PointerType *PFTy = 0;
5047 const FunctionType *Ty = 0;
Gabor Greif89f01162008-04-06 23:07:54 +00005048 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-5].TypeVal->get())) ||
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005049 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5050 // Pull out the types of all of the arguments...
5051 std::vector<const Type*> ParamTypes;
Gabor Greif89f01162008-04-06 23:07:54 +00005052 ParamList::iterator I = yyvsp[-2].ParamList->begin(), E = yyvsp[-2].ParamList->end();
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005053 for (; I != E; ++I) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005054 const Type *Ty = I->Val->getType();
5055 if (Ty == Type::VoidTy)
5056 GEN_ERROR("Short call syntax cannot be used with varargs");
5057 ParamTypes.push_back(Ty);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005058 }
Gabor Greif89f01162008-04-06 23:07:54 +00005059 Ty = FunctionType::get(yyvsp[-5].TypeVal->get(), ParamTypes, false);
Christopher Lambfb623c62007-12-17 01:17:35 +00005060 PFTy = PointerType::getUnqual(Ty);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005061 }
5062
Gabor Greif89f01162008-04-06 23:07:54 +00005063 Value *V = getVal(PFTy, yyvsp[-4].ValIDVal); // Get the function we're calling...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005064 CHECK_FOR_ERROR
5065
5066 // Check for call to invalid intrinsic to avoid crashing later.
5067 if (Function *theF = dyn_cast<Function>(V)) {
5068 if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) &&
5069 (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) &&
5070 !theF->getIntrinsicID(true))
5071 GEN_ERROR("Call to invalid LLVM intrinsic function '" +
5072 theF->getName() + "'");
5073 }
5074
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005075 // Set up the ParamAttrs for the function
Chris Lattner1c8733e2008-03-12 17:45:29 +00005076 SmallVector<ParamAttrsWithIndex, 8> Attrs;
Gabor Greif89f01162008-04-06 23:07:54 +00005077 if (yyvsp[0].ParamAttrs != ParamAttr::None)
5078 Attrs.push_back(ParamAttrsWithIndex::get(0, yyvsp[0].ParamAttrs));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005079 // Check the arguments
5080 ValueList Args;
Gabor Greif89f01162008-04-06 23:07:54 +00005081 if (yyvsp[-2].ParamList->empty()) { // Has no arguments?
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005082 // Make sure no arguments is a good thing!
5083 if (Ty->getNumParams() != 0)
5084 GEN_ERROR("No arguments passed to a function that "
5085 "expects arguments");
5086 } else { // Has arguments?
5087 // Loop through FunctionType's arguments and ensure they are specified
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005088 // correctly. Also, gather any parameter attributes.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005089 FunctionType::param_iterator I = Ty->param_begin();
5090 FunctionType::param_iterator E = Ty->param_end();
Gabor Greif89f01162008-04-06 23:07:54 +00005091 ParamList::iterator ArgI = yyvsp[-2].ParamList->begin(), ArgE = yyvsp[-2].ParamList->end();
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005092 unsigned index = 1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005093
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005094 for (; ArgI != ArgE && I != E; ++ArgI, ++I, ++index) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005095 if (ArgI->Val->getType() != *I)
5096 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
5097 (*I)->getDescription() + "'");
5098 Args.push_back(ArgI->Val);
Chris Lattner1c8733e2008-03-12 17:45:29 +00005099 if (ArgI->Attrs != ParamAttr::None)
5100 Attrs.push_back(ParamAttrsWithIndex::get(index, ArgI->Attrs));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005101 }
5102 if (Ty->isVarArg()) {
5103 if (I == E)
Chris Lattner59363a32008-02-19 04:36:25 +00005104 for (; ArgI != ArgE; ++ArgI, ++index) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005105 Args.push_back(ArgI->Val); // push the remaining varargs
Chris Lattner1c8733e2008-03-12 17:45:29 +00005106 if (ArgI->Attrs != ParamAttr::None)
5107 Attrs.push_back(ParamAttrsWithIndex::get(index, ArgI->Attrs));
Chris Lattner59363a32008-02-19 04:36:25 +00005108 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005109 } else if (I != E || ArgI != ArgE)
5110 GEN_ERROR("Invalid number of parameters detected");
5111 }
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005112
5113 // Finish off the ParamAttrs and check them
Chris Lattner1c8733e2008-03-12 17:45:29 +00005114 PAListPtr PAL;
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005115 if (!Attrs.empty())
Chris Lattner1c8733e2008-03-12 17:45:29 +00005116 PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005117
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005118 // Create the call node
Gabor Greif89f01162008-04-06 23:07:54 +00005119 CallInst *CI = CallInst::Create(V, Args.begin(), Args.end());
5120 CI->setTailCall(yyvsp[-7].BoolVal);
5121 CI->setCallingConv(yyvsp[-6].UIntVal);
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005122 CI->setParamAttrs(PAL);
Gabor Greif89f01162008-04-06 23:07:54 +00005123 yyval.InstVal = CI;
5124 delete yyvsp[-2].ParamList;
5125 delete yyvsp[-5].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005126 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00005127 ;
5128 break;}
5129case 312:
5130#line 3043 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
5131{
5132 yyval.InstVal = yyvsp[0].InstVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005133 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00005134 ;
5135 break;}
5136case 313:
5137#line 3048 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
5138{
5139 yyval.BoolVal = true;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005140 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00005141 ;
5142 break;}
5143case 314:
5144#line 3052 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
5145{
5146 yyval.BoolVal = false;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005147 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00005148 ;
5149 break;}
5150case 315:
5151#line 3059 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
5152{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005153 if (!UpRefs.empty())
Gabor Greif89f01162008-04-06 23:07:54 +00005154 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
5155 yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
5156 delete yyvsp[-1].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005157 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00005158 ;
5159 break;}
5160case 316:
5161#line 3066 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
5162{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005163 if (!UpRefs.empty())
Gabor Greif89f01162008-04-06 23:07:54 +00005164 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
5165 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005166 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00005167 yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
5168 delete yyvsp[-4].TypeVal;
5169 ;
5170 break;}
5171case 317:
5172#line 3074 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
5173{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005174 if (!UpRefs.empty())
Gabor Greif89f01162008-04-06 23:07:54 +00005175 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
5176 yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
5177 delete yyvsp[-1].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005178 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00005179 ;
5180 break;}
5181case 318:
5182#line 3081 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
5183{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005184 if (!UpRefs.empty())
Gabor Greif89f01162008-04-06 23:07:54 +00005185 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
5186 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005187 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00005188 yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
5189 delete yyvsp[-4].TypeVal;
5190 ;
5191 break;}
5192case 319:
5193#line 3089 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
5194{
5195 if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005196 GEN_ERROR("Trying to free nonpointer type " +
Gabor Greif89f01162008-04-06 23:07:54 +00005197 yyvsp[0].ValueVal->getType()->getDescription() + "");
5198 yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005199 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00005200 ;
5201 break;}
5202case 320:
5203#line 3097 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
5204{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005205 if (!UpRefs.empty())
Gabor Greif89f01162008-04-06 23:07:54 +00005206 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
5207 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005208 GEN_ERROR("Can't load from nonpointer type: " +
Gabor Greif89f01162008-04-06 23:07:54 +00005209 (*yyvsp[-2].TypeVal)->getDescription());
5210 if (!cast<PointerType>(yyvsp[-2].TypeVal->get())->getElementType()->isFirstClassType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005211 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Gabor Greif89f01162008-04-06 23:07:54 +00005212 (*yyvsp[-2].TypeVal)->getDescription());
5213 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005214 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00005215 yyval.InstVal = new LoadInst(tmpVal, "", yyvsp[-4].BoolVal, yyvsp[0].UIntVal);
5216 delete yyvsp[-2].TypeVal;
5217 ;
5218 break;}
5219case 321:
5220#line 3111 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
5221{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005222 if (!UpRefs.empty())
Gabor Greif89f01162008-04-06 23:07:54 +00005223 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
5224 const PointerType *PT = dyn_cast<PointerType>(yyvsp[-2].TypeVal->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005225 if (!PT)
5226 GEN_ERROR("Can't store to a nonpointer type: " +
Gabor Greif89f01162008-04-06 23:07:54 +00005227 (*yyvsp[-2].TypeVal)->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005228 const Type *ElTy = PT->getElementType();
Gabor Greif89f01162008-04-06 23:07:54 +00005229 if (ElTy != yyvsp[-4].ValueVal->getType())
5230 GEN_ERROR("Can't store '" + yyvsp[-4].ValueVal->getType()->getDescription() +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005231 "' into space of type '" + ElTy->getDescription() + "'");
5232
Gabor Greif89f01162008-04-06 23:07:54 +00005233 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005234 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00005235 yyval.InstVal = new StoreInst(yyvsp[-4].ValueVal, tmpVal, yyvsp[-6].BoolVal, yyvsp[0].UIntVal);
5236 delete yyvsp[-2].TypeVal;
5237 ;
5238 break;}
5239case 322:
5240#line 3128 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
5241{
5242 Value *TmpVal = getVal(yyvsp[-3].TypeVal->get(), yyvsp[-2].ValIDVal);
5243 if (!GetResultInst::isValidOperands(TmpVal, yyvsp[0].UInt64Val))
Devang Patel3b8849c2008-02-19 22:27:01 +00005244 GEN_ERROR("Invalid getresult operands");
Gabor Greif89f01162008-04-06 23:07:54 +00005245 yyval.InstVal = new GetResultInst(TmpVal, yyvsp[0].UInt64Val);
5246 delete yyvsp[-3].TypeVal;
Devang Patel3b8849c2008-02-19 22:27:01 +00005247 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00005248 ;
5249 break;}
5250case 323:
5251#line 3136 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
5252{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005253 if (!UpRefs.empty())
Gabor Greif89f01162008-04-06 23:07:54 +00005254 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
5255 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005256 GEN_ERROR("getelementptr insn requires pointer operand");
5257
Gabor Greif89f01162008-04-06 23:07:54 +00005258 if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end(), true))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005259 GEN_ERROR("Invalid getelementptr indices for type '" +
Gabor Greif89f01162008-04-06 23:07:54 +00005260 (*yyvsp[-2].TypeVal)->getDescription()+ "'");
5261 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005262 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00005263 yyval.InstVal = GetElementPtrInst::Create(tmpVal, yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end());
5264 delete yyvsp[-2].TypeVal;
5265 delete yyvsp[0].ValueList;
5266 ;
5267 break;}
5268}
5269 /* the action file gets copied in in place of this dollarsign */
5270#line 543 "/usr/share/bison.simple"
5271
5272 yyvsp -= yylen;
5273 yyssp -= yylen;
5274#ifdef YYLSP_NEEDED
5275 yylsp -= yylen;
5276#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005277
Gabor Greif89f01162008-04-06 23:07:54 +00005278#if YYDEBUG != 0
5279 if (yydebug)
5280 {
5281 short *ssp1 = yyss - 1;
5282 fprintf (stderr, "state stack now");
5283 while (ssp1 != yyssp)
5284 fprintf (stderr, " %d", *++ssp1);
5285 fprintf (stderr, "\n");
Dale Johannesen3afee192007-09-07 21:07:57 +00005286 }
Gabor Greif89f01162008-04-06 23:07:54 +00005287#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005288
5289 *++yyvsp = yyval;
5290
Gabor Greif89f01162008-04-06 23:07:54 +00005291#ifdef YYLSP_NEEDED
5292 yylsp++;
5293 if (yylen == 0)
5294 {
5295 yylsp->first_line = yylloc.first_line;
5296 yylsp->first_column = yylloc.first_column;
5297 yylsp->last_line = (yylsp-1)->last_line;
5298 yylsp->last_column = (yylsp-1)->last_column;
5299 yylsp->text = 0;
5300 }
5301 else
5302 {
5303 yylsp->last_line = (yylsp+yylen-1)->last_line;
5304 yylsp->last_column = (yylsp+yylen-1)->last_column;
5305 }
5306#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005307
Gabor Greif89f01162008-04-06 23:07:54 +00005308 /* Now "shift" the result of the reduction.
5309 Determine what state that goes to,
5310 based on the state we popped back to
5311 and the rule number reduced by. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005312
5313 yyn = yyr1[yyn];
5314
Gabor Greif89f01162008-04-06 23:07:54 +00005315 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
5316 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005317 yystate = yytable[yystate];
5318 else
Gabor Greif89f01162008-04-06 23:07:54 +00005319 yystate = yydefgoto[yyn - YYNTBASE];
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005320
5321 goto yynewstate;
5322
Gabor Greif89f01162008-04-06 23:07:54 +00005323yyerrlab: /* here on detecting error */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005324
Gabor Greif89f01162008-04-06 23:07:54 +00005325 if (! yyerrstatus)
5326 /* If not already recovering from an error, report this error. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005327 {
5328 ++yynerrs;
Dale Johannesen3afee192007-09-07 21:07:57 +00005329
Gabor Greif89f01162008-04-06 23:07:54 +00005330#ifdef YYERROR_VERBOSE
5331 yyn = yypact[yystate];
5332
5333 if (yyn > YYFLAG && yyn < YYLAST)
5334 {
5335 int size = 0;
5336 char *msg;
5337 int x, count;
5338
5339 count = 0;
5340 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
5341 for (x = (yyn < 0 ? -yyn : 0);
5342 x < (sizeof(yytname) / sizeof(char *)); x++)
5343 if (yycheck[x + yyn] == x)
5344 size += strlen(yytname[x]) + 15, count++;
5345 msg = (char *) malloc(size + 15);
5346 if (msg != 0)
5347 {
5348 strcpy(msg, "parse error");
5349
5350 if (count < 5)
5351 {
5352 count = 0;
5353 for (x = (yyn < 0 ? -yyn : 0);
5354 x < (sizeof(yytname) / sizeof(char *)); x++)
5355 if (yycheck[x + yyn] == x)
5356 {
5357 strcat(msg, count == 0 ? ", expecting `" : " or `");
5358 strcat(msg, yytname[x]);
5359 strcat(msg, "'");
5360 count++;
5361 }
5362 }
5363 yyerror(msg);
5364 free(msg);
5365 }
5366 else
5367 yyerror ("parse error; also virtual memory exceeded");
5368 }
5369 else
5370#endif /* YYERROR_VERBOSE */
5371 yyerror("parse error");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005372 }
5373
Gabor Greif89f01162008-04-06 23:07:54 +00005374 goto yyerrlab1;
5375yyerrlab1: /* here on error raised explicitly by an action */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005376
5377 if (yyerrstatus == 3)
5378 {
Gabor Greif89f01162008-04-06 23:07:54 +00005379 /* if just tried and failed to reuse lookahead token after an error, discard it. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005380
Gabor Greif89f01162008-04-06 23:07:54 +00005381 /* return failure if at end of input */
5382 if (yychar == YYEOF)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005383 YYABORT;
5384
Gabor Greif89f01162008-04-06 23:07:54 +00005385#if YYDEBUG != 0
5386 if (yydebug)
5387 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
5388#endif
Dale Johannesen3afee192007-09-07 21:07:57 +00005389
Gabor Greif89f01162008-04-06 23:07:54 +00005390 yychar = YYEMPTY;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005391 }
5392
Gabor Greif89f01162008-04-06 23:07:54 +00005393 /* Else will try to reuse lookahead token
5394 after shifting the error token. */
5395
5396 yyerrstatus = 3; /* Each real token shifted decrements this */
5397
5398 goto yyerrhandle;
5399
5400yyerrdefault: /* current state does not do anything special for the error token. */
5401
5402#if 0
5403 /* This is wrong; only states that explicitly want error tokens
5404 should shift them. */
5405 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
5406 if (yyn) goto yydefault;
5407#endif
5408
5409yyerrpop: /* pop the current state because it cannot handle the error token */
5410
5411 if (yyssp == yyss) YYABORT;
5412 yyvsp--;
5413 yystate = *--yyssp;
5414#ifdef YYLSP_NEEDED
5415 yylsp--;
5416#endif
5417
5418#if YYDEBUG != 0
5419 if (yydebug)
5420 {
5421 short *ssp1 = yyss - 1;
5422 fprintf (stderr, "Error: state stack now");
5423 while (ssp1 != yyssp)
5424 fprintf (stderr, " %d", *++ssp1);
5425 fprintf (stderr, "\n");
5426 }
5427#endif
5428
5429yyerrhandle:
5430
5431 yyn = yypact[yystate];
5432 if (yyn == YYFLAG)
5433 goto yyerrdefault;
5434
5435 yyn += YYTERROR;
5436 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
5437 goto yyerrdefault;
5438
5439 yyn = yytable[yyn];
5440 if (yyn < 0)
5441 {
5442 if (yyn == YYFLAG)
5443 goto yyerrpop;
5444 yyn = -yyn;
5445 goto yyreduce;
5446 }
5447 else if (yyn == 0)
5448 goto yyerrpop;
5449
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005450 if (yyn == YYFINAL)
5451 YYACCEPT;
5452
Gabor Greif89f01162008-04-06 23:07:54 +00005453#if YYDEBUG != 0
5454 if (yydebug)
5455 fprintf(stderr, "Shifting error token, ");
5456#endif
5457
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005458 *++yyvsp = yylval;
Gabor Greif89f01162008-04-06 23:07:54 +00005459#ifdef YYLSP_NEEDED
5460 *++yylsp = yylloc;
5461#endif
Reid Spenceraa8ae282007-07-31 03:50:36 +00005462
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005463 yystate = yyn;
5464 goto yynewstate;
5465
Gabor Greif89f01162008-04-06 23:07:54 +00005466 yyacceptlab:
5467 /* YYACCEPT comes here. */
5468 if (yyfree_stacks)
Chris Lattner59363a32008-02-19 04:36:25 +00005469 {
Gabor Greif89f01162008-04-06 23:07:54 +00005470 free (yyss);
5471 free (yyvs);
5472#ifdef YYLSP_NEEDED
5473 free (yyls);
5474#endif
Scott Michel6d1aba82008-01-30 03:10:00 +00005475 }
Gabor Greif89f01162008-04-06 23:07:54 +00005476 return 0;
5477
5478 yyabortlab:
5479 /* YYABORT comes here. */
5480 if (yyfree_stacks)
5481 {
5482 free (yyss);
5483 free (yyvs);
5484#ifdef YYLSP_NEEDED
5485 free (yyls);
Chris Lattner59363a32008-02-19 04:36:25 +00005486#endif
Gabor Greif89f01162008-04-06 23:07:54 +00005487 }
5488 return 1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005489}
Gabor Greif89f01162008-04-06 23:07:54 +00005490#line 3153 "/Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005491
5492
5493// common code from the two 'RunVMAsmParser' functions
5494static Module* RunParser(Module * M) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005495 CurModule.CurrentModule = M;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005496 // Check to make sure the parser succeeded
5497 if (yyparse()) {
5498 if (ParserResult)
5499 delete ParserResult;
5500 return 0;
5501 }
5502
5503 // Emit an error if there are any unresolved types left.
5504 if (!CurModule.LateResolveTypes.empty()) {
5505 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
5506 if (DID.Type == ValID::LocalName) {
5507 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
5508 } else {
5509 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
5510 }
5511 if (ParserResult)
5512 delete ParserResult;
5513 return 0;
5514 }
5515
5516 // Emit an error if there are any unresolved values left.
5517 if (!CurModule.LateResolveValues.empty()) {
5518 Value *V = CurModule.LateResolveValues.back();
5519 std::map<Value*, std::pair<ValID, int> >::iterator I =
5520 CurModule.PlaceHolderInfo.find(V);
5521
5522 if (I != CurModule.PlaceHolderInfo.end()) {
5523 ValID &DID = I->second.first;
5524 if (DID.Type == ValID::LocalName) {
5525 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
5526 } else {
5527 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
5528 }
5529 if (ParserResult)
5530 delete ParserResult;
5531 return 0;
5532 }
5533 }
5534
5535 // Check to make sure that parsing produced a result
5536 if (!ParserResult)
5537 return 0;
5538
5539 // Reset ParserResult variable while saving its value for the result.
5540 Module *Result = ParserResult;
5541 ParserResult = 0;
5542
5543 return Result;
5544}
5545
5546void llvm::GenerateError(const std::string &message, int LineNo) {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005547 if (LineNo == -1) LineNo = LLLgetLineNo();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005548 // TODO: column number in exception
5549 if (TheParseError)
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005550 TheParseError->setError(LLLgetFilename(), message, LineNo);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005551 TriggerError = 1;
5552}
5553
5554int yyerror(const char *ErrorMsg) {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005555 std::string where = LLLgetFilename() + ":" + utostr(LLLgetLineNo()) + ": ";
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005556 std::string errMsg = where + "error: " + std::string(ErrorMsg);
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005557 if (yychar != YYEMPTY && yychar != 0) {
5558 errMsg += " while reading token: '";
5559 errMsg += std::string(LLLgetTokenStart(),
5560 LLLgetTokenStart()+LLLgetTokenLength()) + "'";
5561 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005562 GenerateError(errMsg);
5563 return 0;
5564}