blob: 52ab9dc2fda22beaad3d60f6332f233ed4501f69 [file] [log] [blame]
Reid Spencer68a24bd2005-08-27 18:50:39 +00001
Chris Lattnerd25db202006-04-08 03:55:17 +00002/* A Bison parser, made from /Users/sabre/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 Lattnerd25db202006-04-08 03:55:17 +0000114#line 14 "/Users/sabre/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 Lattnerd25db202006-04-08 03:55:17 +0000990#line 890 "/Users/sabre/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 Lattnerd25db202006-04-08 03:55:17 +00001040#define YYFINAL 495
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,
Chris Lattnerd25db202006-04-08 03:55:17 +00001098 292, 299, 306, 313, 322, 331, 335, 337, 339, 341,
1099 343, 346, 349, 354, 357, 359, 364, 367, 372, 373,
1100 381, 382, 390, 394, 399, 400, 402, 404, 406, 410,
1101 414, 418, 422, 426, 428, 429, 431, 433, 435, 436,
1102 439, 443, 445, 447, 451, 453, 454, 463, 465, 467,
1103 471, 473, 475, 478, 479, 483, 484, 486, 488, 490,
1104 492, 494, 496, 498, 500, 502, 506, 508, 514, 516,
1105 518, 520, 522, 525, 528, 531, 535, 538, 539, 541,
1106 544, 547, 551, 561, 571, 580, 594, 596, 598, 605,
1107 611, 614, 621, 629, 631, 635, 637, 638, 641, 643,
1108 649, 655, 661, 664, 669, 674, 681, 686, 691, 696,
1109 701, 708, 715, 718, 726, 728, 731, 732, 734, 735,
1110 739, 746, 750, 757, 760, 765, 772
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,
Chris Lattnerd25db202006-04-08 03:55:17 +00001145 106, 0, 98, 105, 142, 103, 142, 103, 142, 106,
1146 0, 99, 105, 142, 103, 142, 103, 142, 106, 0,
1147 144, 103, 142, 0, 142, 0, 32, 0, 33, 0,
1148 147, 0, 147, 165, 0, 147, 166, 0, 147, 59,
1149 58, 151, 0, 147, 25, 0, 148, 0, 148, 126,
1150 20, 135, 0, 148, 166, 0, 148, 59, 58, 151,
1151 0, 0, 148, 126, 127, 145, 142, 149, 133, 0,
1152 0, 148, 126, 47, 145, 137, 150, 133, 0, 148,
1153 48, 153, 0, 148, 55, 102, 154, 0, 0, 24,
1154 0, 53, 0, 52, 0, 50, 102, 152, 0, 51,
1155 102, 4, 0, 49, 102, 24, 0, 107, 155, 109,
1156 0, 155, 103, 24, 0, 24, 0, 0, 22, 0,
1157 24, 0, 156, 0, 0, 137, 157, 0, 159, 103,
1158 158, 0, 158, 0, 159, 0, 159, 103, 37, 0,
1159 37, 0, 0, 128, 135, 156, 105, 160, 106, 132,
1160 129, 0, 29, 0, 112, 0, 127, 161, 162, 0,
1161 30, 0, 113, 0, 173, 164, 0, 0, 31, 167,
1162 161, 0, 0, 60, 0, 3, 0, 4, 0, 7,
1163 0, 27, 0, 28, 0, 38, 0, 39, 0, 26,
1164 0, 110, 144, 111, 0, 143, 0, 58, 168, 24,
1165 103, 24, 0, 116, 0, 156, 0, 170, 0, 169,
1166 0, 137, 171, 0, 173, 174, 0, 163, 174, 0,
1167 175, 126, 176, 0, 175, 178, 0, 0, 23, 0,
1168 65, 172, 0, 65, 8, 0, 66, 21, 171, 0,
1169 66, 9, 171, 103, 21, 171, 103, 21, 171, 0,
1170 67, 124, 171, 103, 21, 171, 107, 177, 109, 0,
1171 67, 124, 171, 103, 21, 171, 107, 109, 0, 68,
1172 128, 135, 171, 105, 181, 106, 36, 21, 171, 69,
1173 21, 171, 0, 69, 0, 70, 0, 177, 124, 169,
1174 103, 21, 171, 0, 124, 169, 103, 21, 171, 0,
1175 126, 183, 0, 137, 107, 171, 103, 171, 109, 0,
1176 179, 103, 107, 171, 103, 171, 109, 0, 172, 0,
1177 180, 103, 172, 0, 180, 0, 0, 57, 56, 0,
1178 56, 0, 118, 137, 171, 103, 171, 0, 119, 137,
1179 171, 103, 171, 0, 120, 137, 171, 103, 171, 0,
1180 46, 172, 0, 121, 172, 103, 172, 0, 92, 172,
1181 36, 137, 0, 93, 172, 103, 172, 103, 172, 0,
1182 96, 172, 103, 137, 0, 100, 172, 103, 137, 0,
1183 101, 172, 103, 137, 0, 97, 172, 103, 172, 0,
1184 98, 172, 103, 172, 103, 172, 0, 99, 172, 103,
1185 172, 103, 172, 0, 91, 179, 0, 182, 128, 135,
1186 171, 105, 181, 106, 0, 186, 0, 103, 180, 0,
1187 0, 35, 0, 0, 85, 137, 130, 0, 85, 137,
1188 103, 15, 171, 130, 0, 86, 137, 130, 0, 86,
1189 137, 103, 15, 171, 130, 0, 87, 172, 0, 185,
1190 88, 137, 171, 0, 185, 89, 172, 103, 137, 171,
1191 0, 90, 137, 171, 184, 0
Chris Lattner8335e842006-01-23 23:05:42 +00001192};
Reid Spencer68a24bd2005-08-27 18:50:39 +00001193
1194#endif
1195
Chris Lattner8335e842006-01-23 23:05:42 +00001196#if YYDEBUG != 0
1197static const short yyrline[] = { 0,
Chris Lattner0e9c3762006-01-25 22:27:16 +00001198 1010, 1011, 1018, 1019, 1028, 1028, 1028, 1028, 1028, 1029,
1199 1029, 1029, 1030, 1030, 1030, 1030, 1030, 1030, 1032, 1032,
1200 1036, 1036, 1036, 1036, 1037, 1037, 1037, 1037, 1038, 1038,
1201 1039, 1039, 1042, 1045, 1049, 1049, 1050, 1051, 1052, 1055,
1202 1055, 1056, 1057, 1058, 1067, 1067, 1073, 1073, 1081, 1088,
1203 1088, 1094, 1094, 1096, 1100, 1113, 1113, 1114, 1114, 1116,
1204 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1126, 1126, 1126,
1205 1126, 1126, 1126, 1127, 1130, 1133, 1139, 1146, 1158, 1162,
1206 1173, 1182, 1185, 1193, 1197, 1202, 1203, 1206, 1209, 1219,
1207 1244, 1257, 1286, 1311, 1331, 1343, 1352, 1356, 1415, 1421,
1208 1429, 1434, 1439, 1442, 1445, 1452, 1462, 1493, 1500, 1521,
Chris Lattnerd25db202006-04-08 03:55:17 +00001209 1531, 1536, 1543, 1551, 1554, 1562, 1565, 1572, 1572, 1582,
1210 1589, 1593, 1596, 1599, 1602, 1615, 1635, 1637, 1639, 1642,
1211 1645, 1649, 1652, 1654, 1656, 1660, 1672, 1673, 1675, 1678,
1212 1686, 1691, 1693, 1697, 1701, 1709, 1709, 1710, 1710, 1712,
1213 1718, 1723, 1729, 1732, 1737, 1741, 1745, 1831, 1831, 1833,
1214 1841, 1841, 1843, 1847, 1847, 1856, 1859, 1863, 1866, 1869,
1215 1872, 1875, 1878, 1881, 1884, 1887, 1911, 1914, 1927, 1930,
1216 1935, 1935, 1941, 1945, 1948, 1956, 1965, 1969, 1979, 1990,
1217 1993, 1996, 1999, 2002, 2016, 2020, 2073, 2076, 2082, 2090,
1218 2100, 2107, 2112, 2119, 2123, 2129, 2129, 2131, 2134, 2140,
1219 2152, 2163, 2173, 2185, 2192, 2199, 2206, 2211, 2230, 2252,
1220 2260, 2272, 2277, 2291, 2348, 2354, 2356, 2360, 2363, 2369,
1221 2373, 2377, 2381, 2385, 2392, 2402, 2415
Chris Lattner8335e842006-01-23 23:05:42 +00001222};
1223#endif
1224
1225
1226#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
1227
1228static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL",
1229"EUINT64VAL","SINTVAL","UINTVAL","FPVAL","VOID","BOOL","SBYTE","UBYTE","SHORT",
1230"USHORT","INT","UINT","LONG","ULONG","FLOAT","DOUBLE","TYPE","LABEL","VAR_ID",
1231"LABELSTR","STRINGCONSTANT","IMPLEMENTATION","ZEROINITIALIZER","TRUETOK","FALSETOK",
1232"BEGINTOK","ENDTOK","DECLARE","GLOBAL","CONSTANT","SECTION","VOLATILE","TO",
1233"DOTDOTDOT","NULL_TOK","UNDEF","CONST","INTERNAL","LINKONCE","WEAK","APPENDING",
1234"OPAQUE","NOT","EXTERNAL","TARGET","TRIPLE","ENDIAN","POINTERSIZE","LITTLE",
Chris Lattner0e9c3762006-01-25 22:27:16 +00001235"BIG","ALIGN","DEPLIBS","CALL","TAIL","ASM_TOK","MODULE","SIDEEFFECT","CC_TOK",
1236"CCC_TOK","FASTCC_TOK","COLDCC_TOK","RET","BR","SWITCH","INVOKE","UNWIND","UNREACHABLE",
Chris Lattner66316012006-01-24 04:14:29 +00001237"ADD","SUB","MUL","DIV","REM","AND","OR","XOR","SETLE","SETGE","SETLT","SETGT",
1238"SETEQ","SETNE","MALLOC","ALLOCA","FREE","LOAD","STORE","GETELEMENTPTR","PHI_TOK",
Chris Lattnerd5efe842006-04-08 01:18:56 +00001239"CAST","SELECT","SHL","SHR","VAARG","EXTRACTELEMENT","INSERTELEMENT","SHUFFLEVECTOR",
1240"VAARG_old","VANEXT_old","'='","','","'\\\\'","'('","')'","'['","'x'","']'",
1241"'<'","'>'","'{'","'}'","'*'","'c'","INTVAL","EINT64VAL","ArithmeticOps","LogicalOps",
1242"SetCondOps","ShiftOps","SIntType","UIntType","IntType","FPType","OptAssign",
1243"OptLinkage","OptCallingConv","OptAlign","OptCAlign","SectionString","OptSection",
1244"GlobalVarAttributes","GlobalVarAttribute","TypesV","UpRTypesV","Types","PrimType",
1245"UpRTypes","TypeListI","ArgTypeListI","ConstVal","ConstExpr","ConstVector","GlobalType",
1246"Module","FunctionList","ConstPool","@1","@2","AsmBlock","BigOrLittle","TargetDefinition",
1247"LibrariesDefinition","LibList","Name","OptName","ArgVal","ArgListH","ArgList",
1248"FunctionHeaderH","BEGIN","FunctionHeader","END","Function","FunctionProto",
1249"@3","OptSideEffect","ConstValueRef","SymbolicValueRef","ValueRef","ResolvedVal",
1250"BasicBlockList","BasicBlock","InstructionList","BBTerminatorInst","JumpTable",
1251"Inst","PHIList","ValueRefList","ValueRefListE","OptTailCall","InstVal","IndexList",
1252"OptVolatile","MemoryInst", NULL
Chris Lattner8335e842006-01-23 23:05:42 +00001253};
1254#endif
1255
1256static const short yyr1[] = { 0,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001257 116, 116, 117, 117, 118, 118, 118, 118, 118, 119,
1258 119, 119, 120, 120, 120, 120, 120, 120, 121, 121,
1259 122, 122, 122, 122, 123, 123, 123, 123, 124, 124,
1260 125, 125, 126, 126, 127, 127, 127, 127, 127, 128,
1261 128, 128, 128, 128, 129, 129, 130, 130, 131, 132,
1262 132, 133, 133, 134, 134, 135, 135, 136, 136, 137,
1263 138, 138, 138, 138, 138, 138, 138, 138, 138, 138,
1264 138, 138, 138, 139, 139, 139, 139, 139, 139, 139,
1265 139, 139, 139, 140, 140, 141, 141, 141, 141, 142,
1266 142, 142, 142, 142, 142, 142, 142, 142, 142, 142,
1267 142, 142, 142, 142, 142, 143, 143, 143, 143, 143,
Chris Lattnerd25db202006-04-08 03:55:17 +00001268 143, 143, 143, 143, 143, 144, 144, 145, 145, 146,
1269 147, 147, 147, 147, 147, 148, 148, 148, 149, 148,
1270 150, 148, 148, 148, 148, 151, 152, 152, 153, 153,
1271 153, 154, 155, 155, 155, 156, 156, 157, 157, 158,
1272 159, 159, 160, 160, 160, 160, 161, 162, 162, 163,
1273 164, 164, 165, 167, 166, 168, 168, 169, 169, 169,
1274 169, 169, 169, 169, 169, 169, 169, 169, 170, 170,
1275 171, 171, 172, 173, 173, 174, 175, 175, 175, 176,
1276 176, 176, 176, 176, 176, 176, 176, 176, 177, 177,
1277 178, 179, 179, 180, 180, 181, 181, 182, 182, 183,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001278 183, 183, 183, 183, 183, 183, 183, 183, 183, 183,
Chris Lattnerd25db202006-04-08 03:55:17 +00001279 183, 183, 183, 183, 183, 184, 184, 185, 185, 186,
1280 186, 186, 186, 186, 186, 186, 186
Chris Lattner8335e842006-01-23 23:05:42 +00001281};
1282
1283static const short yyr2[] = { 0,
1284 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1285 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1286 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1287 1, 1, 2, 0, 1, 1, 1, 1, 0, 0,
1288 1, 1, 1, 2, 0, 2, 0, 3, 2, 0,
1289 1, 0, 3, 1, 2, 1, 1, 1, 1, 1,
1290 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1291 1, 1, 1, 1, 1, 1, 2, 4, 5, 5,
1292 3, 2, 2, 1, 3, 1, 3, 1, 0, 4,
1293 3, 3, 4, 4, 3, 2, 2, 2, 2, 2,
1294 2, 2, 2, 2, 2, 6, 5, 8, 6, 6,
Chris Lattnerd25db202006-04-08 03:55:17 +00001295 6, 6, 6, 8, 8, 3, 1, 1, 1, 1,
1296 2, 2, 4, 2, 1, 4, 2, 4, 0, 7,
1297 0, 7, 3, 4, 0, 1, 1, 1, 3, 3,
1298 3, 3, 3, 1, 0, 1, 1, 1, 0, 2,
1299 3, 1, 1, 3, 1, 0, 8, 1, 1, 3,
1300 1, 1, 2, 0, 3, 0, 1, 1, 1, 1,
1301 1, 1, 1, 1, 1, 3, 1, 5, 1, 1,
1302 1, 1, 2, 2, 2, 3, 2, 0, 1, 2,
1303 2, 3, 9, 9, 8, 13, 1, 1, 6, 5,
1304 2, 6, 7, 1, 3, 1, 0, 2, 1, 5,
1305 5, 5, 2, 4, 4, 6, 4, 4, 4, 4,
1306 6, 6, 2, 7, 1, 2, 0, 1, 0, 3,
1307 6, 3, 6, 2, 4, 6, 4
Chris Lattner8335e842006-01-23 23:05:42 +00001308};
1309
Chris Lattnerd25db202006-04-08 03:55:17 +00001310static const short yydefact[] = { 135,
1311 39, 125, 124, 164, 35, 36, 37, 38, 0, 40,
1312 188, 121, 122, 188, 146, 147, 0, 0, 0, 39,
1313 0, 127, 40, 0, 0, 41, 42, 43, 0, 0,
1314 189, 185, 34, 161, 162, 163, 184, 0, 0, 0,
1315 133, 0, 0, 0, 0, 0, 33, 165, 136, 123,
Chris Lattner66316012006-01-24 04:14:29 +00001316 44, 1, 2, 57, 61, 62, 63, 64, 65, 66,
1317 67, 68, 69, 70, 71, 72, 73, 74, 0, 0,
Chris Lattnerd25db202006-04-08 03:55:17 +00001318 0, 0, 179, 0, 0, 56, 75, 60, 180, 76,
1319 158, 159, 160, 229, 187, 0, 0, 0, 145, 134,
1320 128, 126, 118, 119, 0, 0, 77, 0, 0, 59,
1321 82, 84, 0, 0, 89, 83, 228, 0, 209, 0,
1322 0, 0, 0, 40, 197, 198, 5, 6, 7, 8,
Chris Lattner66316012006-01-24 04:14:29 +00001323 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
1324 0, 0, 0, 0, 0, 0, 0, 19, 20, 0,
Chris Lattnerd25db202006-04-08 03:55:17 +00001325 0, 0, 0, 0, 0, 0, 0, 0, 0, 186,
1326 40, 201, 0, 225, 141, 138, 137, 139, 140, 144,
1327 0, 131, 61, 62, 63, 64, 65, 66, 67, 68,
1328 69, 70, 71, 0, 0, 0, 0, 129, 0, 0,
1329 0, 81, 156, 88, 86, 0, 0, 213, 208, 191,
1330 190, 0, 0, 24, 28, 23, 27, 22, 26, 21,
1331 25, 29, 30, 0, 0, 47, 47, 234, 0, 0,
1332 223, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1333 0, 0, 0, 0, 0, 0, 0, 142, 52, 103,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001334 104, 3, 4, 101, 102, 105, 100, 96, 97, 0,
Chris Lattner8335e842006-01-23 23:05:42 +00001335 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattnerd25db202006-04-08 03:55:17 +00001336 0, 0, 0, 99, 98, 52, 58, 58, 85, 155,
1337 149, 152, 153, 0, 0, 78, 168, 169, 170, 175,
1338 171, 172, 173, 174, 166, 0, 177, 182, 181, 183,
1339 0, 192, 0, 0, 0, 230, 0, 232, 227, 0,
Chris Lattner66316012006-01-24 04:14:29 +00001340 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattnerd25db202006-04-08 03:55:17 +00001341 0, 0, 0, 0, 0, 0, 143, 0, 132, 0,
1342 0, 0, 0, 0, 0, 91, 117, 0, 0, 95,
1343 0, 92, 0, 0, 0, 0, 130, 79, 80, 148,
1344 150, 0, 50, 87, 167, 0, 0, 0, 0, 0,
1345 0, 0, 0, 0, 237, 0, 0, 215, 0, 217,
1346 220, 0, 0, 218, 219, 0, 0, 0, 214, 0,
1347 235, 0, 0, 0, 54, 52, 227, 0, 0, 0,
1348 0, 0, 0, 90, 93, 94, 0, 0, 0, 0,
1349 154, 151, 51, 45, 0, 176, 0, 0, 207, 47,
1350 48, 47, 204, 226, 0, 0, 0, 0, 0, 210,
1351 211, 212, 207, 0, 49, 55, 53, 0, 0, 0,
1352 0, 0, 0, 116, 0, 0, 0, 0, 0, 157,
1353 0, 0, 0, 206, 0, 0, 231, 233, 0, 0,
1354 0, 216, 221, 222, 0, 236, 107, 0, 0, 0,
1355 0, 0, 0, 0, 0, 0, 46, 178, 0, 0,
1356 0, 205, 202, 0, 224, 106, 0, 113, 0, 0,
1357 109, 110, 111, 112, 0, 195, 0, 0, 0, 203,
1358 0, 0, 0, 193, 0, 194, 0, 0, 108, 114,
1359 115, 0, 0, 0, 0, 0, 0, 200, 0, 0,
1360 199, 196, 0, 0, 0
Chris Lattner8335e842006-01-23 23:05:42 +00001361};
1362
Chris Lattner66316012006-01-24 04:14:29 +00001363static const short yydefgoto[] = { 73,
Chris Lattnerd25db202006-04-08 03:55:17 +00001364 234, 250, 251, 252, 253, 174, 175, 204, 176, 20,
1365 10, 29, 420, 286, 365, 384, 309, 366, 74, 75,
1366 177, 77, 78, 103, 186, 317, 277, 318, 95, 493,
1367 1, 2, 256, 229, 50, 158, 41, 90, 161, 79,
1368 331, 262, 263, 264, 30, 83, 11, 36, 12, 13,
1369 23, 336, 278, 80, 280, 393, 14, 32, 33, 150,
1370 468, 85, 211, 424, 425, 151, 152, 345, 153, 154
Chris Lattner8335e842006-01-23 23:05:42 +00001371};
1372
1373static const short yypact[] = {-32768,
Chris Lattnerd25db202006-04-08 03:55:17 +00001374 181, 364,-32768,-32768,-32768,-32768,-32768,-32768, 6, -1,
1375 60,-32768,-32768, -14,-32768,-32768, 47, -22, 72, 45,
1376 33,-32768, -1, 125, 157,-32768,-32768,-32768, 1050, -21,
1377-32768,-32768, 22,-32768,-32768,-32768,-32768, 61, 67, 68,
1378-32768, 55, 125, 1050, -6, -6,-32768,-32768,-32768,-32768,
1379-32768,-32768,-32768, 66,-32768,-32768,-32768,-32768,-32768,-32768,
1380-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 168, 170,
1381 171, 566,-32768, 22, 73,-32768,-32768, -24,-32768,-32768,
1382-32768,-32768,-32768, 1213,-32768, 149, 57, 173, 155,-32768,
1383-32768,-32768,-32768,-32768, 1088, 1126,-32768, 74, 75,-32768,
1384-32768, -24, -82, 79, 860,-32768,-32768, 1088,-32768, 124,
1385 1164, 14, 128, -1,-32768,-32768,-32768,-32768,-32768,-32768,
Chris Lattner8335e842006-01-23 23:05:42 +00001386-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
Chris Lattnerd25db202006-04-08 03:55:17 +00001387 1088, 1088, 1088, 1088, 1088, 1088, 1088,-32768,-32768, 1088,
1388 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088,-32768,
1389 -1,-32768, 40,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1390 -9,-32768, 106, 143, 183, 148, 190, 152, 194, 154,
1391 196, 178, 195, 156, 197, 198, 425,-32768, 1088, 1088,
1392 1088,-32768, 898,-32768, 100, 98, 660,-32768,-32768, 66,
1393-32768, 660, 660,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1394-32768,-32768,-32768, 660, 1050, 104, 105,-32768, 660, 102,
1395 108, 177, 111, 112, 123, 130, 132, 133, 134, 660,
1396 660, 660, 135, 1050, 1088, 1088, 203,-32768, 136,-32768,
1397-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 137,
1398 138, 139, 140, 141, 142, 936, 1126, 604, 217, 145,
1399 146, 147, 150,-32768,-32768, 136, 18, -86, -24,-32768,
1400 22,-32768, 151, 153, 974,-32768,-32768,-32768,-32768,-32768,
1401-32768,-32768,-32768,-32768, 193, 1126,-32768,-32768,-32768,-32768,
1402 158,-32768, 159, 660, -5,-32768, 5,-32768, 172, 660,
1403 165, 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088, 174,
1404 175, 179, 1088, 660, 660, 180,-32768, -20,-32768, 1126,
1405 1126, 1126, 1126, 1126, 1126,-32768,-32768, -8, -81,-32768,
1406 -36,-32768, 1126, 1126, 1126, 1126,-32768,-32768,-32768,-32768,
1407-32768, 1012, 222,-32768,-32768, 233, -18, 237, 239, 176,
1408 660, 269, 660, 1088,-32768, 185, 660,-32768, 186,-32768,
1409-32768, 187, 189,-32768,-32768, 660, 660, 660,-32768, 191,
1410-32768, 1088, 252, 276,-32768, 136, 172, 248, 201, 202,
1411 204, 205, 1126,-32768,-32768,-32768, 206, 207, 208, 209,
1412-32768,-32768,-32768, 232, 210,-32768, 660, 660, 1088, 211,
1413-32768, 211,-32768, 223, 660, 224, 1088, 1088, 1088,-32768,
1414-32768,-32768, 1088, 660,-32768,-32768,-32768, 192, 1088, 1126,
1415 1126, 1126, 1126,-32768, 1126, 1126, 1126, 1126, 293,-32768,
1416 275, 225, 199, 223, 214, 280,-32768,-32768, 1088, 220,
1417 660,-32768,-32768,-32768, 229,-32768,-32768, 230, 227, 231,
1418 238, 240, 236, 241, 243, 244,-32768,-32768, 323, 41,
1419 309,-32768,-32768, 242,-32768,-32768, 1126,-32768, 1126, 1126,
1420-32768,-32768,-32768,-32768, 660,-32768, 757, 59, 325,-32768,
1421 246, 247, 249,-32768, 251,-32768, 757, 660,-32768,-32768,
1422-32768, 336, 256, 295, 660, 346, 350,-32768, 660, 660,
1423-32768,-32768, 372, 376,-32768
Chris Lattner8335e842006-01-23 23:05:42 +00001424};
1425
1426static const short yypgoto[] = {-32768,
Chris Lattnerd25db202006-04-08 03:55:17 +00001427-32768, 297, 298, 299, 301, -112, -110, -426,-32768, 344,
1428 359, -103,-32768, -202, 54,-32768, -243,-32768, -38,-32768,
1429 -29,-32768, -55, 287,-32768, -94, 216, -229, 348,-32768,
1430-32768,-32768,-32768,-32768, 355,-32768,-32768,-32768,-32768, 10,
1431-32768, 69,-32768,-32768, 379,-32768,-32768,-32768,-32768, 397,
1432-32768,-32768, -399, -56, 169, -104,-32768, 389,-32768,-32768,
1433-32768,-32768,-32768, 70, 1,-32768,-32768, 43,-32768,-32768
Chris Lattner8335e842006-01-23 23:05:42 +00001434};
1435
1436
Chris Lattnerd25db202006-04-08 03:55:17 +00001437#define YYLAST 1314
Chris Lattner8335e842006-01-23 23:05:42 +00001438
1439
Chris Lattner66316012006-01-24 04:14:29 +00001440static const short yytable[] = { 76,
Chris Lattnerd25db202006-04-08 03:55:17 +00001441 202, 178, 203, 188, 288, 92, 191, 81, 31, 341,
1442 205, 21, 327, 363, 76, 34, 102, 319, 321, 343,
1443 181, 373, 192, 467, 329, 93, 94, 106, 208, 375,
1444 182, 212, 213, 364, 193, 214, 215, 216, 217, 218,
1445 219, 477, 21, 15, 223, 16, 337, 224, 342, 102,
1446 194, 195, 196, 197, 198, 199, 200, 201, 342, 25,
1447 26, 27, 28, 24, 44, 162, 373, 475, 194, 195,
1448 196, 197, 198, 199, 200, 201, 376, 483, 187, 42,
1449 -58, 187, 31, 104, 373, 5, 6, 7, 8, 106,
1450 82, 45, 386, 227, 373, 38, 39, 40, 35, 228,
1451 374, 206, 207, 187, 209, 210, 187, 187, 156, 157,
1452 187, 187, 187, 187, 187, 187, 220, 221, 222, 187,
1453 255, 306, 407, 257, 258, 259, 328, 225, 226, 43,
1454 279, 106, 230, 231, 47, 279, 279, 194, 195, 196,
1455 197, 198, 199, 200, 201, -24, -24, 279, 49, 466,
1456 -23, -23, 279, 261, -22, -22, -21, -21, 232, 233,
1457 51, 89, 86, 279, 279, 279, 284, 476, 87, 88,
1458 -59, 97, 155, 98, 99, 76, 159, 105, 160, 189,
1459 -120, 179, 180, 183, -31, 304, -28, 427, 349, 428,
1460 351, 352, 353, -27, 76, 305, 187, -26, 359, -25,
1461 235, -32, 265, 266, 236, 3, 285, 287, 290, 259,
1462 291, 4, 292, 293, 294, 367, 368, 369, 370, 371,
1463 372, 5, 6, 7, 8, 295, 307, 279, 377, 378,
1464 379, 380, 296, 279, 297, 298, 299, 303, 308, 9,
1465 322, 310, 311, 312, 313, 314, 315, 279, 279, 323,
1466 324, 325, 335, 332, 326, 363, 385, 387, 333, 388,
1467 338, 339, 348, 187, 350, 187, 187, 187, 354, 355,
1468 330, 347, 391, 187, 344, 405, 356, 357, 414, 406,
1469 389, 358, 362, 409, 279, 419, 279, 395, 397, 398,
1470 279, 399, 432, 433, 434, 403, 447, 437, 448, 279,
1471 279, 279, 261, 410, 411, 450, 412, 413, 415, 416,
1472 417, 418, 421, 426, 187, 439, 440, 441, 442, 451,
1473 443, 444, 445, 446, 452, 429, 431, 449, 453, 457,
1474 279, 279, 404, 342, 455, 456, 458, 202, 279, 203,
1475 459, 461, 460, 465, 469, 478, 462, 279, 463, 464,
1476 470, 479, 480, 482, 481, 202, 485, 203, 486, 187,
1477 281, 282, 471, 487, 472, 473, 489, 187, 187, 187,
1478 490, 494, 283, 187, 279, 495, 84, 289, 46, 438,
1479 146, 147, 148, -34, 149, 15, 383, 16, 300, 301,
1480 302, 185, 254, 96, 4, -34, -34, 91, 22, 187,
1481 382, 48, 37, 435, -34, -34, -34, -34, 279, 408,
1482 -34, 17, 0, 394, 0, 0, 0, 0, 18, 0,
1483 0, 279, 19, 0, 0, 0, 0, 0, 279, 52,
1484 53, 0, 279, 279, 0, 0, 0, 0, 0, 0,
1485 0, 0, 0, 0, 0, 0, 15, 0, 16, 0,
1486 237, 0, 340, 0, 0, 0, 0, 0, 346, 0,
1487 0, 0, 238, 239, 0, 0, 0, 0, 0, 0,
1488 0, 0, 360, 361, 0, 0, 0, 0, 0, 0,
1489 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001490 0, 0, 0, 0, 0, 117, 118, 119, 120, 121,
Chris Lattnerd25db202006-04-08 03:55:17 +00001491 122, 123, 124, 125, 126, 127, 128, 129, 130, 390,
1492 0, 392, 0, 0, 240, 396, 241, 242, 138, 139,
1493 0, 243, 244, 245, 400, 401, 402, 0, 0, 0,
1494 0, 246, 0, 0, 247, 0, 248, 0, 0, 249,
Chris Lattner8335e842006-01-23 23:05:42 +00001495 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattnerd25db202006-04-08 03:55:17 +00001496 0, 0, 0, 0, 0, 422, 423, 0, 0, 0,
1497 0, 0, 0, 430, 0, 0, 0, 0, 0, 0,
1498 52, 53, 436, 100, 55, 56, 57, 58, 59, 60,
1499 61, 62, 63, 64, 65, 66, 67, 15, 0, 16,
1500 0, 0, 0, 0, 0, 0, 0, 0, 0, 454,
1501 0, 0, 0, 0, 0, 0, 0, 0, 52, 53,
1502 68, 100, 163, 164, 165, 166, 167, 168, 169, 170,
1503 171, 172, 173, 66, 67, 15, 0, 16, 0, 0,
1504 0, 0, 0, 474, 0, 0, 0, 0, 0, 0,
1505 0, 0, 0, 0, 0, 0, 484, 0, 68, 0,
1506 0, 0, 0, 488, 0, 0, 0, 491, 492, 0,
1507 0, 0, 267, 268, 52, 53, 269, 0, 0, 69,
1508 0, 0, 70, 0, 0, 71, 0, 72, 101, 0,
1509 0, 15, 0, 16, 0, 270, 271, 272, 0, 0,
1510 0, 0, 0, 0, 0, 0, 0, 273, 274, 0,
1511 0, 0, 0, 0, 0, 0, 0, 69, 0, 0,
1512 70, 0, 0, 71, 0, 72, 320, 275, 0, 0,
Chris Lattner66316012006-01-24 04:14:29 +00001513 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001514 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
Chris Lattnerd25db202006-04-08 03:55:17 +00001515 127, 128, 129, 130, 0, 0, 0, 0, 0, 240,
1516 0, 241, 242, 138, 139, 0, 243, 244, 245, 267,
1517 268, 0, 0, 269, 0, 0, 0, 0, 0, 276,
1518 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1519 0, 0, 270, 271, 272, 0, 0, 0, 0, 0,
1520 0, 0, 0, 0, 273, 274, 0, 0, 0, 0,
1521 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1522 0, 0, 0, 0, 275, 0, 0, 0, 0, 0,
1523 0, 0, 0, 0, 0, 0, 0, 117, 118, 119,
1524 120, 121, 122, 123, 124, 125, 126, 127, 128, 129,
1525 130, 0, 0, 0, 0, 0, 240, 0, 241, 242,
1526 138, 139, 0, 243, 244, 245, 0, 0, 0, 0,
1527 0, 0, 0, 0, 52, 53, 276, 100, 55, 56,
1528 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1529 67, 15, 0, 16, 0, 0, 0, 0, 0, 0,
1530 0, 0, 0, 0, 0, 0, 184, 0, 0, 0,
1531 0, 0, 52, 53, 68, 100, 55, 56, 57, 58,
1532 59, 60, 61, 62, 63, 64, 65, 66, 67, 15,
1533 0, 16, 0, 0, 0, 0, 0, 0, 0, 0,
1534 0, 0, 0, 0, 260, 0, 0, 0, 0, 0,
1535 52, 53, 68, 100, 163, 164, 165, 166, 167, 168,
1536 169, 170, 171, 172, 173, 66, 67, 15, 0, 16,
1537 0, 0, 0, 69, 0, 0, 70, 0, 0, 71,
1538 0, 72, 0, 0, 0, 0, 0, 0, 52, 53,
1539 68, 100, 55, 56, 57, 58, 59, 60, 61, 62,
1540 63, 64, 65, 66, 67, 15, 0, 16, 0, 0,
1541 0, 69, 0, 0, 70, 0, 0, 71, 0, 72,
1542 334, 0, 0, 0, 0, 0, 52, 53, 68, 100,
1543 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1544 65, 66, 67, 15, 0, 16, 0, 0, 0, 69,
1545 0, 0, 70, 0, 316, 71, 0, 72, 381, 0,
1546 0, 0, 0, 0, 52, 53, 68, 54, 55, 56,
1547 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1548 67, 15, 0, 16, 0, 0, 0, 69, 0, 0,
1549 70, 0, 0, 71, 0, 72, 0, 0, 0, 0,
1550 0, 0, 52, 53, 68, 100, 55, 56, 57, 58,
1551 59, 60, 61, 62, 63, 64, 65, 66, 67, 15,
1552 0, 16, 0, 0, 0, 69, 0, 0, 70, 0,
1553 0, 71, 0, 72, 0, 0, 0, 0, 0, 0,
1554 52, 53, 68, 100, 163, 164, 165, 166, 167, 168,
1555 169, 170, 171, 172, 173, 66, 67, 15, 0, 16,
1556 0, 0, 0, 69, 0, 0, 70, 0, 0, 71,
1557 0, 72, 0, 0, 0, 0, 0, 0, 52, 53,
1558 68, 190, 55, 56, 57, 58, 59, 60, 61, 62,
1559 63, 64, 65, 66, 67, 15, 0, 16, 0, 0,
1560 0, 69, 0, 0, 70, 0, 0, 71, 0, 72,
1561 0, 0, 0, 0, 0, 0, 0, 0, 68, 0,
1562 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1563 0, 0, 0, 0, 0, 0, 0, 0, 0, 69,
1564 0, 0, 70, 0, 0, 71, 0, 72, 0, 0,
1565 0, 0, 0, 0, 0, 0, 0, 107, 0, 0,
1566 0, 0, 0, 0, 0, 0, 0, 0, 108, 0,
1567 0, 0, 0, 0, 0, 0, 0, 69, 109, 110,
1568 70, 0, 0, 71, 0, 72, 0, 111, 112, 113,
1569 114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
1570 124, 125, 126, 127, 128, 129, 130, 131, 132, 133,
1571 0, 0, 134, 135, 136, 137, 138, 139, 140, 141,
1572 142, 143, 144, 145
Chris Lattner8335e842006-01-23 23:05:42 +00001573};
1574
Chris Lattner66316012006-01-24 04:14:29 +00001575static const short yycheck[] = { 29,
Chris Lattnerd25db202006-04-08 03:55:17 +00001576 113, 96, 113, 108, 207, 44, 111, 29, 23, 15,
1577 114, 2, 256, 34, 44, 30, 72, 247, 248, 15,
1578 103, 103, 9, 450, 111, 32, 33, 114, 133, 111,
1579 113, 136, 137, 54, 21, 140, 141, 142, 143, 144,
1580 145, 468, 33, 22, 149, 24, 276, 151, 54, 105,
1581 10, 11, 12, 13, 14, 15, 16, 17, 54, 61,
1582 62, 63, 64, 58, 20, 95, 103, 467, 10, 11,
1583 12, 13, 14, 15, 16, 17, 113, 477, 108, 102,
1584 105, 111, 23, 74, 103, 41, 42, 43, 44, 114,
1585 112, 47, 111, 103, 103, 49, 50, 51, 113, 109,
1586 109, 131, 132, 133, 134, 135, 136, 137, 52, 53,
1587 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
1588 177, 226, 366, 179, 180, 181, 109, 88, 89, 58,
1589 187, 114, 27, 28, 102, 192, 193, 10, 11, 12,
1590 13, 14, 15, 16, 17, 3, 4, 204, 24, 109,
1591 3, 4, 209, 183, 3, 4, 3, 4, 3, 4,
1592 4, 107, 102, 220, 221, 222, 205, 109, 102, 102,
1593 105, 4, 24, 4, 4, 205, 4, 105, 24, 56,
1594 0, 108, 108, 105, 7, 224, 4, 390, 293, 392,
1595 295, 296, 297, 4, 224, 225, 226, 4, 303, 4,
1596 4, 7, 103, 106, 7, 25, 103, 103, 107, 265,
1597 103, 31, 36, 103, 103, 310, 311, 312, 313, 314,
1598 315, 41, 42, 43, 44, 103, 24, 284, 323, 324,
1599 325, 326, 103, 290, 103, 103, 103, 103, 103, 59,
1600 24, 105, 105, 105, 105, 105, 105, 304, 305, 105,
1601 105, 105, 60, 103, 105, 34, 24, 21, 106, 21,
1602 103, 103, 292, 293, 294, 295, 296, 297, 298, 299,
1603 261, 107, 4, 303, 103, 24, 103, 103, 373, 4,
1604 105, 103, 103, 36, 341, 54, 343, 103, 103, 103,
1605 347, 103, 397, 398, 399, 105, 4, 106, 24, 356,
1606 357, 358, 332, 103, 103, 107, 103, 103, 103, 103,
1607 103, 103, 103, 103, 344, 410, 411, 412, 413, 106,
1608 415, 416, 417, 418, 429, 103, 103, 103, 109, 103,
1609 387, 388, 362, 54, 106, 106, 106, 450, 395, 450,
1610 103, 106, 103, 21, 36, 21, 106, 404, 106, 106,
1611 109, 106, 106, 103, 106, 468, 21, 468, 103, 389,
1612 192, 193, 457, 69, 459, 460, 21, 397, 398, 399,
1613 21, 0, 204, 403, 431, 0, 33, 209, 20, 409,
1614 84, 84, 84, 20, 84, 22, 333, 24, 220, 221,
1615 222, 105, 177, 46, 31, 32, 33, 43, 2, 429,
1616 332, 23, 14, 403, 41, 42, 43, 44, 465, 367,
1617 47, 48, -1, 344, -1, -1, -1, -1, 55, -1,
1618 -1, 478, 59, -1, -1, -1, -1, -1, 485, 5,
1619 6, -1, 489, 490, -1, -1, -1, -1, -1, -1,
1620 -1, -1, -1, -1, -1, -1, 22, -1, 24, -1,
1621 26, -1, 284, -1, -1, -1, -1, -1, 290, -1,
1622 -1, -1, 38, 39, -1, -1, -1, -1, -1, -1,
1623 -1, -1, 304, 305, -1, -1, -1, -1, -1, -1,
1624 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001625 -1, -1, -1, -1, -1, 71, 72, 73, 74, 75,
Chris Lattnerd25db202006-04-08 03:55:17 +00001626 76, 77, 78, 79, 80, 81, 82, 83, 84, 341,
1627 -1, 343, -1, -1, 90, 347, 92, 93, 94, 95,
1628 -1, 97, 98, 99, 356, 357, 358, -1, -1, -1,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001629 -1, 107, -1, -1, 110, -1, 112, -1, -1, 115,
1630 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattnerd25db202006-04-08 03:55:17 +00001631 -1, -1, -1, -1, -1, 387, 388, -1, -1, -1,
1632 -1, -1, -1, 395, -1, -1, -1, -1, -1, -1,
1633 5, 6, 404, 8, 9, 10, 11, 12, 13, 14,
1634 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
1635 -1, -1, -1, -1, -1, -1, -1, -1, -1, 431,
1636 -1, -1, -1, -1, -1, -1, -1, -1, 5, 6,
1637 45, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1638 17, 18, 19, 20, 21, 22, -1, 24, -1, -1,
1639 -1, -1, -1, 465, -1, -1, -1, -1, -1, -1,
1640 -1, -1, -1, -1, -1, -1, 478, -1, 45, -1,
1641 -1, -1, -1, 485, -1, -1, -1, 489, 490, -1,
1642 -1, -1, 3, 4, 5, 6, 7, -1, -1, 104,
1643 -1, -1, 107, -1, -1, 110, -1, 112, 113, -1,
1644 -1, 22, -1, 24, -1, 26, 27, 28, -1, -1,
1645 -1, -1, -1, -1, -1, -1, -1, 38, 39, -1,
1646 -1, -1, -1, -1, -1, -1, -1, 104, -1, -1,
1647 107, -1, -1, 110, -1, 112, 113, 58, -1, -1,
1648 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1649 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
1650 81, 82, 83, 84, -1, -1, -1, -1, -1, 90,
1651 -1, 92, 93, 94, 95, -1, 97, 98, 99, 3,
1652 4, -1, -1, 7, -1, -1, -1, -1, -1, 110,
1653 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1654 -1, -1, 26, 27, 28, -1, -1, -1, -1, -1,
1655 -1, -1, -1, -1, 38, 39, -1, -1, -1, -1,
1656 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1657 -1, -1, -1, -1, 58, -1, -1, -1, -1, -1,
1658 -1, -1, -1, -1, -1, -1, -1, 71, 72, 73,
1659 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
1660 84, -1, -1, -1, -1, -1, 90, -1, 92, 93,
1661 94, 95, -1, 97, 98, 99, -1, -1, -1, -1,
1662 -1, -1, -1, -1, 5, 6, 110, 8, 9, 10,
1663 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
1664 21, 22, -1, 24, -1, -1, -1, -1, -1, -1,
1665 -1, -1, -1, -1, -1, -1, 37, -1, -1, -1,
1666 -1, -1, 5, 6, 45, 8, 9, 10, 11, 12,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001667 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
1668 -1, 24, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattnerd25db202006-04-08 03:55:17 +00001669 -1, -1, -1, -1, 37, -1, -1, -1, -1, -1,
1670 5, 6, 45, 8, 9, 10, 11, 12, 13, 14,
1671 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
1672 -1, -1, -1, 104, -1, -1, 107, -1, -1, 110,
1673 -1, 112, -1, -1, -1, -1, -1, -1, 5, 6,
1674 45, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1675 17, 18, 19, 20, 21, 22, -1, 24, -1, -1,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001676 -1, 104, -1, -1, 107, -1, -1, 110, -1, 112,
Chris Lattnerd25db202006-04-08 03:55:17 +00001677 37, -1, -1, -1, -1, -1, 5, 6, 45, 8,
1678 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
1679 19, 20, 21, 22, -1, 24, -1, -1, -1, 104,
1680 -1, -1, 107, -1, 109, 110, -1, 112, 37, -1,
1681 -1, -1, -1, -1, 5, 6, 45, 8, 9, 10,
1682 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
1683 21, 22, -1, 24, -1, -1, -1, 104, -1, -1,
1684 107, -1, -1, 110, -1, 112, -1, -1, -1, -1,
1685 -1, -1, 5, 6, 45, 8, 9, 10, 11, 12,
1686 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
1687 -1, 24, -1, -1, -1, 104, -1, -1, 107, -1,
1688 -1, 110, -1, 112, -1, -1, -1, -1, -1, -1,
1689 5, 6, 45, 8, 9, 10, 11, 12, 13, 14,
1690 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
1691 -1, -1, -1, 104, -1, -1, 107, -1, -1, 110,
1692 -1, 112, -1, -1, -1, -1, -1, -1, 5, 6,
1693 45, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1694 17, 18, 19, 20, 21, 22, -1, 24, -1, -1,
1695 -1, 104, -1, -1, 107, -1, -1, 110, -1, 112,
1696 -1, -1, -1, -1, -1, -1, -1, -1, 45, -1,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001697 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattnerd25db202006-04-08 03:55:17 +00001698 -1, -1, -1, -1, -1, -1, -1, -1, -1, 104,
1699 -1, -1, 107, -1, -1, 110, -1, 112, -1, -1,
1700 -1, -1, -1, -1, -1, -1, -1, 35, -1, -1,
1701 -1, -1, -1, -1, -1, -1, -1, -1, 46, -1,
1702 -1, -1, -1, -1, -1, -1, -1, 104, 56, 57,
1703 107, -1, -1, 110, -1, 112, -1, 65, 66, 67,
1704 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
1705 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
1706 -1, -1, 90, 91, 92, 93, 94, 95, 96, 97,
1707 98, 99, 100, 101
Chris Lattner8335e842006-01-23 23:05:42 +00001708};
1709/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
1710#line 3 "/usr/share/bison.simple"
1711/* This file comes from bison-1.28. */
1712
1713/* Skeleton output parser for bison,
1714 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
1715
1716 This program is free software; you can redistribute it and/or modify
1717 it under the terms of the GNU General Public License as published by
1718 the Free Software Foundation; either version 2, or (at your option)
1719 any later version.
1720
1721 This program is distributed in the hope that it will be useful,
1722 but WITHOUT ANY WARRANTY; without even the implied warranty of
1723 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1724 GNU General Public License for more details.
1725
1726 You should have received a copy of the GNU General Public License
1727 along with this program; if not, write to the Free Software
1728 Foundation, Inc., 59 Temple Place - Suite 330,
1729 Boston, MA 02111-1307, USA. */
1730
1731/* As a special exception, when this file is copied by Bison into a
1732 Bison output file, you may use that output file without restriction.
1733 This special exception was added by the Free Software Foundation
1734 in version 1.24 of Bison. */
1735
1736/* This is the parser code that is written into each bison parser
1737 when the %semantic_parser declaration is not specified in the grammar.
1738 It was written by Richard Stallman by simplifying the hairy parser
1739 used when %semantic_parser is specified. */
1740
1741#ifndef YYSTACK_USE_ALLOCA
1742#ifdef alloca
1743#define YYSTACK_USE_ALLOCA
1744#else /* alloca not defined */
1745#ifdef __GNUC__
1746#define YYSTACK_USE_ALLOCA
1747#define alloca __builtin_alloca
1748#else /* not GNU C. */
1749#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
1750#define YYSTACK_USE_ALLOCA
1751#include <alloca.h>
1752#else /* not sparc */
1753/* We think this test detects Watcom and Microsoft C. */
1754/* This used to test MSDOS, but that is a bad idea
1755 since that symbol is in the user namespace. */
1756#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
1757#if 0 /* No need for malloc.h, which pollutes the namespace;
1758 instead, just don't use alloca. */
1759#include <malloc.h>
1760#endif
1761#else /* not MSDOS, or __TURBOC__ */
1762#if defined(_AIX)
1763/* I don't know what this was needed for, but it pollutes the namespace.
1764 So I turned it off. rms, 2 May 1997. */
1765/* #include <malloc.h> */
1766 #pragma alloca
1767#define YYSTACK_USE_ALLOCA
1768#else /* not MSDOS, or __TURBOC__, or _AIX */
1769#if 0
1770#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
1771 and on HPUX 10. Eventually we can turn this on. */
1772#define YYSTACK_USE_ALLOCA
1773#define alloca __builtin_alloca
1774#endif /* __hpux */
1775#endif
1776#endif /* not _AIX */
1777#endif /* not MSDOS, or __TURBOC__ */
1778#endif /* not sparc */
1779#endif /* not GNU C */
1780#endif /* alloca not defined */
1781#endif /* YYSTACK_USE_ALLOCA not defined */
1782
1783#ifdef YYSTACK_USE_ALLOCA
1784#define YYSTACK_ALLOC alloca
Reid Spencer68a24bd2005-08-27 18:50:39 +00001785#else
Chris Lattner8335e842006-01-23 23:05:42 +00001786#define YYSTACK_ALLOC malloc
Reid Spencer68a24bd2005-08-27 18:50:39 +00001787#endif
1788
Chris Lattner8335e842006-01-23 23:05:42 +00001789/* Note: there must be only one dollar sign in this file.
1790 It is replaced by the list of actions, each action
1791 as one case of the switch. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001792
1793#define yyerrok (yyerrstatus = 0)
1794#define yyclearin (yychar = YYEMPTY)
Chris Lattner8335e842006-01-23 23:05:42 +00001795#define YYEMPTY -2
Reid Spencer68a24bd2005-08-27 18:50:39 +00001796#define YYEOF 0
Reid Spencer68a24bd2005-08-27 18:50:39 +00001797#define YYACCEPT goto yyacceptlab
Chris Lattner8335e842006-01-23 23:05:42 +00001798#define YYABORT goto yyabortlab
1799#define YYERROR goto yyerrlab1
1800/* Like YYERROR except do call yyerror.
1801 This remains here temporarily to ease the
1802 transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00001803 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001804#define YYFAIL goto yyerrlab
Reid Spencer68a24bd2005-08-27 18:50:39 +00001805#define YYRECOVERING() (!!yyerrstatus)
Chris Lattner8335e842006-01-23 23:05:42 +00001806#define YYBACKUP(token, value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00001807do \
1808 if (yychar == YYEMPTY && yylen == 1) \
Chris Lattner8335e842006-01-23 23:05:42 +00001809 { yychar = (token), yylval = (value); \
1810 yychar1 = YYTRANSLATE (yychar); \
Reid Spencer68a24bd2005-08-27 18:50:39 +00001811 YYPOPSTACK; \
1812 goto yybackup; \
1813 } \
1814 else \
Chris Lattner8335e842006-01-23 23:05:42 +00001815 { yyerror ("syntax error: cannot back up"); YYERROR; } \
Reid Spencer68a24bd2005-08-27 18:50:39 +00001816while (0)
1817
1818#define YYTERROR 1
1819#define YYERRCODE 256
1820
Chris Lattner8335e842006-01-23 23:05:42 +00001821#ifndef YYPURE
1822#define YYLEX yylex()
Reid Spencer68a24bd2005-08-27 18:50:39 +00001823#endif
1824
Chris Lattner8335e842006-01-23 23:05:42 +00001825#ifdef YYPURE
1826#ifdef YYLSP_NEEDED
Reid Spencer68a24bd2005-08-27 18:50:39 +00001827#ifdef YYLEX_PARAM
Chris Lattner8335e842006-01-23 23:05:42 +00001828#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001829#else
Chris Lattner8335e842006-01-23 23:05:42 +00001830#define YYLEX yylex(&yylval, &yylloc)
1831#endif
1832#else /* not YYLSP_NEEDED */
1833#ifdef YYLEX_PARAM
1834#define YYLEX yylex(&yylval, YYLEX_PARAM)
1835#else
1836#define YYLEX yylex(&yylval)
1837#endif
1838#endif /* not YYLSP_NEEDED */
Robert Bocchino2def1b32006-01-17 20:06:25 +00001839#endif
Reid Spencere812fb22006-01-19 01:21:04 +00001840
Chris Lattner8335e842006-01-23 23:05:42 +00001841/* If nonreentrant, generate the variables here */
Reid Spencere812fb22006-01-19 01:21:04 +00001842
Chris Lattner8335e842006-01-23 23:05:42 +00001843#ifndef YYPURE
Reid Spencere812fb22006-01-19 01:21:04 +00001844
Chris Lattner8335e842006-01-23 23:05:42 +00001845int yychar; /* the lookahead symbol */
1846YYSTYPE yylval; /* the semantic value of the */
1847 /* lookahead symbol */
Reid Spencere812fb22006-01-19 01:21:04 +00001848
Chris Lattner8335e842006-01-23 23:05:42 +00001849#ifdef YYLSP_NEEDED
1850YYLTYPE yylloc; /* location data for the lookahead */
1851 /* symbol */
Robert Bocchino2def1b32006-01-17 20:06:25 +00001852#endif
Reid Spencere812fb22006-01-19 01:21:04 +00001853
Chris Lattner8335e842006-01-23 23:05:42 +00001854int yynerrs; /* number of parse errors so far */
1855#endif /* not YYPURE */
Reid Spencere812fb22006-01-19 01:21:04 +00001856
Chris Lattner8335e842006-01-23 23:05:42 +00001857#if YYDEBUG != 0
1858int yydebug; /* nonzero means print parse trace */
1859/* Since this is uninitialized, it does not stop multiple parsers
1860 from coexisting. */
Nate Begeman14b05292005-11-05 09:21:28 +00001861#endif
Reid Spencer0b118202006-01-16 21:12:35 +00001862
Chris Lattner8335e842006-01-23 23:05:42 +00001863/* YYINITDEPTH indicates the initial size of the parser's stacks */
Reid Spencer0b118202006-01-16 21:12:35 +00001864
Reid Spencer68a24bd2005-08-27 18:50:39 +00001865#ifndef YYINITDEPTH
Chris Lattner8335e842006-01-23 23:05:42 +00001866#define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00001867#endif
1868
Chris Lattner8335e842006-01-23 23:05:42 +00001869/* YYMAXDEPTH is the maximum size the stacks can grow to
1870 (effective only if the built-in stack extension method is used). */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001871
Chris Lattner8335e842006-01-23 23:05:42 +00001872#if YYMAXDEPTH == 0
1873#undef YYMAXDEPTH
Reid Spencer68a24bd2005-08-27 18:50:39 +00001874#endif
1875
1876#ifndef YYMAXDEPTH
Chris Lattner8335e842006-01-23 23:05:42 +00001877#define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00001878#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001879
Chris Lattner8335e842006-01-23 23:05:42 +00001880/* Define __yy_memcpy. Note that the size argument
1881 should be passed with type unsigned int, because that is what the non-GCC
1882 definitions require. With GCC, __builtin_memcpy takes an arg
1883 of type size_t, but it can handle unsigned int. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001884
Chris Lattner8335e842006-01-23 23:05:42 +00001885#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
1886#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
1887#else /* not GNU C or C++ */
1888#ifndef __cplusplus
Reid Spencer68a24bd2005-08-27 18:50:39 +00001889
Chris Lattner8335e842006-01-23 23:05:42 +00001890/* This is the most reliable way to avoid incompatibilities
1891 in available built-in functions on various systems. */
Reid Spencere812fb22006-01-19 01:21:04 +00001892static void
Chris Lattner8335e842006-01-23 23:05:42 +00001893__yy_memcpy (to, from, count)
1894 char *to;
1895 char *from;
1896 unsigned int count;
1897{
1898 register char *f = from;
1899 register char *t = to;
1900 register int i = count;
1901
1902 while (i-- > 0)
1903 *t++ = *f++;
1904}
1905
1906#else /* __cplusplus */
1907
1908/* This is the most reliable way to avoid incompatibilities
1909 in available built-in functions on various systems. */
Reid Spencere812fb22006-01-19 01:21:04 +00001910static void
Chris Lattner8335e842006-01-23 23:05:42 +00001911__yy_memcpy (char *to, char *from, unsigned int count)
1912{
1913 register char *t = to;
1914 register char *f = from;
1915 register int i = count;
1916
1917 while (i-- > 0)
1918 *t++ = *f++;
1919}
1920
Reid Spencer0b118202006-01-16 21:12:35 +00001921#endif
Reid Spencere812fb22006-01-19 01:21:04 +00001922#endif
Reid Spencere812fb22006-01-19 01:21:04 +00001923
Chris Lattner8335e842006-01-23 23:05:42 +00001924#line 217 "/usr/share/bison.simple"
Reid Spencere812fb22006-01-19 01:21:04 +00001925
Chris Lattner8335e842006-01-23 23:05:42 +00001926/* The user can define YYPARSE_PARAM as the name of an argument to be passed
1927 into yyparse. The argument should have type void *.
1928 It should actually point to an object.
1929 Grammar actions can access the variable by casting it
1930 to the proper pointer type. */
Reid Spencere812fb22006-01-19 01:21:04 +00001931
1932#ifdef YYPARSE_PARAM
Chris Lattner8335e842006-01-23 23:05:42 +00001933#ifdef __cplusplus
1934#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
1935#define YYPARSE_PARAM_DECL
1936#else /* not __cplusplus */
1937#define YYPARSE_PARAM_ARG YYPARSE_PARAM
1938#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
1939#endif /* not __cplusplus */
1940#else /* not YYPARSE_PARAM */
1941#define YYPARSE_PARAM_ARG
1942#define YYPARSE_PARAM_DECL
1943#endif /* not YYPARSE_PARAM */
1944
1945/* Prevent warning if -Wstrict-prototypes. */
1946#ifdef __GNUC__
1947#ifdef YYPARSE_PARAM
1948int yyparse (void *);
1949#else
Reid Spencere812fb22006-01-19 01:21:04 +00001950int yyparse (void);
Reid Spencere812fb22006-01-19 01:21:04 +00001951#endif
Chris Lattner8335e842006-01-23 23:05:42 +00001952#endif
Reid Spencere812fb22006-01-19 01:21:04 +00001953
Reid Spencere812fb22006-01-19 01:21:04 +00001954int
Chris Lattner8335e842006-01-23 23:05:42 +00001955yyparse(YYPARSE_PARAM_ARG)
1956 YYPARSE_PARAM_DECL
Reid Spencere812fb22006-01-19 01:21:04 +00001957{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001958 register int yystate;
1959 register int yyn;
Nate Begeman14b05292005-11-05 09:21:28 +00001960 register short *yyssp;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001961 register YYSTYPE *yyvsp;
Chris Lattner8335e842006-01-23 23:05:42 +00001962 int yyerrstatus; /* number of tokens to shift before error messages enabled */
1963 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001964
Chris Lattner8335e842006-01-23 23:05:42 +00001965 short yyssa[YYINITDEPTH]; /* the state stack */
1966 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001967
Chris Lattner8335e842006-01-23 23:05:42 +00001968 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
1969 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001970
Chris Lattner8335e842006-01-23 23:05:42 +00001971#ifdef YYLSP_NEEDED
1972 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
1973 YYLTYPE *yyls = yylsa;
1974 YYLTYPE *yylsp;
1975
1976#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
1977#else
Reid Spencer68a24bd2005-08-27 18:50:39 +00001978#define YYPOPSTACK (yyvsp--, yyssp--)
Chris Lattner8335e842006-01-23 23:05:42 +00001979#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001980
Chris Lattner8335e842006-01-23 23:05:42 +00001981 int yystacksize = YYINITDEPTH;
1982 int yyfree_stacks = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001983
Chris Lattner8335e842006-01-23 23:05:42 +00001984#ifdef YYPURE
1985 int yychar;
1986 YYSTYPE yylval;
1987 int yynerrs;
1988#ifdef YYLSP_NEEDED
1989 YYLTYPE yylloc;
1990#endif
1991#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001992
Chris Lattner8335e842006-01-23 23:05:42 +00001993 YYSTYPE yyval; /* the variable used to return */
1994 /* semantic values from the action */
1995 /* routines */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001996
Reid Spencer68a24bd2005-08-27 18:50:39 +00001997 int yylen;
1998
Chris Lattner8335e842006-01-23 23:05:42 +00001999#if YYDEBUG != 0
2000 if (yydebug)
2001 fprintf(stderr, "Starting parse\n");
2002#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002003
2004 yystate = 0;
2005 yyerrstatus = 0;
2006 yynerrs = 0;
2007 yychar = YYEMPTY; /* Cause a token to be read. */
2008
2009 /* Initialize stack pointers.
2010 Waste one element of value and location stack
2011 so that they stay on the same level as the state stack.
2012 The wasted elements are never initialized. */
2013
Chris Lattner8335e842006-01-23 23:05:42 +00002014 yyssp = yyss - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002015 yyvsp = yyvs;
Chris Lattner8335e842006-01-23 23:05:42 +00002016#ifdef YYLSP_NEEDED
2017 yylsp = yyls;
2018#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002019
Chris Lattner8335e842006-01-23 23:05:42 +00002020/* Push a new state, which is found in yystate . */
2021/* In all cases, when you get here, the value and location stacks
2022 have just been pushed. so pushing a state here evens the stacks. */
2023yynewstate:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002024
Chris Lattner8335e842006-01-23 23:05:42 +00002025 *++yyssp = yystate;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002026
Chris Lattner8335e842006-01-23 23:05:42 +00002027 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002028 {
Chris Lattner8335e842006-01-23 23:05:42 +00002029 /* Give user a chance to reallocate the stack */
2030 /* Use copies of these so that the &'s don't force the real ones into memory. */
2031 YYSTYPE *yyvs1 = yyvs;
2032 short *yyss1 = yyss;
2033#ifdef YYLSP_NEEDED
2034 YYLTYPE *yyls1 = yyls;
2035#endif
2036
Reid Spencer68a24bd2005-08-27 18:50:39 +00002037 /* Get the current used size of the three stacks, in elements. */
Chris Lattner8335e842006-01-23 23:05:42 +00002038 int size = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002039
2040#ifdef yyoverflow
Chris Lattner8335e842006-01-23 23:05:42 +00002041 /* Each stack pointer address is followed by the size of
2042 the data in use in that stack, in bytes. */
2043#ifdef YYLSP_NEEDED
2044 /* This used to be a conditional around just the two extra args,
2045 but that might be undefined if yyoverflow is a macro. */
2046 yyoverflow("parser stack overflow",
2047 &yyss1, size * sizeof (*yyssp),
2048 &yyvs1, size * sizeof (*yyvsp),
2049 &yyls1, size * sizeof (*yylsp),
2050 &yystacksize);
2051#else
2052 yyoverflow("parser stack overflow",
2053 &yyss1, size * sizeof (*yyssp),
2054 &yyvs1, size * sizeof (*yyvsp),
2055 &yystacksize);
2056#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002057
Chris Lattner8335e842006-01-23 23:05:42 +00002058 yyss = yyss1; yyvs = yyvs1;
2059#ifdef YYLSP_NEEDED
2060 yyls = yyls1;
2061#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002062#else /* no yyoverflow */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002063 /* Extend the stack our own way. */
Chris Lattner8335e842006-01-23 23:05:42 +00002064 if (yystacksize >= YYMAXDEPTH)
2065 {
2066 yyerror("parser stack overflow");
2067 if (yyfree_stacks)
2068 {
2069 free (yyss);
2070 free (yyvs);
2071#ifdef YYLSP_NEEDED
2072 free (yyls);
2073#endif
2074 }
2075 return 2;
2076 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002077 yystacksize *= 2;
Chris Lattner8335e842006-01-23 23:05:42 +00002078 if (yystacksize > YYMAXDEPTH)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002079 yystacksize = YYMAXDEPTH;
Chris Lattner8335e842006-01-23 23:05:42 +00002080#ifndef YYSTACK_USE_ALLOCA
2081 yyfree_stacks = 1;
2082#endif
2083 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
2084 __yy_memcpy ((char *)yyss, (char *)yyss1,
2085 size * (unsigned int) sizeof (*yyssp));
2086 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
2087 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
2088 size * (unsigned int) sizeof (*yyvsp));
2089#ifdef YYLSP_NEEDED
2090 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
2091 __yy_memcpy ((char *)yyls, (char *)yyls1,
2092 size * (unsigned int) sizeof (*yylsp));
2093#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002094#endif /* no yyoverflow */
2095
Chris Lattner8335e842006-01-23 23:05:42 +00002096 yyssp = yyss + size - 1;
2097 yyvsp = yyvs + size - 1;
2098#ifdef YYLSP_NEEDED
2099 yylsp = yyls + size - 1;
2100#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002101
Chris Lattner8335e842006-01-23 23:05:42 +00002102#if YYDEBUG != 0
2103 if (yydebug)
2104 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2105#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002106
Chris Lattner8335e842006-01-23 23:05:42 +00002107 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002108 YYABORT;
2109 }
2110
Chris Lattner8335e842006-01-23 23:05:42 +00002111#if YYDEBUG != 0
2112 if (yydebug)
2113 fprintf(stderr, "Entering state %d\n", yystate);
2114#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002115
2116 goto yybackup;
Chris Lattner8335e842006-01-23 23:05:42 +00002117 yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002118
2119/* Do appropriate processing given the current state. */
2120/* Read a lookahead token if we need one and don't already have one. */
2121/* yyresume: */
2122
2123 /* First try to decide what to do without reference to lookahead token. */
2124
2125 yyn = yypact[yystate];
Chris Lattner8335e842006-01-23 23:05:42 +00002126 if (yyn == YYFLAG)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002127 goto yydefault;
2128
2129 /* Not known => get a lookahead token if don't already have one. */
2130
Chris Lattner8335e842006-01-23 23:05:42 +00002131 /* yychar is either YYEMPTY or YYEOF
2132 or a valid token in external form. */
2133
Reid Spencer68a24bd2005-08-27 18:50:39 +00002134 if (yychar == YYEMPTY)
2135 {
Chris Lattner8335e842006-01-23 23:05:42 +00002136#if YYDEBUG != 0
2137 if (yydebug)
2138 fprintf(stderr, "Reading a token: ");
2139#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002140 yychar = YYLEX;
2141 }
2142
Chris Lattner8335e842006-01-23 23:05:42 +00002143 /* Convert token to internal form (in yychar1) for indexing tables with */
2144
2145 if (yychar <= 0) /* This means end of input. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002146 {
Chris Lattner8335e842006-01-23 23:05:42 +00002147 yychar1 = 0;
2148 yychar = YYEOF; /* Don't call YYLEX any more */
2149
2150#if YYDEBUG != 0
2151 if (yydebug)
2152 fprintf(stderr, "Now at end of input.\n");
2153#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002154 }
2155 else
2156 {
Chris Lattner8335e842006-01-23 23:05:42 +00002157 yychar1 = YYTRANSLATE(yychar);
2158
2159#if YYDEBUG != 0
2160 if (yydebug)
2161 {
2162 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2163 /* Give the individual parser a way to print the precise meaning
2164 of a token, for further debugging info. */
2165#ifdef YYPRINT
2166 YYPRINT (stderr, yychar, yylval);
2167#endif
2168 fprintf (stderr, ")\n");
2169 }
2170#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002171 }
2172
Chris Lattner8335e842006-01-23 23:05:42 +00002173 yyn += yychar1;
2174 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002175 goto yydefault;
Chris Lattner8335e842006-01-23 23:05:42 +00002176
Reid Spencer68a24bd2005-08-27 18:50:39 +00002177 yyn = yytable[yyn];
Chris Lattner8335e842006-01-23 23:05:42 +00002178
2179 /* yyn is what to do for this token type in this state.
2180 Negative => reduce, -yyn is rule number.
2181 Positive => shift, yyn is new state.
2182 New state is final state => don't bother to shift,
2183 just return success.
2184 0, or most negative number => error. */
2185
2186 if (yyn < 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002187 {
Chris Lattner8335e842006-01-23 23:05:42 +00002188 if (yyn == YYFLAG)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002189 goto yyerrlab;
2190 yyn = -yyn;
2191 goto yyreduce;
2192 }
Chris Lattner8335e842006-01-23 23:05:42 +00002193 else if (yyn == 0)
2194 goto yyerrlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002195
2196 if (yyn == YYFINAL)
2197 YYACCEPT;
2198
2199 /* Shift the lookahead token. */
Chris Lattner8335e842006-01-23 23:05:42 +00002200
2201#if YYDEBUG != 0
2202 if (yydebug)
2203 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2204#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002205
2206 /* Discard the token being shifted unless it is eof. */
2207 if (yychar != YYEOF)
2208 yychar = YYEMPTY;
2209
2210 *++yyvsp = yylval;
Chris Lattner8335e842006-01-23 23:05:42 +00002211#ifdef YYLSP_NEEDED
2212 *++yylsp = yylloc;
2213#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002214
Chris Lattner8335e842006-01-23 23:05:42 +00002215 /* count tokens shifted since error; after three, turn off error status. */
2216 if (yyerrstatus) yyerrstatus--;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002217
2218 yystate = yyn;
2219 goto yynewstate;
2220
Chris Lattner8335e842006-01-23 23:05:42 +00002221/* Do the default action for the current state. */
Reid Spencere812fb22006-01-19 01:21:04 +00002222yydefault:
Chris Lattner8335e842006-01-23 23:05:42 +00002223
Reid Spencer68a24bd2005-08-27 18:50:39 +00002224 yyn = yydefact[yystate];
2225 if (yyn == 0)
2226 goto yyerrlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002227
Chris Lattner8335e842006-01-23 23:05:42 +00002228/* Do a reduction. yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002229yyreduce:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002230 yylen = yyr2[yyn];
Chris Lattner8335e842006-01-23 23:05:42 +00002231 if (yylen > 0)
2232 yyval = yyvsp[1-yylen]; /* implement default value of the action */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002233
Chris Lattner8335e842006-01-23 23:05:42 +00002234#if YYDEBUG != 0
2235 if (yydebug)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002236 {
Chris Lattner8335e842006-01-23 23:05:42 +00002237 int i;
2238
2239 fprintf (stderr, "Reducing via rule %d (line %d), ",
2240 yyn, yyrline[yyn]);
2241
2242 /* Print the symbols being reduced, and their result. */
2243 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2244 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2245 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2246 }
2247#endif
2248
2249
2250 switch (yyn) {
2251
2252case 2:
Chris Lattnerd25db202006-04-08 03:55:17 +00002253#line 1011 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002254{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002255 if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX) // Outside of my range!
2256 ThrowException("Value too large for type!");
2257 yyval.SIntVal = (int32_t)yyvsp[0].UIntVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002258;
2259 break;}
2260case 4:
Chris Lattnerd25db202006-04-08 03:55:17 +00002261#line 1019 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002262{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002263 if (yyvsp[0].UInt64Val > (uint64_t)INT64_MAX) // Outside of my range!
2264 ThrowException("Value too large for type!");
2265 yyval.SInt64Val = (int64_t)yyvsp[0].UInt64Val;
Chris Lattner8335e842006-01-23 23:05:42 +00002266;
2267 break;}
2268case 33:
Chris Lattnerd25db202006-04-08 03:55:17 +00002269#line 1042 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002270{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002271 yyval.StrVal = yyvsp[-1].StrVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002272 ;
2273 break;}
2274case 34:
Chris Lattnerd25db202006-04-08 03:55:17 +00002275#line 1045 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002276{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002277 yyval.StrVal = 0;
Chris Lattner8335e842006-01-23 23:05:42 +00002278 ;
2279 break;}
2280case 35:
Chris Lattnerd25db202006-04-08 03:55:17 +00002281#line 1049 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002282{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2283 break;}
2284case 36:
Chris Lattnerd25db202006-04-08 03:55:17 +00002285#line 1050 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002286{ yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2287 break;}
2288case 37:
Chris Lattnerd25db202006-04-08 03:55:17 +00002289#line 1051 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002290{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2291 break;}
2292case 38:
Chris Lattnerd25db202006-04-08 03:55:17 +00002293#line 1052 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002294{ yyval.Linkage = GlobalValue::AppendingLinkage; ;
2295 break;}
2296case 39:
Chris Lattnerd25db202006-04-08 03:55:17 +00002297#line 1053 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002298{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2299 break;}
2300case 40:
Chris Lattnerd25db202006-04-08 03:55:17 +00002301#line 1055 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002302{ yyval.UIntVal = CallingConv::C; ;
2303 break;}
2304case 41:
Chris Lattnerd25db202006-04-08 03:55:17 +00002305#line 1056 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002306{ yyval.UIntVal = CallingConv::C; ;
2307 break;}
2308case 42:
Chris Lattnerd25db202006-04-08 03:55:17 +00002309#line 1057 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002310{ yyval.UIntVal = CallingConv::Fast; ;
2311 break;}
2312case 43:
Chris Lattnerd25db202006-04-08 03:55:17 +00002313#line 1058 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002314{ yyval.UIntVal = CallingConv::Cold; ;
2315 break;}
2316case 44:
Chris Lattnerd25db202006-04-08 03:55:17 +00002317#line 1059 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002318{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002319 if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
2320 ThrowException("Calling conv too large!");
2321 yyval.UIntVal = yyvsp[0].UInt64Val;
Chris Lattner8335e842006-01-23 23:05:42 +00002322 ;
2323 break;}
2324case 45:
Chris Lattnerd25db202006-04-08 03:55:17 +00002325#line 1067 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002326{ yyval.UIntVal = 0; ;
2327 break;}
2328case 46:
Chris Lattnerd25db202006-04-08 03:55:17 +00002329#line 1068 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002330{
Chris Lattnerb475c422005-11-12 18:22:38 +00002331 yyval.UIntVal = yyvsp[0].UInt64Val;
2332 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
2333 ThrowException("Alignment must be a power of two!");
Chris Lattner8335e842006-01-23 23:05:42 +00002334;
2335 break;}
2336case 47:
Chris Lattnerd25db202006-04-08 03:55:17 +00002337#line 1073 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002338{ yyval.UIntVal = 0; ;
2339 break;}
2340case 48:
Chris Lattnerd25db202006-04-08 03:55:17 +00002341#line 1074 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002342{
Chris Lattnerb475c422005-11-12 18:22:38 +00002343 yyval.UIntVal = yyvsp[0].UInt64Val;
2344 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
2345 ThrowException("Alignment must be a power of two!");
Chris Lattner8335e842006-01-23 23:05:42 +00002346;
2347 break;}
2348case 49:
Chris Lattnerd25db202006-04-08 03:55:17 +00002349#line 1081 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002350{
Chris Lattnere869eef2005-11-12 00:11:49 +00002351 for (unsigned i = 0, e = strlen(yyvsp[0].StrVal); i != e; ++i)
2352 if (yyvsp[0].StrVal[i] == '"' || yyvsp[0].StrVal[i] == '\\')
2353 ThrowException("Invalid character in section name!");
2354 yyval.StrVal = yyvsp[0].StrVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002355;
2356 break;}
2357case 50:
Chris Lattnerd25db202006-04-08 03:55:17 +00002358#line 1088 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002359{ yyval.StrVal = 0; ;
2360 break;}
2361case 51:
Chris Lattnerd25db202006-04-08 03:55:17 +00002362#line 1089 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002363{ yyval.StrVal = yyvsp[0].StrVal; ;
2364 break;}
2365case 52:
Chris Lattnerd25db202006-04-08 03:55:17 +00002366#line 1094 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002367{;
2368 break;}
2369case 53:
Chris Lattnerd25db202006-04-08 03:55:17 +00002370#line 1095 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002371{;
2372 break;}
2373case 54:
Chris Lattnerd25db202006-04-08 03:55:17 +00002374#line 1096 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002375{
Chris Lattnerb475c422005-11-12 18:22:38 +00002376 CurGV->setSection(yyvsp[0].StrVal);
2377 free(yyvsp[0].StrVal);
Chris Lattner8335e842006-01-23 23:05:42 +00002378 ;
2379 break;}
2380case 55:
Chris Lattnerd25db202006-04-08 03:55:17 +00002381#line 1100 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002382{
Chris Lattner7aa61892005-12-21 17:53:23 +00002383 if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val))
2384 ThrowException("Alignment must be a power of two!");
Chris Lattnerb475c422005-11-12 18:22:38 +00002385 CurGV->setAlignment(yyvsp[0].UInt64Val);
Chris Lattner8335e842006-01-23 23:05:42 +00002386 ;
2387 break;}
2388case 57:
Chris Lattnerd25db202006-04-08 03:55:17 +00002389#line 1113 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002390{ yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2391 break;}
2392case 59:
Chris Lattnerd25db202006-04-08 03:55:17 +00002393#line 1114 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002394{ yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2395 break;}
2396case 60:
Chris Lattnerd25db202006-04-08 03:55:17 +00002397#line 1116 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002398{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002399 if (!UpRefs.empty())
2400 ThrowException("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
2401 yyval.TypeVal = yyvsp[0].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002402 ;
2403 break;}
2404case 74:
Chris Lattnerd25db202006-04-08 03:55:17 +00002405#line 1127 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002406{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002407 yyval.TypeVal = new PATypeHolder(OpaqueType::get());
Chris Lattner8335e842006-01-23 23:05:42 +00002408 ;
2409 break;}
2410case 75:
Chris Lattnerd25db202006-04-08 03:55:17 +00002411#line 1130 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002412{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002413 yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
Chris Lattner8335e842006-01-23 23:05:42 +00002414 ;
2415 break;}
2416case 76:
Chris Lattnerd25db202006-04-08 03:55:17 +00002417#line 1133 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002418{ // Named types are also simple types...
Reid Spencer68a24bd2005-08-27 18:50:39 +00002419 yyval.TypeVal = new PATypeHolder(getTypeVal(yyvsp[0].ValIDVal));
Chris Lattner8335e842006-01-23 23:05:42 +00002420;
2421 break;}
2422case 77:
Chris Lattnerd25db202006-04-08 03:55:17 +00002423#line 1139 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002424{ // Type UpReference
Reid Spencer68a24bd2005-08-27 18:50:39 +00002425 if (yyvsp[0].UInt64Val > (uint64_t)~0U) ThrowException("Value out of range!");
2426 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
2427 UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector...
2428 yyval.TypeVal = new PATypeHolder(OT);
2429 UR_OUT("New Upreference!\n");
Chris Lattner8335e842006-01-23 23:05:42 +00002430 ;
2431 break;}
2432case 78:
Chris Lattnerd25db202006-04-08 03:55:17 +00002433#line 1146 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002434{ // Function derived type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002435 std::vector<const Type*> Params;
2436 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2437 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2438 Params.push_back(*I);
2439 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
2440 if (isVarArg) Params.pop_back();
2441
2442 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FunctionType::get(*yyvsp[-3].TypeVal,Params,isVarArg)));
2443 delete yyvsp[-1].TypeList; // Delete the argument list
2444 delete yyvsp[-3].TypeVal; // Delete the return type handle
Chris Lattner8335e842006-01-23 23:05:42 +00002445 ;
2446 break;}
2447case 79:
Chris Lattnerd25db202006-04-08 03:55:17 +00002448#line 1158 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002449{ // Sized array type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002450 yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2451 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002452 ;
2453 break;}
2454case 80:
Chris Lattnerd25db202006-04-08 03:55:17 +00002455#line 1162 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002456{ // Packed array type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002457 const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
Chris Lattner9547d7f2005-11-10 01:42:43 +00002458 if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002459 ThrowException("Unsigned result not equal to signed result");
Chris Lattner9547d7f2005-11-10 01:42:43 +00002460 if (!ElemTy->isPrimitiveType())
Reid Spencer68a24bd2005-08-27 18:50:39 +00002461 ThrowException("Elemental type of a PackedType must be primitive");
Chris Lattner9547d7f2005-11-10 01:42:43 +00002462 if (!isPowerOf2_32(yyvsp[-3].UInt64Val))
2463 ThrowException("Vector length should be a power of 2!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00002464 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PackedType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2465 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002466 ;
2467 break;}
2468case 81:
Chris Lattnerd25db202006-04-08 03:55:17 +00002469#line 1173 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002470{ // Structure type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002471 std::vector<const Type*> Elements;
2472 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2473 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2474 Elements.push_back(*I);
2475
2476 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
2477 delete yyvsp[-1].TypeList;
Chris Lattner8335e842006-01-23 23:05:42 +00002478 ;
2479 break;}
2480case 82:
Chris Lattnerd25db202006-04-08 03:55:17 +00002481#line 1182 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002482{ // Empty structure type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002483 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Chris Lattner8335e842006-01-23 23:05:42 +00002484 ;
2485 break;}
2486case 83:
Chris Lattnerd25db202006-04-08 03:55:17 +00002487#line 1185 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002488{ // Pointer type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002489 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal)));
2490 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002491 ;
2492 break;}
2493case 84:
Chris Lattnerd25db202006-04-08 03:55:17 +00002494#line 1193 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002495{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002496 yyval.TypeList = new std::list<PATypeHolder>();
2497 yyval.TypeList->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002498 ;
2499 break;}
2500case 85:
Chris Lattnerd25db202006-04-08 03:55:17 +00002501#line 1197 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002502{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002503 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002504 ;
2505 break;}
2506case 87:
Chris Lattnerd25db202006-04-08 03:55:17 +00002507#line 1203 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002508{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002509 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(Type::VoidTy);
Chris Lattner8335e842006-01-23 23:05:42 +00002510 ;
2511 break;}
2512case 88:
Chris Lattnerd25db202006-04-08 03:55:17 +00002513#line 1206 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002514{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002515 (yyval.TypeList = new std::list<PATypeHolder>())->push_back(Type::VoidTy);
Chris Lattner8335e842006-01-23 23:05:42 +00002516 ;
2517 break;}
2518case 89:
Chris Lattnerd25db202006-04-08 03:55:17 +00002519#line 1209 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002520{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002521 yyval.TypeList = new std::list<PATypeHolder>();
Chris Lattner8335e842006-01-23 23:05:42 +00002522 ;
2523 break;}
2524case 90:
Chris Lattnerd25db202006-04-08 03:55:17 +00002525#line 1219 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002526{ // Nonempty unsized arr
Reid Spencer68a24bd2005-08-27 18:50:39 +00002527 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
2528 if (ATy == 0)
2529 ThrowException("Cannot make array constant with type: '" +
2530 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2531 const Type *ETy = ATy->getElementType();
2532 int NumElements = ATy->getNumElements();
2533
2534 // Verify that we have the correct size...
2535 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2536 ThrowException("Type mismatch: constant sized array initialized with " +
2537 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
2538 itostr(NumElements) + "!");
2539
2540 // Verify all elements are correct type!
2541 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2542 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2543 ThrowException("Element #" + utostr(i) + " is not of type '" +
2544 ETy->getDescription() +"' as required!\nIt is of type '"+
2545 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2546 }
2547
2548 yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
2549 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Chris Lattner8335e842006-01-23 23:05:42 +00002550 ;
2551 break;}
2552case 91:
Chris Lattnerd25db202006-04-08 03:55:17 +00002553#line 1244 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002554{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002555 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2556 if (ATy == 0)
2557 ThrowException("Cannot make array constant with type: '" +
2558 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2559
2560 int NumElements = ATy->getNumElements();
2561 if (NumElements != -1 && NumElements != 0)
2562 ThrowException("Type mismatch: constant sized array initialized with 0"
2563 " arguments, but has size of " + itostr(NumElements) +"!");
2564 yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
2565 delete yyvsp[-2].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002566 ;
2567 break;}
2568case 92:
Chris Lattnerd25db202006-04-08 03:55:17 +00002569#line 1257 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002570{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002571 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2572 if (ATy == 0)
2573 ThrowException("Cannot make array constant with type: '" +
2574 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2575
2576 int NumElements = ATy->getNumElements();
2577 const Type *ETy = ATy->getElementType();
2578 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
2579 if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal))
2580 ThrowException("Can't build string constant of size " +
2581 itostr((int)(EndStr-yyvsp[0].StrVal)) +
2582 " when array has size " + itostr(NumElements) + "!");
2583 std::vector<Constant*> Vals;
2584 if (ETy == Type::SByteTy) {
Chris Lattner66316012006-01-24 04:14:29 +00002585 for (signed char *C = (signed char *)yyvsp[0].StrVal; C != (signed char *)EndStr; ++C)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002586 Vals.push_back(ConstantSInt::get(ETy, *C));
2587 } else if (ETy == Type::UByteTy) {
Chris Lattner66316012006-01-24 04:14:29 +00002588 for (unsigned char *C = (unsigned char *)yyvsp[0].StrVal;
2589 C != (unsigned char*)EndStr; ++C)
2590 Vals.push_back(ConstantUInt::get(ETy, *C));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002591 } else {
2592 free(yyvsp[0].StrVal);
2593 ThrowException("Cannot build string arrays of non byte sized elements!");
2594 }
2595 free(yyvsp[0].StrVal);
2596 yyval.ConstVal = ConstantArray::get(ATy, Vals);
2597 delete yyvsp[-2].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002598 ;
2599 break;}
2600case 93:
Chris Lattnerd25db202006-04-08 03:55:17 +00002601#line 1286 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002602{ // Nonempty unsized arr
Reid Spencer68a24bd2005-08-27 18:50:39 +00002603 const PackedType *PTy = dyn_cast<PackedType>(yyvsp[-3].TypeVal->get());
2604 if (PTy == 0)
2605 ThrowException("Cannot make packed constant with type: '" +
2606 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2607 const Type *ETy = PTy->getElementType();
2608 int NumElements = PTy->getNumElements();
2609
2610 // Verify that we have the correct size...
2611 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2612 ThrowException("Type mismatch: constant sized packed initialized with " +
2613 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
2614 itostr(NumElements) + "!");
2615
2616 // Verify all elements are correct type!
2617 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2618 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2619 ThrowException("Element #" + utostr(i) + " is not of type '" +
2620 ETy->getDescription() +"' as required!\nIt is of type '"+
2621 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2622 }
2623
2624 yyval.ConstVal = ConstantPacked::get(PTy, *yyvsp[-1].ConstVector);
2625 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Chris Lattner8335e842006-01-23 23:05:42 +00002626 ;
2627 break;}
2628case 94:
Chris Lattnerd25db202006-04-08 03:55:17 +00002629#line 1311 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002630{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002631 const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
2632 if (STy == 0)
2633 ThrowException("Cannot make struct constant with type: '" +
2634 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2635
2636 if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
2637 ThrowException("Illegal number of initializers for structure type!");
2638
2639 // Check to ensure that constants are compatible with the type initializer!
2640 for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
2641 if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
2642 ThrowException("Expected type '" +
2643 STy->getElementType(i)->getDescription() +
2644 "' for element #" + utostr(i) +
2645 " of structure initializer!");
2646
2647 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
2648 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Chris Lattner8335e842006-01-23 23:05:42 +00002649 ;
2650 break;}
2651case 95:
Chris Lattnerd25db202006-04-08 03:55:17 +00002652#line 1331 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002653{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002654 const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
2655 if (STy == 0)
2656 ThrowException("Cannot make struct constant with type: '" +
2657 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2658
2659 if (STy->getNumContainedTypes() != 0)
2660 ThrowException("Illegal number of initializers for structure type!");
2661
2662 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
2663 delete yyvsp[-2].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002664 ;
2665 break;}
2666case 96:
Chris Lattnerd25db202006-04-08 03:55:17 +00002667#line 1343 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002668{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002669 const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
2670 if (PTy == 0)
2671 ThrowException("Cannot make null pointer constant with type: '" +
2672 (*yyvsp[-1].TypeVal)->getDescription() + "'!");
2673
2674 yyval.ConstVal = ConstantPointerNull::get(PTy);
2675 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002676 ;
2677 break;}
2678case 97:
Chris Lattnerd25db202006-04-08 03:55:17 +00002679#line 1352 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002680{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002681 yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
2682 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002683 ;
2684 break;}
2685case 98:
Chris Lattnerd25db202006-04-08 03:55:17 +00002686#line 1356 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002687{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002688 const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
2689 if (Ty == 0)
2690 ThrowException("Global const reference must be a pointer type!");
2691
2692 // ConstExprs can exist in the body of a function, thus creating
2693 // GlobalValues whenever they refer to a variable. Because we are in
2694 // the context of a function, getValNonImprovising will search the functions
2695 // symbol table instead of the module symbol table for the global symbol,
2696 // which throws things all off. To get around this, we just tell
2697 // getValNonImprovising that we are at global scope here.
2698 //
2699 Function *SavedCurFn = CurFun.CurrentFunction;
2700 CurFun.CurrentFunction = 0;
2701
2702 Value *V = getValNonImprovising(Ty, yyvsp[0].ValIDVal);
2703
2704 CurFun.CurrentFunction = SavedCurFn;
2705
2706 // If this is an initializer for a constant pointer, which is referencing a
2707 // (currently) undefined variable, create a stub now that shall be replaced
2708 // in the future with the right type of variable.
2709 //
2710 if (V == 0) {
2711 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
2712 const PointerType *PT = cast<PointerType>(Ty);
2713
2714 // First check to see if the forward references value is already created!
2715 PerModuleInfo::GlobalRefsType::iterator I =
2716 CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
2717
2718 if (I != CurModule.GlobalRefs.end()) {
2719 V = I->second; // Placeholder already exists, use it...
2720 yyvsp[0].ValIDVal.destroy();
2721 } else {
2722 std::string Name;
2723 if (yyvsp[0].ValIDVal.Type == ValID::NameVal) Name = yyvsp[0].ValIDVal.Name;
2724
2725 // Create the forward referenced global.
2726 GlobalValue *GV;
2727 if (const FunctionType *FTy =
2728 dyn_cast<FunctionType>(PT->getElementType())) {
2729 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
2730 CurModule.CurrentModule);
2731 } else {
2732 GV = new GlobalVariable(PT->getElementType(), false,
2733 GlobalValue::ExternalLinkage, 0,
2734 Name, CurModule.CurrentModule);
2735 }
2736
2737 // Keep track of the fact that we have a forward ref to recycle it
2738 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
2739 V = GV;
2740 }
2741 }
2742
2743 yyval.ConstVal = cast<GlobalValue>(V);
2744 delete yyvsp[-1].TypeVal; // Free the type handle
Chris Lattner8335e842006-01-23 23:05:42 +00002745 ;
2746 break;}
2747case 99:
Chris Lattnerd25db202006-04-08 03:55:17 +00002748#line 1415 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002749{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002750 if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
2751 ThrowException("Mismatched types for constant expression!");
2752 yyval.ConstVal = yyvsp[0].ConstVal;
2753 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002754 ;
2755 break;}
2756case 100:
Chris Lattnerd25db202006-04-08 03:55:17 +00002757#line 1421 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002758{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002759 const Type *Ty = yyvsp[-1].TypeVal->get();
2760 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
2761 ThrowException("Cannot create a null initialized value of this type!");
2762 yyval.ConstVal = Constant::getNullValue(Ty);
2763 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002764 ;
2765 break;}
2766case 101:
Chris Lattnerd25db202006-04-08 03:55:17 +00002767#line 1429 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002768{ // integral constants
Reid Spencer68a24bd2005-08-27 18:50:39 +00002769 if (!ConstantSInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
2770 ThrowException("Constant value doesn't fit in type!");
2771 yyval.ConstVal = ConstantSInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val);
Chris Lattner8335e842006-01-23 23:05:42 +00002772 ;
2773 break;}
2774case 102:
Chris Lattnerd25db202006-04-08 03:55:17 +00002775#line 1434 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002776{ // integral constants
Reid Spencer68a24bd2005-08-27 18:50:39 +00002777 if (!ConstantUInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
2778 ThrowException("Constant value doesn't fit in type!");
2779 yyval.ConstVal = ConstantUInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val);
Chris Lattner8335e842006-01-23 23:05:42 +00002780 ;
2781 break;}
2782case 103:
Chris Lattnerd25db202006-04-08 03:55:17 +00002783#line 1439 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002784{ // Boolean constants
Reid Spencer68a24bd2005-08-27 18:50:39 +00002785 yyval.ConstVal = ConstantBool::True;
Chris Lattner8335e842006-01-23 23:05:42 +00002786 ;
2787 break;}
2788case 104:
Chris Lattnerd25db202006-04-08 03:55:17 +00002789#line 1442 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002790{ // Boolean constants
Reid Spencer68a24bd2005-08-27 18:50:39 +00002791 yyval.ConstVal = ConstantBool::False;
Chris Lattner8335e842006-01-23 23:05:42 +00002792 ;
2793 break;}
2794case 105:
Chris Lattnerd25db202006-04-08 03:55:17 +00002795#line 1445 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002796{ // Float & Double constants
Reid Spencer68a24bd2005-08-27 18:50:39 +00002797 if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal))
2798 ThrowException("Floating point constant invalid for type!!");
2799 yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal);
Chris Lattner8335e842006-01-23 23:05:42 +00002800 ;
2801 break;}
2802case 106:
Chris Lattnerd25db202006-04-08 03:55:17 +00002803#line 1452 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002804{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002805 if (!yyvsp[-3].ConstVal->getType()->isFirstClassType())
2806 ThrowException("cast constant expression from a non-primitive type: '" +
2807 yyvsp[-3].ConstVal->getType()->getDescription() + "'!");
2808 if (!yyvsp[-1].TypeVal->get()->isFirstClassType())
2809 ThrowException("cast constant expression to a non-primitive type: '" +
2810 yyvsp[-1].TypeVal->get()->getDescription() + "'!");
2811 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-3].ConstVal, yyvsp[-1].TypeVal->get());
2812 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002813 ;
2814 break;}
2815case 107:
Chris Lattnerd25db202006-04-08 03:55:17 +00002816#line 1462 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002817{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002818 if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
2819 ThrowException("GetElementPtr requires a pointer operand!");
2820
2821 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
2822 // indices to uint struct indices for compatibility.
2823 generic_gep_type_iterator<std::vector<Value*>::iterator>
2824 GTI = gep_type_begin(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end()),
2825 GTE = gep_type_end(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end());
2826 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
2827 if (isa<StructType>(*GTI)) // Only change struct indices
2828 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[-1].ValueList)[i]))
2829 if (CUI->getType() == Type::UByteTy)
2830 (*yyvsp[-1].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
2831
2832 const Type *IdxTy =
2833 GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), *yyvsp[-1].ValueList, true);
2834 if (!IdxTy)
2835 ThrowException("Index list invalid for constant getelementptr!");
2836
2837 std::vector<Constant*> IdxVec;
2838 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
2839 if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
2840 IdxVec.push_back(C);
2841 else
2842 ThrowException("Indices to constant getelementptr must be constants!");
2843
2844 delete yyvsp[-1].ValueList;
2845
2846 yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, IdxVec);
Chris Lattner8335e842006-01-23 23:05:42 +00002847 ;
2848 break;}
2849case 108:
Chris Lattnerd25db202006-04-08 03:55:17 +00002850#line 1493 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002851{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002852 if (yyvsp[-5].ConstVal->getType() != Type::BoolTy)
2853 ThrowException("Select condition must be of boolean type!");
2854 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2855 ThrowException("Select operand types must match!");
2856 yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Chris Lattner8335e842006-01-23 23:05:42 +00002857 ;
2858 break;}
2859case 109:
Chris Lattnerd25db202006-04-08 03:55:17 +00002860#line 1500 "/Users/sabre/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("Binary operator types must match!");
2864 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
2865 // To retain backward compatibility with these early compilers, we emit a
2866 // cast to the appropriate integer type automatically if we are in the
2867 // broken case. See PR424 for more information.
2868 if (!isa<PointerType>(yyvsp[-3].ConstVal->getType())) {
2869 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2870 } else {
2871 const Type *IntPtrTy = 0;
2872 switch (CurModule.CurrentModule->getPointerSize()) {
2873 case Module::Pointer32: IntPtrTy = Type::IntTy; break;
2874 case Module::Pointer64: IntPtrTy = Type::LongTy; break;
2875 default: ThrowException("invalid pointer binary constant expr!");
2876 }
2877 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, ConstantExpr::getCast(yyvsp[-3].ConstVal, IntPtrTy),
2878 ConstantExpr::getCast(yyvsp[-1].ConstVal, IntPtrTy));
2879 yyval.ConstVal = ConstantExpr::getCast(yyval.ConstVal, yyvsp[-3].ConstVal->getType());
2880 }
Chris Lattner8335e842006-01-23 23:05:42 +00002881 ;
2882 break;}
2883case 110:
Chris Lattnerd25db202006-04-08 03:55:17 +00002884#line 1521 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002885{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002886 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2887 ThrowException("Logical operator types must match!");
Chris Lattner524a1312005-12-21 18:31:50 +00002888 if (!yyvsp[-3].ConstVal->getType()->isIntegral()) {
2889 if (!isa<PackedType>(yyvsp[-3].ConstVal->getType()) ||
2890 !cast<PackedType>(yyvsp[-3].ConstVal->getType())->getElementType()->isIntegral())
2891 ThrowException("Logical operator requires integral operands!");
2892 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002893 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Chris Lattner8335e842006-01-23 23:05:42 +00002894 ;
2895 break;}
2896case 111:
Chris Lattnerd25db202006-04-08 03:55:17 +00002897#line 1531 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002898{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002899 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2900 ThrowException("setcc operand types must match!");
2901 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Chris Lattner8335e842006-01-23 23:05:42 +00002902 ;
2903 break;}
2904case 112:
Chris Lattnerd25db202006-04-08 03:55:17 +00002905#line 1536 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002906{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002907 if (yyvsp[-1].ConstVal->getType() != Type::UByteTy)
2908 ThrowException("Shift count for shift constant must be unsigned byte!");
2909 if (!yyvsp[-3].ConstVal->getType()->isInteger())
2910 ThrowException("Shift constant expression requires integer operand!");
2911 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].OtherOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Chris Lattner8335e842006-01-23 23:05:42 +00002912 ;
2913 break;}
2914case 113:
Chris Lattnerd25db202006-04-08 03:55:17 +00002915#line 1543 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002916{
Robert Bocchino9c62b562006-01-10 19:04:32 +00002917 if (!isa<PackedType>(yyvsp[-3].ConstVal->getType()))
2918 ThrowException("First operand of extractelement must be "
2919 "packed type!");
2920 if (yyvsp[-1].ConstVal->getType() != Type::UIntTy)
2921 ThrowException("Second operand of extractelement must be uint!");
2922 yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Chris Lattner8335e842006-01-23 23:05:42 +00002923 ;
2924 break;}
2925case 114:
Chris Lattnerd25db202006-04-08 03:55:17 +00002926#line 1551 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2927{
2928 yyval.ConstVal = ConstantExpr::getInsertElement(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2929 ;
2930 break;}
2931case 115:
2932#line 1554 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2933{
2934 if (!ShuffleVectorInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
2935 ThrowException("Invalid shufflevector operands!");
2936 yyval.ConstVal = ConstantExpr::getShuffleVector(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2937 ;
2938 break;}
2939case 116:
2940#line 1562 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002941{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002942 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
Chris Lattner8335e842006-01-23 23:05:42 +00002943 ;
2944 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00002945case 117:
2946#line 1565 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002947{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002948 yyval.ConstVector = new std::vector<Constant*>();
2949 yyval.ConstVector->push_back(yyvsp[0].ConstVal);
Chris Lattner8335e842006-01-23 23:05:42 +00002950 ;
2951 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00002952case 118:
2953#line 1572 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002954{ yyval.BoolVal = false; ;
2955 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00002956case 119:
2957#line 1572 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002958{ yyval.BoolVal = true; ;
2959 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00002960case 120:
2961#line 1582 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002962{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002963 yyval.ModuleVal = ParserResult = yyvsp[0].ModuleVal;
2964 CurModule.ModuleDone();
Chris Lattner8335e842006-01-23 23:05:42 +00002965;
2966 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00002967case 121:
2968#line 1589 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002969{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002970 yyval.ModuleVal = yyvsp[-1].ModuleVal;
2971 CurFun.FunctionDone();
Chris Lattner8335e842006-01-23 23:05:42 +00002972 ;
2973 break;}
Chris Lattner8335e842006-01-23 23:05:42 +00002974case 122:
Chris Lattnerd25db202006-04-08 03:55:17 +00002975#line 1593 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002976{
Robert Bocchino9c62b562006-01-10 19:04:32 +00002977 yyval.ModuleVal = yyvsp[-1].ModuleVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002978 ;
2979 break;}
2980case 123:
Chris Lattnerd25db202006-04-08 03:55:17 +00002981#line 1596 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2982{
2983 yyval.ModuleVal = yyvsp[-3].ModuleVal;
2984 ;
2985 break;}
2986case 124:
2987#line 1599 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2988{
2989 yyval.ModuleVal = yyvsp[-1].ModuleVal;
2990 ;
2991 break;}
2992case 125:
2993#line 1602 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002994{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002995 yyval.ModuleVal = CurModule.CurrentModule;
2996 // Emit an error if there are any unresolved types left.
2997 if (!CurModule.LateResolveTypes.empty()) {
2998 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
2999 if (DID.Type == ValID::NameVal)
3000 ThrowException("Reference to an undefined type: '"+DID.getName() + "'");
3001 else
3002 ThrowException("Reference to an undefined type: #" + itostr(DID.Num));
3003 }
Chris Lattner8335e842006-01-23 23:05:42 +00003004 ;
3005 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003006case 126:
3007#line 1615 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003008{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003009 // Eagerly resolve types. This is not an optimization, this is a
3010 // requirement that is due to the fact that we could have this:
3011 //
3012 // %list = type { %list * }
3013 // %list = type { %list * } ; repeated type decl
3014 //
3015 // If types are not resolved eagerly, then the two types will not be
3016 // determined to be the same type!
3017 //
3018 ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
3019
3020 if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
3021 // If this is a named type that is not a redefinition, add it to the slot
3022 // table.
3023 CurModule.Types.push_back(*yyvsp[0].TypeVal);
3024 }
3025
3026 delete yyvsp[0].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003027 ;
3028 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003029case 127:
3030#line 1635 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003031{ // Function prototypes can be in const pool
3032 ;
3033 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003034case 128:
3035#line 1637 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner66316012006-01-24 04:14:29 +00003036{ // Asm blocks can be in the const pool
Chris Lattner8335e842006-01-23 23:05:42 +00003037 ;
3038 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003039case 129:
3040#line 1639 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003041{
Chris Lattnerb475c422005-11-12 18:22:38 +00003042 if (yyvsp[0].ConstVal == 0) ThrowException("Global value initializer is not a constant!");
3043 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 +00003044 ;
3045 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003046case 130:
3047#line 1642 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003048{
Chris Lattnerb475c422005-11-12 18:22:38 +00003049 CurGV = 0;
Chris Lattner8335e842006-01-23 23:05:42 +00003050 ;
3051 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003052case 131:
3053#line 1645 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003054{
Chris Lattnerb475c422005-11-12 18:22:38 +00003055 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalLinkage,
3056 yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0);
3057 delete yyvsp[0].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003058 ;
3059 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003060case 132:
3061#line 1649 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003062{
Chris Lattnerb475c422005-11-12 18:22:38 +00003063 CurGV = 0;
Chris Lattner8335e842006-01-23 23:05:42 +00003064 ;
3065 break;}
Chris Lattner8335e842006-01-23 23:05:42 +00003066case 133:
Chris Lattnerd25db202006-04-08 03:55:17 +00003067#line 1652 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003068{
3069 ;
3070 break;}
3071case 134:
Chris Lattnerd25db202006-04-08 03:55:17 +00003072#line 1654 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3073{
3074 ;
3075 break;}
3076case 135:
3077#line 1656 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3078{
3079 ;
3080 break;}
3081case 136:
3082#line 1660 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003083{
Chris Lattner66316012006-01-24 04:14:29 +00003084 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
3085 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
3086 std::string NewAsm(yyvsp[0].StrVal, EndStr);
Chris Lattner8335e842006-01-23 23:05:42 +00003087 free(yyvsp[0].StrVal);
Chris Lattner66316012006-01-24 04:14:29 +00003088
3089 if (AsmSoFar.empty())
3090 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
3091 else
3092 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Chris Lattner8335e842006-01-23 23:05:42 +00003093;
3094 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003095case 137:
3096#line 1672 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003097{ yyval.Endianness = Module::BigEndian; ;
3098 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003099case 138:
3100#line 1673 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003101{ yyval.Endianness = Module::LittleEndian; ;
3102 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003103case 139:
3104#line 1675 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003105{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003106 CurModule.CurrentModule->setEndianness(yyvsp[0].Endianness);
Chris Lattner8335e842006-01-23 23:05:42 +00003107 ;
3108 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003109case 140:
3110#line 1678 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003111{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003112 if (yyvsp[0].UInt64Val == 32)
3113 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
3114 else if (yyvsp[0].UInt64Val == 64)
3115 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
3116 else
3117 ThrowException("Invalid pointer size: '" + utostr(yyvsp[0].UInt64Val) + "'!");
Chris Lattner8335e842006-01-23 23:05:42 +00003118 ;
3119 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003120case 141:
3121#line 1686 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003122{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003123 CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal);
3124 free(yyvsp[0].StrVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003125 ;
3126 break;}
Chris Lattner66316012006-01-24 04:14:29 +00003127case 143:
Chris Lattnerd25db202006-04-08 03:55:17 +00003128#line 1693 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3129{
3130 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3131 free(yyvsp[0].StrVal);
3132 ;
3133 break;}
3134case 144:
3135#line 1697 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3136{
3137 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3138 free(yyvsp[0].StrVal);
3139 ;
3140 break;}
3141case 145:
3142#line 1701 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner66316012006-01-24 04:14:29 +00003143{
Chris Lattner8335e842006-01-23 23:05:42 +00003144 ;
3145 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003146case 149:
3147#line 1710 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003148{ yyval.StrVal = 0; ;
3149 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003150case 150:
3151#line 1712 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003152{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003153 if (*yyvsp[-1].TypeVal == Type::VoidTy)
3154 ThrowException("void typed arguments are invalid!");
3155 yyval.ArgVal = new std::pair<PATypeHolder*, char*>(yyvsp[-1].TypeVal, yyvsp[0].StrVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003156;
3157 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003158case 151:
3159#line 1718 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003160{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003161 yyval.ArgList = yyvsp[-2].ArgList;
3162 yyvsp[-2].ArgList->push_back(*yyvsp[0].ArgVal);
3163 delete yyvsp[0].ArgVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003164 ;
3165 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003166case 152:
3167#line 1723 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003168{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003169 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
3170 yyval.ArgList->push_back(*yyvsp[0].ArgVal);
3171 delete yyvsp[0].ArgVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003172 ;
3173 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003174case 153:
3175#line 1729 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003176{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003177 yyval.ArgList = yyvsp[0].ArgList;
Chris Lattner8335e842006-01-23 23:05:42 +00003178 ;
3179 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003180case 154:
3181#line 1732 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003182{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003183 yyval.ArgList = yyvsp[-2].ArgList;
3184 yyval.ArgList->push_back(std::pair<PATypeHolder*,
3185 char*>(new PATypeHolder(Type::VoidTy), 0));
Chris Lattner8335e842006-01-23 23:05:42 +00003186 ;
3187 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003188case 155:
3189#line 1737 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003190{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003191 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
3192 yyval.ArgList->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0));
Chris Lattner8335e842006-01-23 23:05:42 +00003193 ;
3194 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003195case 156:
3196#line 1741 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003197{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003198 yyval.ArgList = 0;
Chris Lattner8335e842006-01-23 23:05:42 +00003199 ;
3200 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003201case 157:
3202#line 1746 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003203{
Chris Lattnere869eef2005-11-12 00:11:49 +00003204 UnEscapeLexed(yyvsp[-5].StrVal);
3205 std::string FunctionName(yyvsp[-5].StrVal);
3206 free(yyvsp[-5].StrVal); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00003207
Chris Lattnere869eef2005-11-12 00:11:49 +00003208 if (!(*yyvsp[-6].TypeVal)->isFirstClassType() && *yyvsp[-6].TypeVal != Type::VoidTy)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003209 ThrowException("LLVM functions cannot return aggregate types!");
3210
3211 std::vector<const Type*> ParamTypeList;
Chris Lattnere869eef2005-11-12 00:11:49 +00003212 if (yyvsp[-3].ArgList) { // If there are arguments...
3213 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-3].ArgList->begin();
3214 I != yyvsp[-3].ArgList->end(); ++I)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003215 ParamTypeList.push_back(I->first->get());
3216 }
3217
3218 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
3219 if (isVarArg) ParamTypeList.pop_back();
3220
Chris Lattnere869eef2005-11-12 00:11:49 +00003221 const FunctionType *FT = FunctionType::get(*yyvsp[-6].TypeVal, ParamTypeList, isVarArg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003222 const PointerType *PFT = PointerType::get(FT);
Chris Lattnere869eef2005-11-12 00:11:49 +00003223 delete yyvsp[-6].TypeVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003224
3225 ValID ID;
3226 if (!FunctionName.empty()) {
3227 ID = ValID::create((char*)FunctionName.c_str());
3228 } else {
3229 ID = ValID::create((int)CurModule.Values[PFT].size());
3230 }
3231
3232 Function *Fn = 0;
3233 // See if this function was forward referenced. If so, recycle the object.
3234 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
3235 // Move the function to the end of the list, from whereever it was
3236 // previously inserted.
3237 Fn = cast<Function>(FWRef);
3238 CurModule.CurrentModule->getFunctionList().remove(Fn);
3239 CurModule.CurrentModule->getFunctionList().push_back(Fn);
3240 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
3241 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
3242 // If this is the case, either we need to be a forward decl, or it needs
3243 // to be.
3244 if (!CurFun.isDeclare && !Fn->isExternal())
3245 ThrowException("Redefinition of function '" + FunctionName + "'!");
3246
3247 // Make sure to strip off any argument names so we can't get conflicts.
3248 if (Fn->isExternal())
3249 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
3250 AI != AE; ++AI)
3251 AI->setName("");
3252
3253 } else { // Not already defined?
3254 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
3255 CurModule.CurrentModule);
3256 InsertValue(Fn, CurModule.Values);
3257 }
3258
3259 CurFun.FunctionStart(Fn);
Chris Lattnere869eef2005-11-12 00:11:49 +00003260 Fn->setCallingConv(yyvsp[-7].UIntVal);
Chris Lattner0019bbe2005-11-06 06:46:53 +00003261 Fn->setAlignment(yyvsp[0].UIntVal);
Chris Lattnere869eef2005-11-12 00:11:49 +00003262 if (yyvsp[-1].StrVal) {
3263 Fn->setSection(yyvsp[-1].StrVal);
3264 free(yyvsp[-1].StrVal);
3265 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00003266
3267 // Add all of the arguments we parsed to the function...
Chris Lattnere869eef2005-11-12 00:11:49 +00003268 if (yyvsp[-3].ArgList) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00003269 if (isVarArg) { // Nuke the last entry
Chris Lattnere869eef2005-11-12 00:11:49 +00003270 assert(yyvsp[-3].ArgList->back().first->get() == Type::VoidTy && yyvsp[-3].ArgList->back().second == 0&&
Reid Spencer68a24bd2005-08-27 18:50:39 +00003271 "Not a varargs marker!");
Chris Lattnere869eef2005-11-12 00:11:49 +00003272 delete yyvsp[-3].ArgList->back().first;
3273 yyvsp[-3].ArgList->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00003274 }
3275 Function::arg_iterator ArgIt = Fn->arg_begin();
Chris Lattnere869eef2005-11-12 00:11:49 +00003276 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-3].ArgList->begin();
3277 I != yyvsp[-3].ArgList->end(); ++I, ++ArgIt) {
Reid Spencer68a24bd2005-08-27 18:50:39 +00003278 delete I->first; // Delete the typeholder...
3279
3280 setValueName(ArgIt, I->second); // Insert arg into symtab...
3281 InsertValue(ArgIt);
3282 }
3283
Chris Lattnere869eef2005-11-12 00:11:49 +00003284 delete yyvsp[-3].ArgList; // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00003285 }
Chris Lattner8335e842006-01-23 23:05:42 +00003286;
3287 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003288case 160:
3289#line 1833 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003290{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003291 yyval.FunctionVal = CurFun.CurrentFunction;
3292
3293 // Make sure that we keep track of the linkage type even if there was a
3294 // previous "declare".
3295 yyval.FunctionVal->setLinkage(yyvsp[-2].Linkage);
Chris Lattner8335e842006-01-23 23:05:42 +00003296;
3297 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003298case 163:
3299#line 1843 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003300{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003301 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003302;
3303 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003304case 164:
3305#line 1847 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003306{ CurFun.isDeclare = true; ;
3307 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003308case 165:
3309#line 1847 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003310{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003311 yyval.FunctionVal = CurFun.CurrentFunction;
3312 CurFun.FunctionDone();
Chris Lattner8335e842006-01-23 23:05:42 +00003313;
3314 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003315case 166:
3316#line 1856 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner0e9c3762006-01-25 22:27:16 +00003317{
3318 yyval.BoolVal = false;
3319 ;
3320 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003321case 167:
3322#line 1859 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner0e9c3762006-01-25 22:27:16 +00003323{
3324 yyval.BoolVal = true;
3325 ;
3326 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003327case 168:
3328#line 1863 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003329{ // A reference to a direct constant
Reid Spencer68a24bd2005-08-27 18:50:39 +00003330 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
Chris Lattner8335e842006-01-23 23:05:42 +00003331 ;
3332 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003333case 169:
3334#line 1866 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003335{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003336 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
Chris Lattner8335e842006-01-23 23:05:42 +00003337 ;
3338 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003339case 170:
3340#line 1869 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003341{ // Perhaps it's an FP constant?
Reid Spencer68a24bd2005-08-27 18:50:39 +00003342 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003343 ;
3344 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003345case 171:
3346#line 1872 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003347{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003348 yyval.ValIDVal = ValID::create(ConstantBool::True);
Chris Lattner8335e842006-01-23 23:05:42 +00003349 ;
3350 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003351case 172:
3352#line 1875 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003353{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003354 yyval.ValIDVal = ValID::create(ConstantBool::False);
Chris Lattner8335e842006-01-23 23:05:42 +00003355 ;
3356 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003357case 173:
3358#line 1878 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003359{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003360 yyval.ValIDVal = ValID::createNull();
Chris Lattner8335e842006-01-23 23:05:42 +00003361 ;
3362 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003363case 174:
3364#line 1881 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003365{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003366 yyval.ValIDVal = ValID::createUndef();
Chris Lattner8335e842006-01-23 23:05:42 +00003367 ;
3368 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003369case 175:
3370#line 1884 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003371{ // A vector zero constant.
Chris Lattner7aa61892005-12-21 17:53:23 +00003372 yyval.ValIDVal = ValID::createZeroInit();
Chris Lattner8335e842006-01-23 23:05:42 +00003373 ;
3374 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003375case 176:
3376#line 1887 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003377{ // Nonempty unsized packed vector
Reid Spencer68a24bd2005-08-27 18:50:39 +00003378 const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
3379 int NumElements = yyvsp[-1].ConstVector->size();
3380
3381 PackedType* pt = PackedType::get(ETy, NumElements);
3382 PATypeHolder* PTy = new PATypeHolder(
3383 HandleUpRefs(
3384 PackedType::get(
3385 ETy,
3386 NumElements)
3387 )
3388 );
3389
3390 // Verify all elements are correct type!
3391 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3392 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
3393 ThrowException("Element #" + utostr(i) + " is not of type '" +
3394 ETy->getDescription() +"' as required!\nIt is of type '" +
3395 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
3396 }
3397
3398 yyval.ValIDVal = ValID::create(ConstantPacked::get(pt, *yyvsp[-1].ConstVector));
3399 delete PTy; delete yyvsp[-1].ConstVector;
Chris Lattner8335e842006-01-23 23:05:42 +00003400 ;
3401 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003402case 177:
3403#line 1911 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003404{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003405 yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003406 ;
3407 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003408case 178:
3409#line 1914 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner0e9c3762006-01-25 22:27:16 +00003410{
3411 char *End = UnEscapeLexed(yyvsp[-2].StrVal, true);
3412 std::string AsmStr = std::string(yyvsp[-2].StrVal, End);
3413 End = UnEscapeLexed(yyvsp[0].StrVal, true);
3414 std::string Constraints = std::string(yyvsp[0].StrVal, End);
3415 yyval.ValIDVal = ValID::createInlineAsm(AsmStr, Constraints, yyvsp[-3].BoolVal);
3416 free(yyvsp[-2].StrVal);
3417 free(yyvsp[0].StrVal);
3418 ;
3419 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003420case 179:
3421#line 1927 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003422{ // Is it an integer reference...?
Reid Spencer68a24bd2005-08-27 18:50:39 +00003423 yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003424 ;
3425 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003426case 180:
3427#line 1930 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003428{ // Is it a named reference...?
Reid Spencer68a24bd2005-08-27 18:50:39 +00003429 yyval.ValIDVal = ValID::create(yyvsp[0].StrVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003430 ;
3431 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003432case 183:
3433#line 1941 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003434{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003435 yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003436 ;
3437 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003438case 184:
3439#line 1945 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003440{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003441 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003442 ;
3443 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003444case 185:
3445#line 1948 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003446{ // Do not allow functions with 0 basic blocks
Reid Spencer68a24bd2005-08-27 18:50:39 +00003447 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003448 ;
3449 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003450case 186:
3451#line 1956 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003452{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003453 setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
3454 InsertValue(yyvsp[0].TermInstVal);
3455
3456 yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
3457 InsertValue(yyvsp[-2].BasicBlockVal);
3458 yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003459 ;
3460 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003461case 187:
3462#line 1965 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003463{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003464 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
3465 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003466 ;
3467 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003468case 188:
3469#line 1969 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003470{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003471 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
3472
3473 // Make sure to move the basic block to the correct location in the
3474 // function, instead of leaving it inserted wherever it was first
3475 // referenced.
3476 Function::BasicBlockListType &BBL =
3477 CurFun.CurrentFunction->getBasicBlockList();
3478 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003479 ;
3480 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003481case 189:
3482#line 1979 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003483{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003484 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create(yyvsp[0].StrVal), true);
3485
3486 // Make sure to move the basic block to the correct location in the
3487 // function, instead of leaving it inserted wherever it was first
3488 // referenced.
3489 Function::BasicBlockListType &BBL =
3490 CurFun.CurrentFunction->getBasicBlockList();
3491 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003492 ;
3493 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003494case 190:
3495#line 1990 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003496{ // Return with a result...
Reid Spencer68a24bd2005-08-27 18:50:39 +00003497 yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003498 ;
3499 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003500case 191:
3501#line 1993 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003502{ // Return with no result...
Reid Spencer68a24bd2005-08-27 18:50:39 +00003503 yyval.TermInstVal = new ReturnInst();
Chris Lattner8335e842006-01-23 23:05:42 +00003504 ;
3505 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003506case 192:
3507#line 1996 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003508{ // Unconditional Branch...
Reid Spencer68a24bd2005-08-27 18:50:39 +00003509 yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[0].ValIDVal));
Chris Lattner8335e842006-01-23 23:05:42 +00003510 ;
3511 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003512case 193:
3513#line 1999 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003514{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003515 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 +00003516 ;
3517 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003518case 194:
3519#line 2002 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003520{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003521 SwitchInst *S = new SwitchInst(getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal), getBBVal(yyvsp[-3].ValIDVal), yyvsp[-1].JumpTable->size());
3522 yyval.TermInstVal = S;
3523
3524 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
3525 E = yyvsp[-1].JumpTable->end();
3526 for (; I != E; ++I) {
3527 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
3528 S->addCase(CI, I->second);
3529 else
3530 ThrowException("Switch case is constant, but not a simple integer!");
3531 }
3532 delete yyvsp[-1].JumpTable;
Chris Lattner8335e842006-01-23 23:05:42 +00003533 ;
3534 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003535case 195:
3536#line 2016 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003537{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003538 SwitchInst *S = new SwitchInst(getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal), getBBVal(yyvsp[-2].ValIDVal), 0);
3539 yyval.TermInstVal = S;
Chris Lattner8335e842006-01-23 23:05:42 +00003540 ;
3541 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003542case 196:
3543#line 2021 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003544{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003545 const PointerType *PFTy;
3546 const FunctionType *Ty;
3547
3548 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-10].TypeVal->get())) ||
3549 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3550 // Pull out the types of all of the arguments...
3551 std::vector<const Type*> ParamTypes;
3552 if (yyvsp[-7].ValueList) {
3553 for (std::vector<Value*>::iterator I = yyvsp[-7].ValueList->begin(), E = yyvsp[-7].ValueList->end();
3554 I != E; ++I)
3555 ParamTypes.push_back((*I)->getType());
3556 }
3557
3558 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3559 if (isVarArg) ParamTypes.pop_back();
3560
3561 Ty = FunctionType::get(yyvsp[-10].TypeVal->get(), ParamTypes, isVarArg);
3562 PFTy = PointerType::get(Ty);
3563 }
3564
3565 Value *V = getVal(PFTy, yyvsp[-9].ValIDVal); // Get the function we're calling...
3566
3567 BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
3568 BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
3569
3570 // Create the call node...
3571 if (!yyvsp[-7].ValueList) { // Has no arguments?
3572 yyval.TermInstVal = new InvokeInst(V, Normal, Except, std::vector<Value*>());
3573 } else { // Has arguments?
3574 // Loop through FunctionType's arguments and ensure they are specified
3575 // correctly!
3576 //
3577 FunctionType::param_iterator I = Ty->param_begin();
3578 FunctionType::param_iterator E = Ty->param_end();
3579 std::vector<Value*>::iterator ArgI = yyvsp[-7].ValueList->begin(), ArgE = yyvsp[-7].ValueList->end();
3580
3581 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3582 if ((*ArgI)->getType() != *I)
3583 ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
3584 (*I)->getDescription() + "'!");
3585
3586 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
3587 ThrowException("Invalid number of parameters detected!");
3588
3589 yyval.TermInstVal = new InvokeInst(V, Normal, Except, *yyvsp[-7].ValueList);
3590 }
3591 cast<InvokeInst>(yyval.TermInstVal)->setCallingConv(yyvsp[-11].UIntVal);
3592
3593 delete yyvsp[-10].TypeVal;
3594 delete yyvsp[-7].ValueList;
Chris Lattner8335e842006-01-23 23:05:42 +00003595 ;
3596 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003597case 197:
3598#line 2073 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003599{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003600 yyval.TermInstVal = new UnwindInst();
Chris Lattner8335e842006-01-23 23:05:42 +00003601 ;
3602 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003603case 198:
3604#line 2076 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003605{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003606 yyval.TermInstVal = new UnreachableInst();
Chris Lattner8335e842006-01-23 23:05:42 +00003607 ;
3608 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003609case 199:
3610#line 2082 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003611{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003612 yyval.JumpTable = yyvsp[-5].JumpTable;
3613 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
3614 if (V == 0)
3615 ThrowException("May only switch on a constant pool value!");
3616
3617 yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
Chris Lattner8335e842006-01-23 23:05:42 +00003618 ;
3619 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003620case 200:
3621#line 2090 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003622{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003623 yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
3624 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
3625
3626 if (V == 0)
3627 ThrowException("May only switch on a constant pool value!");
3628
3629 yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
Chris Lattner8335e842006-01-23 23:05:42 +00003630 ;
3631 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003632case 201:
3633#line 2100 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003634{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003635 // Is this definition named?? if so, assign the name...
3636 setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
3637 InsertValue(yyvsp[0].InstVal);
3638 yyval.InstVal = yyvsp[0].InstVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003639;
3640 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003641case 202:
3642#line 2107 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003643{ // Used for PHI nodes
Reid Spencer68a24bd2005-08-27 18:50:39 +00003644 yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
3645 yyval.PHIList->push_back(std::make_pair(getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal), getBBVal(yyvsp[-1].ValIDVal)));
3646 delete yyvsp[-5].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003647 ;
3648 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003649case 203:
3650#line 2112 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003651{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003652 yyval.PHIList = yyvsp[-6].PHIList;
3653 yyvsp[-6].PHIList->push_back(std::make_pair(getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal),
3654 getBBVal(yyvsp[-1].ValIDVal)));
Chris Lattner8335e842006-01-23 23:05:42 +00003655 ;
3656 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003657case 204:
3658#line 2119 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003659{ // Used for call statements, and memory insts...
Reid Spencer68a24bd2005-08-27 18:50:39 +00003660 yyval.ValueList = new std::vector<Value*>();
3661 yyval.ValueList->push_back(yyvsp[0].ValueVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003662 ;
3663 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003664case 205:
3665#line 2123 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003666{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003667 yyval.ValueList = yyvsp[-2].ValueList;
3668 yyvsp[-2].ValueList->push_back(yyvsp[0].ValueVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003669 ;
3670 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003671case 207:
3672#line 2129 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003673{ yyval.ValueList = 0; ;
3674 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003675case 208:
3676#line 2131 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003677{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003678 yyval.BoolVal = true;
Chris Lattner8335e842006-01-23 23:05:42 +00003679 ;
3680 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003681case 209:
3682#line 2134 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003683{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003684 yyval.BoolVal = false;
Chris Lattner8335e842006-01-23 23:05:42 +00003685 ;
3686 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003687case 210:
3688#line 2140 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003689{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003690 if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
3691 !isa<PackedType>((*yyvsp[-3].TypeVal).get()))
3692 ThrowException(
3693 "Arithmetic operator requires integer, FP, or packed operands!");
3694 if (isa<PackedType>((*yyvsp[-3].TypeVal).get()) && yyvsp[-4].BinaryOpVal == Instruction::Rem)
3695 ThrowException("Rem not supported on packed types!");
3696 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3697 if (yyval.InstVal == 0)
3698 ThrowException("binary operator returned null!");
3699 delete yyvsp[-3].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003700 ;
3701 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003702case 211:
3703#line 2152 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003704{
Chris Lattner524a1312005-12-21 18:31:50 +00003705 if (!(*yyvsp[-3].TypeVal)->isIntegral()) {
3706 if (!isa<PackedType>(yyvsp[-3].TypeVal->get()) ||
3707 !cast<PackedType>(yyvsp[-3].TypeVal->get())->getElementType()->isIntegral())
3708 ThrowException("Logical operator requires integral operands!");
3709 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00003710 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3711 if (yyval.InstVal == 0)
3712 ThrowException("binary operator returned null!");
3713 delete yyvsp[-3].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003714 ;
3715 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003716case 212:
3717#line 2163 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003718{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003719 if(isa<PackedType>((*yyvsp[-3].TypeVal).get())) {
3720 ThrowException(
3721 "PackedTypes currently not supported in setcc instructions!");
3722 }
3723 yyval.InstVal = new SetCondInst(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3724 if (yyval.InstVal == 0)
3725 ThrowException("binary operator returned null!");
3726 delete yyvsp[-3].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003727 ;
3728 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003729case 213:
3730#line 2173 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003731{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003732 std::cerr << "WARNING: Use of eliminated 'not' instruction:"
3733 << " Replacing with 'xor'.\n";
3734
3735 Value *Ones = ConstantIntegral::getAllOnesValue(yyvsp[0].ValueVal->getType());
3736 if (Ones == 0)
3737 ThrowException("Expected integral type for not instruction!");
3738
3739 yyval.InstVal = BinaryOperator::create(Instruction::Xor, yyvsp[0].ValueVal, Ones);
3740 if (yyval.InstVal == 0)
3741 ThrowException("Could not create a xor instruction!");
Chris Lattner8335e842006-01-23 23:05:42 +00003742 ;
3743 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003744case 214:
3745#line 2185 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003746{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003747 if (yyvsp[0].ValueVal->getType() != Type::UByteTy)
3748 ThrowException("Shift amount must be ubyte!");
3749 if (!yyvsp[-2].ValueVal->getType()->isInteger())
3750 ThrowException("Shift constant expression requires integer operand!");
3751 yyval.InstVal = new ShiftInst(yyvsp[-3].OtherOpVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003752 ;
3753 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003754case 215:
3755#line 2192 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003756{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003757 if (!yyvsp[0].TypeVal->get()->isFirstClassType())
3758 ThrowException("cast instruction to a non-primitive type: '" +
3759 yyvsp[0].TypeVal->get()->getDescription() + "'!");
3760 yyval.InstVal = new CastInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
3761 delete yyvsp[0].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003762 ;
3763 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003764case 216:
3765#line 2199 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003766{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003767 if (yyvsp[-4].ValueVal->getType() != Type::BoolTy)
3768 ThrowException("select condition must be boolean!");
3769 if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
3770 ThrowException("select value types should match!");
3771 yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003772 ;
3773 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003774case 217:
3775#line 2206 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003776{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003777 NewVarArgs = true;
3778 yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
3779 delete yyvsp[0].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003780 ;
3781 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003782case 218:
3783#line 2211 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003784{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003785 ObsoleteVarArgs = true;
3786 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
3787 Function* NF = CurModule.CurrentModule->
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003788 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003789
3790 //b = vaarg a, t ->
3791 //foo = alloca 1 of t
3792 //bar = vacopy a
3793 //store bar -> foo
3794 //b = vaarg foo, t
3795 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
3796 CurBB->getInstList().push_back(foo);
3797 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
3798 CurBB->getInstList().push_back(bar);
3799 CurBB->getInstList().push_back(new StoreInst(bar, foo));
3800 yyval.InstVal = new VAArgInst(foo, *yyvsp[0].TypeVal);
3801 delete yyvsp[0].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003802 ;
3803 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003804case 219:
3805#line 2230 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003806{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003807 ObsoleteVarArgs = true;
3808 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
3809 Function* NF = CurModule.CurrentModule->
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003810 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003811
3812 //b = vanext a, t ->
3813 //foo = alloca 1 of t
3814 //bar = vacopy a
3815 //store bar -> foo
3816 //tmp = vaarg foo, t
3817 //b = load foo
3818 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
3819 CurBB->getInstList().push_back(foo);
3820 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
3821 CurBB->getInstList().push_back(bar);
3822 CurBB->getInstList().push_back(new StoreInst(bar, foo));
3823 Instruction* tmp = new VAArgInst(foo, *yyvsp[0].TypeVal);
3824 CurBB->getInstList().push_back(tmp);
3825 yyval.InstVal = new LoadInst(foo);
3826 delete yyvsp[0].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003827 ;
3828 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003829case 220:
3830#line 2252 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003831{
Robert Bocchino9c62b562006-01-10 19:04:32 +00003832 if (!isa<PackedType>(yyvsp[-2].ValueVal->getType()))
Robert Bocchino2def1b32006-01-17 20:06:25 +00003833 ThrowException("First operand of extractelement must be "
3834 "packed type!");
Robert Bocchino9c62b562006-01-10 19:04:32 +00003835 if (yyvsp[0].ValueVal->getType() != Type::UIntTy)
Robert Bocchino2def1b32006-01-17 20:06:25 +00003836 ThrowException("Second operand of extractelement must be uint!");
Robert Bocchino9c62b562006-01-10 19:04:32 +00003837 yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003838 ;
3839 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003840case 221:
3841#line 2260 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003842{
Robert Bocchino2def1b32006-01-17 20:06:25 +00003843 if (!isa<PackedType>(yyvsp[-4].ValueVal->getType()))
3844 ThrowException("First operand of insertelement must be "
3845 "packed type!");
3846 if (yyvsp[-2].ValueVal->getType() !=
3847 cast<PackedType>(yyvsp[-4].ValueVal->getType())->getElementType())
3848 ThrowException("Second operand of insertelement must be "
3849 "packed element type!");
3850 if (yyvsp[0].ValueVal->getType() != Type::UIntTy)
3851 ThrowException("Third operand of insertelement must be uint!");
3852 yyval.InstVal = new InsertElementInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003853 ;
3854 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003855case 222:
3856#line 2272 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerd5efe842006-04-08 01:18:56 +00003857{
Chris Lattnerd25db202006-04-08 03:55:17 +00003858 if (!ShuffleVectorInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
3859 ThrowException("Invalid shufflevector operands!");
Chris Lattnerd5efe842006-04-08 01:18:56 +00003860 yyval.InstVal = new ShuffleVectorInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
3861 ;
3862 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003863case 223:
3864#line 2277 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003865{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003866 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
3867 if (!Ty->isFirstClassType())
3868 ThrowException("PHI node operands must be of first class type!");
3869 yyval.InstVal = new PHINode(Ty);
3870 ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
3871 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
3872 if (yyvsp[0].PHIList->front().first->getType() != Ty)
3873 ThrowException("All elements of a PHI node must be of the same type!");
3874 cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
3875 yyvsp[0].PHIList->pop_front();
3876 }
3877 delete yyvsp[0].PHIList; // Free the list...
Chris Lattner8335e842006-01-23 23:05:42 +00003878 ;
3879 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003880case 224:
3881#line 2291 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003882{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003883 const PointerType *PFTy;
3884 const FunctionType *Ty;
3885
3886 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-4].TypeVal->get())) ||
3887 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3888 // Pull out the types of all of the arguments...
3889 std::vector<const Type*> ParamTypes;
3890 if (yyvsp[-1].ValueList) {
3891 for (std::vector<Value*>::iterator I = yyvsp[-1].ValueList->begin(), E = yyvsp[-1].ValueList->end();
3892 I != E; ++I)
3893 ParamTypes.push_back((*I)->getType());
3894 }
3895
3896 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3897 if (isVarArg) ParamTypes.pop_back();
3898
3899 if (!(*yyvsp[-4].TypeVal)->isFirstClassType() && *yyvsp[-4].TypeVal != Type::VoidTy)
3900 ThrowException("LLVM functions cannot return aggregate types!");
3901
3902 Ty = FunctionType::get(yyvsp[-4].TypeVal->get(), ParamTypes, isVarArg);
3903 PFTy = PointerType::get(Ty);
3904 }
3905
3906 Value *V = getVal(PFTy, yyvsp[-3].ValIDVal); // Get the function we're calling...
3907
3908 // Create the call node...
3909 if (!yyvsp[-1].ValueList) { // Has no arguments?
3910 // Make sure no arguments is a good thing!
3911 if (Ty->getNumParams() != 0)
3912 ThrowException("No arguments passed to a function that "
3913 "expects arguments!");
3914
3915 yyval.InstVal = new CallInst(V, std::vector<Value*>());
3916 } else { // Has arguments?
3917 // Loop through FunctionType's arguments and ensure they are specified
3918 // correctly!
3919 //
3920 FunctionType::param_iterator I = Ty->param_begin();
3921 FunctionType::param_iterator E = Ty->param_end();
3922 std::vector<Value*>::iterator ArgI = yyvsp[-1].ValueList->begin(), ArgE = yyvsp[-1].ValueList->end();
3923
3924 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3925 if ((*ArgI)->getType() != *I)
3926 ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
3927 (*I)->getDescription() + "'!");
3928
3929 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
3930 ThrowException("Invalid number of parameters detected!");
3931
3932 yyval.InstVal = new CallInst(V, *yyvsp[-1].ValueList);
3933 }
3934 cast<CallInst>(yyval.InstVal)->setTailCall(yyvsp[-6].BoolVal);
3935 cast<CallInst>(yyval.InstVal)->setCallingConv(yyvsp[-5].UIntVal);
3936 delete yyvsp[-4].TypeVal;
3937 delete yyvsp[-1].ValueList;
Chris Lattner8335e842006-01-23 23:05:42 +00003938 ;
3939 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003940case 225:
3941#line 2348 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003942{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003943 yyval.InstVal = yyvsp[0].InstVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003944 ;
3945 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003946case 226:
3947#line 2354 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003948{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003949 yyval.ValueList = yyvsp[0].ValueList;
Chris Lattner8335e842006-01-23 23:05:42 +00003950 ;
3951 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003952case 227:
3953#line 2356 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003954{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003955 yyval.ValueList = new std::vector<Value*>();
Chris Lattner8335e842006-01-23 23:05:42 +00003956 ;
3957 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003958case 228:
3959#line 2360 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003960{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003961 yyval.BoolVal = true;
Chris Lattner8335e842006-01-23 23:05:42 +00003962 ;
3963 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003964case 229:
3965#line 2363 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003966{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003967 yyval.BoolVal = false;
Chris Lattner8335e842006-01-23 23:05:42 +00003968 ;
3969 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003970case 230:
3971#line 2369 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003972{
Chris Lattner7d09ab62005-11-06 06:34:34 +00003973 yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
3974 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003975 ;
3976 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003977case 231:
3978#line 2373 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003979{
Chris Lattner7d09ab62005-11-06 06:34:34 +00003980 yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal);
3981 delete yyvsp[-4].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003982 ;
3983 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003984case 232:
3985#line 2377 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003986{
Chris Lattner7d09ab62005-11-06 06:34:34 +00003987 yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
3988 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003989 ;
3990 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003991case 233:
3992#line 2381 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003993{
Chris Lattner7d09ab62005-11-06 06:34:34 +00003994 yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal);
3995 delete yyvsp[-4].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003996 ;
3997 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003998case 234:
3999#line 2385 "/Users/sabre/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[0].ValueVal->getType()))
4002 ThrowException("Trying to free nonpointer type " +
4003 yyvsp[0].ValueVal->getType()->getDescription() + "!");
4004 yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
Chris Lattner8335e842006-01-23 23:05:42 +00004005 ;
4006 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00004007case 235:
4008#line 2392 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00004009{
Reid Spencer68a24bd2005-08-27 18:50:39 +00004010 if (!isa<PointerType>(yyvsp[-1].TypeVal->get()))
4011 ThrowException("Can't load from nonpointer type: " +
4012 (*yyvsp[-1].TypeVal)->getDescription());
4013 if (!cast<PointerType>(yyvsp[-1].TypeVal->get())->getElementType()->isFirstClassType())
4014 ThrowException("Can't load from pointer of non-first-class type: " +
4015 (*yyvsp[-1].TypeVal)->getDescription());
4016 yyval.InstVal = new LoadInst(getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), "", yyvsp[-3].BoolVal);
4017 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00004018 ;
4019 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00004020case 236:
4021#line 2402 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00004022{
Reid Spencer68a24bd2005-08-27 18:50:39 +00004023 const PointerType *PT = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
4024 if (!PT)
4025 ThrowException("Can't store to a nonpointer type: " +
4026 (*yyvsp[-1].TypeVal)->getDescription());
4027 const Type *ElTy = PT->getElementType();
4028 if (ElTy != yyvsp[-3].ValueVal->getType())
4029 ThrowException("Can't store '" + yyvsp[-3].ValueVal->getType()->getDescription() +
4030 "' into space of type '" + ElTy->getDescription() + "'!");
4031
4032 yyval.InstVal = new StoreInst(yyvsp[-3].ValueVal, getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), yyvsp[-5].BoolVal);
4033 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00004034 ;
4035 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00004036case 237:
4037#line 2415 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00004038{
Reid Spencer68a24bd2005-08-27 18:50:39 +00004039 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
4040 ThrowException("getelementptr insn requires pointer operand!");
4041
4042 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
4043 // indices to uint struct indices for compatibility.
4044 generic_gep_type_iterator<std::vector<Value*>::iterator>
4045 GTI = gep_type_begin(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end()),
4046 GTE = gep_type_end(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end());
4047 for (unsigned i = 0, e = yyvsp[0].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
4048 if (isa<StructType>(*GTI)) // Only change struct indices
4049 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[0].ValueList)[i]))
4050 if (CUI->getType() == Type::UByteTy)
4051 (*yyvsp[0].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
4052
4053 if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, *yyvsp[0].ValueList, true))
4054 ThrowException("Invalid getelementptr indices for type '" +
4055 (*yyvsp[-2].TypeVal)->getDescription()+ "'!");
4056 yyval.InstVal = new GetElementPtrInst(getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal), *yyvsp[0].ValueList);
4057 delete yyvsp[-2].TypeVal; delete yyvsp[0].ValueList;
Chris Lattner8335e842006-01-23 23:05:42 +00004058 ;
4059 break;}
4060}
4061 /* the action file gets copied in in place of this dollarsign */
4062#line 543 "/usr/share/bison.simple"
Reid Spencer68a24bd2005-08-27 18:50:39 +00004063
4064 yyvsp -= yylen;
4065 yyssp -= yylen;
Chris Lattner8335e842006-01-23 23:05:42 +00004066#ifdef YYLSP_NEEDED
4067 yylsp -= yylen;
4068#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00004069
Chris Lattner8335e842006-01-23 23:05:42 +00004070#if YYDEBUG != 0
4071 if (yydebug)
4072 {
4073 short *ssp1 = yyss - 1;
4074 fprintf (stderr, "state stack now");
4075 while (ssp1 != yyssp)
4076 fprintf (stderr, " %d", *++ssp1);
4077 fprintf (stderr, "\n");
4078 }
4079#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00004080
4081 *++yyvsp = yyval;
4082
Chris Lattner8335e842006-01-23 23:05:42 +00004083#ifdef YYLSP_NEEDED
4084 yylsp++;
4085 if (yylen == 0)
4086 {
4087 yylsp->first_line = yylloc.first_line;
4088 yylsp->first_column = yylloc.first_column;
4089 yylsp->last_line = (yylsp-1)->last_line;
4090 yylsp->last_column = (yylsp-1)->last_column;
4091 yylsp->text = 0;
4092 }
4093 else
4094 {
4095 yylsp->last_line = (yylsp+yylen-1)->last_line;
4096 yylsp->last_column = (yylsp+yylen-1)->last_column;
4097 }
4098#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00004099
Chris Lattner8335e842006-01-23 23:05:42 +00004100 /* Now "shift" the result of the reduction.
4101 Determine what state that goes to,
4102 based on the state we popped back to
4103 and the rule number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004104
4105 yyn = yyr1[yyn];
4106
Chris Lattner8335e842006-01-23 23:05:42 +00004107 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
4108 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004109 yystate = yytable[yystate];
4110 else
Chris Lattner8335e842006-01-23 23:05:42 +00004111 yystate = yydefgoto[yyn - YYNTBASE];
Reid Spencer68a24bd2005-08-27 18:50:39 +00004112
4113 goto yynewstate;
4114
Chris Lattner8335e842006-01-23 23:05:42 +00004115yyerrlab: /* here on detecting error */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004116
Chris Lattner8335e842006-01-23 23:05:42 +00004117 if (! yyerrstatus)
4118 /* If not already recovering from an error, report this error. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004119 {
4120 ++yynerrs;
Chris Lattner8335e842006-01-23 23:05:42 +00004121
4122#ifdef YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00004123 yyn = yypact[yystate];
4124
Chris Lattner8335e842006-01-23 23:05:42 +00004125 if (yyn > YYFLAG && yyn < YYLAST)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004126 {
Chris Lattner8335e842006-01-23 23:05:42 +00004127 int size = 0;
4128 char *msg;
4129 int x, count;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004130
Chris Lattner8335e842006-01-23 23:05:42 +00004131 count = 0;
4132 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
4133 for (x = (yyn < 0 ? -yyn : 0);
4134 x < (sizeof(yytname) / sizeof(char *)); x++)
4135 if (yycheck[x + yyn] == x)
4136 size += strlen(yytname[x]) + 15, count++;
4137 msg = (char *) malloc(size + 15);
4138 if (msg != 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004139 {
Chris Lattner8335e842006-01-23 23:05:42 +00004140 strcpy(msg, "parse error");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004141
Chris Lattner8335e842006-01-23 23:05:42 +00004142 if (count < 5)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004143 {
Chris Lattner8335e842006-01-23 23:05:42 +00004144 count = 0;
4145 for (x = (yyn < 0 ? -yyn : 0);
4146 x < (sizeof(yytname) / sizeof(char *)); x++)
4147 if (yycheck[x + yyn] == x)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004148 {
Chris Lattner8335e842006-01-23 23:05:42 +00004149 strcat(msg, count == 0 ? ", expecting `" : " or `");
4150 strcat(msg, yytname[x]);
4151 strcat(msg, "'");
4152 count++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004153 }
4154 }
Chris Lattner8335e842006-01-23 23:05:42 +00004155 yyerror(msg);
4156 free(msg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004157 }
4158 else
Chris Lattner8335e842006-01-23 23:05:42 +00004159 yyerror ("parse error; also virtual memory exceeded");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004160 }
4161 else
4162#endif /* YYERROR_VERBOSE */
Chris Lattner8335e842006-01-23 23:05:42 +00004163 yyerror("parse error");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004164 }
4165
Chris Lattner8335e842006-01-23 23:05:42 +00004166 goto yyerrlab1;
4167yyerrlab1: /* here on error raised explicitly by an action */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004168
4169 if (yyerrstatus == 3)
4170 {
Chris Lattner8335e842006-01-23 23:05:42 +00004171 /* if just tried and failed to reuse lookahead token after an error, discard it. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004172
Chris Lattner8335e842006-01-23 23:05:42 +00004173 /* return failure if at end of input */
4174 if (yychar == YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004175 YYABORT;
4176
Chris Lattner8335e842006-01-23 23:05:42 +00004177#if YYDEBUG != 0
4178 if (yydebug)
4179 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
4180#endif
4181
4182 yychar = YYEMPTY;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004183 }
4184
Chris Lattner8335e842006-01-23 23:05:42 +00004185 /* Else will try to reuse lookahead token
4186 after shifting the error token. */
4187
4188 yyerrstatus = 3; /* Each real token shifted decrements this */
4189
4190 goto yyerrhandle;
4191
4192yyerrdefault: /* current state does not do anything special for the error token. */
4193
4194#if 0
4195 /* This is wrong; only states that explicitly want error tokens
4196 should shift them. */
4197 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
4198 if (yyn) goto yydefault;
4199#endif
4200
4201yyerrpop: /* pop the current state because it cannot handle the error token */
4202
4203 if (yyssp == yyss) YYABORT;
4204 yyvsp--;
4205 yystate = *--yyssp;
4206#ifdef YYLSP_NEEDED
4207 yylsp--;
4208#endif
4209
4210#if YYDEBUG != 0
4211 if (yydebug)
4212 {
4213 short *ssp1 = yyss - 1;
4214 fprintf (stderr, "Error: state stack now");
4215 while (ssp1 != yyssp)
4216 fprintf (stderr, " %d", *++ssp1);
4217 fprintf (stderr, "\n");
4218 }
4219#endif
4220
4221yyerrhandle:
4222
4223 yyn = yypact[yystate];
4224 if (yyn == YYFLAG)
4225 goto yyerrdefault;
4226
4227 yyn += YYTERROR;
4228 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
4229 goto yyerrdefault;
4230
4231 yyn = yytable[yyn];
4232 if (yyn < 0)
4233 {
4234 if (yyn == YYFLAG)
4235 goto yyerrpop;
4236 yyn = -yyn;
4237 goto yyreduce;
4238 }
4239 else if (yyn == 0)
4240 goto yyerrpop;
4241
Reid Spencer68a24bd2005-08-27 18:50:39 +00004242 if (yyn == YYFINAL)
4243 YYACCEPT;
4244
Chris Lattner8335e842006-01-23 23:05:42 +00004245#if YYDEBUG != 0
4246 if (yydebug)
4247 fprintf(stderr, "Shifting error token, ");
4248#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00004249
4250 *++yyvsp = yylval;
Chris Lattner8335e842006-01-23 23:05:42 +00004251#ifdef YYLSP_NEEDED
4252 *++yylsp = yylloc;
4253#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00004254
4255 yystate = yyn;
4256 goto yynewstate;
4257
Chris Lattner8335e842006-01-23 23:05:42 +00004258 yyacceptlab:
4259 /* YYACCEPT comes here. */
4260 if (yyfree_stacks)
4261 {
4262 free (yyss);
4263 free (yyvs);
4264#ifdef YYLSP_NEEDED
4265 free (yyls);
Reid Spencer0b118202006-01-16 21:12:35 +00004266#endif
Chris Lattner8335e842006-01-23 23:05:42 +00004267 }
4268 return 0;
Reid Spencere812fb22006-01-19 01:21:04 +00004269
Chris Lattner8335e842006-01-23 23:05:42 +00004270 yyabortlab:
4271 /* YYABORT comes here. */
4272 if (yyfree_stacks)
4273 {
4274 free (yyss);
4275 free (yyvs);
4276#ifdef YYLSP_NEEDED
4277 free (yyls);
Reid Spencere812fb22006-01-19 01:21:04 +00004278#endif
Chris Lattner8335e842006-01-23 23:05:42 +00004279 }
4280 return 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004281}
Chris Lattnerd25db202006-04-08 03:55:17 +00004282#line 2438 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00004283
4284int yyerror(const char *ErrorMsg) {
4285 std::string where
4286 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
4287 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
4288 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
4289 if (yychar == YYEMPTY || yychar == 0)
4290 errMsg += "end-of-file.";
4291 else
4292 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
4293 ThrowException(errMsg);
4294 return 0;
4295}