blob: a6192c13ad61c53b4e797fabb5612d5fdaced201 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001
Scott Michel6d1aba82008-01-30 03:10:00 +00002/* A Bison parser, made from /Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y
3 by GNU Bison version 1.28 */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004
Scott Michel6d1aba82008-01-30 03:10:00 +00005#define YYBISON 1 /* Identify Bison output. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006
7#define yyparse llvmAsmparse
Scott Michel6d1aba82008-01-30 03:10:00 +00008#define yylex llvmAsmlex
Dan Gohmanf17a25c2007-07-18 16:29:46 +00009#define yyerror llvmAsmerror
Scott Michel6d1aba82008-01-30 03:10:00 +000010#define yylval llvmAsmlval
11#define yychar llvmAsmchar
Dan Gohmanf17a25c2007-07-18 16:29:46 +000012#define yydebug llvmAsmdebug
13#define yynerrs llvmAsmnerrs
Scott Michel6d1aba82008-01-30 03:10:00 +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 RET 322
80#define BR 323
81#define SWITCH 324
82#define INVOKE 325
83#define UNWIND 326
84#define UNREACHABLE 327
85#define ADD 328
86#define SUB 329
87#define MUL 330
88#define UDIV 331
89#define SDIV 332
90#define FDIV 333
91#define UREM 334
92#define SREM 335
93#define FREM 336
94#define AND 337
95#define OR 338
96#define XOR 339
97#define SHL 340
98#define LSHR 341
99#define ASHR 342
100#define ICMP 343
101#define FCMP 344
102#define EQ 345
103#define NE 346
104#define SLT 347
105#define SGT 348
106#define SLE 349
107#define SGE 350
108#define ULT 351
109#define UGT 352
110#define ULE 353
111#define UGE 354
112#define OEQ 355
113#define ONE 356
114#define OLT 357
115#define OGT 358
116#define OLE 359
117#define OGE 360
118#define ORD 361
119#define UNO 362
120#define UEQ 363
121#define UNE 364
122#define MALLOC 365
123#define ALLOCA 366
124#define FREE 367
125#define LOAD 368
126#define STORE 369
127#define GETELEMENTPTR 370
128#define TRUNC 371
129#define ZEXT 372
130#define SEXT 373
131#define FPTRUNC 374
132#define FPEXT 375
133#define BITCAST 376
134#define UITOFP 377
135#define SITOFP 378
136#define FPTOUI 379
137#define FPTOSI 380
138#define INTTOPTR 381
139#define PTRTOINT 382
140#define PHI_TOK 383
141#define SELECT 384
142#define VAARG 385
143#define EXTRACTELEMENT 386
144#define INSERTELEMENT 387
145#define SHUFFLEVECTOR 388
146#define SIGNEXT 389
147#define ZEROEXT 390
148#define NORETURN 391
149#define INREG 392
150#define SRET 393
151#define NOUNWIND 394
152#define NOALIAS 395
153#define BYVAL 396
154#define NEST 397
155#define READNONE 398
156#define READONLY 399
157#define GC 400
158#define DEFAULT 401
159#define HIDDEN 402
160#define PROTECTED 403
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000161
Scott Michel6d1aba82008-01-30 03:10:00 +0000162#line 14 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000163
164#include "ParserInternals.h"
165#include "llvm/CallingConv.h"
166#include "llvm/InlineAsm.h"
167#include "llvm/Instructions.h"
168#include "llvm/Module.h"
169#include "llvm/ValueSymbolTable.h"
Chandler Carruth563d4a42007-08-04 01:56:21 +0000170#include "llvm/AutoUpgrade.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000171#include "llvm/Support/GetElementPtrTypeIterator.h"
172#include "llvm/Support/CommandLine.h"
173#include "llvm/ADT/SmallVector.h"
174#include "llvm/ADT/STLExtras.h"
175#include "llvm/Support/MathExtras.h"
176#include "llvm/Support/Streams.h"
177#include <algorithm>
178#include <list>
179#include <map>
180#include <utility>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000181
182// The following is a gross hack. In order to rid the libAsmParser library of
183// exceptions, we have to have a way of getting the yyparse function to go into
184// an error situation. So, whenever we want an error to occur, the GenerateError
185// function (see bottom of file) sets TriggerError. Then, at the end of each
186// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
187// (a goto) to put YACC in error state. Furthermore, several calls to
188// GenerateError are made from inside productions and they must simulate the
189// previous exception behavior by exiting the production immediately. We have
190// replaced these with the GEN_ERROR macro which calls GeneratError and then
191// immediately invokes YYERROR. This would be so much cleaner if it was a
192// recursive descent parser.
193static bool TriggerError = false;
194#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
195#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
196
197int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
198int yylex(); // declaration" of xxx warnings.
199int yyparse();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000200using namespace llvm;
201
202static Module *ParserResult;
203
204// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
205// relating to upreferences in the input stream.
206//
207//#define DEBUG_UPREFS 1
208#ifdef DEBUG_UPREFS
209#define UR_OUT(X) cerr << X
210#else
211#define UR_OUT(X)
212#endif
213
214#define YYERROR_VERBOSE 1
215
216static GlobalVariable *CurGV;
217
218
219// This contains info used when building the body of a function. It is
220// destroyed when the function is completed.
221//
222typedef std::vector<Value *> ValueList; // Numbered defs
223
224static void
225ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0);
226
227static struct PerModuleInfo {
228 Module *CurrentModule;
229 ValueList Values; // Module level numbered definitions
230 ValueList LateResolveValues;
231 std::vector<PATypeHolder> Types;
232 std::map<ValID, PATypeHolder> LateResolveTypes;
233
234 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
235 /// how they were referenced and on which line of the input they came from so
236 /// that we can resolve them later and print error messages as appropriate.
237 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
238
239 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
240 // references to global values. Global values may be referenced before they
241 // are defined, and if so, the temporary object that they represent is held
242 // here. This is used for forward references of GlobalValues.
243 //
244 typedef std::map<std::pair<const PointerType *,
245 ValID>, GlobalValue*> GlobalRefsType;
246 GlobalRefsType GlobalRefs;
247
248 void ModuleDone() {
249 // If we could not resolve some functions at function compilation time
250 // (calls to functions before they are defined), resolve them now... Types
251 // are resolved when the constant pool has been completely parsed.
252 //
253 ResolveDefinitions(LateResolveValues);
254 if (TriggerError)
255 return;
256
257 // Check to make sure that all global value forward references have been
258 // resolved!
259 //
260 if (!GlobalRefs.empty()) {
261 std::string UndefinedReferences = "Unresolved global references exist:\n";
262
263 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
264 I != E; ++I) {
265 UndefinedReferences += " " + I->first.first->getDescription() + " " +
266 I->first.second.getName() + "\n";
267 }
268 GenerateError(UndefinedReferences);
269 return;
270 }
271
Chandler Carruth563d4a42007-08-04 01:56:21 +0000272 // Look for intrinsic functions and CallInst that need to be upgraded
273 for (Module::iterator FI = CurrentModule->begin(),
274 FE = CurrentModule->end(); FI != FE; )
275 UpgradeCallsToIntrinsic(FI++); // must be post-increment, as we remove
276
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000277 Values.clear(); // Clear out function local definitions
278 Types.clear();
279 CurrentModule = 0;
280 }
281
282 // GetForwardRefForGlobal - Check to see if there is a forward reference
283 // for this global. If so, remove it from the GlobalRefs map and return it.
284 // If not, just return null.
285 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
286 // Check to see if there is a forward reference to this global variable...
287 // if there is, eliminate it and patch the reference to use the new def'n.
288 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
289 GlobalValue *Ret = 0;
290 if (I != GlobalRefs.end()) {
291 Ret = I->second;
292 GlobalRefs.erase(I);
293 }
294 return Ret;
295 }
296
297 bool TypeIsUnresolved(PATypeHolder* PATy) {
298 // If it isn't abstract, its resolved
299 const Type* Ty = PATy->get();
300 if (!Ty->isAbstract())
301 return false;
302 // Traverse the type looking for abstract types. If it isn't abstract then
303 // we don't need to traverse that leg of the type.
304 std::vector<const Type*> WorkList, SeenList;
305 WorkList.push_back(Ty);
306 while (!WorkList.empty()) {
307 const Type* Ty = WorkList.back();
308 SeenList.push_back(Ty);
309 WorkList.pop_back();
310 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
311 // Check to see if this is an unresolved type
312 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
313 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
314 for ( ; I != E; ++I) {
315 if (I->second.get() == OpTy)
316 return true;
317 }
318 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
319 const Type* TheTy = SeqTy->getElementType();
320 if (TheTy->isAbstract() && TheTy != Ty) {
321 std::vector<const Type*>::iterator I = SeenList.begin(),
322 E = SeenList.end();
323 for ( ; I != E; ++I)
324 if (*I == TheTy)
325 break;
326 if (I == E)
327 WorkList.push_back(TheTy);
328 }
329 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
330 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
331 const Type* TheTy = StrTy->getElementType(i);
332 if (TheTy->isAbstract() && TheTy != Ty) {
333 std::vector<const Type*>::iterator I = SeenList.begin(),
334 E = SeenList.end();
335 for ( ; I != E; ++I)
336 if (*I == TheTy)
337 break;
338 if (I == E)
339 WorkList.push_back(TheTy);
340 }
341 }
342 }
343 }
344 return false;
345 }
346} CurModule;
347
348static struct PerFunctionInfo {
349 Function *CurrentFunction; // Pointer to current function being created
350
351 ValueList Values; // Keep track of #'d definitions
352 unsigned NextValNum;
353 ValueList LateResolveValues;
354 bool isDeclare; // Is this function a forward declararation?
355 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
356 GlobalValue::VisibilityTypes Visibility;
357
358 /// BBForwardRefs - When we see forward references to basic blocks, keep
359 /// track of them here.
360 std::map<ValID, BasicBlock*> BBForwardRefs;
361
362 inline PerFunctionInfo() {
363 CurrentFunction = 0;
364 isDeclare = false;
365 Linkage = GlobalValue::ExternalLinkage;
366 Visibility = GlobalValue::DefaultVisibility;
367 }
368
369 inline void FunctionStart(Function *M) {
370 CurrentFunction = M;
371 NextValNum = 0;
372 }
373
374 void FunctionDone() {
375 // Any forward referenced blocks left?
376 if (!BBForwardRefs.empty()) {
377 GenerateError("Undefined reference to label " +
378 BBForwardRefs.begin()->second->getName());
379 return;
380 }
381
382 // Resolve all forward references now.
383 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
384
385 Values.clear(); // Clear out function local definitions
386 BBForwardRefs.clear();
387 CurrentFunction = 0;
388 isDeclare = false;
389 Linkage = GlobalValue::ExternalLinkage;
390 Visibility = GlobalValue::DefaultVisibility;
391 }
392} CurFun; // Info for the current function...
393
394static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
395
396
397//===----------------------------------------------------------------------===//
398// Code to handle definitions of all the types
399//===----------------------------------------------------------------------===//
400
401static void InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) {
402 // Things that have names or are void typed don't get slot numbers
403 if (V->hasName() || (V->getType() == Type::VoidTy))
404 return;
405
406 // In the case of function values, we have to allow for the forward reference
407 // of basic blocks, which are included in the numbering. Consequently, we keep
408 // track of the next insertion location with NextValNum. When a BB gets
409 // inserted, it could change the size of the CurFun.Values vector.
410 if (&ValueTab == &CurFun.Values) {
411 if (ValueTab.size() <= CurFun.NextValNum)
412 ValueTab.resize(CurFun.NextValNum+1);
413 ValueTab[CurFun.NextValNum++] = V;
414 return;
415 }
416 // For all other lists, its okay to just tack it on the back of the vector.
417 ValueTab.push_back(V);
418}
419
420static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
421 switch (D.Type) {
422 case ValID::LocalID: // Is it a numbered definition?
423 // Module constants occupy the lowest numbered slots...
424 if (D.Num < CurModule.Types.size())
425 return CurModule.Types[D.Num];
426 break;
427 case ValID::LocalName: // Is it a named definition?
428 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.getName())) {
429 D.destroy(); // Free old strdup'd memory...
430 return N;
431 }
432 break;
433 default:
434 GenerateError("Internal parser error: Invalid symbol type reference");
435 return 0;
436 }
437
438 // If we reached here, we referenced either a symbol that we don't know about
439 // or an id number that hasn't been read yet. We may be referencing something
440 // forward, so just create an entry to be resolved later and get to it...
441 //
442 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
443
444
445 if (inFunctionScope()) {
446 if (D.Type == ValID::LocalName) {
447 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
448 return 0;
449 } else {
450 GenerateError("Reference to an undefined type: #" + utostr(D.Num));
451 return 0;
452 }
453 }
454
455 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
456 if (I != CurModule.LateResolveTypes.end())
457 return I->second;
458
459 Type *Typ = OpaqueType::get();
460 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
461 return Typ;
462 }
463
464// getExistingVal - Look up the value specified by the provided type and
465// the provided ValID. If the value exists and has already been defined, return
466// it. Otherwise return null.
467//
468static Value *getExistingVal(const Type *Ty, const ValID &D) {
469 if (isa<FunctionType>(Ty)) {
470 GenerateError("Functions are not values and "
471 "must be referenced as pointers");
472 return 0;
473 }
474
475 switch (D.Type) {
476 case ValID::LocalID: { // Is it a numbered definition?
477 // Check that the number is within bounds.
478 if (D.Num >= CurFun.Values.size())
479 return 0;
480 Value *Result = CurFun.Values[D.Num];
481 if (Ty != Result->getType()) {
482 GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" +
483 Result->getType()->getDescription() + "' does not match "
484 "expected type, '" + Ty->getDescription() + "'");
485 return 0;
486 }
487 return Result;
488 }
489 case ValID::GlobalID: { // Is it a numbered definition?
490 if (D.Num >= CurModule.Values.size())
491 return 0;
492 Value *Result = CurModule.Values[D.Num];
493 if (Ty != Result->getType()) {
494 GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" +
495 Result->getType()->getDescription() + "' does not match "
496 "expected type, '" + Ty->getDescription() + "'");
497 return 0;
498 }
499 return Result;
500 }
501
502 case ValID::LocalName: { // Is it a named definition?
503 if (!inFunctionScope())
504 return 0;
505 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
506 Value *N = SymTab.lookup(D.getName());
507 if (N == 0)
508 return 0;
509 if (N->getType() != Ty)
510 return 0;
511
512 D.destroy(); // Free old strdup'd memory...
513 return N;
514 }
515 case ValID::GlobalName: { // Is it a named definition?
516 ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
517 Value *N = SymTab.lookup(D.getName());
518 if (N == 0)
519 return 0;
520 if (N->getType() != Ty)
521 return 0;
522
523 D.destroy(); // Free old strdup'd memory...
524 return N;
525 }
526
527 // Check to make sure that "Ty" is an integral type, and that our
528 // value will fit into the specified type...
529 case ValID::ConstSIntVal: // Is it a constant pool reference??
530 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
531 GenerateError("Signed integral constant '" +
532 itostr(D.ConstPool64) + "' is invalid for type '" +
533 Ty->getDescription() + "'");
534 return 0;
535 }
536 return ConstantInt::get(Ty, D.ConstPool64, true);
537
538 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
539 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
540 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
541 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
542 "' is invalid or out of range");
543 return 0;
544 } else { // This is really a signed reference. Transmogrify.
545 return ConstantInt::get(Ty, D.ConstPool64, true);
546 }
547 } else {
548 return ConstantInt::get(Ty, D.UConstPool64);
549 }
550
551 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Dale Johannesen3afee192007-09-07 21:07:57 +0000552 if (!ConstantFP::isValueValidForType(Ty, *D.ConstPoolFP)) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000553 GenerateError("FP constant invalid for type");
554 return 0;
555 }
Dale Johannesen255b8fe2007-09-11 18:33:39 +0000556 // Lexer has no type info, so builds all float and double FP constants
557 // as double. Fix this here. Long double does not need this.
558 if (&D.ConstPoolFP->getSemantics() == &APFloat::IEEEdouble &&
559 Ty==Type::FloatTy)
Dale Johannesen3afee192007-09-07 21:07:57 +0000560 D.ConstPoolFP->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
561 return ConstantFP::get(Ty, *D.ConstPoolFP);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000562
563 case ValID::ConstNullVal: // Is it a null value?
564 if (!isa<PointerType>(Ty)) {
565 GenerateError("Cannot create a a non pointer null");
566 return 0;
567 }
568 return ConstantPointerNull::get(cast<PointerType>(Ty));
569
570 case ValID::ConstUndefVal: // Is it an undef value?
571 return UndefValue::get(Ty);
572
573 case ValID::ConstZeroVal: // Is it a zero value?
574 return Constant::getNullValue(Ty);
575
576 case ValID::ConstantVal: // Fully resolved constant?
577 if (D.ConstantValue->getType() != Ty) {
578 GenerateError("Constant expression type different from required type");
579 return 0;
580 }
581 return D.ConstantValue;
582
583 case ValID::InlineAsmVal: { // Inline asm expression
584 const PointerType *PTy = dyn_cast<PointerType>(Ty);
585 const FunctionType *FTy =
586 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
587 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
588 GenerateError("Invalid type for asm constraint string");
589 return 0;
590 }
591 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
592 D.IAD->HasSideEffects);
593 D.destroy(); // Free InlineAsmDescriptor.
594 return IA;
595 }
596 default:
597 assert(0 && "Unhandled case!");
598 return 0;
599 } // End of switch
600
601 assert(0 && "Unhandled case!");
602 return 0;
603}
604
605// getVal - This function is identical to getExistingVal, except that if a
606// value is not already defined, it "improvises" by creating a placeholder var
607// that looks and acts just like the requested variable. When the value is
608// defined later, all uses of the placeholder variable are replaced with the
609// real thing.
610//
611static Value *getVal(const Type *Ty, const ValID &ID) {
612 if (Ty == Type::LabelTy) {
613 GenerateError("Cannot use a basic block here");
614 return 0;
615 }
616
617 // See if the value has already been defined.
618 Value *V = getExistingVal(Ty, ID);
619 if (V) return V;
620 if (TriggerError) return 0;
621
622 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
623 GenerateError("Invalid use of a composite type");
624 return 0;
625 }
626
627 // If we reached here, we referenced either a symbol that we don't know about
628 // or an id number that hasn't been read yet. We may be referencing something
629 // forward, so just create an entry to be resolved later and get to it...
630 //
631 switch (ID.Type) {
632 case ValID::GlobalName:
633 case ValID::GlobalID: {
634 const PointerType *PTy = dyn_cast<PointerType>(Ty);
635 if (!PTy) {
636 GenerateError("Invalid type for reference to global" );
637 return 0;
638 }
639 const Type* ElTy = PTy->getElementType();
640 if (const FunctionType *FTy = dyn_cast<FunctionType>(ElTy))
641 V = new Function(FTy, GlobalValue::ExternalLinkage);
642 else
Christopher Lamb0a243582007-12-11 09:02:08 +0000643 V = new GlobalVariable(ElTy, false, GlobalValue::ExternalLinkage, 0, "",
644 (Module*)0, false, PTy->getAddressSpace());
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000645 break;
646 }
647 default:
648 V = new Argument(Ty);
649 }
650
651 // Remember where this forward reference came from. FIXME, shouldn't we try
652 // to recycle these things??
653 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
Duncan Sandsf5588dc2007-11-27 13:23:08 +0000654 LLLgetLineNo())));
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000655
656 if (inFunctionScope())
657 InsertValue(V, CurFun.LateResolveValues);
658 else
659 InsertValue(V, CurModule.LateResolveValues);
660 return V;
661}
662
663/// defineBBVal - This is a definition of a new basic block with the specified
664/// identifier which must be the same as CurFun.NextValNum, if its numeric.
665static BasicBlock *defineBBVal(const ValID &ID) {
666 assert(inFunctionScope() && "Can't get basic block at global scope!");
667
668 BasicBlock *BB = 0;
669
670 // First, see if this was forward referenced
671
672 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
673 if (BBI != CurFun.BBForwardRefs.end()) {
674 BB = BBI->second;
675 // The forward declaration could have been inserted anywhere in the
676 // function: insert it into the correct place now.
677 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
678 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
679
680 // We're about to erase the entry, save the key so we can clean it up.
681 ValID Tmp = BBI->first;
682
683 // Erase the forward ref from the map as its no longer "forward"
684 CurFun.BBForwardRefs.erase(ID);
685
686 // The key has been removed from the map but so we don't want to leave
687 // strdup'd memory around so destroy it too.
688 Tmp.destroy();
689
690 // If its a numbered definition, bump the number and set the BB value.
691 if (ID.Type == ValID::LocalID) {
692 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
693 InsertValue(BB);
694 }
695
696 ID.destroy();
697 return BB;
698 }
699
700 // We haven't seen this BB before and its first mention is a definition.
701 // Just create it and return it.
702 std::string Name (ID.Type == ValID::LocalName ? ID.getName() : "");
703 BB = new BasicBlock(Name, CurFun.CurrentFunction);
704 if (ID.Type == ValID::LocalID) {
705 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
706 InsertValue(BB);
707 }
708
709 ID.destroy(); // Free strdup'd memory
710 return BB;
711}
712
713/// getBBVal - get an existing BB value or create a forward reference for it.
714///
715static BasicBlock *getBBVal(const ValID &ID) {
716 assert(inFunctionScope() && "Can't get basic block at global scope!");
717
718 BasicBlock *BB = 0;
719
720 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
721 if (BBI != CurFun.BBForwardRefs.end()) {
722 BB = BBI->second;
723 } if (ID.Type == ValID::LocalName) {
724 std::string Name = ID.getName();
725 Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
726 if (N)
727 if (N->getType()->getTypeID() == Type::LabelTyID)
728 BB = cast<BasicBlock>(N);
729 else
730 GenerateError("Reference to label '" + Name + "' is actually of type '"+
731 N->getType()->getDescription() + "'");
732 } else if (ID.Type == ValID::LocalID) {
733 if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) {
734 if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID)
735 BB = cast<BasicBlock>(CurFun.Values[ID.Num]);
736 else
737 GenerateError("Reference to label '%" + utostr(ID.Num) +
738 "' is actually of type '"+
739 CurFun.Values[ID.Num]->getType()->getDescription() + "'");
740 }
741 } else {
742 GenerateError("Illegal label reference " + ID.getName());
743 return 0;
744 }
745
746 // If its already been defined, return it now.
747 if (BB) {
748 ID.destroy(); // Free strdup'd memory.
749 return BB;
750 }
751
752 // Otherwise, this block has not been seen before, create it.
753 std::string Name;
754 if (ID.Type == ValID::LocalName)
755 Name = ID.getName();
756 BB = new BasicBlock(Name, CurFun.CurrentFunction);
757
758 // Insert it in the forward refs map.
759 CurFun.BBForwardRefs[ID] = BB;
760
761 return BB;
762}
763
764
765//===----------------------------------------------------------------------===//
766// Code to handle forward references in instructions
767//===----------------------------------------------------------------------===//
768//
769// This code handles the late binding needed with statements that reference
770// values not defined yet... for example, a forward branch, or the PHI node for
771// a loop body.
772//
773// This keeps a table (CurFun.LateResolveValues) of all such forward references
774// and back patchs after we are done.
775//
776
777// ResolveDefinitions - If we could not resolve some defs at parsing
778// time (forward branches, phi functions for loops, etc...) resolve the
779// defs now...
780//
781static void
782ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) {
783 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
784 while (!LateResolvers.empty()) {
785 Value *V = LateResolvers.back();
786 LateResolvers.pop_back();
787
788 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
789 CurModule.PlaceHolderInfo.find(V);
790 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
791
792 ValID &DID = PHI->second.first;
793
794 Value *TheRealValue = getExistingVal(V->getType(), DID);
795 if (TriggerError)
796 return;
797 if (TheRealValue) {
798 V->replaceAllUsesWith(TheRealValue);
799 delete V;
800 CurModule.PlaceHolderInfo.erase(PHI);
801 } else if (FutureLateResolvers) {
802 // Functions have their unresolved items forwarded to the module late
803 // resolver table
804 InsertValue(V, *FutureLateResolvers);
805 } else {
806 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
807 GenerateError("Reference to an invalid definition: '" +DID.getName()+
808 "' of type '" + V->getType()->getDescription() + "'",
809 PHI->second.second);
810 return;
811 } else {
812 GenerateError("Reference to an invalid definition: #" +
813 itostr(DID.Num) + " of type '" +
814 V->getType()->getDescription() + "'",
815 PHI->second.second);
816 return;
817 }
818 }
819 }
820 LateResolvers.clear();
821}
822
823// ResolveTypeTo - A brand new type was just declared. This means that (if
824// name is not null) things referencing Name can be resolved. Otherwise, things
825// refering to the number can be resolved. Do this now.
826//
827static void ResolveTypeTo(std::string *Name, const Type *ToTy) {
828 ValID D;
829 if (Name)
830 D = ValID::createLocalName(*Name);
831 else
832 D = ValID::createLocalID(CurModule.Types.size());
833
834 std::map<ValID, PATypeHolder>::iterator I =
835 CurModule.LateResolveTypes.find(D);
836 if (I != CurModule.LateResolveTypes.end()) {
837 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
838 CurModule.LateResolveTypes.erase(I);
839 }
840}
841
842// setValueName - Set the specified value to the name given. The name may be
843// null potentially, in which case this is a noop. The string passed in is
844// assumed to be a malloc'd string buffer, and is free'd by this function.
845//
846static void setValueName(Value *V, std::string *NameStr) {
847 if (!NameStr) return;
848 std::string Name(*NameStr); // Copy string
849 delete NameStr; // Free old string
850
851 if (V->getType() == Type::VoidTy) {
852 GenerateError("Can't assign name '" + Name+"' to value with void type");
853 return;
854 }
855
856 assert(inFunctionScope() && "Must be in function scope!");
857 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
858 if (ST.lookup(Name)) {
859 GenerateError("Redefinition of value '" + Name + "' of type '" +
860 V->getType()->getDescription() + "'");
861 return;
862 }
863
864 // Set the name.
865 V->setName(Name);
866}
867
868/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
869/// this is a declaration, otherwise it is a definition.
870static GlobalVariable *
871ParseGlobalVariable(std::string *NameStr,
872 GlobalValue::LinkageTypes Linkage,
873 GlobalValue::VisibilityTypes Visibility,
874 bool isConstantGlobal, const Type *Ty,
Christopher Lamb0a243582007-12-11 09:02:08 +0000875 Constant *Initializer, bool IsThreadLocal,
876 unsigned AddressSpace = 0) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000877 if (isa<FunctionType>(Ty)) {
878 GenerateError("Cannot declare global vars of function type");
879 return 0;
880 }
881
Christopher Lamb0a243582007-12-11 09:02:08 +0000882 const PointerType *PTy = PointerType::get(Ty, AddressSpace);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000883
884 std::string Name;
885 if (NameStr) {
886 Name = *NameStr; // Copy string
887 delete NameStr; // Free old string
888 }
889
890 // See if this global value was forward referenced. If so, recycle the
891 // object.
892 ValID ID;
893 if (!Name.empty()) {
894 ID = ValID::createGlobalName(Name);
895 } else {
896 ID = ValID::createGlobalID(CurModule.Values.size());
897 }
898
899 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
900 // Move the global to the end of the list, from whereever it was
901 // previously inserted.
902 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
903 CurModule.CurrentModule->getGlobalList().remove(GV);
904 CurModule.CurrentModule->getGlobalList().push_back(GV);
905 GV->setInitializer(Initializer);
906 GV->setLinkage(Linkage);
907 GV->setVisibility(Visibility);
908 GV->setConstant(isConstantGlobal);
909 GV->setThreadLocal(IsThreadLocal);
910 InsertValue(GV, CurModule.Values);
911 return GV;
912 }
913
914 // If this global has a name
915 if (!Name.empty()) {
916 // if the global we're parsing has an initializer (is a definition) and
917 // has external linkage.
918 if (Initializer && Linkage != GlobalValue::InternalLinkage)
919 // If there is already a global with external linkage with this name
920 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
921 // If we allow this GVar to get created, it will be renamed in the
922 // symbol table because it conflicts with an existing GVar. We can't
923 // allow redefinition of GVars whose linking indicates that their name
924 // must stay the same. Issue the error.
925 GenerateError("Redefinition of global variable named '" + Name +
926 "' of type '" + Ty->getDescription() + "'");
927 return 0;
928 }
929 }
930
931 // Otherwise there is no existing GV to use, create one now.
932 GlobalVariable *GV =
933 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
Christopher Lamb0a243582007-12-11 09:02:08 +0000934 CurModule.CurrentModule, IsThreadLocal, AddressSpace);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000935 GV->setVisibility(Visibility);
936 InsertValue(GV, CurModule.Values);
937 return GV;
938}
939
940// setTypeName - Set the specified type to the name given. The name may be
941// null potentially, in which case this is a noop. The string passed in is
942// assumed to be a malloc'd string buffer, and is freed by this function.
943//
944// This function returns true if the type has already been defined, but is
945// allowed to be redefined in the specified context. If the name is a new name
946// for the type plane, it is inserted and false is returned.
947static bool setTypeName(const Type *T, std::string *NameStr) {
948 assert(!inFunctionScope() && "Can't give types function-local names!");
949 if (NameStr == 0) return false;
950
951 std::string Name(*NameStr); // Copy string
952 delete NameStr; // Free old string
953
954 // We don't allow assigning names to void type
955 if (T == Type::VoidTy) {
956 GenerateError("Can't assign name '" + Name + "' to the void type");
957 return false;
958 }
959
960 // Set the type name, checking for conflicts as we do so.
961 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
962
963 if (AlreadyExists) { // Inserting a name that is already defined???
964 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
965 assert(Existing && "Conflict but no matching type?!");
966
967 // There is only one case where this is allowed: when we are refining an
968 // opaque type. In this case, Existing will be an opaque type.
969 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
970 // We ARE replacing an opaque type!
971 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
972 return true;
973 }
974
975 // Otherwise, this is an attempt to redefine a type. That's okay if
976 // the redefinition is identical to the original. This will be so if
977 // Existing and T point to the same Type object. In this one case we
978 // allow the equivalent redefinition.
979 if (Existing == T) return true; // Yes, it's equal.
980
981 // Any other kind of (non-equivalent) redefinition is an error.
982 GenerateError("Redefinition of type named '" + Name + "' of type '" +
983 T->getDescription() + "'");
984 }
985
986 return false;
987}
988
989//===----------------------------------------------------------------------===//
990// Code for handling upreferences in type names...
991//
992
993// TypeContains - Returns true if Ty directly contains E in it.
994//
995static bool TypeContains(const Type *Ty, const Type *E) {
996 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
997 E) != Ty->subtype_end();
998}
999
1000namespace {
1001 struct UpRefRecord {
1002 // NestingLevel - The number of nesting levels that need to be popped before
1003 // this type is resolved.
1004 unsigned NestingLevel;
1005
1006 // LastContainedTy - This is the type at the current binding level for the
1007 // type. Every time we reduce the nesting level, this gets updated.
1008 const Type *LastContainedTy;
1009
1010 // UpRefTy - This is the actual opaque type that the upreference is
1011 // represented with.
1012 OpaqueType *UpRefTy;
1013
1014 UpRefRecord(unsigned NL, OpaqueType *URTy)
1015 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1016 };
1017}
1018
1019// UpRefs - A list of the outstanding upreferences that need to be resolved.
1020static std::vector<UpRefRecord> UpRefs;
1021
1022/// HandleUpRefs - Every time we finish a new layer of types, this function is
1023/// called. It loops through the UpRefs vector, which is a list of the
1024/// currently active types. For each type, if the up reference is contained in
1025/// the newly completed type, we decrement the level count. When the level
1026/// count reaches zero, the upreferenced type is the type that is passed in:
1027/// thus we can complete the cycle.
1028///
1029static PATypeHolder HandleUpRefs(const Type *ty) {
1030 // If Ty isn't abstract, or if there are no up-references in it, then there is
1031 // nothing to resolve here.
1032 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1033
1034 PATypeHolder Ty(ty);
1035 UR_OUT("Type '" << Ty->getDescription() <<
1036 "' newly formed. Resolving upreferences.\n" <<
1037 UpRefs.size() << " upreferences active!\n");
1038
1039 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1040 // to zero), we resolve them all together before we resolve them to Ty. At
1041 // the end of the loop, if there is anything to resolve to Ty, it will be in
1042 // this variable.
1043 OpaqueType *TypeToResolve = 0;
1044
1045 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1046 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1047 << UpRefs[i].second->getDescription() << ") = "
1048 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1049 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1050 // Decrement level of upreference
1051 unsigned Level = --UpRefs[i].NestingLevel;
1052 UpRefs[i].LastContainedTy = Ty;
1053 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1054 if (Level == 0) { // Upreference should be resolved!
1055 if (!TypeToResolve) {
1056 TypeToResolve = UpRefs[i].UpRefTy;
1057 } else {
1058 UR_OUT(" * Resolving upreference for "
1059 << UpRefs[i].second->getDescription() << "\n";
1060 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1061 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1062 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1063 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1064 }
1065 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1066 --i; // Do not skip the next element...
1067 }
1068 }
1069 }
1070
1071 if (TypeToResolve) {
1072 UR_OUT(" * Resolving upreference for "
1073 << UpRefs[i].second->getDescription() << "\n";
1074 std::string OldName = TypeToResolve->getDescription());
1075 TypeToResolve->refineAbstractTypeTo(Ty);
1076 }
1077
1078 return Ty;
1079}
1080
1081//===----------------------------------------------------------------------===//
1082// RunVMAsmParser - Define an interface to this parser
1083//===----------------------------------------------------------------------===//
1084//
1085static Module* RunParser(Module * M);
1086
Duncan Sandsf5588dc2007-11-27 13:23:08 +00001087Module *llvm::RunVMAsmParser(llvm::MemoryBuffer *MB) {
1088 InitLLLexer(MB);
1089 Module *M = RunParser(new Module(LLLgetFilename()));
1090 FreeLexer();
1091 return M;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001092}
1093
1094
Scott Michel6d1aba82008-01-30 03:10:00 +00001095#line 947 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
1096typedef union {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001097 llvm::Module *ModuleVal;
1098 llvm::Function *FunctionVal;
1099 llvm::BasicBlock *BasicBlockVal;
1100 llvm::TerminatorInst *TermInstVal;
1101 llvm::Instruction *InstVal;
1102 llvm::Constant *ConstVal;
1103
1104 const llvm::Type *PrimType;
1105 std::list<llvm::PATypeHolder> *TypeList;
1106 llvm::PATypeHolder *TypeVal;
1107 llvm::Value *ValueVal;
1108 std::vector<llvm::Value*> *ValueList;
1109 llvm::ArgListType *ArgList;
1110 llvm::TypeWithAttrs TypeWithAttrs;
1111 llvm::TypeWithAttrsList *TypeWithAttrsList;
Dale Johannesencfb19e62007-11-05 21:20:28 +00001112 llvm::ParamList *ParamList;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001113
1114 // Represent the RHS of PHI node
1115 std::list<std::pair<llvm::Value*,
1116 llvm::BasicBlock*> > *PHIList;
1117 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1118 std::vector<llvm::Constant*> *ConstVector;
1119
1120 llvm::GlobalValue::LinkageTypes Linkage;
1121 llvm::GlobalValue::VisibilityTypes Visibility;
1122 uint16_t ParamAttrs;
1123 llvm::APInt *APIntVal;
1124 int64_t SInt64Val;
1125 uint64_t UInt64Val;
1126 int SIntVal;
1127 unsigned UIntVal;
Dale Johannesen3afee192007-09-07 21:07:57 +00001128 llvm::APFloat *FPVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001129 bool BoolVal;
1130
1131 std::string *StrVal; // This memory must be deleted
1132 llvm::ValID ValIDVal;
1133
1134 llvm::Instruction::BinaryOps BinaryOpVal;
1135 llvm::Instruction::TermOps TermOpVal;
1136 llvm::Instruction::MemoryOps MemOpVal;
1137 llvm::Instruction::CastOps CastOpVal;
1138 llvm::Instruction::OtherOps OtherOpVal;
1139 llvm::ICmpInst::Predicate IPredicate;
1140 llvm::FCmpInst::Predicate FPredicate;
Scott Michel6d1aba82008-01-30 03:10:00 +00001141} YYSTYPE;
1142#include <stdio.h>
1143
1144#ifndef __cplusplus
1145#ifndef __STDC__
1146#define const
1147#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001148#endif
1149
1150
1151
Scott Michel6d1aba82008-01-30 03:10:00 +00001152#define YYFINAL 619
1153#define YYFLAG -32768
1154#define YYNTBASE 164
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001155
Scott Michel6d1aba82008-01-30 03:10:00 +00001156#define YYTRANSLATE(x) ((unsigned)(x) <= 403 ? yytranslate[x] : 247)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001157
Scott Michel6d1aba82008-01-30 03:10:00 +00001158static const short yytranslate[] = { 0,
1159 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1160 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1161 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1162 2, 2, 2, 2, 2, 2, 2, 2, 2, 150,
1163 151, 154, 2, 153, 2, 2, 2, 2, 2, 2,
1164 2, 2, 2, 2, 2, 2, 2, 2, 2, 159,
1165 152, 160, 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, 2,
1168 156, 155, 158, 2, 2, 2, 2, 2, 163, 2,
1169 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1170 2, 2, 2, 2, 2, 2, 2, 2, 2, 157,
1171 2, 2, 161, 2, 162, 2, 2, 2, 2, 2,
1172 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1173 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1174 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1175 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1176 2, 2, 2, 2, 2, 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, 1, 3, 4, 5, 6,
1185 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1186 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1187 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
1188 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
1189 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
1190 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1191 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1192 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1193 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
1194 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
1195 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
1196 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
1197 127, 128, 129, 130, 131, 132, 133, 134, 135, 136,
1198 137, 138, 139, 140, 141, 142, 143, 144, 145, 146,
1199 147, 148, 149
1200};
Reid Spenceraa8ae282007-07-31 03:50:36 +00001201
Scott Michel6d1aba82008-01-30 03:10:00 +00001202#if YYDEBUG != 0
1203static const short yyprhs[] = { 0,
1204 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
1205 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
1206 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
1207 60, 62, 64, 66, 68, 70, 72, 74, 76, 78,
1208 80, 82, 84, 86, 88, 90, 92, 94, 96, 98,
1209 100, 102, 104, 106, 108, 110, 112, 114, 116, 118,
1210 120, 122, 124, 126, 127, 132, 133, 136, 137, 139,
1211 141, 143, 144, 147, 149, 151, 153, 155, 157, 159,
1212 161, 163, 164, 166, 168, 170, 171, 173, 175, 176,
1213 178, 180, 182, 184, 185, 187, 189, 190, 192, 194,
1214 196, 198, 200, 203, 205, 207, 209, 211, 213, 215,
1215 217, 219, 221, 222, 225, 227, 229, 231, 233, 235,
1216 237, 238, 241, 242, 245, 246, 249, 250, 254, 257,
1217 258, 260, 261, 265, 267, 270, 272, 274, 276, 278,
1218 280, 282, 284, 286, 288, 292, 294, 297, 303, 309,
1219 315, 321, 325, 328, 334, 339, 342, 344, 346, 348,
1220 352, 354, 358, 360, 361, 363, 367, 372, 376, 380,
1221 385, 390, 394, 401, 407, 410, 413, 416, 419, 422,
1222 425, 428, 431, 434, 437, 440, 443, 450, 456, 465,
1223 472, 479, 487, 495, 502, 511, 520, 524, 526, 528,
1224 530, 532, 533, 536, 543, 545, 546, 548, 551, 552,
1225 556, 557, 561, 565, 569, 573, 574, 583, 584, 594,
1226 595, 605, 611, 614, 618, 620, 624, 628, 632, 636,
1227 638, 639, 645, 649, 651, 655, 657, 658, 669, 671,
1228 673, 678, 680, 682, 685, 689, 690, 692, 694, 696,
1229 698, 700, 702, 704, 706, 708, 712, 714, 720, 722,
1230 724, 726, 728, 730, 732, 735, 738, 741, 745, 748,
1231 749, 751, 754, 757, 761, 771, 781, 790, 805, 807,
1232 809, 816, 822, 825, 832, 840, 845, 850, 857, 864,
1233 865, 866, 870, 873, 875, 881, 887, 894, 901, 906,
1234 913, 918, 923, 930, 937, 940, 949, 951, 953, 954,
1235 958, 965, 969, 976, 979, 985, 993
1236};
1237
1238static const short yyrhs[] = { 74,
1239 0, 75, 0, 76, 0, 77, 0, 78, 0, 79,
1240 0, 80, 0, 81, 0, 82, 0, 86, 0, 87,
1241 0, 88, 0, 83, 0, 84, 0, 85, 0, 117,
1242 0, 118, 0, 119, 0, 120, 0, 121, 0, 122,
1243 0, 123, 0, 124, 0, 125, 0, 126, 0, 127,
1244 0, 128, 0, 91, 0, 92, 0, 93, 0, 94,
1245 0, 95, 0, 96, 0, 97, 0, 98, 0, 99,
1246 0, 100, 0, 101, 0, 102, 0, 103, 0, 104,
1247 0, 105, 0, 106, 0, 107, 0, 108, 0, 109,
1248 0, 110, 0, 97, 0, 98, 0, 99, 0, 100,
1249 0, 26, 0, 27, 0, 11, 0, 12, 0, 13,
1250 0, 16, 0, 15, 0, 14, 0, 19, 0, 22,
1251 0, 24, 0, 171, 0, 0, 54, 150, 4, 151,
1252 0, 0, 171, 152, 0, 0, 20, 0, 23, 0,
1253 177, 0, 0, 175, 152, 0, 42, 0, 44, 0,
1254 43, 0, 45, 0, 47, 0, 46, 0, 48, 0,
1255 50, 0, 0, 147, 0, 148, 0, 149, 0, 0,
1256 46, 0, 48, 0, 0, 42, 0, 43, 0, 44,
1257 0, 47, 0, 0, 44, 0, 42, 0, 0, 62,
1258 0, 63, 0, 64, 0, 65, 0, 66, 0, 61,
1259 4, 0, 136, 0, 118, 0, 135, 0, 119, 0,
1260 138, 0, 139, 0, 141, 0, 142, 0, 143, 0,
1261 0, 186, 185, 0, 137, 0, 140, 0, 136, 0,
1262 135, 0, 144, 0, 145, 0, 0, 188, 187, 0,
1263 0, 146, 22, 0, 0, 53, 4, 0, 0, 153,
1264 53, 4, 0, 34, 22, 0, 0, 192, 0, 0,
1265 153, 195, 194, 0, 192, 0, 53, 4, 0, 11,
1266 0, 12, 0, 13, 0, 16, 0, 15, 0, 14,
1267 0, 17, 0, 49, 0, 196, 0, 197, 173, 154,
1268 0, 231, 0, 155, 4, 0, 197, 150, 201, 151,
1269 188, 0, 10, 150, 201, 151, 188, 0, 156, 4,
1270 157, 197, 158, 0, 159, 4, 157, 197, 160, 0,
1271 161, 202, 162, 0, 161, 162, 0, 159, 161, 202,
1272 162, 160, 0, 159, 161, 162, 160, 0, 197, 186,
1273 0, 197, 0, 10, 0, 198, 0, 200, 153, 198,
1274 0, 200, 0, 200, 153, 39, 0, 39, 0, 0,
1275 197, 0, 202, 153, 197, 0, 197, 156, 205, 158,
1276 0, 197, 156, 158, 0, 197, 163, 22, 0, 197,
1277 159, 205, 160, 0, 197, 161, 205, 162, 0, 197,
1278 161, 162, 0, 197, 159, 161, 205, 162, 160, 0,
1279 197, 159, 161, 162, 160, 0, 197, 40, 0, 197,
1280 41, 0, 197, 231, 0, 197, 204, 0, 197, 25,
1281 0, 169, 3, 0, 169, 5, 0, 169, 4, 0,
1282 169, 6, 0, 11, 26, 0, 11, 27, 0, 170,
1283 9, 0, 166, 150, 203, 38, 197, 151, 0, 116,
1284 150, 203, 242, 151, 0, 130, 150, 203, 153, 203,
1285 153, 203, 151, 0, 164, 150, 203, 153, 203, 151,
1286 0, 165, 150, 203, 153, 203, 151, 0, 89, 167,
1287 150, 203, 153, 203, 151, 0, 90, 168, 150, 203,
1288 153, 203, 151, 0, 132, 150, 203, 153, 203, 151,
1289 0, 133, 150, 203, 153, 203, 153, 203, 151, 0,
1290 134, 150, 203, 153, 203, 153, 203, 151, 0, 205,
1291 153, 203, 0, 203, 0, 32, 0, 33, 0, 37,
1292 0, 0, 199, 231, 0, 122, 150, 208, 38, 197,
1293 151, 0, 210, 0, 0, 211, 0, 210, 211, 0,
1294 0, 31, 212, 227, 0, 0, 30, 213, 228, 0,
1295 59, 58, 217, 0, 174, 18, 197, 0, 174, 18,
1296 10, 0, 0, 176, 180, 207, 206, 203, 173, 214,
1297 194, 0, 0, 176, 178, 180, 207, 206, 203, 173,
1298 215, 194, 0, 0, 176, 179, 180, 207, 206, 197,
1299 173, 216, 194, 0, 176, 180, 35, 183, 208, 0,
1300 51, 218, 0, 55, 152, 219, 0, 22, 0, 52,
1301 152, 22, 0, 67, 152, 22, 0, 156, 220, 158,
1302 0, 220, 153, 22, 0, 22, 0, 0, 221, 153,
1303 197, 186, 172, 0, 197, 186, 172, 0, 221, 0,
1304 221, 153, 39, 0, 39, 0, 0, 184, 199, 175,
1305 150, 222, 151, 188, 193, 190, 189, 0, 28, 0,
1306 161, 0, 182, 180, 223, 224, 0, 29, 0, 162,
1307 0, 234, 226, 0, 181, 180, 223, 0, 0, 60,
1308 0, 3, 0, 4, 0, 9, 0, 26, 0, 27,
1309 0, 40, 0, 41, 0, 25, 0, 159, 205, 160,
1310 0, 204, 0, 58, 229, 22, 153, 22, 0, 7,
1311 0, 8, 0, 171, 0, 175, 0, 231, 0, 230,
1312 0, 197, 232, 0, 234, 235, 0, 225, 235, 0,
1313 236, 174, 237, 0, 236, 239, 0, 0, 21, 0,
1314 68, 233, 0, 68, 10, 0, 69, 17, 232, 0,
1315 69, 11, 232, 153, 17, 232, 153, 17, 232, 0,
1316 70, 169, 232, 153, 17, 232, 156, 238, 158, 0,
1317 70, 169, 232, 153, 17, 232, 156, 158, 0, 71,
1318 184, 199, 232, 150, 241, 151, 188, 38, 17, 232,
1319 72, 17, 232, 0, 72, 0, 73, 0, 238, 169,
1320 230, 153, 17, 232, 0, 169, 230, 153, 17, 232,
1321 0, 174, 244, 0, 197, 156, 232, 153, 232, 158,
1322 0, 240, 153, 156, 232, 153, 232, 158, 0, 197,
1323 186, 232, 186, 0, 17, 186, 232, 186, 0, 241,
1324 153, 197, 186, 232, 186, 0, 241, 153, 17, 186,
1325 232, 186, 0, 0, 0, 242, 153, 233, 0, 57,
1326 56, 0, 56, 0, 164, 197, 232, 153, 232, 0,
1327 165, 197, 232, 153, 232, 0, 89, 167, 197, 232,
1328 153, 232, 0, 90, 168, 197, 232, 153, 232, 0,
1329 166, 233, 38, 197, 0, 130, 233, 153, 233, 153,
1330 233, 0, 131, 233, 153, 197, 0, 132, 233, 153,
1331 233, 0, 133, 233, 153, 233, 153, 233, 0, 134,
1332 233, 153, 233, 153, 233, 0, 129, 240, 0, 243,
1333 184, 199, 232, 150, 241, 151, 188, 0, 246, 0,
1334 36, 0, 0, 111, 197, 191, 0, 111, 197, 153,
1335 11, 232, 191, 0, 112, 197, 191, 0, 112, 197,
1336 153, 11, 232, 191, 0, 113, 233, 0, 245, 114,
1337 197, 232, 191, 0, 245, 115, 233, 153, 197, 232,
1338 191, 0, 116, 197, 232, 242, 0
1339};
1340
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001341#endif
1342
Scott Michel6d1aba82008-01-30 03:10:00 +00001343#if YYDEBUG != 0
1344static const short yyrline[] = { 0,
1345 1107, 1107, 1107, 1107, 1107, 1107, 1107, 1107, 1107, 1108,
1346 1108, 1108, 1108, 1108, 1108, 1109, 1109, 1109, 1109, 1109,
1347 1109, 1109, 1110, 1110, 1110, 1110, 1110, 1113, 1113, 1114,
1348 1114, 1115, 1115, 1116, 1116, 1117, 1117, 1121, 1121, 1122,
1349 1122, 1123, 1123, 1124, 1124, 1125, 1125, 1126, 1126, 1127,
1350 1127, 1128, 1129, 1134, 1135, 1135, 1135, 1135, 1135, 1137,
1351 1137, 1137, 1138, 1138, 1140, 1141, 1145, 1149, 1154, 1154,
1352 1156, 1157, 1162, 1168, 1169, 1170, 1171, 1172, 1176, 1177,
1353 1178, 1182, 1183, 1184, 1185, 1189, 1190, 1191, 1195, 1196,
1354 1197, 1198, 1199, 1203, 1204, 1205, 1208, 1208, 1209, 1210,
1355 1211, 1212, 1213, 1221, 1222, 1223, 1224, 1225, 1226, 1227,
1356 1228, 1229, 1232, 1233, 1238, 1239, 1240, 1241, 1242, 1243,
1357 1246, 1247, 1252, 1253, 1260, 1260, 1267, 1267, 1277, 1285,
1358 1285, 1291, 1291, 1293, 1298, 1311, 1311, 1311, 1311, 1311,
1359 1311, 1311, 1314, 1318, 1322, 1329, 1334, 1342, 1372, 1397,
1360 1402, 1412, 1422, 1426, 1436, 1443, 1452, 1459, 1464, 1469,
1361 1476, 1477, 1484, 1491, 1499, 1505, 1517, 1545, 1561, 1588,
1362 1616, 1642, 1662, 1688, 1708, 1720, 1727, 1793, 1803, 1813,
1363 1819, 1829, 1835, 1845, 1850, 1855, 1868, 1880, 1902, 1910,
1364 1916, 1927, 1932, 1937, 1943, 1949, 1958, 1962, 1970, 1970,
1365 1973, 1973, 1976, 1988, 2009, 2014, 2022, 2023, 2027, 2027,
1366 2031, 2031, 2034, 2037, 2061, 2072, 2080, 2083, 2089, 2092,
1367 2099, 2103, 2143, 2146, 2152, 2162, 2166, 2171, 2173, 2178,
1368 2183, 2192, 2202, 2213, 2217, 2226, 2235, 2240, 2374, 2374,
1369 2376, 2385, 2385, 2387, 2392, 2404, 2408, 2413, 2417, 2421,
1370 2425, 2429, 2433, 2437, 2441, 2445, 2470, 2474, 2484, 2488,
1371 2492, 2497, 2504, 2504, 2510, 2519, 2523, 2532, 2541, 2550,
1372 2554, 2561, 2565, 2569, 2574, 2584, 2603, 2612, 2696, 2700,
1373 2707, 2718, 2731, 2741, 2752, 2762, 2773, 2781, 2791, 2798,
1374 2801, 2802, 2809, 2813, 2818, 2834, 2851, 2865, 2879, 2891,
1375 2899, 2906, 2912, 2918, 2924, 2939, 3030, 3035, 3039, 3046,
1376 3053, 3061, 3068, 3076, 3084, 3098, 3115
1377};
1378#endif
1379
1380
1381#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
1382
1383static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL",
1384"EUINT64VAL","ESAPINTVAL","EUAPINTVAL","LOCALVAL_ID","GLOBALVAL_ID","FPVAL",
1385"VOID","INTTYPE","FLOAT","DOUBLE","X86_FP80","FP128","PPC_FP128","LABEL","TYPE",
1386"LOCALVAR","GLOBALVAR","LABELSTR","STRINGCONSTANT","ATSTRINGCONSTANT","PCTSTRINGCONSTANT",
1387"ZEROINITIALIZER","TRUETOK","FALSETOK","BEGINTOK","ENDTOK","DECLARE","DEFINE",
1388"GLOBAL","CONSTANT","SECTION","ALIAS","VOLATILE","THREAD_LOCAL","TO","DOTDOTDOT",
1389"NULL_TOK","UNDEF","INTERNAL","LINKONCE","WEAK","APPENDING","DLLIMPORT","DLLEXPORT",
1390"EXTERN_WEAK","OPAQUE","EXTERNAL","TARGET","TRIPLE","ALIGN","ADDRSPACE","DEPLIBS",
1391"CALL","TAIL","ASM_TOK","MODULE","SIDEEFFECT","CC_TOK","CCC_TOK","FASTCC_TOK",
1392"COLDCC_TOK","X86_STDCALLCC_TOK","X86_FASTCALLCC_TOK","DATALAYOUT","RET","BR",
1393"SWITCH","INVOKE","UNWIND","UNREACHABLE","ADD","SUB","MUL","UDIV","SDIV","FDIV",
1394"UREM","SREM","FREM","AND","OR","XOR","SHL","LSHR","ASHR","ICMP","FCMP","EQ",
1395"NE","SLT","SGT","SLE","SGE","ULT","UGT","ULE","UGE","OEQ","ONE","OLT","OGT",
1396"OLE","OGE","ORD","UNO","UEQ","UNE","MALLOC","ALLOCA","FREE","LOAD","STORE",
1397"GETELEMENTPTR","TRUNC","ZEXT","SEXT","FPTRUNC","FPEXT","BITCAST","UITOFP","SITOFP",
1398"FPTOUI","FPTOSI","INTTOPTR","PTRTOINT","PHI_TOK","SELECT","VAARG","EXTRACTELEMENT",
1399"INSERTELEMENT","SHUFFLEVECTOR","SIGNEXT","ZEROEXT","NORETURN","INREG","SRET",
1400"NOUNWIND","NOALIAS","BYVAL","NEST","READNONE","READONLY","GC","DEFAULT","HIDDEN",
1401"PROTECTED","'('","')'","'='","','","'*'","'\\\\'","'['","'x'","']'","'<'","'>'",
1402"'{'","'}'","'c'","ArithmeticOps","LogicalOps","CastOps","IPredicates","FPredicates",
1403"IntType","FPType","LocalName","OptLocalName","OptAddrSpace","OptLocalAssign",
1404"GlobalName","OptGlobalAssign","GlobalAssign","GVInternalLinkage","GVExternalLinkage",
1405"GVVisibilityStyle","FunctionDeclareLinkage","FunctionDefineLinkage","AliasLinkage",
1406"OptCallingConv","ParamAttr","OptParamAttrs","FuncAttr","OptFuncAttrs","OptGC",
1407"OptAlign","OptCAlign","SectionString","OptSection","GlobalVarAttributes","GlobalVarAttribute",
1408"PrimType","Types","ArgType","ResultTypes","ArgTypeList","ArgTypeListI","TypeListI",
1409"ConstVal","ConstExpr","ConstVector","GlobalType","ThreadLocal","AliaseeRef",
1410"Module","DefinitionList","Definition","@1","@2","@3","@4","@5","AsmBlock","TargetDefinition",
1411"LibrariesDefinition","LibList","ArgListH","ArgList","FunctionHeaderH","BEGIN",
1412"FunctionHeader","END","Function","FunctionProto","OptSideEffect","ConstValueRef",
1413"SymbolicValueRef","ValueRef","ResolvedVal","BasicBlockList","BasicBlock","InstructionList",
1414"BBTerminatorInst","JumpTable","Inst","PHIList","ParamList","IndexList","OptTailCall",
1415"InstVal","OptVolatile","MemoryInst", NULL
1416};
1417#endif
1418
1419static const short yyr1[] = { 0,
1420 164, 164, 164, 164, 164, 164, 164, 164, 164, 165,
1421 165, 165, 165, 165, 165, 166, 166, 166, 166, 166,
1422 166, 166, 166, 166, 166, 166, 166, 167, 167, 167,
1423 167, 167, 167, 167, 167, 167, 167, 168, 168, 168,
1424 168, 168, 168, 168, 168, 168, 168, 168, 168, 168,
1425 168, 168, 168, 169, 170, 170, 170, 170, 170, 171,
1426 171, 171, 172, 172, 173, 173, 174, 174, 175, 175,
1427 176, 176, 177, 178, 178, 178, 178, 178, 179, 179,
1428 179, 180, 180, 180, 180, 181, 181, 181, 182, 182,
1429 182, 182, 182, 183, 183, 183, 184, 184, 184, 184,
1430 184, 184, 184, 185, 185, 185, 185, 185, 185, 185,
1431 185, 185, 186, 186, 187, 187, 187, 187, 187, 187,
1432 188, 188, 189, 189, 190, 190, 191, 191, 192, 193,
1433 193, 194, 194, 195, 195, 196, 196, 196, 196, 196,
1434 196, 196, 197, 197, 197, 197, 197, 197, 197, 197,
1435 197, 197, 197, 197, 197, 198, 199, 199, 200, 200,
1436 201, 201, 201, 201, 202, 202, 203, 203, 203, 203,
1437 203, 203, 203, 203, 203, 203, 203, 203, 203, 203,
1438 203, 203, 203, 203, 203, 203, 204, 204, 204, 204,
1439 204, 204, 204, 204, 204, 204, 205, 205, 206, 206,
1440 207, 207, 208, 208, 209, 209, 210, 210, 212, 211,
1441 213, 211, 211, 211, 211, 214, 211, 215, 211, 216,
1442 211, 211, 211, 211, 217, 218, 218, 219, 220, 220,
1443 220, 221, 221, 222, 222, 222, 222, 223, 224, 224,
1444 225, 226, 226, 227, 228, 229, 229, 230, 230, 230,
1445 230, 230, 230, 230, 230, 230, 230, 230, 231, 231,
1446 231, 231, 232, 232, 233, 234, 234, 235, 236, 236,
1447 236, 237, 237, 237, 237, 237, 237, 237, 237, 237,
1448 238, 238, 239, 240, 240, 241, 241, 241, 241, 241,
1449 242, 242, 243, 243, 244, 244, 244, 244, 244, 244,
1450 244, 244, 244, 244, 244, 244, 244, 245, 245, 246,
1451 246, 246, 246, 246, 246, 246, 246
1452};
1453
1454static const short yyr2[] = { 0,
1455 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1456 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1457 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1458 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1459 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1460 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1461 1, 1, 1, 0, 4, 0, 2, 0, 1, 1,
1462 1, 0, 2, 1, 1, 1, 1, 1, 1, 1,
1463 1, 0, 1, 1, 1, 0, 1, 1, 0, 1,
1464 1, 1, 1, 0, 1, 1, 0, 1, 1, 1,
1465 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
1466 1, 1, 0, 2, 1, 1, 1, 1, 1, 1,
1467 0, 2, 0, 2, 0, 2, 0, 3, 2, 0,
1468 1, 0, 3, 1, 2, 1, 1, 1, 1, 1,
1469 1, 1, 1, 1, 3, 1, 2, 5, 5, 5,
1470 5, 3, 2, 5, 4, 2, 1, 1, 1, 3,
1471 1, 3, 1, 0, 1, 3, 4, 3, 3, 4,
1472 4, 3, 6, 5, 2, 2, 2, 2, 2, 2,
1473 2, 2, 2, 2, 2, 2, 6, 5, 8, 6,
1474 6, 7, 7, 6, 8, 8, 3, 1, 1, 1,
1475 1, 0, 2, 6, 1, 0, 1, 2, 0, 3,
1476 0, 3, 3, 3, 3, 0, 8, 0, 9, 0,
1477 9, 5, 2, 3, 1, 3, 3, 3, 3, 1,
1478 0, 5, 3, 1, 3, 1, 0, 10, 1, 1,
1479 4, 1, 1, 2, 3, 0, 1, 1, 1, 1,
1480 1, 1, 1, 1, 1, 3, 1, 5, 1, 1,
1481 1, 1, 1, 1, 2, 2, 2, 3, 2, 0,
1482 1, 2, 2, 3, 9, 9, 8, 14, 1, 1,
1483 6, 5, 2, 6, 7, 4, 4, 6, 6, 0,
1484 0, 3, 2, 1, 5, 5, 6, 6, 4, 6,
1485 4, 4, 6, 6, 2, 8, 1, 1, 0, 3,
1486 6, 3, 6, 2, 5, 7, 4
1487};
1488
1489static const short yydefact[] = { 72,
1490 60, 69, 61, 70, 62, 211, 209, 0, 0, 0,
1491 0, 0, 0, 82, 71, 72, 207, 86, 89, 0,
1492 0, 223, 0, 0, 67, 0, 73, 74, 76, 75,
1493 77, 79, 78, 80, 81, 83, 84, 85, 82, 82,
1494 202, 208, 87, 88, 82, 212, 90, 91, 92, 93,
1495 82, 270, 210, 270, 0, 0, 231, 224, 225, 213,
1496 259, 260, 215, 136, 137, 138, 141, 140, 139, 142,
1497 143, 0, 0, 0, 0, 261, 262, 144, 214, 146,
1498 202, 202, 94, 201, 0, 97, 97, 271, 267, 68,
1499 242, 243, 244, 266, 226, 227, 230, 0, 164, 147,
1500 0, 0, 0, 0, 153, 165, 0, 0, 164, 0,
1501 0, 0, 96, 95, 0, 199, 200, 0, 0, 98,
1502 99, 100, 101, 102, 0, 245, 0, 309, 269, 0,
1503 228, 163, 113, 159, 161, 0, 0, 0, 0, 0,
1504 0, 152, 0, 0, 145, 0, 0, 158, 0, 157,
1505 0, 222, 136, 137, 138, 141, 140, 139, 0, 0,
1506 66, 66, 103, 0, 239, 240, 241, 308, 294, 0,
1507 0, 0, 0, 97, 279, 280, 1, 2, 3, 4,
1508 5, 6, 7, 8, 9, 13, 14, 15, 10, 11,
1509 12, 0, 0, 0, 0, 0, 0, 16, 17, 18,
1510 19, 20, 21, 22, 23, 24, 25, 26, 27, 0,
1511 0, 0, 0, 0, 0, 0, 0, 0, 268, 97,
1512 283, 0, 307, 229, 156, 0, 121, 66, 66, 155,
1513 0, 166, 0, 121, 66, 66, 0, 203, 184, 185,
1514 180, 182, 181, 183, 186, 179, 175, 176, 0, 0,
1515 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1516 0, 0, 178, 177, 216, 0, 293, 273, 66, 272,
1517 0, 0, 54, 0, 0, 28, 29, 30, 31, 32,
1518 33, 34, 35, 36, 37, 0, 52, 53, 48, 49,
1519 50, 51, 38, 39, 40, 41, 42, 43, 44, 45,
1520 46, 47, 0, 127, 127, 314, 66, 66, 305, 0,
1521 0, 0, 0, 0, 66, 66, 0, 0, 0, 0,
1522 105, 107, 106, 104, 108, 109, 110, 111, 112, 114,
1523 162, 160, 149, 150, 151, 154, 65, 148, 218, 220,
1524 0, 0, 0, 0, 0, 0, 0, 0, 168, 198,
1525 0, 0, 0, 172, 0, 169, 0, 0, 0, 132,
1526 237, 248, 249, 250, 255, 251, 252, 253, 254, 246,
1527 0, 257, 264, 263, 265, 0, 274, 0, 0, 66,
1528 66, 0, 310, 0, 312, 291, 0, 0, 0, 0,
1529 0, 0, 0, 0, 0, 0, 0, 66, 0, 118,
1530 117, 115, 116, 119, 120, 122, 132, 132, 0, 0,
1531 0, 291, 0, 0, 0, 0, 0, 167, 153, 165,
1532 0, 170, 171, 0, 0, 0, 0, 217, 236, 113,
1533 234, 0, 247, 0, 0, 0, 0, 0, 0, 0,
1534 0, 0, 0, 317, 0, 0, 0, 301, 302, 0,
1535 0, 0, 0, 299, 0, 127, 0, 219, 221, 66,
1536 0, 0, 0, 0, 0, 0, 0, 197, 174, 0,
1537 0, 0, 0, 0, 0, 134, 132, 64, 0, 121,
1538 0, 256, 0, 0, 290, 0, 0, 127, 128, 127,
1539 0, 0, 0, 0, 0, 0, 295, 296, 290, 0,
1540 315, 66, 204, 0, 0, 188, 0, 0, 0, 0,
1541 173, 0, 0, 66, 129, 135, 133, 63, 233, 235,
1542 113, 130, 0, 0, 0, 113, 113, 0, 297, 298,
1543 311, 313, 292, 0, 0, 300, 303, 304, 0, 127,
1544 0, 0, 0, 194, 0, 0, 190, 191, 187, 64,
1545 131, 125, 258, 0, 0, 0, 0, 121, 0, 284,
1546 0, 121, 316, 192, 193, 0, 0, 0, 232, 0,
1547 123, 0, 277, 0, 0, 105, 107, 113, 113, 0,
1548 113, 113, 285, 306, 189, 195, 196, 126, 0, 238,
1549 275, 0, 276, 0, 287, 286, 0, 0, 0, 124,
1550 0, 0, 0, 113, 113, 0, 0, 0, 289, 288,
1551 282, 0, 0, 281, 0, 278, 0, 0, 0
1552};
1553
1554static const short yydefgoto[] = { 260,
1555 261, 262, 286, 303, 159, 160, 76, 519, 110, 12,
1556 77, 14, 15, 39, 40, 41, 45, 51, 115, 125,
1557 330, 225, 406, 333, 590, 571, 383, 476, 552, 428,
1558 477, 78, 161, 134, 151, 135, 136, 107, 350, 372,
1559 351, 118, 85, 152, 617, 16, 17, 19, 18, 360,
1560 407, 408, 60, 22, 58, 98, 431, 432, 126, 167,
1561 52, 93, 53, 46, 434, 373, 80, 375, 270, 54,
1562 89, 90, 219, 575, 129, 309, 528, 444, 220, 221,
1563 222, 223
1564};
1565
1566static const short yypact[] = { 253,
1567-32768,-32768,-32768,-32768,-32768,-32768,-32768, -4, -114, -16,
1568 -103, 46, -78, 12,-32768, 392,-32768, 149, 177, -44,
1569 -31,-32768, -1, 154,-32768, 1529,-32768,-32768,-32768,-32768,
1570-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -37, -37,
1571 203,-32768,-32768,-32768, -37,-32768,-32768,-32768,-32768,-32768,
1572 -37, 190,-32768, 2, 195, 217, 245,-32768,-32768,-32768,
1573-32768,-32768, 124,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1574-32768, 274, 278, 1, 505,-32768,-32768,-32768, 62,-32768,
1575 256, 256, 200,-32768, 119, 224, 224,-32768,-32768, 100,
1576-32768,-32768,-32768,-32768,-32768,-32768,-32768, 57, 1052,-32768,
1577 140, 148, 604, 124,-32768, 62, -69, 157, 1052, 155,
1578 119, 119,-32768,-32768, 1295,-32768,-32768, 1569, 306,-32768,
1579-32768,-32768,-32768,-32768, 1627,-32768, -17, 1851,-32768, 289,
1580-32768,-32768, 62,-32768, 163, 166, 1645, 1645, 158, -58,
1581 1645,-32768, 315, 171,-32768, 1569, 1645, 124, 170, 62,
1582 58,-32768, 41, 314, 318, 320, 321, 329, 226, 330,
1583 1107, 270,-32768, 30,-32768,-32768,-32768,-32768,-32768, 288,
1584 1685, 137, 336, 224,-32768,-32768,-32768,-32768,-32768,-32768,
1585-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1586-32768, 388, 781, 1645, 1645, 1645, 1645,-32768,-32768,-32768,
1587-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 1645,
1588 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645,-32768, 224,
1589-32768, 70,-32768,-32768, 207, 1374,-32768, -15, -14,-32768,
1590 197, 62, 208,-32768, 270, -13, 1295,-32768,-32768,-32768,
1591-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 388, 781,
1592 212, 213, 214, 220, 221, 1414, 1725, 782, 351, 228,
1593 229, 231,-32768,-32768,-32768, 232,-32768, 124, 696,-32768,
1594 834, 834,-32768, 834, 1627,-32768,-32768,-32768,-32768,-32768,
1595-32768,-32768,-32768,-32768,-32768, 1645,-32768,-32768,-32768,-32768,
1596-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1597-32768,-32768, 1645, 15, 29,-32768, 696, 7, 205, 223,
1598 235, 236, 237, 238, 696, 696, 346, 1627, 1645, 1645,
1599-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1600-32768,-32768, 120,-32768,-32768,-32768,-32768, 120,-32768, 155,
1601 358, 248, 249, 1569, 1569, 1569, 1569, 1569,-32768,-32768,
1602 69, 1007, -61,-32768, -56,-32768, 1569, 1569, 1569, 251,
1603 1454,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 341,
1604 1569,-32768,-32768,-32768,-32768, 252,-32768, 255, 834, 696,
1605 696, 19,-32768, 23,-32768,-32768, 834, 246, 1645, 1645,
1606 1645, 1645, 1645, 260, 266, 1645, 834, 696, 271,-32768,
1607-32768,-32768,-32768,-32768,-32768,-32768, 251, 251, 1645, 1569,
1608 1569,-32768, 272, 275, 276, 277, 1569,-32768, 267, 962,
1609 -55,-32768,-32768, 286, 291, 371, 18,-32768,-32768, 62,
1610 292, 280,-32768, 420, -57, 431, 433, 302, 300, 301,
1611 834, 453, 834, 305, 307, 834, 309, 62,-32768, 310,
1612 311, 834, 834, 62, 316, 312, 1645,-32768,-32768, -18,
1613 323, 324, 92, 1569, 1569, 1569, 1569,-32768,-32768, 299,
1614 1569, 1569, 1645, 446, 469,-32768, 251, 729, 1472,-32768,
1615 339,-32768, 834, 834, 1743, 834, 834, 312,-32768, 312,
1616 1645, 834, 340, 1645, 1645, 1645,-32768,-32768, 1743, 421,
1617-32768, 696,-32768, 1569, 1569,-32768, 342, 343, 344, 345,
1618-32768, 348, 349, 16,-32768,-32768,-32768,-32768,-32768,-32768,
1619 62, -6, 474, 350, 352, 64, 62, 101,-32768,-32768,
1620-32768,-32768,-32768, 347, 834,-32768,-32768,-32768, 115, 312,
1621 353, 356, 1569,-32768, 1569, 1569,-32768,-32768,-32768, 729,
1622-32768, 448,-32768, 485, -5, 555, 555,-32768, 1800,-32768,
1623 365,-32768,-32768,-32768,-32768, 363, 379, 380,-32768, 530,
1624 390, 834,-32768, 1246, -2, 359, 389,-32768,-32768, 5,
1625 64, 62,-32768, 120,-32768,-32768,-32768,-32768, 516,-32768,
1626-32768, 391,-32768, 1246, 207, 207, 524, 555, 555,-32768,
1627 525, 394, 834,-32768,-32768, 834, 526, 473, 207, 207,
1628-32768, 834, 531,-32768, 834,-32768, 551, 556,-32768
1629};
1630
1631static const short yypgoto[] = { 427,
1632 437, 439, 319, 322, -172,-32768, 0, 11, -149, 480,
1633 10,-32768,-32768,-32768,-32768, 49,-32768,-32768,-32768, -147,
1634-32768, -401,-32768, -222,-32768,-32768, -281, 51,-32768, -375,
1635-32768,-32768, -24, 357, -117,-32768, 462, 481, -111, -157,
1636 -243, 169, 210, 354,-32768,-32768, 560,-32768,-32768,-32768,
1637-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 498,-32768,
1638-32768,-32768,-32768,-32768,-32768, -557, -46, -66, -193,-32768,
1639 532,-32768,-32768,-32768,-32768,-32768, 88, 176,-32768,-32768,
1640-32768,-32768
1641};
1642
1643
1644#define YYLAST 1985
1645
1646
1647static const short yytable[] = { 11,
1648 274, 79, 306, 263, 102, 273, 162, 164, 273, 13,
1649 165, 338, 265, 353, 355, 11, 592, 310, 311, 312,
1650 313, 314, 88, 385, 317, 13, 275, 474, 478, 441,
1651 91, 458, 459, 443, 235, 108, 602, 23, 108, 108,
1652 108, 24, 597, -54, -54, -54, -54, 20, 25, 2,
1653 106, 474, 4, 28, 29, 30, 31, 32, 33, 34,
1654 108, 35, 21, 26, 61, 62, 239, 240, 108, 108,
1655 475, 442, 318, 27, 133, 442, 1, 2, 106, 3,
1656 4, 5, 108, 141, 133, 339, 340, 81, 82, 11,
1657 150, 417, 142, 86, 141, 417, 417, 417, 422, 87,
1658 150, 517, 482, 231, 238, 423, 470, 55, 421, 36,
1659 37, 38, 228, 229, 264, 108, 232, -142, 1, 550,
1660 56, 3, 236, 5, 556, 557, 399, 435, 400, 401,
1661 402, 109, 503, 403, 109, 109, 109, 404, 405, 400,
1662 401, 402, 334, 166, 403, 335, 269, 271, 404, 405,
1663 116, 117, 573, 272, 57, 593, 109, 379, 36, 37,
1664 38, 103, 387, 92, 109, 109, 549, 382, -66, 304,
1665 305, 269, 307, 266, 501, 59, 595, 596, 109, 598,
1666 599, 384, -66, 319, 320, 308, 269, 269, 269, 269,
1667 269, 315, 316, 269, 43, 447, 44, 449, 450, 451,
1668 397, 133, 609, 610, 376, 377, 531, 378, 532, 130,
1669 88, 109, 150, -142, 131, -66, 95, -142, 47, 48,
1670 49, 417, 374, 50, 374, 374, 418, 374, 241, 242,
1671 243, 244, 412, 413, 414, 415, 416, 83, 96, 84,
1672 386, 113, 506, 114, 491, 424, 425, 426, 394, 395,
1673 150, 558, -206, 559, 400, 401, 402, 522, 563, 403,
1674 374, 380, 263, 404, 405, 562, 97, 559, 374, 374,
1675 -68, 1, 2, 99, 3, 4, 5, 100, 381, 146,
1676 147, 101, 6, 7, 119, 120, 121, 122, 123, 124,
1677 111, 112, 84, 150, 398, 269, 137, 533, 461, 462,
1678 536, 537, 538, 8, 138, 468, 143, 9, 145, 163,
1679 224, 10, 438, 439, 440, 226, 227, 230, 233, 237,
1680 445, 234, -55, 108, 321, 322, -56, 420, -59, -58,
1681 455, 456, 374, 374, 374, 580, 430, -57, 245, 584,
1682 374, 323, 324, 267, 325, 326, 273, 327, 328, 329,
1683 374, 374, 507, 508, 509, 510, 336, 388, 337, 512,
1684 513, 344, 345, 346, 269, 448, 269, 269, 269, 347,
1685 348, 454, 356, 264, 488, 389, 490, 357, 358, 493,
1686 359, 361, 574, 396, 460, 497, 498, 390, 391, 392,
1687 393, -205, 541, 542, 374, 409, 374, 410, 411, 374,
1688 433, 446, 594, 427, 436, 374, 374, 437, 473, -68,
1689 1, 2, 452, 3, 4, 5, 524, 525, 453, 529,
1690 530, 6, 7, 457, 464, 534, 469, 465, 466, 467,
1691 480, 566, 502, 567, 568, 540, 374, 374, 471, 374,
1692 374, 481, 8, 472, 479, 374, 9, 483, 514, 484,
1693 10, 485, 486, 487, 521, 374, 489, 491, 511, 492,
1694 527, 494, 495, 496, 500, 499, 269, 515, 561, 269,
1695 269, 269, 516, 442, 527, 504, 505, 518, 276, 277,
1696 278, 279, 280, 281, 282, 283, 284, 285, 374, 578,
1697 579, 523, 535, 544, 543, 553, 545, 546, 547, 548,
1698 570, 572, 554, 564, 560, 591, 565, 555, -17, 374,
1699 374, 61, 62, 585, 104, 64, 65, 66, 67, 68,
1700 69, 70, 583, 1, 2, 374, 3, 4, 5, 586,
1701 587, 604, 605, 588, 582, 589, 608, 600, -18, 611,
1702 603, 606, 612, 601, 613, 614, 607, 615, 616, 518,
1703 618, 374, 374, 71, 216, 619, 374, 362, 363, 374,
1704 569, 61, 62, 364, 217, 374, 218, 342, 374, 128,
1705 144, 343, 551, 1, 2, 42, 3, 4, 5, 365,
1706 366, 367, 332, 140, 127, 94, 539, 463, 0, 0,
1707 341, 0, 0, 0, 368, 369, 0, 0, 0, 0,
1708 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1709 61, 62, 370, 104, 64, 65, 66, 67, 68, 69,
1710 70, 0, 1, 2, 0, 3, 4, 5, 177, 178,
1711 179, 180, 181, 182, 183, 184, 185, 186, 187, 188,
1712 189, 190, 191, 249, 250, 0, 0, 0, 0, 0,
1713 0, 0, 71, 0, 0, 0, 0, 0, 0, 72,
1714 73, 0, 0, 74, 0, 75, 105, 0, 0, 0,
1715 251, 198, 576, 577, 201, 202, 203, 204, 205, 206,
1716 207, 208, 209, 0, 252, 0, 253, 254, 255, 323,
1717 324, 0, 325, 326, 0, 327, 328, 329, 362, 363,
1718 0, 0, 61, 62, 364, 0, 0, 0, 0, 0,
1719 0, 0, 0, 371, 1, 2, 0, 3, 4, 5,
1720 365, 366, 367, 0, 0, 0, 0, 0, 0, 0,
1721 0, 0, 0, 0, 0, 368, 369, 0, 0, 0,
1722 0, 0, 0, 0, 0, 0, 0, 1, 0, 108,
1723 3, 0, 5, 370, 0, 0, 0, 0, 72, 73,
1724 0, 0, 74, 0, 75, 139, 0, 0, 0, 177,
1725 178, 179, 180, 181, 182, 183, 184, 185, 186, 187,
1726 188, 189, 190, 191, 249, 250, 0, 0, 61, 62,
1727 0, 104, 153, 154, 155, 156, 157, 158, 70, 0,
1728 1, 2, 0, 3, 4, 5, 287, 288, 0, 0,
1729 0, 251, 198, 199, 200, 201, 202, 203, 204, 205,
1730 206, 207, 208, 209, 0, 252, 0, 253, 254, 255,
1731 71, 0, 0, 0, 0, 0, 362, 363, 0, 0,
1732 61, 62, 364, 0, 0, 109, 321, 322, 0, 0,
1733 0, 0, 1, 2, 371, 3, 4, 5, 365, 366,
1734 367, 0, 0, 323, 324, 0, 325, 326, 0, 327,
1735 328, 329, 0, 368, 369, 0, 0, 289, 290, 291,
1736 292, 293, 294, 295, 296, 297, 298, 299, 300, 301,
1737 302, 370, 0, 0, 0, 0, 0, 0, 0, 0,
1738 0, 0, 0, 0, 0, 0, 0, 177, 178, 179,
1739 180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
1740 190, 191, 249, 250, 0, 0, 0, 0, 0, 0,
1741 0, 0, 0, 0, 0, 0, 72, 73, 0, 0,
1742 74, 0, 75, 354, 0, 0, 0, 0, 0, 251,
1743 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
1744 208, 209, 0, 252, 0, 253, 254, 255, 61, 62,
1745 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1746 1, 2, 0, 3, 4, 5, 246, 0, 0, 0,
1747 0, 0, 371, 0, 0, 0, 0, 0, 0, 0,
1748 0, 247, 248, 0, 0, 0, 0, 0, 0, 0,
1749 0, 0, 0, 61, 62, 108, 104, 153, 154, 155,
1750 156, 157, 158, 70, 0, 1, 2, 0, 3, 4,
1751 5, 0, 0, 0, 0, 177, 178, 179, 180, 181,
1752 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
1753 249, 250, 0, 0, 0, 71, 0, 0, 61, 62,
1754 0, 104, 64, 65, 66, 67, 68, 69, 70, 0,
1755 1, 2, 0, 3, 4, 5, 0, 251, 198, 199,
1756 200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
1757 132, 252, 0, 253, 254, 255, 0, 0, 0, 0,
1758 71, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1759 0, 109, 0, 61, 62, -66, 0, 256, 0, 0,
1760 257, 0, 258, 0, 259, 1, 2, 0, 3, 4,
1761 5, 246, 0, 0, 0, 0, 0, 0, 0, 0,
1762 0, 0, 0, 0, 0, 0, 247, 248, 0, 0,
1763 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1764 108, 72, 73, 0, 0, 74, 0, 75, 419, 0,
1765 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1766 177, 178, 179, 180, 181, 182, 183, 184, 185, 186,
1767 187, 188, 189, 190, 191, 249, 250, 0, 0, 0,
1768 0, 0, 0, 0, 0, 0, 72, 73, 0, 0,
1769 74, 0, 75, 0, 0, 0, 0, 0, 0, 0,
1770 0, 0, 251, 198, 199, 200, 201, 202, 203, 204,
1771 205, 206, 207, 208, 209, 0, 252, 0, 253, 254,
1772 255, 0, 0, 0, 0, 0, 0, 0, 362, 363,
1773 0, 0, 0, 0, 364, 0, 109, 0, 0, 0,
1774 0, 0, 256, 0, 0, 257, 0, 258, 0, 259,
1775 365, 366, 367, 0, 0, 0, 0, 0, 0, 0,
1776 0, 0, 0, 0, 0, 368, 369, 0, 0, 0,
1777 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1778 0, 61, 62, 370, 148, 64, 65, 66, 67, 68,
1779 69, 70, 0, 1, 2, 0, 3, 4, 5, 177,
1780 178, 179, 180, 181, 182, 183, 184, 185, 186, 187,
1781 188, 189, 190, 191, 249, 250, 0, 0, 0, 0,
1782 0, 0, 0, 71, 0, 0, 0, 0, 0, 0,
1783 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1784 0, 251, 198, 199, 200, 201, 202, 203, 204, 205,
1785 206, 207, 208, 209, 0, 252, 0, 253, 254, 255,
1786 61, 62, 0, 104, 64, 65, 66, 67, 68, 69,
1787 70, 0, 1, 2, 0, 3, 4, 5, 0, 0,
1788 0, 0, 0, 0, 371, 0, 0, 0, 0, 0,
1789 0, 0, 331, 0, 0, 0, 149, 0, 0, 0,
1790 61, 62, 71, 104, 153, 154, 155, 156, 157, 158,
1791 70, 0, 1, 2, 0, 3, 4, 5, 0, 0,
1792 0, 0, 0, 0, 0, 0, 0, 0, 0, 72,
1793 73, 0, 0, 74, 0, 75, 0, 0, 0, 0,
1794 61, 62, 71, 104, 64, 65, 66, 67, 68, 69,
1795 70, 0, 1, 2, 0, 3, 4, 5, 61, 62,
1796 0, 104, 64, 65, 66, 67, 68, 69, 70, 0,
1797 1, 2, 429, 3, 4, 5, 0, 0, 0, 0,
1798 0, 0, 71, 0, 0, 0, 0, 0, 0, 0,
1799 520, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1800 71, 0, 0, 0, 0, 0, 0, 0, 72, 73,
1801 0, 0, 74, 0, 75, 61, 62, 0, 63, 64,
1802 65, 66, 67, 68, 69, 70, 0, 1, 2, 0,
1803 3, 4, 5, 0, 0, 0, 0, 0, 0, 0,
1804 0, 0, 0, 0, 0, 0, 0, 0, 72, 73,
1805 0, 349, 74, 0, 75, 61, 62, 71, 104, 153,
1806 154, 155, 156, 157, 158, 70, 0, 1, 2, 0,
1807 3, 4, 5, 0, 0, 0, 0, 0, 0, 0,
1808 0, 0, 0, 0, 0, 0, 0, 0, 72, 73,
1809 0, 0, 74, 0, 75, 0, 0, 71, 0, 0,
1810 0, 0, 0, 0, 0, 0, 72, 73, 0, 0,
1811 74, 0, 75, 61, 62, 0, 148, 64, 65, 66,
1812 67, 68, 69, 70, 0, 1, 2, 0, 3, 4,
1813 5, 61, 62, 0, 104, 64, 65, 66, 67, 68,
1814 69, 70, 0, 1, 2, 0, 3, 4, 5, 0,
1815 0, 0, 0, 0, 0, 71, 0, 0, 0, 0,
1816 0, 0, 0, 72, 73, 0, 0, 74, 0, 75,
1817 0, 61, 62, 71, 268, 64, 65, 66, 67, 68,
1818 69, 70, 0, 1, 2, 0, 3, 4, 5, 0,
1819 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1820 0, 0, 0, 72, 73, 0, 0, 74, 0, 75,
1821 0, 61, 62, 71, 104, 153, 154, 155, 156, 157,
1822 158, 70, 0, 1, 2, 0, 3, 4, 5, 61,
1823 62, 0, 104, 64, 65, 66, 67, 68, 69, 526,
1824 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
1825 0, 0, 0, 71, 0, 0, 0, 0, 0, 0,
1826 0, 72, 73, 0, 0, 74, 0, 75, 0, 0,
1827 0, 71, 0, 0, 0, 0, 0, 0, 0, 72,
1828 73, 0, 0, 74, 0, 75, 61, 62, 0, 104,
1829 64, 65, 66, 67, 68, 69, 581, 0, 1, 2,
1830 0, 3, 4, 5, 0, 0, 0, 0, 0, 0,
1831 0, 0, 0, 0, 0, 0, 0, 0, 0, 72,
1832 73, 0, 0, 74, 0, 75, 0, 0, 71, 0,
1833 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1834 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1835 0, 0, 0, 0, 0, 0, 0, 0, 0, 72,
1836 73, 0, 0, 74, 0, 352, 168, 0, 0, 0,
1837 0, 0, 0, 0, 0, 0, 0, 72, 73, 0,
1838 0, 74, 0, 75, 0, 0, 169, 170, 0, 0,
1839 0, 0, 0, 0, 0, 0, 0, 0, 171, 172,
1840 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
1841 183, 184, 185, 186, 187, 188, 189, 190, 191, 192,
1842 193, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1843 0, 0, 0, 0, 72, 73, 0, 0, 74, 0,
1844 75, 194, 195, 196, 0, 0, 197, 198, 199, 200,
1845 201, 202, 203, 204, 205, 206, 207, 208, 209, 210,
1846 211, 212, 213, 214, 215
1847};
1848
1849static const short yycheck[] = { 0,
1850 173, 26, 196, 161, 4, 11, 118, 125, 11, 0,
1851 28, 234, 162, 257, 258, 16, 574, 211, 212, 213,
1852 214, 215, 21, 305, 218, 16, 174, 34, 430, 11,
1853 29, 407, 408, 11, 146, 54, 594, 152, 54, 54,
1854 54, 58, 38, 3, 4, 5, 6, 52, 152, 20,
1855 75, 34, 23, 42, 43, 44, 45, 46, 47, 48,
1856 54, 50, 67, 18, 7, 8, 26, 27, 54, 54,
1857 53, 53, 220, 152, 99, 53, 19, 20, 103, 22,
1858 23, 24, 54, 153, 109, 235, 236, 39, 40, 90,
1859 115, 153, 162, 45, 153, 153, 153, 153, 160, 51,
1860 125, 477, 160, 162, 151, 162, 162, 152, 352, 147,
1861 148, 149, 137, 138, 161, 54, 141, 54, 19, 521,
1862 152, 22, 147, 24, 526, 527, 320, 371, 135, 136,
1863 137, 150, 151, 140, 150, 150, 150, 144, 145, 135,
1864 136, 137, 158, 161, 140, 160, 171, 11, 144, 145,
1865 32, 33, 158, 17, 156, 158, 150, 275, 147, 148,
1866 149, 161, 156, 162, 150, 150, 151, 153, 154, 194,
1867 195, 196, 197, 164, 456, 22, 578, 579, 150, 581,
1868 582, 153, 154, 114, 115, 210, 211, 212, 213, 214,
1869 215, 216, 217, 218, 46, 389, 48, 391, 392, 393,
1870 318, 226, 604, 605, 271, 272, 488, 274, 490, 153,
1871 21, 150, 237, 150, 158, 154, 22, 154, 42, 43,
1872 44, 153, 269, 47, 271, 272, 158, 274, 3, 4,
1873 5, 6, 344, 345, 346, 347, 348, 35, 22, 37,
1874 307, 42, 151, 44, 153, 357, 358, 359, 315, 316,
1875 275, 151, 0, 153, 135, 136, 137, 480, 540, 140,
1876 307, 286, 420, 144, 145, 151, 22, 153, 315, 316,
1877 18, 19, 20, 150, 22, 23, 24, 4, 303, 111,
1878 112, 4, 30, 31, 61, 62, 63, 64, 65, 66,
1879 81, 82, 37, 318, 319, 320, 157, 491, 410, 411,
1880 494, 495, 496, 51, 157, 417, 150, 55, 154, 4,
1881 22, 59, 379, 380, 381, 153, 151, 160, 4, 150,
1882 387, 151, 9, 54, 118, 119, 9, 352, 9, 9,
1883 397, 398, 379, 380, 381, 558, 361, 9, 9, 562,
1884 387, 135, 136, 56, 138, 139, 11, 141, 142, 143,
1885 397, 398, 464, 465, 466, 467, 160, 153, 151, 471,
1886 472, 150, 150, 150, 389, 390, 391, 392, 393, 150,
1887 150, 396, 22, 420, 441, 153, 443, 150, 150, 446,
1888 150, 150, 555, 38, 409, 452, 453, 153, 153, 153,
1889 153, 0, 504, 505, 441, 38, 443, 150, 150, 446,
1890 60, 156, 575, 153, 153, 452, 453, 153, 38, 18,
1891 19, 20, 153, 22, 23, 24, 483, 484, 153, 486,
1892 487, 30, 31, 153, 153, 492, 160, 153, 153, 153,
1893 151, 543, 457, 545, 546, 502, 483, 484, 153, 486,
1894 487, 22, 51, 153, 153, 492, 55, 17, 473, 17,
1895 59, 150, 153, 153, 479, 502, 4, 153, 160, 153,
1896 485, 153, 153, 153, 153, 150, 491, 22, 535, 494,
1897 495, 496, 4, 53, 499, 153, 153, 478, 91, 92,
1898 93, 94, 95, 96, 97, 98, 99, 100, 535, 556,
1899 557, 153, 153, 151, 153, 22, 153, 153, 151, 151,
1900 53, 17, 153, 151, 158, 572, 151, 156, 150, 556,
1901 557, 7, 8, 151, 10, 11, 12, 13, 14, 15,
1902 16, 17, 158, 19, 20, 572, 22, 23, 24, 151,
1903 151, 598, 599, 4, 559, 146, 603, 22, 150, 606,
1904 17, 17, 17, 153, 72, 612, 153, 17, 615, 550,
1905 0, 598, 599, 49, 128, 0, 603, 3, 4, 606,
1906 550, 7, 8, 9, 128, 612, 128, 249, 615, 90,
1907 109, 250, 522, 19, 20, 16, 22, 23, 24, 25,
1908 26, 27, 226, 103, 87, 54, 499, 412, -1, -1,
1909 237, -1, -1, -1, 40, 41, -1, -1, -1, -1,
1910 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1911 7, 8, 58, 10, 11, 12, 13, 14, 15, 16,
1912 17, -1, 19, 20, -1, 22, 23, 24, 74, 75,
1913 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
1914 86, 87, 88, 89, 90, -1, -1, -1, -1, -1,
1915 -1, -1, 49, -1, -1, -1, -1, -1, -1, 155,
1916 156, -1, -1, 159, -1, 161, 162, -1, -1, -1,
1917 116, 117, 118, 119, 120, 121, 122, 123, 124, 125,
1918 126, 127, 128, -1, 130, -1, 132, 133, 134, 135,
1919 136, -1, 138, 139, -1, 141, 142, 143, 3, 4,
1920 -1, -1, 7, 8, 9, -1, -1, -1, -1, -1,
1921 -1, -1, -1, 159, 19, 20, -1, 22, 23, 24,
1922 25, 26, 27, -1, -1, -1, -1, -1, -1, -1,
1923 -1, -1, -1, -1, -1, 40, 41, -1, -1, -1,
1924 -1, -1, -1, -1, -1, -1, -1, 19, -1, 54,
1925 22, -1, 24, 58, -1, -1, -1, -1, 155, 156,
1926 -1, -1, 159, -1, 161, 162, -1, -1, -1, 74,
1927 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1928 85, 86, 87, 88, 89, 90, -1, -1, 7, 8,
1929 -1, 10, 11, 12, 13, 14, 15, 16, 17, -1,
1930 19, 20, -1, 22, 23, 24, 26, 27, -1, -1,
1931 -1, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1932 125, 126, 127, 128, -1, 130, -1, 132, 133, 134,
1933 49, -1, -1, -1, -1, -1, 3, 4, -1, -1,
1934 7, 8, 9, -1, -1, 150, 118, 119, -1, -1,
1935 -1, -1, 19, 20, 159, 22, 23, 24, 25, 26,
1936 27, -1, -1, 135, 136, -1, 138, 139, -1, 141,
1937 142, 143, -1, 40, 41, -1, -1, 97, 98, 99,
1938 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
1939 110, 58, -1, -1, -1, -1, -1, -1, -1, -1,
1940 -1, -1, -1, -1, -1, -1, -1, 74, 75, 76,
1941 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1942 87, 88, 89, 90, -1, -1, -1, -1, -1, -1,
1943 -1, -1, -1, -1, -1, -1, 155, 156, -1, -1,
1944 159, -1, 161, 162, -1, -1, -1, -1, -1, 116,
1945 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
1946 127, 128, -1, 130, -1, 132, 133, 134, 7, 8,
1947 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1948 19, 20, -1, 22, 23, 24, 25, -1, -1, -1,
1949 -1, -1, 159, -1, -1, -1, -1, -1, -1, -1,
1950 -1, 40, 41, -1, -1, -1, -1, -1, -1, -1,
1951 -1, -1, -1, 7, 8, 54, 10, 11, 12, 13,
1952 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
1953 24, -1, -1, -1, -1, 74, 75, 76, 77, 78,
1954 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
1955 89, 90, -1, -1, -1, 49, -1, -1, 7, 8,
1956 -1, 10, 11, 12, 13, 14, 15, 16, 17, -1,
1957 19, 20, -1, 22, 23, 24, -1, 116, 117, 118,
1958 119, 120, 121, 122, 123, 124, 125, 126, 127, 128,
1959 39, 130, -1, 132, 133, 134, -1, -1, -1, -1,
1960 49, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1961 -1, 150, -1, 7, 8, 154, -1, 156, -1, -1,
1962 159, -1, 161, -1, 163, 19, 20, -1, 22, 23,
1963 24, 25, -1, -1, -1, -1, -1, -1, -1, -1,
1964 -1, -1, -1, -1, -1, -1, 40, 41, -1, -1,
1965 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1966 54, 155, 156, -1, -1, 159, -1, 161, 162, -1,
1967 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1968 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
1969 84, 85, 86, 87, 88, 89, 90, -1, -1, -1,
1970 -1, -1, -1, -1, -1, -1, 155, 156, -1, -1,
1971 159, -1, 161, -1, -1, -1, -1, -1, -1, -1,
1972 -1, -1, 116, 117, 118, 119, 120, 121, 122, 123,
1973 124, 125, 126, 127, 128, -1, 130, -1, 132, 133,
1974 134, -1, -1, -1, -1, -1, -1, -1, 3, 4,
1975 -1, -1, -1, -1, 9, -1, 150, -1, -1, -1,
1976 -1, -1, 156, -1, -1, 159, -1, 161, -1, 163,
1977 25, 26, 27, -1, -1, -1, -1, -1, -1, -1,
1978 -1, -1, -1, -1, -1, 40, 41, -1, -1, -1,
1979 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1980 -1, 7, 8, 58, 10, 11, 12, 13, 14, 15,
1981 16, 17, -1, 19, 20, -1, 22, 23, 24, 74,
1982 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1983 85, 86, 87, 88, 89, 90, -1, -1, -1, -1,
1984 -1, -1, -1, 49, -1, -1, -1, -1, -1, -1,
1985 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1986 -1, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1987 125, 126, 127, 128, -1, 130, -1, 132, 133, 134,
1988 7, 8, -1, 10, 11, 12, 13, 14, 15, 16,
1989 17, -1, 19, 20, -1, 22, 23, 24, -1, -1,
1990 -1, -1, -1, -1, 159, -1, -1, -1, -1, -1,
1991 -1, -1, 39, -1, -1, -1, 122, -1, -1, -1,
1992 7, 8, 49, 10, 11, 12, 13, 14, 15, 16,
1993 17, -1, 19, 20, -1, 22, 23, 24, -1, -1,
1994 -1, -1, -1, -1, -1, -1, -1, -1, -1, 155,
1995 156, -1, -1, 159, -1, 161, -1, -1, -1, -1,
1996 7, 8, 49, 10, 11, 12, 13, 14, 15, 16,
1997 17, -1, 19, 20, -1, 22, 23, 24, 7, 8,
1998 -1, 10, 11, 12, 13, 14, 15, 16, 17, -1,
1999 19, 20, 39, 22, 23, 24, -1, -1, -1, -1,
2000 -1, -1, 49, -1, -1, -1, -1, -1, -1, -1,
2001 39, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2002 49, -1, -1, -1, -1, -1, -1, -1, 155, 156,
2003 -1, -1, 159, -1, 161, 7, 8, -1, 10, 11,
2004 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
2005 22, 23, 24, -1, -1, -1, -1, -1, -1, -1,
2006 -1, -1, -1, -1, -1, -1, -1, -1, 155, 156,
2007 -1, 158, 159, -1, 161, 7, 8, 49, 10, 11,
2008 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
2009 22, 23, 24, -1, -1, -1, -1, -1, -1, -1,
2010 -1, -1, -1, -1, -1, -1, -1, -1, 155, 156,
2011 -1, -1, 159, -1, 161, -1, -1, 49, -1, -1,
2012 -1, -1, -1, -1, -1, -1, 155, 156, -1, -1,
2013 159, -1, 161, 7, 8, -1, 10, 11, 12, 13,
2014 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
2015 24, 7, 8, -1, 10, 11, 12, 13, 14, 15,
2016 16, 17, -1, 19, 20, -1, 22, 23, 24, -1,
2017 -1, -1, -1, -1, -1, 49, -1, -1, -1, -1,
2018 -1, -1, -1, 155, 156, -1, -1, 159, -1, 161,
2019 -1, 7, 8, 49, 10, 11, 12, 13, 14, 15,
2020 16, 17, -1, 19, 20, -1, 22, 23, 24, -1,
2021 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2022 -1, -1, -1, 155, 156, -1, -1, 159, -1, 161,
2023 -1, 7, 8, 49, 10, 11, 12, 13, 14, 15,
2024 16, 17, -1, 19, 20, -1, 22, 23, 24, 7,
2025 8, -1, 10, 11, 12, 13, 14, 15, 16, 17,
2026 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
2027 -1, -1, -1, 49, -1, -1, -1, -1, -1, -1,
2028 -1, 155, 156, -1, -1, 159, -1, 161, -1, -1,
2029 -1, 49, -1, -1, -1, -1, -1, -1, -1, 155,
2030 156, -1, -1, 159, -1, 161, 7, 8, -1, 10,
2031 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
2032 -1, 22, 23, 24, -1, -1, -1, -1, -1, -1,
2033 -1, -1, -1, -1, -1, -1, -1, -1, -1, 155,
2034 156, -1, -1, 159, -1, 161, -1, -1, 49, -1,
2035 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2036 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2037 -1, -1, -1, -1, -1, -1, -1, -1, -1, 155,
2038 156, -1, -1, 159, -1, 161, 36, -1, -1, -1,
2039 -1, -1, -1, -1, -1, -1, -1, 155, 156, -1,
2040 -1, 159, -1, 161, -1, -1, 56, 57, -1, -1,
2041 -1, -1, -1, -1, -1, -1, -1, -1, 68, 69,
2042 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
2043 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
2044 90, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2045 -1, -1, -1, -1, 155, 156, -1, -1, 159, -1,
2046 161, 111, 112, 113, -1, -1, 116, 117, 118, 119,
2047 120, 121, 122, 123, 124, 125, 126, 127, 128, 129,
2048 130, 131, 132, 133, 134
2049};
2050/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
2051#line 3 "/usr/share/bison.simple"
2052/* This file comes from bison-1.28. */
2053
2054/* Skeleton output parser for bison,
2055 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
2056
2057 This program is free software; you can redistribute it and/or modify
2058 it under the terms of the GNU General Public License as published by
2059 the Free Software Foundation; either version 2, or (at your option)
2060 any later version.
2061
2062 This program is distributed in the hope that it will be useful,
2063 but WITHOUT ANY WARRANTY; without even the implied warranty of
2064 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2065 GNU General Public License for more details.
2066
2067 You should have received a copy of the GNU General Public License
2068 along with this program; if not, write to the Free Software
2069 Foundation, Inc., 59 Temple Place - Suite 330,
2070 Boston, MA 02111-1307, USA. */
2071
2072/* As a special exception, when this file is copied by Bison into a
2073 Bison output file, you may use that output file without restriction.
2074 This special exception was added by the Free Software Foundation
2075 in version 1.24 of Bison. */
2076
2077/* This is the parser code that is written into each bison parser
2078 when the %semantic_parser declaration is not specified in the grammar.
2079 It was written by Richard Stallman by simplifying the hairy parser
2080 used when %semantic_parser is specified. */
2081
2082#ifndef YYSTACK_USE_ALLOCA
2083#ifdef alloca
2084#define YYSTACK_USE_ALLOCA
2085#else /* alloca not defined */
2086#ifdef __GNUC__
2087#define YYSTACK_USE_ALLOCA
2088#define alloca __builtin_alloca
2089#else /* not GNU C. */
2090#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
2091#define YYSTACK_USE_ALLOCA
2092#include <alloca.h>
2093#else /* not sparc */
2094/* We think this test detects Watcom and Microsoft C. */
2095/* This used to test MSDOS, but that is a bad idea
2096 since that symbol is in the user namespace. */
2097#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
2098#if 0 /* No need for malloc.h, which pollutes the namespace;
2099 instead, just don't use alloca. */
2100#include <malloc.h>
2101#endif
2102#else /* not MSDOS, or __TURBOC__ */
2103#if defined(_AIX)
2104/* I don't know what this was needed for, but it pollutes the namespace.
2105 So I turned it off. rms, 2 May 1997. */
2106/* #include <malloc.h> */
2107 #pragma alloca
2108#define YYSTACK_USE_ALLOCA
2109#else /* not MSDOS, or __TURBOC__, or _AIX */
2110#if 0
2111#ifdef __hpux /* <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits">haible at ilog.fr</a> says this works for HPUX 9.05 and up,
2112 and on HPUX 10. Eventually we can turn this on. */
2113#define YYSTACK_USE_ALLOCA
2114#define alloca __builtin_alloca
2115#endif /* __hpux */
2116#endif
2117#endif /* not _AIX */
2118#endif /* not MSDOS, or __TURBOC__ */
2119#endif /* not sparc */
2120#endif /* not GNU C */
2121#endif /* alloca not defined */
2122#endif /* YYSTACK_USE_ALLOCA not defined */
2123
2124#ifdef YYSTACK_USE_ALLOCA
2125#define YYSTACK_ALLOC alloca
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002126#else
Scott Michel6d1aba82008-01-30 03:10:00 +00002127#define YYSTACK_ALLOC malloc
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002128#endif
2129
Scott Michel6d1aba82008-01-30 03:10:00 +00002130/* Note: there must be only one dollar sign in this file.
2131 It is replaced by the list of actions, each action
2132 as one case of the switch. */
David Greene9145dd22007-08-01 03:59:32 +00002133
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002134#define yyerrok (yyerrstatus = 0)
2135#define yyclearin (yychar = YYEMPTY)
Scott Michel6d1aba82008-01-30 03:10:00 +00002136#define YYEMPTY -2
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002137#define YYEOF 0
2138#define YYACCEPT goto yyacceptlab
Scott Michel6d1aba82008-01-30 03:10:00 +00002139#define YYABORT goto yyabortlab
2140#define YYERROR goto yyerrlab1
2141/* Like YYERROR except do call yyerror.
2142 This remains here temporarily to ease the
2143 transition to the new meaning of YYERROR, for GCC.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002144 Once GCC version 2 has supplanted version 1, this can go. */
2145#define YYFAIL goto yyerrlab
2146#define YYRECOVERING() (!!yyerrstatus)
Scott Michel6d1aba82008-01-30 03:10:00 +00002147#define YYBACKUP(token, value) \
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002148do \
2149 if (yychar == YYEMPTY && yylen == 1) \
Scott Michel6d1aba82008-01-30 03:10:00 +00002150 { yychar = (token), yylval = (value); \
2151 yychar1 = YYTRANSLATE (yychar); \
2152 YYPOPSTACK; \
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002153 goto yybackup; \
2154 } \
2155 else \
Scott Michel6d1aba82008-01-30 03:10:00 +00002156 { yyerror ("syntax error: cannot back up"); YYERROR; } \
2157while (0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002158
2159#define YYTERROR 1
2160#define YYERRCODE 256
2161
Scott Michel6d1aba82008-01-30 03:10:00 +00002162#ifndef YYPURE
2163#define YYLEX yylex()
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002164#endif
2165
Scott Michel6d1aba82008-01-30 03:10:00 +00002166#ifdef YYPURE
2167#ifdef YYLSP_NEEDED
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002168#ifdef YYLEX_PARAM
Scott Michel6d1aba82008-01-30 03:10:00 +00002169#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002170#else
Scott Michel6d1aba82008-01-30 03:10:00 +00002171#define YYLEX yylex(&yylval, &yylloc)
2172#endif
2173#else /* not YYLSP_NEEDED */
2174#ifdef YYLEX_PARAM
2175#define YYLEX yylex(&yylval, YYLEX_PARAM)
2176#else
2177#define YYLEX yylex(&yylval)
2178#endif
2179#endif /* not YYLSP_NEEDED */
Christopher Lamb0a243582007-12-11 09:02:08 +00002180#endif
Scott Michel5a6f17b2008-01-30 02:55:46 +00002181
Scott Michel6d1aba82008-01-30 03:10:00 +00002182/* If nonreentrant, generate the variables here */
Scott Michel5a6f17b2008-01-30 02:55:46 +00002183
Scott Michel6d1aba82008-01-30 03:10:00 +00002184#ifndef YYPURE
Scott Michel5a6f17b2008-01-30 02:55:46 +00002185
Scott Michel6d1aba82008-01-30 03:10:00 +00002186int yychar; /* the lookahead symbol */
2187YYSTYPE yylval; /* the semantic value of the */
2188 /* lookahead symbol */
Scott Michel5a6f17b2008-01-30 02:55:46 +00002189
Scott Michel6d1aba82008-01-30 03:10:00 +00002190#ifdef YYLSP_NEEDED
2191YYLTYPE yylloc; /* location data for the lookahead */
2192 /* symbol */
Christopher Lamb0a243582007-12-11 09:02:08 +00002193#endif
Scott Michel5a6f17b2008-01-30 02:55:46 +00002194
Scott Michel6d1aba82008-01-30 03:10:00 +00002195int yynerrs; /* number of parse errors so far */
2196#endif /* not YYPURE */
Scott Michel5a6f17b2008-01-30 02:55:46 +00002197
Scott Michel6d1aba82008-01-30 03:10:00 +00002198#if YYDEBUG != 0
2199int yydebug; /* nonzero means print parse trace */
2200/* Since this is uninitialized, it does not stop multiple parsers
2201 from coexisting. */
Dale Johannesen3afee192007-09-07 21:07:57 +00002202#endif
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002203
Scott Michel6d1aba82008-01-30 03:10:00 +00002204/* YYINITDEPTH indicates the initial size of the parser's stacks */
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002205
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002206#ifndef YYINITDEPTH
Scott Michel6d1aba82008-01-30 03:10:00 +00002207#define YYINITDEPTH 200
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002208#endif
2209
Scott Michel6d1aba82008-01-30 03:10:00 +00002210/* YYMAXDEPTH is the maximum size the stacks can grow to
2211 (effective only if the built-in stack extension method is used). */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002212
Scott Michel6d1aba82008-01-30 03:10:00 +00002213#if YYMAXDEPTH == 0
2214#undef YYMAXDEPTH
2215#endif
David Greene9145dd22007-08-01 03:59:32 +00002216
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002217#ifndef YYMAXDEPTH
Scott Michel6d1aba82008-01-30 03:10:00 +00002218#define YYMAXDEPTH 10000
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002219#endif
2220
Scott Michel6d1aba82008-01-30 03:10:00 +00002221/* Define __yy_memcpy. Note that the size argument
2222 should be passed with type unsigned int, because that is what the non-GCC
2223 definitions require. With GCC, __builtin_memcpy takes an arg
2224 of type size_t, but it can handle unsigned int. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002225
Scott Michel6d1aba82008-01-30 03:10:00 +00002226#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
2227#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
2228#else /* not GNU C or C++ */
2229#ifndef __cplusplus
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002230
Scott Michel6d1aba82008-01-30 03:10:00 +00002231/* This is the most reliable way to avoid incompatibilities
2232 in available built-in functions on various systems. */
Scott Michel5a6f17b2008-01-30 02:55:46 +00002233static void
Scott Michel6d1aba82008-01-30 03:10:00 +00002234__yy_memcpy (to, from, count)
2235 char *to;
2236 char *from;
2237 unsigned int count;
Scott Michel5a6f17b2008-01-30 02:55:46 +00002238{
Scott Michel6d1aba82008-01-30 03:10:00 +00002239 register char *f = from;
2240 register char *t = to;
2241 register int i = count;
Scott Michel5a6f17b2008-01-30 02:55:46 +00002242
Scott Michel6d1aba82008-01-30 03:10:00 +00002243 while (i-- > 0)
2244 *t++ = *f++;
Scott Michel5a6f17b2008-01-30 02:55:46 +00002245}
Scott Michel5a6f17b2008-01-30 02:55:46 +00002246
Scott Michel6d1aba82008-01-30 03:10:00 +00002247#else /* __cplusplus */
2248
2249/* This is the most reliable way to avoid incompatibilities
2250 in available built-in functions on various systems. */
2251static void
2252__yy_memcpy (char *to, char *from, unsigned int count)
2253{
2254 register char *t = to;
2255 register char *f = from;
2256 register int i = count;
2257
2258 while (i-- > 0)
2259 *t++ = *f++;
2260}
2261
2262#endif
2263#endif
2264
2265#line 217 "/usr/share/bison.simple"
2266
2267/* The user can define YYPARSE_PARAM as the name of an argument to be passed
2268 into yyparse. The argument should have type void *.
2269 It should actually point to an object.
2270 Grammar actions can access the variable by casting it
2271 to the proper pointer type. */
Scott Michel5a6f17b2008-01-30 02:55:46 +00002272
2273#ifdef YYPARSE_PARAM
Scott Michel6d1aba82008-01-30 03:10:00 +00002274#ifdef __cplusplus
2275#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
2276#define YYPARSE_PARAM_DECL
2277#else /* not __cplusplus */
2278#define YYPARSE_PARAM_ARG YYPARSE_PARAM
2279#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
2280#endif /* not __cplusplus */
2281#else /* not YYPARSE_PARAM */
2282#define YYPARSE_PARAM_ARG
2283#define YYPARSE_PARAM_DECL
2284#endif /* not YYPARSE_PARAM */
2285
2286/* Prevent warning if -Wstrict-prototypes. */
2287#ifdef __GNUC__
2288#ifdef YYPARSE_PARAM
2289int yyparse (void *);
Scott Michel5a6f17b2008-01-30 02:55:46 +00002290#else
David Greene48556392007-09-04 18:46:50 +00002291int yyparse (void);
Christopher Lamb0a243582007-12-11 09:02:08 +00002292#endif
2293#endif
Scott Michel6d1aba82008-01-30 03:10:00 +00002294
2295int
2296yyparse(YYPARSE_PARAM_ARG)
2297 YYPARSE_PARAM_DECL
Scott Michel5a6f17b2008-01-30 02:55:46 +00002298{
Scott Michel6d1aba82008-01-30 03:10:00 +00002299 register int yystate;
2300 register int yyn;
2301 register short *yyssp;
2302 register YYSTYPE *yyvsp;
2303 int yyerrstatus; /* number of tokens to shift before error messages enabled */
2304 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
2305
2306 short yyssa[YYINITDEPTH]; /* the state stack */
2307 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
2308
2309 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
2310 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
2311
2312#ifdef YYLSP_NEEDED
2313 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
2314 YYLTYPE *yyls = yylsa;
2315 YYLTYPE *yylsp;
2316
2317#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
2318#else
2319#define YYPOPSTACK (yyvsp--, yyssp--)
Christopher Lamb0a243582007-12-11 09:02:08 +00002320#endif
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002321
Scott Michel6d1aba82008-01-30 03:10:00 +00002322 int yystacksize = YYINITDEPTH;
2323 int yyfree_stacks = 0;
Scott Michel5a6f17b2008-01-30 02:55:46 +00002324
Scott Michel6d1aba82008-01-30 03:10:00 +00002325#ifdef YYPURE
2326 int yychar;
2327 YYSTYPE yylval;
2328 int yynerrs;
2329#ifdef YYLSP_NEEDED
2330 YYLTYPE yylloc;
2331#endif
2332#endif
Scott Michel5a6f17b2008-01-30 02:55:46 +00002333
Scott Michel6d1aba82008-01-30 03:10:00 +00002334 YYSTYPE yyval; /* the variable used to return */
2335 /* semantic values from the action */
2336 /* routines */
Scott Michel5a6f17b2008-01-30 02:55:46 +00002337
Scott Michel6d1aba82008-01-30 03:10:00 +00002338 int yylen;
Scott Michel5a6f17b2008-01-30 02:55:46 +00002339
Scott Michel6d1aba82008-01-30 03:10:00 +00002340#if YYDEBUG != 0
2341 if (yydebug)
2342 fprintf(stderr, "Starting parse\n");
2343#endif
Scott Michel5a6f17b2008-01-30 02:55:46 +00002344
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002345 yystate = 0;
2346 yyerrstatus = 0;
2347 yynerrs = 0;
2348 yychar = YYEMPTY; /* Cause a token to be read. */
2349
2350 /* Initialize stack pointers.
2351 Waste one element of value and location stack
2352 so that they stay on the same level as the state stack.
2353 The wasted elements are never initialized. */
2354
Scott Michel6d1aba82008-01-30 03:10:00 +00002355 yyssp = yyss - 1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002356 yyvsp = yyvs;
Scott Michel6d1aba82008-01-30 03:10:00 +00002357#ifdef YYLSP_NEEDED
2358 yylsp = yyls;
2359#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002360
Scott Michel6d1aba82008-01-30 03:10:00 +00002361/* Push a new state, which is found in yystate . */
2362/* In all cases, when you get here, the value and location stacks
2363 have just been pushed. so pushing a state here evens the stacks. */
2364yynewstate:
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002365
Scott Michel6d1aba82008-01-30 03:10:00 +00002366 *++yyssp = yystate;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002367
Scott Michel6d1aba82008-01-30 03:10:00 +00002368 if (yyssp >= yyss + yystacksize - 1)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002369 {
Scott Michel6d1aba82008-01-30 03:10:00 +00002370 /* Give user a chance to reallocate the stack */
2371 /* Use copies of these so that the &'s don't force the real ones into memory. */
2372 YYSTYPE *yyvs1 = yyvs;
2373 short *yyss1 = yyss;
2374#ifdef YYLSP_NEEDED
2375 YYLTYPE *yyls1 = yyls;
2376#endif
2377
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002378 /* Get the current used size of the three stacks, in elements. */
Scott Michel6d1aba82008-01-30 03:10:00 +00002379 int size = yyssp - yyss + 1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002380
2381#ifdef yyoverflow
Scott Michel6d1aba82008-01-30 03:10:00 +00002382 /* Each stack pointer address is followed by the size of
2383 the data in use in that stack, in bytes. */
2384#ifdef YYLSP_NEEDED
2385 /* This used to be a conditional around just the two extra args,
2386 but that might be undefined if yyoverflow is a macro. */
2387 yyoverflow("parser stack overflow",
2388 &yyss1, size * sizeof (*yyssp),
2389 &yyvs1, size * sizeof (*yyvsp),
2390 &yyls1, size * sizeof (*yylsp),
2391 &yystacksize);
2392#else
2393 yyoverflow("parser stack overflow",
2394 &yyss1, size * sizeof (*yyssp),
2395 &yyvs1, size * sizeof (*yyvsp),
2396 &yystacksize);
2397#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002398
Scott Michel6d1aba82008-01-30 03:10:00 +00002399 yyss = yyss1; yyvs = yyvs1;
2400#ifdef YYLSP_NEEDED
2401 yyls = yyls1;
2402#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002403#else /* no yyoverflow */
2404 /* Extend the stack our own way. */
Scott Michel6d1aba82008-01-30 03:10:00 +00002405 if (yystacksize >= YYMAXDEPTH)
2406 {
2407 yyerror("parser stack overflow");
2408 if (yyfree_stacks)
2409 {
2410 free (yyss);
2411 free (yyvs);
2412#ifdef YYLSP_NEEDED
2413 free (yyls);
2414#endif
2415 }
2416 return 2;
2417 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002418 yystacksize *= 2;
Scott Michel6d1aba82008-01-30 03:10:00 +00002419 if (yystacksize > YYMAXDEPTH)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002420 yystacksize = YYMAXDEPTH;
Scott Michel6d1aba82008-01-30 03:10:00 +00002421#ifndef YYSTACK_USE_ALLOCA
2422 yyfree_stacks = 1;
2423#endif
2424 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
2425 __yy_memcpy ((char *)yyss, (char *)yyss1,
2426 size * (unsigned int) sizeof (*yyssp));
2427 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
2428 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
2429 size * (unsigned int) sizeof (*yyvsp));
2430#ifdef YYLSP_NEEDED
2431 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
2432 __yy_memcpy ((char *)yyls, (char *)yyls1,
2433 size * (unsigned int) sizeof (*yylsp));
2434#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002435#endif /* no yyoverflow */
2436
Scott Michel6d1aba82008-01-30 03:10:00 +00002437 yyssp = yyss + size - 1;
2438 yyvsp = yyvs + size - 1;
2439#ifdef YYLSP_NEEDED
2440 yylsp = yyls + size - 1;
2441#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002442
Scott Michel6d1aba82008-01-30 03:10:00 +00002443#if YYDEBUG != 0
2444 if (yydebug)
2445 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2446#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002447
Scott Michel6d1aba82008-01-30 03:10:00 +00002448 if (yyssp >= yyss + yystacksize - 1)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002449 YYABORT;
2450 }
2451
Scott Michel6d1aba82008-01-30 03:10:00 +00002452#if YYDEBUG != 0
2453 if (yydebug)
2454 fprintf(stderr, "Entering state %d\n", yystate);
2455#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002456
2457 goto yybackup;
Scott Michel6d1aba82008-01-30 03:10:00 +00002458 yybackup:
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002459
Scott Michel6d1aba82008-01-30 03:10:00 +00002460/* Do appropriate processing given the current state. */
2461/* Read a lookahead token if we need one and don't already have one. */
2462/* yyresume: */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002463
Scott Michel6d1aba82008-01-30 03:10:00 +00002464 /* First try to decide what to do without reference to lookahead token. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002465
2466 yyn = yypact[yystate];
Scott Michel6d1aba82008-01-30 03:10:00 +00002467 if (yyn == YYFLAG)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002468 goto yydefault;
2469
Scott Michel6d1aba82008-01-30 03:10:00 +00002470 /* Not known => get a lookahead token if don't already have one. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002471
Scott Michel6d1aba82008-01-30 03:10:00 +00002472 /* yychar is either YYEMPTY or YYEOF
2473 or a valid token in external form. */
2474
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002475 if (yychar == YYEMPTY)
2476 {
Scott Michel6d1aba82008-01-30 03:10:00 +00002477#if YYDEBUG != 0
2478 if (yydebug)
2479 fprintf(stderr, "Reading a token: ");
2480#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002481 yychar = YYLEX;
2482 }
2483
Scott Michel6d1aba82008-01-30 03:10:00 +00002484 /* Convert token to internal form (in yychar1) for indexing tables with */
2485
2486 if (yychar <= 0) /* This means end of input. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002487 {
Scott Michel6d1aba82008-01-30 03:10:00 +00002488 yychar1 = 0;
2489 yychar = YYEOF; /* Don't call YYLEX any more */
2490
2491#if YYDEBUG != 0
2492 if (yydebug)
2493 fprintf(stderr, "Now at end of input.\n");
2494#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002495 }
2496 else
2497 {
Scott Michel6d1aba82008-01-30 03:10:00 +00002498 yychar1 = YYTRANSLATE(yychar);
2499
2500#if YYDEBUG != 0
2501 if (yydebug)
2502 {
2503 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2504 /* Give the individual parser a way to print the precise meaning
2505 of a token, for further debugging info. */
2506#ifdef YYPRINT
2507 YYPRINT (stderr, yychar, yylval);
2508#endif
2509 fprintf (stderr, ")\n");
2510 }
2511#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002512 }
2513
Scott Michel6d1aba82008-01-30 03:10:00 +00002514 yyn += yychar1;
2515 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002516 goto yydefault;
Scott Michel6d1aba82008-01-30 03:10:00 +00002517
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002518 yyn = yytable[yyn];
Scott Michel6d1aba82008-01-30 03:10:00 +00002519
2520 /* yyn is what to do for this token type in this state.
2521 Negative => reduce, -yyn is rule number.
2522 Positive => shift, yyn is new state.
2523 New state is final state => don't bother to shift,
2524 just return success.
2525 0, or most negative number => error. */
2526
2527 if (yyn < 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002528 {
Scott Michel6d1aba82008-01-30 03:10:00 +00002529 if (yyn == YYFLAG)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002530 goto yyerrlab;
2531 yyn = -yyn;
2532 goto yyreduce;
2533 }
Scott Michel6d1aba82008-01-30 03:10:00 +00002534 else if (yyn == 0)
2535 goto yyerrlab;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002536
2537 if (yyn == YYFINAL)
2538 YYACCEPT;
2539
Scott Michel6d1aba82008-01-30 03:10:00 +00002540 /* Shift the lookahead token. */
Dale Johannesen3afee192007-09-07 21:07:57 +00002541
Scott Michel6d1aba82008-01-30 03:10:00 +00002542#if YYDEBUG != 0
2543 if (yydebug)
2544 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2545#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002546
Scott Michel6d1aba82008-01-30 03:10:00 +00002547 /* Discard the token being shifted unless it is eof. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002548 if (yychar != YYEOF)
2549 yychar = YYEMPTY;
2550
Scott Michel5a6f17b2008-01-30 02:55:46 +00002551 *++yyvsp = yylval;
Scott Michel6d1aba82008-01-30 03:10:00 +00002552#ifdef YYLSP_NEEDED
2553 *++yylsp = yylloc;
2554#endif
Scott Michel5a6f17b2008-01-30 02:55:46 +00002555
Scott Michel6d1aba82008-01-30 03:10:00 +00002556 /* count tokens shifted since error; after three, turn off error status. */
2557 if (yyerrstatus) yyerrstatus--;
2558
2559 yystate = yyn;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002560 goto yynewstate;
2561
Scott Michel6d1aba82008-01-30 03:10:00 +00002562/* Do the default action for the current state. */
Scott Michel5a6f17b2008-01-30 02:55:46 +00002563yydefault:
Scott Michel6d1aba82008-01-30 03:10:00 +00002564
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002565 yyn = yydefact[yystate];
2566 if (yyn == 0)
2567 goto yyerrlab;
2568
Scott Michel6d1aba82008-01-30 03:10:00 +00002569/* Do a reduction. yyn is the number of a rule to reduce with. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002570yyreduce:
2571 yylen = yyr2[yyn];
Scott Michel6d1aba82008-01-30 03:10:00 +00002572 if (yylen > 0)
2573 yyval = yyvsp[1-yylen]; /* implement default value of the action */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002574
Scott Michel6d1aba82008-01-30 03:10:00 +00002575#if YYDEBUG != 0
2576 if (yydebug)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002577 {
Scott Michel6d1aba82008-01-30 03:10:00 +00002578 int i;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002579
Scott Michel6d1aba82008-01-30 03:10:00 +00002580 fprintf (stderr, "Reducing via rule %d (line %d), ",
2581 yyn, yyrline[yyn]);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002582
Scott Michel6d1aba82008-01-30 03:10:00 +00002583 /* Print the symbols being reduced, and their result. */
2584 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2585 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2586 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2587 }
2588#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002589
2590
Scott Michel6d1aba82008-01-30 03:10:00 +00002591 switch (yyn) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002592
Scott Michel6d1aba82008-01-30 03:10:00 +00002593case 28:
2594#line 1113 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2595{ yyval.IPredicate = ICmpInst::ICMP_EQ; ;
2596 break;}
2597case 29:
2598#line 1113 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2599{ yyval.IPredicate = ICmpInst::ICMP_NE; ;
2600 break;}
2601case 30:
2602#line 1114 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2603{ yyval.IPredicate = ICmpInst::ICMP_SLT; ;
2604 break;}
2605case 31:
2606#line 1114 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2607{ yyval.IPredicate = ICmpInst::ICMP_SGT; ;
2608 break;}
2609case 32:
2610#line 1115 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2611{ yyval.IPredicate = ICmpInst::ICMP_SLE; ;
2612 break;}
2613case 33:
2614#line 1115 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2615{ yyval.IPredicate = ICmpInst::ICMP_SGE; ;
2616 break;}
2617case 34:
2618#line 1116 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2619{ yyval.IPredicate = ICmpInst::ICMP_ULT; ;
2620 break;}
2621case 35:
2622#line 1116 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2623{ yyval.IPredicate = ICmpInst::ICMP_UGT; ;
2624 break;}
2625case 36:
2626#line 1117 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2627{ yyval.IPredicate = ICmpInst::ICMP_ULE; ;
2628 break;}
2629case 37:
2630#line 1117 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2631{ yyval.IPredicate = ICmpInst::ICMP_UGE; ;
2632 break;}
2633case 38:
2634#line 1121 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2635{ yyval.FPredicate = FCmpInst::FCMP_OEQ; ;
2636 break;}
2637case 39:
2638#line 1121 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2639{ yyval.FPredicate = FCmpInst::FCMP_ONE; ;
2640 break;}
2641case 40:
2642#line 1122 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2643{ yyval.FPredicate = FCmpInst::FCMP_OLT; ;
2644 break;}
2645case 41:
2646#line 1122 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2647{ yyval.FPredicate = FCmpInst::FCMP_OGT; ;
2648 break;}
2649case 42:
2650#line 1123 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2651{ yyval.FPredicate = FCmpInst::FCMP_OLE; ;
2652 break;}
2653case 43:
2654#line 1123 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2655{ yyval.FPredicate = FCmpInst::FCMP_OGE; ;
2656 break;}
2657case 44:
2658#line 1124 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2659{ yyval.FPredicate = FCmpInst::FCMP_ORD; ;
2660 break;}
2661case 45:
2662#line 1124 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2663{ yyval.FPredicate = FCmpInst::FCMP_UNO; ;
2664 break;}
2665case 46:
2666#line 1125 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2667{ yyval.FPredicate = FCmpInst::FCMP_UEQ; ;
2668 break;}
2669case 47:
2670#line 1125 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2671{ yyval.FPredicate = FCmpInst::FCMP_UNE; ;
2672 break;}
2673case 48:
2674#line 1126 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2675{ yyval.FPredicate = FCmpInst::FCMP_ULT; ;
2676 break;}
2677case 49:
2678#line 1126 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2679{ yyval.FPredicate = FCmpInst::FCMP_UGT; ;
2680 break;}
2681case 50:
2682#line 1127 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2683{ yyval.FPredicate = FCmpInst::FCMP_ULE; ;
2684 break;}
2685case 51:
2686#line 1127 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2687{ yyval.FPredicate = FCmpInst::FCMP_UGE; ;
2688 break;}
2689case 52:
2690#line 1128 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2691{ yyval.FPredicate = FCmpInst::FCMP_TRUE; ;
2692 break;}
2693case 53:
2694#line 1129 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2695{ yyval.FPredicate = FCmpInst::FCMP_FALSE; ;
2696 break;}
2697case 64:
2698#line 1138 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2699{ yyval.StrVal = 0; ;
2700 break;}
2701case 65:
2702#line 1140 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2703{ yyval.UIntVal=yyvsp[-1].UInt64Val; ;
2704 break;}
2705case 66:
2706#line 1141 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2707{ yyval.UIntVal=0; ;
2708 break;}
2709case 67:
2710#line 1145 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2711{
2712 yyval.StrVal = yyvsp[-1].StrVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002713 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00002714 ;
2715 break;}
2716case 68:
2717#line 1149 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2718{
2719 yyval.StrVal = 0;
Christopher Lamb668d9a02007-12-12 08:45:45 +00002720 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00002721 ;
2722 break;}
2723case 72:
2724#line 1157 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2725{
2726 yyval.StrVal = 0;
Christopher Lamb668d9a02007-12-12 08:45:45 +00002727 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00002728 ;
2729 break;}
2730case 73:
2731#line 1162 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2732{
2733 yyval.StrVal = yyvsp[-1].StrVal;
Christopher Lamb668d9a02007-12-12 08:45:45 +00002734 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00002735 ;
2736 break;}
2737case 74:
2738#line 1168 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2739{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2740 break;}
2741case 75:
2742#line 1169 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2743{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2744 break;}
2745case 76:
2746#line 1170 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2747{ yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2748 break;}
2749case 77:
2750#line 1171 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2751{ yyval.Linkage = GlobalValue::AppendingLinkage; ;
2752 break;}
2753case 78:
2754#line 1172 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2755{ yyval.Linkage = GlobalValue::DLLExportLinkage; ;
2756 break;}
2757case 79:
2758#line 1176 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2759{ yyval.Linkage = GlobalValue::DLLImportLinkage; ;
2760 break;}
2761case 80:
2762#line 1177 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2763{ yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;
2764 break;}
2765case 81:
2766#line 1178 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2767{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2768 break;}
2769case 82:
2770#line 1182 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2771{ yyval.Visibility = GlobalValue::DefaultVisibility; ;
2772 break;}
2773case 83:
2774#line 1183 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2775{ yyval.Visibility = GlobalValue::DefaultVisibility; ;
2776 break;}
2777case 84:
2778#line 1184 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2779{ yyval.Visibility = GlobalValue::HiddenVisibility; ;
2780 break;}
2781case 85:
2782#line 1185 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2783{ yyval.Visibility = GlobalValue::ProtectedVisibility; ;
2784 break;}
2785case 86:
2786#line 1189 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2787{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2788 break;}
2789case 87:
2790#line 1190 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2791{ yyval.Linkage = GlobalValue::DLLImportLinkage; ;
2792 break;}
2793case 88:
2794#line 1191 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2795{ yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;
2796 break;}
2797case 89:
2798#line 1195 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2799{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2800 break;}
2801case 90:
2802#line 1196 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2803{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2804 break;}
2805case 91:
2806#line 1197 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2807{ yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2808 break;}
2809case 92:
2810#line 1198 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2811{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2812 break;}
2813case 93:
2814#line 1199 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2815{ yyval.Linkage = GlobalValue::DLLExportLinkage; ;
2816 break;}
2817case 94:
2818#line 1203 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2819{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2820 break;}
2821case 95:
2822#line 1204 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2823{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2824 break;}
2825case 96:
2826#line 1205 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2827{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2828 break;}
2829case 97:
2830#line 1208 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2831{ yyval.UIntVal = CallingConv::C; ;
2832 break;}
2833case 98:
2834#line 1209 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2835{ yyval.UIntVal = CallingConv::C; ;
2836 break;}
2837case 99:
2838#line 1210 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2839{ yyval.UIntVal = CallingConv::Fast; ;
2840 break;}
2841case 100:
2842#line 1211 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2843{ yyval.UIntVal = CallingConv::Cold; ;
2844 break;}
2845case 101:
2846#line 1212 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2847{ yyval.UIntVal = CallingConv::X86_StdCall; ;
2848 break;}
2849case 102:
2850#line 1213 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2851{ yyval.UIntVal = CallingConv::X86_FastCall; ;
2852 break;}
2853case 103:
2854#line 1214 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2855{
2856 if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002857 GEN_ERROR("Calling conv too large");
Scott Michel6d1aba82008-01-30 03:10:00 +00002858 yyval.UIntVal = yyvsp[0].UInt64Val;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002859 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00002860 ;
2861 break;}
2862case 104:
2863#line 1221 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2864{ yyval.ParamAttrs = ParamAttr::ZExt; ;
2865 break;}
2866case 105:
2867#line 1222 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2868{ yyval.ParamAttrs = ParamAttr::ZExt; ;
2869 break;}
2870case 106:
2871#line 1223 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2872{ yyval.ParamAttrs = ParamAttr::SExt; ;
2873 break;}
2874case 107:
2875#line 1224 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2876{ yyval.ParamAttrs = ParamAttr::SExt; ;
2877 break;}
2878case 108:
2879#line 1225 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2880{ yyval.ParamAttrs = ParamAttr::InReg; ;
2881 break;}
2882case 109:
2883#line 1226 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2884{ yyval.ParamAttrs = ParamAttr::StructRet; ;
2885 break;}
2886case 110:
2887#line 1227 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2888{ yyval.ParamAttrs = ParamAttr::NoAlias; ;
2889 break;}
2890case 111:
2891#line 1228 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2892{ yyval.ParamAttrs = ParamAttr::ByVal; ;
2893 break;}
2894case 112:
2895#line 1229 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2896{ yyval.ParamAttrs = ParamAttr::Nest; ;
2897 break;}
2898case 113:
2899#line 1232 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2900{ yyval.ParamAttrs = ParamAttr::None; ;
2901 break;}
2902case 114:
2903#line 1233 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2904{
2905 yyval.ParamAttrs = yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs;
2906 ;
2907 break;}
2908case 115:
2909#line 1238 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2910{ yyval.ParamAttrs = ParamAttr::NoReturn; ;
2911 break;}
2912case 116:
2913#line 1239 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2914{ yyval.ParamAttrs = ParamAttr::NoUnwind; ;
2915 break;}
2916case 117:
2917#line 1240 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2918{ yyval.ParamAttrs = ParamAttr::ZExt; ;
2919 break;}
2920case 118:
2921#line 1241 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2922{ yyval.ParamAttrs = ParamAttr::SExt; ;
2923 break;}
2924case 119:
2925#line 1242 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2926{ yyval.ParamAttrs = ParamAttr::ReadNone; ;
2927 break;}
2928case 120:
2929#line 1243 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2930{ yyval.ParamAttrs = ParamAttr::ReadOnly; ;
2931 break;}
2932case 121:
2933#line 1246 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2934{ yyval.ParamAttrs = ParamAttr::None; ;
2935 break;}
2936case 122:
2937#line 1247 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2938{
2939 yyval.ParamAttrs = yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs;
2940 ;
2941 break;}
2942case 123:
2943#line 1252 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2944{ yyval.StrVal = 0; ;
2945 break;}
2946case 124:
2947#line 1253 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2948{
2949 yyval.StrVal = yyvsp[0].StrVal;
2950 ;
2951 break;}
2952case 125:
2953#line 1260 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2954{ yyval.UIntVal = 0; ;
2955 break;}
2956case 126:
2957#line 1261 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2958{
2959 yyval.UIntVal = yyvsp[0].UInt64Val;
2960 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002961 GEN_ERROR("Alignment must be a power of two");
2962 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00002963;
2964 break;}
2965case 127:
2966#line 1267 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2967{ yyval.UIntVal = 0; ;
2968 break;}
2969case 128:
2970#line 1268 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2971{
2972 yyval.UIntVal = yyvsp[0].UInt64Val;
2973 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
Christopher Lamb668d9a02007-12-12 08:45:45 +00002974 GEN_ERROR("Alignment must be a power of two");
2975 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00002976;
2977 break;}
2978case 129:
2979#line 1277 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2980{
2981 for (unsigned i = 0, e = yyvsp[0].StrVal->length(); i != e; ++i)
2982 if ((*yyvsp[0].StrVal)[i] == '"' || (*yyvsp[0].StrVal)[i] == '\\')
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002983 GEN_ERROR("Invalid character in section name");
Scott Michel6d1aba82008-01-30 03:10:00 +00002984 yyval.StrVal = yyvsp[0].StrVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002985 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00002986;
2987 break;}
2988case 130:
2989#line 1285 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2990{ yyval.StrVal = 0; ;
2991 break;}
2992case 131:
2993#line 1286 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2994{ yyval.StrVal = yyvsp[0].StrVal; ;
2995 break;}
2996case 132:
2997#line 1291 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2998{;
2999 break;}
3000case 133:
3001#line 1292 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3002{;
3003 break;}
3004case 134:
3005#line 1293 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3006{
3007 CurGV->setSection(*yyvsp[0].StrVal);
3008 delete yyvsp[0].StrVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003009 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003010 ;
3011 break;}
3012case 135:
3013#line 1298 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3014{
3015 if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003016 GEN_ERROR("Alignment must be a power of two");
Scott Michel6d1aba82008-01-30 03:10:00 +00003017 CurGV->setAlignment(yyvsp[0].UInt64Val);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003018 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003019 ;
3020 break;}
3021case 143:
3022#line 1314 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3023{
3024 yyval.TypeVal = new PATypeHolder(OpaqueType::get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003025 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003026 ;
3027 break;}
3028case 144:
3029#line 1318 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3030{
3031 yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003032 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003033 ;
3034 break;}
3035case 145:
3036#line 1322 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3037{ // Pointer type?
3038 if (*yyvsp[-2].TypeVal == Type::LabelTy)
Christopher Lamb668d9a02007-12-12 08:45:45 +00003039 GEN_ERROR("Cannot form a pointer to a basic block");
Scott Michel6d1aba82008-01-30 03:10:00 +00003040 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-2].TypeVal, yyvsp[-1].UIntVal)));
3041 delete yyvsp[-2].TypeVal;
Christopher Lamb668d9a02007-12-12 08:45:45 +00003042 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003043 ;
3044 break;}
3045case 146:
3046#line 1329 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3047{ // Named types are also simple types...
3048 const Type* tmp = getTypeVal(yyvsp[0].ValIDVal);
Christopher Lamb0a243582007-12-11 09:02:08 +00003049 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003050 yyval.TypeVal = new PATypeHolder(tmp);
3051 ;
3052 break;}
3053case 147:
3054#line 1334 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3055{ // Type UpReference
3056 if (yyvsp[0].UInt64Val > (uint64_t)~0U) GEN_ERROR("Value out of range");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003057 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Scott Michel6d1aba82008-01-30 03:10:00 +00003058 UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector...
3059 yyval.TypeVal = new PATypeHolder(OT);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003060 UR_OUT("New Upreference!\n");
3061 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003062 ;
3063 break;}
3064case 148:
3065#line 1342 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3066{
Duncan Sandsf5588dc2007-11-27 13:23:08 +00003067 // Allow but ignore attributes on function types; this permits auto-upgrade.
3068 // FIXME: remove in LLVM 3.0.
Scott Michel6d1aba82008-01-30 03:10:00 +00003069 const Type* RetTy = *yyvsp[-4].TypeVal;
Anton Korobeynikove286f6d2007-12-03 21:01:29 +00003070 if (!(RetTy->isFirstClassType() || RetTy == Type::VoidTy ||
3071 isa<OpaqueType>(RetTy)))
Anton Korobeynikov0cdd2692007-12-03 19:17:47 +00003072 GEN_ERROR("LLVM Functions cannot return aggregates");
Anton Korobeynikove286f6d2007-12-03 21:01:29 +00003073
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003074 std::vector<const Type*> Params;
Scott Michel6d1aba82008-01-30 03:10:00 +00003075 TypeWithAttrsList::iterator I = yyvsp[-2].TypeWithAttrsList->begin(), E = yyvsp[-2].TypeWithAttrsList->end();
Duncan Sandsf5588dc2007-11-27 13:23:08 +00003076 for (; I != E; ++I ) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003077 const Type *Ty = I->Ty->get();
3078 Params.push_back(Ty);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003079 }
Anton Korobeynikove286f6d2007-12-03 21:01:29 +00003080
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003081 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3082 if (isVarArg) Params.pop_back();
3083
Anton Korobeynikove286f6d2007-12-03 21:01:29 +00003084 for (unsigned i = 0; i != Params.size(); ++i)
3085 if (!(Params[i]->isFirstClassType() || isa<OpaqueType>(Params[i])))
3086 GEN_ERROR("Function arguments must be value types!");
3087
3088 CHECK_FOR_ERROR
3089
Anton Korobeynikov0cdd2692007-12-03 19:17:47 +00003090 FunctionType *FT = FunctionType::get(RetTy, Params, isVarArg);
Scott Michel6d1aba82008-01-30 03:10:00 +00003091 delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list
3092 delete yyvsp[-4].TypeVal; // Delete the return type handle
3093 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003094 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003095 ;
3096 break;}
3097case 149:
3098#line 1372 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3099{
Duncan Sandsf5588dc2007-11-27 13:23:08 +00003100 // Allow but ignore attributes on function types; this permits auto-upgrade.
3101 // FIXME: remove in LLVM 3.0.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003102 std::vector<const Type*> Params;
Scott Michel6d1aba82008-01-30 03:10:00 +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
Scott Michel6d1aba82008-01-30 03:10:00 +00003118 FunctionType *FT = FunctionType::get(yyvsp[-4].PrimType, Params, isVarArg);
3119 delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list
3120 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003121 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003122 ;
3123 break;}
3124case 150:
3125#line 1397 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3126{ // Sized array type?
3127 yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
3128 delete yyvsp[-1].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003129 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003130 ;
3131 break;}
3132case 151:
3133#line 1402 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3134{ // Vector type?
3135 const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
3136 if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003137 GEN_ERROR("Unsigned result not equal to signed result");
3138 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
3139 GEN_ERROR("Element type of a VectorType must be primitive");
Scott Michel6d1aba82008-01-30 03:10:00 +00003140 yyval.TypeVal = new PATypeHolder(HandleUpRefs(VectorType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
3141 delete yyvsp[-1].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003142 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003143 ;
3144 break;}
3145case 152:
3146#line 1412 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3147{ // Structure type?
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003148 std::vector<const Type*> Elements;
Scott Michel6d1aba82008-01-30 03:10:00 +00003149 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
3150 E = yyvsp[-1].TypeList->end(); I != E; ++I)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003151 Elements.push_back(*I);
3152
Scott Michel6d1aba82008-01-30 03:10:00 +00003153 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
3154 delete yyvsp[-1].TypeList;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003155 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003156 ;
3157 break;}
3158case 153:
3159#line 1422 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3160{ // Empty structure type?
3161 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003162 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003163 ;
3164 break;}
3165case 154:
3166#line 1426 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3167{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003168 std::vector<const Type*> Elements;
Scott Michel6d1aba82008-01-30 03:10:00 +00003169 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-2].TypeList->begin(),
3170 E = yyvsp[-2].TypeList->end(); I != E; ++I)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003171 Elements.push_back(*I);
3172
Scott Michel6d1aba82008-01-30 03:10:00 +00003173 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
3174 delete yyvsp[-2].TypeList;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003175 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003176 ;
3177 break;}
3178case 155:
3179#line 1436 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3180{ // Empty structure type?
3181 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003182 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003183 ;
3184 break;}
3185case 156:
3186#line 1443 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3187{
Duncan Sandsf5588dc2007-11-27 13:23:08 +00003188 // Allow but ignore attributes on function types; this permits auto-upgrade.
3189 // FIXME: remove in LLVM 3.0.
Scott Michel6d1aba82008-01-30 03:10:00 +00003190 yyval.TypeWithAttrs.Ty = yyvsp[-1].TypeVal;
3191 yyval.TypeWithAttrs.Attrs = ParamAttr::None;
3192 ;
3193 break;}
3194case 157:
3195#line 1452 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3196{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003197 if (!UpRefs.empty())
Scott Michel6d1aba82008-01-30 03:10:00 +00003198 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
3199 if (!(*yyvsp[0].TypeVal)->isFirstClassType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003200 GEN_ERROR("LLVM functions cannot return aggregate types");
Scott Michel6d1aba82008-01-30 03:10:00 +00003201 yyval.TypeVal = yyvsp[0].TypeVal;
3202 ;
3203 break;}
3204case 158:
3205#line 1459 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3206{
3207 yyval.TypeVal = new PATypeHolder(Type::VoidTy);
3208 ;
3209 break;}
3210case 159:
3211#line 1464 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3212{
3213 yyval.TypeWithAttrsList = new TypeWithAttrsList();
3214 yyval.TypeWithAttrsList->push_back(yyvsp[0].TypeWithAttrs);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003215 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003216 ;
3217 break;}
3218case 160:
3219#line 1469 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3220{
3221 (yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList)->push_back(yyvsp[0].TypeWithAttrs);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003222 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003223 ;
3224 break;}
3225case 162:
3226#line 1477 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3227{
3228 yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003229 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
3230 TWA.Ty = new PATypeHolder(Type::VoidTy);
Scott Michel6d1aba82008-01-30 03:10:00 +00003231 yyval.TypeWithAttrsList->push_back(TWA);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003232 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003233 ;
3234 break;}
3235case 163:
3236#line 1484 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3237{
3238 yyval.TypeWithAttrsList = new TypeWithAttrsList;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003239 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
3240 TWA.Ty = new PATypeHolder(Type::VoidTy);
Scott Michel6d1aba82008-01-30 03:10:00 +00003241 yyval.TypeWithAttrsList->push_back(TWA);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003242 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003243 ;
3244 break;}
3245case 164:
3246#line 1491 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3247{
3248 yyval.TypeWithAttrsList = new TypeWithAttrsList();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003249 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003250 ;
3251 break;}
3252case 165:
3253#line 1499 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3254{
3255 yyval.TypeList = new std::list<PATypeHolder>();
3256 yyval.TypeList->push_back(*yyvsp[0].TypeVal);
3257 delete yyvsp[0].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003258 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003259 ;
3260 break;}
3261case 166:
3262#line 1505 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3263{
3264 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal);
3265 delete yyvsp[0].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003266 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003267 ;
3268 break;}
3269case 167:
3270#line 1517 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3271{ // Nonempty unsized arr
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003272 if (!UpRefs.empty())
Scott Michel6d1aba82008-01-30 03:10:00 +00003273 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
3274 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003275 if (ATy == 0)
3276 GEN_ERROR("Cannot make array constant with type: '" +
Scott Michel6d1aba82008-01-30 03:10:00 +00003277 (*yyvsp[-3].TypeVal)->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003278 const Type *ETy = ATy->getElementType();
3279 int NumElements = ATy->getNumElements();
3280
3281 // Verify that we have the correct size...
Scott Michel6d1aba82008-01-30 03:10:00 +00003282 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003283 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Scott Michel6d1aba82008-01-30 03:10:00 +00003284 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003285 itostr(NumElements) + "");
3286
3287 // Verify all elements are correct type!
Scott Michel6d1aba82008-01-30 03:10:00 +00003288 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3289 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003290 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3291 ETy->getDescription() +"' as required!\nIt is of type '"+
Scott Michel6d1aba82008-01-30 03:10:00 +00003292 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003293 }
3294
Scott Michel6d1aba82008-01-30 03:10:00 +00003295 yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
3296 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003297 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003298 ;
3299 break;}
3300case 168:
3301#line 1545 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3302{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003303 if (!UpRefs.empty())
Scott Michel6d1aba82008-01-30 03:10:00 +00003304 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3305 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003306 if (ATy == 0)
3307 GEN_ERROR("Cannot make array constant with type: '" +
Scott Michel6d1aba82008-01-30 03:10:00 +00003308 (*yyvsp[-2].TypeVal)->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003309
3310 int NumElements = ATy->getNumElements();
3311 if (NumElements != -1 && NumElements != 0)
3312 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
3313 " arguments, but has size of " + itostr(NumElements) +"");
Scott Michel6d1aba82008-01-30 03:10:00 +00003314 yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
3315 delete yyvsp[-2].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003316 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003317 ;
3318 break;}
3319case 169:
3320#line 1561 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3321{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003322 if (!UpRefs.empty())
Scott Michel6d1aba82008-01-30 03:10:00 +00003323 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3324 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003325 if (ATy == 0)
3326 GEN_ERROR("Cannot make array constant with type: '" +
Scott Michel6d1aba82008-01-30 03:10:00 +00003327 (*yyvsp[-2].TypeVal)->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003328
3329 int NumElements = ATy->getNumElements();
3330 const Type *ETy = ATy->getElementType();
Scott Michel6d1aba82008-01-30 03:10:00 +00003331 if (NumElements != -1 && NumElements != int(yyvsp[0].StrVal->length()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003332 GEN_ERROR("Can't build string constant of size " +
Scott Michel6d1aba82008-01-30 03:10:00 +00003333 itostr((int)(yyvsp[0].StrVal->length())) +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003334 " when array has size " + itostr(NumElements) + "");
3335 std::vector<Constant*> Vals;
3336 if (ETy == Type::Int8Ty) {
Scott Michel6d1aba82008-01-30 03:10:00 +00003337 for (unsigned i = 0; i < yyvsp[0].StrVal->length(); ++i)
3338 Vals.push_back(ConstantInt::get(ETy, (*yyvsp[0].StrVal)[i]));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003339 } else {
Scott Michel6d1aba82008-01-30 03:10:00 +00003340 delete yyvsp[0].StrVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003341 GEN_ERROR("Cannot build string arrays of non byte sized elements");
3342 }
Scott Michel6d1aba82008-01-30 03:10:00 +00003343 delete yyvsp[0].StrVal;
3344 yyval.ConstVal = ConstantArray::get(ATy, Vals);
3345 delete yyvsp[-2].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003346 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003347 ;
3348 break;}
3349case 170:
3350#line 1588 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3351{ // Nonempty unsized arr
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003352 if (!UpRefs.empty())
Scott Michel6d1aba82008-01-30 03:10:00 +00003353 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
3354 const VectorType *PTy = dyn_cast<VectorType>(yyvsp[-3].TypeVal->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003355 if (PTy == 0)
3356 GEN_ERROR("Cannot make packed constant with type: '" +
Scott Michel6d1aba82008-01-30 03:10:00 +00003357 (*yyvsp[-3].TypeVal)->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003358 const Type *ETy = PTy->getElementType();
3359 int NumElements = PTy->getNumElements();
3360
3361 // Verify that we have the correct size...
Scott Michel6d1aba82008-01-30 03:10:00 +00003362 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003363 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Scott Michel6d1aba82008-01-30 03:10:00 +00003364 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003365 itostr(NumElements) + "");
3366
3367 // Verify all elements are correct type!
Scott Michel6d1aba82008-01-30 03:10:00 +00003368 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3369 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003370 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3371 ETy->getDescription() +"' as required!\nIt is of type '"+
Scott Michel6d1aba82008-01-30 03:10:00 +00003372 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003373 }
3374
Scott Michel6d1aba82008-01-30 03:10:00 +00003375 yyval.ConstVal = ConstantVector::get(PTy, *yyvsp[-1].ConstVector);
3376 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003377 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003378 ;
3379 break;}
3380case 171:
3381#line 1616 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3382{
3383 const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003384 if (STy == 0)
3385 GEN_ERROR("Cannot make struct constant with type: '" +
Scott Michel6d1aba82008-01-30 03:10:00 +00003386 (*yyvsp[-3].TypeVal)->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003387
Scott Michel6d1aba82008-01-30 03:10:00 +00003388 if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003389 GEN_ERROR("Illegal number of initializers for structure type");
3390
3391 // Check to ensure that constants are compatible with the type initializer!
Scott Michel6d1aba82008-01-30 03:10:00 +00003392 for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
3393 if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003394 GEN_ERROR("Expected type '" +
3395 STy->getElementType(i)->getDescription() +
3396 "' for element #" + utostr(i) +
3397 " of structure initializer");
3398
3399 // Check to ensure that Type is not packed
3400 if (STy->isPacked())
3401 GEN_ERROR("Unpacked Initializer to vector type '" +
3402 STy->getDescription() + "'");
3403
Scott Michel6d1aba82008-01-30 03:10:00 +00003404 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
3405 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003406 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003407 ;
3408 break;}
3409case 172:
3410#line 1642 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3411{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003412 if (!UpRefs.empty())
Scott Michel6d1aba82008-01-30 03:10:00 +00003413 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3414 const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003415 if (STy == 0)
3416 GEN_ERROR("Cannot make struct constant with type: '" +
Scott Michel6d1aba82008-01-30 03:10:00 +00003417 (*yyvsp[-2].TypeVal)->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003418
3419 if (STy->getNumContainedTypes() != 0)
3420 GEN_ERROR("Illegal number of initializers for structure type");
3421
3422 // Check to ensure that Type is not packed
3423 if (STy->isPacked())
3424 GEN_ERROR("Unpacked Initializer to vector type '" +
3425 STy->getDescription() + "'");
3426
Scott Michel6d1aba82008-01-30 03:10:00 +00003427 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
3428 delete yyvsp[-2].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003429 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003430 ;
3431 break;}
3432case 173:
3433#line 1662 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3434{
3435 const StructType *STy = dyn_cast<StructType>(yyvsp[-5].TypeVal->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003436 if (STy == 0)
3437 GEN_ERROR("Cannot make struct constant with type: '" +
Scott Michel6d1aba82008-01-30 03:10:00 +00003438 (*yyvsp[-5].TypeVal)->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003439
Scott Michel6d1aba82008-01-30 03:10:00 +00003440 if (yyvsp[-2].ConstVector->size() != STy->getNumContainedTypes())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003441 GEN_ERROR("Illegal number of initializers for structure type");
3442
3443 // Check to ensure that constants are compatible with the type initializer!
Scott Michel6d1aba82008-01-30 03:10:00 +00003444 for (unsigned i = 0, e = yyvsp[-2].ConstVector->size(); i != e; ++i)
3445 if ((*yyvsp[-2].ConstVector)[i]->getType() != STy->getElementType(i))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003446 GEN_ERROR("Expected type '" +
3447 STy->getElementType(i)->getDescription() +
3448 "' for element #" + utostr(i) +
3449 " of structure initializer");
3450
3451 // Check to ensure that Type is packed
3452 if (!STy->isPacked())
3453 GEN_ERROR("Vector initializer to non-vector type '" +
3454 STy->getDescription() + "'");
3455
Scott Michel6d1aba82008-01-30 03:10:00 +00003456 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-2].ConstVector);
3457 delete yyvsp[-5].TypeVal; delete yyvsp[-2].ConstVector;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003458 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003459 ;
3460 break;}
3461case 174:
3462#line 1688 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3463{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003464 if (!UpRefs.empty())
Scott Michel6d1aba82008-01-30 03:10:00 +00003465 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
3466 const StructType *STy = dyn_cast<StructType>(yyvsp[-4].TypeVal->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003467 if (STy == 0)
3468 GEN_ERROR("Cannot make struct constant with type: '" +
Scott Michel6d1aba82008-01-30 03:10:00 +00003469 (*yyvsp[-4].TypeVal)->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003470
3471 if (STy->getNumContainedTypes() != 0)
3472 GEN_ERROR("Illegal number of initializers for structure type");
3473
3474 // Check to ensure that Type is packed
3475 if (!STy->isPacked())
3476 GEN_ERROR("Vector initializer to non-vector type '" +
3477 STy->getDescription() + "'");
3478
Scott Michel6d1aba82008-01-30 03:10:00 +00003479 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
3480 delete yyvsp[-4].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003481 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003482 ;
3483 break;}
3484case 175:
3485#line 1708 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3486{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003487 if (!UpRefs.empty())
Scott Michel6d1aba82008-01-30 03:10:00 +00003488 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3489 const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003490 if (PTy == 0)
3491 GEN_ERROR("Cannot make null pointer constant with type: '" +
Scott Michel6d1aba82008-01-30 03:10:00 +00003492 (*yyvsp[-1].TypeVal)->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003493
Scott Michel6d1aba82008-01-30 03:10:00 +00003494 yyval.ConstVal = ConstantPointerNull::get(PTy);
3495 delete yyvsp[-1].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003496 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003497 ;
3498 break;}
3499case 176:
3500#line 1720 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3501{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003502 if (!UpRefs.empty())
Scott Michel6d1aba82008-01-30 03:10:00 +00003503 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3504 yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
3505 delete yyvsp[-1].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003506 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003507 ;
3508 break;}
3509case 177:
3510#line 1727 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3511{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003512 if (!UpRefs.empty())
Scott Michel6d1aba82008-01-30 03:10:00 +00003513 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3514 const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003515 if (Ty == 0)
3516 GEN_ERROR("Global const reference must be a pointer type");
3517
3518 // ConstExprs can exist in the body of a function, thus creating
3519 // GlobalValues whenever they refer to a variable. Because we are in
3520 // the context of a function, getExistingVal will search the functions
3521 // symbol table instead of the module symbol table for the global symbol,
3522 // which throws things all off. To get around this, we just tell
3523 // getExistingVal that we are at global scope here.
3524 //
3525 Function *SavedCurFn = CurFun.CurrentFunction;
3526 CurFun.CurrentFunction = 0;
3527
Scott Michel6d1aba82008-01-30 03:10:00 +00003528 Value *V = getExistingVal(Ty, yyvsp[0].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003529 CHECK_FOR_ERROR
3530
3531 CurFun.CurrentFunction = SavedCurFn;
3532
3533 // If this is an initializer for a constant pointer, which is referencing a
3534 // (currently) undefined variable, create a stub now that shall be replaced
3535 // in the future with the right type of variable.
3536 //
3537 if (V == 0) {
3538 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
3539 const PointerType *PT = cast<PointerType>(Ty);
3540
3541 // First check to see if the forward references value is already created!
3542 PerModuleInfo::GlobalRefsType::iterator I =
Scott Michel6d1aba82008-01-30 03:10:00 +00003543 CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003544
3545 if (I != CurModule.GlobalRefs.end()) {
3546 V = I->second; // Placeholder already exists, use it...
Scott Michel6d1aba82008-01-30 03:10:00 +00003547 yyvsp[0].ValIDVal.destroy();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003548 } else {
3549 std::string Name;
Scott Michel6d1aba82008-01-30 03:10:00 +00003550 if (yyvsp[0].ValIDVal.Type == ValID::GlobalName)
3551 Name = yyvsp[0].ValIDVal.getName();
3552 else if (yyvsp[0].ValIDVal.Type != ValID::GlobalID)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003553 GEN_ERROR("Invalid reference to global");
3554
3555 // Create the forward referenced global.
3556 GlobalValue *GV;
3557 if (const FunctionType *FTy =
3558 dyn_cast<FunctionType>(PT->getElementType())) {
3559 GV = new Function(FTy, GlobalValue::ExternalWeakLinkage, Name,
3560 CurModule.CurrentModule);
3561 } else {
3562 GV = new GlobalVariable(PT->getElementType(), false,
3563 GlobalValue::ExternalWeakLinkage, 0,
3564 Name, CurModule.CurrentModule);
3565 }
3566
3567 // Keep track of the fact that we have a forward ref to recycle it
Scott Michel6d1aba82008-01-30 03:10:00 +00003568 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003569 V = GV;
3570 }
3571 }
3572
Scott Michel6d1aba82008-01-30 03:10:00 +00003573 yyval.ConstVal = cast<GlobalValue>(V);
3574 delete yyvsp[-1].TypeVal; // Free the type handle
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003575 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003576 ;
3577 break;}
3578case 178:
3579#line 1793 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3580{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003581 if (!UpRefs.empty())
Scott Michel6d1aba82008-01-30 03:10:00 +00003582 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3583 if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003584 GEN_ERROR("Mismatched types for constant expression: " +
Scott Michel6d1aba82008-01-30 03:10:00 +00003585 (*yyvsp[-1].TypeVal)->getDescription() + " and " + yyvsp[0].ConstVal->getType()->getDescription());
3586 yyval.ConstVal = yyvsp[0].ConstVal;
3587 delete yyvsp[-1].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003588 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003589 ;
3590 break;}
3591case 179:
3592#line 1803 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3593{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003594 if (!UpRefs.empty())
Scott Michel6d1aba82008-01-30 03:10:00 +00003595 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3596 const Type *Ty = yyvsp[-1].TypeVal->get();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003597 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
3598 GEN_ERROR("Cannot create a null initialized value of this type");
Scott Michel6d1aba82008-01-30 03:10:00 +00003599 yyval.ConstVal = Constant::getNullValue(Ty);
3600 delete yyvsp[-1].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003601 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003602 ;
3603 break;}
3604case 180:
3605#line 1813 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3606{ // integral constants
3607 if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003608 GEN_ERROR("Constant value doesn't fit in type");
Scott Michel6d1aba82008-01-30 03:10:00 +00003609 yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val, true);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003610 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003611 ;
3612 break;}
3613case 181:
3614#line 1819 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3615{ // arbitrary precision integer constants
3616 uint32_t BitWidth = cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth();
3617 if (yyvsp[0].APIntVal->getBitWidth() > BitWidth) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003618 GEN_ERROR("Constant value does not fit in type");
3619 }
Scott Michel6d1aba82008-01-30 03:10:00 +00003620 yyvsp[0].APIntVal->sextOrTrunc(BitWidth);
3621 yyval.ConstVal = ConstantInt::get(*yyvsp[0].APIntVal);
3622 delete yyvsp[0].APIntVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003623 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003624 ;
3625 break;}
3626case 182:
3627#line 1829 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3628{ // integral constants
3629 if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003630 GEN_ERROR("Constant value doesn't fit in type");
Scott Michel6d1aba82008-01-30 03:10:00 +00003631 yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val, false);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003632 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003633 ;
3634 break;}
3635case 183:
3636#line 1835 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3637{ // arbitrary precision integer constants
3638 uint32_t BitWidth = cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth();
3639 if (yyvsp[0].APIntVal->getBitWidth() > BitWidth) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003640 GEN_ERROR("Constant value does not fit in type");
3641 }
Scott Michel6d1aba82008-01-30 03:10:00 +00003642 yyvsp[0].APIntVal->zextOrTrunc(BitWidth);
3643 yyval.ConstVal = ConstantInt::get(*yyvsp[0].APIntVal);
3644 delete yyvsp[0].APIntVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003645 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003646 ;
3647 break;}
3648case 184:
3649#line 1845 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3650{ // Boolean constants
3651 assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?");
3652 yyval.ConstVal = ConstantInt::getTrue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003653 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003654 ;
3655 break;}
3656case 185:
3657#line 1850 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3658{ // Boolean constants
3659 assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?");
3660 yyval.ConstVal = ConstantInt::getFalse();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003661 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003662 ;
3663 break;}
3664case 186:
3665#line 1855 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3666{ // Floating point constants
3667 if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, *yyvsp[0].FPVal))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003668 GEN_ERROR("Floating point constant invalid for type");
Dale Johannesen255b8fe2007-09-11 18:33:39 +00003669 // Lexer has no type info, so builds all float and double FP constants
3670 // as double. Fix this here. Long double is done right.
Scott Michel6d1aba82008-01-30 03:10:00 +00003671 if (&yyvsp[0].FPVal->getSemantics()==&APFloat::IEEEdouble && yyvsp[-1].PrimType==Type::FloatTy)
3672 yyvsp[0].FPVal->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
3673 yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, *yyvsp[0].FPVal);
3674 delete yyvsp[0].FPVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003675 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003676 ;
3677 break;}
3678case 187:
3679#line 1868 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3680{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003681 if (!UpRefs.empty())
Scott Michel6d1aba82008-01-30 03:10:00 +00003682 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3683 Constant *Val = yyvsp[-3].ConstVal;
3684 const Type *DestTy = yyvsp[-1].TypeVal->get();
3685 if (!CastInst::castIsValid(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003686 GEN_ERROR("invalid cast opcode for cast from '" +
3687 Val->getType()->getDescription() + "' to '" +
3688 DestTy->getDescription() + "'");
Scott Michel6d1aba82008-01-30 03:10:00 +00003689 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy);
3690 delete yyvsp[-1].TypeVal;
3691 ;
3692 break;}
3693case 188:
3694#line 1880 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3695{
3696 if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003697 GEN_ERROR("GetElementPtr requires a pointer operand");
3698
3699 const Type *IdxTy =
Scott Michel6d1aba82008-01-30 03:10:00 +00003700 GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end(),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003701 true);
3702 if (!IdxTy)
3703 GEN_ERROR("Index list invalid for constant getelementptr");
3704
3705 SmallVector<Constant*, 8> IdxVec;
Scott Michel6d1aba82008-01-30 03:10:00 +00003706 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
3707 if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003708 IdxVec.push_back(C);
3709 else
3710 GEN_ERROR("Indices to constant getelementptr must be constants");
3711
Scott Michel6d1aba82008-01-30 03:10:00 +00003712 delete yyvsp[-1].ValueList;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003713
Scott Michel6d1aba82008-01-30 03:10:00 +00003714 yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, &IdxVec[0], IdxVec.size());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003715 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003716 ;
3717 break;}
3718case 189:
3719#line 1902 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3720{
3721 if (yyvsp[-5].ConstVal->getType() != Type::Int1Ty)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003722 GEN_ERROR("Select condition must be of boolean type");
Scott Michel6d1aba82008-01-30 03:10:00 +00003723 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003724 GEN_ERROR("Select operand types must match");
Scott Michel6d1aba82008-01-30 03:10:00 +00003725 yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003726 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003727 ;
3728 break;}
3729case 190:
3730#line 1910 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3731{
3732 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003733 GEN_ERROR("Binary operator types must match");
3734 CHECK_FOR_ERROR;
Scott Michel6d1aba82008-01-30 03:10:00 +00003735 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3736 ;
3737 break;}
3738case 191:
3739#line 1916 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3740{
3741 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003742 GEN_ERROR("Logical operator types must match");
Scott Michel6d1aba82008-01-30 03:10:00 +00003743 if (!yyvsp[-3].ConstVal->getType()->isInteger()) {
3744 if (Instruction::isShift(yyvsp[-5].BinaryOpVal) || !isa<VectorType>(yyvsp[-3].ConstVal->getType()) ||
3745 !cast<VectorType>(yyvsp[-3].ConstVal->getType())->getElementType()->isInteger())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003746 GEN_ERROR("Logical operator requires integral operands");
3747 }
Scott Michel6d1aba82008-01-30 03:10:00 +00003748 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003749 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003750 ;
3751 break;}
3752case 192:
3753#line 1927 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3754{
3755 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003756 GEN_ERROR("icmp operand types must match");
Scott Michel6d1aba82008-01-30 03:10:00 +00003757 yyval.ConstVal = ConstantExpr::getICmp(yyvsp[-5].IPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3758 ;
3759 break;}
3760case 193:
3761#line 1932 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3762{
3763 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003764 GEN_ERROR("fcmp operand types must match");
Scott Michel6d1aba82008-01-30 03:10:00 +00003765 yyval.ConstVal = ConstantExpr::getFCmp(yyvsp[-5].FPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3766 ;
3767 break;}
3768case 194:
3769#line 1937 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3770{
3771 if (!ExtractElementInst::isValidOperands(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003772 GEN_ERROR("Invalid extractelement operands");
Scott Michel6d1aba82008-01-30 03:10:00 +00003773 yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003774 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003775 ;
3776 break;}
3777case 195:
3778#line 1943 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3779{
3780 if (!InsertElementInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003781 GEN_ERROR("Invalid insertelement operands");
Scott Michel6d1aba82008-01-30 03:10:00 +00003782 yyval.ConstVal = ConstantExpr::getInsertElement(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003783 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003784 ;
3785 break;}
3786case 196:
3787#line 1949 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3788{
3789 if (!ShuffleVectorInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003790 GEN_ERROR("Invalid shufflevector operands");
Scott Michel6d1aba82008-01-30 03:10:00 +00003791 yyval.ConstVal = ConstantExpr::getShuffleVector(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003792 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003793 ;
3794 break;}
3795case 197:
3796#line 1958 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3797{
3798 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003799 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003800 ;
3801 break;}
3802case 198:
3803#line 1962 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3804{
3805 yyval.ConstVector = new std::vector<Constant*>();
3806 yyval.ConstVector->push_back(yyvsp[0].ConstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003807 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003808 ;
3809 break;}
3810case 199:
3811#line 1970 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3812{ yyval.BoolVal = false; ;
3813 break;}
3814case 200:
3815#line 1970 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3816{ yyval.BoolVal = true; ;
3817 break;}
3818case 201:
3819#line 1973 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3820{ yyval.BoolVal = true; ;
3821 break;}
3822case 202:
3823#line 1973 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3824{ yyval.BoolVal = false; ;
3825 break;}
3826case 203:
3827#line 1976 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3828{
3829 const Type* VTy = yyvsp[-1].TypeVal->get();
3830 Value *V = getVal(VTy, yyvsp[0].ValIDVal);
Chris Lattnerbb856a32007-08-06 21:00:46 +00003831 CHECK_FOR_ERROR
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003832 GlobalValue* Aliasee = dyn_cast<GlobalValue>(V);
3833 if (!Aliasee)
3834 GEN_ERROR("Aliases can be created only to global values");
3835
Scott Michel6d1aba82008-01-30 03:10:00 +00003836 yyval.ConstVal = Aliasee;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003837 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003838 delete yyvsp[-1].TypeVal;
3839 ;
3840 break;}
3841case 204:
3842#line 1988 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3843{
3844 Constant *Val = yyvsp[-3].ConstVal;
3845 const Type *DestTy = yyvsp[-1].TypeVal->get();
3846 if (!CastInst::castIsValid(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003847 GEN_ERROR("invalid cast opcode for cast from '" +
3848 Val->getType()->getDescription() + "' to '" +
3849 DestTy->getDescription() + "'");
3850
Scott Michel6d1aba82008-01-30 03:10:00 +00003851 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003852 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003853 delete yyvsp[-1].TypeVal;
3854 ;
3855 break;}
3856case 205:
3857#line 2009 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3858{
3859 yyval.ModuleVal = ParserResult = CurModule.CurrentModule;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003860 CurModule.ModuleDone();
3861 CHECK_FOR_ERROR;
Scott Michel6d1aba82008-01-30 03:10:00 +00003862 ;
3863 break;}
3864case 206:
3865#line 2014 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3866{
3867 yyval.ModuleVal = ParserResult = CurModule.CurrentModule;
Christopher Lamb668d9a02007-12-12 08:45:45 +00003868 CurModule.ModuleDone();
3869 CHECK_FOR_ERROR;
Scott Michel6d1aba82008-01-30 03:10:00 +00003870 ;
3871 break;}
3872case 209:
3873#line 2027 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3874{ CurFun.isDeclare = false; ;
3875 break;}
3876case 210:
3877#line 2027 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3878{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003879 CurFun.FunctionDone();
3880 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003881 ;
3882 break;}
3883case 211:
3884#line 2031 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3885{ CurFun.isDeclare = true; ;
3886 break;}
3887case 212:
3888#line 2031 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3889{
Gordon Henriksen13fe5e32007-12-10 03:18:06 +00003890 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003891 ;
3892 break;}
3893case 213:
3894#line 2034 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3895{
Christopher Lamb668d9a02007-12-12 08:45:45 +00003896 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003897 ;
3898 break;}
3899case 214:
3900#line 2037 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3901{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003902 if (!UpRefs.empty())
Scott Michel6d1aba82008-01-30 03:10:00 +00003903 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003904 // Eagerly resolve types. This is not an optimization, this is a
3905 // requirement that is due to the fact that we could have this:
3906 //
3907 // %list = type { %list * }
3908 // %list = type { %list * } ; repeated type decl
3909 //
3910 // If types are not resolved eagerly, then the two types will not be
3911 // determined to be the same type!
3912 //
Scott Michel6d1aba82008-01-30 03:10:00 +00003913 ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003914
Scott Michel6d1aba82008-01-30 03:10:00 +00003915 if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003916 CHECK_FOR_ERROR
3917 // If this is a named type that is not a redefinition, add it to the slot
3918 // table.
Scott Michel6d1aba82008-01-30 03:10:00 +00003919 CurModule.Types.push_back(*yyvsp[0].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003920 }
3921
Scott Michel6d1aba82008-01-30 03:10:00 +00003922 delete yyvsp[0].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003923 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003924 ;
3925 break;}
3926case 215:
3927#line 2061 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3928{
3929 ResolveTypeTo(yyvsp[-2].StrVal, yyvsp[0].PrimType);
Reid Spenceraa8ae282007-07-31 03:50:36 +00003930
Scott Michel6d1aba82008-01-30 03:10:00 +00003931 if (!setTypeName(yyvsp[0].PrimType, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003932 CHECK_FOR_ERROR
3933 // If this is a named type that is not a redefinition, add it to the slot
3934 // table.
Scott Michel6d1aba82008-01-30 03:10:00 +00003935 CurModule.Types.push_back(yyvsp[0].PrimType);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003936 }
3937 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003938 ;
3939 break;}
3940case 216:
3941#line 2073 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3942{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003943 /* "Externally Visible" Linkage */
Scott Michel6d1aba82008-01-30 03:10:00 +00003944 if (yyvsp[-1].ConstVal == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003945 GEN_ERROR("Global value initializer is not a constant");
Scott Michel6d1aba82008-01-30 03:10:00 +00003946 CurGV = ParseGlobalVariable(yyvsp[-5].StrVal, GlobalValue::ExternalLinkage,
3947 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 +00003948 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003949 ;
3950 break;}
3951case 217:
3952#line 2080 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3953{
Christopher Lamb668d9a02007-12-12 08:45:45 +00003954 CurGV = 0;
Scott Michel6d1aba82008-01-30 03:10:00 +00003955 ;
3956 break;}
3957case 218:
3958#line 2084 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3959{
3960 if (yyvsp[-1].ConstVal == 0)
Christopher Lamb668d9a02007-12-12 08:45:45 +00003961 GEN_ERROR("Global value initializer is not a constant");
Scott Michel6d1aba82008-01-30 03:10:00 +00003962 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 +00003963 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003964 ;
3965 break;}
3966case 219:
3967#line 2089 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3968{
Christopher Lamb668d9a02007-12-12 08:45:45 +00003969 CurGV = 0;
Scott Michel6d1aba82008-01-30 03:10:00 +00003970 ;
3971 break;}
3972case 220:
3973#line 2093 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3974{
Christopher Lamb668d9a02007-12-12 08:45:45 +00003975 if (!UpRefs.empty())
Scott Michel6d1aba82008-01-30 03:10:00 +00003976 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3977 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 +00003978 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003979 delete yyvsp[-1].TypeVal;
3980 ;
3981 break;}
3982case 221:
3983#line 2099 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3984{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003985 CurGV = 0;
3986 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00003987 ;
3988 break;}
3989case 222:
3990#line 2103 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3991{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003992 std::string Name;
Scott Michel6d1aba82008-01-30 03:10:00 +00003993 if (yyvsp[-4].StrVal) {
3994 Name = *yyvsp[-4].StrVal;
3995 delete yyvsp[-4].StrVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003996 }
3997 if (Name.empty())
3998 GEN_ERROR("Alias name cannot be empty");
3999
Scott Michel6d1aba82008-01-30 03:10:00 +00004000 Constant* Aliasee = yyvsp[0].ConstVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004001 if (Aliasee == 0)
4002 GEN_ERROR(std::string("Invalid aliasee for alias: ") + Name);
4003
Scott Michel6d1aba82008-01-30 03:10:00 +00004004 GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), yyvsp[-1].Linkage, Name, Aliasee,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004005 CurModule.CurrentModule);
Scott Michel6d1aba82008-01-30 03:10:00 +00004006 GA->setVisibility(yyvsp[-3].Visibility);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004007 InsertValue(GA, CurModule.Values);
Chris Lattner5eefce32007-09-10 23:24:14 +00004008
4009
4010 // If there was a forward reference of this alias, resolve it now.
4011
4012 ValID ID;
4013 if (!Name.empty())
4014 ID = ValID::createGlobalName(Name);
4015 else
4016 ID = ValID::createGlobalID(CurModule.Values.size()-1);
4017
4018 if (GlobalValue *FWGV =
4019 CurModule.GetForwardRefForGlobal(GA->getType(), ID)) {
4020 // Replace uses of the fwdref with the actual alias.
4021 FWGV->replaceAllUsesWith(GA);
4022 if (GlobalVariable *GV = dyn_cast<GlobalVariable>(FWGV))
4023 GV->eraseFromParent();
4024 else
4025 cast<Function>(FWGV)->eraseFromParent();
4026 }
4027 ID.destroy();
4028
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004029 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004030 ;
4031 break;}
4032case 223:
4033#line 2143 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4034{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004035 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004036 ;
4037 break;}
4038case 224:
4039#line 2146 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4040{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004041 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004042 ;
4043 break;}
4044case 225:
4045#line 2152 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4046{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004047 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
4048 if (AsmSoFar.empty())
Scott Michel6d1aba82008-01-30 03:10:00 +00004049 CurModule.CurrentModule->setModuleInlineAsm(*yyvsp[0].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004050 else
Scott Michel6d1aba82008-01-30 03:10:00 +00004051 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+*yyvsp[0].StrVal);
4052 delete yyvsp[0].StrVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004053 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004054;
4055 break;}
4056case 226:
4057#line 2162 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4058{
4059 CurModule.CurrentModule->setTargetTriple(*yyvsp[0].StrVal);
4060 delete yyvsp[0].StrVal;
4061 ;
4062 break;}
4063case 227:
4064#line 2166 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4065{
4066 CurModule.CurrentModule->setDataLayout(*yyvsp[0].StrVal);
4067 delete yyvsp[0].StrVal;
4068 ;
4069 break;}
4070case 229:
4071#line 2173 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4072{
4073 CurModule.CurrentModule->addLibrary(*yyvsp[0].StrVal);
4074 delete yyvsp[0].StrVal;
Christopher Lamb668d9a02007-12-12 08:45:45 +00004075 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004076 ;
4077 break;}
4078case 230:
4079#line 2178 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4080{
4081 CurModule.CurrentModule->addLibrary(*yyvsp[0].StrVal);
4082 delete yyvsp[0].StrVal;
Reid Spencer47470022007-07-31 14:41:17 +00004083 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004084 ;
4085 break;}
4086case 231:
4087#line 2183 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4088{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004089 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004090 ;
4091 break;}
4092case 232:
4093#line 2192 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4094{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004095 if (!UpRefs.empty())
Scott Michel6d1aba82008-01-30 03:10:00 +00004096 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4097 if (*yyvsp[-2].TypeVal == Type::VoidTy)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004098 GEN_ERROR("void typed arguments are invalid");
Scott Michel6d1aba82008-01-30 03:10:00 +00004099 ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal;
4100 yyval.ArgList = yyvsp[-4].ArgList;
4101 yyvsp[-4].ArgList->push_back(E);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004102 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004103 ;
4104 break;}
4105case 233:
4106#line 2202 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4107{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004108 if (!UpRefs.empty())
Scott Michel6d1aba82008-01-30 03:10:00 +00004109 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4110 if (*yyvsp[-2].TypeVal == Type::VoidTy)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004111 GEN_ERROR("void typed arguments are invalid");
Scott Michel6d1aba82008-01-30 03:10:00 +00004112 ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal;
4113 yyval.ArgList = new ArgListType;
4114 yyval.ArgList->push_back(E);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004115 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004116 ;
4117 break;}
4118case 234:
4119#line 2213 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4120{
4121 yyval.ArgList = yyvsp[0].ArgList;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004122 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004123 ;
4124 break;}
4125case 235:
4126#line 2217 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4127{
4128 yyval.ArgList = yyvsp[-2].ArgList;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004129 struct ArgListEntry E;
4130 E.Ty = new PATypeHolder(Type::VoidTy);
4131 E.Name = 0;
4132 E.Attrs = ParamAttr::None;
Scott Michel6d1aba82008-01-30 03:10:00 +00004133 yyval.ArgList->push_back(E);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004134 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004135 ;
4136 break;}
4137case 236:
4138#line 2226 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4139{
4140 yyval.ArgList = new ArgListType;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004141 struct ArgListEntry E;
4142 E.Ty = new PATypeHolder(Type::VoidTy);
4143 E.Name = 0;
4144 E.Attrs = ParamAttr::None;
Scott Michel6d1aba82008-01-30 03:10:00 +00004145 yyval.ArgList->push_back(E);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004146 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004147 ;
4148 break;}
4149case 237:
4150#line 2235 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4151{
4152 yyval.ArgList = 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004153 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004154 ;
4155 break;}
4156case 238:
4157#line 2241 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4158{
4159 std::string FunctionName(*yyvsp[-7].StrVal);
4160 delete yyvsp[-7].StrVal; // Free strdup'd memory!
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004161
4162 // Check the function result for abstractness if this is a define. We should
4163 // have no abstract types at this point
Scott Michel6d1aba82008-01-30 03:10:00 +00004164 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(yyvsp[-8].TypeVal))
4165 GEN_ERROR("Reference to abstract result: "+ yyvsp[-8].TypeVal->get()->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004166
4167 std::vector<const Type*> ParamTypeList;
4168 ParamAttrsVector Attrs;
Scott Michel6d1aba82008-01-30 03:10:00 +00004169 if (yyvsp[-3].ParamAttrs != ParamAttr::None) {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004170 ParamAttrsWithIndex PAWI;
4171 PAWI.index = 0;
Scott Michel6d1aba82008-01-30 03:10:00 +00004172 PAWI.attrs = yyvsp[-3].ParamAttrs;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004173 Attrs.push_back(PAWI);
4174 }
Scott Michel6d1aba82008-01-30 03:10:00 +00004175 if (yyvsp[-5].ArgList) { // If there are arguments...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004176 unsigned index = 1;
Scott Michel6d1aba82008-01-30 03:10:00 +00004177 for (ArgListType::iterator I = yyvsp[-5].ArgList->begin(); I != yyvsp[-5].ArgList->end(); ++I, ++index) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004178 const Type* Ty = I->Ty->get();
4179 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
4180 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
4181 ParamTypeList.push_back(Ty);
4182 if (Ty != Type::VoidTy)
4183 if (I->Attrs != ParamAttr::None) {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004184 ParamAttrsWithIndex PAWI;
4185 PAWI.index = index;
4186 PAWI.attrs = I->Attrs;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004187 Attrs.push_back(PAWI);
4188 }
4189 }
4190 }
4191
4192 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
4193 if (isVarArg) ParamTypeList.pop_back();
4194
Duncan Sands637ec552007-11-28 17:07:01 +00004195 const ParamAttrsList *PAL = 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004196 if (!Attrs.empty())
4197 PAL = ParamAttrsList::get(Attrs);
4198
Scott Michel6d1aba82008-01-30 03:10:00 +00004199 FunctionType *FT = FunctionType::get(*yyvsp[-8].TypeVal, ParamTypeList, isVarArg);
Christopher Lambfb623c62007-12-17 01:17:35 +00004200 const PointerType *PFT = PointerType::getUnqual(FT);
Scott Michel6d1aba82008-01-30 03:10:00 +00004201 delete yyvsp[-8].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004202
4203 ValID ID;
4204 if (!FunctionName.empty()) {
4205 ID = ValID::createGlobalName((char*)FunctionName.c_str());
4206 } else {
4207 ID = ValID::createGlobalID(CurModule.Values.size());
4208 }
4209
4210 Function *Fn = 0;
4211 // See if this function was forward referenced. If so, recycle the object.
4212 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4213 // Move the function to the end of the list, from whereever it was
4214 // previously inserted.
4215 Fn = cast<Function>(FWRef);
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004216 assert(!Fn->getParamAttrs() && "Forward reference has parameter attributes!");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004217 CurModule.CurrentModule->getFunctionList().remove(Fn);
4218 CurModule.CurrentModule->getFunctionList().push_back(Fn);
4219 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
4220 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004221 if (Fn->getFunctionType() != FT ) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004222 // The existing function doesn't have the same type. This is an overload
4223 // error.
4224 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004225 } else if (Fn->getParamAttrs() != PAL) {
4226 // The existing function doesn't have the same parameter attributes.
4227 // This is an overload error.
4228 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004229 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
4230 // Neither the existing or the current function is a declaration and they
4231 // have the same name and same type. Clearly this is a redefinition.
4232 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004233 } else if (Fn->isDeclaration()) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004234 // Make sure to strip off any argument names so we can't get conflicts.
4235 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
4236 AI != AE; ++AI)
4237 AI->setName("");
4238 }
4239 } else { // Not already defined?
4240 Fn = new Function(FT, GlobalValue::ExternalWeakLinkage, FunctionName,
4241 CurModule.CurrentModule);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004242 InsertValue(Fn, CurModule.Values);
4243 }
4244
4245 CurFun.FunctionStart(Fn);
4246
4247 if (CurFun.isDeclare) {
4248 // If we have declaration, always overwrite linkage. This will allow us to
4249 // correctly handle cases, when pointer to function is passed as argument to
4250 // another function.
4251 Fn->setLinkage(CurFun.Linkage);
4252 Fn->setVisibility(CurFun.Visibility);
4253 }
Scott Michel6d1aba82008-01-30 03:10:00 +00004254 Fn->setCallingConv(yyvsp[-9].UIntVal);
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004255 Fn->setParamAttrs(PAL);
Scott Michel6d1aba82008-01-30 03:10:00 +00004256 Fn->setAlignment(yyvsp[-1].UIntVal);
4257 if (yyvsp[-2].StrVal) {
4258 Fn->setSection(*yyvsp[-2].StrVal);
4259 delete yyvsp[-2].StrVal;
Gordon Henriksen13fe5e32007-12-10 03:18:06 +00004260 }
Scott Michel6d1aba82008-01-30 03:10:00 +00004261 if (yyvsp[0].StrVal) {
4262 Fn->setCollector(yyvsp[0].StrVal->c_str());
4263 delete yyvsp[0].StrVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004264 }
4265
4266 // Add all of the arguments we parsed to the function...
Scott Michel6d1aba82008-01-30 03:10:00 +00004267 if (yyvsp[-5].ArgList) { // Is null if empty...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004268 if (isVarArg) { // Nuke the last entry
Scott Michel6d1aba82008-01-30 03:10:00 +00004269 assert(yyvsp[-5].ArgList->back().Ty->get() == Type::VoidTy && yyvsp[-5].ArgList->back().Name == 0 &&
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004270 "Not a varargs marker!");
Scott Michel6d1aba82008-01-30 03:10:00 +00004271 delete yyvsp[-5].ArgList->back().Ty;
4272 yyvsp[-5].ArgList->pop_back(); // Delete the last entry
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004273 }
4274 Function::arg_iterator ArgIt = Fn->arg_begin();
4275 Function::arg_iterator ArgEnd = Fn->arg_end();
4276 unsigned Idx = 1;
Scott Michel6d1aba82008-01-30 03:10:00 +00004277 for (ArgListType::iterator I = yyvsp[-5].ArgList->begin();
4278 I != yyvsp[-5].ArgList->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004279 delete I->Ty; // Delete the typeholder...
4280 setValueName(ArgIt, I->Name); // Insert arg into symtab...
4281 CHECK_FOR_ERROR
4282 InsertValue(ArgIt);
4283 Idx++;
4284 }
4285
Scott Michel6d1aba82008-01-30 03:10:00 +00004286 delete yyvsp[-5].ArgList; // We're now done with the argument list
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004287 }
4288 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004289;
4290 break;}
4291case 241:
4292#line 2376 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4293{
4294 yyval.FunctionVal = CurFun.CurrentFunction;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004295
4296 // Make sure that we keep track of the linkage type even if there was a
4297 // previous "declare".
Scott Michel6d1aba82008-01-30 03:10:00 +00004298 yyval.FunctionVal->setLinkage(yyvsp[-3].Linkage);
4299 yyval.FunctionVal->setVisibility(yyvsp[-2].Visibility);
4300;
4301 break;}
4302case 244:
4303#line 2387 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4304{
4305 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004306 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004307;
4308 break;}
4309case 245:
4310#line 2392 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4311{
4312 CurFun.CurrentFunction->setLinkage(yyvsp[-2].Linkage);
4313 CurFun.CurrentFunction->setVisibility(yyvsp[-1].Visibility);
4314 yyval.FunctionVal = CurFun.CurrentFunction;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004315 CurFun.FunctionDone();
4316 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004317 ;
4318 break;}
4319case 246:
4320#line 2404 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4321{
4322 yyval.BoolVal = false;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004323 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004324 ;
4325 break;}
4326case 247:
4327#line 2408 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4328{
4329 yyval.BoolVal = true;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004330 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004331 ;
4332 break;}
4333case 248:
4334#line 2413 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4335{ // A reference to a direct constant
4336 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004337 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004338 ;
4339 break;}
4340case 249:
4341#line 2417 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4342{
4343 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004344 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004345 ;
4346 break;}
4347case 250:
4348#line 2421 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4349{ // Perhaps it's an FP constant?
4350 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004351 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004352 ;
4353 break;}
4354case 251:
4355#line 2425 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4356{
4357 yyval.ValIDVal = ValID::create(ConstantInt::getTrue());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004358 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004359 ;
4360 break;}
4361case 252:
4362#line 2429 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4363{
4364 yyval.ValIDVal = ValID::create(ConstantInt::getFalse());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004365 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004366 ;
4367 break;}
4368case 253:
4369#line 2433 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4370{
4371 yyval.ValIDVal = ValID::createNull();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004372 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004373 ;
4374 break;}
4375case 254:
4376#line 2437 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4377{
4378 yyval.ValIDVal = ValID::createUndef();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004379 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004380 ;
4381 break;}
4382case 255:
4383#line 2441 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4384{ // A vector zero constant.
4385 yyval.ValIDVal = ValID::createZeroInit();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004386 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004387 ;
4388 break;}
4389case 256:
4390#line 2445 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4391{ // Nonempty unsized packed vector
4392 const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
4393 int NumElements = yyvsp[-1].ConstVector->size();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004394
4395 VectorType* pt = VectorType::get(ETy, NumElements);
4396 PATypeHolder* PTy = new PATypeHolder(
4397 HandleUpRefs(
4398 VectorType::get(
4399 ETy,
4400 NumElements)
4401 )
4402 );
4403
4404 // Verify all elements are correct type!
Scott Michel6d1aba82008-01-30 03:10:00 +00004405 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
4406 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004407 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
4408 ETy->getDescription() +"' as required!\nIt is of type '" +
Scott Michel6d1aba82008-01-30 03:10:00 +00004409 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004410 }
4411
Scott Michel6d1aba82008-01-30 03:10:00 +00004412 yyval.ValIDVal = ValID::create(ConstantVector::get(pt, *yyvsp[-1].ConstVector));
4413 delete PTy; delete yyvsp[-1].ConstVector;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004414 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004415 ;
4416 break;}
4417case 257:
4418#line 2470 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4419{
4420 yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004421 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004422 ;
4423 break;}
4424case 258:
4425#line 2474 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4426{
4427 yyval.ValIDVal = ValID::createInlineAsm(*yyvsp[-2].StrVal, *yyvsp[0].StrVal, yyvsp[-3].BoolVal);
4428 delete yyvsp[-2].StrVal;
4429 delete yyvsp[0].StrVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004430 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004431 ;
4432 break;}
4433case 259:
4434#line 2484 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4435{ // Is it an integer reference...?
4436 yyval.ValIDVal = ValID::createLocalID(yyvsp[0].UIntVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004437 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004438 ;
4439 break;}
4440case 260:
4441#line 2488 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4442{
4443 yyval.ValIDVal = ValID::createGlobalID(yyvsp[0].UIntVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004444 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004445 ;
4446 break;}
4447case 261:
4448#line 2492 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4449{ // Is it a named reference...?
4450 yyval.ValIDVal = ValID::createLocalName(*yyvsp[0].StrVal);
4451 delete yyvsp[0].StrVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004452 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004453 ;
4454 break;}
4455case 262:
4456#line 2497 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4457{ // Is it a named reference...?
4458 yyval.ValIDVal = ValID::createGlobalName(*yyvsp[0].StrVal);
4459 delete yyvsp[0].StrVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004460 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004461 ;
4462 break;}
4463case 265:
4464#line 2510 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4465{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004466 if (!UpRefs.empty())
Scott Michel6d1aba82008-01-30 03:10:00 +00004467 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4468 yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
4469 delete yyvsp[-1].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004470 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004471 ;
4472 break;}
4473case 266:
4474#line 2519 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4475{
4476 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004477 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004478 ;
4479 break;}
4480case 267:
4481#line 2523 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4482{ // Do not allow functions with 0 basic blocks
4483 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004484 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004485 ;
4486 break;}
4487case 268:
4488#line 2532 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4489{
4490 setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004491 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004492 InsertValue(yyvsp[0].TermInstVal);
4493 yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
4494 yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004495 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004496 ;
4497 break;}
4498case 269:
4499#line 2541 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4500{
4501 if (CastInst *CI1 = dyn_cast<CastInst>(yyvsp[0].InstVal))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004502 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
4503 if (CI2->getParent() == 0)
Scott Michel6d1aba82008-01-30 03:10:00 +00004504 yyvsp[-1].BasicBlockVal->getInstList().push_back(CI2);
4505 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
4506 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004507 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004508 ;
4509 break;}
4510case 270:
4511#line 2550 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4512{ // Empty space between instruction lists
4513 yyval.BasicBlockVal = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004514 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004515 ;
4516 break;}
4517case 271:
4518#line 2554 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4519{ // Labelled (named) basic block
4520 yyval.BasicBlockVal = defineBBVal(ValID::createLocalName(*yyvsp[0].StrVal));
4521 delete yyvsp[0].StrVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004522 CHECK_FOR_ERROR
4523
Scott Michel6d1aba82008-01-30 03:10:00 +00004524 ;
4525 break;}
4526case 272:
4527#line 2561 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4528{ // Return with a result...
4529 yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
4530 CHECK_FOR_ERROR
4531 ;
4532 break;}
4533case 273:
4534#line 2565 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4535{ // Return with no result...
4536 yyval.TermInstVal = new ReturnInst();
4537 CHECK_FOR_ERROR
4538 ;
4539 break;}
4540case 274:
4541#line 2569 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4542{ // Unconditional Branch...
4543 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
4544 CHECK_FOR_ERROR
4545 yyval.TermInstVal = new BranchInst(tmpBB);
4546 ;
4547 break;}
4548case 275:
4549#line 2574 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4550{
4551 assert(cast<IntegerType>(yyvsp[-7].PrimType)->getBitWidth() == 1 && "Not Bool?");
4552 BasicBlock* tmpBBA = getBBVal(yyvsp[-3].ValIDVal);
4553 CHECK_FOR_ERROR
4554 BasicBlock* tmpBBB = getBBVal(yyvsp[0].ValIDVal);
4555 CHECK_FOR_ERROR
4556 Value* tmpVal = getVal(Type::Int1Ty, yyvsp[-6].ValIDVal);
4557 CHECK_FOR_ERROR
4558 yyval.TermInstVal = new BranchInst(tmpBBA, tmpBBB, tmpVal);
4559 ;
4560 break;}
4561case 276:
4562#line 2584 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4563{
4564 Value* tmpVal = getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal);
4565 CHECK_FOR_ERROR
4566 BasicBlock* tmpBB = getBBVal(yyvsp[-3].ValIDVal);
4567 CHECK_FOR_ERROR
4568 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, yyvsp[-1].JumpTable->size());
4569 yyval.TermInstVal = S;
Reid Spenceraa8ae282007-07-31 03:50:36 +00004570
Scott Michel6d1aba82008-01-30 03:10:00 +00004571 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
4572 E = yyvsp[-1].JumpTable->end();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004573 for (; I != E; ++I) {
4574 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
4575 S->addCase(CI, I->second);
4576 else
4577 GEN_ERROR("Switch case is constant, but not a simple integer");
4578 }
Scott Michel6d1aba82008-01-30 03:10:00 +00004579 delete yyvsp[-1].JumpTable;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004580 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004581 ;
4582 break;}
4583case 277:
4584#line 2603 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4585{
4586 Value* tmpVal = getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004587 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004588 BasicBlock* tmpBB = getBBVal(yyvsp[-2].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004589 CHECK_FOR_ERROR
4590 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Scott Michel6d1aba82008-01-30 03:10:00 +00004591 yyval.TermInstVal = S;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004592 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004593 ;
4594 break;}
4595case 278:
4596#line 2613 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4597{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004598
4599 // Handle the short syntax
4600 const PointerType *PFTy = 0;
4601 const FunctionType *Ty = 0;
Scott Michel6d1aba82008-01-30 03:10:00 +00004602 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-11].TypeVal->get())) ||
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004603 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4604 // Pull out the types of all of the arguments...
4605 std::vector<const Type*> ParamTypes;
Scott Michel6d1aba82008-01-30 03:10:00 +00004606 ParamList::iterator I = yyvsp[-8].ParamList->begin(), E = yyvsp[-8].ParamList->end();
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004607 for (; I != E; ++I) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004608 const Type *Ty = I->Val->getType();
4609 if (Ty == Type::VoidTy)
4610 GEN_ERROR("Short call syntax cannot be used with varargs");
4611 ParamTypes.push_back(Ty);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004612 }
Scott Michel6d1aba82008-01-30 03:10:00 +00004613 Ty = FunctionType::get(yyvsp[-11].TypeVal->get(), ParamTypes, false);
Christopher Lambfb623c62007-12-17 01:17:35 +00004614 PFTy = PointerType::getUnqual(Ty);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004615 }
4616
Scott Michel6d1aba82008-01-30 03:10:00 +00004617 delete yyvsp[-11].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004618
Scott Michel6d1aba82008-01-30 03:10:00 +00004619 Value *V = getVal(PFTy, yyvsp[-10].ValIDVal); // Get the function we're calling...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004620 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004621 BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004622 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004623 BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004624 CHECK_FOR_ERROR
4625
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004626 ParamAttrsVector Attrs;
Scott Michel6d1aba82008-01-30 03:10:00 +00004627 if (yyvsp[-6].ParamAttrs != ParamAttr::None) {
4628 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[-6].ParamAttrs;
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004629 Attrs.push_back(PAWI);
4630 }
4631
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004632 // Check the arguments
4633 ValueList Args;
Scott Michel6d1aba82008-01-30 03:10:00 +00004634 if (yyvsp[-8].ParamList->empty()) { // Has no arguments?
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004635 // Make sure no arguments is a good thing!
4636 if (Ty->getNumParams() != 0)
4637 GEN_ERROR("No arguments passed to a function that "
4638 "expects arguments");
4639 } else { // Has arguments?
4640 // Loop through FunctionType's arguments and ensure they are specified
4641 // correctly!
4642 FunctionType::param_iterator I = Ty->param_begin();
4643 FunctionType::param_iterator E = Ty->param_end();
Scott Michel6d1aba82008-01-30 03:10:00 +00004644 ParamList::iterator ArgI = yyvsp[-8].ParamList->begin(), ArgE = yyvsp[-8].ParamList->end();
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004645 unsigned index = 1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004646
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004647 for (; ArgI != ArgE && I != E; ++ArgI, ++I, ++index) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004648 if (ArgI->Val->getType() != *I)
4649 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
4650 (*I)->getDescription() + "'");
4651 Args.push_back(ArgI->Val);
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004652 if (ArgI->Attrs != ParamAttr::None) {
4653 ParamAttrsWithIndex PAWI;
4654 PAWI.index = index;
4655 PAWI.attrs = ArgI->Attrs;
4656 Attrs.push_back(PAWI);
4657 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004658 }
4659
4660 if (Ty->isVarArg()) {
4661 if (I == E)
Scott Michel6d1aba82008-01-30 03:10:00 +00004662 for (; ArgI != ArgE; ++ArgI)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004663 Args.push_back(ArgI->Val); // push the remaining varargs
4664 } else if (I != E || ArgI != ArgE)
4665 GEN_ERROR("Invalid number of parameters detected");
4666 }
4667
Duncan Sands637ec552007-11-28 17:07:01 +00004668 const ParamAttrsList *PAL = 0;
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004669 if (!Attrs.empty())
4670 PAL = ParamAttrsList::get(Attrs);
4671
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004672 // Create the InvokeInst
Chris Lattnerd140ada2007-08-29 16:15:23 +00004673 InvokeInst *II = new InvokeInst(V, Normal, Except, Args.begin(), Args.end());
Scott Michel6d1aba82008-01-30 03:10:00 +00004674 II->setCallingConv(yyvsp[-12].UIntVal);
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004675 II->setParamAttrs(PAL);
Scott Michel6d1aba82008-01-30 03:10:00 +00004676 yyval.TermInstVal = II;
4677 delete yyvsp[-8].ParamList;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004678 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004679 ;
4680 break;}
4681case 279:
4682#line 2696 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4683{
4684 yyval.TermInstVal = new UnwindInst();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004685 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004686 ;
4687 break;}
4688case 280:
4689#line 2700 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4690{
4691 yyval.TermInstVal = new UnreachableInst();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004692 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004693 ;
4694 break;}
4695case 281:
4696#line 2707 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4697{
4698 yyval.JumpTable = yyvsp[-5].JumpTable;
4699 Constant *V = cast<Constant>(getExistingVal(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004700 CHECK_FOR_ERROR
4701 if (V == 0)
4702 GEN_ERROR("May only switch on a constant pool value");
4703
Scott Michel6d1aba82008-01-30 03:10:00 +00004704 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004705 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004706 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
4707 ;
4708 break;}
4709case 282:
4710#line 2718 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4711{
4712 yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
4713 Constant *V = cast<Constant>(getExistingVal(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004714 CHECK_FOR_ERROR
4715
4716 if (V == 0)
4717 GEN_ERROR("May only switch on a constant pool value");
4718
Scott Michel6d1aba82008-01-30 03:10:00 +00004719 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004720 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004721 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
4722 ;
4723 break;}
4724case 283:
4725#line 2731 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4726{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004727 // Is this definition named?? if so, assign the name...
Scott Michel6d1aba82008-01-30 03:10:00 +00004728 setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004729 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004730 InsertValue(yyvsp[0].InstVal);
4731 yyval.InstVal = yyvsp[0].InstVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004732 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004733 ;
4734 break;}
4735case 284:
4736#line 2741 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4737{ // Used for PHI nodes
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004738 if (!UpRefs.empty())
Scott Michel6d1aba82008-01-30 03:10:00 +00004739 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-5].TypeVal)->getDescription());
4740 yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
4741 Value* tmpVal = getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004742 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004743 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004744 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004745 yyval.PHIList->push_back(std::make_pair(tmpVal, tmpBB));
4746 delete yyvsp[-5].TypeVal;
4747 ;
4748 break;}
4749case 285:
4750#line 2752 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4751{
4752 yyval.PHIList = yyvsp[-6].PHIList;
4753 Value* tmpVal = getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004754 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004755 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004756 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004757 yyvsp[-6].PHIList->push_back(std::make_pair(tmpVal, tmpBB));
4758 ;
4759 break;}
4760case 286:
4761#line 2762 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4762{
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004763 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004764 if (!UpRefs.empty())
Scott Michel6d1aba82008-01-30 03:10:00 +00004765 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004766 // Used for call and invoke instructions
Scott Michel6d1aba82008-01-30 03:10:00 +00004767 yyval.ParamList = new ParamList();
4768 ParamListEntry E; E.Attrs = yyvsp[-2].ParamAttrs | yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-3].TypeVal->get(), yyvsp[-1].ValIDVal);
4769 yyval.ParamList->push_back(E);
4770 delete yyvsp[-3].TypeVal;
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004771 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004772 ;
4773 break;}
4774case 287:
4775#line 2773 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4776{
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004777 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Dale Johannesencfb19e62007-11-05 21:20:28 +00004778 // Labels are only valid in ASMs
Scott Michel6d1aba82008-01-30 03:10:00 +00004779 yyval.ParamList = new ParamList();
4780 ParamListEntry E; E.Attrs = yyvsp[-2].ParamAttrs | yyvsp[0].ParamAttrs; E.Val = getBBVal(yyvsp[-1].ValIDVal);
4781 yyval.ParamList->push_back(E);
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004782 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004783 ;
4784 break;}
4785case 288:
4786#line 2781 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4787{
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004788 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004789 if (!UpRefs.empty())
Scott Michel6d1aba82008-01-30 03:10:00 +00004790 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4791 yyval.ParamList = yyvsp[-5].ParamList;
4792 ParamListEntry E; E.Attrs = yyvsp[-2].ParamAttrs | yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-3].TypeVal->get(), yyvsp[-1].ValIDVal);
4793 yyval.ParamList->push_back(E);
4794 delete yyvsp[-3].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004795 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004796 ;
4797 break;}
4798case 289:
4799#line 2791 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4800{
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004801 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Scott Michel6d1aba82008-01-30 03:10:00 +00004802 yyval.ParamList = yyvsp[-5].ParamList;
4803 ParamListEntry E; E.Attrs = yyvsp[-2].ParamAttrs | yyvsp[0].ParamAttrs; E.Val = getBBVal(yyvsp[-1].ValIDVal);
4804 yyval.ParamList->push_back(E);
Dale Johannesencfb19e62007-11-05 21:20:28 +00004805 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004806 ;
4807 break;}
4808case 290:
4809#line 2798 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4810{ yyval.ParamList = new ParamList(); ;
4811 break;}
4812case 291:
4813#line 2801 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4814{ yyval.ValueList = new std::vector<Value*>(); ;
4815 break;}
4816case 292:
4817#line 2802 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4818{
4819 yyval.ValueList = yyvsp[-2].ValueList;
4820 yyval.ValueList->push_back(yyvsp[0].ValueVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004821 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004822 ;
4823 break;}
4824case 293:
4825#line 2809 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4826{
4827 yyval.BoolVal = true;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004828 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004829 ;
4830 break;}
4831case 294:
4832#line 2813 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4833{
4834 yyval.BoolVal = false;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004835 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004836 ;
4837 break;}
4838case 295:
4839#line 2818 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4840{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004841 if (!UpRefs.empty())
Scott Michel6d1aba82008-01-30 03:10:00 +00004842 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4843 if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
4844 !isa<VectorType>((*yyvsp[-3].TypeVal).get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004845 GEN_ERROR(
4846 "Arithmetic operator requires integer, FP, or packed operands");
Scott Michel6d1aba82008-01-30 03:10:00 +00004847 Value* val1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004848 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004849 Value* val2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004850 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004851 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, val1, val2);
4852 if (yyval.InstVal == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004853 GEN_ERROR("binary operator returned null");
Scott Michel6d1aba82008-01-30 03:10:00 +00004854 delete yyvsp[-3].TypeVal;
4855 ;
4856 break;}
4857case 296:
4858#line 2834 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4859{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004860 if (!UpRefs.empty())
Scott Michel6d1aba82008-01-30 03:10:00 +00004861 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4862 if (!(*yyvsp[-3].TypeVal)->isInteger()) {
4863 if (Instruction::isShift(yyvsp[-4].BinaryOpVal) || !isa<VectorType>(yyvsp[-3].TypeVal->get()) ||
4864 !cast<VectorType>(yyvsp[-3].TypeVal->get())->getElementType()->isInteger())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004865 GEN_ERROR("Logical operator requires integral operands");
4866 }
Scott Michel6d1aba82008-01-30 03:10:00 +00004867 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004868 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004869 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004870 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004871 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, tmpVal1, tmpVal2);
4872 if (yyval.InstVal == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004873 GEN_ERROR("binary operator returned null");
Scott Michel6d1aba82008-01-30 03:10:00 +00004874 delete yyvsp[-3].TypeVal;
4875 ;
4876 break;}
4877case 297:
4878#line 2851 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4879{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004880 if (!UpRefs.empty())
Scott Michel6d1aba82008-01-30 03:10:00 +00004881 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4882 if (isa<VectorType>((*yyvsp[-3].TypeVal).get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004883 GEN_ERROR("Vector types not supported by icmp instruction");
Scott Michel6d1aba82008-01-30 03:10:00 +00004884 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004885 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004886 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004887 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004888 yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].IPredicate, tmpVal1, tmpVal2);
4889 if (yyval.InstVal == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004890 GEN_ERROR("icmp operator returned null");
Scott Michel6d1aba82008-01-30 03:10:00 +00004891 delete yyvsp[-3].TypeVal;
4892 ;
4893 break;}
4894case 298:
4895#line 2865 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4896{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004897 if (!UpRefs.empty())
Scott Michel6d1aba82008-01-30 03:10:00 +00004898 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4899 if (isa<VectorType>((*yyvsp[-3].TypeVal).get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004900 GEN_ERROR("Vector types not supported by fcmp instruction");
Scott Michel6d1aba82008-01-30 03:10:00 +00004901 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004902 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004903 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004904 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004905 yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].FPredicate, tmpVal1, tmpVal2);
4906 if (yyval.InstVal == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004907 GEN_ERROR("fcmp operator returned null");
Scott Michel6d1aba82008-01-30 03:10:00 +00004908 delete yyvsp[-3].TypeVal;
4909 ;
4910 break;}
4911case 299:
4912#line 2879 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4913{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004914 if (!UpRefs.empty())
Scott Michel6d1aba82008-01-30 03:10:00 +00004915 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
4916 Value* Val = yyvsp[-2].ValueVal;
4917 const Type* DestTy = yyvsp[0].TypeVal->get();
4918 if (!CastInst::castIsValid(yyvsp[-3].CastOpVal, Val, DestTy))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004919 GEN_ERROR("invalid cast opcode for cast from '" +
4920 Val->getType()->getDescription() + "' to '" +
4921 DestTy->getDescription() + "'");
Scott Michel6d1aba82008-01-30 03:10:00 +00004922 yyval.InstVal = CastInst::create(yyvsp[-3].CastOpVal, Val, DestTy);
4923 delete yyvsp[0].TypeVal;
4924 ;
4925 break;}
4926case 300:
4927#line 2891 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4928{
4929 if (yyvsp[-4].ValueVal->getType() != Type::Int1Ty)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004930 GEN_ERROR("select condition must be boolean");
Scott Michel6d1aba82008-01-30 03:10:00 +00004931 if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004932 GEN_ERROR("select value types should match");
Scott Michel6d1aba82008-01-30 03:10:00 +00004933 yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004934 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004935 ;
4936 break;}
4937case 301:
4938#line 2899 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4939{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004940 if (!UpRefs.empty())
Scott Michel6d1aba82008-01-30 03:10:00 +00004941 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
4942 yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
4943 delete yyvsp[0].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004944 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004945 ;
4946 break;}
4947case 302:
4948#line 2906 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4949{
4950 if (!ExtractElementInst::isValidOperands(yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004951 GEN_ERROR("Invalid extractelement operands");
Scott Michel6d1aba82008-01-30 03:10:00 +00004952 yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004953 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004954 ;
4955 break;}
4956case 303:
4957#line 2912 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4958{
4959 if (!InsertElementInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004960 GEN_ERROR("Invalid insertelement operands");
Scott Michel6d1aba82008-01-30 03:10:00 +00004961 yyval.InstVal = new InsertElementInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004962 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004963 ;
4964 break;}
4965case 304:
4966#line 2918 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4967{
4968 if (!ShuffleVectorInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004969 GEN_ERROR("Invalid shufflevector operands");
Scott Michel6d1aba82008-01-30 03:10:00 +00004970 yyval.InstVal = new ShuffleVectorInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004971 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004972 ;
4973 break;}
4974case 305:
4975#line 2924 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4976{
4977 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004978 if (!Ty->isFirstClassType())
4979 GEN_ERROR("PHI node operands must be of first class type");
Scott Michel6d1aba82008-01-30 03:10:00 +00004980 yyval.InstVal = new PHINode(Ty);
4981 ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
4982 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
4983 if (yyvsp[0].PHIList->front().first->getType() != Ty)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004984 GEN_ERROR("All elements of a PHI node must be of the same type");
Scott Michel6d1aba82008-01-30 03:10:00 +00004985 cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
4986 yyvsp[0].PHIList->pop_front();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004987 }
Scott Michel6d1aba82008-01-30 03:10:00 +00004988 delete yyvsp[0].PHIList; // Free the list...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004989 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00004990 ;
4991 break;}
4992case 306:
4993#line 2940 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4994{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004995
4996 // Handle the short syntax
4997 const PointerType *PFTy = 0;
4998 const FunctionType *Ty = 0;
Scott Michel6d1aba82008-01-30 03:10:00 +00004999 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-5].TypeVal->get())) ||
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005000 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5001 // Pull out the types of all of the arguments...
5002 std::vector<const Type*> ParamTypes;
Scott Michel6d1aba82008-01-30 03:10:00 +00005003 ParamList::iterator I = yyvsp[-2].ParamList->begin(), E = yyvsp[-2].ParamList->end();
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005004 for (; I != E; ++I) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005005 const Type *Ty = I->Val->getType();
5006 if (Ty == Type::VoidTy)
5007 GEN_ERROR("Short call syntax cannot be used with varargs");
5008 ParamTypes.push_back(Ty);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005009 }
Scott Michel6d1aba82008-01-30 03:10:00 +00005010 Ty = FunctionType::get(yyvsp[-5].TypeVal->get(), ParamTypes, false);
Christopher Lambfb623c62007-12-17 01:17:35 +00005011 PFTy = PointerType::getUnqual(Ty);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005012 }
5013
Scott Michel6d1aba82008-01-30 03:10:00 +00005014 Value *V = getVal(PFTy, yyvsp[-4].ValIDVal); // Get the function we're calling...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005015 CHECK_FOR_ERROR
5016
5017 // Check for call to invalid intrinsic to avoid crashing later.
5018 if (Function *theF = dyn_cast<Function>(V)) {
5019 if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) &&
5020 (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) &&
5021 !theF->getIntrinsicID(true))
5022 GEN_ERROR("Call to invalid LLVM intrinsic function '" +
5023 theF->getName() + "'");
5024 }
5025
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005026 // Set up the ParamAttrs for the function
5027 ParamAttrsVector Attrs;
Scott Michel6d1aba82008-01-30 03:10:00 +00005028 if (yyvsp[0].ParamAttrs != ParamAttr::None) {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005029 ParamAttrsWithIndex PAWI;
5030 PAWI.index = 0;
Scott Michel6d1aba82008-01-30 03:10:00 +00005031 PAWI.attrs = yyvsp[0].ParamAttrs;
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005032 Attrs.push_back(PAWI);
5033 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005034 // Check the arguments
5035 ValueList Args;
Scott Michel6d1aba82008-01-30 03:10:00 +00005036 if (yyvsp[-2].ParamList->empty()) { // Has no arguments?
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005037 // Make sure no arguments is a good thing!
5038 if (Ty->getNumParams() != 0)
5039 GEN_ERROR("No arguments passed to a function that "
5040 "expects arguments");
5041 } else { // Has arguments?
5042 // Loop through FunctionType's arguments and ensure they are specified
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005043 // correctly. Also, gather any parameter attributes.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005044 FunctionType::param_iterator I = Ty->param_begin();
5045 FunctionType::param_iterator E = Ty->param_end();
Scott Michel6d1aba82008-01-30 03:10:00 +00005046 ParamList::iterator ArgI = yyvsp[-2].ParamList->begin(), ArgE = yyvsp[-2].ParamList->end();
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005047 unsigned index = 1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005048
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005049 for (; ArgI != ArgE && I != E; ++ArgI, ++I, ++index) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005050 if (ArgI->Val->getType() != *I)
5051 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
5052 (*I)->getDescription() + "'");
5053 Args.push_back(ArgI->Val);
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005054 if (ArgI->Attrs != ParamAttr::None) {
5055 ParamAttrsWithIndex PAWI;
5056 PAWI.index = index;
5057 PAWI.attrs = ArgI->Attrs;
5058 Attrs.push_back(PAWI);
5059 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005060 }
5061 if (Ty->isVarArg()) {
5062 if (I == E)
Scott Michel6d1aba82008-01-30 03:10:00 +00005063 for (; ArgI != ArgE; ++ArgI)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005064 Args.push_back(ArgI->Val); // push the remaining varargs
5065 } else if (I != E || ArgI != ArgE)
5066 GEN_ERROR("Invalid number of parameters detected");
5067 }
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005068
5069 // Finish off the ParamAttrs and check them
Duncan Sands637ec552007-11-28 17:07:01 +00005070 const ParamAttrsList *PAL = 0;
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005071 if (!Attrs.empty())
5072 PAL = ParamAttrsList::get(Attrs);
5073
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005074 // Create the call node
David Greene9145dd22007-08-01 03:59:32 +00005075 CallInst *CI = new CallInst(V, Args.begin(), Args.end());
Scott Michel6d1aba82008-01-30 03:10:00 +00005076 CI->setTailCall(yyvsp[-7].BoolVal);
5077 CI->setCallingConv(yyvsp[-6].UIntVal);
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005078 CI->setParamAttrs(PAL);
Scott Michel6d1aba82008-01-30 03:10:00 +00005079 yyval.InstVal = CI;
5080 delete yyvsp[-2].ParamList;
5081 delete yyvsp[-5].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005082 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00005083 ;
5084 break;}
5085case 307:
5086#line 3030 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
5087{
5088 yyval.InstVal = yyvsp[0].InstVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005089 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00005090 ;
5091 break;}
5092case 308:
5093#line 3035 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
5094{
5095 yyval.BoolVal = true;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005096 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00005097 ;
5098 break;}
5099case 309:
5100#line 3039 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
5101{
5102 yyval.BoolVal = false;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005103 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00005104 ;
5105 break;}
5106case 310:
5107#line 3046 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
5108{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005109 if (!UpRefs.empty())
Scott Michel6d1aba82008-01-30 03:10:00 +00005110 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
5111 yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
5112 delete yyvsp[-1].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005113 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00005114 ;
5115 break;}
5116case 311:
5117#line 3053 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
5118{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005119 if (!UpRefs.empty())
Scott Michel6d1aba82008-01-30 03:10:00 +00005120 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
5121 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005122 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00005123 yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
5124 delete yyvsp[-4].TypeVal;
5125 ;
5126 break;}
5127case 312:
5128#line 3061 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
5129{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005130 if (!UpRefs.empty())
Scott Michel6d1aba82008-01-30 03:10:00 +00005131 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
5132 yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
5133 delete yyvsp[-1].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005134 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00005135 ;
5136 break;}
5137case 313:
5138#line 3068 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
5139{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005140 if (!UpRefs.empty())
Scott Michel6d1aba82008-01-30 03:10:00 +00005141 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
5142 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005143 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00005144 yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
5145 delete yyvsp[-4].TypeVal;
5146 ;
5147 break;}
5148case 314:
5149#line 3076 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
5150{
5151 if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005152 GEN_ERROR("Trying to free nonpointer type " +
Scott Michel6d1aba82008-01-30 03:10:00 +00005153 yyvsp[0].ValueVal->getType()->getDescription() + "");
5154 yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005155 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00005156 ;
5157 break;}
5158case 315:
5159#line 3084 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
5160{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005161 if (!UpRefs.empty())
Scott Michel6d1aba82008-01-30 03:10:00 +00005162 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
5163 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005164 GEN_ERROR("Can't load from nonpointer type: " +
Scott Michel6d1aba82008-01-30 03:10:00 +00005165 (*yyvsp[-2].TypeVal)->getDescription());
5166 if (!cast<PointerType>(yyvsp[-2].TypeVal->get())->getElementType()->isFirstClassType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005167 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Scott Michel6d1aba82008-01-30 03:10:00 +00005168 (*yyvsp[-2].TypeVal)->getDescription());
5169 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005170 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00005171 yyval.InstVal = new LoadInst(tmpVal, "", yyvsp[-4].BoolVal, yyvsp[0].UIntVal);
5172 delete yyvsp[-2].TypeVal;
5173 ;
5174 break;}
5175case 316:
5176#line 3098 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
5177{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005178 if (!UpRefs.empty())
Scott Michel6d1aba82008-01-30 03:10:00 +00005179 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
5180 const PointerType *PT = dyn_cast<PointerType>(yyvsp[-2].TypeVal->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005181 if (!PT)
5182 GEN_ERROR("Can't store to a nonpointer type: " +
Scott Michel6d1aba82008-01-30 03:10:00 +00005183 (*yyvsp[-2].TypeVal)->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005184 const Type *ElTy = PT->getElementType();
Scott Michel6d1aba82008-01-30 03:10:00 +00005185 if (ElTy != yyvsp[-4].ValueVal->getType())
5186 GEN_ERROR("Can't store '" + yyvsp[-4].ValueVal->getType()->getDescription() +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005187 "' into space of type '" + ElTy->getDescription() + "'");
5188
Scott Michel6d1aba82008-01-30 03:10:00 +00005189 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005190 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00005191 yyval.InstVal = new StoreInst(yyvsp[-4].ValueVal, tmpVal, yyvsp[-6].BoolVal, yyvsp[0].UIntVal);
5192 delete yyvsp[-2].TypeVal;
5193 ;
5194 break;}
5195case 317:
5196#line 3115 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
5197{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005198 if (!UpRefs.empty())
Scott Michel6d1aba82008-01-30 03:10:00 +00005199 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
5200 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005201 GEN_ERROR("getelementptr insn requires pointer operand");
5202
Scott Michel6d1aba82008-01-30 03:10:00 +00005203 if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end(), true))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005204 GEN_ERROR("Invalid getelementptr indices for type '" +
Scott Michel6d1aba82008-01-30 03:10:00 +00005205 (*yyvsp[-2].TypeVal)->getDescription()+ "'");
5206 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005207 CHECK_FOR_ERROR
Scott Michel6d1aba82008-01-30 03:10:00 +00005208 yyval.InstVal = new GetElementPtrInst(tmpVal, yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end());
5209 delete yyvsp[-2].TypeVal;
5210 delete yyvsp[0].ValueList;
5211 ;
5212 break;}
5213}
5214 /* the action file gets copied in in place of this dollarsign */
5215#line 543 "/usr/share/bison.simple"
5216
5217 yyvsp -= yylen;
5218 yyssp -= yylen;
5219#ifdef YYLSP_NEEDED
5220 yylsp -= yylen;
5221#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005222
Scott Michel6d1aba82008-01-30 03:10:00 +00005223#if YYDEBUG != 0
5224 if (yydebug)
5225 {
5226 short *ssp1 = yyss - 1;
5227 fprintf (stderr, "state stack now");
5228 while (ssp1 != yyssp)
5229 fprintf (stderr, " %d", *++ssp1);
5230 fprintf (stderr, "\n");
Dale Johannesen3afee192007-09-07 21:07:57 +00005231 }
Scott Michel6d1aba82008-01-30 03:10:00 +00005232#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005233
5234 *++yyvsp = yyval;
5235
Scott Michel6d1aba82008-01-30 03:10:00 +00005236#ifdef YYLSP_NEEDED
5237 yylsp++;
5238 if (yylen == 0)
5239 {
5240 yylsp->first_line = yylloc.first_line;
5241 yylsp->first_column = yylloc.first_column;
5242 yylsp->last_line = (yylsp-1)->last_line;
5243 yylsp->last_column = (yylsp-1)->last_column;
5244 yylsp->text = 0;
5245 }
5246 else
5247 {
5248 yylsp->last_line = (yylsp+yylen-1)->last_line;
5249 yylsp->last_column = (yylsp+yylen-1)->last_column;
5250 }
5251#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005252
Scott Michel6d1aba82008-01-30 03:10:00 +00005253 /* Now "shift" the result of the reduction.
5254 Determine what state that goes to,
5255 based on the state we popped back to
5256 and the rule number reduced by. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005257
5258 yyn = yyr1[yyn];
5259
Scott Michel6d1aba82008-01-30 03:10:00 +00005260 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
5261 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005262 yystate = yytable[yystate];
5263 else
Scott Michel6d1aba82008-01-30 03:10:00 +00005264 yystate = yydefgoto[yyn - YYNTBASE];
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005265
5266 goto yynewstate;
5267
Scott Michel6d1aba82008-01-30 03:10:00 +00005268yyerrlab: /* here on detecting error */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005269
Scott Michel6d1aba82008-01-30 03:10:00 +00005270 if (! yyerrstatus)
5271 /* If not already recovering from an error, report this error. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005272 {
5273 ++yynerrs;
Dale Johannesen3afee192007-09-07 21:07:57 +00005274
Scott Michel6d1aba82008-01-30 03:10:00 +00005275#ifdef YYERROR_VERBOSE
5276 yyn = yypact[yystate];
5277
5278 if (yyn > YYFLAG && yyn < YYLAST)
5279 {
5280 int size = 0;
5281 char *msg;
5282 int x, count;
5283
5284 count = 0;
5285 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
5286 for (x = (yyn < 0 ? -yyn : 0);
5287 x < (sizeof(yytname) / sizeof(char *)); x++)
5288 if (yycheck[x + yyn] == x)
5289 size += strlen(yytname[x]) + 15, count++;
5290 msg = (char *) malloc(size + 15);
5291 if (msg != 0)
5292 {
5293 strcpy(msg, "parse error");
5294
5295 if (count < 5)
5296 {
5297 count = 0;
5298 for (x = (yyn < 0 ? -yyn : 0);
5299 x < (sizeof(yytname) / sizeof(char *)); x++)
5300 if (yycheck[x + yyn] == x)
5301 {
5302 strcat(msg, count == 0 ? ", expecting `" : " or `");
5303 strcat(msg, yytname[x]);
5304 strcat(msg, "'");
5305 count++;
5306 }
5307 }
5308 yyerror(msg);
5309 free(msg);
5310 }
5311 else
5312 yyerror ("parse error; also virtual memory exceeded");
5313 }
5314 else
5315#endif /* YYERROR_VERBOSE */
5316 yyerror("parse error");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005317 }
5318
Scott Michel6d1aba82008-01-30 03:10:00 +00005319 goto yyerrlab1;
5320yyerrlab1: /* here on error raised explicitly by an action */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005321
5322 if (yyerrstatus == 3)
5323 {
Scott Michel6d1aba82008-01-30 03:10:00 +00005324 /* if just tried and failed to reuse lookahead token after an error, discard it. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005325
Scott Michel6d1aba82008-01-30 03:10:00 +00005326 /* return failure if at end of input */
5327 if (yychar == YYEOF)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005328 YYABORT;
5329
Scott Michel6d1aba82008-01-30 03:10:00 +00005330#if YYDEBUG != 0
5331 if (yydebug)
5332 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
5333#endif
Dale Johannesen3afee192007-09-07 21:07:57 +00005334
Scott Michel6d1aba82008-01-30 03:10:00 +00005335 yychar = YYEMPTY;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005336 }
5337
Scott Michel6d1aba82008-01-30 03:10:00 +00005338 /* Else will try to reuse lookahead token
5339 after shifting the error token. */
5340
5341 yyerrstatus = 3; /* Each real token shifted decrements this */
5342
5343 goto yyerrhandle;
5344
5345yyerrdefault: /* current state does not do anything special for the error token. */
5346
5347#if 0
5348 /* This is wrong; only states that explicitly want error tokens
5349 should shift them. */
5350 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
5351 if (yyn) goto yydefault;
5352#endif
5353
5354yyerrpop: /* pop the current state because it cannot handle the error token */
5355
5356 if (yyssp == yyss) YYABORT;
5357 yyvsp--;
5358 yystate = *--yyssp;
5359#ifdef YYLSP_NEEDED
5360 yylsp--;
5361#endif
5362
5363#if YYDEBUG != 0
5364 if (yydebug)
5365 {
5366 short *ssp1 = yyss - 1;
5367 fprintf (stderr, "Error: state stack now");
5368 while (ssp1 != yyssp)
5369 fprintf (stderr, " %d", *++ssp1);
5370 fprintf (stderr, "\n");
5371 }
5372#endif
5373
5374yyerrhandle:
5375
5376 yyn = yypact[yystate];
5377 if (yyn == YYFLAG)
5378 goto yyerrdefault;
5379
5380 yyn += YYTERROR;
5381 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
5382 goto yyerrdefault;
5383
5384 yyn = yytable[yyn];
5385 if (yyn < 0)
5386 {
5387 if (yyn == YYFLAG)
5388 goto yyerrpop;
5389 yyn = -yyn;
5390 goto yyreduce;
5391 }
5392 else if (yyn == 0)
5393 goto yyerrpop;
5394
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005395 if (yyn == YYFINAL)
5396 YYACCEPT;
5397
Scott Michel6d1aba82008-01-30 03:10:00 +00005398#if YYDEBUG != 0
5399 if (yydebug)
5400 fprintf(stderr, "Shifting error token, ");
5401#endif
5402
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005403 *++yyvsp = yylval;
Scott Michel6d1aba82008-01-30 03:10:00 +00005404#ifdef YYLSP_NEEDED
5405 *++yylsp = yylloc;
5406#endif
Reid Spenceraa8ae282007-07-31 03:50:36 +00005407
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005408 yystate = yyn;
5409 goto yynewstate;
5410
Scott Michel6d1aba82008-01-30 03:10:00 +00005411 yyacceptlab:
5412 /* YYACCEPT comes here. */
5413 if (yyfree_stacks)
Scott Michel5a6f17b2008-01-30 02:55:46 +00005414 {
Scott Michel6d1aba82008-01-30 03:10:00 +00005415 free (yyss);
5416 free (yyvs);
5417#ifdef YYLSP_NEEDED
5418 free (yyls);
5419#endif
Christopher Lamb0a243582007-12-11 09:02:08 +00005420 }
Scott Michel6d1aba82008-01-30 03:10:00 +00005421 return 0;
5422
5423 yyabortlab:
5424 /* YYABORT comes here. */
5425 if (yyfree_stacks)
5426 {
5427 free (yyss);
5428 free (yyvs);
5429#ifdef YYLSP_NEEDED
5430 free (yyls);
Scott Michel5a6f17b2008-01-30 02:55:46 +00005431#endif
Scott Michel6d1aba82008-01-30 03:10:00 +00005432 }
5433 return 1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005434}
Scott Michel6d1aba82008-01-30 03:10:00 +00005435#line 3132 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005436
5437
5438// common code from the two 'RunVMAsmParser' functions
5439static Module* RunParser(Module * M) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005440 CurModule.CurrentModule = M;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005441 // Check to make sure the parser succeeded
5442 if (yyparse()) {
5443 if (ParserResult)
5444 delete ParserResult;
5445 return 0;
5446 }
5447
5448 // Emit an error if there are any unresolved types left.
5449 if (!CurModule.LateResolveTypes.empty()) {
5450 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
5451 if (DID.Type == ValID::LocalName) {
5452 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
5453 } else {
5454 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
5455 }
5456 if (ParserResult)
5457 delete ParserResult;
5458 return 0;
5459 }
5460
5461 // Emit an error if there are any unresolved values left.
5462 if (!CurModule.LateResolveValues.empty()) {
5463 Value *V = CurModule.LateResolveValues.back();
5464 std::map<Value*, std::pair<ValID, int> >::iterator I =
5465 CurModule.PlaceHolderInfo.find(V);
5466
5467 if (I != CurModule.PlaceHolderInfo.end()) {
5468 ValID &DID = I->second.first;
5469 if (DID.Type == ValID::LocalName) {
5470 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
5471 } else {
5472 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
5473 }
5474 if (ParserResult)
5475 delete ParserResult;
5476 return 0;
5477 }
5478 }
5479
5480 // Check to make sure that parsing produced a result
5481 if (!ParserResult)
5482 return 0;
5483
5484 // Reset ParserResult variable while saving its value for the result.
5485 Module *Result = ParserResult;
5486 ParserResult = 0;
5487
5488 return Result;
5489}
5490
5491void llvm::GenerateError(const std::string &message, int LineNo) {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005492 if (LineNo == -1) LineNo = LLLgetLineNo();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005493 // TODO: column number in exception
5494 if (TheParseError)
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005495 TheParseError->setError(LLLgetFilename(), message, LineNo);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005496 TriggerError = 1;
5497}
5498
5499int yyerror(const char *ErrorMsg) {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005500 std::string where = LLLgetFilename() + ":" + utostr(LLLgetLineNo()) + ": ";
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005501 std::string errMsg = where + "error: " + std::string(ErrorMsg);
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005502 if (yychar != YYEMPTY && yychar != 0) {
5503 errMsg += " while reading token: '";
5504 errMsg += std::string(LLLgetTokenStart(),
5505 LLLgetTokenStart()+LLLgetTokenLength()) + "'";
5506 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005507 GenerateError(errMsg);
5508 return 0;
5509}