blob: e0952f2796fd5e02bee859d601fcbb06ec413658 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001
Dale Johannesen3afee192007-09-07 21:07:57 +00002/* A Bison parser, made from /Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y
3 by GNU Bison version 1.28 */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004
Dale Johannesen3afee192007-09-07 21:07:57 +00005#define YYBISON 1 /* Identify Bison output. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006
7#define yyparse llvmAsmparse
Dale Johannesen3afee192007-09-07 21:07:57 +00008#define yylex llvmAsmlex
Dan Gohmanf17a25c2007-07-18 16:29:46 +00009#define yyerror llvmAsmerror
Dale Johannesen3afee192007-09-07 21:07:57 +000010#define yylval llvmAsmlval
11#define yychar llvmAsmchar
Dan Gohmanf17a25c2007-07-18 16:29:46 +000012#define yydebug llvmAsmdebug
13#define yynerrs llvmAsmnerrs
Dale Johannesen3afee192007-09-07 21:07:57 +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 DEPLIBS 308
66#define CALL 309
67#define TAIL 310
68#define ASM_TOK 311
69#define MODULE 312
70#define SIDEEFFECT 313
71#define CC_TOK 314
72#define CCC_TOK 315
73#define FASTCC_TOK 316
74#define COLDCC_TOK 317
75#define X86_STDCALLCC_TOK 318
76#define X86_FASTCALLCC_TOK 319
77#define DATALAYOUT 320
78#define RET 321
79#define BR 322
80#define SWITCH 323
81#define INVOKE 324
82#define UNWIND 325
83#define UNREACHABLE 326
84#define ADD 327
85#define SUB 328
86#define MUL 329
87#define UDIV 330
88#define SDIV 331
89#define FDIV 332
90#define UREM 333
91#define SREM 334
92#define FREM 335
93#define AND 336
94#define OR 337
95#define XOR 338
96#define SHL 339
97#define LSHR 340
98#define ASHR 341
99#define ICMP 342
100#define FCMP 343
101#define EQ 344
102#define NE 345
103#define SLT 346
104#define SGT 347
105#define SLE 348
106#define SGE 349
107#define ULT 350
108#define UGT 351
109#define ULE 352
110#define UGE 353
111#define OEQ 354
112#define ONE 355
113#define OLT 356
114#define OGT 357
115#define OLE 358
116#define OGE 359
117#define ORD 360
118#define UNO 361
119#define UEQ 362
120#define UNE 363
121#define MALLOC 364
122#define ALLOCA 365
123#define FREE 366
124#define LOAD 367
125#define STORE 368
126#define GETELEMENTPTR 369
127#define TRUNC 370
128#define ZEXT 371
129#define SEXT 372
130#define FPTRUNC 373
131#define FPEXT 374
132#define BITCAST 375
133#define UITOFP 376
134#define SITOFP 377
135#define FPTOUI 378
136#define FPTOSI 379
137#define INTTOPTR 380
138#define PTRTOINT 381
139#define PHI_TOK 382
140#define SELECT 383
141#define VAARG 384
142#define EXTRACTELEMENT 385
143#define INSERTELEMENT 386
144#define SHUFFLEVECTOR 387
145#define SIGNEXT 388
146#define ZEROEXT 389
147#define NORETURN 390
148#define INREG 391
149#define SRET 392
150#define NOUNWIND 393
151#define NOALIAS 394
152#define BYVAL 395
153#define NEST 396
154#define DEFAULT 397
155#define HIDDEN 398
156#define PROTECTED 399
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000157
Dale Johannesen3afee192007-09-07 21:07:57 +0000158#line 14 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000159
160#include "ParserInternals.h"
161#include "llvm/CallingConv.h"
162#include "llvm/InlineAsm.h"
163#include "llvm/Instructions.h"
164#include "llvm/Module.h"
165#include "llvm/ValueSymbolTable.h"
Chandler Carruth563d4a42007-08-04 01:56:21 +0000166#include "llvm/AutoUpgrade.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000167#include "llvm/Support/GetElementPtrTypeIterator.h"
168#include "llvm/Support/CommandLine.h"
169#include "llvm/ADT/SmallVector.h"
170#include "llvm/ADT/STLExtras.h"
171#include "llvm/Support/MathExtras.h"
172#include "llvm/Support/Streams.h"
173#include <algorithm>
174#include <list>
175#include <map>
176#include <utility>
177#ifndef NDEBUG
178#define YYDEBUG 1
179#endif
180
181// The following is a gross hack. In order to rid the libAsmParser library of
182// exceptions, we have to have a way of getting the yyparse function to go into
183// an error situation. So, whenever we want an error to occur, the GenerateError
184// function (see bottom of file) sets TriggerError. Then, at the end of each
185// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
186// (a goto) to put YACC in error state. Furthermore, several calls to
187// GenerateError are made from inside productions and they must simulate the
188// previous exception behavior by exiting the production immediately. We have
189// replaced these with the GEN_ERROR macro which calls GeneratError and then
190// immediately invokes YYERROR. This would be so much cleaner if it was a
191// recursive descent parser.
192static bool TriggerError = false;
193#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
194#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
195
196int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
197int yylex(); // declaration" of xxx warnings.
198int yyparse();
199
200namespace llvm {
201 std::string CurFilename;
202#if YYDEBUG
203static cl::opt<bool>
204Debug("debug-yacc", cl::desc("Print yacc debug state changes"),
205 cl::Hidden, cl::init(false));
206#endif
207}
208using namespace llvm;
209
210static Module *ParserResult;
211
212// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
213// relating to upreferences in the input stream.
214//
215//#define DEBUG_UPREFS 1
216#ifdef DEBUG_UPREFS
217#define UR_OUT(X) cerr << X
218#else
219#define UR_OUT(X)
220#endif
221
222#define YYERROR_VERBOSE 1
223
224static GlobalVariable *CurGV;
225
226
227// This contains info used when building the body of a function. It is
228// destroyed when the function is completed.
229//
230typedef std::vector<Value *> ValueList; // Numbered defs
231
232static void
233ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0);
234
235static struct PerModuleInfo {
236 Module *CurrentModule;
237 ValueList Values; // Module level numbered definitions
238 ValueList LateResolveValues;
239 std::vector<PATypeHolder> Types;
240 std::map<ValID, PATypeHolder> LateResolveTypes;
241
242 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
243 /// how they were referenced and on which line of the input they came from so
244 /// that we can resolve them later and print error messages as appropriate.
245 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
246
247 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
248 // references to global values. Global values may be referenced before they
249 // are defined, and if so, the temporary object that they represent is held
250 // here. This is used for forward references of GlobalValues.
251 //
252 typedef std::map<std::pair<const PointerType *,
253 ValID>, GlobalValue*> GlobalRefsType;
254 GlobalRefsType GlobalRefs;
255
256 void ModuleDone() {
257 // If we could not resolve some functions at function compilation time
258 // (calls to functions before they are defined), resolve them now... Types
259 // are resolved when the constant pool has been completely parsed.
260 //
261 ResolveDefinitions(LateResolveValues);
262 if (TriggerError)
263 return;
264
265 // Check to make sure that all global value forward references have been
266 // resolved!
267 //
268 if (!GlobalRefs.empty()) {
269 std::string UndefinedReferences = "Unresolved global references exist:\n";
270
271 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
272 I != E; ++I) {
273 UndefinedReferences += " " + I->first.first->getDescription() + " " +
274 I->first.second.getName() + "\n";
275 }
276 GenerateError(UndefinedReferences);
277 return;
278 }
279
Chandler Carruth563d4a42007-08-04 01:56:21 +0000280 // Look for intrinsic functions and CallInst that need to be upgraded
281 for (Module::iterator FI = CurrentModule->begin(),
282 FE = CurrentModule->end(); FI != FE; )
283 UpgradeCallsToIntrinsic(FI++); // must be post-increment, as we remove
284
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000285 Values.clear(); // Clear out function local definitions
286 Types.clear();
287 CurrentModule = 0;
288 }
289
290 // GetForwardRefForGlobal - Check to see if there is a forward reference
291 // for this global. If so, remove it from the GlobalRefs map and return it.
292 // If not, just return null.
293 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
294 // Check to see if there is a forward reference to this global variable...
295 // if there is, eliminate it and patch the reference to use the new def'n.
296 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
297 GlobalValue *Ret = 0;
298 if (I != GlobalRefs.end()) {
299 Ret = I->second;
300 GlobalRefs.erase(I);
301 }
302 return Ret;
303 }
304
305 bool TypeIsUnresolved(PATypeHolder* PATy) {
306 // If it isn't abstract, its resolved
307 const Type* Ty = PATy->get();
308 if (!Ty->isAbstract())
309 return false;
310 // Traverse the type looking for abstract types. If it isn't abstract then
311 // we don't need to traverse that leg of the type.
312 std::vector<const Type*> WorkList, SeenList;
313 WorkList.push_back(Ty);
314 while (!WorkList.empty()) {
315 const Type* Ty = WorkList.back();
316 SeenList.push_back(Ty);
317 WorkList.pop_back();
318 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
319 // Check to see if this is an unresolved type
320 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
321 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
322 for ( ; I != E; ++I) {
323 if (I->second.get() == OpTy)
324 return true;
325 }
326 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
327 const Type* TheTy = SeqTy->getElementType();
328 if (TheTy->isAbstract() && TheTy != Ty) {
329 std::vector<const Type*>::iterator I = SeenList.begin(),
330 E = SeenList.end();
331 for ( ; I != E; ++I)
332 if (*I == TheTy)
333 break;
334 if (I == E)
335 WorkList.push_back(TheTy);
336 }
337 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
338 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
339 const Type* TheTy = StrTy->getElementType(i);
340 if (TheTy->isAbstract() && TheTy != Ty) {
341 std::vector<const Type*>::iterator I = SeenList.begin(),
342 E = SeenList.end();
343 for ( ; I != E; ++I)
344 if (*I == TheTy)
345 break;
346 if (I == E)
347 WorkList.push_back(TheTy);
348 }
349 }
350 }
351 }
352 return false;
353 }
354} CurModule;
355
356static struct PerFunctionInfo {
357 Function *CurrentFunction; // Pointer to current function being created
358
359 ValueList Values; // Keep track of #'d definitions
360 unsigned NextValNum;
361 ValueList LateResolveValues;
362 bool isDeclare; // Is this function a forward declararation?
363 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
364 GlobalValue::VisibilityTypes Visibility;
365
366 /// BBForwardRefs - When we see forward references to basic blocks, keep
367 /// track of them here.
368 std::map<ValID, BasicBlock*> BBForwardRefs;
369
370 inline PerFunctionInfo() {
371 CurrentFunction = 0;
372 isDeclare = false;
373 Linkage = GlobalValue::ExternalLinkage;
374 Visibility = GlobalValue::DefaultVisibility;
375 }
376
377 inline void FunctionStart(Function *M) {
378 CurrentFunction = M;
379 NextValNum = 0;
380 }
381
382 void FunctionDone() {
383 // Any forward referenced blocks left?
384 if (!BBForwardRefs.empty()) {
385 GenerateError("Undefined reference to label " +
386 BBForwardRefs.begin()->second->getName());
387 return;
388 }
389
390 // Resolve all forward references now.
391 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
392
393 Values.clear(); // Clear out function local definitions
394 BBForwardRefs.clear();
395 CurrentFunction = 0;
396 isDeclare = false;
397 Linkage = GlobalValue::ExternalLinkage;
398 Visibility = GlobalValue::DefaultVisibility;
399 }
400} CurFun; // Info for the current function...
401
402static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
403
404
405//===----------------------------------------------------------------------===//
406// Code to handle definitions of all the types
407//===----------------------------------------------------------------------===//
408
409static void InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) {
410 // Things that have names or are void typed don't get slot numbers
411 if (V->hasName() || (V->getType() == Type::VoidTy))
412 return;
413
414 // In the case of function values, we have to allow for the forward reference
415 // of basic blocks, which are included in the numbering. Consequently, we keep
416 // track of the next insertion location with NextValNum. When a BB gets
417 // inserted, it could change the size of the CurFun.Values vector.
418 if (&ValueTab == &CurFun.Values) {
419 if (ValueTab.size() <= CurFun.NextValNum)
420 ValueTab.resize(CurFun.NextValNum+1);
421 ValueTab[CurFun.NextValNum++] = V;
422 return;
423 }
424 // For all other lists, its okay to just tack it on the back of the vector.
425 ValueTab.push_back(V);
426}
427
428static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
429 switch (D.Type) {
430 case ValID::LocalID: // Is it a numbered definition?
431 // Module constants occupy the lowest numbered slots...
432 if (D.Num < CurModule.Types.size())
433 return CurModule.Types[D.Num];
434 break;
435 case ValID::LocalName: // Is it a named definition?
436 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.getName())) {
437 D.destroy(); // Free old strdup'd memory...
438 return N;
439 }
440 break;
441 default:
442 GenerateError("Internal parser error: Invalid symbol type reference");
443 return 0;
444 }
445
446 // If we reached here, we referenced either a symbol that we don't know about
447 // or an id number that hasn't been read yet. We may be referencing something
448 // forward, so just create an entry to be resolved later and get to it...
449 //
450 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
451
452
453 if (inFunctionScope()) {
454 if (D.Type == ValID::LocalName) {
455 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
456 return 0;
457 } else {
458 GenerateError("Reference to an undefined type: #" + utostr(D.Num));
459 return 0;
460 }
461 }
462
463 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
464 if (I != CurModule.LateResolveTypes.end())
465 return I->second;
466
467 Type *Typ = OpaqueType::get();
468 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
469 return Typ;
470 }
471
472// getExistingVal - Look up the value specified by the provided type and
473// the provided ValID. If the value exists and has already been defined, return
474// it. Otherwise return null.
475//
476static Value *getExistingVal(const Type *Ty, const ValID &D) {
477 if (isa<FunctionType>(Ty)) {
478 GenerateError("Functions are not values and "
479 "must be referenced as pointers");
480 return 0;
481 }
482
483 switch (D.Type) {
484 case ValID::LocalID: { // Is it a numbered definition?
485 // Check that the number is within bounds.
486 if (D.Num >= CurFun.Values.size())
487 return 0;
488 Value *Result = CurFun.Values[D.Num];
489 if (Ty != Result->getType()) {
490 GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" +
491 Result->getType()->getDescription() + "' does not match "
492 "expected type, '" + Ty->getDescription() + "'");
493 return 0;
494 }
495 return Result;
496 }
497 case ValID::GlobalID: { // Is it a numbered definition?
498 if (D.Num >= CurModule.Values.size())
499 return 0;
500 Value *Result = CurModule.Values[D.Num];
501 if (Ty != Result->getType()) {
502 GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" +
503 Result->getType()->getDescription() + "' does not match "
504 "expected type, '" + Ty->getDescription() + "'");
505 return 0;
506 }
507 return Result;
508 }
509
510 case ValID::LocalName: { // Is it a named definition?
511 if (!inFunctionScope())
512 return 0;
513 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
514 Value *N = SymTab.lookup(D.getName());
515 if (N == 0)
516 return 0;
517 if (N->getType() != Ty)
518 return 0;
519
520 D.destroy(); // Free old strdup'd memory...
521 return N;
522 }
523 case ValID::GlobalName: { // Is it a named definition?
524 ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
525 Value *N = SymTab.lookup(D.getName());
526 if (N == 0)
527 return 0;
528 if (N->getType() != Ty)
529 return 0;
530
531 D.destroy(); // Free old strdup'd memory...
532 return N;
533 }
534
535 // Check to make sure that "Ty" is an integral type, and that our
536 // value will fit into the specified type...
537 case ValID::ConstSIntVal: // Is it a constant pool reference??
538 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
539 GenerateError("Signed integral constant '" +
540 itostr(D.ConstPool64) + "' is invalid for type '" +
541 Ty->getDescription() + "'");
542 return 0;
543 }
544 return ConstantInt::get(Ty, D.ConstPool64, true);
545
546 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
547 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
548 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
549 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
550 "' is invalid or out of range");
551 return 0;
552 } else { // This is really a signed reference. Transmogrify.
553 return ConstantInt::get(Ty, D.ConstPool64, true);
554 }
555 } else {
556 return ConstantInt::get(Ty, D.UConstPool64);
557 }
558
559 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Dale Johannesen3afee192007-09-07 21:07:57 +0000560 if (!ConstantFP::isValueValidForType(Ty, *D.ConstPoolFP)) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000561 GenerateError("FP constant invalid for type");
562 return 0;
563 }
Dale Johannesen3afee192007-09-07 21:07:57 +0000564 // Lexer has no type info, so builds all FP constants as double.
565 // Fix this here.
566 if (Ty==Type::FloatTy)
567 D.ConstPoolFP->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
568 return ConstantFP::get(Ty, *D.ConstPoolFP);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000569
570 case ValID::ConstNullVal: // Is it a null value?
571 if (!isa<PointerType>(Ty)) {
572 GenerateError("Cannot create a a non pointer null");
573 return 0;
574 }
575 return ConstantPointerNull::get(cast<PointerType>(Ty));
576
577 case ValID::ConstUndefVal: // Is it an undef value?
578 return UndefValue::get(Ty);
579
580 case ValID::ConstZeroVal: // Is it a zero value?
581 return Constant::getNullValue(Ty);
582
583 case ValID::ConstantVal: // Fully resolved constant?
584 if (D.ConstantValue->getType() != Ty) {
585 GenerateError("Constant expression type different from required type");
586 return 0;
587 }
588 return D.ConstantValue;
589
590 case ValID::InlineAsmVal: { // Inline asm expression
591 const PointerType *PTy = dyn_cast<PointerType>(Ty);
592 const FunctionType *FTy =
593 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
594 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
595 GenerateError("Invalid type for asm constraint string");
596 return 0;
597 }
598 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
599 D.IAD->HasSideEffects);
600 D.destroy(); // Free InlineAsmDescriptor.
601 return IA;
602 }
603 default:
604 assert(0 && "Unhandled case!");
605 return 0;
606 } // End of switch
607
608 assert(0 && "Unhandled case!");
609 return 0;
610}
611
612// getVal - This function is identical to getExistingVal, except that if a
613// value is not already defined, it "improvises" by creating a placeholder var
614// that looks and acts just like the requested variable. When the value is
615// defined later, all uses of the placeholder variable are replaced with the
616// real thing.
617//
618static Value *getVal(const Type *Ty, const ValID &ID) {
619 if (Ty == Type::LabelTy) {
620 GenerateError("Cannot use a basic block here");
621 return 0;
622 }
623
624 // See if the value has already been defined.
625 Value *V = getExistingVal(Ty, ID);
626 if (V) return V;
627 if (TriggerError) return 0;
628
629 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
630 GenerateError("Invalid use of a composite type");
631 return 0;
632 }
633
634 // If we reached here, we referenced either a symbol that we don't know about
635 // or an id number that hasn't been read yet. We may be referencing something
636 // forward, so just create an entry to be resolved later and get to it...
637 //
638 switch (ID.Type) {
639 case ValID::GlobalName:
640 case ValID::GlobalID: {
641 const PointerType *PTy = dyn_cast<PointerType>(Ty);
642 if (!PTy) {
643 GenerateError("Invalid type for reference to global" );
644 return 0;
645 }
646 const Type* ElTy = PTy->getElementType();
647 if (const FunctionType *FTy = dyn_cast<FunctionType>(ElTy))
648 V = new Function(FTy, GlobalValue::ExternalLinkage);
649 else
650 V = new GlobalVariable(ElTy, false, GlobalValue::ExternalLinkage);
651 break;
652 }
653 default:
654 V = new Argument(Ty);
655 }
656
657 // Remember where this forward reference came from. FIXME, shouldn't we try
658 // to recycle these things??
659 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
660 llvmAsmlineno)));
661
662 if (inFunctionScope())
663 InsertValue(V, CurFun.LateResolveValues);
664 else
665 InsertValue(V, CurModule.LateResolveValues);
666 return V;
667}
668
669/// defineBBVal - This is a definition of a new basic block with the specified
670/// identifier which must be the same as CurFun.NextValNum, if its numeric.
671static BasicBlock *defineBBVal(const ValID &ID) {
672 assert(inFunctionScope() && "Can't get basic block at global scope!");
673
674 BasicBlock *BB = 0;
675
676 // First, see if this was forward referenced
677
678 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
679 if (BBI != CurFun.BBForwardRefs.end()) {
680 BB = BBI->second;
681 // The forward declaration could have been inserted anywhere in the
682 // function: insert it into the correct place now.
683 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
684 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
685
686 // We're about to erase the entry, save the key so we can clean it up.
687 ValID Tmp = BBI->first;
688
689 // Erase the forward ref from the map as its no longer "forward"
690 CurFun.BBForwardRefs.erase(ID);
691
692 // The key has been removed from the map but so we don't want to leave
693 // strdup'd memory around so destroy it too.
694 Tmp.destroy();
695
696 // If its a numbered definition, bump the number and set the BB value.
697 if (ID.Type == ValID::LocalID) {
698 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
699 InsertValue(BB);
700 }
701
702 ID.destroy();
703 return BB;
704 }
705
706 // We haven't seen this BB before and its first mention is a definition.
707 // Just create it and return it.
708 std::string Name (ID.Type == ValID::LocalName ? ID.getName() : "");
709 BB = new BasicBlock(Name, CurFun.CurrentFunction);
710 if (ID.Type == ValID::LocalID) {
711 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
712 InsertValue(BB);
713 }
714
715 ID.destroy(); // Free strdup'd memory
716 return BB;
717}
718
719/// getBBVal - get an existing BB value or create a forward reference for it.
720///
721static BasicBlock *getBBVal(const ValID &ID) {
722 assert(inFunctionScope() && "Can't get basic block at global scope!");
723
724 BasicBlock *BB = 0;
725
726 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
727 if (BBI != CurFun.BBForwardRefs.end()) {
728 BB = BBI->second;
729 } if (ID.Type == ValID::LocalName) {
730 std::string Name = ID.getName();
731 Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
732 if (N)
733 if (N->getType()->getTypeID() == Type::LabelTyID)
734 BB = cast<BasicBlock>(N);
735 else
736 GenerateError("Reference to label '" + Name + "' is actually of type '"+
737 N->getType()->getDescription() + "'");
738 } else if (ID.Type == ValID::LocalID) {
739 if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) {
740 if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID)
741 BB = cast<BasicBlock>(CurFun.Values[ID.Num]);
742 else
743 GenerateError("Reference to label '%" + utostr(ID.Num) +
744 "' is actually of type '"+
745 CurFun.Values[ID.Num]->getType()->getDescription() + "'");
746 }
747 } else {
748 GenerateError("Illegal label reference " + ID.getName());
749 return 0;
750 }
751
752 // If its already been defined, return it now.
753 if (BB) {
754 ID.destroy(); // Free strdup'd memory.
755 return BB;
756 }
757
758 // Otherwise, this block has not been seen before, create it.
759 std::string Name;
760 if (ID.Type == ValID::LocalName)
761 Name = ID.getName();
762 BB = new BasicBlock(Name, CurFun.CurrentFunction);
763
764 // Insert it in the forward refs map.
765 CurFun.BBForwardRefs[ID] = BB;
766
767 return BB;
768}
769
770
771//===----------------------------------------------------------------------===//
772// Code to handle forward references in instructions
773//===----------------------------------------------------------------------===//
774//
775// This code handles the late binding needed with statements that reference
776// values not defined yet... for example, a forward branch, or the PHI node for
777// a loop body.
778//
779// This keeps a table (CurFun.LateResolveValues) of all such forward references
780// and back patchs after we are done.
781//
782
783// ResolveDefinitions - If we could not resolve some defs at parsing
784// time (forward branches, phi functions for loops, etc...) resolve the
785// defs now...
786//
787static void
788ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) {
789 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
790 while (!LateResolvers.empty()) {
791 Value *V = LateResolvers.back();
792 LateResolvers.pop_back();
793
794 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
795 CurModule.PlaceHolderInfo.find(V);
796 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
797
798 ValID &DID = PHI->second.first;
799
800 Value *TheRealValue = getExistingVal(V->getType(), DID);
801 if (TriggerError)
802 return;
803 if (TheRealValue) {
804 V->replaceAllUsesWith(TheRealValue);
805 delete V;
806 CurModule.PlaceHolderInfo.erase(PHI);
807 } else if (FutureLateResolvers) {
808 // Functions have their unresolved items forwarded to the module late
809 // resolver table
810 InsertValue(V, *FutureLateResolvers);
811 } else {
812 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
813 GenerateError("Reference to an invalid definition: '" +DID.getName()+
814 "' of type '" + V->getType()->getDescription() + "'",
815 PHI->second.second);
816 return;
817 } else {
818 GenerateError("Reference to an invalid definition: #" +
819 itostr(DID.Num) + " of type '" +
820 V->getType()->getDescription() + "'",
821 PHI->second.second);
822 return;
823 }
824 }
825 }
826 LateResolvers.clear();
827}
828
829// ResolveTypeTo - A brand new type was just declared. This means that (if
830// name is not null) things referencing Name can be resolved. Otherwise, things
831// refering to the number can be resolved. Do this now.
832//
833static void ResolveTypeTo(std::string *Name, const Type *ToTy) {
834 ValID D;
835 if (Name)
836 D = ValID::createLocalName(*Name);
837 else
838 D = ValID::createLocalID(CurModule.Types.size());
839
840 std::map<ValID, PATypeHolder>::iterator I =
841 CurModule.LateResolveTypes.find(D);
842 if (I != CurModule.LateResolveTypes.end()) {
843 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
844 CurModule.LateResolveTypes.erase(I);
845 }
846}
847
848// setValueName - Set the specified value to the name given. The name may be
849// null potentially, in which case this is a noop. The string passed in is
850// assumed to be a malloc'd string buffer, and is free'd by this function.
851//
852static void setValueName(Value *V, std::string *NameStr) {
853 if (!NameStr) return;
854 std::string Name(*NameStr); // Copy string
855 delete NameStr; // Free old string
856
857 if (V->getType() == Type::VoidTy) {
858 GenerateError("Can't assign name '" + Name+"' to value with void type");
859 return;
860 }
861
862 assert(inFunctionScope() && "Must be in function scope!");
863 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
864 if (ST.lookup(Name)) {
865 GenerateError("Redefinition of value '" + Name + "' of type '" +
866 V->getType()->getDescription() + "'");
867 return;
868 }
869
870 // Set the name.
871 V->setName(Name);
872}
873
874/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
875/// this is a declaration, otherwise it is a definition.
876static GlobalVariable *
877ParseGlobalVariable(std::string *NameStr,
878 GlobalValue::LinkageTypes Linkage,
879 GlobalValue::VisibilityTypes Visibility,
880 bool isConstantGlobal, const Type *Ty,
881 Constant *Initializer, bool IsThreadLocal) {
882 if (isa<FunctionType>(Ty)) {
883 GenerateError("Cannot declare global vars of function type");
884 return 0;
885 }
886
887 const PointerType *PTy = PointerType::get(Ty);
888
889 std::string Name;
890 if (NameStr) {
891 Name = *NameStr; // Copy string
892 delete NameStr; // Free old string
893 }
894
895 // See if this global value was forward referenced. If so, recycle the
896 // object.
897 ValID ID;
898 if (!Name.empty()) {
899 ID = ValID::createGlobalName(Name);
900 } else {
901 ID = ValID::createGlobalID(CurModule.Values.size());
902 }
903
904 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
905 // Move the global to the end of the list, from whereever it was
906 // previously inserted.
907 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
908 CurModule.CurrentModule->getGlobalList().remove(GV);
909 CurModule.CurrentModule->getGlobalList().push_back(GV);
910 GV->setInitializer(Initializer);
911 GV->setLinkage(Linkage);
912 GV->setVisibility(Visibility);
913 GV->setConstant(isConstantGlobal);
914 GV->setThreadLocal(IsThreadLocal);
915 InsertValue(GV, CurModule.Values);
916 return GV;
917 }
918
919 // If this global has a name
920 if (!Name.empty()) {
921 // if the global we're parsing has an initializer (is a definition) and
922 // has external linkage.
923 if (Initializer && Linkage != GlobalValue::InternalLinkage)
924 // If there is already a global with external linkage with this name
925 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
926 // If we allow this GVar to get created, it will be renamed in the
927 // symbol table because it conflicts with an existing GVar. We can't
928 // allow redefinition of GVars whose linking indicates that their name
929 // must stay the same. Issue the error.
930 GenerateError("Redefinition of global variable named '" + Name +
931 "' of type '" + Ty->getDescription() + "'");
932 return 0;
933 }
934 }
935
936 // Otherwise there is no existing GV to use, create one now.
937 GlobalVariable *GV =
938 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
939 CurModule.CurrentModule, IsThreadLocal);
940 GV->setVisibility(Visibility);
941 InsertValue(GV, CurModule.Values);
942 return GV;
943}
944
945// setTypeName - Set the specified type to the name given. The name may be
946// null potentially, in which case this is a noop. The string passed in is
947// assumed to be a malloc'd string buffer, and is freed by this function.
948//
949// This function returns true if the type has already been defined, but is
950// allowed to be redefined in the specified context. If the name is a new name
951// for the type plane, it is inserted and false is returned.
952static bool setTypeName(const Type *T, std::string *NameStr) {
953 assert(!inFunctionScope() && "Can't give types function-local names!");
954 if (NameStr == 0) return false;
955
956 std::string Name(*NameStr); // Copy string
957 delete NameStr; // Free old string
958
959 // We don't allow assigning names to void type
960 if (T == Type::VoidTy) {
961 GenerateError("Can't assign name '" + Name + "' to the void type");
962 return false;
963 }
964
965 // Set the type name, checking for conflicts as we do so.
966 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
967
968 if (AlreadyExists) { // Inserting a name that is already defined???
969 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
970 assert(Existing && "Conflict but no matching type?!");
971
972 // There is only one case where this is allowed: when we are refining an
973 // opaque type. In this case, Existing will be an opaque type.
974 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
975 // We ARE replacing an opaque type!
976 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
977 return true;
978 }
979
980 // Otherwise, this is an attempt to redefine a type. That's okay if
981 // the redefinition is identical to the original. This will be so if
982 // Existing and T point to the same Type object. In this one case we
983 // allow the equivalent redefinition.
984 if (Existing == T) return true; // Yes, it's equal.
985
986 // Any other kind of (non-equivalent) redefinition is an error.
987 GenerateError("Redefinition of type named '" + Name + "' of type '" +
988 T->getDescription() + "'");
989 }
990
991 return false;
992}
993
994//===----------------------------------------------------------------------===//
995// Code for handling upreferences in type names...
996//
997
998// TypeContains - Returns true if Ty directly contains E in it.
999//
1000static bool TypeContains(const Type *Ty, const Type *E) {
1001 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1002 E) != Ty->subtype_end();
1003}
1004
1005namespace {
1006 struct UpRefRecord {
1007 // NestingLevel - The number of nesting levels that need to be popped before
1008 // this type is resolved.
1009 unsigned NestingLevel;
1010
1011 // LastContainedTy - This is the type at the current binding level for the
1012 // type. Every time we reduce the nesting level, this gets updated.
1013 const Type *LastContainedTy;
1014
1015 // UpRefTy - This is the actual opaque type that the upreference is
1016 // represented with.
1017 OpaqueType *UpRefTy;
1018
1019 UpRefRecord(unsigned NL, OpaqueType *URTy)
1020 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1021 };
1022}
1023
1024// UpRefs - A list of the outstanding upreferences that need to be resolved.
1025static std::vector<UpRefRecord> UpRefs;
1026
1027/// HandleUpRefs - Every time we finish a new layer of types, this function is
1028/// called. It loops through the UpRefs vector, which is a list of the
1029/// currently active types. For each type, if the up reference is contained in
1030/// the newly completed type, we decrement the level count. When the level
1031/// count reaches zero, the upreferenced type is the type that is passed in:
1032/// thus we can complete the cycle.
1033///
1034static PATypeHolder HandleUpRefs(const Type *ty) {
1035 // If Ty isn't abstract, or if there are no up-references in it, then there is
1036 // nothing to resolve here.
1037 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1038
1039 PATypeHolder Ty(ty);
1040 UR_OUT("Type '" << Ty->getDescription() <<
1041 "' newly formed. Resolving upreferences.\n" <<
1042 UpRefs.size() << " upreferences active!\n");
1043
1044 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1045 // to zero), we resolve them all together before we resolve them to Ty. At
1046 // the end of the loop, if there is anything to resolve to Ty, it will be in
1047 // this variable.
1048 OpaqueType *TypeToResolve = 0;
1049
1050 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1051 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1052 << UpRefs[i].second->getDescription() << ") = "
1053 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1054 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1055 // Decrement level of upreference
1056 unsigned Level = --UpRefs[i].NestingLevel;
1057 UpRefs[i].LastContainedTy = Ty;
1058 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1059 if (Level == 0) { // Upreference should be resolved!
1060 if (!TypeToResolve) {
1061 TypeToResolve = UpRefs[i].UpRefTy;
1062 } else {
1063 UR_OUT(" * Resolving upreference for "
1064 << UpRefs[i].second->getDescription() << "\n";
1065 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1066 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1067 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1068 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1069 }
1070 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1071 --i; // Do not skip the next element...
1072 }
1073 }
1074 }
1075
1076 if (TypeToResolve) {
1077 UR_OUT(" * Resolving upreference for "
1078 << UpRefs[i].second->getDescription() << "\n";
1079 std::string OldName = TypeToResolve->getDescription());
1080 TypeToResolve->refineAbstractTypeTo(Ty);
1081 }
1082
1083 return Ty;
1084}
1085
1086//===----------------------------------------------------------------------===//
1087// RunVMAsmParser - Define an interface to this parser
1088//===----------------------------------------------------------------------===//
1089//
1090static Module* RunParser(Module * M);
1091
1092Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1093 set_scan_file(F);
1094
1095 CurFilename = Filename;
1096 return RunParser(new Module(CurFilename));
1097}
1098
1099Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1100 set_scan_string(AsmString);
1101
1102 CurFilename = "from_memory";
1103 if (M == NULL) {
1104 return RunParser(new Module (CurFilename));
1105 } else {
1106 return RunParser(M);
1107 }
1108}
1109
1110
Dale Johannesen3afee192007-09-07 21:07:57 +00001111#line 967 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
1112typedef union {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001113 llvm::Module *ModuleVal;
1114 llvm::Function *FunctionVal;
1115 llvm::BasicBlock *BasicBlockVal;
1116 llvm::TerminatorInst *TermInstVal;
1117 llvm::Instruction *InstVal;
1118 llvm::Constant *ConstVal;
1119
1120 const llvm::Type *PrimType;
1121 std::list<llvm::PATypeHolder> *TypeList;
1122 llvm::PATypeHolder *TypeVal;
1123 llvm::Value *ValueVal;
1124 std::vector<llvm::Value*> *ValueList;
1125 llvm::ArgListType *ArgList;
1126 llvm::TypeWithAttrs TypeWithAttrs;
1127 llvm::TypeWithAttrsList *TypeWithAttrsList;
1128 llvm::ValueRefList *ValueRefList;
1129
1130 // Represent the RHS of PHI node
1131 std::list<std::pair<llvm::Value*,
1132 llvm::BasicBlock*> > *PHIList;
1133 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1134 std::vector<llvm::Constant*> *ConstVector;
1135
1136 llvm::GlobalValue::LinkageTypes Linkage;
1137 llvm::GlobalValue::VisibilityTypes Visibility;
1138 uint16_t ParamAttrs;
1139 llvm::APInt *APIntVal;
1140 int64_t SInt64Val;
1141 uint64_t UInt64Val;
1142 int SIntVal;
1143 unsigned UIntVal;
Dale Johannesen3afee192007-09-07 21:07:57 +00001144 llvm::APFloat *FPVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001145 bool BoolVal;
1146
1147 std::string *StrVal; // This memory must be deleted
1148 llvm::ValID ValIDVal;
1149
1150 llvm::Instruction::BinaryOps BinaryOpVal;
1151 llvm::Instruction::TermOps TermOpVal;
1152 llvm::Instruction::MemoryOps MemOpVal;
1153 llvm::Instruction::CastOps CastOpVal;
1154 llvm::Instruction::OtherOps OtherOpVal;
1155 llvm::ICmpInst::Predicate IPredicate;
1156 llvm::FCmpInst::Predicate FPredicate;
Chris Lattnerbb856a32007-08-06 21:00:46 +00001157} YYSTYPE;
Dale Johannesen3afee192007-09-07 21:07:57 +00001158#include <stdio.h>
1159
1160#ifndef __cplusplus
1161#ifndef __STDC__
1162#define const
1163#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001164#endif
1165
1166
1167
Dale Johannesen3afee192007-09-07 21:07:57 +00001168#define YYFINAL 594
1169#define YYFLAG -32768
1170#define YYNTBASE 160
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001171
Dale Johannesen3afee192007-09-07 21:07:57 +00001172#define YYTRANSLATE(x) ((unsigned)(x) <= 399 ? yytranslate[x] : 241)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001173
Dale Johannesen3afee192007-09-07 21:07:57 +00001174static const short yytranslate[] = { 0,
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, 150,
1179 151, 148, 2, 147, 2, 2, 2, 2, 2, 2,
1180 2, 2, 2, 2, 2, 2, 2, 2, 2, 155,
1181 146, 156, 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 152, 149, 154, 2, 2, 2, 2, 2, 159, 2,
1185 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1186 2, 2, 2, 2, 2, 2, 2, 2, 2, 153,
1187 2, 2, 157, 2, 158, 2, 2, 2, 2, 2,
1188 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1189 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1190 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1191 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1192 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1193 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1194 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1195 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1196 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1197 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1198 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1199 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1200 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
1201 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1202 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1203 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
1204 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
1205 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
1206 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1207 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1208 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1209 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
1210 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
1211 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
1212 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
1213 127, 128, 129, 130, 131, 132, 133, 134, 135, 136,
1214 137, 138, 139, 140, 141, 142, 143, 144, 145
1215};
Reid Spenceraa8ae282007-07-31 03:50:36 +00001216
Dale Johannesen3afee192007-09-07 21:07:57 +00001217#if YYDEBUG != 0
1218static const short yyprhs[] = { 0,
1219 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
1220 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
1221 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
1222 60, 62, 64, 66, 68, 70, 72, 74, 76, 78,
1223 80, 82, 84, 86, 88, 90, 92, 94, 96, 98,
1224 100, 102, 104, 106, 108, 110, 112, 114, 116, 118,
1225 120, 122, 124, 126, 127, 130, 131, 133, 135, 137,
1226 138, 141, 143, 145, 147, 149, 151, 153, 155, 157,
1227 158, 160, 162, 164, 165, 167, 169, 170, 172, 174,
1228 176, 178, 179, 181, 183, 184, 186, 188, 190, 192,
1229 194, 197, 199, 201, 203, 205, 207, 209, 211, 213,
1230 215, 216, 219, 221, 223, 225, 227, 228, 231, 232,
1231 235, 236, 240, 243, 244, 246, 247, 251, 253, 256,
1232 258, 260, 262, 264, 266, 268, 270, 272, 274, 277,
1233 279, 282, 288, 294, 300, 306, 310, 313, 319, 324,
1234 327, 329, 331, 333, 337, 339, 343, 345, 346, 348,
1235 352, 357, 361, 365, 370, 375, 379, 386, 392, 395,
1236 398, 401, 404, 407, 410, 413, 416, 419, 422, 425,
1237 428, 435, 441, 450, 457, 464, 472, 480, 487, 496,
1238 505, 509, 511, 513, 515, 517, 518, 521, 528, 530,
1239 531, 533, 536, 537, 541, 542, 546, 550, 554, 558,
1240 559, 567, 568, 577, 578, 587, 593, 596, 600, 602,
1241 606, 610, 614, 618, 620, 621, 627, 631, 633, 637,
1242 639, 640, 650, 652, 654, 659, 661, 663, 666, 670,
1243 671, 673, 675, 677, 679, 681, 683, 685, 687, 689,
1244 693, 695, 701, 703, 705, 707, 709, 711, 713, 716,
1245 719, 722, 726, 729, 730, 732, 735, 738, 742, 752,
1246 762, 771, 786, 788, 790, 797, 803, 806, 813, 821,
1247 825, 831, 832, 833, 837, 840, 842, 848, 854, 861,
1248 868, 873, 880, 885, 890, 897, 904, 907, 916, 918,
1249 920, 921, 925, 932, 936, 943, 946, 952, 960
1250};
Chris Lattnerbb856a32007-08-06 21:00:46 +00001251
Dale Johannesen3afee192007-09-07 21:07:57 +00001252static const short yyrhs[] = { 73,
1253 0, 74, 0, 75, 0, 76, 0, 77, 0, 78,
1254 0, 79, 0, 80, 0, 81, 0, 85, 0, 86,
1255 0, 87, 0, 82, 0, 83, 0, 84, 0, 116,
1256 0, 117, 0, 118, 0, 119, 0, 120, 0, 121,
1257 0, 122, 0, 123, 0, 124, 0, 125, 0, 126,
1258 0, 127, 0, 90, 0, 91, 0, 92, 0, 93,
1259 0, 94, 0, 95, 0, 96, 0, 97, 0, 98,
1260 0, 99, 0, 100, 0, 101, 0, 102, 0, 103,
1261 0, 104, 0, 105, 0, 106, 0, 107, 0, 108,
1262 0, 109, 0, 96, 0, 97, 0, 98, 0, 99,
1263 0, 26, 0, 27, 0, 11, 0, 12, 0, 13,
1264 0, 16, 0, 15, 0, 14, 0, 19, 0, 22,
1265 0, 24, 0, 167, 0, 0, 167, 146, 0, 0,
1266 20, 0, 23, 0, 172, 0, 0, 170, 146, 0,
1267 42, 0, 44, 0, 43, 0, 45, 0, 47, 0,
1268 46, 0, 48, 0, 50, 0, 0, 143, 0, 144,
1269 0, 145, 0, 0, 46, 0, 48, 0, 0, 42,
1270 0, 43, 0, 44, 0, 47, 0, 0, 44, 0,
1271 42, 0, 0, 61, 0, 62, 0, 63, 0, 64,
1272 0, 65, 0, 60, 4, 0, 135, 0, 117, 0,
1273 134, 0, 118, 0, 137, 0, 138, 0, 140, 0,
1274 141, 0, 142, 0, 0, 181, 180, 0, 136, 0,
1275 139, 0, 135, 0, 134, 0, 0, 183, 182, 0,
1276 0, 53, 4, 0, 0, 147, 53, 4, 0, 34,
1277 22, 0, 0, 186, 0, 0, 147, 189, 188, 0,
1278 186, 0, 53, 4, 0, 11, 0, 12, 0, 13,
1279 0, 16, 0, 15, 0, 14, 0, 17, 0, 49,
1280 0, 190, 0, 191, 148, 0, 225, 0, 149, 4,
1281 0, 191, 150, 195, 151, 183, 0, 10, 150, 195,
1282 151, 183, 0, 152, 4, 153, 191, 154, 0, 155,
1283 4, 153, 191, 156, 0, 157, 196, 158, 0, 157,
1284 158, 0, 155, 157, 196, 158, 156, 0, 155, 157,
1285 158, 156, 0, 191, 181, 0, 191, 0, 10, 0,
1286 192, 0, 194, 147, 192, 0, 194, 0, 194, 147,
1287 39, 0, 39, 0, 0, 191, 0, 196, 147, 191,
1288 0, 191, 152, 199, 154, 0, 191, 152, 154, 0,
1289 191, 159, 22, 0, 191, 155, 199, 156, 0, 191,
1290 157, 199, 158, 0, 191, 157, 158, 0, 191, 155,
1291 157, 199, 158, 156, 0, 191, 155, 157, 158, 156,
1292 0, 191, 40, 0, 191, 41, 0, 191, 225, 0,
1293 191, 198, 0, 191, 25, 0, 165, 3, 0, 165,
1294 5, 0, 165, 4, 0, 165, 6, 0, 11, 26,
1295 0, 11, 27, 0, 166, 9, 0, 162, 150, 197,
1296 38, 191, 151, 0, 115, 150, 197, 236, 151, 0,
1297 129, 150, 197, 147, 197, 147, 197, 151, 0, 160,
1298 150, 197, 147, 197, 151, 0, 161, 150, 197, 147,
1299 197, 151, 0, 88, 163, 150, 197, 147, 197, 151,
1300 0, 89, 164, 150, 197, 147, 197, 151, 0, 131,
1301 150, 197, 147, 197, 151, 0, 132, 150, 197, 147,
1302 197, 147, 197, 151, 0, 133, 150, 197, 147, 197,
1303 147, 197, 151, 0, 199, 147, 197, 0, 197, 0,
1304 32, 0, 33, 0, 37, 0, 0, 193, 225, 0,
1305 121, 150, 202, 38, 191, 151, 0, 204, 0, 0,
1306 205, 0, 204, 205, 0, 0, 31, 206, 221, 0,
1307 0, 30, 207, 222, 0, 58, 57, 211, 0, 169,
1308 18, 191, 0, 169, 18, 10, 0, 0, 171, 175,
1309 201, 200, 197, 208, 188, 0, 0, 171, 173, 175,
1310 201, 200, 197, 209, 188, 0, 0, 171, 174, 175,
1311 201, 200, 191, 210, 188, 0, 171, 175, 35, 178,
1312 202, 0, 51, 212, 0, 54, 146, 213, 0, 22,
1313 0, 52, 146, 22, 0, 66, 146, 22, 0, 152,
1314 214, 154, 0, 214, 147, 22, 0, 22, 0, 0,
1315 215, 147, 191, 181, 168, 0, 191, 181, 168, 0,
1316 215, 0, 215, 147, 39, 0, 39, 0, 0, 179,
1317 193, 170, 150, 216, 151, 183, 187, 184, 0, 28,
1318 0, 157, 0, 177, 175, 217, 218, 0, 29, 0,
1319 158, 0, 228, 220, 0, 176, 175, 217, 0, 0,
1320 59, 0, 3, 0, 4, 0, 9, 0, 26, 0,
1321 27, 0, 40, 0, 41, 0, 25, 0, 155, 199,
1322 156, 0, 198, 0, 57, 223, 22, 147, 22, 0,
1323 7, 0, 8, 0, 167, 0, 170, 0, 225, 0,
1324 224, 0, 191, 226, 0, 228, 229, 0, 219, 229,
1325 0, 230, 169, 231, 0, 230, 233, 0, 0, 21,
1326 0, 67, 227, 0, 67, 10, 0, 68, 17, 226,
1327 0, 68, 11, 226, 147, 17, 226, 147, 17, 226,
1328 0, 69, 165, 226, 147, 17, 226, 152, 232, 154,
1329 0, 69, 165, 226, 147, 17, 226, 152, 154, 0,
1330 70, 179, 193, 226, 150, 235, 151, 183, 38, 17,
1331 226, 71, 17, 226, 0, 71, 0, 72, 0, 232,
1332 165, 224, 147, 17, 226, 0, 165, 224, 147, 17,
1333 226, 0, 169, 238, 0, 191, 152, 226, 147, 226,
1334 154, 0, 234, 147, 152, 226, 147, 226, 154, 0,
1335 191, 226, 181, 0, 235, 147, 191, 226, 181, 0,
1336 0, 0, 236, 147, 227, 0, 56, 55, 0, 55,
1337 0, 160, 191, 226, 147, 226, 0, 161, 191, 226,
1338 147, 226, 0, 88, 163, 191, 226, 147, 226, 0,
1339 89, 164, 191, 226, 147, 226, 0, 162, 227, 38,
1340 191, 0, 129, 227, 147, 227, 147, 227, 0, 130,
1341 227, 147, 191, 0, 131, 227, 147, 227, 0, 132,
1342 227, 147, 227, 147, 227, 0, 133, 227, 147, 227,
1343 147, 227, 0, 128, 234, 0, 237, 179, 193, 226,
1344 150, 235, 151, 183, 0, 240, 0, 36, 0, 0,
1345 110, 191, 185, 0, 110, 191, 147, 11, 226, 185,
1346 0, 111, 191, 185, 0, 111, 191, 147, 11, 226,
1347 185, 0, 112, 227, 0, 239, 113, 191, 226, 185,
1348 0, 239, 114, 227, 147, 191, 226, 185, 0, 115,
1349 191, 226, 236, 0
1350};
Chris Lattnerbb856a32007-08-06 21:00:46 +00001351
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001352#endif
1353
Dale Johannesen3afee192007-09-07 21:07:57 +00001354#if YYDEBUG != 0
1355static const short yyrline[] = { 0,
1356 1126, 1126, 1126, 1126, 1126, 1126, 1126, 1126, 1126, 1127,
1357 1127, 1127, 1127, 1127, 1127, 1128, 1128, 1128, 1128, 1128,
1358 1128, 1128, 1129, 1129, 1129, 1129, 1129, 1132, 1132, 1133,
1359 1133, 1134, 1134, 1135, 1135, 1136, 1136, 1140, 1140, 1141,
1360 1141, 1142, 1142, 1143, 1143, 1144, 1144, 1145, 1145, 1146,
1361 1146, 1147, 1148, 1153, 1154, 1154, 1154, 1154, 1154, 1156,
1362 1156, 1156, 1157, 1157, 1161, 1165, 1170, 1170, 1172, 1173,
1363 1178, 1184, 1185, 1186, 1187, 1188, 1192, 1193, 1194, 1198,
1364 1199, 1200, 1201, 1205, 1206, 1207, 1211, 1212, 1213, 1214,
1365 1215, 1219, 1220, 1221, 1224, 1224, 1225, 1226, 1227, 1228,
1366 1229, 1237, 1238, 1239, 1240, 1241, 1242, 1243, 1244, 1245,
1367 1248, 1249, 1254, 1255, 1256, 1257, 1260, 1261, 1268, 1268,
1368 1275, 1275, 1284, 1292, 1292, 1298, 1298, 1300, 1305, 1318,
1369 1318, 1318, 1318, 1318, 1318, 1318, 1321, 1325, 1329, 1336,
1370 1341, 1349, 1379, 1410, 1415, 1427, 1437, 1441, 1451, 1458,
1371 1465, 1472, 1477, 1482, 1489, 1490, 1497, 1504, 1512, 1518,
1372 1530, 1558, 1574, 1601, 1629, 1655, 1675, 1701, 1721, 1733,
1373 1740, 1806, 1816, 1826, 1832, 1842, 1848, 1858, 1863, 1868,
1374 1881, 1893, 1915, 1923, 1929, 1940, 1945, 1950, 1956, 1962,
1375 1971, 1975, 1983, 1983, 1986, 1986, 1989, 2001, 2022, 2027,
1376 2035, 2036, 2040, 2040, 2044, 2044, 2047, 2050, 2074, 2085,
1377 2092, 2095, 2101, 2104, 2111, 2115, 2134, 2137, 2143, 2153,
1378 2157, 2162, 2164, 2169, 2174, 2183, 2193, 2204, 2208, 2217,
1379 2226, 2231, 2352, 2352, 2354, 2363, 2363, 2365, 2370, 2382,
1380 2386, 2391, 2395, 2399, 2403, 2407, 2411, 2415, 2419, 2423,
1381 2448, 2452, 2462, 2466, 2470, 2475, 2482, 2482, 2488, 2497,
1382 2501, 2510, 2519, 2528, 2532, 2539, 2543, 2547, 2552, 2562,
1383 2581, 2590, 2670, 2674, 2681, 2692, 2705, 2715, 2726, 2736,
1384 2745, 2754, 2757, 2758, 2765, 2769, 2774, 2795, 2812, 2826,
1385 2840, 2852, 2860, 2867, 2873, 2879, 2885, 2900, 2985, 2990,
1386 2994, 3001, 3008, 3016, 3023, 3031, 3039, 3053, 3070
1387};
1388#endif
1389
1390
1391#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
1392
1393static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL",
1394"EUINT64VAL","ESAPINTVAL","EUAPINTVAL","LOCALVAL_ID","GLOBALVAL_ID","FPVAL",
1395"VOID","INTTYPE","FLOAT","DOUBLE","X86_FP80","FP128","PPC_FP128","LABEL","TYPE",
1396"LOCALVAR","GLOBALVAR","LABELSTR","STRINGCONSTANT","ATSTRINGCONSTANT","PCTSTRINGCONSTANT",
1397"ZEROINITIALIZER","TRUETOK","FALSETOK","BEGINTOK","ENDTOK","DECLARE","DEFINE",
1398"GLOBAL","CONSTANT","SECTION","ALIAS","VOLATILE","THREAD_LOCAL","TO","DOTDOTDOT",
1399"NULL_TOK","UNDEF","INTERNAL","LINKONCE","WEAK","APPENDING","DLLIMPORT","DLLEXPORT",
1400"EXTERN_WEAK","OPAQUE","EXTERNAL","TARGET","TRIPLE","ALIGN","DEPLIBS","CALL",
1401"TAIL","ASM_TOK","MODULE","SIDEEFFECT","CC_TOK","CCC_TOK","FASTCC_TOK","COLDCC_TOK",
1402"X86_STDCALLCC_TOK","X86_FASTCALLCC_TOK","DATALAYOUT","RET","BR","SWITCH","INVOKE",
1403"UNWIND","UNREACHABLE","ADD","SUB","MUL","UDIV","SDIV","FDIV","UREM","SREM",
1404"FREM","AND","OR","XOR","SHL","LSHR","ASHR","ICMP","FCMP","EQ","NE","SLT","SGT",
1405"SLE","SGE","ULT","UGT","ULE","UGE","OEQ","ONE","OLT","OGT","OLE","OGE","ORD",
1406"UNO","UEQ","UNE","MALLOC","ALLOCA","FREE","LOAD","STORE","GETELEMENTPTR","TRUNC",
1407"ZEXT","SEXT","FPTRUNC","FPEXT","BITCAST","UITOFP","SITOFP","FPTOUI","FPTOSI",
1408"INTTOPTR","PTRTOINT","PHI_TOK","SELECT","VAARG","EXTRACTELEMENT","INSERTELEMENT",
1409"SHUFFLEVECTOR","SIGNEXT","ZEROEXT","NORETURN","INREG","SRET","NOUNWIND","NOALIAS",
1410"BYVAL","NEST","DEFAULT","HIDDEN","PROTECTED","'='","','","'*'","'\\\\'","'('",
1411"')'","'['","'x'","']'","'<'","'>'","'{'","'}'","'c'","ArithmeticOps","LogicalOps",
1412"CastOps","IPredicates","FPredicates","IntType","FPType","LocalName","OptLocalName",
1413"OptLocalAssign","GlobalName","OptGlobalAssign","GlobalAssign","GVInternalLinkage",
1414"GVExternalLinkage","GVVisibilityStyle","FunctionDeclareLinkage","FunctionDefineLinkage",
1415"AliasLinkage","OptCallingConv","ParamAttr","OptParamAttrs","FuncAttr","OptFuncAttrs",
1416"OptAlign","OptCAlign","SectionString","OptSection","GlobalVarAttributes","GlobalVarAttribute",
1417"PrimType","Types","ArgType","ResultTypes","ArgTypeList","ArgTypeListI","TypeListI",
1418"ConstVal","ConstExpr","ConstVector","GlobalType","ThreadLocal","AliaseeRef",
1419"Module","DefinitionList","Definition","@1","@2","@3","@4","@5","AsmBlock","TargetDefinition",
1420"LibrariesDefinition","LibList","ArgListH","ArgList","FunctionHeaderH","BEGIN",
1421"FunctionHeader","END","Function","FunctionProto","OptSideEffect","ConstValueRef",
1422"SymbolicValueRef","ValueRef","ResolvedVal","BasicBlockList","BasicBlock","InstructionList",
1423"BBTerminatorInst","JumpTable","Inst","PHIList","ValueRefList","IndexList","OptTailCall",
1424"InstVal","OptVolatile","MemoryInst", NULL
1425};
1426#endif
1427
1428static const short yyr1[] = { 0,
1429 160, 160, 160, 160, 160, 160, 160, 160, 160, 161,
1430 161, 161, 161, 161, 161, 162, 162, 162, 162, 162,
1431 162, 162, 162, 162, 162, 162, 162, 163, 163, 163,
1432 163, 163, 163, 163, 163, 163, 163, 164, 164, 164,
1433 164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
1434 164, 164, 164, 165, 166, 166, 166, 166, 166, 167,
1435 167, 167, 168, 168, 169, 169, 170, 170, 171, 171,
1436 172, 173, 173, 173, 173, 173, 174, 174, 174, 175,
1437 175, 175, 175, 176, 176, 176, 177, 177, 177, 177,
1438 177, 178, 178, 178, 179, 179, 179, 179, 179, 179,
1439 179, 180, 180, 180, 180, 180, 180, 180, 180, 180,
1440 181, 181, 182, 182, 182, 182, 183, 183, 184, 184,
1441 185, 185, 186, 187, 187, 188, 188, 189, 189, 190,
1442 190, 190, 190, 190, 190, 190, 191, 191, 191, 191,
1443 191, 191, 191, 191, 191, 191, 191, 191, 191, 192,
1444 193, 193, 194, 194, 195, 195, 195, 195, 196, 196,
1445 197, 197, 197, 197, 197, 197, 197, 197, 197, 197,
1446 197, 197, 197, 197, 197, 197, 197, 197, 197, 197,
1447 198, 198, 198, 198, 198, 198, 198, 198, 198, 198,
1448 199, 199, 200, 200, 201, 201, 202, 202, 203, 203,
1449 204, 204, 206, 205, 207, 205, 205, 205, 205, 208,
1450 205, 209, 205, 210, 205, 205, 205, 205, 211, 212,
1451 212, 213, 214, 214, 214, 215, 215, 216, 216, 216,
1452 216, 217, 218, 218, 219, 220, 220, 221, 222, 223,
1453 223, 224, 224, 224, 224, 224, 224, 224, 224, 224,
1454 224, 224, 225, 225, 225, 225, 226, 226, 227, 228,
1455 228, 229, 230, 230, 230, 231, 231, 231, 231, 231,
1456 231, 231, 231, 231, 232, 232, 233, 234, 234, 235,
1457 235, 235, 236, 236, 237, 237, 238, 238, 238, 238,
1458 238, 238, 238, 238, 238, 238, 238, 238, 238, 239,
1459 239, 240, 240, 240, 240, 240, 240, 240, 240
1460};
1461
1462static const short yyr2[] = { 0,
1463 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1464 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1465 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1466 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1467 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1468 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1469 1, 1, 1, 0, 2, 0, 1, 1, 1, 0,
1470 2, 1, 1, 1, 1, 1, 1, 1, 1, 0,
1471 1, 1, 1, 0, 1, 1, 0, 1, 1, 1,
1472 1, 0, 1, 1, 0, 1, 1, 1, 1, 1,
1473 2, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1474 0, 2, 1, 1, 1, 1, 0, 2, 0, 2,
1475 0, 3, 2, 0, 1, 0, 3, 1, 2, 1,
1476 1, 1, 1, 1, 1, 1, 1, 1, 2, 1,
1477 2, 5, 5, 5, 5, 3, 2, 5, 4, 2,
1478 1, 1, 1, 3, 1, 3, 1, 0, 1, 3,
1479 4, 3, 3, 4, 4, 3, 6, 5, 2, 2,
1480 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1481 6, 5, 8, 6, 6, 7, 7, 6, 8, 8,
1482 3, 1, 1, 1, 1, 0, 2, 6, 1, 0,
1483 1, 2, 0, 3, 0, 3, 3, 3, 3, 0,
1484 7, 0, 8, 0, 8, 5, 2, 3, 1, 3,
1485 3, 3, 3, 1, 0, 5, 3, 1, 3, 1,
1486 0, 9, 1, 1, 4, 1, 1, 2, 3, 0,
1487 1, 1, 1, 1, 1, 1, 1, 1, 1, 3,
1488 1, 5, 1, 1, 1, 1, 1, 1, 2, 2,
1489 2, 3, 2, 0, 1, 2, 2, 3, 9, 9,
1490 8, 14, 1, 1, 6, 5, 2, 6, 7, 3,
1491 5, 0, 0, 3, 2, 1, 5, 5, 6, 6,
1492 4, 6, 4, 4, 6, 6, 2, 8, 1, 1,
1493 0, 3, 6, 3, 6, 2, 5, 7, 4
1494};
1495
1496static const short yydefact[] = { 70,
1497 60, 67, 61, 68, 62, 205, 203, 0, 0, 0,
1498 0, 0, 0, 80, 69, 70, 201, 84, 87, 0,
1499 0, 217, 0, 0, 65, 0, 71, 72, 74, 73,
1500 75, 77, 76, 78, 79, 81, 82, 83, 80, 80,
1501 196, 202, 85, 86, 80, 206, 88, 89, 90, 91,
1502 80, 264, 204, 264, 0, 0, 225, 218, 219, 207,
1503 253, 254, 209, 130, 131, 132, 135, 134, 133, 136,
1504 137, 0, 0, 0, 0, 255, 256, 138, 208, 140,
1505 196, 196, 92, 195, 0, 95, 95, 265, 261, 66,
1506 236, 237, 238, 260, 220, 221, 224, 0, 158, 141,
1507 0, 0, 0, 0, 147, 159, 0, 139, 158, 0,
1508 0, 94, 93, 0, 193, 194, 0, 0, 96, 97,
1509 98, 99, 100, 0, 239, 0, 301, 263, 0, 222,
1510 157, 111, 153, 155, 0, 0, 0, 0, 0, 0,
1511 146, 0, 0, 0, 152, 0, 151, 0, 216, 130,
1512 131, 132, 135, 134, 133, 0, 0, 0, 210, 101,
1513 0, 233, 234, 235, 300, 286, 0, 0, 0, 0,
1514 95, 273, 274, 1, 2, 3, 4, 5, 6, 7,
1515 8, 9, 13, 14, 15, 10, 11, 12, 0, 0,
1516 0, 0, 0, 0, 16, 17, 18, 19, 20, 21,
1517 22, 23, 24, 25, 26, 27, 0, 0, 0, 0,
1518 0, 0, 0, 0, 0, 262, 95, 277, 0, 299,
1519 223, 150, 0, 117, 0, 0, 149, 0, 160, 117,
1520 212, 214, 0, 197, 178, 179, 174, 176, 175, 177,
1521 180, 173, 169, 170, 0, 0, 0, 0, 0, 0,
1522 0, 0, 0, 0, 0, 0, 0, 0, 172, 171,
1523 126, 0, 285, 267, 0, 266, 0, 0, 54, 0,
1524 0, 28, 29, 30, 31, 32, 33, 34, 35, 36,
1525 37, 0, 52, 53, 48, 49, 50, 51, 38, 39,
1526 40, 41, 42, 43, 44, 45, 46, 47, 0, 121,
1527 121, 306, 0, 0, 297, 0, 0, 0, 0, 0,
1528 0, 0, 0, 0, 0, 0, 103, 105, 104, 102,
1529 106, 107, 108, 109, 110, 112, 156, 154, 143, 144,
1530 145, 148, 142, 126, 126, 0, 0, 0, 0, 0,
1531 0, 0, 0, 162, 192, 0, 0, 0, 166, 0,
1532 163, 0, 0, 0, 0, 211, 231, 242, 243, 244,
1533 249, 245, 246, 247, 248, 240, 0, 251, 258, 257,
1534 259, 0, 268, 0, 0, 0, 0, 0, 302, 0,
1535 304, 283, 0, 0, 0, 0, 0, 0, 0, 0,
1536 0, 0, 0, 0, 0, 116, 115, 113, 114, 118,
1537 213, 215, 0, 0, 0, 283, 0, 0, 0, 0,
1538 0, 161, 147, 159, 0, 164, 165, 0, 0, 0,
1539 0, 0, 128, 126, 230, 111, 228, 0, 241, 0,
1540 0, 0, 0, 0, 0, 0, 0, 0, 0, 309,
1541 0, 0, 0, 293, 294, 0, 0, 0, 0, 291,
1542 0, 121, 0, 0, 0, 0, 0, 0, 0, 0,
1543 0, 191, 168, 0, 0, 0, 0, 123, 129, 127,
1544 64, 0, 117, 0, 250, 0, 0, 282, 0, 0,
1545 121, 122, 121, 0, 0, 0, 0, 0, 0, 287,
1546 288, 282, 0, 307, 0, 198, 0, 0, 182, 0,
1547 0, 0, 0, 167, 0, 0, 0, 63, 227, 229,
1548 111, 124, 0, 0, 0, 0, 0, 289, 290, 303,
1549 305, 284, 0, 0, 292, 295, 296, 0, 121, 0,
1550 0, 0, 188, 0, 0, 184, 185, 181, 64, 125,
1551 119, 252, 0, 0, 111, 0, 117, 278, 0, 117,
1552 308, 186, 187, 0, 0, 0, 226, 0, 232, 0,
1553 271, 0, 0, 280, 0, 0, 279, 298, 183, 189,
1554 190, 120, 269, 0, 270, 0, 111, 0, 0, 0,
1555 281, 0, 0, 0, 0, 276, 0, 0, 275, 0,
1556 272, 0, 0, 0
1557};
1558
1559static const short yydefgoto[] = { 256,
1560 257, 258, 282, 299, 156, 157, 76, 509, 12, 77,
1561 14, 15, 39, 40, 41, 45, 51, 114, 124, 326,
1562 222, 400, 329, 559, 379, 423, 541, 356, 424, 78,
1563 158, 133, 148, 134, 135, 107, 345, 368, 346, 117,
1564 85, 149, 592, 16, 17, 19, 18, 261, 334, 335,
1565 60, 22, 58, 98, 427, 428, 125, 164, 52, 93,
1566 53, 46, 430, 369, 80, 371, 266, 54, 89, 90,
1567 216, 563, 128, 305, 517, 440, 217, 218, 219, 220
1568};
1569
1570static const short yypact[] = { 42,
1571-32768,-32768,-32768,-32768,-32768,-32768,-32768, -21, -131, 60,
1572 -93, 105, -22, 182,-32768, 525,-32768, 46, 168, -12,
1573 19,-32768, 1, 152,-32768, 1277,-32768,-32768,-32768,-32768,
1574-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 90, 90,
1575 100,-32768,-32768,-32768, 90,-32768,-32768,-32768,-32768,-32768,
1576 90, 186,-32768, 12, 187, 201, 209,-32768,-32768,-32768,
1577-32768,-32768, 93,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1578-32768, 252, 254, 2, 907,-32768,-32768,-32768, 13,-32768,
1579 225, 225, 150,-32768, 76, 116, 116,-32768,-32768, 108,
1580-32768,-32768,-32768,-32768,-32768,-32768,-32768, -79, 1027,-32768,
1581 111, 114, 947, 93,-32768, 13, -104,-32768, 1027, 76,
1582 76,-32768,-32768, 1067,-32768,-32768, 1299, 266,-32768,-32768,
1583-32768,-32768,-32768, 1330,-32768, -16, 1572,-32768, 256,-32768,
1584-32768, 13,-32768, 139, 144, 1370, 1370, 132, -95, 1370,
1585-32768, 145, 1299, 1370, 93, 147, 13, 311,-32768, 43,
1586 290, 293, 298, 299, 302, 247, 303, 724,-32768,-32768,
1587 35,-32768,-32768,-32768,-32768,-32768, 258, 1450, 70, 305,
1588 116,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1589-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 317, 405,
1590 1370, 1370, 1370, 1370,-32768,-32768,-32768,-32768,-32768,-32768,
1591-32768,-32768,-32768,-32768,-32768,-32768, 1370, 1370, 1370, 1370,
1592 1370, 1370, 1370, 1370, 1370,-32768, 116,-32768, 34,-32768,
1593-32768, 131, 1107,-32768, 6, -46,-32768, 164, 13,-32768,
1594-32768, 13, 1067,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1595-32768,-32768,-32768,-32768, 317, 405, 173, 178, 179, 189,
1596 192, 1179, 1481, 987, 314, 193, 197, 198,-32768,-32768,
1597 202, 203,-32768, 93, 565,-32768, 699, 699,-32768, 699,
1598 1330,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1599-32768, 1370,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1600-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 1370, 113,
1601 137,-32768, 565, -10, 205, 207, 208, 210, 218, 219,
1602 565, 565, 330, 1330, 1370, 1370,-32768,-32768,-32768,-32768,
1603-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 106,-32768,
1604-32768,-32768, 106, 202, 202, 331, 220, 221, 1299, 1299,
1605 1299, 1299, 1299,-32768,-32768, -41, 1005, -61,-32768, -91,
1606-32768, 1299, 1299, 1299, -13,-32768, 1219,-32768,-32768,-32768,
1607-32768,-32768,-32768,-32768,-32768, 313, 1299,-32768,-32768,-32768,
1608-32768, 226,-32768, 227, 699, 565, 565, 23,-32768, 24,
1609-32768,-32768, 699, 223, 1370, 1370, 1370, 1370, 1370, 232,
1610 233, 1370, 699, 565, 234,-32768,-32768,-32768,-32768,-32768,
1611-32768,-32768, 1370, 1299, 1299,-32768, 235, 236, 237, 239,
1612 1299,-32768, 231, 724, -76,-32768,-32768, 241, 242, 352,
1613 369, 388,-32768, 202,-32768, 13, 246, 243,-32768, 374,
1614 -59, 380, 385, 253, 257, 270, 699, 414, 699, 272,
1615 273, 699, 278, 13,-32768, 280, 282, 699, 699, 13,
1616 283, 287, 1370, -112, 288, 289, -33, 1299, 1299, 1299,
1617 1299,-32768,-32768, 294, 1299, 1299, 1370,-32768,-32768,-32768,
1618 79, 1259,-32768, 292,-32768, 699, 699, 1370, 699, 699,
1619 287,-32768, 287, 1370, 699, 307, 1370, 1370, 1370,-32768,
1620-32768, 1370, 392,-32768, 565,-32768, 1299, 1299,-32768, 308,
1621 295, 309, 310,-32768, 301, 315, 7,-32768,-32768,-32768,
1622 13, 10, 427, 318, 306, 565, 52,-32768,-32768,-32768,
1623-32768,-32768, 316, 699,-32768,-32768,-32768, 71, 287, 322,
1624 325, 1299,-32768, 1299, 1299,-32768,-32768,-32768, 79,-32768,
1625 407,-32768, 444, -4,-32768, 1370,-32768,-32768, 323,-32768,
1626-32768,-32768,-32768, 327, 328, 329,-32768, 464,-32768, 699,
1627-32768, 859, -3, 131, 565, -14,-32768, 106,-32768,-32768,
1628-32768,-32768,-32768, 334,-32768, 859,-32768, 452, 465, 336,
1629 131, 699, 699, 468, 416,-32768, 699, 471,-32768, 699,
1630-32768, 490, 491,-32768
1631};
1632
1633static const short yypgoto[] = { 365,
1634 366, 367, 255, 251, -168,-32768, 0, -40, 408, 14,
1635-32768,-32768,-32768,-32768, 40,-32768,-32768,-32768, -158,-32768,
1636 -406,-32768, -226,-32768, -290, 3,-32768, -317,-32768,-32768,
1637 -25, 296, -119,-32768, 409, 413, -60, -155, -231, 166,
1638 119, 284,-32768,-32768, 504,-32768,-32768,-32768,-32768,-32768,
1639-32768,-32768,-32768,-32768,-32768,-32768, 435,-32768,-32768,-32768,
1640-32768,-32768,-32768, -525, -139, 47, -183,-32768, 474,-32768,
1641-32768,-32768,-32768,-32768, 37, 124,-32768,-32768,-32768,-32768
1642};
1643
1644
1645#define YYLAST 1705
1646
1647
1648static const short yytable[] = { 11,
1649 79, 270, 259, 333, 161, 102, 269, 269, 234, 302,
1650 381, 162, 271, 13, 23, 11, 401, 402, 260, 471,
1651 421, 348, 350, 578, 306, 307, 308, 309, 310, 13,
1652 20, 313, 88, 437, 439, 108, 574, 109, 496, 422,
1653 91, -200, 140, 421, 21, -54, -54, -54, -54, 106,
1654 580, 140, 25, 141, 2, 411, 159, 4, 314, -66,
1655 1, 2, 228, 3, 4, 5, 417, 129, 235, 236,
1656 411, 6, 7, 132, 130, 438, 438, 106, 81, 82,
1657 267, 464, 231, 132, 86, 411, 268, 411, 147, 11,
1658 87, 43, 8, 44, 416, 9, 475, 1, 147, 10,
1659 3, 108, 5, 109, 539, 411, 470, 115, 116, 331,
1660 225, 226, 412, 484, 229, 415, 24, 499, 232, 396,
1661 397, 398, 26, 27, 399, 370, 1, 370, 370, 3,
1662 370, 5, 395, 55, 83, 431, 84, 108, 564, 109,
1663 163, 383, 265, 396, 397, 398, 315, 316, 399, 561,
1664 575, 375, 57, 108, 108, 109, 109, 538, 103, 330,
1665 108, 494, 109, 370, 56, 300, 301, 265, 303, 92,
1666 581, 370, 370, 59, 262, 118, 119, 120, 121, 122,
1667 123, 304, 265, 265, 265, 265, 265, 311, 312, 265,
1668 520, 112, 521, 113, 393, 317, 318, 132, 546, 110,
1669 111, 443, 547, 445, 446, 447, 88, 147, 95, 47,
1670 48, 49, 319, 320, 50, 321, 322, 546, 323, 324,
1671 325, 550, 96, 28, 29, 30, 31, 32, 33, 34,
1672 97, 35, 36, 37, 38, 370, 370, 370, 551, 396,
1673 397, 398, 99, 370, 399, 147, 512, 317, 318, 237,
1674 238, 239, 240, 370, 370, 100, 376, 101, 259, 378,
1675 108, 84, 109, 136, 319, 320, 137, 321, 322, 160,
1676 323, 324, 325, 377, 260, 143, 144, 221, 406, 407,
1677 408, 409, 410, 380, 108, 223, 109, 227, 147, 394,
1678 265, 418, 419, 420, 224, 230, 233, 370, -55, 370,
1679 522, -56, 370, 525, 526, 527, -59, -58, 370, 370,
1680 -57, 241, 263, 372, 373, 269, 374, 61, 62, 332,
1681 566, 414, 339, 568, 36, 37, 38, 340, 341, 1,
1682 2, 426, 3, 4, 5, 351, 370, 370, 342, 370,
1683 370, 343, 352, 455, 456, 370, 353, 354, 355, 382,
1684 462, 384, 357, 385, 386, 370, 387, 390, 391, 265,
1685 444, 265, 265, 265, 388, 389, 450, 392, 403, 404,
1686 405, 429, 432, 433, 442, 562, 370, 454, 448, 449,
1687 453, 458, 459, 460, 370, 461, 463, 465, 466, 467,
1688 468, 469, 472, 473, 576, 474, 476, 500, 501, 502,
1689 503, 477, 478, 479, 505, 506, 272, 273, 274, 275,
1690 276, 277, 278, 279, 280, 281, 480, 482, 484, 485,
1691 370, 434, 435, 436, 487, 370, 488, 495, 489, 441,
1692 283, 284, 492, 493, 497, 498, 530, 531, 513, 451,
1693 452, 507, 370, 370, 438, 533, 511, 370, 542, 504,
1694 370, 536, 516, 524, 532, 534, 535, 544, 265, 558,
1695 560, 265, 265, 265, 543, 537, 516, 572, 582, 548,
1696 508, 554, 552, 555, 556, 553, 567, 569, 570, 571,
1697 579, 583, 584, 481, 587, 483, 588, 590, 486, 593,
1698 594, 213, 214, 215, 490, 491, 338, 127, 557, 337,
1699 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1700 295, 296, 297, 298, 540, 139, 336, 142, 328, 42,
1701 565, 126, 514, 515, -199, 518, 519, 94, 528, 457,
1702 0, 523, 0, 0, 0, 0, 0, 0, 508, 0,
1703 0, 529, -66, 1, 2, 0, 3, 4, 5, 0,
1704 0, 0, 0, 0, 6, 7, 0, 0, 0, 0,
1705 0, 0, 545, 0, 0, 0, 0, 358, 359, 0,
1706 549, 61, 62, 360, 0, 8, 0, 0, 9, 0,
1707 0, 0, 10, 1, 2, 0, 3, 4, 5, 361,
1708 362, 363, 0, 0, 0, 0, 0, 0, 0, 0,
1709 0, 0, 0, 0, 364, 365, 573, 0, 0, 0,
1710 0, 577, 0, 0, 0, 0, 0, 0, 0, 0,
1711 0, 366, 0, 0, 0, 0, 0, 0, 585, 586,
1712 0, 0, 0, 589, 0, 0, 591, 174, 175, 176,
1713 177, 178, 179, 180, 181, 182, 183, 184, 185, 186,
1714 187, 188, 245, 246, 0, 0, 0, 0, 0, 0,
1715 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1716 0, 0, 0, 0, 0, 0, 0, 0, 0, 247,
1717 195, 196, 197, 198, 199, 200, 201, 202, 203, 204,
1718 205, 206, 0, 248, 0, 249, 250, 251, 0, 0,
1719 0, 358, 359, 0, 0, 61, 62, 360, 0, 0,
1720 0, 0, 108, 0, 109, 0, 0, 1, 2, 367,
1721 3, 4, 5, 361, 362, 363, 0, 0, 0, 0,
1722 61, 62, 0, 0, 0, 0, 0, 0, 364, 365,
1723 0, 0, 1, 2, 0, 3, 4, 5, 242, 0,
1724 0, 0, 0, 0, 0, 366, 0, 0, 0, 0,
1725 0, 0, 0, 243, 244, 0, 0, 0, 0, 0,
1726 0, 174, 175, 176, 177, 178, 179, 180, 181, 182,
1727 183, 184, 185, 186, 187, 188, 245, 246, 0, 0,
1728 0, 0, 0, 0, 0, 0, 174, 175, 176, 177,
1729 178, 179, 180, 181, 182, 183, 184, 185, 186, 187,
1730 188, 245, 246, 247, 195, 196, 197, 198, 199, 200,
1731 201, 202, 203, 204, 205, 206, 0, 248, 0, 249,
1732 250, 251, 0, 0, 0, 0, 0, 0, 247, 195,
1733 196, 197, 198, 199, 200, 201, 202, 203, 204, 205,
1734 206, 0, 248, 367, 249, 250, 251, 0, 0, 0,
1735 0, 358, 359, 0, 0, 0, 0, 360, 0, 0,
1736 0, 108, 0, 109, 0, 252, 0, 0, 253, 0,
1737 254, 0, 255, 361, 362, 363, 0, 0, 0, 0,
1738 0, 0, 0, 0, 0, 0, 0, 0, 364, 365,
1739 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1740 0, 0, 0, 61, 62, 366, 104, 64, 65, 66,
1741 67, 68, 69, 70, 0, 1, 2, 0, 3, 4,
1742 5, 174, 175, 176, 177, 178, 179, 180, 181, 182,
1743 183, 184, 185, 186, 187, 188, 245, 246, 0, 0,
1744 0, 0, 0, 61, 62, 71, 104, 64, 65, 66,
1745 67, 68, 69, 70, 0, 1, 2, 0, 3, 4,
1746 5, 0, 0, 247, 195, 196, 197, 198, 199, 200,
1747 201, 202, 203, 204, 205, 206, 0, 248, 0, 249,
1748 250, 251, 0, 61, 62, 71, 104, 150, 151, 152,
1749 153, 154, 155, 70, 0, 1, 2, 0, 3, 4,
1750 5, 61, 62, 367, 104, 150, 151, 152, 153, 154,
1751 155, 70, 0, 1, 2, 0, 3, 4, 5, 0,
1752 0, 0, 0, 61, 62, 71, 104, 64, 65, 66,
1753 67, 68, 69, 70, 0, 1, 2, 0, 3, 4,
1754 5, 0, 0, 71, 0, 72, 0, 0, 73, 0,
1755 0, 74, 0, 75, 105, 131, 0, 0, 0, 0,
1756 0, 0, 0, 61, 62, 71, 145, 64, 65, 66,
1757 67, 68, 69, 70, 0, 1, 2, 0, 3, 4,
1758 5, 0, 0, 0, 0, 72, 0, 0, 73, 0,
1759 0, 74, 0, 75, 138, 0, 0, 0, 0, 0,
1760 0, 0, 0, 61, 62, 71, 104, 64, 65, 66,
1761 67, 68, 69, 70, 0, 1, 2, 0, 3, 4,
1762 5, 0, 0, 0, 0, 72, 0, 0, 73, 0,
1763 0, 74, 0, 75, 349, 327, 0, 0, 0, 0,
1764 0, 0, 0, 72, 0, 71, 73, 0, 0, 74,
1765 0, 75, 413, 0, 0, 0, 0, 0, 0, 0,
1766 0, 0, 0, 0, 0, 72, 0, 0, 73, 0,
1767 0, 74, 0, 75, 0, 61, 62, 146, 104, 150,
1768 151, 152, 153, 154, 155, 70, 0, 1, 2, 0,
1769 3, 4, 5, 0, 0, 0, 0, 0, 0, 0,
1770 0, 0, 0, 0, 0, 72, 0, 0, 73, 0,
1771 0, 74, 0, 75, 0, 61, 62, 71, 104, 64,
1772 65, 66, 67, 68, 69, 70, 0, 1, 2, 0,
1773 3, 4, 5, 0, 0, 0, 0, 0, 0, 0,
1774 0, 0, 0, 0, 0, 72, 0, 425, 73, 0,
1775 0, 74, 0, 75, 0, 61, 62, 71, 104, 64,
1776 65, 66, 67, 68, 69, 70, 0, 1, 2, 0,
1777 3, 4, 5, 61, 62, 0, 63, 64, 65, 66,
1778 67, 68, 69, 70, 0, 1, 2, 510, 3, 4,
1779 5, 0, 0, 0, 0, 61, 62, 71, 104, 150,
1780 151, 152, 153, 154, 155, 70, 0, 1, 2, 0,
1781 3, 4, 5, 0, 0, 71, 0, 72, 0, 0,
1782 73, 0, 344, 74, 0, 75, 61, 62, 0, 145,
1783 64, 65, 66, 67, 68, 69, 70, 71, 1, 2,
1784 0, 3, 4, 5, 0, 0, 0, 0, 0, 0,
1785 0, 0, 0, 0, 0, 0, 0, 72, 0, 0,
1786 73, 0, 0, 74, 0, 75, 61, 62, 71, 104,
1787 64, 65, 66, 67, 68, 69, 70, 0, 1, 2,
1788 0, 3, 4, 5, 0, 0, 0, 0, 0, 0,
1789 0, 0, 0, 0, 0, 0, 0, 72, 0, 0,
1790 73, 0, 0, 74, 0, 75, 0, 0, 71, 0,
1791 0, 0, 0, 0, 0, 72, 0, 0, 73, 0,
1792 0, 74, 0, 75, 0, 0, 0, 0, 0, 0,
1793 0, 0, 0, 0, 0, 0, 0, 72, 0, 0,
1794 73, 0, 0, 74, 0, 75, 61, 62, 0, 264,
1795 64, 65, 66, 67, 68, 69, 70, 0, 1, 2,
1796 0, 3, 4, 5, 0, 0, 0, 0, 72, 0,
1797 0, 73, 0, 0, 74, 0, 75, 61, 62, 0,
1798 104, 150, 151, 152, 153, 154, 155, 70, 71, 1,
1799 2, 0, 3, 4, 5, 0, 0, 0, 0, 0,
1800 0, 0, 0, 0, 0, 0, 0, 0, 72, 0,
1801 0, 73, 0, 0, 74, 0, 75, 0, 0, 71,
1802 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1803 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1804 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1805 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1806 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1807 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1808 0, 0, 0, 0, 0, 0, 0, 0, 72, 0,
1809 0, 73, 0, 0, 74, 0, 75, 165, 0, 0,
1810 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1811 0, 0, 0, 0, 0, 0, 166, 167, 0, 72,
1812 0, 0, 73, 0, 0, 74, 0, 347, 168, 169,
1813 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
1814 180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
1815 190, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1816 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1817 0, 191, 192, 193, 0, 0, 194, 195, 196, 197,
1818 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
1819 208, 209, 210, 211, 212
1820};
1821
1822static const short yycheck[] = { 0,
1823 26, 170, 158, 230, 124, 4, 11, 11, 148, 193,
1824 301, 28, 171, 0, 146, 16, 334, 335, 158, 426,
1825 34, 253, 254, 38, 208, 209, 210, 211, 212, 16,
1826 52, 215, 21, 11, 11, 148, 562, 150, 151, 53,
1827 29, 0, 147, 34, 66, 3, 4, 5, 6, 75,
1828 576, 147, 146, 158, 20, 147, 117, 23, 217, 18,
1829 19, 20, 158, 22, 23, 24, 158, 147, 26, 27,
1830 147, 30, 31, 99, 154, 53, 53, 103, 39, 40,
1831 11, 158, 143, 109, 45, 147, 17, 147, 114, 90,
1832 51, 46, 51, 48, 156, 54, 156, 19, 124, 58,
1833 22, 148, 24, 150, 511, 147, 424, 32, 33, 156,
1834 136, 137, 154, 147, 140, 347, 57, 151, 144, 134,
1835 135, 136, 18, 146, 139, 265, 19, 267, 268, 22,
1836 270, 24, 316, 146, 35, 367, 37, 148, 545, 150,
1837 157, 152, 168, 134, 135, 136, 113, 114, 139, 154,
1838 154, 271, 152, 148, 148, 150, 150, 151, 157, 154,
1839 148, 452, 150, 303, 146, 191, 192, 193, 194, 158,
1840 577, 311, 312, 22, 161, 60, 61, 62, 63, 64,
1841 65, 207, 208, 209, 210, 211, 212, 213, 214, 215,
1842 481, 42, 483, 44, 314, 117, 118, 223, 147, 81,
1843 82, 385, 151, 387, 388, 389, 21, 233, 22, 42,
1844 43, 44, 134, 135, 47, 137, 138, 147, 140, 141,
1845 142, 151, 22, 42, 43, 44, 45, 46, 47, 48,
1846 22, 50, 143, 144, 145, 375, 376, 377, 529, 134,
1847 135, 136, 150, 383, 139, 271, 473, 117, 118, 3,
1848 4, 5, 6, 393, 394, 4, 282, 4, 414, 147,
1849 148, 37, 150, 153, 134, 135, 153, 137, 138, 4,
1850 140, 141, 142, 299, 414, 110, 111, 22, 339, 340,
1851 341, 342, 343, 147, 148, 147, 150, 156, 314, 315,
1852 316, 352, 353, 354, 151, 151, 150, 437, 9, 439,
1853 484, 9, 442, 487, 488, 489, 9, 9, 448, 449,
1854 9, 9, 55, 267, 268, 11, 270, 7, 8, 156,
1855 547, 347, 150, 550, 143, 144, 145, 150, 150, 19,
1856 20, 357, 22, 23, 24, 22, 476, 477, 150, 479,
1857 480, 150, 150, 404, 405, 485, 150, 150, 147, 303,
1858 411, 147, 150, 147, 147, 495, 147, 311, 312, 385,
1859 386, 387, 388, 389, 147, 147, 392, 38, 38, 150,
1860 150, 59, 147, 147, 152, 544, 516, 403, 147, 147,
1861 147, 147, 147, 147, 524, 147, 156, 147, 147, 38,
1862 22, 4, 147, 151, 563, 22, 17, 458, 459, 460,
1863 461, 17, 150, 147, 465, 466, 90, 91, 92, 93,
1864 94, 95, 96, 97, 98, 99, 147, 4, 147, 147,
1865 560, 375, 376, 377, 147, 565, 147, 453, 147, 383,
1866 26, 27, 150, 147, 147, 147, 497, 498, 147, 393,
1867 394, 467, 582, 583, 53, 151, 472, 587, 22, 156,
1868 590, 151, 478, 147, 147, 147, 147, 152, 484, 53,
1869 17, 487, 488, 489, 147, 151, 492, 4, 17, 154,
1870 471, 532, 151, 534, 535, 151, 154, 151, 151, 151,
1871 147, 17, 147, 437, 17, 439, 71, 17, 442, 0,
1872 0, 127, 127, 127, 448, 449, 246, 90, 539, 245,
1873 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
1874 106, 107, 108, 109, 512, 103, 233, 109, 223, 16,
1875 546, 87, 476, 477, 0, 479, 480, 54, 492, 406,
1876 -1, 485, -1, -1, -1, -1, -1, -1, 539, -1,
1877 -1, 495, 18, 19, 20, -1, 22, 23, 24, -1,
1878 -1, -1, -1, -1, 30, 31, -1, -1, -1, -1,
1879 -1, -1, 516, -1, -1, -1, -1, 3, 4, -1,
1880 524, 7, 8, 9, -1, 51, -1, -1, 54, -1,
1881 -1, -1, 58, 19, 20, -1, 22, 23, 24, 25,
1882 26, 27, -1, -1, -1, -1, -1, -1, -1, -1,
1883 -1, -1, -1, -1, 40, 41, 560, -1, -1, -1,
1884 -1, 565, -1, -1, -1, -1, -1, -1, -1, -1,
1885 -1, 57, -1, -1, -1, -1, -1, -1, 582, 583,
1886 -1, -1, -1, 587, -1, -1, 590, 73, 74, 75,
1887 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
1888 86, 87, 88, 89, -1, -1, -1, -1, -1, -1,
1889 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1890 -1, -1, -1, -1, -1, -1, -1, -1, -1, 115,
1891 116, 117, 118, 119, 120, 121, 122, 123, 124, 125,
1892 126, 127, -1, 129, -1, 131, 132, 133, -1, -1,
1893 -1, 3, 4, -1, -1, 7, 8, 9, -1, -1,
1894 -1, -1, 148, -1, 150, -1, -1, 19, 20, 155,
1895 22, 23, 24, 25, 26, 27, -1, -1, -1, -1,
1896 7, 8, -1, -1, -1, -1, -1, -1, 40, 41,
1897 -1, -1, 19, 20, -1, 22, 23, 24, 25, -1,
1898 -1, -1, -1, -1, -1, 57, -1, -1, -1, -1,
1899 -1, -1, -1, 40, 41, -1, -1, -1, -1, -1,
1900 -1, 73, 74, 75, 76, 77, 78, 79, 80, 81,
1901 82, 83, 84, 85, 86, 87, 88, 89, -1, -1,
1902 -1, -1, -1, -1, -1, -1, 73, 74, 75, 76,
1903 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1904 87, 88, 89, 115, 116, 117, 118, 119, 120, 121,
1905 122, 123, 124, 125, 126, 127, -1, 129, -1, 131,
1906 132, 133, -1, -1, -1, -1, -1, -1, 115, 116,
1907 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
1908 127, -1, 129, 155, 131, 132, 133, -1, -1, -1,
1909 -1, 3, 4, -1, -1, -1, -1, 9, -1, -1,
1910 -1, 148, -1, 150, -1, 152, -1, -1, 155, -1,
1911 157, -1, 159, 25, 26, 27, -1, -1, -1, -1,
1912 -1, -1, -1, -1, -1, -1, -1, -1, 40, 41,
1913 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1914 -1, -1, -1, 7, 8, 57, 10, 11, 12, 13,
1915 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
1916 24, 73, 74, 75, 76, 77, 78, 79, 80, 81,
1917 82, 83, 84, 85, 86, 87, 88, 89, -1, -1,
1918 -1, -1, -1, 7, 8, 49, 10, 11, 12, 13,
1919 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
1920 24, -1, -1, 115, 116, 117, 118, 119, 120, 121,
1921 122, 123, 124, 125, 126, 127, -1, 129, -1, 131,
1922 132, 133, -1, 7, 8, 49, 10, 11, 12, 13,
1923 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
1924 24, 7, 8, 155, 10, 11, 12, 13, 14, 15,
1925 16, 17, -1, 19, 20, -1, 22, 23, 24, -1,
1926 -1, -1, -1, 7, 8, 49, 10, 11, 12, 13,
1927 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
1928 24, -1, -1, 49, -1, 149, -1, -1, 152, -1,
1929 -1, 155, -1, 157, 158, 39, -1, -1, -1, -1,
1930 -1, -1, -1, 7, 8, 49, 10, 11, 12, 13,
1931 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
1932 24, -1, -1, -1, -1, 149, -1, -1, 152, -1,
1933 -1, 155, -1, 157, 158, -1, -1, -1, -1, -1,
1934 -1, -1, -1, 7, 8, 49, 10, 11, 12, 13,
1935 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
1936 24, -1, -1, -1, -1, 149, -1, -1, 152, -1,
1937 -1, 155, -1, 157, 158, 39, -1, -1, -1, -1,
1938 -1, -1, -1, 149, -1, 49, 152, -1, -1, 155,
1939 -1, 157, 158, -1, -1, -1, -1, -1, -1, -1,
1940 -1, -1, -1, -1, -1, 149, -1, -1, 152, -1,
1941 -1, 155, -1, 157, -1, 7, 8, 121, 10, 11,
1942 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
1943 22, 23, 24, -1, -1, -1, -1, -1, -1, -1,
1944 -1, -1, -1, -1, -1, 149, -1, -1, 152, -1,
1945 -1, 155, -1, 157, -1, 7, 8, 49, 10, 11,
1946 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
1947 22, 23, 24, -1, -1, -1, -1, -1, -1, -1,
1948 -1, -1, -1, -1, -1, 149, -1, 39, 152, -1,
1949 -1, 155, -1, 157, -1, 7, 8, 49, 10, 11,
1950 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
1951 22, 23, 24, 7, 8, -1, 10, 11, 12, 13,
1952 14, 15, 16, 17, -1, 19, 20, 39, 22, 23,
1953 24, -1, -1, -1, -1, 7, 8, 49, 10, 11,
1954 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
1955 22, 23, 24, -1, -1, 49, -1, 149, -1, -1,
1956 152, -1, 154, 155, -1, 157, 7, 8, -1, 10,
1957 11, 12, 13, 14, 15, 16, 17, 49, 19, 20,
1958 -1, 22, 23, 24, -1, -1, -1, -1, -1, -1,
1959 -1, -1, -1, -1, -1, -1, -1, 149, -1, -1,
1960 152, -1, -1, 155, -1, 157, 7, 8, 49, 10,
1961 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
1962 -1, 22, 23, 24, -1, -1, -1, -1, -1, -1,
1963 -1, -1, -1, -1, -1, -1, -1, 149, -1, -1,
1964 152, -1, -1, 155, -1, 157, -1, -1, 49, -1,
1965 -1, -1, -1, -1, -1, 149, -1, -1, 152, -1,
1966 -1, 155, -1, 157, -1, -1, -1, -1, -1, -1,
1967 -1, -1, -1, -1, -1, -1, -1, 149, -1, -1,
1968 152, -1, -1, 155, -1, 157, 7, 8, -1, 10,
1969 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
1970 -1, 22, 23, 24, -1, -1, -1, -1, 149, -1,
1971 -1, 152, -1, -1, 155, -1, 157, 7, 8, -1,
1972 10, 11, 12, 13, 14, 15, 16, 17, 49, 19,
1973 20, -1, 22, 23, 24, -1, -1, -1, -1, -1,
1974 -1, -1, -1, -1, -1, -1, -1, -1, 149, -1,
1975 -1, 152, -1, -1, 155, -1, 157, -1, -1, 49,
1976 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1977 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1978 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1979 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1980 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1981 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1982 -1, -1, -1, -1, -1, -1, -1, -1, 149, -1,
1983 -1, 152, -1, -1, 155, -1, 157, 36, -1, -1,
1984 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1985 -1, -1, -1, -1, -1, -1, 55, 56, -1, 149,
1986 -1, -1, 152, -1, -1, 155, -1, 157, 67, 68,
1987 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
1988 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
1989 89, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1990 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1991 -1, 110, 111, 112, -1, -1, 115, 116, 117, 118,
1992 119, 120, 121, 122, 123, 124, 125, 126, 127, 128,
1993 129, 130, 131, 132, 133
1994};
1995/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
1996#line 3 "/usr/share/bison.simple"
1997/* This file comes from bison-1.28. */
1998
1999/* Skeleton output parser for bison,
2000 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
2001
2002 This program is free software; you can redistribute it and/or modify
2003 it under the terms of the GNU General Public License as published by
2004 the Free Software Foundation; either version 2, or (at your option)
2005 any later version.
2006
2007 This program is distributed in the hope that it will be useful,
2008 but WITHOUT ANY WARRANTY; without even the implied warranty of
2009 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2010 GNU General Public License for more details.
2011
2012 You should have received a copy of the GNU General Public License
2013 along with this program; if not, write to the Free Software
2014 Foundation, Inc., 59 Temple Place - Suite 330,
2015 Boston, MA 02111-1307, USA. */
2016
2017/* As a special exception, when this file is copied by Bison into a
2018 Bison output file, you may use that output file without restriction.
2019 This special exception was added by the Free Software Foundation
2020 in version 1.24 of Bison. */
2021
2022/* This is the parser code that is written into each bison parser
2023 when the %semantic_parser declaration is not specified in the grammar.
2024 It was written by Richard Stallman by simplifying the hairy parser
2025 used when %semantic_parser is specified. */
2026
2027#ifndef YYSTACK_USE_ALLOCA
2028#ifdef alloca
2029#define YYSTACK_USE_ALLOCA
2030#else /* alloca not defined */
2031#ifdef __GNUC__
2032#define YYSTACK_USE_ALLOCA
2033#define alloca __builtin_alloca
2034#else /* not GNU C. */
2035#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
2036#define YYSTACK_USE_ALLOCA
2037#include <alloca.h>
2038#else /* not sparc */
2039/* We think this test detects Watcom and Microsoft C. */
2040/* This used to test MSDOS, but that is a bad idea
2041 since that symbol is in the user namespace. */
2042#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
2043#if 0 /* No need for malloc.h, which pollutes the namespace;
2044 instead, just don't use alloca. */
2045#include <malloc.h>
2046#endif
2047#else /* not MSDOS, or __TURBOC__ */
2048#if defined(_AIX)
2049/* I don't know what this was needed for, but it pollutes the namespace.
2050 So I turned it off. rms, 2 May 1997. */
2051/* #include <malloc.h> */
2052 #pragma alloca
2053#define YYSTACK_USE_ALLOCA
2054#else /* not MSDOS, or __TURBOC__, or _AIX */
2055#if 0
2056#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
2057 and on HPUX 10. Eventually we can turn this on. */
2058#define YYSTACK_USE_ALLOCA
2059#define alloca __builtin_alloca
2060#endif /* __hpux */
2061#endif
2062#endif /* not _AIX */
2063#endif /* not MSDOS, or __TURBOC__ */
2064#endif /* not sparc */
2065#endif /* not GNU C */
2066#endif /* alloca not defined */
2067#endif /* YYSTACK_USE_ALLOCA not defined */
2068
2069#ifdef YYSTACK_USE_ALLOCA
2070#define YYSTACK_ALLOC alloca
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002071#else
Dale Johannesen3afee192007-09-07 21:07:57 +00002072#define YYSTACK_ALLOC malloc
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002073#endif
2074
Dale Johannesen3afee192007-09-07 21:07:57 +00002075/* Note: there must be only one dollar sign in this file.
2076 It is replaced by the list of actions, each action
2077 as one case of the switch. */
David Greene9145dd22007-08-01 03:59:32 +00002078
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002079#define yyerrok (yyerrstatus = 0)
2080#define yyclearin (yychar = YYEMPTY)
Dale Johannesen3afee192007-09-07 21:07:57 +00002081#define YYEMPTY -2
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002082#define YYEOF 0
2083#define YYACCEPT goto yyacceptlab
Dale Johannesen3afee192007-09-07 21:07:57 +00002084#define YYABORT goto yyabortlab
2085#define YYERROR goto yyerrlab1
2086/* Like YYERROR except do call yyerror.
2087 This remains here temporarily to ease the
2088 transition to the new meaning of YYERROR, for GCC.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002089 Once GCC version 2 has supplanted version 1, this can go. */
2090#define YYFAIL goto yyerrlab
2091#define YYRECOVERING() (!!yyerrstatus)
Dale Johannesen3afee192007-09-07 21:07:57 +00002092#define YYBACKUP(token, value) \
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002093do \
2094 if (yychar == YYEMPTY && yylen == 1) \
Dale Johannesen3afee192007-09-07 21:07:57 +00002095 { yychar = (token), yylval = (value); \
2096 yychar1 = YYTRANSLATE (yychar); \
Chris Lattnerbb856a32007-08-06 21:00:46 +00002097 YYPOPSTACK; \
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002098 goto yybackup; \
2099 } \
2100 else \
Dale Johannesen3afee192007-09-07 21:07:57 +00002101 { yyerror ("syntax error: cannot back up"); YYERROR; } \
Chris Lattnerbb856a32007-08-06 21:00:46 +00002102while (0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002103
2104#define YYTERROR 1
2105#define YYERRCODE 256
2106
Dale Johannesen3afee192007-09-07 21:07:57 +00002107#ifndef YYPURE
2108#define YYLEX yylex()
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002109#endif
2110
Dale Johannesen3afee192007-09-07 21:07:57 +00002111#ifdef YYPURE
2112#ifdef YYLSP_NEEDED
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002113#ifdef YYLEX_PARAM
Dale Johannesen3afee192007-09-07 21:07:57 +00002114#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002115#else
Dale Johannesen3afee192007-09-07 21:07:57 +00002116#define YYLEX yylex(&yylval, &yylloc)
2117#endif
2118#else /* not YYLSP_NEEDED */
2119#ifdef YYLEX_PARAM
2120#define YYLEX yylex(&yylval, YYLEX_PARAM)
2121#else
2122#define YYLEX yylex(&yylval)
2123#endif
2124#endif /* not YYLSP_NEEDED */
Chris Lattnerbb856a32007-08-06 21:00:46 +00002125#endif
David Greene48556392007-09-04 18:46:50 +00002126
Dale Johannesen3afee192007-09-07 21:07:57 +00002127/* If nonreentrant, generate the variables here */
David Greene48556392007-09-04 18:46:50 +00002128
Dale Johannesen3afee192007-09-07 21:07:57 +00002129#ifndef YYPURE
David Greene48556392007-09-04 18:46:50 +00002130
Dale Johannesen3afee192007-09-07 21:07:57 +00002131int yychar; /* the lookahead symbol */
2132YYSTYPE yylval; /* the semantic value of the */
2133 /* lookahead symbol */
David Greene48556392007-09-04 18:46:50 +00002134
Dale Johannesen3afee192007-09-07 21:07:57 +00002135#ifdef YYLSP_NEEDED
2136YYLTYPE yylloc; /* location data for the lookahead */
2137 /* symbol */
Chris Lattnerbb856a32007-08-06 21:00:46 +00002138#endif
David Greene48556392007-09-04 18:46:50 +00002139
Dale Johannesen3afee192007-09-07 21:07:57 +00002140int yynerrs; /* number of parse errors so far */
2141#endif /* not YYPURE */
David Greene48556392007-09-04 18:46:50 +00002142
Dale Johannesen3afee192007-09-07 21:07:57 +00002143#if YYDEBUG != 0
2144int yydebug; /* nonzero means print parse trace */
2145/* Since this is uninitialized, it does not stop multiple parsers
2146 from coexisting. */
Dale Johannesenf325d9f2007-08-03 01:03:46 +00002147#endif
Chandler Carruth563d4a42007-08-04 01:56:21 +00002148
Dale Johannesen3afee192007-09-07 21:07:57 +00002149/* YYINITDEPTH indicates the initial size of the parser's stacks */
Chandler Carruth563d4a42007-08-04 01:56:21 +00002150
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002151#ifndef YYINITDEPTH
Dale Johannesen3afee192007-09-07 21:07:57 +00002152#define YYINITDEPTH 200
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002153#endif
2154
Dale Johannesen3afee192007-09-07 21:07:57 +00002155/* YYMAXDEPTH is the maximum size the stacks can grow to
2156 (effective only if the built-in stack extension method is used). */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002157
Dale Johannesen3afee192007-09-07 21:07:57 +00002158#if YYMAXDEPTH == 0
2159#undef YYMAXDEPTH
Chris Lattnerbb856a32007-08-06 21:00:46 +00002160#endif
David Greene9145dd22007-08-01 03:59:32 +00002161
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002162#ifndef YYMAXDEPTH
Dale Johannesen3afee192007-09-07 21:07:57 +00002163#define YYMAXDEPTH 10000
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002164#endif
2165
Dale Johannesen3afee192007-09-07 21:07:57 +00002166/* Define __yy_memcpy. Note that the size argument
2167 should be passed with type unsigned int, because that is what the non-GCC
2168 definitions require. With GCC, __builtin_memcpy takes an arg
2169 of type size_t, but it can handle unsigned int. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002170
Dale Johannesen3afee192007-09-07 21:07:57 +00002171#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
2172#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
2173#else /* not GNU C or C++ */
2174#ifndef __cplusplus
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002175
Dale Johannesen3afee192007-09-07 21:07:57 +00002176/* This is the most reliable way to avoid incompatibilities
2177 in available built-in functions on various systems. */
David Greene48556392007-09-04 18:46:50 +00002178static void
Dale Johannesen3afee192007-09-07 21:07:57 +00002179__yy_memcpy (to, from, count)
2180 char *to;
2181 char *from;
2182 unsigned int count;
2183{
2184 register char *f = from;
2185 register char *t = to;
2186 register int i = count;
2187
2188 while (i-- > 0)
2189 *t++ = *f++;
2190}
2191
2192#else /* __cplusplus */
2193
2194/* This is the most reliable way to avoid incompatibilities
2195 in available built-in functions on various systems. */
David Greene48556392007-09-04 18:46:50 +00002196static void
Dale Johannesen3afee192007-09-07 21:07:57 +00002197__yy_memcpy (char *to, char *from, unsigned int count)
2198{
2199 register char *t = to;
2200 register char *f = from;
2201 register int i = count;
2202
2203 while (i-- > 0)
2204 *t++ = *f++;
2205}
2206
Dale Johannesenf325d9f2007-08-03 01:03:46 +00002207#endif
David Greene48556392007-09-04 18:46:50 +00002208#endif
David Greene48556392007-09-04 18:46:50 +00002209
Dale Johannesen3afee192007-09-07 21:07:57 +00002210#line 217 "/usr/share/bison.simple"
David Greene48556392007-09-04 18:46:50 +00002211
Dale Johannesen3afee192007-09-07 21:07:57 +00002212/* The user can define YYPARSE_PARAM as the name of an argument to be passed
2213 into yyparse. The argument should have type void *.
2214 It should actually point to an object.
2215 Grammar actions can access the variable by casting it
2216 to the proper pointer type. */
David Greene48556392007-09-04 18:46:50 +00002217
2218#ifdef YYPARSE_PARAM
Dale Johannesen3afee192007-09-07 21:07:57 +00002219#ifdef __cplusplus
2220#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
2221#define YYPARSE_PARAM_DECL
2222#else /* not __cplusplus */
2223#define YYPARSE_PARAM_ARG YYPARSE_PARAM
2224#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
2225#endif /* not __cplusplus */
2226#else /* not YYPARSE_PARAM */
2227#define YYPARSE_PARAM_ARG
2228#define YYPARSE_PARAM_DECL
2229#endif /* not YYPARSE_PARAM */
2230
2231/* Prevent warning if -Wstrict-prototypes. */
2232#ifdef __GNUC__
2233#ifdef YYPARSE_PARAM
2234int yyparse (void *);
2235#else
David Greene48556392007-09-04 18:46:50 +00002236int yyparse (void);
David Greene48556392007-09-04 18:46:50 +00002237#endif
Dale Johannesen3afee192007-09-07 21:07:57 +00002238#endif
David Greene48556392007-09-04 18:46:50 +00002239
David Greene48556392007-09-04 18:46:50 +00002240int
Dale Johannesen3afee192007-09-07 21:07:57 +00002241yyparse(YYPARSE_PARAM_ARG)
2242 YYPARSE_PARAM_DECL
David Greene48556392007-09-04 18:46:50 +00002243{
Chris Lattnerbb856a32007-08-06 21:00:46 +00002244 register int yystate;
2245 register int yyn;
2246 register short *yyssp;
2247 register YYSTYPE *yyvsp;
Dale Johannesen3afee192007-09-07 21:07:57 +00002248 int yyerrstatus; /* number of tokens to shift before error messages enabled */
2249 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
Chris Lattnerbb856a32007-08-06 21:00:46 +00002250
Dale Johannesen3afee192007-09-07 21:07:57 +00002251 short yyssa[YYINITDEPTH]; /* the state stack */
2252 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
Chris Lattnerbb856a32007-08-06 21:00:46 +00002253
Dale Johannesen3afee192007-09-07 21:07:57 +00002254 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
2255 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
Chris Lattnerbb856a32007-08-06 21:00:46 +00002256
Dale Johannesen3afee192007-09-07 21:07:57 +00002257#ifdef YYLSP_NEEDED
2258 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
2259 YYLTYPE *yyls = yylsa;
2260 YYLTYPE *yylsp;
2261
2262#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
2263#else
Chris Lattnerbb856a32007-08-06 21:00:46 +00002264#define YYPOPSTACK (yyvsp--, yyssp--)
Dale Johannesen3afee192007-09-07 21:07:57 +00002265#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002266
Dale Johannesen3afee192007-09-07 21:07:57 +00002267 int yystacksize = YYINITDEPTH;
2268 int yyfree_stacks = 0;
Chandler Carruth563d4a42007-08-04 01:56:21 +00002269
Dale Johannesen3afee192007-09-07 21:07:57 +00002270#ifdef YYPURE
2271 int yychar;
2272 YYSTYPE yylval;
2273 int yynerrs;
2274#ifdef YYLSP_NEEDED
2275 YYLTYPE yylloc;
2276#endif
2277#endif
Chandler Carruth563d4a42007-08-04 01:56:21 +00002278
Dale Johannesen3afee192007-09-07 21:07:57 +00002279 YYSTYPE yyval; /* the variable used to return */
2280 /* semantic values from the action */
2281 /* routines */
Chandler Carruth563d4a42007-08-04 01:56:21 +00002282
Chris Lattnerbb856a32007-08-06 21:00:46 +00002283 int yylen;
Chandler Carruth563d4a42007-08-04 01:56:21 +00002284
Dale Johannesen3afee192007-09-07 21:07:57 +00002285#if YYDEBUG != 0
2286 if (yydebug)
2287 fprintf(stderr, "Starting parse\n");
2288#endif
Chandler Carruth563d4a42007-08-04 01:56:21 +00002289
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002290 yystate = 0;
2291 yyerrstatus = 0;
2292 yynerrs = 0;
2293 yychar = YYEMPTY; /* Cause a token to be read. */
2294
2295 /* Initialize stack pointers.
2296 Waste one element of value and location stack
2297 so that they stay on the same level as the state stack.
2298 The wasted elements are never initialized. */
2299
Dale Johannesen3afee192007-09-07 21:07:57 +00002300 yyssp = yyss - 1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002301 yyvsp = yyvs;
Dale Johannesen3afee192007-09-07 21:07:57 +00002302#ifdef YYLSP_NEEDED
2303 yylsp = yyls;
2304#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002305
Dale Johannesen3afee192007-09-07 21:07:57 +00002306/* Push a new state, which is found in yystate . */
2307/* In all cases, when you get here, the value and location stacks
2308 have just been pushed. so pushing a state here evens the stacks. */
2309yynewstate:
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002310
Dale Johannesen3afee192007-09-07 21:07:57 +00002311 *++yyssp = yystate;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002312
Dale Johannesen3afee192007-09-07 21:07:57 +00002313 if (yyssp >= yyss + yystacksize - 1)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002314 {
Dale Johannesen3afee192007-09-07 21:07:57 +00002315 /* Give user a chance to reallocate the stack */
2316 /* Use copies of these so that the &'s don't force the real ones into memory. */
2317 YYSTYPE *yyvs1 = yyvs;
2318 short *yyss1 = yyss;
2319#ifdef YYLSP_NEEDED
2320 YYLTYPE *yyls1 = yyls;
2321#endif
2322
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002323 /* Get the current used size of the three stacks, in elements. */
Dale Johannesen3afee192007-09-07 21:07:57 +00002324 int size = yyssp - yyss + 1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002325
2326#ifdef yyoverflow
Dale Johannesen3afee192007-09-07 21:07:57 +00002327 /* Each stack pointer address is followed by the size of
2328 the data in use in that stack, in bytes. */
2329#ifdef YYLSP_NEEDED
2330 /* This used to be a conditional around just the two extra args,
2331 but that might be undefined if yyoverflow is a macro. */
2332 yyoverflow("parser stack overflow",
2333 &yyss1, size * sizeof (*yyssp),
2334 &yyvs1, size * sizeof (*yyvsp),
2335 &yyls1, size * sizeof (*yylsp),
2336 &yystacksize);
2337#else
2338 yyoverflow("parser stack overflow",
2339 &yyss1, size * sizeof (*yyssp),
2340 &yyvs1, size * sizeof (*yyvsp),
2341 &yystacksize);
2342#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002343
Dale Johannesen3afee192007-09-07 21:07:57 +00002344 yyss = yyss1; yyvs = yyvs1;
2345#ifdef YYLSP_NEEDED
2346 yyls = yyls1;
2347#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002348#else /* no yyoverflow */
2349 /* Extend the stack our own way. */
Dale Johannesen3afee192007-09-07 21:07:57 +00002350 if (yystacksize >= YYMAXDEPTH)
2351 {
2352 yyerror("parser stack overflow");
2353 if (yyfree_stacks)
2354 {
2355 free (yyss);
2356 free (yyvs);
2357#ifdef YYLSP_NEEDED
2358 free (yyls);
2359#endif
2360 }
2361 return 2;
2362 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002363 yystacksize *= 2;
Dale Johannesen3afee192007-09-07 21:07:57 +00002364 if (yystacksize > YYMAXDEPTH)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002365 yystacksize = YYMAXDEPTH;
Dale Johannesen3afee192007-09-07 21:07:57 +00002366#ifndef YYSTACK_USE_ALLOCA
2367 yyfree_stacks = 1;
2368#endif
2369 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
2370 __yy_memcpy ((char *)yyss, (char *)yyss1,
2371 size * (unsigned int) sizeof (*yyssp));
2372 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
2373 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
2374 size * (unsigned int) sizeof (*yyvsp));
2375#ifdef YYLSP_NEEDED
2376 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
2377 __yy_memcpy ((char *)yyls, (char *)yyls1,
2378 size * (unsigned int) sizeof (*yylsp));
2379#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002380#endif /* no yyoverflow */
2381
Dale Johannesen3afee192007-09-07 21:07:57 +00002382 yyssp = yyss + size - 1;
2383 yyvsp = yyvs + size - 1;
2384#ifdef YYLSP_NEEDED
2385 yylsp = yyls + size - 1;
2386#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002387
Dale Johannesen3afee192007-09-07 21:07:57 +00002388#if YYDEBUG != 0
2389 if (yydebug)
2390 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2391#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002392
Dale Johannesen3afee192007-09-07 21:07:57 +00002393 if (yyssp >= yyss + yystacksize - 1)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002394 YYABORT;
2395 }
2396
Dale Johannesen3afee192007-09-07 21:07:57 +00002397#if YYDEBUG != 0
2398 if (yydebug)
2399 fprintf(stderr, "Entering state %d\n", yystate);
2400#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002401
2402 goto yybackup;
Dale Johannesen3afee192007-09-07 21:07:57 +00002403 yybackup:
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002404
Chris Lattnerbb856a32007-08-06 21:00:46 +00002405/* Do appropriate processing given the current state. */
2406/* Read a lookahead token if we need one and don't already have one. */
2407/* yyresume: */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002408
Chris Lattnerbb856a32007-08-06 21:00:46 +00002409 /* First try to decide what to do without reference to lookahead token. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002410
2411 yyn = yypact[yystate];
Dale Johannesen3afee192007-09-07 21:07:57 +00002412 if (yyn == YYFLAG)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002413 goto yydefault;
2414
Chris Lattnerbb856a32007-08-06 21:00:46 +00002415 /* Not known => get a lookahead token if don't already have one. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002416
Dale Johannesen3afee192007-09-07 21:07:57 +00002417 /* yychar is either YYEMPTY or YYEOF
2418 or a valid token in external form. */
2419
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002420 if (yychar == YYEMPTY)
2421 {
Dale Johannesen3afee192007-09-07 21:07:57 +00002422#if YYDEBUG != 0
2423 if (yydebug)
2424 fprintf(stderr, "Reading a token: ");
2425#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002426 yychar = YYLEX;
2427 }
2428
Dale Johannesen3afee192007-09-07 21:07:57 +00002429 /* Convert token to internal form (in yychar1) for indexing tables with */
2430
2431 if (yychar <= 0) /* This means end of input. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002432 {
Dale Johannesen3afee192007-09-07 21:07:57 +00002433 yychar1 = 0;
2434 yychar = YYEOF; /* Don't call YYLEX any more */
2435
2436#if YYDEBUG != 0
2437 if (yydebug)
2438 fprintf(stderr, "Now at end of input.\n");
2439#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002440 }
2441 else
2442 {
Dale Johannesen3afee192007-09-07 21:07:57 +00002443 yychar1 = YYTRANSLATE(yychar);
2444
2445#if YYDEBUG != 0
2446 if (yydebug)
2447 {
2448 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2449 /* Give the individual parser a way to print the precise meaning
2450 of a token, for further debugging info. */
2451#ifdef YYPRINT
2452 YYPRINT (stderr, yychar, yylval);
2453#endif
2454 fprintf (stderr, ")\n");
2455 }
2456#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002457 }
2458
Dale Johannesen3afee192007-09-07 21:07:57 +00002459 yyn += yychar1;
2460 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002461 goto yydefault;
Dale Johannesen3afee192007-09-07 21:07:57 +00002462
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002463 yyn = yytable[yyn];
Dale Johannesen3afee192007-09-07 21:07:57 +00002464
2465 /* yyn is what to do for this token type in this state.
2466 Negative => reduce, -yyn is rule number.
2467 Positive => shift, yyn is new state.
2468 New state is final state => don't bother to shift,
2469 just return success.
2470 0, or most negative number => error. */
2471
2472 if (yyn < 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002473 {
Dale Johannesen3afee192007-09-07 21:07:57 +00002474 if (yyn == YYFLAG)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002475 goto yyerrlab;
2476 yyn = -yyn;
2477 goto yyreduce;
2478 }
Dale Johannesen3afee192007-09-07 21:07:57 +00002479 else if (yyn == 0)
2480 goto yyerrlab;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002481
2482 if (yyn == YYFINAL)
2483 YYACCEPT;
2484
Chris Lattnerbb856a32007-08-06 21:00:46 +00002485 /* Shift the lookahead token. */
Dale Johannesen3afee192007-09-07 21:07:57 +00002486
2487#if YYDEBUG != 0
2488 if (yydebug)
2489 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2490#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002491
Chris Lattnerbb856a32007-08-06 21:00:46 +00002492 /* Discard the token being shifted unless it is eof. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002493 if (yychar != YYEOF)
2494 yychar = YYEMPTY;
2495
Chandler Carruth563d4a42007-08-04 01:56:21 +00002496 *++yyvsp = yylval;
Dale Johannesen3afee192007-09-07 21:07:57 +00002497#ifdef YYLSP_NEEDED
2498 *++yylsp = yylloc;
2499#endif
Chandler Carruth563d4a42007-08-04 01:56:21 +00002500
Dale Johannesen3afee192007-09-07 21:07:57 +00002501 /* count tokens shifted since error; after three, turn off error status. */
2502 if (yyerrstatus) yyerrstatus--;
Chris Lattnerbb856a32007-08-06 21:00:46 +00002503
2504 yystate = yyn;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002505 goto yynewstate;
2506
Dale Johannesen3afee192007-09-07 21:07:57 +00002507/* Do the default action for the current state. */
David Greene48556392007-09-04 18:46:50 +00002508yydefault:
Dale Johannesen3afee192007-09-07 21:07:57 +00002509
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002510 yyn = yydefact[yystate];
2511 if (yyn == 0)
2512 goto yyerrlab;
2513
Dale Johannesen3afee192007-09-07 21:07:57 +00002514/* Do a reduction. yyn is the number of a rule to reduce with. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002515yyreduce:
2516 yylen = yyr2[yyn];
Dale Johannesen3afee192007-09-07 21:07:57 +00002517 if (yylen > 0)
2518 yyval = yyvsp[1-yylen]; /* implement default value of the action */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002519
Dale Johannesen3afee192007-09-07 21:07:57 +00002520#if YYDEBUG != 0
2521 if (yydebug)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002522 {
Dale Johannesen3afee192007-09-07 21:07:57 +00002523 int i;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002524
Dale Johannesen3afee192007-09-07 21:07:57 +00002525 fprintf (stderr, "Reducing via rule %d (line %d), ",
2526 yyn, yyrline[yyn]);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002527
Dale Johannesen3afee192007-09-07 21:07:57 +00002528 /* Print the symbols being reduced, and their result. */
2529 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2530 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2531 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2532 }
2533#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002534
2535
Dale Johannesen3afee192007-09-07 21:07:57 +00002536 switch (yyn) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002537
Dale Johannesen3afee192007-09-07 21:07:57 +00002538case 28:
2539#line 1132 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2540{ yyval.IPredicate = ICmpInst::ICMP_EQ; ;
2541 break;}
2542case 29:
2543#line 1132 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2544{ yyval.IPredicate = ICmpInst::ICMP_NE; ;
2545 break;}
2546case 30:
2547#line 1133 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2548{ yyval.IPredicate = ICmpInst::ICMP_SLT; ;
2549 break;}
2550case 31:
2551#line 1133 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2552{ yyval.IPredicate = ICmpInst::ICMP_SGT; ;
2553 break;}
2554case 32:
2555#line 1134 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2556{ yyval.IPredicate = ICmpInst::ICMP_SLE; ;
2557 break;}
2558case 33:
2559#line 1134 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2560{ yyval.IPredicate = ICmpInst::ICMP_SGE; ;
2561 break;}
2562case 34:
2563#line 1135 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2564{ yyval.IPredicate = ICmpInst::ICMP_ULT; ;
2565 break;}
2566case 35:
2567#line 1135 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2568{ yyval.IPredicate = ICmpInst::ICMP_UGT; ;
2569 break;}
2570case 36:
2571#line 1136 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2572{ yyval.IPredicate = ICmpInst::ICMP_ULE; ;
2573 break;}
2574case 37:
2575#line 1136 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2576{ yyval.IPredicate = ICmpInst::ICMP_UGE; ;
2577 break;}
2578case 38:
2579#line 1140 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2580{ yyval.FPredicate = FCmpInst::FCMP_OEQ; ;
2581 break;}
2582case 39:
2583#line 1140 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2584{ yyval.FPredicate = FCmpInst::FCMP_ONE; ;
2585 break;}
2586case 40:
2587#line 1141 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2588{ yyval.FPredicate = FCmpInst::FCMP_OLT; ;
2589 break;}
2590case 41:
2591#line 1141 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2592{ yyval.FPredicate = FCmpInst::FCMP_OGT; ;
2593 break;}
2594case 42:
2595#line 1142 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2596{ yyval.FPredicate = FCmpInst::FCMP_OLE; ;
2597 break;}
2598case 43:
2599#line 1142 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2600{ yyval.FPredicate = FCmpInst::FCMP_OGE; ;
2601 break;}
2602case 44:
2603#line 1143 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2604{ yyval.FPredicate = FCmpInst::FCMP_ORD; ;
2605 break;}
2606case 45:
2607#line 1143 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2608{ yyval.FPredicate = FCmpInst::FCMP_UNO; ;
2609 break;}
2610case 46:
2611#line 1144 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2612{ yyval.FPredicate = FCmpInst::FCMP_UEQ; ;
2613 break;}
2614case 47:
2615#line 1144 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2616{ yyval.FPredicate = FCmpInst::FCMP_UNE; ;
2617 break;}
2618case 48:
2619#line 1145 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2620{ yyval.FPredicate = FCmpInst::FCMP_ULT; ;
2621 break;}
2622case 49:
2623#line 1145 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2624{ yyval.FPredicate = FCmpInst::FCMP_UGT; ;
2625 break;}
2626case 50:
2627#line 1146 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2628{ yyval.FPredicate = FCmpInst::FCMP_ULE; ;
2629 break;}
2630case 51:
2631#line 1146 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2632{ yyval.FPredicate = FCmpInst::FCMP_UGE; ;
2633 break;}
2634case 52:
2635#line 1147 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2636{ yyval.FPredicate = FCmpInst::FCMP_TRUE; ;
2637 break;}
2638case 53:
2639#line 1148 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2640{ yyval.FPredicate = FCmpInst::FCMP_FALSE; ;
2641 break;}
2642case 64:
2643#line 1157 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2644{ yyval.StrVal = 0; ;
2645 break;}
2646case 65:
2647#line 1161 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2648{
Chris Lattnerbb856a32007-08-06 21:00:46 +00002649 yyval.StrVal = yyvsp[-1].StrVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002650 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00002651 ;
2652 break;}
2653case 66:
2654#line 1165 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2655{
Chris Lattnerbb856a32007-08-06 21:00:46 +00002656 yyval.StrVal = 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002657 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00002658 ;
2659 break;}
2660case 70:
2661#line 1173 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2662{
Chris Lattnerbb856a32007-08-06 21:00:46 +00002663 yyval.StrVal = 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002664 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00002665 ;
2666 break;}
2667case 71:
2668#line 1178 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2669{
Chris Lattnerbb856a32007-08-06 21:00:46 +00002670 yyval.StrVal = yyvsp[-1].StrVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002671 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00002672 ;
2673 break;}
2674case 72:
2675#line 1184 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2676{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2677 break;}
2678case 73:
2679#line 1185 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2680{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2681 break;}
2682case 74:
2683#line 1186 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2684{ yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2685 break;}
2686case 75:
2687#line 1187 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2688{ yyval.Linkage = GlobalValue::AppendingLinkage; ;
2689 break;}
2690case 76:
2691#line 1188 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2692{ yyval.Linkage = GlobalValue::DLLExportLinkage; ;
2693 break;}
2694case 77:
2695#line 1192 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2696{ yyval.Linkage = GlobalValue::DLLImportLinkage; ;
2697 break;}
2698case 78:
2699#line 1193 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2700{ yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;
2701 break;}
2702case 79:
2703#line 1194 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2704{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2705 break;}
2706case 80:
2707#line 1198 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2708{ yyval.Visibility = GlobalValue::DefaultVisibility; ;
2709 break;}
2710case 81:
2711#line 1199 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2712{ yyval.Visibility = GlobalValue::DefaultVisibility; ;
2713 break;}
2714case 82:
2715#line 1200 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2716{ yyval.Visibility = GlobalValue::HiddenVisibility; ;
2717 break;}
2718case 83:
2719#line 1201 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2720{ yyval.Visibility = GlobalValue::ProtectedVisibility; ;
2721 break;}
2722case 84:
2723#line 1205 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2724{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2725 break;}
2726case 85:
2727#line 1206 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2728{ yyval.Linkage = GlobalValue::DLLImportLinkage; ;
2729 break;}
2730case 86:
2731#line 1207 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2732{ yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;
2733 break;}
2734case 87:
2735#line 1211 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2736{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2737 break;}
2738case 88:
2739#line 1212 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2740{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2741 break;}
2742case 89:
2743#line 1213 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2744{ yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2745 break;}
2746case 90:
2747#line 1214 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2748{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2749 break;}
2750case 91:
2751#line 1215 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2752{ yyval.Linkage = GlobalValue::DLLExportLinkage; ;
2753 break;}
2754case 92:
2755#line 1219 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2756{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2757 break;}
2758case 93:
2759#line 1220 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2760{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2761 break;}
2762case 94:
2763#line 1221 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2764{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2765 break;}
2766case 95:
2767#line 1224 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2768{ yyval.UIntVal = CallingConv::C; ;
2769 break;}
2770case 96:
2771#line 1225 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2772{ yyval.UIntVal = CallingConv::C; ;
2773 break;}
2774case 97:
2775#line 1226 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2776{ yyval.UIntVal = CallingConv::Fast; ;
2777 break;}
2778case 98:
2779#line 1227 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2780{ yyval.UIntVal = CallingConv::Cold; ;
2781 break;}
2782case 99:
2783#line 1228 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2784{ yyval.UIntVal = CallingConv::X86_StdCall; ;
2785 break;}
2786case 100:
2787#line 1229 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2788{ yyval.UIntVal = CallingConv::X86_FastCall; ;
2789 break;}
2790case 101:
2791#line 1230 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2792{
Chris Lattnerbb856a32007-08-06 21:00:46 +00002793 if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002794 GEN_ERROR("Calling conv too large");
Chris Lattnerbb856a32007-08-06 21:00:46 +00002795 yyval.UIntVal = yyvsp[0].UInt64Val;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002796 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00002797 ;
2798 break;}
2799case 102:
2800#line 1237 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2801{ yyval.ParamAttrs = ParamAttr::ZExt; ;
2802 break;}
2803case 103:
2804#line 1238 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2805{ yyval.ParamAttrs = ParamAttr::ZExt; ;
2806 break;}
2807case 104:
2808#line 1239 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2809{ yyval.ParamAttrs = ParamAttr::SExt; ;
2810 break;}
2811case 105:
2812#line 1240 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2813{ yyval.ParamAttrs = ParamAttr::SExt; ;
2814 break;}
2815case 106:
2816#line 1241 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2817{ yyval.ParamAttrs = ParamAttr::InReg; ;
2818 break;}
2819case 107:
2820#line 1242 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2821{ yyval.ParamAttrs = ParamAttr::StructRet; ;
2822 break;}
2823case 108:
2824#line 1243 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2825{ yyval.ParamAttrs = ParamAttr::NoAlias; ;
2826 break;}
2827case 109:
2828#line 1244 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2829{ yyval.ParamAttrs = ParamAttr::ByVal; ;
2830 break;}
2831case 110:
2832#line 1245 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2833{ yyval.ParamAttrs = ParamAttr::Nest; ;
2834 break;}
2835case 111:
2836#line 1248 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2837{ yyval.ParamAttrs = ParamAttr::None; ;
2838 break;}
2839case 112:
2840#line 1249 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2841{
Chris Lattnerbb856a32007-08-06 21:00:46 +00002842 yyval.ParamAttrs = yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs;
Dale Johannesen3afee192007-09-07 21:07:57 +00002843 ;
2844 break;}
2845case 113:
2846#line 1254 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2847{ yyval.ParamAttrs = ParamAttr::NoReturn; ;
2848 break;}
2849case 114:
2850#line 1255 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2851{ yyval.ParamAttrs = ParamAttr::NoUnwind; ;
2852 break;}
2853case 115:
2854#line 1256 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2855{ yyval.ParamAttrs = ParamAttr::ZExt; ;
2856 break;}
2857case 116:
2858#line 1257 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2859{ yyval.ParamAttrs = ParamAttr::SExt; ;
2860 break;}
2861case 117:
2862#line 1260 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2863{ yyval.ParamAttrs = ParamAttr::None; ;
2864 break;}
2865case 118:
2866#line 1261 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2867{
Chris Lattnerbb856a32007-08-06 21:00:46 +00002868 yyval.ParamAttrs = yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs;
Dale Johannesen3afee192007-09-07 21:07:57 +00002869 ;
2870 break;}
2871case 119:
2872#line 1268 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2873{ yyval.UIntVal = 0; ;
2874 break;}
2875case 120:
2876#line 1269 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2877{
Chris Lattnerbb856a32007-08-06 21:00:46 +00002878 yyval.UIntVal = yyvsp[0].UInt64Val;
2879 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002880 GEN_ERROR("Alignment must be a power of two");
2881 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00002882;
2883 break;}
2884case 121:
2885#line 1275 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2886{ yyval.UIntVal = 0; ;
2887 break;}
2888case 122:
2889#line 1276 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2890{
Chris Lattnerbb856a32007-08-06 21:00:46 +00002891 yyval.UIntVal = yyvsp[0].UInt64Val;
2892 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002893 GEN_ERROR("Alignment must be a power of two");
2894 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00002895;
2896 break;}
2897case 123:
2898#line 1284 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2899{
Chris Lattnerbb856a32007-08-06 21:00:46 +00002900 for (unsigned i = 0, e = yyvsp[0].StrVal->length(); i != e; ++i)
2901 if ((*yyvsp[0].StrVal)[i] == '"' || (*yyvsp[0].StrVal)[i] == '\\')
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002902 GEN_ERROR("Invalid character in section name");
Chris Lattnerbb856a32007-08-06 21:00:46 +00002903 yyval.StrVal = yyvsp[0].StrVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002904 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00002905;
2906 break;}
2907case 124:
2908#line 1292 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2909{ yyval.StrVal = 0; ;
2910 break;}
2911case 125:
2912#line 1293 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2913{ yyval.StrVal = yyvsp[0].StrVal; ;
2914 break;}
2915case 126:
2916#line 1298 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2917{;
2918 break;}
2919case 127:
2920#line 1299 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2921{;
2922 break;}
2923case 128:
2924#line 1300 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2925{
Chris Lattnerbb856a32007-08-06 21:00:46 +00002926 CurGV->setSection(*yyvsp[0].StrVal);
2927 delete yyvsp[0].StrVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002928 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00002929 ;
2930 break;}
2931case 129:
2932#line 1305 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2933{
Chris Lattnerbb856a32007-08-06 21:00:46 +00002934 if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002935 GEN_ERROR("Alignment must be a power of two");
Chris Lattnerbb856a32007-08-06 21:00:46 +00002936 CurGV->setAlignment(yyvsp[0].UInt64Val);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002937 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00002938 ;
2939 break;}
2940case 137:
2941#line 1321 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2942{
Chris Lattnerbb856a32007-08-06 21:00:46 +00002943 yyval.TypeVal = new PATypeHolder(OpaqueType::get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002944 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00002945 ;
2946 break;}
2947case 138:
2948#line 1325 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2949{
Chris Lattnerbb856a32007-08-06 21:00:46 +00002950 yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002951 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00002952 ;
2953 break;}
2954case 139:
2955#line 1329 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2956{ // Pointer type?
Chris Lattnerbb856a32007-08-06 21:00:46 +00002957 if (*yyvsp[-1].TypeVal == Type::LabelTy)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002958 GEN_ERROR("Cannot form a pointer to a basic block");
Chris Lattnerbb856a32007-08-06 21:00:46 +00002959 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal)));
2960 delete yyvsp[-1].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002961 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00002962 ;
2963 break;}
2964case 140:
2965#line 1336 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2966{ // Named types are also simple types...
Chris Lattnerbb856a32007-08-06 21:00:46 +00002967 const Type* tmp = getTypeVal(yyvsp[0].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002968 CHECK_FOR_ERROR
Chris Lattnerbb856a32007-08-06 21:00:46 +00002969 yyval.TypeVal = new PATypeHolder(tmp);
Dale Johannesen3afee192007-09-07 21:07:57 +00002970 ;
2971 break;}
2972case 141:
2973#line 1341 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2974{ // Type UpReference
Chris Lattnerbb856a32007-08-06 21:00:46 +00002975 if (yyvsp[0].UInt64Val > (uint64_t)~0U) GEN_ERROR("Value out of range");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002976 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Chris Lattnerbb856a32007-08-06 21:00:46 +00002977 UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector...
2978 yyval.TypeVal = new PATypeHolder(OT);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002979 UR_OUT("New Upreference!\n");
2980 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00002981 ;
2982 break;}
2983case 142:
2984#line 1349 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2985{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002986 std::vector<const Type*> Params;
2987 ParamAttrsVector Attrs;
Chris Lattnerbb856a32007-08-06 21:00:46 +00002988 if (yyvsp[0].ParamAttrs != ParamAttr::None) {
2989 ParamAttrsWithIndex X; X.index = 0; X.attrs = yyvsp[0].ParamAttrs;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002990 Attrs.push_back(X);
2991 }
2992 unsigned index = 1;
Chris Lattnerbb856a32007-08-06 21:00:46 +00002993 TypeWithAttrsList::iterator I = yyvsp[-2].TypeWithAttrsList->begin(), E = yyvsp[-2].TypeWithAttrsList->end();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002994 for (; I != E; ++I, ++index) {
2995 const Type *Ty = I->Ty->get();
2996 Params.push_back(Ty);
2997 if (Ty != Type::VoidTy)
2998 if (I->Attrs != ParamAttr::None) {
2999 ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs;
3000 Attrs.push_back(X);
3001 }
3002 }
3003 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3004 if (isVarArg) Params.pop_back();
3005
3006 ParamAttrsList *ActualAttrs = 0;
3007 if (!Attrs.empty())
3008 ActualAttrs = ParamAttrsList::get(Attrs);
Chris Lattnerbb856a32007-08-06 21:00:46 +00003009 FunctionType *FT = FunctionType::get(*yyvsp[-4].TypeVal, Params, isVarArg, ActualAttrs);
3010 delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list
3011 delete yyvsp[-4].TypeVal; // Delete the return type handle
3012 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003013 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003014 ;
3015 break;}
3016case 143:
3017#line 1379 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3018{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003019 std::vector<const Type*> Params;
3020 ParamAttrsVector Attrs;
Chris Lattnerbb856a32007-08-06 21:00:46 +00003021 if (yyvsp[0].ParamAttrs != ParamAttr::None) {
3022 ParamAttrsWithIndex X; X.index = 0; X.attrs = yyvsp[0].ParamAttrs;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003023 Attrs.push_back(X);
3024 }
Chris Lattnerbb856a32007-08-06 21:00:46 +00003025 TypeWithAttrsList::iterator I = yyvsp[-2].TypeWithAttrsList->begin(), E = yyvsp[-2].TypeWithAttrsList->end();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003026 unsigned index = 1;
3027 for ( ; I != E; ++I, ++index) {
3028 const Type* Ty = I->Ty->get();
3029 Params.push_back(Ty);
3030 if (Ty != Type::VoidTy)
3031 if (I->Attrs != ParamAttr::None) {
3032 ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs;
3033 Attrs.push_back(X);
3034 }
3035 }
3036 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3037 if (isVarArg) Params.pop_back();
3038
3039 ParamAttrsList *ActualAttrs = 0;
3040 if (!Attrs.empty())
3041 ActualAttrs = ParamAttrsList::get(Attrs);
3042
Chris Lattnerbb856a32007-08-06 21:00:46 +00003043 FunctionType *FT = FunctionType::get(yyvsp[-4].PrimType, Params, isVarArg, ActualAttrs);
3044 delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list
3045 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003046 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003047 ;
3048 break;}
3049case 144:
3050#line 1410 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3051{ // Sized array type?
Chris Lattnerbb856a32007-08-06 21:00:46 +00003052 yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
3053 delete yyvsp[-1].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003054 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003055 ;
3056 break;}
3057case 145:
3058#line 1415 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3059{ // Vector type?
Chris Lattnerbb856a32007-08-06 21:00:46 +00003060 const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
3061 if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003062 GEN_ERROR("Unsigned result not equal to signed result");
3063 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
3064 GEN_ERROR("Element type of a VectorType must be primitive");
Chris Lattnerbb856a32007-08-06 21:00:46 +00003065 if (!isPowerOf2_32(yyvsp[-3].UInt64Val))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003066 GEN_ERROR("Vector length should be a power of 2");
Chris Lattnerbb856a32007-08-06 21:00:46 +00003067 yyval.TypeVal = new PATypeHolder(HandleUpRefs(VectorType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
3068 delete yyvsp[-1].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003069 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003070 ;
3071 break;}
3072case 146:
3073#line 1427 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3074{ // Structure type?
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003075 std::vector<const Type*> Elements;
Chris Lattnerbb856a32007-08-06 21:00:46 +00003076 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
3077 E = yyvsp[-1].TypeList->end(); I != E; ++I)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003078 Elements.push_back(*I);
3079
Chris Lattnerbb856a32007-08-06 21:00:46 +00003080 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
3081 delete yyvsp[-1].TypeList;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003082 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003083 ;
3084 break;}
3085case 147:
3086#line 1437 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3087{ // Empty structure type?
Chris Lattnerbb856a32007-08-06 21:00:46 +00003088 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003089 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003090 ;
3091 break;}
3092case 148:
3093#line 1441 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3094{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003095 std::vector<const Type*> Elements;
Chris Lattnerbb856a32007-08-06 21:00:46 +00003096 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-2].TypeList->begin(),
3097 E = yyvsp[-2].TypeList->end(); I != E; ++I)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003098 Elements.push_back(*I);
3099
Chris Lattnerbb856a32007-08-06 21:00:46 +00003100 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
3101 delete yyvsp[-2].TypeList;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003102 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003103 ;
3104 break;}
3105case 149:
3106#line 1451 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3107{ // Empty structure type?
Chris Lattnerbb856a32007-08-06 21:00:46 +00003108 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003109 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003110 ;
3111 break;}
3112case 150:
3113#line 1458 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3114{
Chris Lattnerbb856a32007-08-06 21:00:46 +00003115 yyval.TypeWithAttrs.Ty = yyvsp[-1].TypeVal;
3116 yyval.TypeWithAttrs.Attrs = yyvsp[0].ParamAttrs;
Dale Johannesen3afee192007-09-07 21:07:57 +00003117 ;
3118 break;}
3119case 151:
3120#line 1465 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3121{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003122 if (!UpRefs.empty())
Chris Lattnerbb856a32007-08-06 21:00:46 +00003123 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
3124 if (!(*yyvsp[0].TypeVal)->isFirstClassType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003125 GEN_ERROR("LLVM functions cannot return aggregate types");
Chris Lattnerbb856a32007-08-06 21:00:46 +00003126 yyval.TypeVal = yyvsp[0].TypeVal;
Dale Johannesen3afee192007-09-07 21:07:57 +00003127 ;
3128 break;}
3129case 152:
3130#line 1472 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3131{
Chris Lattnerbb856a32007-08-06 21:00:46 +00003132 yyval.TypeVal = new PATypeHolder(Type::VoidTy);
Dale Johannesen3afee192007-09-07 21:07:57 +00003133 ;
3134 break;}
3135case 153:
3136#line 1477 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3137{
Chris Lattnerbb856a32007-08-06 21:00:46 +00003138 yyval.TypeWithAttrsList = new TypeWithAttrsList();
3139 yyval.TypeWithAttrsList->push_back(yyvsp[0].TypeWithAttrs);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003140 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003141 ;
3142 break;}
3143case 154:
3144#line 1482 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3145{
Chris Lattnerbb856a32007-08-06 21:00:46 +00003146 (yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList)->push_back(yyvsp[0].TypeWithAttrs);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003147 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003148 ;
3149 break;}
3150case 156:
3151#line 1490 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3152{
Chris Lattnerbb856a32007-08-06 21:00:46 +00003153 yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003154 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
3155 TWA.Ty = new PATypeHolder(Type::VoidTy);
Chris Lattnerbb856a32007-08-06 21:00:46 +00003156 yyval.TypeWithAttrsList->push_back(TWA);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003157 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003158 ;
3159 break;}
3160case 157:
3161#line 1497 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3162{
Chris Lattnerbb856a32007-08-06 21:00:46 +00003163 yyval.TypeWithAttrsList = new TypeWithAttrsList;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003164 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
3165 TWA.Ty = new PATypeHolder(Type::VoidTy);
Chris Lattnerbb856a32007-08-06 21:00:46 +00003166 yyval.TypeWithAttrsList->push_back(TWA);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003167 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003168 ;
3169 break;}
3170case 158:
3171#line 1504 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3172{
Chris Lattnerbb856a32007-08-06 21:00:46 +00003173 yyval.TypeWithAttrsList = new TypeWithAttrsList();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003174 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003175 ;
3176 break;}
3177case 159:
3178#line 1512 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3179{
Chris Lattnerbb856a32007-08-06 21:00:46 +00003180 yyval.TypeList = new std::list<PATypeHolder>();
3181 yyval.TypeList->push_back(*yyvsp[0].TypeVal);
3182 delete yyvsp[0].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003183 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003184 ;
3185 break;}
3186case 160:
3187#line 1518 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3188{
Chris Lattnerbb856a32007-08-06 21:00:46 +00003189 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal);
3190 delete yyvsp[0].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003191 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003192 ;
3193 break;}
3194case 161:
3195#line 1530 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3196{ // Nonempty unsized arr
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003197 if (!UpRefs.empty())
Chris Lattnerbb856a32007-08-06 21:00:46 +00003198 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
3199 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003200 if (ATy == 0)
3201 GEN_ERROR("Cannot make array constant with type: '" +
Chris Lattnerbb856a32007-08-06 21:00:46 +00003202 (*yyvsp[-3].TypeVal)->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003203 const Type *ETy = ATy->getElementType();
3204 int NumElements = ATy->getNumElements();
3205
3206 // Verify that we have the correct size...
Chris Lattnerbb856a32007-08-06 21:00:46 +00003207 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003208 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Chris Lattnerbb856a32007-08-06 21:00:46 +00003209 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003210 itostr(NumElements) + "");
3211
3212 // Verify all elements are correct type!
Chris Lattnerbb856a32007-08-06 21:00:46 +00003213 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3214 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003215 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3216 ETy->getDescription() +"' as required!\nIt is of type '"+
Chris Lattnerbb856a32007-08-06 21:00:46 +00003217 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003218 }
3219
Chris Lattnerbb856a32007-08-06 21:00:46 +00003220 yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
3221 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003222 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003223 ;
3224 break;}
3225case 162:
3226#line 1558 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3227{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003228 if (!UpRefs.empty())
Chris Lattnerbb856a32007-08-06 21:00:46 +00003229 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3230 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003231 if (ATy == 0)
3232 GEN_ERROR("Cannot make array constant with type: '" +
Chris Lattnerbb856a32007-08-06 21:00:46 +00003233 (*yyvsp[-2].TypeVal)->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003234
3235 int NumElements = ATy->getNumElements();
3236 if (NumElements != -1 && NumElements != 0)
3237 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
3238 " arguments, but has size of " + itostr(NumElements) +"");
Chris Lattnerbb856a32007-08-06 21:00:46 +00003239 yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
3240 delete yyvsp[-2].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003241 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003242 ;
3243 break;}
3244case 163:
3245#line 1574 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3246{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003247 if (!UpRefs.empty())
Chris Lattnerbb856a32007-08-06 21:00:46 +00003248 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3249 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003250 if (ATy == 0)
3251 GEN_ERROR("Cannot make array constant with type: '" +
Chris Lattnerbb856a32007-08-06 21:00:46 +00003252 (*yyvsp[-2].TypeVal)->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003253
3254 int NumElements = ATy->getNumElements();
3255 const Type *ETy = ATy->getElementType();
Chris Lattnerbb856a32007-08-06 21:00:46 +00003256 if (NumElements != -1 && NumElements != int(yyvsp[0].StrVal->length()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003257 GEN_ERROR("Can't build string constant of size " +
Chris Lattnerbb856a32007-08-06 21:00:46 +00003258 itostr((int)(yyvsp[0].StrVal->length())) +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003259 " when array has size " + itostr(NumElements) + "");
3260 std::vector<Constant*> Vals;
3261 if (ETy == Type::Int8Ty) {
Chris Lattnerbb856a32007-08-06 21:00:46 +00003262 for (unsigned i = 0; i < yyvsp[0].StrVal->length(); ++i)
3263 Vals.push_back(ConstantInt::get(ETy, (*yyvsp[0].StrVal)[i]));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003264 } else {
Chris Lattnerbb856a32007-08-06 21:00:46 +00003265 delete yyvsp[0].StrVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003266 GEN_ERROR("Cannot build string arrays of non byte sized elements");
3267 }
Chris Lattnerbb856a32007-08-06 21:00:46 +00003268 delete yyvsp[0].StrVal;
3269 yyval.ConstVal = ConstantArray::get(ATy, Vals);
3270 delete yyvsp[-2].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003271 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003272 ;
3273 break;}
3274case 164:
3275#line 1601 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3276{ // Nonempty unsized arr
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003277 if (!UpRefs.empty())
Chris Lattnerbb856a32007-08-06 21:00:46 +00003278 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
3279 const VectorType *PTy = dyn_cast<VectorType>(yyvsp[-3].TypeVal->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003280 if (PTy == 0)
3281 GEN_ERROR("Cannot make packed constant with type: '" +
Chris Lattnerbb856a32007-08-06 21:00:46 +00003282 (*yyvsp[-3].TypeVal)->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003283 const Type *ETy = PTy->getElementType();
3284 int NumElements = PTy->getNumElements();
3285
3286 // Verify that we have the correct size...
Chris Lattnerbb856a32007-08-06 21:00:46 +00003287 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003288 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Chris Lattnerbb856a32007-08-06 21:00:46 +00003289 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003290 itostr(NumElements) + "");
3291
3292 // Verify all elements are correct type!
Chris Lattnerbb856a32007-08-06 21:00:46 +00003293 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3294 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003295 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3296 ETy->getDescription() +"' as required!\nIt is of type '"+
Chris Lattnerbb856a32007-08-06 21:00:46 +00003297 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003298 }
3299
Chris Lattnerbb856a32007-08-06 21:00:46 +00003300 yyval.ConstVal = ConstantVector::get(PTy, *yyvsp[-1].ConstVector);
3301 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003302 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003303 ;
3304 break;}
3305case 165:
3306#line 1629 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3307{
Chris Lattnerbb856a32007-08-06 21:00:46 +00003308 const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003309 if (STy == 0)
3310 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattnerbb856a32007-08-06 21:00:46 +00003311 (*yyvsp[-3].TypeVal)->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003312
Chris Lattnerbb856a32007-08-06 21:00:46 +00003313 if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003314 GEN_ERROR("Illegal number of initializers for structure type");
3315
3316 // Check to ensure that constants are compatible with the type initializer!
Chris Lattnerbb856a32007-08-06 21:00:46 +00003317 for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
3318 if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003319 GEN_ERROR("Expected type '" +
3320 STy->getElementType(i)->getDescription() +
3321 "' for element #" + utostr(i) +
3322 " of structure initializer");
3323
3324 // Check to ensure that Type is not packed
3325 if (STy->isPacked())
3326 GEN_ERROR("Unpacked Initializer to vector type '" +
3327 STy->getDescription() + "'");
3328
Chris Lattnerbb856a32007-08-06 21:00:46 +00003329 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
3330 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003331 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003332 ;
3333 break;}
3334case 166:
3335#line 1655 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3336{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003337 if (!UpRefs.empty())
Chris Lattnerbb856a32007-08-06 21:00:46 +00003338 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3339 const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003340 if (STy == 0)
3341 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattnerbb856a32007-08-06 21:00:46 +00003342 (*yyvsp[-2].TypeVal)->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003343
3344 if (STy->getNumContainedTypes() != 0)
3345 GEN_ERROR("Illegal number of initializers for structure type");
3346
3347 // Check to ensure that Type is not packed
3348 if (STy->isPacked())
3349 GEN_ERROR("Unpacked Initializer to vector type '" +
3350 STy->getDescription() + "'");
3351
Chris Lattnerbb856a32007-08-06 21:00:46 +00003352 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
3353 delete yyvsp[-2].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003354 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003355 ;
3356 break;}
3357case 167:
3358#line 1675 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3359{
Chris Lattnerbb856a32007-08-06 21:00:46 +00003360 const StructType *STy = dyn_cast<StructType>(yyvsp[-5].TypeVal->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003361 if (STy == 0)
3362 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattnerbb856a32007-08-06 21:00:46 +00003363 (*yyvsp[-5].TypeVal)->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003364
Chris Lattnerbb856a32007-08-06 21:00:46 +00003365 if (yyvsp[-2].ConstVector->size() != STy->getNumContainedTypes())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003366 GEN_ERROR("Illegal number of initializers for structure type");
3367
3368 // Check to ensure that constants are compatible with the type initializer!
Chris Lattnerbb856a32007-08-06 21:00:46 +00003369 for (unsigned i = 0, e = yyvsp[-2].ConstVector->size(); i != e; ++i)
3370 if ((*yyvsp[-2].ConstVector)[i]->getType() != STy->getElementType(i))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003371 GEN_ERROR("Expected type '" +
3372 STy->getElementType(i)->getDescription() +
3373 "' for element #" + utostr(i) +
3374 " of structure initializer");
3375
3376 // Check to ensure that Type is packed
3377 if (!STy->isPacked())
3378 GEN_ERROR("Vector initializer to non-vector type '" +
3379 STy->getDescription() + "'");
3380
Chris Lattnerbb856a32007-08-06 21:00:46 +00003381 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-2].ConstVector);
3382 delete yyvsp[-5].TypeVal; delete yyvsp[-2].ConstVector;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003383 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003384 ;
3385 break;}
3386case 168:
3387#line 1701 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3388{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003389 if (!UpRefs.empty())
Chris Lattnerbb856a32007-08-06 21:00:46 +00003390 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
3391 const StructType *STy = dyn_cast<StructType>(yyvsp[-4].TypeVal->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003392 if (STy == 0)
3393 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattnerbb856a32007-08-06 21:00:46 +00003394 (*yyvsp[-4].TypeVal)->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003395
3396 if (STy->getNumContainedTypes() != 0)
3397 GEN_ERROR("Illegal number of initializers for structure type");
3398
3399 // Check to ensure that Type is packed
3400 if (!STy->isPacked())
3401 GEN_ERROR("Vector initializer to non-vector type '" +
3402 STy->getDescription() + "'");
3403
Chris Lattnerbb856a32007-08-06 21:00:46 +00003404 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
3405 delete yyvsp[-4].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003406 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003407 ;
3408 break;}
3409case 169:
3410#line 1721 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3411{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003412 if (!UpRefs.empty())
Chris Lattnerbb856a32007-08-06 21:00:46 +00003413 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3414 const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003415 if (PTy == 0)
3416 GEN_ERROR("Cannot make null pointer constant with type: '" +
Chris Lattnerbb856a32007-08-06 21:00:46 +00003417 (*yyvsp[-1].TypeVal)->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003418
Chris Lattnerbb856a32007-08-06 21:00:46 +00003419 yyval.ConstVal = ConstantPointerNull::get(PTy);
3420 delete yyvsp[-1].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003421 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003422 ;
3423 break;}
3424case 170:
3425#line 1733 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3426{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003427 if (!UpRefs.empty())
Chris Lattnerbb856a32007-08-06 21:00:46 +00003428 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3429 yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
3430 delete yyvsp[-1].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003431 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003432 ;
3433 break;}
3434case 171:
3435#line 1740 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3436{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003437 if (!UpRefs.empty())
Chris Lattnerbb856a32007-08-06 21:00:46 +00003438 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3439 const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003440 if (Ty == 0)
3441 GEN_ERROR("Global const reference must be a pointer type");
3442
3443 // ConstExprs can exist in the body of a function, thus creating
3444 // GlobalValues whenever they refer to a variable. Because we are in
3445 // the context of a function, getExistingVal will search the functions
3446 // symbol table instead of the module symbol table for the global symbol,
3447 // which throws things all off. To get around this, we just tell
3448 // getExistingVal that we are at global scope here.
3449 //
3450 Function *SavedCurFn = CurFun.CurrentFunction;
3451 CurFun.CurrentFunction = 0;
3452
Chris Lattnerbb856a32007-08-06 21:00:46 +00003453 Value *V = getExistingVal(Ty, yyvsp[0].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003454 CHECK_FOR_ERROR
3455
3456 CurFun.CurrentFunction = SavedCurFn;
3457
3458 // If this is an initializer for a constant pointer, which is referencing a
3459 // (currently) undefined variable, create a stub now that shall be replaced
3460 // in the future with the right type of variable.
3461 //
3462 if (V == 0) {
3463 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
3464 const PointerType *PT = cast<PointerType>(Ty);
3465
3466 // First check to see if the forward references value is already created!
3467 PerModuleInfo::GlobalRefsType::iterator I =
Chris Lattnerbb856a32007-08-06 21:00:46 +00003468 CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003469
3470 if (I != CurModule.GlobalRefs.end()) {
3471 V = I->second; // Placeholder already exists, use it...
Chris Lattnerbb856a32007-08-06 21:00:46 +00003472 yyvsp[0].ValIDVal.destroy();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003473 } else {
3474 std::string Name;
Chris Lattnerbb856a32007-08-06 21:00:46 +00003475 if (yyvsp[0].ValIDVal.Type == ValID::GlobalName)
3476 Name = yyvsp[0].ValIDVal.getName();
3477 else if (yyvsp[0].ValIDVal.Type != ValID::GlobalID)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003478 GEN_ERROR("Invalid reference to global");
3479
3480 // Create the forward referenced global.
3481 GlobalValue *GV;
3482 if (const FunctionType *FTy =
3483 dyn_cast<FunctionType>(PT->getElementType())) {
3484 GV = new Function(FTy, GlobalValue::ExternalWeakLinkage, Name,
3485 CurModule.CurrentModule);
3486 } else {
3487 GV = new GlobalVariable(PT->getElementType(), false,
3488 GlobalValue::ExternalWeakLinkage, 0,
3489 Name, CurModule.CurrentModule);
3490 }
3491
3492 // Keep track of the fact that we have a forward ref to recycle it
Chris Lattnerbb856a32007-08-06 21:00:46 +00003493 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003494 V = GV;
3495 }
3496 }
3497
Chris Lattnerbb856a32007-08-06 21:00:46 +00003498 yyval.ConstVal = cast<GlobalValue>(V);
3499 delete yyvsp[-1].TypeVal; // Free the type handle
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003500 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003501 ;
3502 break;}
3503case 172:
3504#line 1806 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3505{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003506 if (!UpRefs.empty())
Chris Lattnerbb856a32007-08-06 21:00:46 +00003507 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3508 if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003509 GEN_ERROR("Mismatched types for constant expression: " +
Chris Lattnerbb856a32007-08-06 21:00:46 +00003510 (*yyvsp[-1].TypeVal)->getDescription() + " and " + yyvsp[0].ConstVal->getType()->getDescription());
3511 yyval.ConstVal = yyvsp[0].ConstVal;
3512 delete yyvsp[-1].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003513 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003514 ;
3515 break;}
3516case 173:
3517#line 1816 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3518{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003519 if (!UpRefs.empty())
Chris Lattnerbb856a32007-08-06 21:00:46 +00003520 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3521 const Type *Ty = yyvsp[-1].TypeVal->get();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003522 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
3523 GEN_ERROR("Cannot create a null initialized value of this type");
Chris Lattnerbb856a32007-08-06 21:00:46 +00003524 yyval.ConstVal = Constant::getNullValue(Ty);
3525 delete yyvsp[-1].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003526 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003527 ;
3528 break;}
3529case 174:
3530#line 1826 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3531{ // integral constants
Chris Lattnerbb856a32007-08-06 21:00:46 +00003532 if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003533 GEN_ERROR("Constant value doesn't fit in type");
Chris Lattnerbb856a32007-08-06 21:00:46 +00003534 yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val, true);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003535 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003536 ;
3537 break;}
3538case 175:
3539#line 1832 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3540{ // arbitrary precision integer constants
Chris Lattnerbb856a32007-08-06 21:00:46 +00003541 uint32_t BitWidth = cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth();
3542 if (yyvsp[0].APIntVal->getBitWidth() > BitWidth) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003543 GEN_ERROR("Constant value does not fit in type");
3544 }
Chris Lattnerbb856a32007-08-06 21:00:46 +00003545 yyvsp[0].APIntVal->sextOrTrunc(BitWidth);
3546 yyval.ConstVal = ConstantInt::get(*yyvsp[0].APIntVal);
3547 delete yyvsp[0].APIntVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003548 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003549 ;
3550 break;}
3551case 176:
3552#line 1842 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3553{ // integral constants
Chris Lattnerbb856a32007-08-06 21:00:46 +00003554 if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003555 GEN_ERROR("Constant value doesn't fit in type");
Chris Lattnerbb856a32007-08-06 21:00:46 +00003556 yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val, false);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003557 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003558 ;
3559 break;}
3560case 177:
3561#line 1848 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3562{ // arbitrary precision integer constants
Chris Lattnerbb856a32007-08-06 21:00:46 +00003563 uint32_t BitWidth = cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth();
3564 if (yyvsp[0].APIntVal->getBitWidth() > BitWidth) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003565 GEN_ERROR("Constant value does not fit in type");
3566 }
Chris Lattnerbb856a32007-08-06 21:00:46 +00003567 yyvsp[0].APIntVal->zextOrTrunc(BitWidth);
3568 yyval.ConstVal = ConstantInt::get(*yyvsp[0].APIntVal);
3569 delete yyvsp[0].APIntVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003570 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003571 ;
3572 break;}
3573case 178:
3574#line 1858 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3575{ // Boolean constants
Chris Lattnerbb856a32007-08-06 21:00:46 +00003576 assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?");
3577 yyval.ConstVal = ConstantInt::getTrue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003578 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003579 ;
3580 break;}
3581case 179:
3582#line 1863 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3583{ // Boolean constants
Chris Lattnerbb856a32007-08-06 21:00:46 +00003584 assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?");
3585 yyval.ConstVal = ConstantInt::getFalse();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003586 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003587 ;
3588 break;}
3589case 180:
3590#line 1868 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3591{ // Float & Double constants
3592 if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, *yyvsp[0].FPVal))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003593 GEN_ERROR("Floating point constant invalid for type");
Dale Johannesen3afee192007-09-07 21:07:57 +00003594 // Lexer has no type info, so builds all FP constants as double.
3595 // Fix this here.
3596 if (yyvsp[-1].PrimType==Type::FloatTy)
3597 yyvsp[0].FPVal->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
3598 yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, *yyvsp[0].FPVal);
3599 delete yyvsp[0].FPVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003600 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003601 ;
3602 break;}
3603case 181:
3604#line 1881 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3605{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003606 if (!UpRefs.empty())
Chris Lattnerbb856a32007-08-06 21:00:46 +00003607 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3608 Constant *Val = yyvsp[-3].ConstVal;
3609 const Type *DestTy = yyvsp[-1].TypeVal->get();
3610 if (!CastInst::castIsValid(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003611 GEN_ERROR("invalid cast opcode for cast from '" +
3612 Val->getType()->getDescription() + "' to '" +
3613 DestTy->getDescription() + "'");
Chris Lattnerbb856a32007-08-06 21:00:46 +00003614 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy);
3615 delete yyvsp[-1].TypeVal;
Dale Johannesen3afee192007-09-07 21:07:57 +00003616 ;
3617 break;}
3618case 182:
3619#line 1893 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3620{
Chris Lattnerbb856a32007-08-06 21:00:46 +00003621 if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003622 GEN_ERROR("GetElementPtr requires a pointer operand");
3623
3624 const Type *IdxTy =
David Greene48556392007-09-04 18:46:50 +00003625 GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end(),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003626 true);
3627 if (!IdxTy)
3628 GEN_ERROR("Index list invalid for constant getelementptr");
3629
3630 SmallVector<Constant*, 8> IdxVec;
Chris Lattnerbb856a32007-08-06 21:00:46 +00003631 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
3632 if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003633 IdxVec.push_back(C);
3634 else
3635 GEN_ERROR("Indices to constant getelementptr must be constants");
3636
Chris Lattnerbb856a32007-08-06 21:00:46 +00003637 delete yyvsp[-1].ValueList;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003638
Chris Lattnerbb856a32007-08-06 21:00:46 +00003639 yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, &IdxVec[0], IdxVec.size());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003640 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003641 ;
3642 break;}
3643case 183:
3644#line 1915 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3645{
Chris Lattnerbb856a32007-08-06 21:00:46 +00003646 if (yyvsp[-5].ConstVal->getType() != Type::Int1Ty)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003647 GEN_ERROR("Select condition must be of boolean type");
Chris Lattnerbb856a32007-08-06 21:00:46 +00003648 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003649 GEN_ERROR("Select operand types must match");
Chris Lattnerbb856a32007-08-06 21:00:46 +00003650 yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003651 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003652 ;
3653 break;}
3654case 184:
3655#line 1923 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3656{
Chris Lattnerbb856a32007-08-06 21:00:46 +00003657 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003658 GEN_ERROR("Binary operator types must match");
3659 CHECK_FOR_ERROR;
Chris Lattnerbb856a32007-08-06 21:00:46 +00003660 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Dale Johannesen3afee192007-09-07 21:07:57 +00003661 ;
3662 break;}
3663case 185:
3664#line 1929 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3665{
Chris Lattnerbb856a32007-08-06 21:00:46 +00003666 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003667 GEN_ERROR("Logical operator types must match");
Chris Lattnerbb856a32007-08-06 21:00:46 +00003668 if (!yyvsp[-3].ConstVal->getType()->isInteger()) {
3669 if (Instruction::isShift(yyvsp[-5].BinaryOpVal) || !isa<VectorType>(yyvsp[-3].ConstVal->getType()) ||
3670 !cast<VectorType>(yyvsp[-3].ConstVal->getType())->getElementType()->isInteger())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003671 GEN_ERROR("Logical operator requires integral operands");
3672 }
Chris Lattnerbb856a32007-08-06 21:00:46 +00003673 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003674 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003675 ;
3676 break;}
3677case 186:
3678#line 1940 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3679{
Chris Lattnerbb856a32007-08-06 21:00:46 +00003680 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003681 GEN_ERROR("icmp operand types must match");
Chris Lattnerbb856a32007-08-06 21:00:46 +00003682 yyval.ConstVal = ConstantExpr::getICmp(yyvsp[-5].IPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Dale Johannesen3afee192007-09-07 21:07:57 +00003683 ;
3684 break;}
3685case 187:
3686#line 1945 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3687{
Chris Lattnerbb856a32007-08-06 21:00:46 +00003688 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003689 GEN_ERROR("fcmp operand types must match");
Chris Lattnerbb856a32007-08-06 21:00:46 +00003690 yyval.ConstVal = ConstantExpr::getFCmp(yyvsp[-5].FPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Dale Johannesen3afee192007-09-07 21:07:57 +00003691 ;
3692 break;}
3693case 188:
3694#line 1950 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3695{
Chris Lattnerbb856a32007-08-06 21:00:46 +00003696 if (!ExtractElementInst::isValidOperands(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003697 GEN_ERROR("Invalid extractelement operands");
Chris Lattnerbb856a32007-08-06 21:00:46 +00003698 yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003699 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003700 ;
3701 break;}
3702case 189:
3703#line 1956 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3704{
Chris Lattnerbb856a32007-08-06 21:00:46 +00003705 if (!InsertElementInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003706 GEN_ERROR("Invalid insertelement operands");
Chris Lattnerbb856a32007-08-06 21:00:46 +00003707 yyval.ConstVal = ConstantExpr::getInsertElement(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003708 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003709 ;
3710 break;}
3711case 190:
3712#line 1962 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3713{
Chris Lattnerbb856a32007-08-06 21:00:46 +00003714 if (!ShuffleVectorInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003715 GEN_ERROR("Invalid shufflevector operands");
Chris Lattnerbb856a32007-08-06 21:00:46 +00003716 yyval.ConstVal = ConstantExpr::getShuffleVector(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003717 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003718 ;
3719 break;}
3720case 191:
3721#line 1971 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3722{
Chris Lattnerbb856a32007-08-06 21:00:46 +00003723 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003724 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003725 ;
3726 break;}
3727case 192:
3728#line 1975 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3729{
Chris Lattnerbb856a32007-08-06 21:00:46 +00003730 yyval.ConstVector = new std::vector<Constant*>();
3731 yyval.ConstVector->push_back(yyvsp[0].ConstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003732 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003733 ;
3734 break;}
3735case 193:
3736#line 1983 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3737{ yyval.BoolVal = false; ;
3738 break;}
3739case 194:
3740#line 1983 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3741{ yyval.BoolVal = true; ;
3742 break;}
3743case 195:
3744#line 1986 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3745{ yyval.BoolVal = true; ;
3746 break;}
3747case 196:
3748#line 1986 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3749{ yyval.BoolVal = false; ;
3750 break;}
3751case 197:
3752#line 1989 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3753{
Chris Lattnerbb856a32007-08-06 21:00:46 +00003754 const Type* VTy = yyvsp[-1].TypeVal->get();
3755 Value *V = getVal(VTy, yyvsp[0].ValIDVal);
3756 CHECK_FOR_ERROR
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003757 GlobalValue* Aliasee = dyn_cast<GlobalValue>(V);
3758 if (!Aliasee)
3759 GEN_ERROR("Aliases can be created only to global values");
3760
Chris Lattnerbb856a32007-08-06 21:00:46 +00003761 yyval.ConstVal = Aliasee;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003762 CHECK_FOR_ERROR
Chris Lattnerbb856a32007-08-06 21:00:46 +00003763 delete yyvsp[-1].TypeVal;
Dale Johannesen3afee192007-09-07 21:07:57 +00003764 ;
3765 break;}
3766case 198:
3767#line 2001 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3768{
Chris Lattnerbb856a32007-08-06 21:00:46 +00003769 Constant *Val = yyvsp[-3].ConstVal;
3770 const Type *DestTy = yyvsp[-1].TypeVal->get();
3771 if (!CastInst::castIsValid(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003772 GEN_ERROR("invalid cast opcode for cast from '" +
3773 Val->getType()->getDescription() + "' to '" +
3774 DestTy->getDescription() + "'");
3775
Chris Lattnerbb856a32007-08-06 21:00:46 +00003776 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003777 CHECK_FOR_ERROR
Chris Lattnerbb856a32007-08-06 21:00:46 +00003778 delete yyvsp[-1].TypeVal;
Dale Johannesen3afee192007-09-07 21:07:57 +00003779 ;
3780 break;}
3781case 199:
3782#line 2022 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3783{
Chris Lattnerbb856a32007-08-06 21:00:46 +00003784 yyval.ModuleVal = ParserResult = CurModule.CurrentModule;
Reid Spencer47470022007-07-31 14:41:17 +00003785 CurModule.ModuleDone();
3786 CHECK_FOR_ERROR;
Dale Johannesen3afee192007-09-07 21:07:57 +00003787 ;
3788 break;}
3789case 200:
3790#line 2027 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3791{
Chris Lattnerbb856a32007-08-06 21:00:46 +00003792 yyval.ModuleVal = ParserResult = CurModule.CurrentModule;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003793 CurModule.ModuleDone();
3794 CHECK_FOR_ERROR;
Dale Johannesen3afee192007-09-07 21:07:57 +00003795 ;
3796 break;}
3797case 203:
3798#line 2040 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3799{ CurFun.isDeclare = false; ;
3800 break;}
3801case 204:
3802#line 2040 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3803{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003804 CurFun.FunctionDone();
3805 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003806 ;
3807 break;}
3808case 205:
3809#line 2044 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3810{ CurFun.isDeclare = true; ;
3811 break;}
3812case 206:
3813#line 2044 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3814{
Reid Spencer47470022007-07-31 14:41:17 +00003815 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003816 ;
3817 break;}
3818case 207:
3819#line 2047 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3820{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003821 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003822 ;
3823 break;}
3824case 208:
3825#line 2050 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3826{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003827 if (!UpRefs.empty())
Chris Lattnerbb856a32007-08-06 21:00:46 +00003828 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003829 // Eagerly resolve types. This is not an optimization, this is a
3830 // requirement that is due to the fact that we could have this:
3831 //
3832 // %list = type { %list * }
3833 // %list = type { %list * } ; repeated type decl
3834 //
3835 // If types are not resolved eagerly, then the two types will not be
3836 // determined to be the same type!
3837 //
Chris Lattnerbb856a32007-08-06 21:00:46 +00003838 ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003839
Chris Lattnerbb856a32007-08-06 21:00:46 +00003840 if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003841 CHECK_FOR_ERROR
3842 // If this is a named type that is not a redefinition, add it to the slot
3843 // table.
Chris Lattnerbb856a32007-08-06 21:00:46 +00003844 CurModule.Types.push_back(*yyvsp[0].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003845 }
3846
Chris Lattnerbb856a32007-08-06 21:00:46 +00003847 delete yyvsp[0].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003848 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003849 ;
3850 break;}
3851case 209:
3852#line 2074 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3853{
Chris Lattnerbb856a32007-08-06 21:00:46 +00003854 ResolveTypeTo(yyvsp[-2].StrVal, yyvsp[0].PrimType);
Reid Spenceraa8ae282007-07-31 03:50:36 +00003855
Chris Lattnerbb856a32007-08-06 21:00:46 +00003856 if (!setTypeName(yyvsp[0].PrimType, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003857 CHECK_FOR_ERROR
3858 // If this is a named type that is not a redefinition, add it to the slot
3859 // table.
Chris Lattnerbb856a32007-08-06 21:00:46 +00003860 CurModule.Types.push_back(yyvsp[0].PrimType);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003861 }
3862 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003863 ;
3864 break;}
3865case 210:
3866#line 2085 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3867{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003868 /* "Externally Visible" Linkage */
Chris Lattnerbb856a32007-08-06 21:00:46 +00003869 if (yyvsp[0].ConstVal == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003870 GEN_ERROR("Global value initializer is not a constant");
Chris Lattnerbb856a32007-08-06 21:00:46 +00003871 CurGV = ParseGlobalVariable(yyvsp[-4].StrVal, GlobalValue::ExternalLinkage,
3872 yyvsp[-3].Visibility, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal, yyvsp[-2].BoolVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003873 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003874 ;
3875 break;}
3876case 211:
3877#line 2092 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3878{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003879 CurGV = 0;
Dale Johannesen3afee192007-09-07 21:07:57 +00003880 ;
3881 break;}
3882case 212:
3883#line 2096 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3884{
Chris Lattnerbb856a32007-08-06 21:00:46 +00003885 if (yyvsp[0].ConstVal == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003886 GEN_ERROR("Global value initializer is not a constant");
Chris Lattnerbb856a32007-08-06 21:00:46 +00003887 CurGV = ParseGlobalVariable(yyvsp[-5].StrVal, yyvsp[-4].Linkage, yyvsp[-3].Visibility, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal, yyvsp[-2].BoolVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003888 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003889 ;
3890 break;}
3891case 213:
3892#line 2101 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3893{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003894 CurGV = 0;
Dale Johannesen3afee192007-09-07 21:07:57 +00003895 ;
3896 break;}
3897case 214:
3898#line 2105 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3899{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003900 if (!UpRefs.empty())
Chris Lattnerbb856a32007-08-06 21:00:46 +00003901 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
3902 CurGV = ParseGlobalVariable(yyvsp[-5].StrVal, yyvsp[-4].Linkage, yyvsp[-3].Visibility, yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0, yyvsp[-2].BoolVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003903 CHECK_FOR_ERROR
Chris Lattnerbb856a32007-08-06 21:00:46 +00003904 delete yyvsp[0].TypeVal;
Dale Johannesen3afee192007-09-07 21:07:57 +00003905 ;
3906 break;}
3907case 215:
3908#line 2111 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3909{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003910 CurGV = 0;
3911 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003912 ;
3913 break;}
3914case 216:
3915#line 2115 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3916{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003917 std::string Name;
Chris Lattnerbb856a32007-08-06 21:00:46 +00003918 if (yyvsp[-4].StrVal) {
3919 Name = *yyvsp[-4].StrVal;
3920 delete yyvsp[-4].StrVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003921 }
3922 if (Name.empty())
3923 GEN_ERROR("Alias name cannot be empty");
3924
Chris Lattnerbb856a32007-08-06 21:00:46 +00003925 Constant* Aliasee = yyvsp[0].ConstVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003926 if (Aliasee == 0)
3927 GEN_ERROR(std::string("Invalid aliasee for alias: ") + Name);
3928
Chris Lattnerbb856a32007-08-06 21:00:46 +00003929 GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), yyvsp[-1].Linkage, Name, Aliasee,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003930 CurModule.CurrentModule);
Chris Lattnerbb856a32007-08-06 21:00:46 +00003931 GA->setVisibility(yyvsp[-3].Visibility);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003932 InsertValue(GA, CurModule.Values);
3933 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003934 ;
3935 break;}
3936case 217:
3937#line 2134 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3938{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003939 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003940 ;
3941 break;}
3942case 218:
3943#line 2137 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3944{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003945 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003946 ;
3947 break;}
3948case 219:
3949#line 2143 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3950{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003951 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
3952 if (AsmSoFar.empty())
Chris Lattnerbb856a32007-08-06 21:00:46 +00003953 CurModule.CurrentModule->setModuleInlineAsm(*yyvsp[0].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003954 else
Chris Lattnerbb856a32007-08-06 21:00:46 +00003955 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+*yyvsp[0].StrVal);
3956 delete yyvsp[0].StrVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003957 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003958;
3959 break;}
3960case 220:
3961#line 2153 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3962{
Chris Lattnerbb856a32007-08-06 21:00:46 +00003963 CurModule.CurrentModule->setTargetTriple(*yyvsp[0].StrVal);
3964 delete yyvsp[0].StrVal;
Dale Johannesen3afee192007-09-07 21:07:57 +00003965 ;
3966 break;}
3967case 221:
3968#line 2157 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3969{
Chris Lattnerbb856a32007-08-06 21:00:46 +00003970 CurModule.CurrentModule->setDataLayout(*yyvsp[0].StrVal);
3971 delete yyvsp[0].StrVal;
Dale Johannesen3afee192007-09-07 21:07:57 +00003972 ;
3973 break;}
3974case 223:
3975#line 2164 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3976{
Chris Lattnerbb856a32007-08-06 21:00:46 +00003977 CurModule.CurrentModule->addLibrary(*yyvsp[0].StrVal);
3978 delete yyvsp[0].StrVal;
Reid Spencer47470022007-07-31 14:41:17 +00003979 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003980 ;
3981 break;}
3982case 224:
3983#line 2169 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3984{
Chris Lattnerbb856a32007-08-06 21:00:46 +00003985 CurModule.CurrentModule->addLibrary(*yyvsp[0].StrVal);
3986 delete yyvsp[0].StrVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003987 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003988 ;
3989 break;}
3990case 225:
3991#line 2174 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3992{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003993 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00003994 ;
3995 break;}
3996case 226:
3997#line 2183 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3998{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003999 if (!UpRefs.empty())
Chris Lattnerbb856a32007-08-06 21:00:46 +00004000 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4001 if (*yyvsp[-2].TypeVal == Type::VoidTy)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004002 GEN_ERROR("void typed arguments are invalid");
Chris Lattnerbb856a32007-08-06 21:00:46 +00004003 ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal;
4004 yyval.ArgList = yyvsp[-4].ArgList;
4005 yyvsp[-4].ArgList->push_back(E);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004006 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004007 ;
4008 break;}
4009case 227:
4010#line 2193 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4011{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004012 if (!UpRefs.empty())
Chris Lattnerbb856a32007-08-06 21:00:46 +00004013 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4014 if (*yyvsp[-2].TypeVal == Type::VoidTy)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004015 GEN_ERROR("void typed arguments are invalid");
Chris Lattnerbb856a32007-08-06 21:00:46 +00004016 ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal;
4017 yyval.ArgList = new ArgListType;
4018 yyval.ArgList->push_back(E);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004019 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004020 ;
4021 break;}
4022case 228:
4023#line 2204 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4024{
Chris Lattnerbb856a32007-08-06 21:00:46 +00004025 yyval.ArgList = yyvsp[0].ArgList;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004026 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004027 ;
4028 break;}
4029case 229:
4030#line 2208 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4031{
Chris Lattnerbb856a32007-08-06 21:00:46 +00004032 yyval.ArgList = yyvsp[-2].ArgList;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004033 struct ArgListEntry E;
4034 E.Ty = new PATypeHolder(Type::VoidTy);
4035 E.Name = 0;
4036 E.Attrs = ParamAttr::None;
Chris Lattnerbb856a32007-08-06 21:00:46 +00004037 yyval.ArgList->push_back(E);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004038 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004039 ;
4040 break;}
4041case 230:
4042#line 2217 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4043{
Chris Lattnerbb856a32007-08-06 21:00:46 +00004044 yyval.ArgList = new ArgListType;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004045 struct ArgListEntry E;
4046 E.Ty = new PATypeHolder(Type::VoidTy);
4047 E.Name = 0;
4048 E.Attrs = ParamAttr::None;
Chris Lattnerbb856a32007-08-06 21:00:46 +00004049 yyval.ArgList->push_back(E);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004050 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004051 ;
4052 break;}
4053case 231:
4054#line 2226 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4055{
Chris Lattnerbb856a32007-08-06 21:00:46 +00004056 yyval.ArgList = 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004057 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004058 ;
4059 break;}
4060case 232:
4061#line 2232 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4062{
Chris Lattnerbb856a32007-08-06 21:00:46 +00004063 std::string FunctionName(*yyvsp[-6].StrVal);
4064 delete yyvsp[-6].StrVal; // Free strdup'd memory!
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004065
4066 // Check the function result for abstractness if this is a define. We should
4067 // have no abstract types at this point
Chris Lattnerbb856a32007-08-06 21:00:46 +00004068 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(yyvsp[-7].TypeVal))
4069 GEN_ERROR("Reference to abstract result: "+ yyvsp[-7].TypeVal->get()->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004070
4071 std::vector<const Type*> ParamTypeList;
4072 ParamAttrsVector Attrs;
Chris Lattnerbb856a32007-08-06 21:00:46 +00004073 if (yyvsp[-2].ParamAttrs != ParamAttr::None) {
4074 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[-2].ParamAttrs;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004075 Attrs.push_back(PAWI);
4076 }
Chris Lattnerbb856a32007-08-06 21:00:46 +00004077 if (yyvsp[-4].ArgList) { // If there are arguments...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004078 unsigned index = 1;
Chris Lattnerbb856a32007-08-06 21:00:46 +00004079 for (ArgListType::iterator I = yyvsp[-4].ArgList->begin(); I != yyvsp[-4].ArgList->end(); ++I, ++index) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004080 const Type* Ty = I->Ty->get();
4081 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
4082 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
4083 ParamTypeList.push_back(Ty);
4084 if (Ty != Type::VoidTy)
4085 if (I->Attrs != ParamAttr::None) {
4086 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
4087 Attrs.push_back(PAWI);
4088 }
4089 }
4090 }
4091
4092 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
4093 if (isVarArg) ParamTypeList.pop_back();
4094
4095 ParamAttrsList *PAL = 0;
4096 if (!Attrs.empty())
4097 PAL = ParamAttrsList::get(Attrs);
4098
Chris Lattnerbb856a32007-08-06 21:00:46 +00004099 FunctionType *FT = FunctionType::get(*yyvsp[-7].TypeVal, ParamTypeList, isVarArg, PAL);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004100 const PointerType *PFT = PointerType::get(FT);
Chris Lattnerbb856a32007-08-06 21:00:46 +00004101 delete yyvsp[-7].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004102
4103 ValID ID;
4104 if (!FunctionName.empty()) {
4105 ID = ValID::createGlobalName((char*)FunctionName.c_str());
4106 } else {
4107 ID = ValID::createGlobalID(CurModule.Values.size());
4108 }
4109
4110 Function *Fn = 0;
4111 // See if this function was forward referenced. If so, recycle the object.
4112 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4113 // Move the function to the end of the list, from whereever it was
4114 // previously inserted.
4115 Fn = cast<Function>(FWRef);
4116 CurModule.CurrentModule->getFunctionList().remove(Fn);
4117 CurModule.CurrentModule->getFunctionList().push_back(Fn);
4118 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
4119 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
4120 if (Fn->getFunctionType() != FT) {
4121 // The existing function doesn't have the same type. This is an overload
4122 // error.
4123 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
4124 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
4125 // Neither the existing or the current function is a declaration and they
4126 // have the same name and same type. Clearly this is a redefinition.
4127 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
4128 } if (Fn->isDeclaration()) {
4129 // Make sure to strip off any argument names so we can't get conflicts.
4130 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
4131 AI != AE; ++AI)
4132 AI->setName("");
4133 }
4134 } else { // Not already defined?
4135 Fn = new Function(FT, GlobalValue::ExternalWeakLinkage, FunctionName,
4136 CurModule.CurrentModule);
4137
4138 InsertValue(Fn, CurModule.Values);
4139 }
4140
4141 CurFun.FunctionStart(Fn);
4142
4143 if (CurFun.isDeclare) {
4144 // If we have declaration, always overwrite linkage. This will allow us to
4145 // correctly handle cases, when pointer to function is passed as argument to
4146 // another function.
4147 Fn->setLinkage(CurFun.Linkage);
4148 Fn->setVisibility(CurFun.Visibility);
4149 }
Chris Lattnerbb856a32007-08-06 21:00:46 +00004150 Fn->setCallingConv(yyvsp[-8].UIntVal);
4151 Fn->setAlignment(yyvsp[0].UIntVal);
4152 if (yyvsp[-1].StrVal) {
4153 Fn->setSection(*yyvsp[-1].StrVal);
4154 delete yyvsp[-1].StrVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004155 }
4156
4157 // Add all of the arguments we parsed to the function...
Chris Lattnerbb856a32007-08-06 21:00:46 +00004158 if (yyvsp[-4].ArgList) { // Is null if empty...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004159 if (isVarArg) { // Nuke the last entry
Chris Lattnerbb856a32007-08-06 21:00:46 +00004160 assert(yyvsp[-4].ArgList->back().Ty->get() == Type::VoidTy && yyvsp[-4].ArgList->back().Name == 0 &&
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004161 "Not a varargs marker!");
Chris Lattnerbb856a32007-08-06 21:00:46 +00004162 delete yyvsp[-4].ArgList->back().Ty;
4163 yyvsp[-4].ArgList->pop_back(); // Delete the last entry
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004164 }
4165 Function::arg_iterator ArgIt = Fn->arg_begin();
4166 Function::arg_iterator ArgEnd = Fn->arg_end();
4167 unsigned Idx = 1;
Chris Lattnerbb856a32007-08-06 21:00:46 +00004168 for (ArgListType::iterator I = yyvsp[-4].ArgList->begin();
4169 I != yyvsp[-4].ArgList->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004170 delete I->Ty; // Delete the typeholder...
4171 setValueName(ArgIt, I->Name); // Insert arg into symtab...
4172 CHECK_FOR_ERROR
4173 InsertValue(ArgIt);
4174 Idx++;
4175 }
4176
Chris Lattnerbb856a32007-08-06 21:00:46 +00004177 delete yyvsp[-4].ArgList; // We're now done with the argument list
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004178 }
4179 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004180;
4181 break;}
4182case 235:
4183#line 2354 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4184{
Chris Lattnerbb856a32007-08-06 21:00:46 +00004185 yyval.FunctionVal = CurFun.CurrentFunction;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004186
4187 // Make sure that we keep track of the linkage type even if there was a
4188 // previous "declare".
Chris Lattnerbb856a32007-08-06 21:00:46 +00004189 yyval.FunctionVal->setLinkage(yyvsp[-3].Linkage);
4190 yyval.FunctionVal->setVisibility(yyvsp[-2].Visibility);
Dale Johannesen3afee192007-09-07 21:07:57 +00004191;
4192 break;}
4193case 238:
4194#line 2365 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4195{
Chris Lattnerbb856a32007-08-06 21:00:46 +00004196 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004197 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004198;
4199 break;}
4200case 239:
4201#line 2370 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4202{
Chris Lattnerbb856a32007-08-06 21:00:46 +00004203 CurFun.CurrentFunction->setLinkage(yyvsp[-2].Linkage);
4204 CurFun.CurrentFunction->setVisibility(yyvsp[-1].Visibility);
4205 yyval.FunctionVal = CurFun.CurrentFunction;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004206 CurFun.FunctionDone();
4207 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004208 ;
4209 break;}
4210case 240:
4211#line 2382 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4212{
Chris Lattnerbb856a32007-08-06 21:00:46 +00004213 yyval.BoolVal = false;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004214 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004215 ;
4216 break;}
4217case 241:
4218#line 2386 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4219{
Chris Lattnerbb856a32007-08-06 21:00:46 +00004220 yyval.BoolVal = true;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004221 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004222 ;
4223 break;}
4224case 242:
4225#line 2391 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4226{ // A reference to a direct constant
Chris Lattnerbb856a32007-08-06 21:00:46 +00004227 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004228 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004229 ;
4230 break;}
4231case 243:
4232#line 2395 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4233{
Chris Lattnerbb856a32007-08-06 21:00:46 +00004234 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004235 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004236 ;
4237 break;}
4238case 244:
4239#line 2399 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4240{ // Perhaps it's an FP constant?
Chris Lattnerbb856a32007-08-06 21:00:46 +00004241 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004242 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004243 ;
4244 break;}
4245case 245:
4246#line 2403 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4247{
Chris Lattnerbb856a32007-08-06 21:00:46 +00004248 yyval.ValIDVal = ValID::create(ConstantInt::getTrue());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004249 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004250 ;
4251 break;}
4252case 246:
4253#line 2407 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4254{
Chris Lattnerbb856a32007-08-06 21:00:46 +00004255 yyval.ValIDVal = ValID::create(ConstantInt::getFalse());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004256 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004257 ;
4258 break;}
4259case 247:
4260#line 2411 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4261{
Chris Lattnerbb856a32007-08-06 21:00:46 +00004262 yyval.ValIDVal = ValID::createNull();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004263 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004264 ;
4265 break;}
4266case 248:
4267#line 2415 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4268{
Chris Lattnerbb856a32007-08-06 21:00:46 +00004269 yyval.ValIDVal = ValID::createUndef();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004270 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004271 ;
4272 break;}
4273case 249:
4274#line 2419 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4275{ // A vector zero constant.
Chris Lattnerbb856a32007-08-06 21:00:46 +00004276 yyval.ValIDVal = ValID::createZeroInit();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004277 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004278 ;
4279 break;}
4280case 250:
4281#line 2423 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4282{ // Nonempty unsized packed vector
Chris Lattnerbb856a32007-08-06 21:00:46 +00004283 const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
4284 int NumElements = yyvsp[-1].ConstVector->size();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004285
4286 VectorType* pt = VectorType::get(ETy, NumElements);
4287 PATypeHolder* PTy = new PATypeHolder(
4288 HandleUpRefs(
4289 VectorType::get(
4290 ETy,
4291 NumElements)
4292 )
4293 );
4294
4295 // Verify all elements are correct type!
Chris Lattnerbb856a32007-08-06 21:00:46 +00004296 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
4297 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004298 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
4299 ETy->getDescription() +"' as required!\nIt is of type '" +
Chris Lattnerbb856a32007-08-06 21:00:46 +00004300 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004301 }
4302
Chris Lattnerbb856a32007-08-06 21:00:46 +00004303 yyval.ValIDVal = ValID::create(ConstantVector::get(pt, *yyvsp[-1].ConstVector));
4304 delete PTy; delete yyvsp[-1].ConstVector;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004305 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004306 ;
4307 break;}
4308case 251:
4309#line 2448 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4310{
Chris Lattnerbb856a32007-08-06 21:00:46 +00004311 yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004312 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004313 ;
4314 break;}
4315case 252:
4316#line 2452 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4317{
Chris Lattnerbb856a32007-08-06 21:00:46 +00004318 yyval.ValIDVal = ValID::createInlineAsm(*yyvsp[-2].StrVal, *yyvsp[0].StrVal, yyvsp[-3].BoolVal);
4319 delete yyvsp[-2].StrVal;
4320 delete yyvsp[0].StrVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004321 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004322 ;
4323 break;}
4324case 253:
4325#line 2462 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4326{ // Is it an integer reference...?
Chris Lattnerbb856a32007-08-06 21:00:46 +00004327 yyval.ValIDVal = ValID::createLocalID(yyvsp[0].UIntVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004328 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004329 ;
4330 break;}
4331case 254:
4332#line 2466 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4333{
Chris Lattnerbb856a32007-08-06 21:00:46 +00004334 yyval.ValIDVal = ValID::createGlobalID(yyvsp[0].UIntVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004335 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004336 ;
4337 break;}
4338case 255:
4339#line 2470 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4340{ // Is it a named reference...?
Chris Lattnerbb856a32007-08-06 21:00:46 +00004341 yyval.ValIDVal = ValID::createLocalName(*yyvsp[0].StrVal);
4342 delete yyvsp[0].StrVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004343 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004344 ;
4345 break;}
4346case 256:
4347#line 2475 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4348{ // Is it a named reference...?
Chris Lattnerbb856a32007-08-06 21:00:46 +00004349 yyval.ValIDVal = ValID::createGlobalName(*yyvsp[0].StrVal);
4350 delete yyvsp[0].StrVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004351 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004352 ;
4353 break;}
4354case 259:
4355#line 2488 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4356{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004357 if (!UpRefs.empty())
Chris Lattnerbb856a32007-08-06 21:00:46 +00004358 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4359 yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
4360 delete yyvsp[-1].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004361 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004362 ;
4363 break;}
4364case 260:
4365#line 2497 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4366{
Chris Lattnerbb856a32007-08-06 21:00:46 +00004367 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004368 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004369 ;
4370 break;}
4371case 261:
4372#line 2501 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4373{ // Do not allow functions with 0 basic blocks
Chris Lattnerbb856a32007-08-06 21:00:46 +00004374 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004375 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004376 ;
4377 break;}
4378case 262:
4379#line 2510 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4380{
Chris Lattnerbb856a32007-08-06 21:00:46 +00004381 setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004382 CHECK_FOR_ERROR
Chris Lattnerbb856a32007-08-06 21:00:46 +00004383 InsertValue(yyvsp[0].TermInstVal);
4384 yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
4385 yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004386 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004387 ;
4388 break;}
4389case 263:
4390#line 2519 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4391{
Chris Lattnerbb856a32007-08-06 21:00:46 +00004392 if (CastInst *CI1 = dyn_cast<CastInst>(yyvsp[0].InstVal))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004393 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
4394 if (CI2->getParent() == 0)
Chris Lattnerbb856a32007-08-06 21:00:46 +00004395 yyvsp[-1].BasicBlockVal->getInstList().push_back(CI2);
4396 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
4397 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004398 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004399 ;
4400 break;}
4401case 264:
4402#line 2528 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4403{ // Empty space between instruction lists
Chris Lattnerbb856a32007-08-06 21:00:46 +00004404 yyval.BasicBlockVal = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004405 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004406 ;
4407 break;}
4408case 265:
4409#line 2532 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4410{ // Labelled (named) basic block
Chris Lattnerbb856a32007-08-06 21:00:46 +00004411 yyval.BasicBlockVal = defineBBVal(ValID::createLocalName(*yyvsp[0].StrVal));
4412 delete yyvsp[0].StrVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004413 CHECK_FOR_ERROR
4414
Dale Johannesen3afee192007-09-07 21:07:57 +00004415 ;
4416 break;}
4417case 266:
4418#line 2539 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4419{ // Return with a result...
Chris Lattnerbb856a32007-08-06 21:00:46 +00004420 yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
4421 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004422 ;
4423 break;}
4424case 267:
4425#line 2543 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4426{ // Return with no result...
Chris Lattnerbb856a32007-08-06 21:00:46 +00004427 yyval.TermInstVal = new ReturnInst();
4428 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004429 ;
4430 break;}
4431case 268:
4432#line 2547 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4433{ // Unconditional Branch...
Chris Lattnerbb856a32007-08-06 21:00:46 +00004434 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
4435 CHECK_FOR_ERROR
4436 yyval.TermInstVal = new BranchInst(tmpBB);
Dale Johannesen3afee192007-09-07 21:07:57 +00004437 ;
4438 break;}
4439case 269:
4440#line 2552 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4441{
Chris Lattnerbb856a32007-08-06 21:00:46 +00004442 assert(cast<IntegerType>(yyvsp[-7].PrimType)->getBitWidth() == 1 && "Not Bool?");
4443 BasicBlock* tmpBBA = getBBVal(yyvsp[-3].ValIDVal);
4444 CHECK_FOR_ERROR
4445 BasicBlock* tmpBBB = getBBVal(yyvsp[0].ValIDVal);
4446 CHECK_FOR_ERROR
4447 Value* tmpVal = getVal(Type::Int1Ty, yyvsp[-6].ValIDVal);
4448 CHECK_FOR_ERROR
4449 yyval.TermInstVal = new BranchInst(tmpBBA, tmpBBB, tmpVal);
Dale Johannesen3afee192007-09-07 21:07:57 +00004450 ;
4451 break;}
4452case 270:
4453#line 2562 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4454{
Chris Lattnerbb856a32007-08-06 21:00:46 +00004455 Value* tmpVal = getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal);
4456 CHECK_FOR_ERROR
4457 BasicBlock* tmpBB = getBBVal(yyvsp[-3].ValIDVal);
4458 CHECK_FOR_ERROR
4459 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, yyvsp[-1].JumpTable->size());
4460 yyval.TermInstVal = S;
Reid Spenceraa8ae282007-07-31 03:50:36 +00004461
Chris Lattnerbb856a32007-08-06 21:00:46 +00004462 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
4463 E = yyvsp[-1].JumpTable->end();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004464 for (; I != E; ++I) {
4465 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
4466 S->addCase(CI, I->second);
4467 else
4468 GEN_ERROR("Switch case is constant, but not a simple integer");
4469 }
Chris Lattnerbb856a32007-08-06 21:00:46 +00004470 delete yyvsp[-1].JumpTable;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004471 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004472 ;
4473 break;}
4474case 271:
4475#line 2581 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4476{
Chris Lattnerbb856a32007-08-06 21:00:46 +00004477 Value* tmpVal = getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004478 CHECK_FOR_ERROR
Chris Lattnerbb856a32007-08-06 21:00:46 +00004479 BasicBlock* tmpBB = getBBVal(yyvsp[-2].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004480 CHECK_FOR_ERROR
4481 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Chris Lattnerbb856a32007-08-06 21:00:46 +00004482 yyval.TermInstVal = S;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004483 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004484 ;
4485 break;}
4486case 272:
4487#line 2591 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4488{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004489
4490 // Handle the short syntax
4491 const PointerType *PFTy = 0;
4492 const FunctionType *Ty = 0;
Chris Lattnerbb856a32007-08-06 21:00:46 +00004493 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-11].TypeVal->get())) ||
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004494 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4495 // Pull out the types of all of the arguments...
4496 std::vector<const Type*> ParamTypes;
4497 ParamAttrsVector Attrs;
Chris Lattnerbb856a32007-08-06 21:00:46 +00004498 if (yyvsp[-6].ParamAttrs != ParamAttr::None) {
4499 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[-6].ParamAttrs;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004500 Attrs.push_back(PAWI);
4501 }
Chris Lattnerbb856a32007-08-06 21:00:46 +00004502 ValueRefList::iterator I = yyvsp[-8].ValueRefList->begin(), E = yyvsp[-8].ValueRefList->end();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004503 unsigned index = 1;
4504 for (; I != E; ++I, ++index) {
4505 const Type *Ty = I->Val->getType();
4506 if (Ty == Type::VoidTy)
4507 GEN_ERROR("Short call syntax cannot be used with varargs");
4508 ParamTypes.push_back(Ty);
4509 if (I->Attrs != ParamAttr::None) {
4510 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
4511 Attrs.push_back(PAWI);
4512 }
4513 }
4514
4515 ParamAttrsList *PAL = 0;
4516 if (!Attrs.empty())
4517 PAL = ParamAttrsList::get(Attrs);
Chris Lattnerbb856a32007-08-06 21:00:46 +00004518 Ty = FunctionType::get(yyvsp[-11].TypeVal->get(), ParamTypes, false, PAL);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004519 PFTy = PointerType::get(Ty);
4520 }
4521
Chris Lattnerbb856a32007-08-06 21:00:46 +00004522 delete yyvsp[-11].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004523
Chris Lattnerbb856a32007-08-06 21:00:46 +00004524 Value *V = getVal(PFTy, yyvsp[-10].ValIDVal); // Get the function we're calling...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004525 CHECK_FOR_ERROR
Chris Lattnerbb856a32007-08-06 21:00:46 +00004526 BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004527 CHECK_FOR_ERROR
Chris Lattnerbb856a32007-08-06 21:00:46 +00004528 BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004529 CHECK_FOR_ERROR
4530
4531 // Check the arguments
4532 ValueList Args;
Chris Lattnerbb856a32007-08-06 21:00:46 +00004533 if (yyvsp[-8].ValueRefList->empty()) { // Has no arguments?
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004534 // Make sure no arguments is a good thing!
4535 if (Ty->getNumParams() != 0)
4536 GEN_ERROR("No arguments passed to a function that "
4537 "expects arguments");
4538 } else { // Has arguments?
4539 // Loop through FunctionType's arguments and ensure they are specified
4540 // correctly!
4541 FunctionType::param_iterator I = Ty->param_begin();
4542 FunctionType::param_iterator E = Ty->param_end();
Chris Lattnerbb856a32007-08-06 21:00:46 +00004543 ValueRefList::iterator ArgI = yyvsp[-8].ValueRefList->begin(), ArgE = yyvsp[-8].ValueRefList->end();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004544
4545 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
4546 if (ArgI->Val->getType() != *I)
4547 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
4548 (*I)->getDescription() + "'");
4549 Args.push_back(ArgI->Val);
4550 }
4551
4552 if (Ty->isVarArg()) {
4553 if (I == E)
4554 for (; ArgI != ArgE; ++ArgI)
4555 Args.push_back(ArgI->Val); // push the remaining varargs
4556 } else if (I != E || ArgI != ArgE)
4557 GEN_ERROR("Invalid number of parameters detected");
4558 }
4559
4560 // Create the InvokeInst
Chris Lattnerd140ada2007-08-29 16:15:23 +00004561 InvokeInst *II = new InvokeInst(V, Normal, Except, Args.begin(), Args.end());
Chris Lattnerbb856a32007-08-06 21:00:46 +00004562 II->setCallingConv(yyvsp[-12].UIntVal);
4563 yyval.TermInstVal = II;
4564 delete yyvsp[-8].ValueRefList;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004565 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004566 ;
4567 break;}
4568case 273:
4569#line 2670 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4570{
Chris Lattnerbb856a32007-08-06 21:00:46 +00004571 yyval.TermInstVal = new UnwindInst();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004572 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004573 ;
4574 break;}
4575case 274:
4576#line 2674 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4577{
Chris Lattnerbb856a32007-08-06 21:00:46 +00004578 yyval.TermInstVal = new UnreachableInst();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004579 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004580 ;
4581 break;}
4582case 275:
4583#line 2681 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4584{
Chris Lattnerbb856a32007-08-06 21:00:46 +00004585 yyval.JumpTable = yyvsp[-5].JumpTable;
4586 Constant *V = cast<Constant>(getExistingVal(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004587 CHECK_FOR_ERROR
4588 if (V == 0)
4589 GEN_ERROR("May only switch on a constant pool value");
4590
Chris Lattnerbb856a32007-08-06 21:00:46 +00004591 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004592 CHECK_FOR_ERROR
Chris Lattnerbb856a32007-08-06 21:00:46 +00004593 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
Dale Johannesen3afee192007-09-07 21:07:57 +00004594 ;
4595 break;}
4596case 276:
4597#line 2692 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4598{
Chris Lattnerbb856a32007-08-06 21:00:46 +00004599 yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
4600 Constant *V = cast<Constant>(getExistingVal(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004601 CHECK_FOR_ERROR
4602
4603 if (V == 0)
4604 GEN_ERROR("May only switch on a constant pool value");
4605
Chris Lattnerbb856a32007-08-06 21:00:46 +00004606 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004607 CHECK_FOR_ERROR
Chris Lattnerbb856a32007-08-06 21:00:46 +00004608 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
Dale Johannesen3afee192007-09-07 21:07:57 +00004609 ;
4610 break;}
4611case 277:
4612#line 2705 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4613{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004614 // Is this definition named?? if so, assign the name...
Chris Lattnerbb856a32007-08-06 21:00:46 +00004615 setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004616 CHECK_FOR_ERROR
Chris Lattnerbb856a32007-08-06 21:00:46 +00004617 InsertValue(yyvsp[0].InstVal);
4618 yyval.InstVal = yyvsp[0].InstVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004619 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004620 ;
4621 break;}
4622case 278:
4623#line 2715 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4624{ // Used for PHI nodes
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004625 if (!UpRefs.empty())
Chris Lattnerbb856a32007-08-06 21:00:46 +00004626 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-5].TypeVal)->getDescription());
4627 yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
4628 Value* tmpVal = getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004629 CHECK_FOR_ERROR
Chris Lattnerbb856a32007-08-06 21:00:46 +00004630 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004631 CHECK_FOR_ERROR
Chris Lattnerbb856a32007-08-06 21:00:46 +00004632 yyval.PHIList->push_back(std::make_pair(tmpVal, tmpBB));
4633 delete yyvsp[-5].TypeVal;
Dale Johannesen3afee192007-09-07 21:07:57 +00004634 ;
4635 break;}
4636case 279:
4637#line 2726 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4638{
Chris Lattnerbb856a32007-08-06 21:00:46 +00004639 yyval.PHIList = yyvsp[-6].PHIList;
4640 Value* tmpVal = getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004641 CHECK_FOR_ERROR
Chris Lattnerbb856a32007-08-06 21:00:46 +00004642 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004643 CHECK_FOR_ERROR
Chris Lattnerbb856a32007-08-06 21:00:46 +00004644 yyvsp[-6].PHIList->push_back(std::make_pair(tmpVal, tmpBB));
Dale Johannesen3afee192007-09-07 21:07:57 +00004645 ;
4646 break;}
4647case 280:
4648#line 2736 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4649{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004650 if (!UpRefs.empty())
Chris Lattnerbb856a32007-08-06 21:00:46 +00004651 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004652 // Used for call and invoke instructions
Chris Lattnerbb856a32007-08-06 21:00:46 +00004653 yyval.ValueRefList = new ValueRefList();
4654 ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal);
4655 yyval.ValueRefList->push_back(E);
4656 delete yyvsp[-2].TypeVal;
Dale Johannesen3afee192007-09-07 21:07:57 +00004657 ;
4658 break;}
4659case 281:
4660#line 2745 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4661{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004662 if (!UpRefs.empty())
Chris Lattnerbb856a32007-08-06 21:00:46 +00004663 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4664 yyval.ValueRefList = yyvsp[-4].ValueRefList;
4665 ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal);
4666 yyval.ValueRefList->push_back(E);
4667 delete yyvsp[-2].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004668 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004669 ;
4670 break;}
4671case 282:
4672#line 2754 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4673{ yyval.ValueRefList = new ValueRefList(); ;
4674 break;}
4675case 283:
4676#line 2757 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4677{ yyval.ValueList = new std::vector<Value*>(); ;
4678 break;}
4679case 284:
4680#line 2758 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4681{
Chris Lattnerbb856a32007-08-06 21:00:46 +00004682 yyval.ValueList = yyvsp[-2].ValueList;
4683 yyval.ValueList->push_back(yyvsp[0].ValueVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004684 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004685 ;
4686 break;}
4687case 285:
4688#line 2765 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4689{
Chris Lattnerbb856a32007-08-06 21:00:46 +00004690 yyval.BoolVal = true;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004691 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004692 ;
4693 break;}
4694case 286:
4695#line 2769 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4696{
Chris Lattnerbb856a32007-08-06 21:00:46 +00004697 yyval.BoolVal = false;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004698 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004699 ;
4700 break;}
4701case 287:
4702#line 2774 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4703{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004704 if (!UpRefs.empty())
Chris Lattnerbb856a32007-08-06 21:00:46 +00004705 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4706 if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
4707 !isa<VectorType>((*yyvsp[-3].TypeVal).get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004708 GEN_ERROR(
4709 "Arithmetic operator requires integer, FP, or packed operands");
Chris Lattnerbb856a32007-08-06 21:00:46 +00004710 if (isa<VectorType>((*yyvsp[-3].TypeVal).get()) &&
4711 (yyvsp[-4].BinaryOpVal == Instruction::URem ||
4712 yyvsp[-4].BinaryOpVal == Instruction::SRem ||
4713 yyvsp[-4].BinaryOpVal == Instruction::FRem))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004714 GEN_ERROR("Remainder not supported on vector types");
Chris Lattnerbb856a32007-08-06 21:00:46 +00004715 Value* val1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004716 CHECK_FOR_ERROR
Chris Lattnerbb856a32007-08-06 21:00:46 +00004717 Value* val2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004718 CHECK_FOR_ERROR
Chris Lattnerbb856a32007-08-06 21:00:46 +00004719 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, val1, val2);
4720 if (yyval.InstVal == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004721 GEN_ERROR("binary operator returned null");
Chris Lattnerbb856a32007-08-06 21:00:46 +00004722 delete yyvsp[-3].TypeVal;
Dale Johannesen3afee192007-09-07 21:07:57 +00004723 ;
4724 break;}
4725case 288:
4726#line 2795 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4727{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004728 if (!UpRefs.empty())
Chris Lattnerbb856a32007-08-06 21:00:46 +00004729 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4730 if (!(*yyvsp[-3].TypeVal)->isInteger()) {
4731 if (Instruction::isShift(yyvsp[-4].BinaryOpVal) || !isa<VectorType>(yyvsp[-3].TypeVal->get()) ||
4732 !cast<VectorType>(yyvsp[-3].TypeVal->get())->getElementType()->isInteger())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004733 GEN_ERROR("Logical operator requires integral operands");
4734 }
Chris Lattnerbb856a32007-08-06 21:00:46 +00004735 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004736 CHECK_FOR_ERROR
Chris Lattnerbb856a32007-08-06 21:00:46 +00004737 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004738 CHECK_FOR_ERROR
Chris Lattnerbb856a32007-08-06 21:00:46 +00004739 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, tmpVal1, tmpVal2);
4740 if (yyval.InstVal == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004741 GEN_ERROR("binary operator returned null");
Chris Lattnerbb856a32007-08-06 21:00:46 +00004742 delete yyvsp[-3].TypeVal;
Dale Johannesen3afee192007-09-07 21:07:57 +00004743 ;
4744 break;}
4745case 289:
4746#line 2812 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4747{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004748 if (!UpRefs.empty())
Chris Lattnerbb856a32007-08-06 21:00:46 +00004749 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4750 if (isa<VectorType>((*yyvsp[-3].TypeVal).get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004751 GEN_ERROR("Vector types not supported by icmp instruction");
Chris Lattnerbb856a32007-08-06 21:00:46 +00004752 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004753 CHECK_FOR_ERROR
Chris Lattnerbb856a32007-08-06 21:00:46 +00004754 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004755 CHECK_FOR_ERROR
Chris Lattnerbb856a32007-08-06 21:00:46 +00004756 yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].IPredicate, tmpVal1, tmpVal2);
4757 if (yyval.InstVal == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004758 GEN_ERROR("icmp operator returned null");
Chris Lattnerbb856a32007-08-06 21:00:46 +00004759 delete yyvsp[-3].TypeVal;
Dale Johannesen3afee192007-09-07 21:07:57 +00004760 ;
4761 break;}
4762case 290:
4763#line 2826 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4764{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004765 if (!UpRefs.empty())
Chris Lattnerbb856a32007-08-06 21:00:46 +00004766 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4767 if (isa<VectorType>((*yyvsp[-3].TypeVal).get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004768 GEN_ERROR("Vector types not supported by fcmp instruction");
Chris Lattnerbb856a32007-08-06 21:00:46 +00004769 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004770 CHECK_FOR_ERROR
Chris Lattnerbb856a32007-08-06 21:00:46 +00004771 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004772 CHECK_FOR_ERROR
Chris Lattnerbb856a32007-08-06 21:00:46 +00004773 yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].FPredicate, tmpVal1, tmpVal2);
4774 if (yyval.InstVal == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004775 GEN_ERROR("fcmp operator returned null");
Chris Lattnerbb856a32007-08-06 21:00:46 +00004776 delete yyvsp[-3].TypeVal;
Dale Johannesen3afee192007-09-07 21:07:57 +00004777 ;
4778 break;}
4779case 291:
4780#line 2840 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4781{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004782 if (!UpRefs.empty())
Chris Lattnerbb856a32007-08-06 21:00:46 +00004783 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
4784 Value* Val = yyvsp[-2].ValueVal;
4785 const Type* DestTy = yyvsp[0].TypeVal->get();
4786 if (!CastInst::castIsValid(yyvsp[-3].CastOpVal, Val, DestTy))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004787 GEN_ERROR("invalid cast opcode for cast from '" +
4788 Val->getType()->getDescription() + "' to '" +
4789 DestTy->getDescription() + "'");
Chris Lattnerbb856a32007-08-06 21:00:46 +00004790 yyval.InstVal = CastInst::create(yyvsp[-3].CastOpVal, Val, DestTy);
4791 delete yyvsp[0].TypeVal;
Dale Johannesen3afee192007-09-07 21:07:57 +00004792 ;
4793 break;}
4794case 292:
4795#line 2852 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4796{
Chris Lattnerbb856a32007-08-06 21:00:46 +00004797 if (yyvsp[-4].ValueVal->getType() != Type::Int1Ty)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004798 GEN_ERROR("select condition must be boolean");
Chris Lattnerbb856a32007-08-06 21:00:46 +00004799 if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004800 GEN_ERROR("select value types should match");
Chris Lattnerbb856a32007-08-06 21:00:46 +00004801 yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004802 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004803 ;
4804 break;}
4805case 293:
4806#line 2860 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4807{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004808 if (!UpRefs.empty())
Chris Lattnerbb856a32007-08-06 21:00:46 +00004809 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
4810 yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
4811 delete yyvsp[0].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004812 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004813 ;
4814 break;}
4815case 294:
4816#line 2867 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4817{
Chris Lattnerbb856a32007-08-06 21:00:46 +00004818 if (!ExtractElementInst::isValidOperands(yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004819 GEN_ERROR("Invalid extractelement operands");
Chris Lattnerbb856a32007-08-06 21:00:46 +00004820 yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004821 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004822 ;
4823 break;}
4824case 295:
4825#line 2873 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4826{
Chris Lattnerbb856a32007-08-06 21:00:46 +00004827 if (!InsertElementInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004828 GEN_ERROR("Invalid insertelement operands");
Chris Lattnerbb856a32007-08-06 21:00:46 +00004829 yyval.InstVal = new InsertElementInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004830 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004831 ;
4832 break;}
4833case 296:
4834#line 2879 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4835{
Chris Lattnerbb856a32007-08-06 21:00:46 +00004836 if (!ShuffleVectorInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004837 GEN_ERROR("Invalid shufflevector operands");
Chris Lattnerbb856a32007-08-06 21:00:46 +00004838 yyval.InstVal = new ShuffleVectorInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004839 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004840 ;
4841 break;}
4842case 297:
4843#line 2885 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4844{
Chris Lattnerbb856a32007-08-06 21:00:46 +00004845 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004846 if (!Ty->isFirstClassType())
4847 GEN_ERROR("PHI node operands must be of first class type");
Chris Lattnerbb856a32007-08-06 21:00:46 +00004848 yyval.InstVal = new PHINode(Ty);
4849 ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
4850 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
4851 if (yyvsp[0].PHIList->front().first->getType() != Ty)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004852 GEN_ERROR("All elements of a PHI node must be of the same type");
Chris Lattnerbb856a32007-08-06 21:00:46 +00004853 cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
4854 yyvsp[0].PHIList->pop_front();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004855 }
Chris Lattnerbb856a32007-08-06 21:00:46 +00004856 delete yyvsp[0].PHIList; // Free the list...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004857 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004858 ;
4859 break;}
4860case 298:
4861#line 2901 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4862{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004863
4864 // Handle the short syntax
4865 const PointerType *PFTy = 0;
4866 const FunctionType *Ty = 0;
Chris Lattnerbb856a32007-08-06 21:00:46 +00004867 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-5].TypeVal->get())) ||
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004868 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4869 // Pull out the types of all of the arguments...
4870 std::vector<const Type*> ParamTypes;
4871 ParamAttrsVector Attrs;
Chris Lattnerbb856a32007-08-06 21:00:46 +00004872 if (yyvsp[0].ParamAttrs != ParamAttr::None) {
4873 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[0].ParamAttrs;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004874 Attrs.push_back(PAWI);
4875 }
4876 unsigned index = 1;
Chris Lattnerbb856a32007-08-06 21:00:46 +00004877 ValueRefList::iterator I = yyvsp[-2].ValueRefList->begin(), E = yyvsp[-2].ValueRefList->end();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004878 for (; I != E; ++I, ++index) {
4879 const Type *Ty = I->Val->getType();
4880 if (Ty == Type::VoidTy)
4881 GEN_ERROR("Short call syntax cannot be used with varargs");
4882 ParamTypes.push_back(Ty);
4883 if (I->Attrs != ParamAttr::None) {
4884 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
4885 Attrs.push_back(PAWI);
4886 }
4887 }
4888
4889 ParamAttrsList *PAL = 0;
4890 if (!Attrs.empty())
4891 PAL = ParamAttrsList::get(Attrs);
4892
Chris Lattnerbb856a32007-08-06 21:00:46 +00004893 Ty = FunctionType::get(yyvsp[-5].TypeVal->get(), ParamTypes, false, PAL);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004894 PFTy = PointerType::get(Ty);
4895 }
4896
Chris Lattnerbb856a32007-08-06 21:00:46 +00004897 Value *V = getVal(PFTy, yyvsp[-4].ValIDVal); // Get the function we're calling...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004898 CHECK_FOR_ERROR
4899
4900 // Check for call to invalid intrinsic to avoid crashing later.
4901 if (Function *theF = dyn_cast<Function>(V)) {
4902 if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) &&
4903 (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) &&
4904 !theF->getIntrinsicID(true))
4905 GEN_ERROR("Call to invalid LLVM intrinsic function '" +
4906 theF->getName() + "'");
4907 }
4908
4909 // Check the arguments
4910 ValueList Args;
Chris Lattnerbb856a32007-08-06 21:00:46 +00004911 if (yyvsp[-2].ValueRefList->empty()) { // Has no arguments?
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004912 // Make sure no arguments is a good thing!
4913 if (Ty->getNumParams() != 0)
4914 GEN_ERROR("No arguments passed to a function that "
4915 "expects arguments");
4916 } else { // Has arguments?
4917 // Loop through FunctionType's arguments and ensure they are specified
4918 // correctly!
4919 //
4920 FunctionType::param_iterator I = Ty->param_begin();
4921 FunctionType::param_iterator E = Ty->param_end();
Chris Lattnerbb856a32007-08-06 21:00:46 +00004922 ValueRefList::iterator ArgI = yyvsp[-2].ValueRefList->begin(), ArgE = yyvsp[-2].ValueRefList->end();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004923
4924 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
4925 if (ArgI->Val->getType() != *I)
4926 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
4927 (*I)->getDescription() + "'");
4928 Args.push_back(ArgI->Val);
4929 }
4930 if (Ty->isVarArg()) {
4931 if (I == E)
4932 for (; ArgI != ArgE; ++ArgI)
4933 Args.push_back(ArgI->Val); // push the remaining varargs
4934 } else if (I != E || ArgI != ArgE)
4935 GEN_ERROR("Invalid number of parameters detected");
4936 }
4937 // Create the call node
David Greene9145dd22007-08-01 03:59:32 +00004938 CallInst *CI = new CallInst(V, Args.begin(), Args.end());
Chris Lattnerbb856a32007-08-06 21:00:46 +00004939 CI->setTailCall(yyvsp[-7].BoolVal);
4940 CI->setCallingConv(yyvsp[-6].UIntVal);
4941 yyval.InstVal = CI;
4942 delete yyvsp[-2].ValueRefList;
4943 delete yyvsp[-5].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004944 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004945 ;
4946 break;}
4947case 299:
4948#line 2985 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4949{
Chris Lattnerbb856a32007-08-06 21:00:46 +00004950 yyval.InstVal = yyvsp[0].InstVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004951 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004952 ;
4953 break;}
4954case 300:
4955#line 2990 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4956{
Chris Lattnerbb856a32007-08-06 21:00:46 +00004957 yyval.BoolVal = true;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004958 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004959 ;
4960 break;}
4961case 301:
4962#line 2994 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4963{
Chris Lattnerbb856a32007-08-06 21:00:46 +00004964 yyval.BoolVal = false;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004965 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004966 ;
4967 break;}
4968case 302:
4969#line 3001 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4970{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004971 if (!UpRefs.empty())
Chris Lattnerbb856a32007-08-06 21:00:46 +00004972 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4973 yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
4974 delete yyvsp[-1].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004975 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004976 ;
4977 break;}
4978case 303:
4979#line 3008 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4980{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004981 if (!UpRefs.empty())
Chris Lattnerbb856a32007-08-06 21:00:46 +00004982 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
4983 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004984 CHECK_FOR_ERROR
Chris Lattnerbb856a32007-08-06 21:00:46 +00004985 yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
4986 delete yyvsp[-4].TypeVal;
Dale Johannesen3afee192007-09-07 21:07:57 +00004987 ;
4988 break;}
4989case 304:
4990#line 3016 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4991{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004992 if (!UpRefs.empty())
Chris Lattnerbb856a32007-08-06 21:00:46 +00004993 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4994 yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
4995 delete yyvsp[-1].TypeVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004996 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00004997 ;
4998 break;}
4999case 305:
5000#line 3023 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
5001{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005002 if (!UpRefs.empty())
Chris Lattnerbb856a32007-08-06 21:00:46 +00005003 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
5004 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005005 CHECK_FOR_ERROR
Chris Lattnerbb856a32007-08-06 21:00:46 +00005006 yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
5007 delete yyvsp[-4].TypeVal;
Dale Johannesen3afee192007-09-07 21:07:57 +00005008 ;
5009 break;}
5010case 306:
5011#line 3031 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
5012{
Chris Lattnerbb856a32007-08-06 21:00:46 +00005013 if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005014 GEN_ERROR("Trying to free nonpointer type " +
Chris Lattnerbb856a32007-08-06 21:00:46 +00005015 yyvsp[0].ValueVal->getType()->getDescription() + "");
5016 yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005017 CHECK_FOR_ERROR
Dale Johannesen3afee192007-09-07 21:07:57 +00005018 ;
5019 break;}
5020case 307:
5021#line 3039 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
5022{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005023 if (!UpRefs.empty())
Chris Lattnerbb856a32007-08-06 21:00:46 +00005024 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
5025 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005026 GEN_ERROR("Can't load from nonpointer type: " +
Chris Lattnerbb856a32007-08-06 21:00:46 +00005027 (*yyvsp[-2].TypeVal)->getDescription());
5028 if (!cast<PointerType>(yyvsp[-2].TypeVal->get())->getElementType()->isFirstClassType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005029 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Chris Lattnerbb856a32007-08-06 21:00:46 +00005030 (*yyvsp[-2].TypeVal)->getDescription());
5031 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005032 CHECK_FOR_ERROR
Chris Lattnerbb856a32007-08-06 21:00:46 +00005033 yyval.InstVal = new LoadInst(tmpVal, "", yyvsp[-4].BoolVal, yyvsp[0].UIntVal);
5034 delete yyvsp[-2].TypeVal;
Dale Johannesen3afee192007-09-07 21:07:57 +00005035 ;
5036 break;}
5037case 308:
5038#line 3053 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
5039{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005040 if (!UpRefs.empty())
Chris Lattnerbb856a32007-08-06 21:00:46 +00005041 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
5042 const PointerType *PT = dyn_cast<PointerType>(yyvsp[-2].TypeVal->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005043 if (!PT)
5044 GEN_ERROR("Can't store to a nonpointer type: " +
Chris Lattnerbb856a32007-08-06 21:00:46 +00005045 (*yyvsp[-2].TypeVal)->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005046 const Type *ElTy = PT->getElementType();
Chris Lattnerbb856a32007-08-06 21:00:46 +00005047 if (ElTy != yyvsp[-4].ValueVal->getType())
5048 GEN_ERROR("Can't store '" + yyvsp[-4].ValueVal->getType()->getDescription() +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005049 "' into space of type '" + ElTy->getDescription() + "'");
5050
Chris Lattnerbb856a32007-08-06 21:00:46 +00005051 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005052 CHECK_FOR_ERROR
Chris Lattnerbb856a32007-08-06 21:00:46 +00005053 yyval.InstVal = new StoreInst(yyvsp[-4].ValueVal, tmpVal, yyvsp[-6].BoolVal, yyvsp[0].UIntVal);
5054 delete yyvsp[-2].TypeVal;
Dale Johannesen3afee192007-09-07 21:07:57 +00005055 ;
5056 break;}
5057case 309:
5058#line 3070 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
5059{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005060 if (!UpRefs.empty())
Chris Lattnerbb856a32007-08-06 21:00:46 +00005061 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
5062 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005063 GEN_ERROR("getelementptr insn requires pointer operand");
5064
David Greene48556392007-09-04 18:46:50 +00005065 if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end(), true))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005066 GEN_ERROR("Invalid getelementptr indices for type '" +
Chris Lattnerbb856a32007-08-06 21:00:46 +00005067 (*yyvsp[-2].TypeVal)->getDescription()+ "'");
5068 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005069 CHECK_FOR_ERROR
David Greene48556392007-09-04 18:46:50 +00005070 yyval.InstVal = new GetElementPtrInst(tmpVal, yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end());
Chris Lattnerbb856a32007-08-06 21:00:46 +00005071 delete yyvsp[-2].TypeVal;
5072 delete yyvsp[0].ValueList;
Dale Johannesen3afee192007-09-07 21:07:57 +00005073 ;
5074 break;}
5075}
5076 /* the action file gets copied in in place of this dollarsign */
5077#line 543 "/usr/share/bison.simple"
Chris Lattnerbb856a32007-08-06 21:00:46 +00005078
5079 yyvsp -= yylen;
5080 yyssp -= yylen;
Dale Johannesen3afee192007-09-07 21:07:57 +00005081#ifdef YYLSP_NEEDED
5082 yylsp -= yylen;
5083#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005084
Dale Johannesen3afee192007-09-07 21:07:57 +00005085#if YYDEBUG != 0
5086 if (yydebug)
5087 {
5088 short *ssp1 = yyss - 1;
5089 fprintf (stderr, "state stack now");
5090 while (ssp1 != yyssp)
5091 fprintf (stderr, " %d", *++ssp1);
5092 fprintf (stderr, "\n");
5093 }
5094#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005095
5096 *++yyvsp = yyval;
5097
Dale Johannesen3afee192007-09-07 21:07:57 +00005098#ifdef YYLSP_NEEDED
5099 yylsp++;
5100 if (yylen == 0)
5101 {
5102 yylsp->first_line = yylloc.first_line;
5103 yylsp->first_column = yylloc.first_column;
5104 yylsp->last_line = (yylsp-1)->last_line;
5105 yylsp->last_column = (yylsp-1)->last_column;
5106 yylsp->text = 0;
5107 }
5108 else
5109 {
5110 yylsp->last_line = (yylsp+yylen-1)->last_line;
5111 yylsp->last_column = (yylsp+yylen-1)->last_column;
5112 }
5113#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005114
Dale Johannesen3afee192007-09-07 21:07:57 +00005115 /* Now "shift" the result of the reduction.
5116 Determine what state that goes to,
5117 based on the state we popped back to
5118 and the rule number reduced by. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005119
5120 yyn = yyr1[yyn];
5121
Dale Johannesen3afee192007-09-07 21:07:57 +00005122 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
5123 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005124 yystate = yytable[yystate];
5125 else
Dale Johannesen3afee192007-09-07 21:07:57 +00005126 yystate = yydefgoto[yyn - YYNTBASE];
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005127
5128 goto yynewstate;
5129
Dale Johannesen3afee192007-09-07 21:07:57 +00005130yyerrlab: /* here on detecting error */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005131
Dale Johannesen3afee192007-09-07 21:07:57 +00005132 if (! yyerrstatus)
5133 /* If not already recovering from an error, report this error. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005134 {
5135 ++yynerrs;
Dale Johannesen3afee192007-09-07 21:07:57 +00005136
5137#ifdef YYERROR_VERBOSE
Chris Lattnerbb856a32007-08-06 21:00:46 +00005138 yyn = yypact[yystate];
5139
Dale Johannesen3afee192007-09-07 21:07:57 +00005140 if (yyn > YYFLAG && yyn < YYLAST)
Chris Lattnerbb856a32007-08-06 21:00:46 +00005141 {
Dale Johannesen3afee192007-09-07 21:07:57 +00005142 int size = 0;
5143 char *msg;
5144 int x, count;
Chris Lattnerbb856a32007-08-06 21:00:46 +00005145
Dale Johannesen3afee192007-09-07 21:07:57 +00005146 count = 0;
5147 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
5148 for (x = (yyn < 0 ? -yyn : 0);
5149 x < (sizeof(yytname) / sizeof(char *)); x++)
5150 if (yycheck[x + yyn] == x)
5151 size += strlen(yytname[x]) + 15, count++;
5152 msg = (char *) malloc(size + 15);
5153 if (msg != 0)
Chris Lattnerbb856a32007-08-06 21:00:46 +00005154 {
Dale Johannesen3afee192007-09-07 21:07:57 +00005155 strcpy(msg, "parse error");
Chris Lattnerbb856a32007-08-06 21:00:46 +00005156
Dale Johannesen3afee192007-09-07 21:07:57 +00005157 if (count < 5)
Chris Lattnerbb856a32007-08-06 21:00:46 +00005158 {
Dale Johannesen3afee192007-09-07 21:07:57 +00005159 count = 0;
5160 for (x = (yyn < 0 ? -yyn : 0);
5161 x < (sizeof(yytname) / sizeof(char *)); x++)
5162 if (yycheck[x + yyn] == x)
Chris Lattnerbb856a32007-08-06 21:00:46 +00005163 {
Dale Johannesen3afee192007-09-07 21:07:57 +00005164 strcat(msg, count == 0 ? ", expecting `" : " or `");
5165 strcat(msg, yytname[x]);
5166 strcat(msg, "'");
5167 count++;
Chris Lattnerbb856a32007-08-06 21:00:46 +00005168 }
5169 }
Dale Johannesen3afee192007-09-07 21:07:57 +00005170 yyerror(msg);
5171 free(msg);
Chris Lattnerbb856a32007-08-06 21:00:46 +00005172 }
5173 else
Dale Johannesen3afee192007-09-07 21:07:57 +00005174 yyerror ("parse error; also virtual memory exceeded");
Chris Lattnerbb856a32007-08-06 21:00:46 +00005175 }
5176 else
5177#endif /* YYERROR_VERBOSE */
Dale Johannesen3afee192007-09-07 21:07:57 +00005178 yyerror("parse error");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005179 }
5180
Dale Johannesen3afee192007-09-07 21:07:57 +00005181 goto yyerrlab1;
5182yyerrlab1: /* here on error raised explicitly by an action */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005183
5184 if (yyerrstatus == 3)
5185 {
Dale Johannesen3afee192007-09-07 21:07:57 +00005186 /* if just tried and failed to reuse lookahead token after an error, discard it. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005187
Dale Johannesen3afee192007-09-07 21:07:57 +00005188 /* return failure if at end of input */
5189 if (yychar == YYEOF)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005190 YYABORT;
5191
Dale Johannesen3afee192007-09-07 21:07:57 +00005192#if YYDEBUG != 0
5193 if (yydebug)
5194 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
5195#endif
5196
5197 yychar = YYEMPTY;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005198 }
5199
Dale Johannesen3afee192007-09-07 21:07:57 +00005200 /* Else will try to reuse lookahead token
5201 after shifting the error token. */
5202
5203 yyerrstatus = 3; /* Each real token shifted decrements this */
5204
5205 goto yyerrhandle;
5206
5207yyerrdefault: /* current state does not do anything special for the error token. */
5208
5209#if 0
5210 /* This is wrong; only states that explicitly want error tokens
5211 should shift them. */
5212 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
5213 if (yyn) goto yydefault;
5214#endif
5215
5216yyerrpop: /* pop the current state because it cannot handle the error token */
5217
5218 if (yyssp == yyss) YYABORT;
5219 yyvsp--;
5220 yystate = *--yyssp;
5221#ifdef YYLSP_NEEDED
5222 yylsp--;
5223#endif
5224
5225#if YYDEBUG != 0
5226 if (yydebug)
5227 {
5228 short *ssp1 = yyss - 1;
5229 fprintf (stderr, "Error: state stack now");
5230 while (ssp1 != yyssp)
5231 fprintf (stderr, " %d", *++ssp1);
5232 fprintf (stderr, "\n");
5233 }
5234#endif
5235
5236yyerrhandle:
5237
5238 yyn = yypact[yystate];
5239 if (yyn == YYFLAG)
5240 goto yyerrdefault;
5241
5242 yyn += YYTERROR;
5243 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
5244 goto yyerrdefault;
5245
5246 yyn = yytable[yyn];
5247 if (yyn < 0)
5248 {
5249 if (yyn == YYFLAG)
5250 goto yyerrpop;
5251 yyn = -yyn;
5252 goto yyreduce;
5253 }
5254 else if (yyn == 0)
5255 goto yyerrpop;
5256
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005257 if (yyn == YYFINAL)
5258 YYACCEPT;
5259
Dale Johannesen3afee192007-09-07 21:07:57 +00005260#if YYDEBUG != 0
5261 if (yydebug)
5262 fprintf(stderr, "Shifting error token, ");
5263#endif
Chris Lattnerbb856a32007-08-06 21:00:46 +00005264
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005265 *++yyvsp = yylval;
Dale Johannesen3afee192007-09-07 21:07:57 +00005266#ifdef YYLSP_NEEDED
5267 *++yylsp = yylloc;
5268#endif
Reid Spenceraa8ae282007-07-31 03:50:36 +00005269
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005270 yystate = yyn;
5271 goto yynewstate;
5272
Dale Johannesen3afee192007-09-07 21:07:57 +00005273 yyacceptlab:
5274 /* YYACCEPT comes here. */
5275 if (yyfree_stacks)
5276 {
5277 free (yyss);
5278 free (yyvs);
5279#ifdef YYLSP_NEEDED
5280 free (yyls);
Chandler Carruth563d4a42007-08-04 01:56:21 +00005281#endif
Dale Johannesen3afee192007-09-07 21:07:57 +00005282 }
5283 return 0;
David Greene48556392007-09-04 18:46:50 +00005284
Dale Johannesen3afee192007-09-07 21:07:57 +00005285 yyabortlab:
5286 /* YYABORT comes here. */
5287 if (yyfree_stacks)
5288 {
5289 free (yyss);
5290 free (yyvs);
5291#ifdef YYLSP_NEEDED
5292 free (yyls);
David Greene48556392007-09-04 18:46:50 +00005293#endif
Dale Johannesen3afee192007-09-07 21:07:57 +00005294 }
5295 return 1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005296}
Dale Johannesen3afee192007-09-07 21:07:57 +00005297#line 3087 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005298
5299
5300// common code from the two 'RunVMAsmParser' functions
5301static Module* RunParser(Module * M) {
5302
5303 llvmAsmlineno = 1; // Reset the current line number...
5304 CurModule.CurrentModule = M;
5305#if YYDEBUG
5306 yydebug = Debug;
5307#endif
5308
5309 // Check to make sure the parser succeeded
5310 if (yyparse()) {
5311 if (ParserResult)
5312 delete ParserResult;
5313 return 0;
5314 }
5315
5316 // Emit an error if there are any unresolved types left.
5317 if (!CurModule.LateResolveTypes.empty()) {
5318 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
5319 if (DID.Type == ValID::LocalName) {
5320 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
5321 } else {
5322 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
5323 }
5324 if (ParserResult)
5325 delete ParserResult;
5326 return 0;
5327 }
5328
5329 // Emit an error if there are any unresolved values left.
5330 if (!CurModule.LateResolveValues.empty()) {
5331 Value *V = CurModule.LateResolveValues.back();
5332 std::map<Value*, std::pair<ValID, int> >::iterator I =
5333 CurModule.PlaceHolderInfo.find(V);
5334
5335 if (I != CurModule.PlaceHolderInfo.end()) {
5336 ValID &DID = I->second.first;
5337 if (DID.Type == ValID::LocalName) {
5338 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
5339 } else {
5340 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
5341 }
5342 if (ParserResult)
5343 delete ParserResult;
5344 return 0;
5345 }
5346 }
5347
5348 // Check to make sure that parsing produced a result
5349 if (!ParserResult)
5350 return 0;
5351
5352 // Reset ParserResult variable while saving its value for the result.
5353 Module *Result = ParserResult;
5354 ParserResult = 0;
5355
5356 return Result;
5357}
5358
5359void llvm::GenerateError(const std::string &message, int LineNo) {
5360 if (LineNo == -1) LineNo = llvmAsmlineno;
5361 // TODO: column number in exception
5362 if (TheParseError)
5363 TheParseError->setError(CurFilename, message, LineNo);
5364 TriggerError = 1;
5365}
5366
5367int yyerror(const char *ErrorMsg) {
5368 std::string where
5369 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
5370 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
5371 std::string errMsg = where + "error: " + std::string(ErrorMsg);
5372 if (yychar != YYEMPTY && yychar != 0)
5373 errMsg += " while reading token: '" + std::string(llvmAsmtext, llvmAsmleng)+
5374 "'";
5375 GenerateError(errMsg);
5376 return 0;
5377}