blob: e6e58db1b06b1a87d91cf4922492945c7e94a658 [file] [log] [blame]
Reid Spencer68a24bd2005-08-27 18:50:39 +00001
Chris Lattnerd5efe842006-04-08 01:18:56 +00002/* A Bison parser, made from /Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y
Chris Lattner8335e842006-01-23 23:05:42 +00003 by GNU Bison version 1.28 */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004
Chris Lattner8335e842006-01-23 23:05:42 +00005#define YYBISON 1 /* Identify Bison output. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00006
Reid Spencer68a24bd2005-08-27 18:50:39 +00007#define yyparse llvmAsmparse
Chris Lattner8335e842006-01-23 23:05:42 +00008#define yylex llvmAsmlex
Reid Spencer68a24bd2005-08-27 18:50:39 +00009#define yyerror llvmAsmerror
Chris Lattner8335e842006-01-23 23:05:42 +000010#define yylval llvmAsmlval
11#define yychar llvmAsmchar
Reid Spencer68a24bd2005-08-27 18:50:39 +000012#define yydebug llvmAsmdebug
13#define yynerrs llvmAsmnerrs
Chris Lattner8335e842006-01-23 23:05:42 +000014#define ESINT64VAL 257
15#define EUINT64VAL 258
16#define SINTVAL 259
17#define UINTVAL 260
18#define FPVAL 261
19#define VOID 262
20#define BOOL 263
21#define SBYTE 264
22#define UBYTE 265
23#define SHORT 266
24#define USHORT 267
25#define INT 268
26#define UINT 269
27#define LONG 270
28#define ULONG 271
29#define FLOAT 272
30#define DOUBLE 273
31#define TYPE 274
32#define LABEL 275
33#define VAR_ID 276
34#define LABELSTR 277
35#define STRINGCONSTANT 278
36#define IMPLEMENTATION 279
37#define ZEROINITIALIZER 280
38#define TRUETOK 281
39#define FALSETOK 282
40#define BEGINTOK 283
41#define ENDTOK 284
42#define DECLARE 285
43#define GLOBAL 286
44#define CONSTANT 287
45#define SECTION 288
46#define VOLATILE 289
47#define TO 290
48#define DOTDOTDOT 291
49#define NULL_TOK 292
50#define UNDEF 293
51#define CONST 294
52#define INTERNAL 295
53#define LINKONCE 296
54#define WEAK 297
55#define APPENDING 298
56#define OPAQUE 299
57#define NOT 300
58#define EXTERNAL 301
59#define TARGET 302
60#define TRIPLE 303
61#define ENDIAN 304
62#define POINTERSIZE 305
63#define LITTLE 306
64#define BIG 307
65#define ALIGN 308
66#define DEPLIBS 309
67#define CALL 310
68#define TAIL 311
69#define ASM_TOK 312
Chris Lattner66316012006-01-24 04:14:29 +000070#define MODULE 313
Chris Lattner0e9c3762006-01-25 22:27:16 +000071#define SIDEEFFECT 314
72#define CC_TOK 315
73#define CCC_TOK 316
74#define FASTCC_TOK 317
75#define COLDCC_TOK 318
76#define RET 319
77#define BR 320
78#define SWITCH 321
79#define INVOKE 322
80#define UNWIND 323
81#define UNREACHABLE 324
82#define ADD 325
83#define SUB 326
84#define MUL 327
85#define DIV 328
86#define REM 329
87#define AND 330
88#define OR 331
89#define XOR 332
90#define SETLE 333
91#define SETGE 334
92#define SETLT 335
93#define SETGT 336
94#define SETEQ 337
95#define SETNE 338
96#define MALLOC 339
97#define ALLOCA 340
98#define FREE 341
99#define LOAD 342
100#define STORE 343
101#define GETELEMENTPTR 344
102#define PHI_TOK 345
103#define CAST 346
104#define SELECT 347
105#define SHL 348
106#define SHR 349
107#define VAARG 350
108#define EXTRACTELEMENT 351
109#define INSERTELEMENT 352
Chris Lattnerd5efe842006-04-08 01:18:56 +0000110#define SHUFFLEVECTOR 353
111#define VAARG_old 354
112#define VANEXT_old 355
Reid Spencer68a24bd2005-08-27 18:50:39 +0000113
Chris Lattnerd5efe842006-04-08 01:18:56 +0000114#line 14 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000115
116#include "ParserInternals.h"
117#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000118#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000119#include "llvm/Instructions.h"
120#include "llvm/Module.h"
121#include "llvm/SymbolTable.h"
Reid Spencer0b118202006-01-16 21:12:35 +0000122#include "llvm/Assembly/AutoUpgrade.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000123#include "llvm/Support/GetElementPtrTypeIterator.h"
124#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000125#include "llvm/Support/MathExtras.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000126#include <algorithm>
127#include <iostream>
128#include <list>
129#include <utility>
130
131int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
132int yylex(); // declaration" of xxx warnings.
133int yyparse();
134
135namespace llvm {
136 std::string CurFilename;
137}
138using namespace llvm;
139
140static Module *ParserResult;
141
142// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
143// relating to upreferences in the input stream.
144//
145//#define DEBUG_UPREFS 1
146#ifdef DEBUG_UPREFS
147#define UR_OUT(X) std::cerr << X
148#else
149#define UR_OUT(X)
150#endif
151
152#define YYERROR_VERBOSE 1
153
154static bool ObsoleteVarArgs;
155static bool NewVarArgs;
Chris Lattnerb475c422005-11-12 18:22:38 +0000156static BasicBlock *CurBB;
157static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000158
159
160// This contains info used when building the body of a function. It is
161// destroyed when the function is completed.
162//
163typedef std::vector<Value *> ValueList; // Numbered defs
164static void
165ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
166 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
167
168static struct PerModuleInfo {
169 Module *CurrentModule;
170 std::map<const Type *, ValueList> Values; // Module level numbered definitions
171 std::map<const Type *,ValueList> LateResolveValues;
172 std::vector<PATypeHolder> Types;
173 std::map<ValID, PATypeHolder> LateResolveTypes;
174
175 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
176 /// how they were referenced and one which line of the input they came from so
177 /// that we can resolve them later and print error messages as appropriate.
178 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
179
180 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
181 // references to global values. Global values may be referenced before they
182 // are defined, and if so, the temporary object that they represent is held
183 // here. This is used for forward references of GlobalValues.
184 //
185 typedef std::map<std::pair<const PointerType *,
186 ValID>, GlobalValue*> GlobalRefsType;
187 GlobalRefsType GlobalRefs;
188
189 void ModuleDone() {
190 // If we could not resolve some functions at function compilation time
191 // (calls to functions before they are defined), resolve them now... Types
192 // are resolved when the constant pool has been completely parsed.
193 //
194 ResolveDefinitions(LateResolveValues);
195
196 // Check to make sure that all global value forward references have been
197 // resolved!
198 //
199 if (!GlobalRefs.empty()) {
200 std::string UndefinedReferences = "Unresolved global references exist:\n";
201
202 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
203 I != E; ++I) {
204 UndefinedReferences += " " + I->first.first->getDescription() + " " +
205 I->first.second.getName() + "\n";
206 }
207 ThrowException(UndefinedReferences);
208 }
209
Reid Spencere812fb22006-01-19 01:21:04 +0000210 // Look for intrinsic functions and CallInst that need to be upgraded
Chris Lattnerd5efe842006-04-08 01:18:56 +0000211 for (Module::iterator FI = CurrentModule->begin(),
212 FE = CurrentModule->end(); FI != FE; )
Chris Lattnerc2c60382006-03-04 07:53:41 +0000213 UpgradeCallsToIntrinsic(FI++);
Reid Spencer0b118202006-01-16 21:12:35 +0000214
Reid Spencer68a24bd2005-08-27 18:50:39 +0000215 Values.clear(); // Clear out function local definitions
216 Types.clear();
217 CurrentModule = 0;
218 }
219
Reid Spencer68a24bd2005-08-27 18:50:39 +0000220 // GetForwardRefForGlobal - Check to see if there is a forward reference
221 // for this global. If so, remove it from the GlobalRefs map and return it.
222 // If not, just return null.
223 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
224 // Check to see if there is a forward reference to this global variable...
225 // if there is, eliminate it and patch the reference to use the new def'n.
226 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
227 GlobalValue *Ret = 0;
228 if (I != GlobalRefs.end()) {
229 Ret = I->second;
230 GlobalRefs.erase(I);
231 }
232 return Ret;
233 }
234} CurModule;
235
236static struct PerFunctionInfo {
237 Function *CurrentFunction; // Pointer to current function being created
238
239 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
240 std::map<const Type*, ValueList> LateResolveValues;
241 bool isDeclare; // Is this function a forward declararation?
242
243 /// BBForwardRefs - When we see forward references to basic blocks, keep
244 /// track of them here.
245 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
246 std::vector<BasicBlock*> NumberedBlocks;
247 unsigned NextBBNum;
248
249 inline PerFunctionInfo() {
250 CurrentFunction = 0;
251 isDeclare = false;
252 }
253
254 inline void FunctionStart(Function *M) {
255 CurrentFunction = M;
256 NextBBNum = 0;
257 }
258
259 void FunctionDone() {
260 NumberedBlocks.clear();
261
262 // Any forward referenced blocks left?
263 if (!BBForwardRefs.empty())
264 ThrowException("Undefined reference to label " +
265 BBForwardRefs.begin()->first->getName());
266
267 // Resolve all forward references now.
268 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
269
270 Values.clear(); // Clear out function local definitions
271 CurrentFunction = 0;
272 isDeclare = false;
273 }
274} CurFun; // Info for the current function...
275
276static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
277
278
279//===----------------------------------------------------------------------===//
280// Code to handle definitions of all the types
281//===----------------------------------------------------------------------===//
282
283static int InsertValue(Value *V,
284 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
285 if (V->hasName()) return -1; // Is this a numbered definition?
286
287 // Yes, insert the value into the value table...
288 ValueList &List = ValueTab[V->getType()];
289 List.push_back(V);
290 return List.size()-1;
291}
292
293static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
294 switch (D.Type) {
295 case ValID::NumberVal: // Is it a numbered definition?
296 // Module constants occupy the lowest numbered slots...
297 if ((unsigned)D.Num < CurModule.Types.size())
298 return CurModule.Types[(unsigned)D.Num];
299 break;
300 case ValID::NameVal: // Is it a named definition?
301 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
302 D.destroy(); // Free old strdup'd memory...
303 return N;
304 }
305 break;
306 default:
307 ThrowException("Internal parser error: Invalid symbol type reference!");
308 }
309
310 // If we reached here, we referenced either a symbol that we don't know about
311 // or an id number that hasn't been read yet. We may be referencing something
312 // forward, so just create an entry to be resolved later and get to it...
313 //
314 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
315
316
317 if (inFunctionScope()) {
318 if (D.Type == ValID::NameVal)
319 ThrowException("Reference to an undefined type: '" + D.getName() + "'");
320 else
321 ThrowException("Reference to an undefined type: #" + itostr(D.Num));
322 }
323
324 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
325 if (I != CurModule.LateResolveTypes.end())
326 return I->second;
327
328 Type *Typ = OpaqueType::get();
329 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
330 return Typ;
331 }
332
333static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
334 SymbolTable &SymTab =
335 inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() :
336 CurModule.CurrentModule->getSymbolTable();
337 return SymTab.lookup(Ty, Name);
338}
339
340// getValNonImprovising - Look up the value specified by the provided type and
341// the provided ValID. If the value exists and has already been defined, return
342// it. Otherwise return null.
343//
344static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
345 if (isa<FunctionType>(Ty))
346 ThrowException("Functions are not values and "
347 "must be referenced as pointers");
348
349 switch (D.Type) {
350 case ValID::NumberVal: { // Is it a numbered definition?
351 unsigned Num = (unsigned)D.Num;
352
353 // Module constants occupy the lowest numbered slots...
354 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
355 if (VI != CurModule.Values.end()) {
356 if (Num < VI->second.size())
357 return VI->second[Num];
358 Num -= VI->second.size();
359 }
360
361 // Make sure that our type is within bounds
362 VI = CurFun.Values.find(Ty);
363 if (VI == CurFun.Values.end()) return 0;
364
365 // Check that the number is within bounds...
366 if (VI->second.size() <= Num) return 0;
367
368 return VI->second[Num];
369 }
370
371 case ValID::NameVal: { // Is it a named definition?
372 Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
373 if (N == 0) return 0;
374
375 D.destroy(); // Free old strdup'd memory...
376 return N;
377 }
378
379 // Check to make sure that "Ty" is an integral type, and that our
380 // value will fit into the specified type...
381 case ValID::ConstSIntVal: // Is it a constant pool reference??
382 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64))
383 ThrowException("Signed integral constant '" +
384 itostr(D.ConstPool64) + "' is invalid for type '" +
385 Ty->getDescription() + "'!");
386 return ConstantSInt::get(Ty, D.ConstPool64);
387
388 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
389 if (!ConstantUInt::isValueValidForType(Ty, D.UConstPool64)) {
390 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) {
391 ThrowException("Integral constant '" + utostr(D.UConstPool64) +
392 "' is invalid or out of range!");
393 } else { // This is really a signed reference. Transmogrify.
394 return ConstantSInt::get(Ty, D.ConstPool64);
395 }
396 } else {
397 return ConstantUInt::get(Ty, D.UConstPool64);
398 }
399
400 case ValID::ConstFPVal: // Is it a floating point const pool reference?
401 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
402 ThrowException("FP constant invalid for type!!");
403 return ConstantFP::get(Ty, D.ConstPoolFP);
404
405 case ValID::ConstNullVal: // Is it a null value?
406 if (!isa<PointerType>(Ty))
407 ThrowException("Cannot create a a non pointer null!");
408 return ConstantPointerNull::get(cast<PointerType>(Ty));
409
410 case ValID::ConstUndefVal: // Is it an undef value?
411 return UndefValue::get(Ty);
412
Chris Lattner7aa61892005-12-21 17:53:23 +0000413 case ValID::ConstZeroVal: // Is it a zero value?
414 return Constant::getNullValue(Ty);
415
Reid Spencer68a24bd2005-08-27 18:50:39 +0000416 case ValID::ConstantVal: // Fully resolved constant?
417 if (D.ConstantValue->getType() != Ty)
418 ThrowException("Constant expression type different from required type!");
419 return D.ConstantValue;
420
Chris Lattner0e9c3762006-01-25 22:27:16 +0000421 case ValID::InlineAsmVal: { // Inline asm expression
422 const PointerType *PTy = dyn_cast<PointerType>(Ty);
423 const FunctionType *FTy =
424 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
425 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints))
426 ThrowException("Invalid type for asm constraint string!");
427 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
428 D.IAD->HasSideEffects);
429 D.destroy(); // Free InlineAsmDescriptor.
430 return IA;
431 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000432 default:
433 assert(0 && "Unhandled case!");
434 return 0;
435 } // End of switch
436
437 assert(0 && "Unhandled case!");
438 return 0;
439}
440
441// getVal - This function is identical to getValNonImprovising, except that if a
442// value is not already defined, it "improvises" by creating a placeholder var
443// that looks and acts just like the requested variable. When the value is
444// defined later, all uses of the placeholder variable are replaced with the
445// real thing.
446//
447static Value *getVal(const Type *Ty, const ValID &ID) {
448 if (Ty == Type::LabelTy)
449 ThrowException("Cannot use a basic block here");
450
451 // See if the value has already been defined.
452 Value *V = getValNonImprovising(Ty, ID);
453 if (V) return V;
454
455 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
456 ThrowException("Invalid use of a composite type!");
457
458 // If we reached here, we referenced either a symbol that we don't know about
459 // or an id number that hasn't been read yet. We may be referencing something
460 // forward, so just create an entry to be resolved later and get to it...
461 //
462 V = new Argument(Ty);
463
464 // Remember where this forward reference came from. FIXME, shouldn't we try
465 // to recycle these things??
466 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
467 llvmAsmlineno)));
468
469 if (inFunctionScope())
470 InsertValue(V, CurFun.LateResolveValues);
471 else
472 InsertValue(V, CurModule.LateResolveValues);
473 return V;
474}
475
476/// getBBVal - This is used for two purposes:
477/// * If isDefinition is true, a new basic block with the specified ID is being
478/// defined.
479/// * If isDefinition is true, this is a reference to a basic block, which may
480/// or may not be a forward reference.
481///
482static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
483 assert(inFunctionScope() && "Can't get basic block at global scope!");
484
485 std::string Name;
486 BasicBlock *BB = 0;
487 switch (ID.Type) {
488 default: ThrowException("Illegal label reference " + ID.getName());
489 case ValID::NumberVal: // Is it a numbered definition?
490 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
491 CurFun.NumberedBlocks.resize(ID.Num+1);
492 BB = CurFun.NumberedBlocks[ID.Num];
493 break;
494 case ValID::NameVal: // Is it a named definition?
495 Name = ID.Name;
496 if (Value *N = CurFun.CurrentFunction->
497 getSymbolTable().lookup(Type::LabelTy, Name))
498 BB = cast<BasicBlock>(N);
499 break;
500 }
501
502 // See if the block has already been defined.
503 if (BB) {
504 // If this is the definition of the block, make sure the existing value was
505 // just a forward reference. If it was a forward reference, there will be
506 // an entry for it in the PlaceHolderInfo map.
507 if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
508 // The existing value was a definition, not a forward reference.
509 ThrowException("Redefinition of label " + ID.getName());
510
511 ID.destroy(); // Free strdup'd memory.
512 return BB;
513 }
514
515 // Otherwise this block has not been seen before.
516 BB = new BasicBlock("", CurFun.CurrentFunction);
517 if (ID.Type == ValID::NameVal) {
518 BB->setName(ID.Name);
519 } else {
520 CurFun.NumberedBlocks[ID.Num] = BB;
521 }
522
523 // If this is not a definition, keep track of it so we can use it as a forward
524 // reference.
525 if (!isDefinition) {
526 // Remember where this forward reference came from.
527 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
528 } else {
529 // The forward declaration could have been inserted anywhere in the
530 // function: insert it into the correct place now.
531 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
532 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
533 }
534 ID.destroy();
535 return BB;
536}
537
538
539//===----------------------------------------------------------------------===//
540// Code to handle forward references in instructions
541//===----------------------------------------------------------------------===//
542//
543// This code handles the late binding needed with statements that reference
544// values not defined yet... for example, a forward branch, or the PHI node for
545// a loop body.
546//
547// This keeps a table (CurFun.LateResolveValues) of all such forward references
548// and back patchs after we are done.
549//
550
551// ResolveDefinitions - If we could not resolve some defs at parsing
552// time (forward branches, phi functions for loops, etc...) resolve the
553// defs now...
554//
555static void
556ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
557 std::map<const Type*,ValueList> *FutureLateResolvers) {
558 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
559 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
560 E = LateResolvers.end(); LRI != E; ++LRI) {
561 ValueList &List = LRI->second;
562 while (!List.empty()) {
563 Value *V = List.back();
564 List.pop_back();
565
566 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
567 CurModule.PlaceHolderInfo.find(V);
568 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
569
570 ValID &DID = PHI->second.first;
571
572 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
573 if (TheRealValue) {
574 V->replaceAllUsesWith(TheRealValue);
575 delete V;
576 CurModule.PlaceHolderInfo.erase(PHI);
577 } else if (FutureLateResolvers) {
578 // Functions have their unresolved items forwarded to the module late
579 // resolver table
580 InsertValue(V, *FutureLateResolvers);
581 } else {
582 if (DID.Type == ValID::NameVal)
583 ThrowException("Reference to an invalid definition: '" +DID.getName()+
584 "' of type '" + V->getType()->getDescription() + "'",
585 PHI->second.second);
586 else
587 ThrowException("Reference to an invalid definition: #" +
588 itostr(DID.Num) + " of type '" +
589 V->getType()->getDescription() + "'",
590 PHI->second.second);
591 }
592 }
593 }
594
595 LateResolvers.clear();
596}
597
598// ResolveTypeTo - A brand new type was just declared. This means that (if
599// name is not null) things referencing Name can be resolved. Otherwise, things
600// refering to the number can be resolved. Do this now.
601//
602static void ResolveTypeTo(char *Name, const Type *ToTy) {
603 ValID D;
604 if (Name) D = ValID::create(Name);
605 else D = ValID::create((int)CurModule.Types.size());
606
607 std::map<ValID, PATypeHolder>::iterator I =
608 CurModule.LateResolveTypes.find(D);
609 if (I != CurModule.LateResolveTypes.end()) {
610 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
611 CurModule.LateResolveTypes.erase(I);
612 }
613}
614
615// setValueName - Set the specified value to the name given. The name may be
616// null potentially, in which case this is a noop. The string passed in is
617// assumed to be a malloc'd string buffer, and is free'd by this function.
618//
619static void setValueName(Value *V, char *NameStr) {
620 if (NameStr) {
621 std::string Name(NameStr); // Copy string
622 free(NameStr); // Free old string
623
624 if (V->getType() == Type::VoidTy)
625 ThrowException("Can't assign name '" + Name+"' to value with void type!");
626
627 assert(inFunctionScope() && "Must be in function scope!");
628 SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable();
629 if (ST.lookup(V->getType(), Name))
630 ThrowException("Redefinition of value named '" + Name + "' in the '" +
631 V->getType()->getDescription() + "' type plane!");
632
633 // Set the name.
634 V->setName(Name);
635 }
636}
637
638/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
639/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +0000640static GlobalVariable *
641ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
642 bool isConstantGlobal, const Type *Ty,
643 Constant *Initializer) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000644 if (isa<FunctionType>(Ty))
645 ThrowException("Cannot declare global vars of function type!");
646
647 const PointerType *PTy = PointerType::get(Ty);
648
649 std::string Name;
650 if (NameStr) {
651 Name = NameStr; // Copy string
652 free(NameStr); // Free old string
653 }
654
655 // See if this global value was forward referenced. If so, recycle the
656 // object.
657 ValID ID;
658 if (!Name.empty()) {
659 ID = ValID::create((char*)Name.c_str());
660 } else {
661 ID = ValID::create((int)CurModule.Values[PTy].size());
662 }
663
664 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
665 // Move the global to the end of the list, from whereever it was
666 // previously inserted.
667 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
668 CurModule.CurrentModule->getGlobalList().remove(GV);
669 CurModule.CurrentModule->getGlobalList().push_back(GV);
670 GV->setInitializer(Initializer);
671 GV->setLinkage(Linkage);
672 GV->setConstant(isConstantGlobal);
673 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000674 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000675 }
676
677 // If this global has a name, check to see if there is already a definition
678 // of this global in the module. If so, merge as appropriate. Note that
679 // this is really just a hack around problems in the CFE. :(
680 if (!Name.empty()) {
681 // We are a simple redefinition of a value, check to see if it is defined
682 // the same as the old one.
683 if (GlobalVariable *EGV =
684 CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
685 // We are allowed to redefine a global variable in two circumstances:
686 // 1. If at least one of the globals is uninitialized or
687 // 2. If both initializers have the same value.
688 //
689 if (!EGV->hasInitializer() || !Initializer ||
690 EGV->getInitializer() == Initializer) {
691
692 // Make sure the existing global version gets the initializer! Make
693 // sure that it also gets marked const if the new version is.
694 if (Initializer && !EGV->hasInitializer())
695 EGV->setInitializer(Initializer);
696 if (isConstantGlobal)
697 EGV->setConstant(true);
698 EGV->setLinkage(Linkage);
Chris Lattnerb475c422005-11-12 18:22:38 +0000699 return EGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000700 }
701
702 ThrowException("Redefinition of global variable named '" + Name +
703 "' in the '" + Ty->getDescription() + "' type plane!");
704 }
705 }
706
707 // Otherwise there is no existing GV to use, create one now.
708 GlobalVariable *GV =
709 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
710 CurModule.CurrentModule);
711 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000712 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000713}
714
715// setTypeName - Set the specified type to the name given. The name may be
716// null potentially, in which case this is a noop. The string passed in is
717// assumed to be a malloc'd string buffer, and is freed by this function.
718//
719// This function returns true if the type has already been defined, but is
720// allowed to be redefined in the specified context. If the name is a new name
721// for the type plane, it is inserted and false is returned.
722static bool setTypeName(const Type *T, char *NameStr) {
723 assert(!inFunctionScope() && "Can't give types function-local names!");
724 if (NameStr == 0) return false;
725
726 std::string Name(NameStr); // Copy string
727 free(NameStr); // Free old string
728
729 // We don't allow assigning names to void type
730 if (T == Type::VoidTy)
731 ThrowException("Can't assign name '" + Name + "' to the void type!");
732
733 // Set the type name, checking for conflicts as we do so.
734 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
735
736 if (AlreadyExists) { // Inserting a name that is already defined???
737 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
738 assert(Existing && "Conflict but no matching type?");
739
740 // There is only one case where this is allowed: when we are refining an
741 // opaque type. In this case, Existing will be an opaque type.
742 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
743 // We ARE replacing an opaque type!
744 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
745 return true;
746 }
747
748 // Otherwise, this is an attempt to redefine a type. That's okay if
749 // the redefinition is identical to the original. This will be so if
750 // Existing and T point to the same Type object. In this one case we
751 // allow the equivalent redefinition.
752 if (Existing == T) return true; // Yes, it's equal.
753
754 // Any other kind of (non-equivalent) redefinition is an error.
755 ThrowException("Redefinition of type named '" + Name + "' in the '" +
756 T->getDescription() + "' type plane!");
757 }
758
759 return false;
760}
761
762//===----------------------------------------------------------------------===//
763// Code for handling upreferences in type names...
764//
765
766// TypeContains - Returns true if Ty directly contains E in it.
767//
768static bool TypeContains(const Type *Ty, const Type *E) {
769 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
770 E) != Ty->subtype_end();
771}
772
773namespace {
774 struct UpRefRecord {
775 // NestingLevel - The number of nesting levels that need to be popped before
776 // this type is resolved.
777 unsigned NestingLevel;
778
779 // LastContainedTy - This is the type at the current binding level for the
780 // type. Every time we reduce the nesting level, this gets updated.
781 const Type *LastContainedTy;
782
783 // UpRefTy - This is the actual opaque type that the upreference is
784 // represented with.
785 OpaqueType *UpRefTy;
786
787 UpRefRecord(unsigned NL, OpaqueType *URTy)
788 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
789 };
790}
791
792// UpRefs - A list of the outstanding upreferences that need to be resolved.
793static std::vector<UpRefRecord> UpRefs;
794
795/// HandleUpRefs - Every time we finish a new layer of types, this function is
796/// called. It loops through the UpRefs vector, which is a list of the
797/// currently active types. For each type, if the up reference is contained in
798/// the newly completed type, we decrement the level count. When the level
799/// count reaches zero, the upreferenced type is the type that is passed in:
800/// thus we can complete the cycle.
801///
802static PATypeHolder HandleUpRefs(const Type *ty) {
803 if (!ty->isAbstract()) return ty;
804 PATypeHolder Ty(ty);
805 UR_OUT("Type '" << Ty->getDescription() <<
806 "' newly formed. Resolving upreferences.\n" <<
807 UpRefs.size() << " upreferences active!\n");
808
809 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
810 // to zero), we resolve them all together before we resolve them to Ty. At
811 // the end of the loop, if there is anything to resolve to Ty, it will be in
812 // this variable.
813 OpaqueType *TypeToResolve = 0;
814
815 for (unsigned i = 0; i != UpRefs.size(); ++i) {
816 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
817 << UpRefs[i].second->getDescription() << ") = "
818 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
819 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
820 // Decrement level of upreference
821 unsigned Level = --UpRefs[i].NestingLevel;
822 UpRefs[i].LastContainedTy = Ty;
823 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
824 if (Level == 0) { // Upreference should be resolved!
825 if (!TypeToResolve) {
826 TypeToResolve = UpRefs[i].UpRefTy;
827 } else {
828 UR_OUT(" * Resolving upreference for "
829 << UpRefs[i].second->getDescription() << "\n";
830 std::string OldName = UpRefs[i].UpRefTy->getDescription());
831 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
832 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
833 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
834 }
835 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
836 --i; // Do not skip the next element...
837 }
838 }
839 }
840
841 if (TypeToResolve) {
842 UR_OUT(" * Resolving upreference for "
843 << UpRefs[i].second->getDescription() << "\n";
844 std::string OldName = TypeToResolve->getDescription());
845 TypeToResolve->refineAbstractTypeTo(Ty);
846 }
847
848 return Ty;
849}
850
851
852// common code from the two 'RunVMAsmParser' functions
853 static Module * RunParser(Module * M) {
854
855 llvmAsmlineno = 1; // Reset the current line number...
856 ObsoleteVarArgs = false;
857 NewVarArgs = false;
858
859 CurModule.CurrentModule = M;
860 yyparse(); // Parse the file, potentially throwing exception
861
862 Module *Result = ParserResult;
863 ParserResult = 0;
864
865 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
866 {
867 Function* F;
868 if ((F = Result->getNamedFunction("llvm.va_start"))
869 && F->getFunctionType()->getNumParams() == 0)
870 ObsoleteVarArgs = true;
871 if((F = Result->getNamedFunction("llvm.va_copy"))
872 && F->getFunctionType()->getNumParams() == 1)
873 ObsoleteVarArgs = true;
874 }
875
876 if (ObsoleteVarArgs && NewVarArgs)
877 ThrowException("This file is corrupt: it uses both new and old style varargs");
878
879 if(ObsoleteVarArgs) {
880 if(Function* F = Result->getNamedFunction("llvm.va_start")) {
881 if (F->arg_size() != 0)
882 ThrowException("Obsolete va_start takes 0 argument!");
883
884 //foo = va_start()
885 // ->
886 //bar = alloca typeof(foo)
887 //va_start(bar)
888 //foo = load bar
889
890 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
891 const Type* ArgTy = F->getFunctionType()->getReturnType();
892 const Type* ArgTyPtr = PointerType::get(ArgTy);
893 Function* NF = Result->getOrInsertFunction("llvm.va_start",
Jeff Cohen66c5fd62005-10-23 04:37:20 +0000894 RetTy, ArgTyPtr, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000895
896 while (!F->use_empty()) {
897 CallInst* CI = cast<CallInst>(F->use_back());
898 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
899 new CallInst(NF, bar, "", CI);
900 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
901 CI->replaceAllUsesWith(foo);
902 CI->getParent()->getInstList().erase(CI);
903 }
904 Result->getFunctionList().erase(F);
905 }
906
907 if(Function* F = Result->getNamedFunction("llvm.va_end")) {
908 if(F->arg_size() != 1)
909 ThrowException("Obsolete va_end takes 1 argument!");
910
911 //vaend foo
912 // ->
913 //bar = alloca 1 of typeof(foo)
914 //vaend bar
915 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
916 const Type* ArgTy = F->getFunctionType()->getParamType(0);
917 const Type* ArgTyPtr = PointerType::get(ArgTy);
918 Function* NF = Result->getOrInsertFunction("llvm.va_end",
Jeff Cohen66c5fd62005-10-23 04:37:20 +0000919 RetTy, ArgTyPtr, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000920
921 while (!F->use_empty()) {
922 CallInst* CI = cast<CallInst>(F->use_back());
923 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
924 new StoreInst(CI->getOperand(1), bar, CI);
925 new CallInst(NF, bar, "", CI);
926 CI->getParent()->getInstList().erase(CI);
927 }
928 Result->getFunctionList().erase(F);
929 }
930
931 if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
932 if(F->arg_size() != 1)
933 ThrowException("Obsolete va_copy takes 1 argument!");
934 //foo = vacopy(bar)
935 // ->
936 //a = alloca 1 of typeof(foo)
937 //b = alloca 1 of typeof(foo)
938 //store bar -> b
939 //vacopy(a, b)
940 //foo = load a
941
942 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
943 const Type* ArgTy = F->getFunctionType()->getReturnType();
944 const Type* ArgTyPtr = PointerType::get(ArgTy);
945 Function* NF = Result->getOrInsertFunction("llvm.va_copy",
Jeff Cohen66c5fd62005-10-23 04:37:20 +0000946 RetTy, ArgTyPtr, ArgTyPtr,
947 (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000948
949 while (!F->use_empty()) {
950 CallInst* CI = cast<CallInst>(F->use_back());
951 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
952 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
953 new StoreInst(CI->getOperand(1), b, CI);
954 new CallInst(NF, a, b, "", CI);
955 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
956 CI->replaceAllUsesWith(foo);
957 CI->getParent()->getInstList().erase(CI);
958 }
959 Result->getFunctionList().erase(F);
960 }
961 }
962
963 return Result;
964
965 }
966
967//===----------------------------------------------------------------------===//
968// RunVMAsmParser - Define an interface to this parser
969//===----------------------------------------------------------------------===//
970//
971Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
972 set_scan_file(F);
973
974 CurFilename = Filename;
975 return RunParser(new Module(CurFilename));
976}
977
978Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
979 set_scan_string(AsmString);
980
981 CurFilename = "from_memory";
982 if (M == NULL) {
983 return RunParser(new Module (CurFilename));
984 } else {
985 return RunParser(M);
986 }
987}
988
989
Chris Lattnerd5efe842006-04-08 01:18:56 +0000990#line 890 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +0000991typedef union {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000992 llvm::Module *ModuleVal;
993 llvm::Function *FunctionVal;
994 std::pair<llvm::PATypeHolder*, char*> *ArgVal;
995 llvm::BasicBlock *BasicBlockVal;
996 llvm::TerminatorInst *TermInstVal;
997 llvm::Instruction *InstVal;
998 llvm::Constant *ConstVal;
999
1000 const llvm::Type *PrimType;
1001 llvm::PATypeHolder *TypeVal;
1002 llvm::Value *ValueVal;
1003
1004 std::vector<std::pair<llvm::PATypeHolder*,char*> > *ArgList;
1005 std::vector<llvm::Value*> *ValueList;
1006 std::list<llvm::PATypeHolder> *TypeList;
1007 // Represent the RHS of PHI node
1008 std::list<std::pair<llvm::Value*,
1009 llvm::BasicBlock*> > *PHIList;
1010 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1011 std::vector<llvm::Constant*> *ConstVector;
1012
1013 llvm::GlobalValue::LinkageTypes Linkage;
1014 int64_t SInt64Val;
1015 uint64_t UInt64Val;
1016 int SIntVal;
1017 unsigned UIntVal;
1018 double FPVal;
1019 bool BoolVal;
1020
1021 char *StrVal; // This memory is strdup'd!
1022 llvm::ValID ValIDVal; // strdup'd memory maybe!
1023
1024 llvm::Instruction::BinaryOps BinaryOpVal;
1025 llvm::Instruction::TermOps TermOpVal;
1026 llvm::Instruction::MemoryOps MemOpVal;
1027 llvm::Instruction::OtherOps OtherOpVal;
1028 llvm::Module::Endianness Endianness;
1029} YYSTYPE;
Chris Lattner8335e842006-01-23 23:05:42 +00001030#include <stdio.h>
1031
1032#ifndef __cplusplus
1033#ifndef __STDC__
1034#define const
1035#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001036#endif
1037
1038
1039
Chris Lattnerd5efe842006-04-08 01:18:56 +00001040#define YYFINAL 479
Chris Lattner8335e842006-01-23 23:05:42 +00001041#define YYFLAG -32768
Chris Lattnerd5efe842006-04-08 01:18:56 +00001042#define YYNTBASE 116
Reid Spencer68a24bd2005-08-27 18:50:39 +00001043
Chris Lattnerd5efe842006-04-08 01:18:56 +00001044#define YYTRANSLATE(x) ((unsigned)(x) <= 355 ? yytranslate[x] : 187)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001045
Chris Lattner8335e842006-01-23 23:05:42 +00001046static const char yytranslate[] = { 0,
1047 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1048 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1049 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001050 2, 2, 2, 2, 2, 2, 2, 2, 2, 105,
1051 106, 114, 2, 103, 2, 2, 2, 2, 2, 2,
1052 2, 2, 2, 2, 2, 2, 2, 2, 2, 110,
1053 102, 111, 2, 2, 2, 2, 2, 2, 2, 2,
Chris Lattner8335e842006-01-23 23:05:42 +00001054 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1055 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001056 107, 104, 109, 2, 2, 2, 2, 2, 115, 2,
Chris Lattner8335e842006-01-23 23:05:42 +00001057 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001058 2, 2, 2, 2, 2, 2, 2, 2, 2, 108,
1059 2, 2, 112, 2, 113, 2, 2, 2, 2, 2,
Chris Lattner8335e842006-01-23 23:05:42 +00001060 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1061 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1062 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1063 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1064 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1065 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1066 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1067 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1068 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1069 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1070 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1071 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1072 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
1073 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1074 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1075 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
1076 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
1077 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
1078 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1079 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1080 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1081 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001082 97, 98, 99, 100, 101
Chris Lattner8335e842006-01-23 23:05:42 +00001083};
Reid Spencer68a24bd2005-08-27 18:50:39 +00001084
Chris Lattner8335e842006-01-23 23:05:42 +00001085#if YYDEBUG != 0
1086static const short yyprhs[] = { 0,
1087 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
1088 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
1089 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
1090 60, 62, 64, 67, 68, 70, 72, 74, 76, 77,
1091 78, 80, 82, 84, 87, 88, 91, 92, 96, 99,
1092 100, 102, 103, 107, 109, 112, 114, 116, 118, 120,
1093 122, 124, 126, 128, 130, 132, 134, 136, 138, 140,
1094 142, 144, 146, 148, 150, 152, 154, 157, 162, 168,
1095 174, 178, 181, 184, 186, 190, 192, 196, 198, 199,
1096 204, 208, 212, 217, 222, 226, 229, 232, 235, 238,
1097 241, 244, 247, 250, 253, 256, 263, 269, 278, 285,
1098 292, 299, 306, 313, 317, 319, 321, 323, 325, 328,
Chris Lattner66316012006-01-24 04:14:29 +00001099 331, 336, 339, 341, 346, 349, 354, 355, 363, 364,
1100 372, 376, 381, 382, 384, 386, 388, 392, 396, 400,
1101 404, 408, 410, 411, 413, 415, 417, 418, 421, 425,
1102 427, 429, 433, 435, 436, 445, 447, 449, 453, 455,
Chris Lattner0e9c3762006-01-25 22:27:16 +00001103 457, 460, 461, 465, 466, 468, 470, 472, 474, 476,
1104 478, 480, 482, 484, 488, 490, 496, 498, 500, 502,
1105 504, 507, 510, 513, 517, 520, 521, 523, 526, 529,
1106 533, 543, 553, 562, 576, 578, 580, 587, 593, 596,
1107 603, 611, 613, 617, 619, 620, 623, 625, 631, 637,
1108 643, 646, 651, 656, 663, 668, 673, 678, 683, 690,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001109 697, 700, 708, 710, 713, 714, 716, 717, 721, 728,
1110 732, 739, 742, 747, 754
Chris Lattner8335e842006-01-23 23:05:42 +00001111};
Reid Spencer68a24bd2005-08-27 18:50:39 +00001112
Chris Lattner8335e842006-01-23 23:05:42 +00001113static const short yyrhs[] = { 5,
Chris Lattner0e9c3762006-01-25 22:27:16 +00001114 0, 6, 0, 3, 0, 4, 0, 71, 0, 72,
1115 0, 73, 0, 74, 0, 75, 0, 76, 0, 77,
1116 0, 78, 0, 79, 0, 80, 0, 81, 0, 82,
1117 0, 83, 0, 84, 0, 94, 0, 95, 0, 16,
Chris Lattner8335e842006-01-23 23:05:42 +00001118 0, 14, 0, 12, 0, 10, 0, 17, 0, 15,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001119 0, 13, 0, 11, 0, 122, 0, 123, 0, 18,
1120 0, 19, 0, 156, 102, 0, 0, 41, 0, 42,
Chris Lattner0e9c3762006-01-25 22:27:16 +00001121 0, 43, 0, 44, 0, 0, 0, 62, 0, 63,
1122 0, 64, 0, 61, 4, 0, 0, 54, 4, 0,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001123 0, 103, 54, 4, 0, 34, 24, 0, 0, 131,
1124 0, 0, 103, 134, 133, 0, 131, 0, 54, 4,
1125 0, 137, 0, 8, 0, 139, 0, 8, 0, 139,
Chris Lattner8335e842006-01-23 23:05:42 +00001126 0, 9, 0, 10, 0, 11, 0, 12, 0, 13,
1127 0, 14, 0, 15, 0, 16, 0, 17, 0, 18,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001128 0, 19, 0, 20, 0, 21, 0, 45, 0, 138,
1129 0, 170, 0, 104, 4, 0, 136, 105, 141, 106,
1130 0, 107, 4, 108, 139, 109, 0, 110, 4, 108,
1131 139, 111, 0, 112, 140, 113, 0, 112, 113, 0,
1132 139, 114, 0, 139, 0, 140, 103, 139, 0, 140,
1133 0, 140, 103, 37, 0, 37, 0, 0, 137, 107,
1134 144, 109, 0, 137, 107, 109, 0, 137, 115, 24,
1135 0, 137, 110, 144, 111, 0, 137, 112, 144, 113,
1136 0, 137, 112, 113, 0, 137, 38, 0, 137, 39,
1137 0, 137, 170, 0, 137, 143, 0, 137, 26, 0,
1138 122, 117, 0, 123, 4, 0, 9, 27, 0, 9,
1139 28, 0, 125, 7, 0, 92, 105, 142, 36, 137,
1140 106, 0, 90, 105, 142, 184, 106, 0, 93, 105,
1141 142, 103, 142, 103, 142, 106, 0, 118, 105, 142,
1142 103, 142, 106, 0, 119, 105, 142, 103, 142, 106,
1143 0, 120, 105, 142, 103, 142, 106, 0, 121, 105,
1144 142, 103, 142, 106, 0, 97, 105, 142, 103, 142,
1145 106, 0, 144, 103, 142, 0, 142, 0, 32, 0,
1146 33, 0, 147, 0, 147, 165, 0, 147, 166, 0,
1147 147, 59, 58, 151, 0, 147, 25, 0, 148, 0,
1148 148, 126, 20, 135, 0, 148, 166, 0, 148, 59,
1149 58, 151, 0, 0, 148, 126, 127, 145, 142, 149,
1150 133, 0, 0, 148, 126, 47, 145, 137, 150, 133,
1151 0, 148, 48, 153, 0, 148, 55, 102, 154, 0,
1152 0, 24, 0, 53, 0, 52, 0, 50, 102, 152,
1153 0, 51, 102, 4, 0, 49, 102, 24, 0, 107,
1154 155, 109, 0, 155, 103, 24, 0, 24, 0, 0,
1155 22, 0, 24, 0, 156, 0, 0, 137, 157, 0,
1156 159, 103, 158, 0, 158, 0, 159, 0, 159, 103,
1157 37, 0, 37, 0, 0, 128, 135, 156, 105, 160,
1158 106, 132, 129, 0, 29, 0, 112, 0, 127, 161,
1159 162, 0, 30, 0, 113, 0, 173, 164, 0, 0,
1160 31, 167, 161, 0, 0, 60, 0, 3, 0, 4,
Chris Lattner0e9c3762006-01-25 22:27:16 +00001161 0, 7, 0, 27, 0, 28, 0, 38, 0, 39,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001162 0, 26, 0, 110, 144, 111, 0, 143, 0, 58,
1163 168, 24, 103, 24, 0, 116, 0, 156, 0, 170,
1164 0, 169, 0, 137, 171, 0, 173, 174, 0, 163,
1165 174, 0, 175, 126, 176, 0, 175, 178, 0, 0,
1166 23, 0, 65, 172, 0, 65, 8, 0, 66, 21,
1167 171, 0, 66, 9, 171, 103, 21, 171, 103, 21,
1168 171, 0, 67, 124, 171, 103, 21, 171, 107, 177,
1169 109, 0, 67, 124, 171, 103, 21, 171, 107, 109,
1170 0, 68, 128, 135, 171, 105, 181, 106, 36, 21,
1171 171, 69, 21, 171, 0, 69, 0, 70, 0, 177,
1172 124, 169, 103, 21, 171, 0, 124, 169, 103, 21,
1173 171, 0, 126, 183, 0, 137, 107, 171, 103, 171,
1174 109, 0, 179, 103, 107, 171, 103, 171, 109, 0,
1175 172, 0, 180, 103, 172, 0, 180, 0, 0, 57,
1176 56, 0, 56, 0, 118, 137, 171, 103, 171, 0,
1177 119, 137, 171, 103, 171, 0, 120, 137, 171, 103,
1178 171, 0, 46, 172, 0, 121, 172, 103, 172, 0,
1179 92, 172, 36, 137, 0, 93, 172, 103, 172, 103,
1180 172, 0, 96, 172, 103, 137, 0, 100, 172, 103,
1181 137, 0, 101, 172, 103, 137, 0, 97, 172, 103,
1182 172, 0, 98, 172, 103, 172, 103, 172, 0, 99,
1183 172, 103, 172, 103, 172, 0, 91, 179, 0, 182,
1184 128, 135, 171, 105, 181, 106, 0, 186, 0, 103,
1185 180, 0, 0, 35, 0, 0, 85, 137, 130, 0,
1186 85, 137, 103, 15, 171, 130, 0, 86, 137, 130,
1187 0, 86, 137, 103, 15, 171, 130, 0, 87, 172,
1188 0, 185, 88, 137, 171, 0, 185, 89, 172, 103,
1189 137, 171, 0, 90, 137, 171, 184, 0
Chris Lattner8335e842006-01-23 23:05:42 +00001190};
Reid Spencer68a24bd2005-08-27 18:50:39 +00001191
1192#endif
1193
Chris Lattner8335e842006-01-23 23:05:42 +00001194#if YYDEBUG != 0
1195static const short yyrline[] = { 0,
Chris Lattner0e9c3762006-01-25 22:27:16 +00001196 1010, 1011, 1018, 1019, 1028, 1028, 1028, 1028, 1028, 1029,
1197 1029, 1029, 1030, 1030, 1030, 1030, 1030, 1030, 1032, 1032,
1198 1036, 1036, 1036, 1036, 1037, 1037, 1037, 1037, 1038, 1038,
1199 1039, 1039, 1042, 1045, 1049, 1049, 1050, 1051, 1052, 1055,
1200 1055, 1056, 1057, 1058, 1067, 1067, 1073, 1073, 1081, 1088,
1201 1088, 1094, 1094, 1096, 1100, 1113, 1113, 1114, 1114, 1116,
1202 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1126, 1126, 1126,
1203 1126, 1126, 1126, 1127, 1130, 1133, 1139, 1146, 1158, 1162,
1204 1173, 1182, 1185, 1193, 1197, 1202, 1203, 1206, 1209, 1219,
1205 1244, 1257, 1286, 1311, 1331, 1343, 1352, 1356, 1415, 1421,
1206 1429, 1434, 1439, 1442, 1445, 1452, 1462, 1493, 1500, 1521,
1207 1531, 1536, 1543, 1553, 1556, 1563, 1563, 1573, 1580, 1584,
1208 1587, 1590, 1593, 1606, 1626, 1628, 1630, 1633, 1636, 1640,
1209 1643, 1645, 1647, 1651, 1663, 1664, 1666, 1669, 1677, 1682,
1210 1684, 1688, 1692, 1700, 1700, 1701, 1701, 1703, 1709, 1714,
1211 1720, 1723, 1728, 1732, 1736, 1822, 1822, 1824, 1832, 1832,
1212 1834, 1838, 1838, 1847, 1850, 1854, 1857, 1860, 1863, 1866,
1213 1869, 1872, 1875, 1878, 1902, 1905, 1918, 1921, 1926, 1926,
1214 1932, 1936, 1939, 1947, 1956, 1960, 1970, 1981, 1984, 1987,
1215 1990, 1993, 2007, 2011, 2064, 2067, 2073, 2081, 2091, 2098,
1216 2103, 2110, 2114, 2120, 2120, 2122, 2125, 2131, 2143, 2154,
1217 2164, 2176, 2183, 2190, 2197, 2202, 2221, 2243, 2251, 2263,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001218 2268, 2282, 2339, 2345, 2347, 2351, 2354, 2360, 2364, 2368,
1219 2372, 2376, 2383, 2393, 2406
Chris Lattner8335e842006-01-23 23:05:42 +00001220};
1221#endif
1222
1223
1224#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
1225
1226static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL",
1227"EUINT64VAL","SINTVAL","UINTVAL","FPVAL","VOID","BOOL","SBYTE","UBYTE","SHORT",
1228"USHORT","INT","UINT","LONG","ULONG","FLOAT","DOUBLE","TYPE","LABEL","VAR_ID",
1229"LABELSTR","STRINGCONSTANT","IMPLEMENTATION","ZEROINITIALIZER","TRUETOK","FALSETOK",
1230"BEGINTOK","ENDTOK","DECLARE","GLOBAL","CONSTANT","SECTION","VOLATILE","TO",
1231"DOTDOTDOT","NULL_TOK","UNDEF","CONST","INTERNAL","LINKONCE","WEAK","APPENDING",
1232"OPAQUE","NOT","EXTERNAL","TARGET","TRIPLE","ENDIAN","POINTERSIZE","LITTLE",
Chris Lattner0e9c3762006-01-25 22:27:16 +00001233"BIG","ALIGN","DEPLIBS","CALL","TAIL","ASM_TOK","MODULE","SIDEEFFECT","CC_TOK",
1234"CCC_TOK","FASTCC_TOK","COLDCC_TOK","RET","BR","SWITCH","INVOKE","UNWIND","UNREACHABLE",
Chris Lattner66316012006-01-24 04:14:29 +00001235"ADD","SUB","MUL","DIV","REM","AND","OR","XOR","SETLE","SETGE","SETLT","SETGT",
1236"SETEQ","SETNE","MALLOC","ALLOCA","FREE","LOAD","STORE","GETELEMENTPTR","PHI_TOK",
Chris Lattnerd5efe842006-04-08 01:18:56 +00001237"CAST","SELECT","SHL","SHR","VAARG","EXTRACTELEMENT","INSERTELEMENT","SHUFFLEVECTOR",
1238"VAARG_old","VANEXT_old","'='","','","'\\\\'","'('","')'","'['","'x'","']'",
1239"'<'","'>'","'{'","'}'","'*'","'c'","INTVAL","EINT64VAL","ArithmeticOps","LogicalOps",
1240"SetCondOps","ShiftOps","SIntType","UIntType","IntType","FPType","OptAssign",
1241"OptLinkage","OptCallingConv","OptAlign","OptCAlign","SectionString","OptSection",
1242"GlobalVarAttributes","GlobalVarAttribute","TypesV","UpRTypesV","Types","PrimType",
1243"UpRTypes","TypeListI","ArgTypeListI","ConstVal","ConstExpr","ConstVector","GlobalType",
1244"Module","FunctionList","ConstPool","@1","@2","AsmBlock","BigOrLittle","TargetDefinition",
1245"LibrariesDefinition","LibList","Name","OptName","ArgVal","ArgListH","ArgList",
1246"FunctionHeaderH","BEGIN","FunctionHeader","END","Function","FunctionProto",
1247"@3","OptSideEffect","ConstValueRef","SymbolicValueRef","ValueRef","ResolvedVal",
1248"BasicBlockList","BasicBlock","InstructionList","BBTerminatorInst","JumpTable",
1249"Inst","PHIList","ValueRefList","ValueRefListE","OptTailCall","InstVal","IndexList",
1250"OptVolatile","MemoryInst", NULL
Chris Lattner8335e842006-01-23 23:05:42 +00001251};
1252#endif
1253
1254static const short yyr1[] = { 0,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001255 116, 116, 117, 117, 118, 118, 118, 118, 118, 119,
1256 119, 119, 120, 120, 120, 120, 120, 120, 121, 121,
1257 122, 122, 122, 122, 123, 123, 123, 123, 124, 124,
1258 125, 125, 126, 126, 127, 127, 127, 127, 127, 128,
1259 128, 128, 128, 128, 129, 129, 130, 130, 131, 132,
1260 132, 133, 133, 134, 134, 135, 135, 136, 136, 137,
1261 138, 138, 138, 138, 138, 138, 138, 138, 138, 138,
1262 138, 138, 138, 139, 139, 139, 139, 139, 139, 139,
1263 139, 139, 139, 140, 140, 141, 141, 141, 141, 142,
1264 142, 142, 142, 142, 142, 142, 142, 142, 142, 142,
1265 142, 142, 142, 142, 142, 143, 143, 143, 143, 143,
1266 143, 143, 143, 144, 144, 145, 145, 146, 147, 147,
1267 147, 147, 147, 148, 148, 148, 149, 148, 150, 148,
1268 148, 148, 148, 151, 152, 152, 153, 153, 153, 154,
1269 155, 155, 155, 156, 156, 157, 157, 158, 159, 159,
1270 160, 160, 160, 160, 161, 162, 162, 163, 164, 164,
1271 165, 167, 166, 168, 168, 169, 169, 169, 169, 169,
1272 169, 169, 169, 169, 169, 169, 170, 170, 171, 171,
1273 172, 173, 173, 174, 175, 175, 175, 176, 176, 176,
1274 176, 176, 176, 176, 176, 176, 177, 177, 178, 179,
1275 179, 180, 180, 181, 181, 182, 182, 183, 183, 183,
1276 183, 183, 183, 183, 183, 183, 183, 183, 183, 183,
1277 183, 183, 183, 184, 184, 185, 185, 186, 186, 186,
1278 186, 186, 186, 186, 186
Chris Lattner8335e842006-01-23 23:05:42 +00001279};
1280
1281static const short yyr2[] = { 0,
1282 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1283 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1284 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1285 1, 1, 2, 0, 1, 1, 1, 1, 0, 0,
1286 1, 1, 1, 2, 0, 2, 0, 3, 2, 0,
1287 1, 0, 3, 1, 2, 1, 1, 1, 1, 1,
1288 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1289 1, 1, 1, 1, 1, 1, 2, 4, 5, 5,
1290 3, 2, 2, 1, 3, 1, 3, 1, 0, 4,
1291 3, 3, 4, 4, 3, 2, 2, 2, 2, 2,
1292 2, 2, 2, 2, 2, 6, 5, 8, 6, 6,
1293 6, 6, 6, 3, 1, 1, 1, 1, 2, 2,
Chris Lattner66316012006-01-24 04:14:29 +00001294 4, 2, 1, 4, 2, 4, 0, 7, 0, 7,
Chris Lattner8335e842006-01-23 23:05:42 +00001295 3, 4, 0, 1, 1, 1, 3, 3, 3, 3,
1296 3, 1, 0, 1, 1, 1, 0, 2, 3, 1,
1297 1, 3, 1, 0, 8, 1, 1, 3, 1, 1,
Chris Lattner0e9c3762006-01-25 22:27:16 +00001298 2, 0, 3, 0, 1, 1, 1, 1, 1, 1,
1299 1, 1, 1, 3, 1, 5, 1, 1, 1, 1,
1300 2, 2, 2, 3, 2, 0, 1, 2, 2, 3,
1301 9, 9, 8, 13, 1, 1, 6, 5, 2, 6,
1302 7, 1, 3, 1, 0, 2, 1, 5, 5, 5,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001303 2, 4, 4, 6, 4, 4, 4, 4, 6, 6,
1304 2, 7, 1, 2, 0, 1, 0, 3, 6, 3,
1305 6, 2, 4, 6, 4
Chris Lattner8335e842006-01-23 23:05:42 +00001306};
1307
1308static const short yydefact[] = { 133,
1309 39, 123, 122, 162, 35, 36, 37, 38, 0, 40,
Chris Lattner0e9c3762006-01-25 22:27:16 +00001310 186, 119, 120, 186, 144, 145, 0, 0, 0, 39,
Chris Lattner66316012006-01-24 04:14:29 +00001311 0, 125, 40, 0, 0, 41, 42, 43, 0, 0,
Chris Lattner0e9c3762006-01-25 22:27:16 +00001312 187, 183, 34, 159, 160, 161, 182, 0, 0, 0,
Chris Lattner66316012006-01-24 04:14:29 +00001313 131, 0, 0, 0, 0, 0, 33, 163, 134, 121,
1314 44, 1, 2, 57, 61, 62, 63, 64, 65, 66,
1315 67, 68, 69, 70, 71, 72, 73, 74, 0, 0,
Chris Lattner0e9c3762006-01-25 22:27:16 +00001316 0, 0, 177, 0, 0, 56, 75, 60, 178, 76,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001317 156, 157, 158, 227, 185, 0, 0, 0, 143, 132,
Chris Lattner66316012006-01-24 04:14:29 +00001318 126, 124, 116, 117, 0, 0, 77, 0, 0, 59,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001319 82, 84, 0, 0, 89, 83, 226, 0, 207, 0,
Chris Lattner0e9c3762006-01-25 22:27:16 +00001320 0, 0, 0, 40, 195, 196, 5, 6, 7, 8,
Chris Lattner66316012006-01-24 04:14:29 +00001321 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
1322 0, 0, 0, 0, 0, 0, 0, 19, 20, 0,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001323 0, 0, 0, 0, 0, 0, 0, 0, 0, 184,
1324 40, 199, 0, 223, 139, 136, 135, 137, 138, 142,
1325 0, 129, 61, 62, 63, 64, 65, 66, 67, 68,
1326 69, 70, 71, 0, 0, 0, 0, 127, 0, 0,
1327 0, 81, 154, 88, 86, 0, 0, 211, 206, 189,
1328 188, 0, 0, 24, 28, 23, 27, 22, 26, 21,
1329 25, 29, 30, 0, 0, 47, 47, 232, 0, 0,
1330 221, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1331 0, 0, 0, 0, 0, 0, 0, 140, 52, 103,
1332 104, 3, 4, 101, 102, 105, 100, 96, 97, 0,
Chris Lattner8335e842006-01-23 23:05:42 +00001333 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001334 0, 99, 98, 52, 58, 58, 85, 153, 147, 150,
1335 151, 0, 0, 78, 166, 167, 168, 173, 169, 170,
1336 171, 172, 164, 0, 175, 180, 179, 181, 0, 190,
1337 0, 0, 0, 228, 0, 230, 225, 0, 0, 0,
Chris Lattner66316012006-01-24 04:14:29 +00001338 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001339 0, 0, 0, 0, 141, 0, 130, 0, 0, 0,
1340 0, 91, 115, 0, 0, 95, 0, 92, 0, 0,
1341 0, 0, 128, 79, 80, 146, 148, 0, 50, 87,
1342 165, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1343 235, 0, 0, 213, 0, 215, 218, 0, 0, 216,
1344 217, 0, 0, 0, 212, 0, 233, 0, 0, 0,
1345 54, 52, 225, 0, 0, 0, 0, 90, 93, 94,
1346 0, 0, 0, 0, 152, 149, 51, 45, 0, 174,
1347 0, 0, 205, 47, 48, 47, 202, 224, 0, 0,
1348 0, 0, 0, 208, 209, 210, 205, 0, 49, 55,
1349 53, 0, 0, 0, 0, 114, 0, 0, 0, 0,
1350 0, 155, 0, 0, 0, 204, 0, 0, 229, 231,
1351 0, 0, 0, 214, 219, 220, 0, 234, 107, 0,
1352 0, 0, 0, 0, 0, 0, 46, 176, 0, 0,
1353 0, 203, 200, 0, 222, 106, 0, 113, 109, 110,
1354 111, 112, 0, 193, 0, 0, 0, 201, 0, 191,
1355 0, 192, 0, 0, 108, 0, 0, 0, 0, 0,
1356 0, 198, 0, 0, 197, 194, 0, 0, 0
Chris Lattner8335e842006-01-23 23:05:42 +00001357};
1358
Chris Lattner66316012006-01-24 04:14:29 +00001359static const short yydefgoto[] = { 73,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001360 234, 248, 249, 250, 251, 174, 175, 204, 176, 20,
1361 10, 29, 412, 284, 361, 378, 307, 362, 74, 75,
1362 187, 77, 78, 103, 186, 313, 275, 314, 95, 477,
1363 1, 2, 254, 229, 50, 158, 41, 90, 161, 79,
1364 327, 260, 261, 262, 30, 83, 11, 36, 12, 13,
1365 23, 332, 276, 80, 278, 387, 14, 32, 33, 150,
1366 456, 85, 211, 416, 417, 151, 152, 341, 153, 154
Chris Lattner8335e842006-01-23 23:05:42 +00001367};
1368
1369static const short yypact[] = {-32768,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001370 107, 362,-32768,-32768,-32768,-32768,-32768,-32768, -37, 78,
1371 23,-32768,-32768, -12,-32768,-32768, 75, 2, 32, -6,
1372 27,-32768, 78, 85, 140,-32768,-32768,-32768, 957, -20,
1373-32768,-32768, 121,-32768,-32768,-32768,-32768, 45, 53, 70,
1374-32768, 68, 85, 957, 31, 31,-32768,-32768,-32768,-32768,
1375-32768,-32768,-32768, 76,-32768,-32768,-32768,-32768,-32768,-32768,
1376-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 178, 179,
1377 182, 67,-32768, 121, 88,-32768,-32768, 16,-32768,-32768,
1378-32768,-32768,-32768, 1120,-32768, 170, 100, 184, 173,-32768,
1379-32768,-32768,-32768,-32768, 995, 1033,-32768, 91, 92,-32768,
1380-32768, 16, -42, 96, 767,-32768,-32768, 995,-32768, 147,
1381 1071, 22, 223, 78,-32768,-32768,-32768,-32768,-32768,-32768,
Chris Lattner8335e842006-01-23 23:05:42 +00001382-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001383 995, 995, 995, 995, 995, 995, 995,-32768,-32768, 995,
1384 995, 995, 995, 995, 995, 995, 995, 995, 995,-32768,
1385 78,-32768, 47,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1386 24,-32768, 41, 154, 203, 156, 204, 160, 205, 164,
1387 206, 207, 215, 166, 209, 216, 425,-32768, 995, 995,
1388 995,-32768, 805,-32768, 108, 118, 604,-32768,-32768, 76,
1389-32768, 604, 604,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1390-32768,-32768,-32768, 604, 957, 122, 123,-32768, 604, 120,
1391 125, 208, 138, 139, 143, 144, 145, 146, 149, 604,
1392 604, 604, 150, 957, 995, 995, 219,-32768, 151,-32768,
1393-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 153,
1394 155, 157, 159, 843, 1033, 548, 226, 161, 165, 168,
1395 169,-32768,-32768, 151, -75, -3, 16,-32768, 121,-32768,
1396 152, 163, 881,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1397-32768,-32768, 196, 1033,-32768,-32768,-32768,-32768, 162,-32768,
1398 172, 604, -5,-32768, 5,-32768, 175, 604, 176, 995,
1399 995, 995, 995, 995, 995, 995, 995, 181, 183, 185,
1400 995, 604, 604, 186,-32768, -22,-32768, 1033, 1033, 1033,
1401 1033,-32768,-32768, 25, -46,-32768, 7,-32768, 1033, 1033,
1402 1033, 1033,-32768,-32768,-32768,-32768,-32768, 919, 242,-32768,
1403-32768, 261, -41, 266, 273, 190, 604, 292, 604, 995,
1404-32768, 194, 604,-32768, 195,-32768,-32768, 197, 198,-32768,
1405-32768, 604, 604, 604,-32768, 200,-32768, 995, 283, 305,
1406-32768, 151, 175, 274, 210, 213, 1033,-32768,-32768,-32768,
1407 224, 228, 230, 231,-32768,-32768,-32768, 257, 232,-32768,
1408 604, 604, 995, 234,-32768, 234,-32768, 236, 604, 237,
1409 995, 995, 995,-32768,-32768,-32768, 995, 604,-32768,-32768,
1410-32768, 220, 995, 1033, 1033,-32768, 1033, 1033, 1033, 1033,
1411 338,-32768, 319, 244, 238, 236, 243, 294,-32768,-32768,
1412 995, 246, 604,-32768,-32768,-32768, 250,-32768,-32768, 253,
1413 258, 254, 256, 259, 260, 262,-32768,-32768, 342, 13,
1414 328,-32768,-32768, 263,-32768,-32768, 1033,-32768,-32768,-32768,
1415-32768,-32768, 604,-32768, 664, 83, 348,-32768, 264,-32768,
1416 268,-32768, 664, 604,-32768, 352, 280, 308, 604, 364,
1417 366,-32768, 604, 604,-32768,-32768, 388, 389,-32768
Chris Lattner8335e842006-01-23 23:05:42 +00001418};
1419
1420static const short yypgoto[] = {-32768,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001421-32768, 306, 307, 312, 313, -112, -110, -398,-32768, 365,
1422 379, -101,-32768, -199, 71,-32768, -249,-32768, -40,-32768,
1423 -29,-32768, -65, 296,-32768, -90, 225, -229, 361,-32768,
1424-32768,-32768,-32768,-32768, 368,-32768,-32768,-32768,-32768, 0,
1425-32768, 80,-32768,-32768, 390,-32768,-32768,-32768,-32768, 410,
1426-32768,-32768, -332, -31, 132, -89,-32768, 401,-32768,-32768,
1427-32768,-32768,-32768, 79, 19,-32768,-32768, 60,-32768,-32768
Chris Lattner8335e842006-01-23 23:05:42 +00001428};
1429
1430
Chris Lattnerd5efe842006-04-08 01:18:56 +00001431#define YYLAST 1221
Chris Lattner8335e842006-01-23 23:05:42 +00001432
1433
Chris Lattner66316012006-01-24 04:14:29 +00001434static const short yytable[] = { 76,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001435 202, 21, 203, 92, 323, 178, 102, 286, 81, 337,
1436 31, 359, 205, 44, 76, 315, 317, 34, 188, 339,
1437 24, 191, 194, 195, 196, 197, 198, 199, 200, 201,
1438 192, 360, 21, 324, 5, 6, 7, 8, 106, 102,
1439 45, 455, 193, 208, 333, 31, 212, 213, 338, 224,
1440 214, 215, 216, 217, 218, 219, 367, 463, 338, 223,
1441 181, 367, 93, 94, 369, 162, 177, 230, 231, 380,
1442 182, 52, 53, 104, 100, 55, 56, 57, 58, 59,
1443 60, 61, 62, 63, 64, 65, 66, 67, 15, 43,
1444 16, 82, 194, 195, 196, 197, 198, 199, 200, 201,
1445 35, 206, 207, 42, 209, 210, -118, 325, 49, 367,
1446 106, 68, 401, 255, 256, 257, 220, 221, 222, 370,
1447 -58, 454, 461, 38, 39, 40, 227, 367, 47, 106,
1448 467, 3, 228, 368, 225, 226, 304, 4, 25, 26,
1449 27, 28, 15, 51, 16, 253, 86, 5, 6, 7,
1450 8, 156, 157, 259, 87, 277, -24, -24, -23, -23,
1451 277, 277, -22, -22, 282, 9, -21, -21, 232, 233,
1452 69, 88, 277, 70, 89, 76, 71, 277, 72, 101,
1453 -59, 97, 98, 302, 419, 99, 420, 159, 277, 277,
1454 277, 462, 105, 155, 76, 303, 160, 257, 179, 180,
1455 183, 345, 189, 347, 348, 349, -28, -27, -26, -25,
1456 263, 355, 235, -31, 177, 177, 177, 363, 364, 365,
1457 366, -32, 236, 264, 283, 285, 288, 289, 371, 372,
1458 373, 374, 194, 195, 196, 197, 198, 199, 200, 201,
1459 291, 292, 305, 290, 177, 293, 294, 295, 296, 318,
1460 277, 297, 301, 306, 328, 331, 277, 308, 326, 309,
1461 344, 310, 346, 311, 334, 319, 350, 351, 329, 320,
1462 277, 277, 321, 322, 335, 359, 406, 340, 177, 177,
1463 177, 177, 343, 352, 379, 353, 381, 354, 358, 177,
1464 177, 177, 177, 382, 383, 385, 389, 391, 259, 392,
1465 393, 424, 425, 426, 397, 277, 399, 277, 400, 403,
1466 411, 277, 404, 431, 432, 405, 433, 434, 435, 436,
1467 277, 277, 277, 279, 280, 429, 407, 202, 398, 203,
1468 408, 442, 409, 410, 413, 281, 418, 177, 421, 423,
1469 287, 437, 438, 202, 440, 203, 439, 338, 441, 277,
1470 277, 298, 299, 300, 443, 445, 459, 277, 446, 448,
1471 447, 449, 453, 457, 450, 451, 277, 452, 464, 465,
1472 466, 458, 469, 430, 177, 177, 471, 177, 177, 177,
1473 177, -34, 470, 15, 473, 16, 474, 478, 479, 146,
1474 147, 277, 4, -34, -34, 148, 149, 84, 46, 377,
1475 185, 252, -34, -34, -34, -34, 96, 376, -34, 17,
1476 91, 22, 48, 336, 37, 427, 18, 177, 388, 342,
1477 19, 277, 402, 0, 0, 0, 0, 0, 0, 52,
1478 53, 0, 277, 356, 357, 0, 0, 277, 0, 0,
1479 0, 277, 277, 0, 0, 0, 15, 0, 16, 0,
1480 237, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1481 0, 0, 238, 239, 0, 0, 0, 0, 384, 0,
1482 386, 0, 0, 0, 390, 0, 0, 0, 0, 0,
1483 0, 0, 0, 394, 395, 396, 0, 0, 0, 0,
1484 0, 0, 0, 0, 0, 117, 118, 119, 120, 121,
1485 122, 123, 124, 125, 126, 127, 128, 129, 130, 0,
1486 0, 0, 414, 415, 240, 0, 241, 242, 138, 139,
1487 422, 243, 0, 0, 0, 0, 0, 0, 0, 428,
1488 0, 244, 0, 0, 245, 0, 246, 0, 0, 247,
Chris Lattner8335e842006-01-23 23:05:42 +00001489 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001490 0, 0, 52, 53, 444, 100, 163, 164, 165, 166,
1491 167, 168, 169, 170, 171, 172, 173, 66, 67, 15,
1492 0, 16, 0, 0, 0, 0, 0, 0, 0, 0,
1493 0, 0, 0, 0, 460, 0, 0, 0, 0, 0,
1494 0, 0, 68, 0, 0, 468, 0, 0, 0, 0,
1495 472, 0, 0, 0, 475, 476, 265, 266, 52, 53,
1496 267, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1497 0, 0, 0, 0, 0, 15, 0, 16, 0, 268,
1498 269, 270, 0, 0, 0, 0, 0, 0, 0, 0,
1499 0, 271, 272, 0, 0, 0, 0, 0, 0, 0,
1500 0, 69, 0, 0, 70, 0, 0, 71, 0, 72,
1501 316, 273, 0, 0, 0, 0, 265, 266, 0, 0,
1502 267, 0, 0, 0, 117, 118, 119, 120, 121, 122,
1503 123, 124, 125, 126, 127, 128, 129, 130, 0, 268,
1504 269, 270, 0, 240, 0, 241, 242, 138, 139, 0,
1505 243, 271, 272, 0, 0, 0, 0, 0, 0, 0,
1506 0, 0, 0, 274, 0, 0, 0, 0, 0, 0,
1507 0, 273, 0, 0, 0, 0, 0, 0, 0, 0,
1508 0, 0, 0, 0, 117, 118, 119, 120, 121, 122,
1509 123, 124, 125, 126, 127, 128, 129, 130, 0, 0,
1510 0, 0, 0, 240, 0, 241, 242, 138, 139, 0,
1511 243, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1512 0, 52, 53, 274, 100, 55, 56, 57, 58, 59,
1513 60, 61, 62, 63, 64, 65, 66, 67, 15, 0,
1514 16, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1515 0, 0, 0, 184, 0, 0, 0, 0, 0, 52,
1516 53, 68, 100, 55, 56, 57, 58, 59, 60, 61,
1517 62, 63, 64, 65, 66, 67, 15, 0, 16, 0,
Chris Lattner66316012006-01-24 04:14:29 +00001518 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001519 0, 258, 0, 0, 0, 0, 0, 52, 53, 68,
1520 100, 163, 164, 165, 166, 167, 168, 169, 170, 171,
1521 172, 173, 66, 67, 15, 0, 16, 0, 0, 0,
Chris Lattner0e9c3762006-01-25 22:27:16 +00001522 69, 0, 0, 70, 0, 0, 71, 0, 72, 0,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001523 0, 0, 0, 0, 0, 52, 53, 68, 100, 55,
1524 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
1525 66, 67, 15, 0, 16, 0, 0, 0, 69, 0,
1526 0, 70, 0, 0, 71, 0, 72, 330, 0, 0,
1527 0, 0, 0, 52, 53, 68, 100, 55, 56, 57,
1528 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
1529 15, 0, 16, 0, 0, 0, 69, 0, 0, 70,
1530 0, 312, 71, 0, 72, 375, 0, 0, 0, 0,
1531 0, 52, 53, 68, 54, 55, 56, 57, 58, 59,
1532 60, 61, 62, 63, 64, 65, 66, 67, 15, 0,
1533 16, 0, 0, 0, 69, 0, 0, 70, 0, 0,
1534 71, 0, 72, 0, 0, 0, 0, 0, 0, 52,
1535 53, 68, 100, 55, 56, 57, 58, 59, 60, 61,
1536 62, 63, 64, 65, 66, 67, 15, 0, 16, 0,
Chris Lattner0e9c3762006-01-25 22:27:16 +00001537 0, 0, 69, 0, 0, 70, 0, 0, 71, 0,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001538 72, 0, 0, 0, 0, 0, 0, 52, 53, 68,
1539 100, 163, 164, 165, 166, 167, 168, 169, 170, 171,
1540 172, 173, 66, 67, 15, 0, 16, 0, 0, 0,
1541 69, 0, 0, 70, 0, 0, 71, 0, 72, 0,
1542 0, 0, 0, 0, 0, 52, 53, 68, 190, 55,
1543 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
1544 66, 67, 15, 0, 16, 0, 0, 0, 69, 0,
1545 0, 70, 0, 0, 71, 0, 72, 0, 0, 0,
1546 0, 0, 0, 0, 0, 68, 0, 0, 0, 0,
1547 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1548 0, 0, 0, 0, 0, 0, 69, 0, 0, 70,
1549 0, 0, 71, 0, 72, 0, 0, 0, 0, 0,
1550 0, 0, 0, 0, 107, 0, 0, 0, 0, 0,
1551 0, 0, 0, 0, 0, 108, 0, 0, 0, 0,
1552 0, 0, 0, 0, 69, 109, 110, 70, 0, 0,
1553 71, 0, 72, 0, 111, 112, 113, 114, 115, 116,
1554 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
1555 127, 128, 129, 130, 131, 132, 133, 0, 0, 134,
1556 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
1557 145
Chris Lattner8335e842006-01-23 23:05:42 +00001558};
1559
Chris Lattner66316012006-01-24 04:14:29 +00001560static const short yycheck[] = { 29,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001561 113, 2, 113, 44, 254, 96, 72, 207, 29, 15,
1562 23, 34, 114, 20, 44, 245, 246, 30, 108, 15,
1563 58, 111, 10, 11, 12, 13, 14, 15, 16, 17,
1564 9, 54, 33, 109, 41, 42, 43, 44, 114, 105,
1565 47, 440, 21, 133, 274, 23, 136, 137, 54, 151,
1566 140, 141, 142, 143, 144, 145, 103, 456, 54, 149,
1567 103, 103, 32, 33, 111, 95, 96, 27, 28, 111,
1568 113, 5, 6, 74, 8, 9, 10, 11, 12, 13,
1569 14, 15, 16, 17, 18, 19, 20, 21, 22, 58,
1570 24, 112, 10, 11, 12, 13, 14, 15, 16, 17,
1571 113, 131, 132, 102, 134, 135, 0, 111, 24, 103,
1572 114, 45, 362, 179, 180, 181, 146, 147, 148, 113,
1573 105, 109, 455, 49, 50, 51, 103, 103, 102, 114,
1574 463, 25, 109, 109, 88, 89, 226, 31, 61, 62,
1575 63, 64, 22, 4, 24, 177, 102, 41, 42, 43,
1576 44, 52, 53, 183, 102, 187, 3, 4, 3, 4,
1577 192, 193, 3, 4, 205, 59, 3, 4, 3, 4,
1578 104, 102, 204, 107, 107, 205, 110, 209, 112, 113,
1579 105, 4, 4, 224, 384, 4, 386, 4, 220, 221,
1580 222, 109, 105, 24, 224, 225, 24, 263, 108, 108,
1581 105, 291, 56, 293, 294, 295, 4, 4, 4, 4,
1582 103, 301, 4, 7, 244, 245, 246, 308, 309, 310,
1583 311, 7, 7, 106, 103, 103, 107, 103, 319, 320,
1584 321, 322, 10, 11, 12, 13, 14, 15, 16, 17,
1585 103, 103, 24, 36, 274, 103, 103, 103, 103, 24,
1586 282, 103, 103, 103, 103, 60, 288, 105, 259, 105,
1587 290, 105, 292, 105, 103, 105, 296, 297, 106, 105,
1588 302, 303, 105, 105, 103, 34, 367, 103, 308, 309,
1589 310, 311, 107, 103, 24, 103, 21, 103, 103, 319,
1590 320, 321, 322, 21, 105, 4, 103, 103, 328, 103,
1591 103, 391, 392, 393, 105, 337, 24, 339, 4, 36,
1592 54, 343, 103, 404, 405, 103, 407, 408, 409, 410,
1593 352, 353, 354, 192, 193, 106, 103, 440, 358, 440,
1594 103, 421, 103, 103, 103, 204, 103, 367, 103, 103,
1595 209, 4, 24, 456, 107, 456, 103, 54, 106, 381,
1596 382, 220, 221, 222, 109, 106, 447, 389, 106, 106,
1597 103, 106, 21, 36, 106, 106, 398, 106, 21, 106,
1598 103, 109, 21, 403, 404, 405, 69, 407, 408, 409,
1599 410, 20, 103, 22, 21, 24, 21, 0, 0, 84,
1600 84, 423, 31, 32, 33, 84, 84, 33, 20, 329,
1601 105, 177, 41, 42, 43, 44, 46, 328, 47, 48,
1602 43, 2, 23, 282, 14, 397, 55, 447, 340, 288,
1603 59, 453, 363, -1, -1, -1, -1, -1, -1, 5,
1604 6, -1, 464, 302, 303, -1, -1, 469, -1, -1,
1605 -1, 473, 474, -1, -1, -1, 22, -1, 24, -1,
1606 26, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1607 -1, -1, 38, 39, -1, -1, -1, -1, 337, -1,
1608 339, -1, -1, -1, 343, -1, -1, -1, -1, -1,
1609 -1, -1, -1, 352, 353, 354, -1, -1, -1, -1,
1610 -1, -1, -1, -1, -1, 71, 72, 73, 74, 75,
1611 76, 77, 78, 79, 80, 81, 82, 83, 84, -1,
1612 -1, -1, 381, 382, 90, -1, 92, 93, 94, 95,
1613 389, 97, -1, -1, -1, -1, -1, -1, -1, 398,
1614 -1, 107, -1, -1, 110, -1, 112, -1, -1, 115,
1615 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1616 -1, -1, 5, 6, 423, 8, 9, 10, 11, 12,
1617 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
1618 -1, 24, -1, -1, -1, -1, -1, -1, -1, -1,
1619 -1, -1, -1, -1, 453, -1, -1, -1, -1, -1,
1620 -1, -1, 45, -1, -1, 464, -1, -1, -1, -1,
1621 469, -1, -1, -1, 473, 474, 3, 4, 5, 6,
1622 7, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1623 -1, -1, -1, -1, -1, 22, -1, 24, -1, 26,
1624 27, 28, -1, -1, -1, -1, -1, -1, -1, -1,
1625 -1, 38, 39, -1, -1, -1, -1, -1, -1, -1,
1626 -1, 104, -1, -1, 107, -1, -1, 110, -1, 112,
1627 113, 58, -1, -1, -1, -1, 3, 4, -1, -1,
1628 7, -1, -1, -1, 71, 72, 73, 74, 75, 76,
1629 77, 78, 79, 80, 81, 82, 83, 84, -1, 26,
1630 27, 28, -1, 90, -1, 92, 93, 94, 95, -1,
1631 97, 38, 39, -1, -1, -1, -1, -1, -1, -1,
1632 -1, -1, -1, 110, -1, -1, -1, -1, -1, -1,
1633 -1, 58, -1, -1, -1, -1, -1, -1, -1, -1,
1634 -1, -1, -1, -1, 71, 72, 73, 74, 75, 76,
1635 77, 78, 79, 80, 81, 82, 83, 84, -1, -1,
1636 -1, -1, -1, 90, -1, 92, 93, 94, 95, -1,
1637 97, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1638 -1, 5, 6, 110, 8, 9, 10, 11, 12, 13,
1639 14, 15, 16, 17, 18, 19, 20, 21, 22, -1,
1640 24, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1641 -1, -1, -1, 37, -1, -1, -1, -1, -1, 5,
1642 6, 45, 8, 9, 10, 11, 12, 13, 14, 15,
1643 16, 17, 18, 19, 20, 21, 22, -1, 24, -1,
1644 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1645 -1, 37, -1, -1, -1, -1, -1, 5, 6, 45,
1646 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
1647 18, 19, 20, 21, 22, -1, 24, -1, -1, -1,
1648 104, -1, -1, 107, -1, -1, 110, -1, 112, -1,
1649 -1, -1, -1, -1, -1, 5, 6, 45, 8, 9,
Chris Lattner0e9c3762006-01-25 22:27:16 +00001650 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001651 20, 21, 22, -1, 24, -1, -1, -1, 104, -1,
1652 -1, 107, -1, -1, 110, -1, 112, 37, -1, -1,
1653 -1, -1, -1, 5, 6, 45, 8, 9, 10, 11,
1654 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
1655 22, -1, 24, -1, -1, -1, 104, -1, -1, 107,
1656 -1, 109, 110, -1, 112, 37, -1, -1, -1, -1,
1657 -1, 5, 6, 45, 8, 9, 10, 11, 12, 13,
1658 14, 15, 16, 17, 18, 19, 20, 21, 22, -1,
1659 24, -1, -1, -1, 104, -1, -1, 107, -1, -1,
1660 110, -1, 112, -1, -1, -1, -1, -1, -1, 5,
1661 6, 45, 8, 9, 10, 11, 12, 13, 14, 15,
1662 16, 17, 18, 19, 20, 21, 22, -1, 24, -1,
1663 -1, -1, 104, -1, -1, 107, -1, -1, 110, -1,
1664 112, -1, -1, -1, -1, -1, -1, 5, 6, 45,
1665 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
1666 18, 19, 20, 21, 22, -1, 24, -1, -1, -1,
1667 104, -1, -1, 107, -1, -1, 110, -1, 112, -1,
1668 -1, -1, -1, -1, -1, 5, 6, 45, 8, 9,
1669 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
1670 20, 21, 22, -1, 24, -1, -1, -1, 104, -1,
1671 -1, 107, -1, -1, 110, -1, 112, -1, -1, -1,
Chris Lattner0e9c3762006-01-25 22:27:16 +00001672 -1, -1, -1, -1, -1, 45, -1, -1, -1, -1,
Chris Lattner8335e842006-01-23 23:05:42 +00001673 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001674 -1, -1, -1, -1, -1, -1, 104, -1, -1, 107,
1675 -1, -1, 110, -1, 112, -1, -1, -1, -1, -1,
1676 -1, -1, -1, -1, 35, -1, -1, -1, -1, -1,
1677 -1, -1, -1, -1, -1, 46, -1, -1, -1, -1,
1678 -1, -1, -1, -1, 104, 56, 57, 107, -1, -1,
1679 110, -1, 112, -1, 65, 66, 67, 68, 69, 70,
1680 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
1681 81, 82, 83, 84, 85, 86, 87, -1, -1, 90,
1682 91, 92, 93, 94, 95, 96, 97, 98, 99, 100,
1683 101
Chris Lattner8335e842006-01-23 23:05:42 +00001684};
1685/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
1686#line 3 "/usr/share/bison.simple"
1687/* This file comes from bison-1.28. */
1688
1689/* Skeleton output parser for bison,
1690 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
1691
1692 This program is free software; you can redistribute it and/or modify
1693 it under the terms of the GNU General Public License as published by
1694 the Free Software Foundation; either version 2, or (at your option)
1695 any later version.
1696
1697 This program is distributed in the hope that it will be useful,
1698 but WITHOUT ANY WARRANTY; without even the implied warranty of
1699 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1700 GNU General Public License for more details.
1701
1702 You should have received a copy of the GNU General Public License
1703 along with this program; if not, write to the Free Software
1704 Foundation, Inc., 59 Temple Place - Suite 330,
1705 Boston, MA 02111-1307, USA. */
1706
1707/* As a special exception, when this file is copied by Bison into a
1708 Bison output file, you may use that output file without restriction.
1709 This special exception was added by the Free Software Foundation
1710 in version 1.24 of Bison. */
1711
1712/* This is the parser code that is written into each bison parser
1713 when the %semantic_parser declaration is not specified in the grammar.
1714 It was written by Richard Stallman by simplifying the hairy parser
1715 used when %semantic_parser is specified. */
1716
1717#ifndef YYSTACK_USE_ALLOCA
1718#ifdef alloca
1719#define YYSTACK_USE_ALLOCA
1720#else /* alloca not defined */
1721#ifdef __GNUC__
1722#define YYSTACK_USE_ALLOCA
1723#define alloca __builtin_alloca
1724#else /* not GNU C. */
1725#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
1726#define YYSTACK_USE_ALLOCA
1727#include <alloca.h>
1728#else /* not sparc */
1729/* We think this test detects Watcom and Microsoft C. */
1730/* This used to test MSDOS, but that is a bad idea
1731 since that symbol is in the user namespace. */
1732#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
1733#if 0 /* No need for malloc.h, which pollutes the namespace;
1734 instead, just don't use alloca. */
1735#include <malloc.h>
1736#endif
1737#else /* not MSDOS, or __TURBOC__ */
1738#if defined(_AIX)
1739/* I don't know what this was needed for, but it pollutes the namespace.
1740 So I turned it off. rms, 2 May 1997. */
1741/* #include <malloc.h> */
1742 #pragma alloca
1743#define YYSTACK_USE_ALLOCA
1744#else /* not MSDOS, or __TURBOC__, or _AIX */
1745#if 0
1746#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
1747 and on HPUX 10. Eventually we can turn this on. */
1748#define YYSTACK_USE_ALLOCA
1749#define alloca __builtin_alloca
1750#endif /* __hpux */
1751#endif
1752#endif /* not _AIX */
1753#endif /* not MSDOS, or __TURBOC__ */
1754#endif /* not sparc */
1755#endif /* not GNU C */
1756#endif /* alloca not defined */
1757#endif /* YYSTACK_USE_ALLOCA not defined */
1758
1759#ifdef YYSTACK_USE_ALLOCA
1760#define YYSTACK_ALLOC alloca
Reid Spencer68a24bd2005-08-27 18:50:39 +00001761#else
Chris Lattner8335e842006-01-23 23:05:42 +00001762#define YYSTACK_ALLOC malloc
Reid Spencer68a24bd2005-08-27 18:50:39 +00001763#endif
1764
Chris Lattner8335e842006-01-23 23:05:42 +00001765/* Note: there must be only one dollar sign in this file.
1766 It is replaced by the list of actions, each action
1767 as one case of the switch. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001768
1769#define yyerrok (yyerrstatus = 0)
1770#define yyclearin (yychar = YYEMPTY)
Chris Lattner8335e842006-01-23 23:05:42 +00001771#define YYEMPTY -2
Reid Spencer68a24bd2005-08-27 18:50:39 +00001772#define YYEOF 0
Reid Spencer68a24bd2005-08-27 18:50:39 +00001773#define YYACCEPT goto yyacceptlab
Chris Lattner8335e842006-01-23 23:05:42 +00001774#define YYABORT goto yyabortlab
1775#define YYERROR goto yyerrlab1
1776/* Like YYERROR except do call yyerror.
1777 This remains here temporarily to ease the
1778 transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00001779 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001780#define YYFAIL goto yyerrlab
Reid Spencer68a24bd2005-08-27 18:50:39 +00001781#define YYRECOVERING() (!!yyerrstatus)
Chris Lattner8335e842006-01-23 23:05:42 +00001782#define YYBACKUP(token, value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00001783do \
1784 if (yychar == YYEMPTY && yylen == 1) \
Chris Lattner8335e842006-01-23 23:05:42 +00001785 { yychar = (token), yylval = (value); \
1786 yychar1 = YYTRANSLATE (yychar); \
Reid Spencer68a24bd2005-08-27 18:50:39 +00001787 YYPOPSTACK; \
1788 goto yybackup; \
1789 } \
1790 else \
Chris Lattner8335e842006-01-23 23:05:42 +00001791 { yyerror ("syntax error: cannot back up"); YYERROR; } \
Reid Spencer68a24bd2005-08-27 18:50:39 +00001792while (0)
1793
1794#define YYTERROR 1
1795#define YYERRCODE 256
1796
Chris Lattner8335e842006-01-23 23:05:42 +00001797#ifndef YYPURE
1798#define YYLEX yylex()
Reid Spencer68a24bd2005-08-27 18:50:39 +00001799#endif
1800
Chris Lattner8335e842006-01-23 23:05:42 +00001801#ifdef YYPURE
1802#ifdef YYLSP_NEEDED
Reid Spencer68a24bd2005-08-27 18:50:39 +00001803#ifdef YYLEX_PARAM
Chris Lattner8335e842006-01-23 23:05:42 +00001804#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001805#else
Chris Lattner8335e842006-01-23 23:05:42 +00001806#define YYLEX yylex(&yylval, &yylloc)
1807#endif
1808#else /* not YYLSP_NEEDED */
1809#ifdef YYLEX_PARAM
1810#define YYLEX yylex(&yylval, YYLEX_PARAM)
1811#else
1812#define YYLEX yylex(&yylval)
1813#endif
1814#endif /* not YYLSP_NEEDED */
Robert Bocchino2def1b32006-01-17 20:06:25 +00001815#endif
Reid Spencere812fb22006-01-19 01:21:04 +00001816
Chris Lattner8335e842006-01-23 23:05:42 +00001817/* If nonreentrant, generate the variables here */
Reid Spencere812fb22006-01-19 01:21:04 +00001818
Chris Lattner8335e842006-01-23 23:05:42 +00001819#ifndef YYPURE
Reid Spencere812fb22006-01-19 01:21:04 +00001820
Chris Lattner8335e842006-01-23 23:05:42 +00001821int yychar; /* the lookahead symbol */
1822YYSTYPE yylval; /* the semantic value of the */
1823 /* lookahead symbol */
Reid Spencere812fb22006-01-19 01:21:04 +00001824
Chris Lattner8335e842006-01-23 23:05:42 +00001825#ifdef YYLSP_NEEDED
1826YYLTYPE yylloc; /* location data for the lookahead */
1827 /* symbol */
Robert Bocchino2def1b32006-01-17 20:06:25 +00001828#endif
Reid Spencere812fb22006-01-19 01:21:04 +00001829
Chris Lattner8335e842006-01-23 23:05:42 +00001830int yynerrs; /* number of parse errors so far */
1831#endif /* not YYPURE */
Reid Spencere812fb22006-01-19 01:21:04 +00001832
Chris Lattner8335e842006-01-23 23:05:42 +00001833#if YYDEBUG != 0
1834int yydebug; /* nonzero means print parse trace */
1835/* Since this is uninitialized, it does not stop multiple parsers
1836 from coexisting. */
Nate Begeman14b05292005-11-05 09:21:28 +00001837#endif
Reid Spencer0b118202006-01-16 21:12:35 +00001838
Chris Lattner8335e842006-01-23 23:05:42 +00001839/* YYINITDEPTH indicates the initial size of the parser's stacks */
Reid Spencer0b118202006-01-16 21:12:35 +00001840
Reid Spencer68a24bd2005-08-27 18:50:39 +00001841#ifndef YYINITDEPTH
Chris Lattner8335e842006-01-23 23:05:42 +00001842#define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00001843#endif
1844
Chris Lattner8335e842006-01-23 23:05:42 +00001845/* YYMAXDEPTH is the maximum size the stacks can grow to
1846 (effective only if the built-in stack extension method is used). */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001847
Chris Lattner8335e842006-01-23 23:05:42 +00001848#if YYMAXDEPTH == 0
1849#undef YYMAXDEPTH
Reid Spencer68a24bd2005-08-27 18:50:39 +00001850#endif
1851
1852#ifndef YYMAXDEPTH
Chris Lattner8335e842006-01-23 23:05:42 +00001853#define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00001854#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001855
Chris Lattner8335e842006-01-23 23:05:42 +00001856/* Define __yy_memcpy. Note that the size argument
1857 should be passed with type unsigned int, because that is what the non-GCC
1858 definitions require. With GCC, __builtin_memcpy takes an arg
1859 of type size_t, but it can handle unsigned int. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001860
Chris Lattner8335e842006-01-23 23:05:42 +00001861#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
1862#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
1863#else /* not GNU C or C++ */
1864#ifndef __cplusplus
Reid Spencer68a24bd2005-08-27 18:50:39 +00001865
Chris Lattner8335e842006-01-23 23:05:42 +00001866/* This is the most reliable way to avoid incompatibilities
1867 in available built-in functions on various systems. */
Reid Spencere812fb22006-01-19 01:21:04 +00001868static void
Chris Lattner8335e842006-01-23 23:05:42 +00001869__yy_memcpy (to, from, count)
1870 char *to;
1871 char *from;
1872 unsigned int count;
1873{
1874 register char *f = from;
1875 register char *t = to;
1876 register int i = count;
1877
1878 while (i-- > 0)
1879 *t++ = *f++;
1880}
1881
1882#else /* __cplusplus */
1883
1884/* This is the most reliable way to avoid incompatibilities
1885 in available built-in functions on various systems. */
Reid Spencere812fb22006-01-19 01:21:04 +00001886static void
Chris Lattner8335e842006-01-23 23:05:42 +00001887__yy_memcpy (char *to, char *from, unsigned int count)
1888{
1889 register char *t = to;
1890 register char *f = from;
1891 register int i = count;
1892
1893 while (i-- > 0)
1894 *t++ = *f++;
1895}
1896
Reid Spencer0b118202006-01-16 21:12:35 +00001897#endif
Reid Spencere812fb22006-01-19 01:21:04 +00001898#endif
Reid Spencere812fb22006-01-19 01:21:04 +00001899
Chris Lattner8335e842006-01-23 23:05:42 +00001900#line 217 "/usr/share/bison.simple"
Reid Spencere812fb22006-01-19 01:21:04 +00001901
Chris Lattner8335e842006-01-23 23:05:42 +00001902/* The user can define YYPARSE_PARAM as the name of an argument to be passed
1903 into yyparse. The argument should have type void *.
1904 It should actually point to an object.
1905 Grammar actions can access the variable by casting it
1906 to the proper pointer type. */
Reid Spencere812fb22006-01-19 01:21:04 +00001907
1908#ifdef YYPARSE_PARAM
Chris Lattner8335e842006-01-23 23:05:42 +00001909#ifdef __cplusplus
1910#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
1911#define YYPARSE_PARAM_DECL
1912#else /* not __cplusplus */
1913#define YYPARSE_PARAM_ARG YYPARSE_PARAM
1914#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
1915#endif /* not __cplusplus */
1916#else /* not YYPARSE_PARAM */
1917#define YYPARSE_PARAM_ARG
1918#define YYPARSE_PARAM_DECL
1919#endif /* not YYPARSE_PARAM */
1920
1921/* Prevent warning if -Wstrict-prototypes. */
1922#ifdef __GNUC__
1923#ifdef YYPARSE_PARAM
1924int yyparse (void *);
1925#else
Reid Spencere812fb22006-01-19 01:21:04 +00001926int yyparse (void);
Reid Spencere812fb22006-01-19 01:21:04 +00001927#endif
Chris Lattner8335e842006-01-23 23:05:42 +00001928#endif
Reid Spencere812fb22006-01-19 01:21:04 +00001929
Reid Spencere812fb22006-01-19 01:21:04 +00001930int
Chris Lattner8335e842006-01-23 23:05:42 +00001931yyparse(YYPARSE_PARAM_ARG)
1932 YYPARSE_PARAM_DECL
Reid Spencere812fb22006-01-19 01:21:04 +00001933{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001934 register int yystate;
1935 register int yyn;
Nate Begeman14b05292005-11-05 09:21:28 +00001936 register short *yyssp;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001937 register YYSTYPE *yyvsp;
Chris Lattner8335e842006-01-23 23:05:42 +00001938 int yyerrstatus; /* number of tokens to shift before error messages enabled */
1939 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001940
Chris Lattner8335e842006-01-23 23:05:42 +00001941 short yyssa[YYINITDEPTH]; /* the state stack */
1942 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001943
Chris Lattner8335e842006-01-23 23:05:42 +00001944 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
1945 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001946
Chris Lattner8335e842006-01-23 23:05:42 +00001947#ifdef YYLSP_NEEDED
1948 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
1949 YYLTYPE *yyls = yylsa;
1950 YYLTYPE *yylsp;
1951
1952#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
1953#else
Reid Spencer68a24bd2005-08-27 18:50:39 +00001954#define YYPOPSTACK (yyvsp--, yyssp--)
Chris Lattner8335e842006-01-23 23:05:42 +00001955#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001956
Chris Lattner8335e842006-01-23 23:05:42 +00001957 int yystacksize = YYINITDEPTH;
1958 int yyfree_stacks = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001959
Chris Lattner8335e842006-01-23 23:05:42 +00001960#ifdef YYPURE
1961 int yychar;
1962 YYSTYPE yylval;
1963 int yynerrs;
1964#ifdef YYLSP_NEEDED
1965 YYLTYPE yylloc;
1966#endif
1967#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001968
Chris Lattner8335e842006-01-23 23:05:42 +00001969 YYSTYPE yyval; /* the variable used to return */
1970 /* semantic values from the action */
1971 /* routines */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001972
Reid Spencer68a24bd2005-08-27 18:50:39 +00001973 int yylen;
1974
Chris Lattner8335e842006-01-23 23:05:42 +00001975#if YYDEBUG != 0
1976 if (yydebug)
1977 fprintf(stderr, "Starting parse\n");
1978#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001979
1980 yystate = 0;
1981 yyerrstatus = 0;
1982 yynerrs = 0;
1983 yychar = YYEMPTY; /* Cause a token to be read. */
1984
1985 /* Initialize stack pointers.
1986 Waste one element of value and location stack
1987 so that they stay on the same level as the state stack.
1988 The wasted elements are never initialized. */
1989
Chris Lattner8335e842006-01-23 23:05:42 +00001990 yyssp = yyss - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001991 yyvsp = yyvs;
Chris Lattner8335e842006-01-23 23:05:42 +00001992#ifdef YYLSP_NEEDED
1993 yylsp = yyls;
1994#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001995
Chris Lattner8335e842006-01-23 23:05:42 +00001996/* Push a new state, which is found in yystate . */
1997/* In all cases, when you get here, the value and location stacks
1998 have just been pushed. so pushing a state here evens the stacks. */
1999yynewstate:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002000
Chris Lattner8335e842006-01-23 23:05:42 +00002001 *++yyssp = yystate;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002002
Chris Lattner8335e842006-01-23 23:05:42 +00002003 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002004 {
Chris Lattner8335e842006-01-23 23:05:42 +00002005 /* Give user a chance to reallocate the stack */
2006 /* Use copies of these so that the &'s don't force the real ones into memory. */
2007 YYSTYPE *yyvs1 = yyvs;
2008 short *yyss1 = yyss;
2009#ifdef YYLSP_NEEDED
2010 YYLTYPE *yyls1 = yyls;
2011#endif
2012
Reid Spencer68a24bd2005-08-27 18:50:39 +00002013 /* Get the current used size of the three stacks, in elements. */
Chris Lattner8335e842006-01-23 23:05:42 +00002014 int size = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002015
2016#ifdef yyoverflow
Chris Lattner8335e842006-01-23 23:05:42 +00002017 /* Each stack pointer address is followed by the size of
2018 the data in use in that stack, in bytes. */
2019#ifdef YYLSP_NEEDED
2020 /* This used to be a conditional around just the two extra args,
2021 but that might be undefined if yyoverflow is a macro. */
2022 yyoverflow("parser stack overflow",
2023 &yyss1, size * sizeof (*yyssp),
2024 &yyvs1, size * sizeof (*yyvsp),
2025 &yyls1, size * sizeof (*yylsp),
2026 &yystacksize);
2027#else
2028 yyoverflow("parser stack overflow",
2029 &yyss1, size * sizeof (*yyssp),
2030 &yyvs1, size * sizeof (*yyvsp),
2031 &yystacksize);
2032#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002033
Chris Lattner8335e842006-01-23 23:05:42 +00002034 yyss = yyss1; yyvs = yyvs1;
2035#ifdef YYLSP_NEEDED
2036 yyls = yyls1;
2037#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002038#else /* no yyoverflow */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002039 /* Extend the stack our own way. */
Chris Lattner8335e842006-01-23 23:05:42 +00002040 if (yystacksize >= YYMAXDEPTH)
2041 {
2042 yyerror("parser stack overflow");
2043 if (yyfree_stacks)
2044 {
2045 free (yyss);
2046 free (yyvs);
2047#ifdef YYLSP_NEEDED
2048 free (yyls);
2049#endif
2050 }
2051 return 2;
2052 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002053 yystacksize *= 2;
Chris Lattner8335e842006-01-23 23:05:42 +00002054 if (yystacksize > YYMAXDEPTH)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002055 yystacksize = YYMAXDEPTH;
Chris Lattner8335e842006-01-23 23:05:42 +00002056#ifndef YYSTACK_USE_ALLOCA
2057 yyfree_stacks = 1;
2058#endif
2059 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
2060 __yy_memcpy ((char *)yyss, (char *)yyss1,
2061 size * (unsigned int) sizeof (*yyssp));
2062 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
2063 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
2064 size * (unsigned int) sizeof (*yyvsp));
2065#ifdef YYLSP_NEEDED
2066 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
2067 __yy_memcpy ((char *)yyls, (char *)yyls1,
2068 size * (unsigned int) sizeof (*yylsp));
2069#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002070#endif /* no yyoverflow */
2071
Chris Lattner8335e842006-01-23 23:05:42 +00002072 yyssp = yyss + size - 1;
2073 yyvsp = yyvs + size - 1;
2074#ifdef YYLSP_NEEDED
2075 yylsp = yyls + size - 1;
2076#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002077
Chris Lattner8335e842006-01-23 23:05:42 +00002078#if YYDEBUG != 0
2079 if (yydebug)
2080 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2081#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002082
Chris Lattner8335e842006-01-23 23:05:42 +00002083 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002084 YYABORT;
2085 }
2086
Chris Lattner8335e842006-01-23 23:05:42 +00002087#if YYDEBUG != 0
2088 if (yydebug)
2089 fprintf(stderr, "Entering state %d\n", yystate);
2090#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002091
2092 goto yybackup;
Chris Lattner8335e842006-01-23 23:05:42 +00002093 yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002094
2095/* Do appropriate processing given the current state. */
2096/* Read a lookahead token if we need one and don't already have one. */
2097/* yyresume: */
2098
2099 /* First try to decide what to do without reference to lookahead token. */
2100
2101 yyn = yypact[yystate];
Chris Lattner8335e842006-01-23 23:05:42 +00002102 if (yyn == YYFLAG)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002103 goto yydefault;
2104
2105 /* Not known => get a lookahead token if don't already have one. */
2106
Chris Lattner8335e842006-01-23 23:05:42 +00002107 /* yychar is either YYEMPTY or YYEOF
2108 or a valid token in external form. */
2109
Reid Spencer68a24bd2005-08-27 18:50:39 +00002110 if (yychar == YYEMPTY)
2111 {
Chris Lattner8335e842006-01-23 23:05:42 +00002112#if YYDEBUG != 0
2113 if (yydebug)
2114 fprintf(stderr, "Reading a token: ");
2115#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002116 yychar = YYLEX;
2117 }
2118
Chris Lattner8335e842006-01-23 23:05:42 +00002119 /* Convert token to internal form (in yychar1) for indexing tables with */
2120
2121 if (yychar <= 0) /* This means end of input. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002122 {
Chris Lattner8335e842006-01-23 23:05:42 +00002123 yychar1 = 0;
2124 yychar = YYEOF; /* Don't call YYLEX any more */
2125
2126#if YYDEBUG != 0
2127 if (yydebug)
2128 fprintf(stderr, "Now at end of input.\n");
2129#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002130 }
2131 else
2132 {
Chris Lattner8335e842006-01-23 23:05:42 +00002133 yychar1 = YYTRANSLATE(yychar);
2134
2135#if YYDEBUG != 0
2136 if (yydebug)
2137 {
2138 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2139 /* Give the individual parser a way to print the precise meaning
2140 of a token, for further debugging info. */
2141#ifdef YYPRINT
2142 YYPRINT (stderr, yychar, yylval);
2143#endif
2144 fprintf (stderr, ")\n");
2145 }
2146#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002147 }
2148
Chris Lattner8335e842006-01-23 23:05:42 +00002149 yyn += yychar1;
2150 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002151 goto yydefault;
Chris Lattner8335e842006-01-23 23:05:42 +00002152
Reid Spencer68a24bd2005-08-27 18:50:39 +00002153 yyn = yytable[yyn];
Chris Lattner8335e842006-01-23 23:05:42 +00002154
2155 /* yyn is what to do for this token type in this state.
2156 Negative => reduce, -yyn is rule number.
2157 Positive => shift, yyn is new state.
2158 New state is final state => don't bother to shift,
2159 just return success.
2160 0, or most negative number => error. */
2161
2162 if (yyn < 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002163 {
Chris Lattner8335e842006-01-23 23:05:42 +00002164 if (yyn == YYFLAG)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002165 goto yyerrlab;
2166 yyn = -yyn;
2167 goto yyreduce;
2168 }
Chris Lattner8335e842006-01-23 23:05:42 +00002169 else if (yyn == 0)
2170 goto yyerrlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002171
2172 if (yyn == YYFINAL)
2173 YYACCEPT;
2174
2175 /* Shift the lookahead token. */
Chris Lattner8335e842006-01-23 23:05:42 +00002176
2177#if YYDEBUG != 0
2178 if (yydebug)
2179 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2180#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002181
2182 /* Discard the token being shifted unless it is eof. */
2183 if (yychar != YYEOF)
2184 yychar = YYEMPTY;
2185
2186 *++yyvsp = yylval;
Chris Lattner8335e842006-01-23 23:05:42 +00002187#ifdef YYLSP_NEEDED
2188 *++yylsp = yylloc;
2189#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002190
Chris Lattner8335e842006-01-23 23:05:42 +00002191 /* count tokens shifted since error; after three, turn off error status. */
2192 if (yyerrstatus) yyerrstatus--;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002193
2194 yystate = yyn;
2195 goto yynewstate;
2196
Chris Lattner8335e842006-01-23 23:05:42 +00002197/* Do the default action for the current state. */
Reid Spencere812fb22006-01-19 01:21:04 +00002198yydefault:
Chris Lattner8335e842006-01-23 23:05:42 +00002199
Reid Spencer68a24bd2005-08-27 18:50:39 +00002200 yyn = yydefact[yystate];
2201 if (yyn == 0)
2202 goto yyerrlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002203
Chris Lattner8335e842006-01-23 23:05:42 +00002204/* Do a reduction. yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002205yyreduce:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002206 yylen = yyr2[yyn];
Chris Lattner8335e842006-01-23 23:05:42 +00002207 if (yylen > 0)
2208 yyval = yyvsp[1-yylen]; /* implement default value of the action */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002209
Chris Lattner8335e842006-01-23 23:05:42 +00002210#if YYDEBUG != 0
2211 if (yydebug)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002212 {
Chris Lattner8335e842006-01-23 23:05:42 +00002213 int i;
2214
2215 fprintf (stderr, "Reducing via rule %d (line %d), ",
2216 yyn, yyrline[yyn]);
2217
2218 /* Print the symbols being reduced, and their result. */
2219 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2220 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2221 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2222 }
2223#endif
2224
2225
2226 switch (yyn) {
2227
2228case 2:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002229#line 1011 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002230{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002231 if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX) // Outside of my range!
2232 ThrowException("Value too large for type!");
2233 yyval.SIntVal = (int32_t)yyvsp[0].UIntVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002234;
2235 break;}
2236case 4:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002237#line 1019 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002238{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002239 if (yyvsp[0].UInt64Val > (uint64_t)INT64_MAX) // Outside of my range!
2240 ThrowException("Value too large for type!");
2241 yyval.SInt64Val = (int64_t)yyvsp[0].UInt64Val;
Chris Lattner8335e842006-01-23 23:05:42 +00002242;
2243 break;}
2244case 33:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002245#line 1042 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002246{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002247 yyval.StrVal = yyvsp[-1].StrVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002248 ;
2249 break;}
2250case 34:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002251#line 1045 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002252{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002253 yyval.StrVal = 0;
Chris Lattner8335e842006-01-23 23:05:42 +00002254 ;
2255 break;}
2256case 35:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002257#line 1049 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002258{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2259 break;}
2260case 36:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002261#line 1050 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002262{ yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2263 break;}
2264case 37:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002265#line 1051 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002266{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2267 break;}
2268case 38:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002269#line 1052 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002270{ yyval.Linkage = GlobalValue::AppendingLinkage; ;
2271 break;}
2272case 39:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002273#line 1053 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002274{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2275 break;}
2276case 40:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002277#line 1055 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002278{ yyval.UIntVal = CallingConv::C; ;
2279 break;}
2280case 41:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002281#line 1056 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002282{ yyval.UIntVal = CallingConv::C; ;
2283 break;}
2284case 42:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002285#line 1057 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002286{ yyval.UIntVal = CallingConv::Fast; ;
2287 break;}
2288case 43:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002289#line 1058 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002290{ yyval.UIntVal = CallingConv::Cold; ;
2291 break;}
2292case 44:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002293#line 1059 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002294{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002295 if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
2296 ThrowException("Calling conv too large!");
2297 yyval.UIntVal = yyvsp[0].UInt64Val;
Chris Lattner8335e842006-01-23 23:05:42 +00002298 ;
2299 break;}
2300case 45:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002301#line 1067 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002302{ yyval.UIntVal = 0; ;
2303 break;}
2304case 46:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002305#line 1068 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002306{
Chris Lattnerb475c422005-11-12 18:22:38 +00002307 yyval.UIntVal = yyvsp[0].UInt64Val;
2308 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
2309 ThrowException("Alignment must be a power of two!");
Chris Lattner8335e842006-01-23 23:05:42 +00002310;
2311 break;}
2312case 47:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002313#line 1073 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002314{ yyval.UIntVal = 0; ;
2315 break;}
2316case 48:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002317#line 1074 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002318{
Chris Lattnerb475c422005-11-12 18:22:38 +00002319 yyval.UIntVal = yyvsp[0].UInt64Val;
2320 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
2321 ThrowException("Alignment must be a power of two!");
Chris Lattner8335e842006-01-23 23:05:42 +00002322;
2323 break;}
2324case 49:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002325#line 1081 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002326{
Chris Lattnere869eef2005-11-12 00:11:49 +00002327 for (unsigned i = 0, e = strlen(yyvsp[0].StrVal); i != e; ++i)
2328 if (yyvsp[0].StrVal[i] == '"' || yyvsp[0].StrVal[i] == '\\')
2329 ThrowException("Invalid character in section name!");
2330 yyval.StrVal = yyvsp[0].StrVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002331;
2332 break;}
2333case 50:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002334#line 1088 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002335{ yyval.StrVal = 0; ;
2336 break;}
2337case 51:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002338#line 1089 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002339{ yyval.StrVal = yyvsp[0].StrVal; ;
2340 break;}
2341case 52:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002342#line 1094 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002343{;
2344 break;}
2345case 53:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002346#line 1095 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002347{;
2348 break;}
2349case 54:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002350#line 1096 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002351{
Chris Lattnerb475c422005-11-12 18:22:38 +00002352 CurGV->setSection(yyvsp[0].StrVal);
2353 free(yyvsp[0].StrVal);
Chris Lattner8335e842006-01-23 23:05:42 +00002354 ;
2355 break;}
2356case 55:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002357#line 1100 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002358{
Chris Lattner7aa61892005-12-21 17:53:23 +00002359 if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val))
2360 ThrowException("Alignment must be a power of two!");
Chris Lattnerb475c422005-11-12 18:22:38 +00002361 CurGV->setAlignment(yyvsp[0].UInt64Val);
Chris Lattner8335e842006-01-23 23:05:42 +00002362 ;
2363 break;}
2364case 57:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002365#line 1113 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002366{ yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2367 break;}
2368case 59:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002369#line 1114 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002370{ yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2371 break;}
2372case 60:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002373#line 1116 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002374{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002375 if (!UpRefs.empty())
2376 ThrowException("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
2377 yyval.TypeVal = yyvsp[0].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002378 ;
2379 break;}
2380case 74:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002381#line 1127 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002382{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002383 yyval.TypeVal = new PATypeHolder(OpaqueType::get());
Chris Lattner8335e842006-01-23 23:05:42 +00002384 ;
2385 break;}
2386case 75:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002387#line 1130 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002388{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002389 yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
Chris Lattner8335e842006-01-23 23:05:42 +00002390 ;
2391 break;}
2392case 76:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002393#line 1133 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002394{ // Named types are also simple types...
Reid Spencer68a24bd2005-08-27 18:50:39 +00002395 yyval.TypeVal = new PATypeHolder(getTypeVal(yyvsp[0].ValIDVal));
Chris Lattner8335e842006-01-23 23:05:42 +00002396;
2397 break;}
2398case 77:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002399#line 1139 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002400{ // Type UpReference
Reid Spencer68a24bd2005-08-27 18:50:39 +00002401 if (yyvsp[0].UInt64Val > (uint64_t)~0U) ThrowException("Value out of range!");
2402 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
2403 UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector...
2404 yyval.TypeVal = new PATypeHolder(OT);
2405 UR_OUT("New Upreference!\n");
Chris Lattner8335e842006-01-23 23:05:42 +00002406 ;
2407 break;}
2408case 78:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002409#line 1146 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002410{ // Function derived type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002411 std::vector<const Type*> Params;
2412 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2413 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2414 Params.push_back(*I);
2415 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
2416 if (isVarArg) Params.pop_back();
2417
2418 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FunctionType::get(*yyvsp[-3].TypeVal,Params,isVarArg)));
2419 delete yyvsp[-1].TypeList; // Delete the argument list
2420 delete yyvsp[-3].TypeVal; // Delete the return type handle
Chris Lattner8335e842006-01-23 23:05:42 +00002421 ;
2422 break;}
2423case 79:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002424#line 1158 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002425{ // Sized array type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002426 yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2427 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002428 ;
2429 break;}
2430case 80:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002431#line 1162 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002432{ // Packed array type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002433 const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
Chris Lattner9547d7f2005-11-10 01:42:43 +00002434 if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002435 ThrowException("Unsigned result not equal to signed result");
Chris Lattner9547d7f2005-11-10 01:42:43 +00002436 if (!ElemTy->isPrimitiveType())
Reid Spencer68a24bd2005-08-27 18:50:39 +00002437 ThrowException("Elemental type of a PackedType must be primitive");
Chris Lattner9547d7f2005-11-10 01:42:43 +00002438 if (!isPowerOf2_32(yyvsp[-3].UInt64Val))
2439 ThrowException("Vector length should be a power of 2!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00002440 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PackedType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2441 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002442 ;
2443 break;}
2444case 81:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002445#line 1173 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002446{ // Structure type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002447 std::vector<const Type*> Elements;
2448 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2449 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2450 Elements.push_back(*I);
2451
2452 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
2453 delete yyvsp[-1].TypeList;
Chris Lattner8335e842006-01-23 23:05:42 +00002454 ;
2455 break;}
2456case 82:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002457#line 1182 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002458{ // Empty structure type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002459 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Chris Lattner8335e842006-01-23 23:05:42 +00002460 ;
2461 break;}
2462case 83:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002463#line 1185 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002464{ // Pointer type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002465 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal)));
2466 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002467 ;
2468 break;}
2469case 84:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002470#line 1193 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002471{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002472 yyval.TypeList = new std::list<PATypeHolder>();
2473 yyval.TypeList->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002474 ;
2475 break;}
2476case 85:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002477#line 1197 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002478{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002479 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002480 ;
2481 break;}
2482case 87:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002483#line 1203 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002484{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002485 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(Type::VoidTy);
Chris Lattner8335e842006-01-23 23:05:42 +00002486 ;
2487 break;}
2488case 88:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002489#line 1206 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002490{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002491 (yyval.TypeList = new std::list<PATypeHolder>())->push_back(Type::VoidTy);
Chris Lattner8335e842006-01-23 23:05:42 +00002492 ;
2493 break;}
2494case 89:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002495#line 1209 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002496{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002497 yyval.TypeList = new std::list<PATypeHolder>();
Chris Lattner8335e842006-01-23 23:05:42 +00002498 ;
2499 break;}
2500case 90:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002501#line 1219 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002502{ // Nonempty unsized arr
Reid Spencer68a24bd2005-08-27 18:50:39 +00002503 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
2504 if (ATy == 0)
2505 ThrowException("Cannot make array constant with type: '" +
2506 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2507 const Type *ETy = ATy->getElementType();
2508 int NumElements = ATy->getNumElements();
2509
2510 // Verify that we have the correct size...
2511 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2512 ThrowException("Type mismatch: constant sized array initialized with " +
2513 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
2514 itostr(NumElements) + "!");
2515
2516 // Verify all elements are correct type!
2517 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2518 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2519 ThrowException("Element #" + utostr(i) + " is not of type '" +
2520 ETy->getDescription() +"' as required!\nIt is of type '"+
2521 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2522 }
2523
2524 yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
2525 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Chris Lattner8335e842006-01-23 23:05:42 +00002526 ;
2527 break;}
2528case 91:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002529#line 1244 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002530{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002531 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2532 if (ATy == 0)
2533 ThrowException("Cannot make array constant with type: '" +
2534 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2535
2536 int NumElements = ATy->getNumElements();
2537 if (NumElements != -1 && NumElements != 0)
2538 ThrowException("Type mismatch: constant sized array initialized with 0"
2539 " arguments, but has size of " + itostr(NumElements) +"!");
2540 yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
2541 delete yyvsp[-2].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002542 ;
2543 break;}
2544case 92:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002545#line 1257 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002546{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002547 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2548 if (ATy == 0)
2549 ThrowException("Cannot make array constant with type: '" +
2550 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2551
2552 int NumElements = ATy->getNumElements();
2553 const Type *ETy = ATy->getElementType();
2554 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
2555 if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal))
2556 ThrowException("Can't build string constant of size " +
2557 itostr((int)(EndStr-yyvsp[0].StrVal)) +
2558 " when array has size " + itostr(NumElements) + "!");
2559 std::vector<Constant*> Vals;
2560 if (ETy == Type::SByteTy) {
Chris Lattner66316012006-01-24 04:14:29 +00002561 for (signed char *C = (signed char *)yyvsp[0].StrVal; C != (signed char *)EndStr; ++C)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002562 Vals.push_back(ConstantSInt::get(ETy, *C));
2563 } else if (ETy == Type::UByteTy) {
Chris Lattner66316012006-01-24 04:14:29 +00002564 for (unsigned char *C = (unsigned char *)yyvsp[0].StrVal;
2565 C != (unsigned char*)EndStr; ++C)
2566 Vals.push_back(ConstantUInt::get(ETy, *C));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002567 } else {
2568 free(yyvsp[0].StrVal);
2569 ThrowException("Cannot build string arrays of non byte sized elements!");
2570 }
2571 free(yyvsp[0].StrVal);
2572 yyval.ConstVal = ConstantArray::get(ATy, Vals);
2573 delete yyvsp[-2].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002574 ;
2575 break;}
2576case 93:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002577#line 1286 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002578{ // Nonempty unsized arr
Reid Spencer68a24bd2005-08-27 18:50:39 +00002579 const PackedType *PTy = dyn_cast<PackedType>(yyvsp[-3].TypeVal->get());
2580 if (PTy == 0)
2581 ThrowException("Cannot make packed constant with type: '" +
2582 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2583 const Type *ETy = PTy->getElementType();
2584 int NumElements = PTy->getNumElements();
2585
2586 // Verify that we have the correct size...
2587 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2588 ThrowException("Type mismatch: constant sized packed initialized with " +
2589 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
2590 itostr(NumElements) + "!");
2591
2592 // Verify all elements are correct type!
2593 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2594 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2595 ThrowException("Element #" + utostr(i) + " is not of type '" +
2596 ETy->getDescription() +"' as required!\nIt is of type '"+
2597 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2598 }
2599
2600 yyval.ConstVal = ConstantPacked::get(PTy, *yyvsp[-1].ConstVector);
2601 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Chris Lattner8335e842006-01-23 23:05:42 +00002602 ;
2603 break;}
2604case 94:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002605#line 1311 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002606{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002607 const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
2608 if (STy == 0)
2609 ThrowException("Cannot make struct constant with type: '" +
2610 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2611
2612 if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
2613 ThrowException("Illegal number of initializers for structure type!");
2614
2615 // Check to ensure that constants are compatible with the type initializer!
2616 for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
2617 if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
2618 ThrowException("Expected type '" +
2619 STy->getElementType(i)->getDescription() +
2620 "' for element #" + utostr(i) +
2621 " of structure initializer!");
2622
2623 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
2624 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Chris Lattner8335e842006-01-23 23:05:42 +00002625 ;
2626 break;}
2627case 95:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002628#line 1331 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002629{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002630 const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
2631 if (STy == 0)
2632 ThrowException("Cannot make struct constant with type: '" +
2633 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2634
2635 if (STy->getNumContainedTypes() != 0)
2636 ThrowException("Illegal number of initializers for structure type!");
2637
2638 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
2639 delete yyvsp[-2].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002640 ;
2641 break;}
2642case 96:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002643#line 1343 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002644{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002645 const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
2646 if (PTy == 0)
2647 ThrowException("Cannot make null pointer constant with type: '" +
2648 (*yyvsp[-1].TypeVal)->getDescription() + "'!");
2649
2650 yyval.ConstVal = ConstantPointerNull::get(PTy);
2651 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002652 ;
2653 break;}
2654case 97:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002655#line 1352 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002656{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002657 yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
2658 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002659 ;
2660 break;}
2661case 98:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002662#line 1356 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002663{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002664 const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
2665 if (Ty == 0)
2666 ThrowException("Global const reference must be a pointer type!");
2667
2668 // ConstExprs can exist in the body of a function, thus creating
2669 // GlobalValues whenever they refer to a variable. Because we are in
2670 // the context of a function, getValNonImprovising will search the functions
2671 // symbol table instead of the module symbol table for the global symbol,
2672 // which throws things all off. To get around this, we just tell
2673 // getValNonImprovising that we are at global scope here.
2674 //
2675 Function *SavedCurFn = CurFun.CurrentFunction;
2676 CurFun.CurrentFunction = 0;
2677
2678 Value *V = getValNonImprovising(Ty, yyvsp[0].ValIDVal);
2679
2680 CurFun.CurrentFunction = SavedCurFn;
2681
2682 // If this is an initializer for a constant pointer, which is referencing a
2683 // (currently) undefined variable, create a stub now that shall be replaced
2684 // in the future with the right type of variable.
2685 //
2686 if (V == 0) {
2687 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
2688 const PointerType *PT = cast<PointerType>(Ty);
2689
2690 // First check to see if the forward references value is already created!
2691 PerModuleInfo::GlobalRefsType::iterator I =
2692 CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
2693
2694 if (I != CurModule.GlobalRefs.end()) {
2695 V = I->second; // Placeholder already exists, use it...
2696 yyvsp[0].ValIDVal.destroy();
2697 } else {
2698 std::string Name;
2699 if (yyvsp[0].ValIDVal.Type == ValID::NameVal) Name = yyvsp[0].ValIDVal.Name;
2700
2701 // Create the forward referenced global.
2702 GlobalValue *GV;
2703 if (const FunctionType *FTy =
2704 dyn_cast<FunctionType>(PT->getElementType())) {
2705 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
2706 CurModule.CurrentModule);
2707 } else {
2708 GV = new GlobalVariable(PT->getElementType(), false,
2709 GlobalValue::ExternalLinkage, 0,
2710 Name, CurModule.CurrentModule);
2711 }
2712
2713 // Keep track of the fact that we have a forward ref to recycle it
2714 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
2715 V = GV;
2716 }
2717 }
2718
2719 yyval.ConstVal = cast<GlobalValue>(V);
2720 delete yyvsp[-1].TypeVal; // Free the type handle
Chris Lattner8335e842006-01-23 23:05:42 +00002721 ;
2722 break;}
2723case 99:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002724#line 1415 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002725{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002726 if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
2727 ThrowException("Mismatched types for constant expression!");
2728 yyval.ConstVal = yyvsp[0].ConstVal;
2729 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002730 ;
2731 break;}
2732case 100:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002733#line 1421 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002734{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002735 const Type *Ty = yyvsp[-1].TypeVal->get();
2736 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
2737 ThrowException("Cannot create a null initialized value of this type!");
2738 yyval.ConstVal = Constant::getNullValue(Ty);
2739 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002740 ;
2741 break;}
2742case 101:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002743#line 1429 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002744{ // integral constants
Reid Spencer68a24bd2005-08-27 18:50:39 +00002745 if (!ConstantSInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
2746 ThrowException("Constant value doesn't fit in type!");
2747 yyval.ConstVal = ConstantSInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val);
Chris Lattner8335e842006-01-23 23:05:42 +00002748 ;
2749 break;}
2750case 102:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002751#line 1434 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002752{ // integral constants
Reid Spencer68a24bd2005-08-27 18:50:39 +00002753 if (!ConstantUInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
2754 ThrowException("Constant value doesn't fit in type!");
2755 yyval.ConstVal = ConstantUInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val);
Chris Lattner8335e842006-01-23 23:05:42 +00002756 ;
2757 break;}
2758case 103:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002759#line 1439 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002760{ // Boolean constants
Reid Spencer68a24bd2005-08-27 18:50:39 +00002761 yyval.ConstVal = ConstantBool::True;
Chris Lattner8335e842006-01-23 23:05:42 +00002762 ;
2763 break;}
2764case 104:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002765#line 1442 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002766{ // Boolean constants
Reid Spencer68a24bd2005-08-27 18:50:39 +00002767 yyval.ConstVal = ConstantBool::False;
Chris Lattner8335e842006-01-23 23:05:42 +00002768 ;
2769 break;}
2770case 105:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002771#line 1445 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002772{ // Float & Double constants
Reid Spencer68a24bd2005-08-27 18:50:39 +00002773 if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal))
2774 ThrowException("Floating point constant invalid for type!!");
2775 yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal);
Chris Lattner8335e842006-01-23 23:05:42 +00002776 ;
2777 break;}
2778case 106:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002779#line 1452 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002780{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002781 if (!yyvsp[-3].ConstVal->getType()->isFirstClassType())
2782 ThrowException("cast constant expression from a non-primitive type: '" +
2783 yyvsp[-3].ConstVal->getType()->getDescription() + "'!");
2784 if (!yyvsp[-1].TypeVal->get()->isFirstClassType())
2785 ThrowException("cast constant expression to a non-primitive type: '" +
2786 yyvsp[-1].TypeVal->get()->getDescription() + "'!");
2787 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-3].ConstVal, yyvsp[-1].TypeVal->get());
2788 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002789 ;
2790 break;}
2791case 107:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002792#line 1462 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002793{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002794 if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
2795 ThrowException("GetElementPtr requires a pointer operand!");
2796
2797 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
2798 // indices to uint struct indices for compatibility.
2799 generic_gep_type_iterator<std::vector<Value*>::iterator>
2800 GTI = gep_type_begin(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end()),
2801 GTE = gep_type_end(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end());
2802 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
2803 if (isa<StructType>(*GTI)) // Only change struct indices
2804 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[-1].ValueList)[i]))
2805 if (CUI->getType() == Type::UByteTy)
2806 (*yyvsp[-1].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
2807
2808 const Type *IdxTy =
2809 GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), *yyvsp[-1].ValueList, true);
2810 if (!IdxTy)
2811 ThrowException("Index list invalid for constant getelementptr!");
2812
2813 std::vector<Constant*> IdxVec;
2814 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
2815 if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
2816 IdxVec.push_back(C);
2817 else
2818 ThrowException("Indices to constant getelementptr must be constants!");
2819
2820 delete yyvsp[-1].ValueList;
2821
2822 yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, IdxVec);
Chris Lattner8335e842006-01-23 23:05:42 +00002823 ;
2824 break;}
2825case 108:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002826#line 1493 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002827{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002828 if (yyvsp[-5].ConstVal->getType() != Type::BoolTy)
2829 ThrowException("Select condition must be of boolean type!");
2830 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2831 ThrowException("Select operand types must match!");
2832 yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Chris Lattner8335e842006-01-23 23:05:42 +00002833 ;
2834 break;}
2835case 109:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002836#line 1500 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002837{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002838 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2839 ThrowException("Binary operator types must match!");
2840 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
2841 // To retain backward compatibility with these early compilers, we emit a
2842 // cast to the appropriate integer type automatically if we are in the
2843 // broken case. See PR424 for more information.
2844 if (!isa<PointerType>(yyvsp[-3].ConstVal->getType())) {
2845 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2846 } else {
2847 const Type *IntPtrTy = 0;
2848 switch (CurModule.CurrentModule->getPointerSize()) {
2849 case Module::Pointer32: IntPtrTy = Type::IntTy; break;
2850 case Module::Pointer64: IntPtrTy = Type::LongTy; break;
2851 default: ThrowException("invalid pointer binary constant expr!");
2852 }
2853 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, ConstantExpr::getCast(yyvsp[-3].ConstVal, IntPtrTy),
2854 ConstantExpr::getCast(yyvsp[-1].ConstVal, IntPtrTy));
2855 yyval.ConstVal = ConstantExpr::getCast(yyval.ConstVal, yyvsp[-3].ConstVal->getType());
2856 }
Chris Lattner8335e842006-01-23 23:05:42 +00002857 ;
2858 break;}
2859case 110:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002860#line 1521 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002861{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002862 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2863 ThrowException("Logical operator types must match!");
Chris Lattner524a1312005-12-21 18:31:50 +00002864 if (!yyvsp[-3].ConstVal->getType()->isIntegral()) {
2865 if (!isa<PackedType>(yyvsp[-3].ConstVal->getType()) ||
2866 !cast<PackedType>(yyvsp[-3].ConstVal->getType())->getElementType()->isIntegral())
2867 ThrowException("Logical operator requires integral operands!");
2868 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002869 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Chris Lattner8335e842006-01-23 23:05:42 +00002870 ;
2871 break;}
2872case 111:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002873#line 1531 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002874{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002875 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2876 ThrowException("setcc operand types must match!");
2877 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Chris Lattner8335e842006-01-23 23:05:42 +00002878 ;
2879 break;}
2880case 112:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002881#line 1536 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002882{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002883 if (yyvsp[-1].ConstVal->getType() != Type::UByteTy)
2884 ThrowException("Shift count for shift constant must be unsigned byte!");
2885 if (!yyvsp[-3].ConstVal->getType()->isInteger())
2886 ThrowException("Shift constant expression requires integer operand!");
2887 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].OtherOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Chris Lattner8335e842006-01-23 23:05:42 +00002888 ;
2889 break;}
2890case 113:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002891#line 1543 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002892{
Robert Bocchino9c62b562006-01-10 19:04:32 +00002893 if (!isa<PackedType>(yyvsp[-3].ConstVal->getType()))
2894 ThrowException("First operand of extractelement must be "
2895 "packed type!");
2896 if (yyvsp[-1].ConstVal->getType() != Type::UIntTy)
2897 ThrowException("Second operand of extractelement must be uint!");
2898 yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Chris Lattner8335e842006-01-23 23:05:42 +00002899 ;
2900 break;}
2901case 114:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002902#line 1553 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002903{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002904 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
Chris Lattner8335e842006-01-23 23:05:42 +00002905 ;
2906 break;}
2907case 115:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002908#line 1556 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002909{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002910 yyval.ConstVector = new std::vector<Constant*>();
2911 yyval.ConstVector->push_back(yyvsp[0].ConstVal);
Chris Lattner8335e842006-01-23 23:05:42 +00002912 ;
2913 break;}
2914case 116:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002915#line 1563 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002916{ yyval.BoolVal = false; ;
2917 break;}
2918case 117:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002919#line 1563 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002920{ yyval.BoolVal = true; ;
2921 break;}
2922case 118:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002923#line 1573 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002924{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002925 yyval.ModuleVal = ParserResult = yyvsp[0].ModuleVal;
2926 CurModule.ModuleDone();
Chris Lattner8335e842006-01-23 23:05:42 +00002927;
2928 break;}
2929case 119:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002930#line 1580 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002931{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002932 yyval.ModuleVal = yyvsp[-1].ModuleVal;
2933 CurFun.FunctionDone();
Chris Lattner8335e842006-01-23 23:05:42 +00002934 ;
2935 break;}
2936case 120:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002937#line 1584 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002938{
Chris Lattner524a1312005-12-21 18:31:50 +00002939 yyval.ModuleVal = yyvsp[-1].ModuleVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002940 ;
2941 break;}
2942case 121:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002943#line 1587 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002944{
Chris Lattner66316012006-01-24 04:14:29 +00002945 yyval.ModuleVal = yyvsp[-3].ModuleVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002946 ;
2947 break;}
2948case 122:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002949#line 1590 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002950{
Robert Bocchino9c62b562006-01-10 19:04:32 +00002951 yyval.ModuleVal = yyvsp[-1].ModuleVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002952 ;
2953 break;}
2954case 123:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002955#line 1593 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002956{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002957 yyval.ModuleVal = CurModule.CurrentModule;
2958 // Emit an error if there are any unresolved types left.
2959 if (!CurModule.LateResolveTypes.empty()) {
2960 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
2961 if (DID.Type == ValID::NameVal)
2962 ThrowException("Reference to an undefined type: '"+DID.getName() + "'");
2963 else
2964 ThrowException("Reference to an undefined type: #" + itostr(DID.Num));
2965 }
Chris Lattner8335e842006-01-23 23:05:42 +00002966 ;
2967 break;}
2968case 124:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002969#line 1606 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002970{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002971 // Eagerly resolve types. This is not an optimization, this is a
2972 // requirement that is due to the fact that we could have this:
2973 //
2974 // %list = type { %list * }
2975 // %list = type { %list * } ; repeated type decl
2976 //
2977 // If types are not resolved eagerly, then the two types will not be
2978 // determined to be the same type!
2979 //
2980 ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
2981
2982 if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
2983 // If this is a named type that is not a redefinition, add it to the slot
2984 // table.
2985 CurModule.Types.push_back(*yyvsp[0].TypeVal);
2986 }
2987
2988 delete yyvsp[0].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002989 ;
2990 break;}
2991case 125:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002992#line 1626 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002993{ // Function prototypes can be in const pool
2994 ;
2995 break;}
2996case 126:
Chris Lattnerd5efe842006-04-08 01:18:56 +00002997#line 1628 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner66316012006-01-24 04:14:29 +00002998{ // Asm blocks can be in the const pool
Chris Lattner8335e842006-01-23 23:05:42 +00002999 ;
3000 break;}
3001case 127:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003002#line 1630 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003003{
Chris Lattnerb475c422005-11-12 18:22:38 +00003004 if (yyvsp[0].ConstVal == 0) ThrowException("Global value initializer is not a constant!");
3005 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, yyvsp[-2].Linkage, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003006 ;
3007 break;}
3008case 128:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003009#line 1633 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003010{
Chris Lattnerb475c422005-11-12 18:22:38 +00003011 CurGV = 0;
Chris Lattner8335e842006-01-23 23:05:42 +00003012 ;
3013 break;}
3014case 129:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003015#line 1636 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003016{
Chris Lattnerb475c422005-11-12 18:22:38 +00003017 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalLinkage,
3018 yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0);
3019 delete yyvsp[0].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003020 ;
3021 break;}
3022case 130:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003023#line 1640 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003024{
Chris Lattnerb475c422005-11-12 18:22:38 +00003025 CurGV = 0;
Chris Lattner8335e842006-01-23 23:05:42 +00003026 ;
3027 break;}
3028case 131:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003029#line 1643 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003030{
3031 ;
3032 break;}
3033case 132:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003034#line 1645 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003035{
3036 ;
3037 break;}
3038case 133:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003039#line 1647 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003040{
3041 ;
3042 break;}
3043case 134:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003044#line 1651 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003045{
Chris Lattner66316012006-01-24 04:14:29 +00003046 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
3047 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
3048 std::string NewAsm(yyvsp[0].StrVal, EndStr);
Chris Lattner8335e842006-01-23 23:05:42 +00003049 free(yyvsp[0].StrVal);
Chris Lattner66316012006-01-24 04:14:29 +00003050
3051 if (AsmSoFar.empty())
3052 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
3053 else
3054 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Chris Lattner8335e842006-01-23 23:05:42 +00003055;
3056 break;}
3057case 135:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003058#line 1663 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003059{ yyval.Endianness = Module::BigEndian; ;
3060 break;}
3061case 136:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003062#line 1664 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003063{ yyval.Endianness = Module::LittleEndian; ;
3064 break;}
3065case 137:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003066#line 1666 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003067{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003068 CurModule.CurrentModule->setEndianness(yyvsp[0].Endianness);
Chris Lattner8335e842006-01-23 23:05:42 +00003069 ;
3070 break;}
3071case 138:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003072#line 1669 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003073{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003074 if (yyvsp[0].UInt64Val == 32)
3075 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
3076 else if (yyvsp[0].UInt64Val == 64)
3077 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
3078 else
3079 ThrowException("Invalid pointer size: '" + utostr(yyvsp[0].UInt64Val) + "'!");
Chris Lattner8335e842006-01-23 23:05:42 +00003080 ;
3081 break;}
3082case 139:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003083#line 1677 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003084{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003085 CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal);
3086 free(yyvsp[0].StrVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003087 ;
3088 break;}
3089case 141:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003090#line 1684 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003091{
Robert Bocchino9c62b562006-01-10 19:04:32 +00003092 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3093 free(yyvsp[0].StrVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003094 ;
3095 break;}
Chris Lattner66316012006-01-24 04:14:29 +00003096case 142:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003097#line 1688 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003098{
Chris Lattner66316012006-01-24 04:14:29 +00003099 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3100 free(yyvsp[0].StrVal);
3101 ;
3102 break;}
3103case 143:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003104#line 1692 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner66316012006-01-24 04:14:29 +00003105{
Chris Lattner8335e842006-01-23 23:05:42 +00003106 ;
3107 break;}
3108case 147:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003109#line 1701 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003110{ yyval.StrVal = 0; ;
3111 break;}
3112case 148:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003113#line 1703 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003114{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003115 if (*yyvsp[-1].TypeVal == Type::VoidTy)
3116 ThrowException("void typed arguments are invalid!");
3117 yyval.ArgVal = new std::pair<PATypeHolder*, char*>(yyvsp[-1].TypeVal, yyvsp[0].StrVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003118;
3119 break;}
3120case 149:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003121#line 1709 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003122{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003123 yyval.ArgList = yyvsp[-2].ArgList;
3124 yyvsp[-2].ArgList->push_back(*yyvsp[0].ArgVal);
3125 delete yyvsp[0].ArgVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003126 ;
3127 break;}
3128case 150:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003129#line 1714 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003130{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003131 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
3132 yyval.ArgList->push_back(*yyvsp[0].ArgVal);
3133 delete yyvsp[0].ArgVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003134 ;
3135 break;}
3136case 151:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003137#line 1720 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003138{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003139 yyval.ArgList = yyvsp[0].ArgList;
Chris Lattner8335e842006-01-23 23:05:42 +00003140 ;
3141 break;}
3142case 152:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003143#line 1723 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003144{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003145 yyval.ArgList = yyvsp[-2].ArgList;
3146 yyval.ArgList->push_back(std::pair<PATypeHolder*,
3147 char*>(new PATypeHolder(Type::VoidTy), 0));
Chris Lattner8335e842006-01-23 23:05:42 +00003148 ;
3149 break;}
3150case 153:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003151#line 1728 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003152{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003153 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
3154 yyval.ArgList->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0));
Chris Lattner8335e842006-01-23 23:05:42 +00003155 ;
3156 break;}
3157case 154:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003158#line 1732 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003159{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003160 yyval.ArgList = 0;
Chris Lattner8335e842006-01-23 23:05:42 +00003161 ;
3162 break;}
3163case 155:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003164#line 1737 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003165{
Chris Lattnere869eef2005-11-12 00:11:49 +00003166 UnEscapeLexed(yyvsp[-5].StrVal);
3167 std::string FunctionName(yyvsp[-5].StrVal);
3168 free(yyvsp[-5].StrVal); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00003169
Chris Lattnere869eef2005-11-12 00:11:49 +00003170 if (!(*yyvsp[-6].TypeVal)->isFirstClassType() && *yyvsp[-6].TypeVal != Type::VoidTy)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003171 ThrowException("LLVM functions cannot return aggregate types!");
3172
3173 std::vector<const Type*> ParamTypeList;
Chris Lattnere869eef2005-11-12 00:11:49 +00003174 if (yyvsp[-3].ArgList) { // If there are arguments...
3175 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-3].ArgList->begin();
3176 I != yyvsp[-3].ArgList->end(); ++I)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003177 ParamTypeList.push_back(I->first->get());
3178 }
3179
3180 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
3181 if (isVarArg) ParamTypeList.pop_back();
3182
Chris Lattnere869eef2005-11-12 00:11:49 +00003183 const FunctionType *FT = FunctionType::get(*yyvsp[-6].TypeVal, ParamTypeList, isVarArg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003184 const PointerType *PFT = PointerType::get(FT);
Chris Lattnere869eef2005-11-12 00:11:49 +00003185 delete yyvsp[-6].TypeVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003186
3187 ValID ID;
3188 if (!FunctionName.empty()) {
3189 ID = ValID::create((char*)FunctionName.c_str());
3190 } else {
3191 ID = ValID::create((int)CurModule.Values[PFT].size());
3192 }
3193
3194 Function *Fn = 0;
3195 // See if this function was forward referenced. If so, recycle the object.
3196 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
3197 // Move the function to the end of the list, from whereever it was
3198 // previously inserted.
3199 Fn = cast<Function>(FWRef);
3200 CurModule.CurrentModule->getFunctionList().remove(Fn);
3201 CurModule.CurrentModule->getFunctionList().push_back(Fn);
3202 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
3203 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
3204 // If this is the case, either we need to be a forward decl, or it needs
3205 // to be.
3206 if (!CurFun.isDeclare && !Fn->isExternal())
3207 ThrowException("Redefinition of function '" + FunctionName + "'!");
3208
3209 // Make sure to strip off any argument names so we can't get conflicts.
3210 if (Fn->isExternal())
3211 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
3212 AI != AE; ++AI)
3213 AI->setName("");
3214
3215 } else { // Not already defined?
3216 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
3217 CurModule.CurrentModule);
3218 InsertValue(Fn, CurModule.Values);
3219 }
3220
3221 CurFun.FunctionStart(Fn);
Chris Lattnere869eef2005-11-12 00:11:49 +00003222 Fn->setCallingConv(yyvsp[-7].UIntVal);
Chris Lattner0019bbe2005-11-06 06:46:53 +00003223 Fn->setAlignment(yyvsp[0].UIntVal);
Chris Lattnere869eef2005-11-12 00:11:49 +00003224 if (yyvsp[-1].StrVal) {
3225 Fn->setSection(yyvsp[-1].StrVal);
3226 free(yyvsp[-1].StrVal);
3227 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00003228
3229 // Add all of the arguments we parsed to the function...
Chris Lattnere869eef2005-11-12 00:11:49 +00003230 if (yyvsp[-3].ArgList) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00003231 if (isVarArg) { // Nuke the last entry
Chris Lattnere869eef2005-11-12 00:11:49 +00003232 assert(yyvsp[-3].ArgList->back().first->get() == Type::VoidTy && yyvsp[-3].ArgList->back().second == 0&&
Reid Spencer68a24bd2005-08-27 18:50:39 +00003233 "Not a varargs marker!");
Chris Lattnere869eef2005-11-12 00:11:49 +00003234 delete yyvsp[-3].ArgList->back().first;
3235 yyvsp[-3].ArgList->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00003236 }
3237 Function::arg_iterator ArgIt = Fn->arg_begin();
Chris Lattnere869eef2005-11-12 00:11:49 +00003238 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-3].ArgList->begin();
3239 I != yyvsp[-3].ArgList->end(); ++I, ++ArgIt) {
Reid Spencer68a24bd2005-08-27 18:50:39 +00003240 delete I->first; // Delete the typeholder...
3241
3242 setValueName(ArgIt, I->second); // Insert arg into symtab...
3243 InsertValue(ArgIt);
3244 }
3245
Chris Lattnere869eef2005-11-12 00:11:49 +00003246 delete yyvsp[-3].ArgList; // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00003247 }
Chris Lattner8335e842006-01-23 23:05:42 +00003248;
3249 break;}
3250case 158:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003251#line 1824 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003252{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003253 yyval.FunctionVal = CurFun.CurrentFunction;
3254
3255 // Make sure that we keep track of the linkage type even if there was a
3256 // previous "declare".
3257 yyval.FunctionVal->setLinkage(yyvsp[-2].Linkage);
Chris Lattner8335e842006-01-23 23:05:42 +00003258;
3259 break;}
3260case 161:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003261#line 1834 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003262{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003263 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003264;
3265 break;}
3266case 162:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003267#line 1838 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003268{ CurFun.isDeclare = true; ;
3269 break;}
3270case 163:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003271#line 1838 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003272{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003273 yyval.FunctionVal = CurFun.CurrentFunction;
3274 CurFun.FunctionDone();
Chris Lattner8335e842006-01-23 23:05:42 +00003275;
3276 break;}
3277case 164:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003278#line 1847 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner0e9c3762006-01-25 22:27:16 +00003279{
3280 yyval.BoolVal = false;
3281 ;
3282 break;}
3283case 165:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003284#line 1850 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner0e9c3762006-01-25 22:27:16 +00003285{
3286 yyval.BoolVal = true;
3287 ;
3288 break;}
3289case 166:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003290#line 1854 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003291{ // A reference to a direct constant
Reid Spencer68a24bd2005-08-27 18:50:39 +00003292 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
Chris Lattner8335e842006-01-23 23:05:42 +00003293 ;
3294 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003295case 167:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003296#line 1857 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003297{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003298 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
Chris Lattner8335e842006-01-23 23:05:42 +00003299 ;
3300 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003301case 168:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003302#line 1860 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003303{ // Perhaps it's an FP constant?
Reid Spencer68a24bd2005-08-27 18:50:39 +00003304 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003305 ;
3306 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003307case 169:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003308#line 1863 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003309{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003310 yyval.ValIDVal = ValID::create(ConstantBool::True);
Chris Lattner8335e842006-01-23 23:05:42 +00003311 ;
3312 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003313case 170:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003314#line 1866 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003315{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003316 yyval.ValIDVal = ValID::create(ConstantBool::False);
Chris Lattner8335e842006-01-23 23:05:42 +00003317 ;
3318 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003319case 171:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003320#line 1869 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003321{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003322 yyval.ValIDVal = ValID::createNull();
Chris Lattner8335e842006-01-23 23:05:42 +00003323 ;
3324 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003325case 172:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003326#line 1872 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003327{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003328 yyval.ValIDVal = ValID::createUndef();
Chris Lattner8335e842006-01-23 23:05:42 +00003329 ;
3330 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003331case 173:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003332#line 1875 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003333{ // A vector zero constant.
Chris Lattner7aa61892005-12-21 17:53:23 +00003334 yyval.ValIDVal = ValID::createZeroInit();
Chris Lattner8335e842006-01-23 23:05:42 +00003335 ;
3336 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003337case 174:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003338#line 1878 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003339{ // Nonempty unsized packed vector
Reid Spencer68a24bd2005-08-27 18:50:39 +00003340 const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
3341 int NumElements = yyvsp[-1].ConstVector->size();
3342
3343 PackedType* pt = PackedType::get(ETy, NumElements);
3344 PATypeHolder* PTy = new PATypeHolder(
3345 HandleUpRefs(
3346 PackedType::get(
3347 ETy,
3348 NumElements)
3349 )
3350 );
3351
3352 // Verify all elements are correct type!
3353 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3354 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
3355 ThrowException("Element #" + utostr(i) + " is not of type '" +
3356 ETy->getDescription() +"' as required!\nIt is of type '" +
3357 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
3358 }
3359
3360 yyval.ValIDVal = ValID::create(ConstantPacked::get(pt, *yyvsp[-1].ConstVector));
3361 delete PTy; delete yyvsp[-1].ConstVector;
Chris Lattner8335e842006-01-23 23:05:42 +00003362 ;
3363 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003364case 175:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003365#line 1902 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003366{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003367 yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003368 ;
3369 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003370case 176:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003371#line 1905 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner0e9c3762006-01-25 22:27:16 +00003372{
3373 char *End = UnEscapeLexed(yyvsp[-2].StrVal, true);
3374 std::string AsmStr = std::string(yyvsp[-2].StrVal, End);
3375 End = UnEscapeLexed(yyvsp[0].StrVal, true);
3376 std::string Constraints = std::string(yyvsp[0].StrVal, End);
3377 yyval.ValIDVal = ValID::createInlineAsm(AsmStr, Constraints, yyvsp[-3].BoolVal);
3378 free(yyvsp[-2].StrVal);
3379 free(yyvsp[0].StrVal);
3380 ;
3381 break;}
3382case 177:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003383#line 1918 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003384{ // Is it an integer reference...?
Reid Spencer68a24bd2005-08-27 18:50:39 +00003385 yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003386 ;
3387 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003388case 178:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003389#line 1921 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003390{ // Is it a named reference...?
Reid Spencer68a24bd2005-08-27 18:50:39 +00003391 yyval.ValIDVal = ValID::create(yyvsp[0].StrVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003392 ;
3393 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003394case 181:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003395#line 1932 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003396{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003397 yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003398 ;
3399 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003400case 182:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003401#line 1936 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003402{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003403 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003404 ;
3405 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003406case 183:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003407#line 1939 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003408{ // Do not allow functions with 0 basic blocks
Reid Spencer68a24bd2005-08-27 18:50:39 +00003409 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003410 ;
3411 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003412case 184:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003413#line 1947 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003414{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003415 setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
3416 InsertValue(yyvsp[0].TermInstVal);
3417
3418 yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
3419 InsertValue(yyvsp[-2].BasicBlockVal);
3420 yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003421 ;
3422 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003423case 185:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003424#line 1956 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003425{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003426 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
3427 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003428 ;
3429 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003430case 186:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003431#line 1960 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003432{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003433 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
3434
3435 // Make sure to move the basic block to the correct location in the
3436 // function, instead of leaving it inserted wherever it was first
3437 // referenced.
3438 Function::BasicBlockListType &BBL =
3439 CurFun.CurrentFunction->getBasicBlockList();
3440 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003441 ;
3442 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003443case 187:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003444#line 1970 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003445{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003446 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create(yyvsp[0].StrVal), true);
3447
3448 // Make sure to move the basic block to the correct location in the
3449 // function, instead of leaving it inserted wherever it was first
3450 // referenced.
3451 Function::BasicBlockListType &BBL =
3452 CurFun.CurrentFunction->getBasicBlockList();
3453 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003454 ;
3455 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003456case 188:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003457#line 1981 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003458{ // Return with a result...
Reid Spencer68a24bd2005-08-27 18:50:39 +00003459 yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003460 ;
3461 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003462case 189:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003463#line 1984 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003464{ // Return with no result...
Reid Spencer68a24bd2005-08-27 18:50:39 +00003465 yyval.TermInstVal = new ReturnInst();
Chris Lattner8335e842006-01-23 23:05:42 +00003466 ;
3467 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003468case 190:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003469#line 1987 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003470{ // Unconditional Branch...
Reid Spencer68a24bd2005-08-27 18:50:39 +00003471 yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[0].ValIDVal));
Chris Lattner8335e842006-01-23 23:05:42 +00003472 ;
3473 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003474case 191:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003475#line 1990 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003476{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003477 yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[-3].ValIDVal), getBBVal(yyvsp[0].ValIDVal), getVal(Type::BoolTy, yyvsp[-6].ValIDVal));
Chris Lattner8335e842006-01-23 23:05:42 +00003478 ;
3479 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003480case 192:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003481#line 1993 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003482{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003483 SwitchInst *S = new SwitchInst(getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal), getBBVal(yyvsp[-3].ValIDVal), yyvsp[-1].JumpTable->size());
3484 yyval.TermInstVal = S;
3485
3486 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
3487 E = yyvsp[-1].JumpTable->end();
3488 for (; I != E; ++I) {
3489 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
3490 S->addCase(CI, I->second);
3491 else
3492 ThrowException("Switch case is constant, but not a simple integer!");
3493 }
3494 delete yyvsp[-1].JumpTable;
Chris Lattner8335e842006-01-23 23:05:42 +00003495 ;
3496 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003497case 193:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003498#line 2007 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003499{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003500 SwitchInst *S = new SwitchInst(getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal), getBBVal(yyvsp[-2].ValIDVal), 0);
3501 yyval.TermInstVal = S;
Chris Lattner8335e842006-01-23 23:05:42 +00003502 ;
3503 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003504case 194:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003505#line 2012 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003506{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003507 const PointerType *PFTy;
3508 const FunctionType *Ty;
3509
3510 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-10].TypeVal->get())) ||
3511 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3512 // Pull out the types of all of the arguments...
3513 std::vector<const Type*> ParamTypes;
3514 if (yyvsp[-7].ValueList) {
3515 for (std::vector<Value*>::iterator I = yyvsp[-7].ValueList->begin(), E = yyvsp[-7].ValueList->end();
3516 I != E; ++I)
3517 ParamTypes.push_back((*I)->getType());
3518 }
3519
3520 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3521 if (isVarArg) ParamTypes.pop_back();
3522
3523 Ty = FunctionType::get(yyvsp[-10].TypeVal->get(), ParamTypes, isVarArg);
3524 PFTy = PointerType::get(Ty);
3525 }
3526
3527 Value *V = getVal(PFTy, yyvsp[-9].ValIDVal); // Get the function we're calling...
3528
3529 BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
3530 BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
3531
3532 // Create the call node...
3533 if (!yyvsp[-7].ValueList) { // Has no arguments?
3534 yyval.TermInstVal = new InvokeInst(V, Normal, Except, std::vector<Value*>());
3535 } else { // Has arguments?
3536 // Loop through FunctionType's arguments and ensure they are specified
3537 // correctly!
3538 //
3539 FunctionType::param_iterator I = Ty->param_begin();
3540 FunctionType::param_iterator E = Ty->param_end();
3541 std::vector<Value*>::iterator ArgI = yyvsp[-7].ValueList->begin(), ArgE = yyvsp[-7].ValueList->end();
3542
3543 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3544 if ((*ArgI)->getType() != *I)
3545 ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
3546 (*I)->getDescription() + "'!");
3547
3548 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
3549 ThrowException("Invalid number of parameters detected!");
3550
3551 yyval.TermInstVal = new InvokeInst(V, Normal, Except, *yyvsp[-7].ValueList);
3552 }
3553 cast<InvokeInst>(yyval.TermInstVal)->setCallingConv(yyvsp[-11].UIntVal);
3554
3555 delete yyvsp[-10].TypeVal;
3556 delete yyvsp[-7].ValueList;
Chris Lattner8335e842006-01-23 23:05:42 +00003557 ;
3558 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003559case 195:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003560#line 2064 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003561{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003562 yyval.TermInstVal = new UnwindInst();
Chris Lattner8335e842006-01-23 23:05:42 +00003563 ;
3564 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003565case 196:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003566#line 2067 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003567{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003568 yyval.TermInstVal = new UnreachableInst();
Chris Lattner8335e842006-01-23 23:05:42 +00003569 ;
3570 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003571case 197:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003572#line 2073 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003573{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003574 yyval.JumpTable = yyvsp[-5].JumpTable;
3575 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
3576 if (V == 0)
3577 ThrowException("May only switch on a constant pool value!");
3578
3579 yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
Chris Lattner8335e842006-01-23 23:05:42 +00003580 ;
3581 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003582case 198:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003583#line 2081 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003584{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003585 yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
3586 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
3587
3588 if (V == 0)
3589 ThrowException("May only switch on a constant pool value!");
3590
3591 yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
Chris Lattner8335e842006-01-23 23:05:42 +00003592 ;
3593 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003594case 199:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003595#line 2091 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003596{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003597 // Is this definition named?? if so, assign the name...
3598 setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
3599 InsertValue(yyvsp[0].InstVal);
3600 yyval.InstVal = yyvsp[0].InstVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003601;
3602 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003603case 200:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003604#line 2098 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003605{ // Used for PHI nodes
Reid Spencer68a24bd2005-08-27 18:50:39 +00003606 yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
3607 yyval.PHIList->push_back(std::make_pair(getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal), getBBVal(yyvsp[-1].ValIDVal)));
3608 delete yyvsp[-5].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003609 ;
3610 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003611case 201:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003612#line 2103 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003613{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003614 yyval.PHIList = yyvsp[-6].PHIList;
3615 yyvsp[-6].PHIList->push_back(std::make_pair(getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal),
3616 getBBVal(yyvsp[-1].ValIDVal)));
Chris Lattner8335e842006-01-23 23:05:42 +00003617 ;
3618 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003619case 202:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003620#line 2110 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003621{ // Used for call statements, and memory insts...
Reid Spencer68a24bd2005-08-27 18:50:39 +00003622 yyval.ValueList = new std::vector<Value*>();
3623 yyval.ValueList->push_back(yyvsp[0].ValueVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003624 ;
3625 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003626case 203:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003627#line 2114 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003628{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003629 yyval.ValueList = yyvsp[-2].ValueList;
3630 yyvsp[-2].ValueList->push_back(yyvsp[0].ValueVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003631 ;
3632 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003633case 205:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003634#line 2120 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003635{ yyval.ValueList = 0; ;
3636 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003637case 206:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003638#line 2122 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003639{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003640 yyval.BoolVal = true;
Chris Lattner8335e842006-01-23 23:05:42 +00003641 ;
3642 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003643case 207:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003644#line 2125 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003645{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003646 yyval.BoolVal = false;
Chris Lattner8335e842006-01-23 23:05:42 +00003647 ;
3648 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003649case 208:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003650#line 2131 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003651{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003652 if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
3653 !isa<PackedType>((*yyvsp[-3].TypeVal).get()))
3654 ThrowException(
3655 "Arithmetic operator requires integer, FP, or packed operands!");
3656 if (isa<PackedType>((*yyvsp[-3].TypeVal).get()) && yyvsp[-4].BinaryOpVal == Instruction::Rem)
3657 ThrowException("Rem not supported on packed types!");
3658 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3659 if (yyval.InstVal == 0)
3660 ThrowException("binary operator returned null!");
3661 delete yyvsp[-3].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003662 ;
3663 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003664case 209:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003665#line 2143 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003666{
Chris Lattner524a1312005-12-21 18:31:50 +00003667 if (!(*yyvsp[-3].TypeVal)->isIntegral()) {
3668 if (!isa<PackedType>(yyvsp[-3].TypeVal->get()) ||
3669 !cast<PackedType>(yyvsp[-3].TypeVal->get())->getElementType()->isIntegral())
3670 ThrowException("Logical operator requires integral operands!");
3671 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00003672 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3673 if (yyval.InstVal == 0)
3674 ThrowException("binary operator returned null!");
3675 delete yyvsp[-3].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003676 ;
3677 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003678case 210:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003679#line 2154 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003680{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003681 if(isa<PackedType>((*yyvsp[-3].TypeVal).get())) {
3682 ThrowException(
3683 "PackedTypes currently not supported in setcc instructions!");
3684 }
3685 yyval.InstVal = new SetCondInst(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3686 if (yyval.InstVal == 0)
3687 ThrowException("binary operator returned null!");
3688 delete yyvsp[-3].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003689 ;
3690 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003691case 211:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003692#line 2164 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003693{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003694 std::cerr << "WARNING: Use of eliminated 'not' instruction:"
3695 << " Replacing with 'xor'.\n";
3696
3697 Value *Ones = ConstantIntegral::getAllOnesValue(yyvsp[0].ValueVal->getType());
3698 if (Ones == 0)
3699 ThrowException("Expected integral type for not instruction!");
3700
3701 yyval.InstVal = BinaryOperator::create(Instruction::Xor, yyvsp[0].ValueVal, Ones);
3702 if (yyval.InstVal == 0)
3703 ThrowException("Could not create a xor instruction!");
Chris Lattner8335e842006-01-23 23:05:42 +00003704 ;
3705 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003706case 212:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003707#line 2176 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003708{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003709 if (yyvsp[0].ValueVal->getType() != Type::UByteTy)
3710 ThrowException("Shift amount must be ubyte!");
3711 if (!yyvsp[-2].ValueVal->getType()->isInteger())
3712 ThrowException("Shift constant expression requires integer operand!");
3713 yyval.InstVal = new ShiftInst(yyvsp[-3].OtherOpVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003714 ;
3715 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003716case 213:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003717#line 2183 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003718{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003719 if (!yyvsp[0].TypeVal->get()->isFirstClassType())
3720 ThrowException("cast instruction to a non-primitive type: '" +
3721 yyvsp[0].TypeVal->get()->getDescription() + "'!");
3722 yyval.InstVal = new CastInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
3723 delete yyvsp[0].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003724 ;
3725 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003726case 214:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003727#line 2190 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003728{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003729 if (yyvsp[-4].ValueVal->getType() != Type::BoolTy)
3730 ThrowException("select condition must be boolean!");
3731 if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
3732 ThrowException("select value types should match!");
3733 yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003734 ;
3735 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003736case 215:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003737#line 2197 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003738{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003739 NewVarArgs = true;
3740 yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
3741 delete yyvsp[0].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003742 ;
3743 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003744case 216:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003745#line 2202 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003746{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003747 ObsoleteVarArgs = true;
3748 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
3749 Function* NF = CurModule.CurrentModule->
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003750 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003751
3752 //b = vaarg a, t ->
3753 //foo = alloca 1 of t
3754 //bar = vacopy a
3755 //store bar -> foo
3756 //b = vaarg foo, t
3757 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
3758 CurBB->getInstList().push_back(foo);
3759 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
3760 CurBB->getInstList().push_back(bar);
3761 CurBB->getInstList().push_back(new StoreInst(bar, foo));
3762 yyval.InstVal = new VAArgInst(foo, *yyvsp[0].TypeVal);
3763 delete yyvsp[0].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003764 ;
3765 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003766case 217:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003767#line 2221 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003768{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003769 ObsoleteVarArgs = true;
3770 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
3771 Function* NF = CurModule.CurrentModule->
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003772 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003773
3774 //b = vanext a, t ->
3775 //foo = alloca 1 of t
3776 //bar = vacopy a
3777 //store bar -> foo
3778 //tmp = vaarg foo, t
3779 //b = load foo
3780 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
3781 CurBB->getInstList().push_back(foo);
3782 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
3783 CurBB->getInstList().push_back(bar);
3784 CurBB->getInstList().push_back(new StoreInst(bar, foo));
3785 Instruction* tmp = new VAArgInst(foo, *yyvsp[0].TypeVal);
3786 CurBB->getInstList().push_back(tmp);
3787 yyval.InstVal = new LoadInst(foo);
3788 delete yyvsp[0].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003789 ;
3790 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003791case 218:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003792#line 2243 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003793{
Robert Bocchino9c62b562006-01-10 19:04:32 +00003794 if (!isa<PackedType>(yyvsp[-2].ValueVal->getType()))
Robert Bocchino2def1b32006-01-17 20:06:25 +00003795 ThrowException("First operand of extractelement must be "
3796 "packed type!");
Robert Bocchino9c62b562006-01-10 19:04:32 +00003797 if (yyvsp[0].ValueVal->getType() != Type::UIntTy)
Robert Bocchino2def1b32006-01-17 20:06:25 +00003798 ThrowException("Second operand of extractelement must be uint!");
Robert Bocchino9c62b562006-01-10 19:04:32 +00003799 yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003800 ;
3801 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003802case 219:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003803#line 2251 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003804{
Robert Bocchino2def1b32006-01-17 20:06:25 +00003805 if (!isa<PackedType>(yyvsp[-4].ValueVal->getType()))
3806 ThrowException("First operand of insertelement must be "
3807 "packed type!");
3808 if (yyvsp[-2].ValueVal->getType() !=
3809 cast<PackedType>(yyvsp[-4].ValueVal->getType())->getElementType())
3810 ThrowException("Second operand of insertelement must be "
3811 "packed element type!");
3812 if (yyvsp[0].ValueVal->getType() != Type::UIntTy)
3813 ThrowException("Third operand of insertelement must be uint!");
3814 yyval.InstVal = new InsertElementInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003815 ;
3816 break;}
Chris Lattner0e9c3762006-01-25 22:27:16 +00003817case 220:
Chris Lattnerd5efe842006-04-08 01:18:56 +00003818#line 2263 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3819{
3820 if (!ShuffleVectorInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
3821 ThrowException("Invalid shufflevector operands!");
3822 yyval.InstVal = new ShuffleVectorInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
3823 ;
3824 break;}
3825case 221:
3826#line 2268 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003827{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003828 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
3829 if (!Ty->isFirstClassType())
3830 ThrowException("PHI node operands must be of first class type!");
3831 yyval.InstVal = new PHINode(Ty);
3832 ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
3833 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
3834 if (yyvsp[0].PHIList->front().first->getType() != Ty)
3835 ThrowException("All elements of a PHI node must be of the same type!");
3836 cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
3837 yyvsp[0].PHIList->pop_front();
3838 }
3839 delete yyvsp[0].PHIList; // Free the list...
Chris Lattner8335e842006-01-23 23:05:42 +00003840 ;
3841 break;}
Chris Lattnerd5efe842006-04-08 01:18:56 +00003842case 222:
3843#line 2282 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003844{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003845 const PointerType *PFTy;
3846 const FunctionType *Ty;
3847
3848 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-4].TypeVal->get())) ||
3849 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3850 // Pull out the types of all of the arguments...
3851 std::vector<const Type*> ParamTypes;
3852 if (yyvsp[-1].ValueList) {
3853 for (std::vector<Value*>::iterator I = yyvsp[-1].ValueList->begin(), E = yyvsp[-1].ValueList->end();
3854 I != E; ++I)
3855 ParamTypes.push_back((*I)->getType());
3856 }
3857
3858 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3859 if (isVarArg) ParamTypes.pop_back();
3860
3861 if (!(*yyvsp[-4].TypeVal)->isFirstClassType() && *yyvsp[-4].TypeVal != Type::VoidTy)
3862 ThrowException("LLVM functions cannot return aggregate types!");
3863
3864 Ty = FunctionType::get(yyvsp[-4].TypeVal->get(), ParamTypes, isVarArg);
3865 PFTy = PointerType::get(Ty);
3866 }
3867
3868 Value *V = getVal(PFTy, yyvsp[-3].ValIDVal); // Get the function we're calling...
3869
3870 // Create the call node...
3871 if (!yyvsp[-1].ValueList) { // Has no arguments?
3872 // Make sure no arguments is a good thing!
3873 if (Ty->getNumParams() != 0)
3874 ThrowException("No arguments passed to a function that "
3875 "expects arguments!");
3876
3877 yyval.InstVal = new CallInst(V, std::vector<Value*>());
3878 } else { // Has arguments?
3879 // Loop through FunctionType's arguments and ensure they are specified
3880 // correctly!
3881 //
3882 FunctionType::param_iterator I = Ty->param_begin();
3883 FunctionType::param_iterator E = Ty->param_end();
3884 std::vector<Value*>::iterator ArgI = yyvsp[-1].ValueList->begin(), ArgE = yyvsp[-1].ValueList->end();
3885
3886 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3887 if ((*ArgI)->getType() != *I)
3888 ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
3889 (*I)->getDescription() + "'!");
3890
3891 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
3892 ThrowException("Invalid number of parameters detected!");
3893
3894 yyval.InstVal = new CallInst(V, *yyvsp[-1].ValueList);
3895 }
3896 cast<CallInst>(yyval.InstVal)->setTailCall(yyvsp[-6].BoolVal);
3897 cast<CallInst>(yyval.InstVal)->setCallingConv(yyvsp[-5].UIntVal);
3898 delete yyvsp[-4].TypeVal;
3899 delete yyvsp[-1].ValueList;
Chris Lattner8335e842006-01-23 23:05:42 +00003900 ;
3901 break;}
Chris Lattnerd5efe842006-04-08 01:18:56 +00003902case 223:
3903#line 2339 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003904{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003905 yyval.InstVal = yyvsp[0].InstVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003906 ;
3907 break;}
Chris Lattnerd5efe842006-04-08 01:18:56 +00003908case 224:
3909#line 2345 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003910{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003911 yyval.ValueList = yyvsp[0].ValueList;
Chris Lattner8335e842006-01-23 23:05:42 +00003912 ;
3913 break;}
Chris Lattnerd5efe842006-04-08 01:18:56 +00003914case 225:
3915#line 2347 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003916{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003917 yyval.ValueList = new std::vector<Value*>();
Chris Lattner8335e842006-01-23 23:05:42 +00003918 ;
3919 break;}
Chris Lattnerd5efe842006-04-08 01:18:56 +00003920case 226:
3921#line 2351 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003922{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003923 yyval.BoolVal = true;
Chris Lattner8335e842006-01-23 23:05:42 +00003924 ;
3925 break;}
Chris Lattnerd5efe842006-04-08 01:18:56 +00003926case 227:
3927#line 2354 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003928{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003929 yyval.BoolVal = false;
Chris Lattner8335e842006-01-23 23:05:42 +00003930 ;
3931 break;}
Chris Lattnerd5efe842006-04-08 01:18:56 +00003932case 228:
3933#line 2360 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003934{
Chris Lattner7d09ab62005-11-06 06:34:34 +00003935 yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
3936 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003937 ;
3938 break;}
Chris Lattnerd5efe842006-04-08 01:18:56 +00003939case 229:
3940#line 2364 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003941{
Chris Lattner7d09ab62005-11-06 06:34:34 +00003942 yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal);
3943 delete yyvsp[-4].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003944 ;
3945 break;}
Chris Lattnerd5efe842006-04-08 01:18:56 +00003946case 230:
3947#line 2368 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003948{
Chris Lattner7d09ab62005-11-06 06:34:34 +00003949 yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
3950 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003951 ;
3952 break;}
Chris Lattnerd5efe842006-04-08 01:18:56 +00003953case 231:
3954#line 2372 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003955{
Chris Lattner7d09ab62005-11-06 06:34:34 +00003956 yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal);
3957 delete yyvsp[-4].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003958 ;
3959 break;}
Chris Lattnerd5efe842006-04-08 01:18:56 +00003960case 232:
3961#line 2376 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003962{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003963 if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
3964 ThrowException("Trying to free nonpointer type " +
3965 yyvsp[0].ValueVal->getType()->getDescription() + "!");
3966 yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003967 ;
3968 break;}
Chris Lattnerd5efe842006-04-08 01:18:56 +00003969case 233:
3970#line 2383 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003971{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003972 if (!isa<PointerType>(yyvsp[-1].TypeVal->get()))
3973 ThrowException("Can't load from nonpointer type: " +
3974 (*yyvsp[-1].TypeVal)->getDescription());
3975 if (!cast<PointerType>(yyvsp[-1].TypeVal->get())->getElementType()->isFirstClassType())
3976 ThrowException("Can't load from pointer of non-first-class type: " +
3977 (*yyvsp[-1].TypeVal)->getDescription());
3978 yyval.InstVal = new LoadInst(getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), "", yyvsp[-3].BoolVal);
3979 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003980 ;
3981 break;}
Chris Lattnerd5efe842006-04-08 01:18:56 +00003982case 234:
3983#line 2393 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003984{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003985 const PointerType *PT = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
3986 if (!PT)
3987 ThrowException("Can't store to a nonpointer type: " +
3988 (*yyvsp[-1].TypeVal)->getDescription());
3989 const Type *ElTy = PT->getElementType();
3990 if (ElTy != yyvsp[-3].ValueVal->getType())
3991 ThrowException("Can't store '" + yyvsp[-3].ValueVal->getType()->getDescription() +
3992 "' into space of type '" + ElTy->getDescription() + "'!");
3993
3994 yyval.InstVal = new StoreInst(yyvsp[-3].ValueVal, getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), yyvsp[-5].BoolVal);
3995 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003996 ;
3997 break;}
Chris Lattnerd5efe842006-04-08 01:18:56 +00003998case 235:
3999#line 2406 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00004000{
Reid Spencer68a24bd2005-08-27 18:50:39 +00004001 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
4002 ThrowException("getelementptr insn requires pointer operand!");
4003
4004 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
4005 // indices to uint struct indices for compatibility.
4006 generic_gep_type_iterator<std::vector<Value*>::iterator>
4007 GTI = gep_type_begin(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end()),
4008 GTE = gep_type_end(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end());
4009 for (unsigned i = 0, e = yyvsp[0].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
4010 if (isa<StructType>(*GTI)) // Only change struct indices
4011 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[0].ValueList)[i]))
4012 if (CUI->getType() == Type::UByteTy)
4013 (*yyvsp[0].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
4014
4015 if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, *yyvsp[0].ValueList, true))
4016 ThrowException("Invalid getelementptr indices for type '" +
4017 (*yyvsp[-2].TypeVal)->getDescription()+ "'!");
4018 yyval.InstVal = new GetElementPtrInst(getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal), *yyvsp[0].ValueList);
4019 delete yyvsp[-2].TypeVal; delete yyvsp[0].ValueList;
Chris Lattner8335e842006-01-23 23:05:42 +00004020 ;
4021 break;}
4022}
4023 /* the action file gets copied in in place of this dollarsign */
4024#line 543 "/usr/share/bison.simple"
Reid Spencer68a24bd2005-08-27 18:50:39 +00004025
4026 yyvsp -= yylen;
4027 yyssp -= yylen;
Chris Lattner8335e842006-01-23 23:05:42 +00004028#ifdef YYLSP_NEEDED
4029 yylsp -= yylen;
4030#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00004031
Chris Lattner8335e842006-01-23 23:05:42 +00004032#if YYDEBUG != 0
4033 if (yydebug)
4034 {
4035 short *ssp1 = yyss - 1;
4036 fprintf (stderr, "state stack now");
4037 while (ssp1 != yyssp)
4038 fprintf (stderr, " %d", *++ssp1);
4039 fprintf (stderr, "\n");
4040 }
4041#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00004042
4043 *++yyvsp = yyval;
4044
Chris Lattner8335e842006-01-23 23:05:42 +00004045#ifdef YYLSP_NEEDED
4046 yylsp++;
4047 if (yylen == 0)
4048 {
4049 yylsp->first_line = yylloc.first_line;
4050 yylsp->first_column = yylloc.first_column;
4051 yylsp->last_line = (yylsp-1)->last_line;
4052 yylsp->last_column = (yylsp-1)->last_column;
4053 yylsp->text = 0;
4054 }
4055 else
4056 {
4057 yylsp->last_line = (yylsp+yylen-1)->last_line;
4058 yylsp->last_column = (yylsp+yylen-1)->last_column;
4059 }
4060#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00004061
Chris Lattner8335e842006-01-23 23:05:42 +00004062 /* Now "shift" the result of the reduction.
4063 Determine what state that goes to,
4064 based on the state we popped back to
4065 and the rule number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004066
4067 yyn = yyr1[yyn];
4068
Chris Lattner8335e842006-01-23 23:05:42 +00004069 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
4070 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004071 yystate = yytable[yystate];
4072 else
Chris Lattner8335e842006-01-23 23:05:42 +00004073 yystate = yydefgoto[yyn - YYNTBASE];
Reid Spencer68a24bd2005-08-27 18:50:39 +00004074
4075 goto yynewstate;
4076
Chris Lattner8335e842006-01-23 23:05:42 +00004077yyerrlab: /* here on detecting error */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004078
Chris Lattner8335e842006-01-23 23:05:42 +00004079 if (! yyerrstatus)
4080 /* If not already recovering from an error, report this error. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004081 {
4082 ++yynerrs;
Chris Lattner8335e842006-01-23 23:05:42 +00004083
4084#ifdef YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00004085 yyn = yypact[yystate];
4086
Chris Lattner8335e842006-01-23 23:05:42 +00004087 if (yyn > YYFLAG && yyn < YYLAST)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004088 {
Chris Lattner8335e842006-01-23 23:05:42 +00004089 int size = 0;
4090 char *msg;
4091 int x, count;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004092
Chris Lattner8335e842006-01-23 23:05:42 +00004093 count = 0;
4094 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
4095 for (x = (yyn < 0 ? -yyn : 0);
4096 x < (sizeof(yytname) / sizeof(char *)); x++)
4097 if (yycheck[x + yyn] == x)
4098 size += strlen(yytname[x]) + 15, count++;
4099 msg = (char *) malloc(size + 15);
4100 if (msg != 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004101 {
Chris Lattner8335e842006-01-23 23:05:42 +00004102 strcpy(msg, "parse error");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004103
Chris Lattner8335e842006-01-23 23:05:42 +00004104 if (count < 5)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004105 {
Chris Lattner8335e842006-01-23 23:05:42 +00004106 count = 0;
4107 for (x = (yyn < 0 ? -yyn : 0);
4108 x < (sizeof(yytname) / sizeof(char *)); x++)
4109 if (yycheck[x + yyn] == x)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004110 {
Chris Lattner8335e842006-01-23 23:05:42 +00004111 strcat(msg, count == 0 ? ", expecting `" : " or `");
4112 strcat(msg, yytname[x]);
4113 strcat(msg, "'");
4114 count++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004115 }
4116 }
Chris Lattner8335e842006-01-23 23:05:42 +00004117 yyerror(msg);
4118 free(msg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004119 }
4120 else
Chris Lattner8335e842006-01-23 23:05:42 +00004121 yyerror ("parse error; also virtual memory exceeded");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004122 }
4123 else
4124#endif /* YYERROR_VERBOSE */
Chris Lattner8335e842006-01-23 23:05:42 +00004125 yyerror("parse error");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004126 }
4127
Chris Lattner8335e842006-01-23 23:05:42 +00004128 goto yyerrlab1;
4129yyerrlab1: /* here on error raised explicitly by an action */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004130
4131 if (yyerrstatus == 3)
4132 {
Chris Lattner8335e842006-01-23 23:05:42 +00004133 /* if just tried and failed to reuse lookahead token after an error, discard it. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004134
Chris Lattner8335e842006-01-23 23:05:42 +00004135 /* return failure if at end of input */
4136 if (yychar == YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004137 YYABORT;
4138
Chris Lattner8335e842006-01-23 23:05:42 +00004139#if YYDEBUG != 0
4140 if (yydebug)
4141 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
4142#endif
4143
4144 yychar = YYEMPTY;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004145 }
4146
Chris Lattner8335e842006-01-23 23:05:42 +00004147 /* Else will try to reuse lookahead token
4148 after shifting the error token. */
4149
4150 yyerrstatus = 3; /* Each real token shifted decrements this */
4151
4152 goto yyerrhandle;
4153
4154yyerrdefault: /* current state does not do anything special for the error token. */
4155
4156#if 0
4157 /* This is wrong; only states that explicitly want error tokens
4158 should shift them. */
4159 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
4160 if (yyn) goto yydefault;
4161#endif
4162
4163yyerrpop: /* pop the current state because it cannot handle the error token */
4164
4165 if (yyssp == yyss) YYABORT;
4166 yyvsp--;
4167 yystate = *--yyssp;
4168#ifdef YYLSP_NEEDED
4169 yylsp--;
4170#endif
4171
4172#if YYDEBUG != 0
4173 if (yydebug)
4174 {
4175 short *ssp1 = yyss - 1;
4176 fprintf (stderr, "Error: state stack now");
4177 while (ssp1 != yyssp)
4178 fprintf (stderr, " %d", *++ssp1);
4179 fprintf (stderr, "\n");
4180 }
4181#endif
4182
4183yyerrhandle:
4184
4185 yyn = yypact[yystate];
4186 if (yyn == YYFLAG)
4187 goto yyerrdefault;
4188
4189 yyn += YYTERROR;
4190 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
4191 goto yyerrdefault;
4192
4193 yyn = yytable[yyn];
4194 if (yyn < 0)
4195 {
4196 if (yyn == YYFLAG)
4197 goto yyerrpop;
4198 yyn = -yyn;
4199 goto yyreduce;
4200 }
4201 else if (yyn == 0)
4202 goto yyerrpop;
4203
Reid Spencer68a24bd2005-08-27 18:50:39 +00004204 if (yyn == YYFINAL)
4205 YYACCEPT;
4206
Chris Lattner8335e842006-01-23 23:05:42 +00004207#if YYDEBUG != 0
4208 if (yydebug)
4209 fprintf(stderr, "Shifting error token, ");
4210#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00004211
4212 *++yyvsp = yylval;
Chris Lattner8335e842006-01-23 23:05:42 +00004213#ifdef YYLSP_NEEDED
4214 *++yylsp = yylloc;
4215#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00004216
4217 yystate = yyn;
4218 goto yynewstate;
4219
Chris Lattner8335e842006-01-23 23:05:42 +00004220 yyacceptlab:
4221 /* YYACCEPT comes here. */
4222 if (yyfree_stacks)
4223 {
4224 free (yyss);
4225 free (yyvs);
4226#ifdef YYLSP_NEEDED
4227 free (yyls);
Reid Spencer0b118202006-01-16 21:12:35 +00004228#endif
Chris Lattner8335e842006-01-23 23:05:42 +00004229 }
4230 return 0;
Reid Spencere812fb22006-01-19 01:21:04 +00004231
Chris Lattner8335e842006-01-23 23:05:42 +00004232 yyabortlab:
4233 /* YYABORT comes here. */
4234 if (yyfree_stacks)
4235 {
4236 free (yyss);
4237 free (yyvs);
4238#ifdef YYLSP_NEEDED
4239 free (yyls);
Reid Spencere812fb22006-01-19 01:21:04 +00004240#endif
Chris Lattner8335e842006-01-23 23:05:42 +00004241 }
4242 return 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004243}
Chris Lattnerd5efe842006-04-08 01:18:56 +00004244#line 2429 "/Volumes/Projects/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00004245
4246int yyerror(const char *ErrorMsg) {
4247 std::string where
4248 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
4249 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
4250 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
4251 if (yychar == YYEMPTY || yychar == 0)
4252 errMsg += "end-of-file.";
4253 else
4254 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
4255 ThrowException(errMsg);
4256 return 0;
4257}