blob: 87f9c5f89853b59fd80901d1486c3ee16b9c79d0 [file] [log] [blame]
Reid Spencer68a24bd2005-08-27 18:50:39 +00001
Chris Lattner0ad19702006-06-21 16:53:00 +00002/* A Bison parser, made from /Volumes/ProjectsDisk/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
Chris Lattner75466192006-05-19 21:28:53 +000074#define CSRETCC_TOK 317
75#define FASTCC_TOK 318
76#define COLDCC_TOK 319
77#define RET 320
78#define BR 321
79#define SWITCH 322
80#define INVOKE 323
81#define UNWIND 324
82#define UNREACHABLE 325
83#define ADD 326
84#define SUB 327
85#define MUL 328
86#define DIV 329
87#define REM 330
88#define AND 331
89#define OR 332
90#define XOR 333
91#define SETLE 334
92#define SETGE 335
93#define SETLT 336
94#define SETGT 337
95#define SETEQ 338
96#define SETNE 339
97#define MALLOC 340
98#define ALLOCA 341
99#define FREE 342
100#define LOAD 343
101#define STORE 344
102#define GETELEMENTPTR 345
103#define PHI_TOK 346
104#define CAST 347
105#define SELECT 348
106#define SHL 349
107#define SHR 350
108#define VAARG 351
109#define EXTRACTELEMENT 352
110#define INSERTELEMENT 353
111#define SHUFFLEVECTOR 354
112#define VAARG_old 355
113#define VANEXT_old 356
Reid Spencer68a24bd2005-08-27 18:50:39 +0000114
Chris Lattner0ad19702006-06-21 16:53:00 +0000115#line 14 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000116
117#include "ParserInternals.h"
118#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000119#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000120#include "llvm/Instructions.h"
121#include "llvm/Module.h"
122#include "llvm/SymbolTable.h"
Reid Spencer0b118202006-01-16 21:12:35 +0000123#include "llvm/Assembly/AutoUpgrade.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000124#include "llvm/Support/GetElementPtrTypeIterator.h"
125#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000126#include "llvm/Support/MathExtras.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000127#include <algorithm>
128#include <iostream>
129#include <list>
130#include <utility>
131
132int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
133int yylex(); // declaration" of xxx warnings.
134int yyparse();
135
136namespace llvm {
137 std::string CurFilename;
138}
139using namespace llvm;
140
141static Module *ParserResult;
142
143// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
144// relating to upreferences in the input stream.
145//
146//#define DEBUG_UPREFS 1
147#ifdef DEBUG_UPREFS
148#define UR_OUT(X) std::cerr << X
149#else
150#define UR_OUT(X)
151#endif
152
153#define YYERROR_VERBOSE 1
154
155static bool ObsoleteVarArgs;
156static bool NewVarArgs;
Chris Lattnerb475c422005-11-12 18:22:38 +0000157static BasicBlock *CurBB;
158static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000159
160
161// This contains info used when building the body of a function. It is
162// destroyed when the function is completed.
163//
164typedef std::vector<Value *> ValueList; // Numbered defs
165static void
166ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
167 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
168
169static struct PerModuleInfo {
170 Module *CurrentModule;
171 std::map<const Type *, ValueList> Values; // Module level numbered definitions
172 std::map<const Type *,ValueList> LateResolveValues;
173 std::vector<PATypeHolder> Types;
174 std::map<ValID, PATypeHolder> LateResolveTypes;
175
176 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000177 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000178 /// that we can resolve them later and print error messages as appropriate.
179 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
180
181 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
182 // references to global values. Global values may be referenced before they
183 // are defined, and if so, the temporary object that they represent is held
184 // here. This is used for forward references of GlobalValues.
185 //
186 typedef std::map<std::pair<const PointerType *,
187 ValID>, GlobalValue*> GlobalRefsType;
188 GlobalRefsType GlobalRefs;
189
190 void ModuleDone() {
191 // If we could not resolve some functions at function compilation time
192 // (calls to functions before they are defined), resolve them now... Types
193 // are resolved when the constant pool has been completely parsed.
194 //
195 ResolveDefinitions(LateResolveValues);
196
197 // Check to make sure that all global value forward references have been
198 // resolved!
199 //
200 if (!GlobalRefs.empty()) {
201 std::string UndefinedReferences = "Unresolved global references exist:\n";
202
203 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
204 I != E; ++I) {
205 UndefinedReferences += " " + I->first.first->getDescription() + " " +
206 I->first.second.getName() + "\n";
207 }
208 ThrowException(UndefinedReferences);
209 }
210
Reid Spencere812fb22006-01-19 01:21:04 +0000211 // Look for intrinsic functions and CallInst that need to be upgraded
Chris Lattnerd5efe842006-04-08 01:18:56 +0000212 for (Module::iterator FI = CurrentModule->begin(),
213 FE = CurrentModule->end(); FI != FE; )
Chris Lattnerc2c60382006-03-04 07:53:41 +0000214 UpgradeCallsToIntrinsic(FI++);
Reid Spencer0b118202006-01-16 21:12:35 +0000215
Reid Spencer68a24bd2005-08-27 18:50:39 +0000216 Values.clear(); // Clear out function local definitions
217 Types.clear();
218 CurrentModule = 0;
219 }
220
Reid Spencer68a24bd2005-08-27 18:50:39 +0000221 // GetForwardRefForGlobal - Check to see if there is a forward reference
222 // for this global. If so, remove it from the GlobalRefs map and return it.
223 // If not, just return null.
224 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
225 // Check to see if there is a forward reference to this global variable...
226 // if there is, eliminate it and patch the reference to use the new def'n.
227 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
228 GlobalValue *Ret = 0;
229 if (I != GlobalRefs.end()) {
230 Ret = I->second;
231 GlobalRefs.erase(I);
232 }
233 return Ret;
234 }
235} CurModule;
236
237static struct PerFunctionInfo {
238 Function *CurrentFunction; // Pointer to current function being created
239
240 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
241 std::map<const Type*, ValueList> LateResolveValues;
242 bool isDeclare; // Is this function a forward declararation?
243
244 /// BBForwardRefs - When we see forward references to basic blocks, keep
245 /// track of them here.
246 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
247 std::vector<BasicBlock*> NumberedBlocks;
248 unsigned NextBBNum;
249
250 inline PerFunctionInfo() {
251 CurrentFunction = 0;
252 isDeclare = false;
253 }
254
255 inline void FunctionStart(Function *M) {
256 CurrentFunction = M;
257 NextBBNum = 0;
258 }
259
260 void FunctionDone() {
261 NumberedBlocks.clear();
262
263 // Any forward referenced blocks left?
264 if (!BBForwardRefs.empty())
265 ThrowException("Undefined reference to label " +
266 BBForwardRefs.begin()->first->getName());
267
268 // Resolve all forward references now.
269 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
270
271 Values.clear(); // Clear out function local definitions
272 CurrentFunction = 0;
273 isDeclare = false;
274 }
275} CurFun; // Info for the current function...
276
277static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
278
279
280//===----------------------------------------------------------------------===//
281// Code to handle definitions of all the types
282//===----------------------------------------------------------------------===//
283
284static int InsertValue(Value *V,
285 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
286 if (V->hasName()) return -1; // Is this a numbered definition?
287
288 // Yes, insert the value into the value table...
289 ValueList &List = ValueTab[V->getType()];
290 List.push_back(V);
291 return List.size()-1;
292}
293
294static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
295 switch (D.Type) {
296 case ValID::NumberVal: // Is it a numbered definition?
297 // Module constants occupy the lowest numbered slots...
298 if ((unsigned)D.Num < CurModule.Types.size())
299 return CurModule.Types[(unsigned)D.Num];
300 break;
301 case ValID::NameVal: // Is it a named definition?
302 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
303 D.destroy(); // Free old strdup'd memory...
304 return N;
305 }
306 break;
307 default:
308 ThrowException("Internal parser error: Invalid symbol type reference!");
309 }
310
311 // If we reached here, we referenced either a symbol that we don't know about
312 // or an id number that hasn't been read yet. We may be referencing something
313 // forward, so just create an entry to be resolved later and get to it...
314 //
315 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
316
317
318 if (inFunctionScope()) {
319 if (D.Type == ValID::NameVal)
320 ThrowException("Reference to an undefined type: '" + D.getName() + "'");
321 else
322 ThrowException("Reference to an undefined type: #" + itostr(D.Num));
323 }
324
325 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
326 if (I != CurModule.LateResolveTypes.end())
327 return I->second;
328
329 Type *Typ = OpaqueType::get();
330 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
331 return Typ;
332 }
333
334static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
335 SymbolTable &SymTab =
336 inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() :
337 CurModule.CurrentModule->getSymbolTable();
338 return SymTab.lookup(Ty, Name);
339}
340
341// getValNonImprovising - Look up the value specified by the provided type and
342// the provided ValID. If the value exists and has already been defined, return
343// it. Otherwise return null.
344//
345static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
346 if (isa<FunctionType>(Ty))
347 ThrowException("Functions are not values and "
348 "must be referenced as pointers");
349
350 switch (D.Type) {
351 case ValID::NumberVal: { // Is it a numbered definition?
352 unsigned Num = (unsigned)D.Num;
353
354 // Module constants occupy the lowest numbered slots...
355 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
356 if (VI != CurModule.Values.end()) {
357 if (Num < VI->second.size())
358 return VI->second[Num];
359 Num -= VI->second.size();
360 }
361
362 // Make sure that our type is within bounds
363 VI = CurFun.Values.find(Ty);
364 if (VI == CurFun.Values.end()) return 0;
365
366 // Check that the number is within bounds...
367 if (VI->second.size() <= Num) return 0;
368
369 return VI->second[Num];
370 }
371
372 case ValID::NameVal: { // Is it a named definition?
373 Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
374 if (N == 0) return 0;
375
376 D.destroy(); // Free old strdup'd memory...
377 return N;
378 }
379
380 // Check to make sure that "Ty" is an integral type, and that our
381 // value will fit into the specified type...
382 case ValID::ConstSIntVal: // Is it a constant pool reference??
383 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64))
384 ThrowException("Signed integral constant '" +
385 itostr(D.ConstPool64) + "' is invalid for type '" +
386 Ty->getDescription() + "'!");
387 return ConstantSInt::get(Ty, D.ConstPool64);
388
389 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
390 if (!ConstantUInt::isValueValidForType(Ty, D.UConstPool64)) {
391 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) {
392 ThrowException("Integral constant '" + utostr(D.UConstPool64) +
393 "' is invalid or out of range!");
394 } else { // This is really a signed reference. Transmogrify.
395 return ConstantSInt::get(Ty, D.ConstPool64);
396 }
397 } else {
398 return ConstantUInt::get(Ty, D.UConstPool64);
399 }
400
401 case ValID::ConstFPVal: // Is it a floating point const pool reference?
402 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
403 ThrowException("FP constant invalid for type!!");
404 return ConstantFP::get(Ty, D.ConstPoolFP);
405
406 case ValID::ConstNullVal: // Is it a null value?
407 if (!isa<PointerType>(Ty))
408 ThrowException("Cannot create a a non pointer null!");
409 return ConstantPointerNull::get(cast<PointerType>(Ty));
410
411 case ValID::ConstUndefVal: // Is it an undef value?
412 return UndefValue::get(Ty);
413
Chris Lattner7aa61892005-12-21 17:53:23 +0000414 case ValID::ConstZeroVal: // Is it a zero value?
415 return Constant::getNullValue(Ty);
416
Reid Spencer68a24bd2005-08-27 18:50:39 +0000417 case ValID::ConstantVal: // Fully resolved constant?
418 if (D.ConstantValue->getType() != Ty)
419 ThrowException("Constant expression type different from required type!");
420 return D.ConstantValue;
421
Chris Lattner0e9c3762006-01-25 22:27:16 +0000422 case ValID::InlineAsmVal: { // Inline asm expression
423 const PointerType *PTy = dyn_cast<PointerType>(Ty);
424 const FunctionType *FTy =
425 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
426 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints))
427 ThrowException("Invalid type for asm constraint string!");
428 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
429 D.IAD->HasSideEffects);
430 D.destroy(); // Free InlineAsmDescriptor.
431 return IA;
432 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000433 default:
434 assert(0 && "Unhandled case!");
435 return 0;
436 } // End of switch
437
438 assert(0 && "Unhandled case!");
439 return 0;
440}
441
442// getVal - This function is identical to getValNonImprovising, except that if a
443// value is not already defined, it "improvises" by creating a placeholder var
444// that looks and acts just like the requested variable. When the value is
445// defined later, all uses of the placeholder variable are replaced with the
446// real thing.
447//
448static Value *getVal(const Type *Ty, const ValID &ID) {
449 if (Ty == Type::LabelTy)
450 ThrowException("Cannot use a basic block here");
451
452 // See if the value has already been defined.
453 Value *V = getValNonImprovising(Ty, ID);
454 if (V) return V;
455
456 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
457 ThrowException("Invalid use of a composite type!");
458
459 // If we reached here, we referenced either a symbol that we don't know about
460 // or an id number that hasn't been read yet. We may be referencing something
461 // forward, so just create an entry to be resolved later and get to it...
462 //
463 V = new Argument(Ty);
464
465 // Remember where this forward reference came from. FIXME, shouldn't we try
466 // to recycle these things??
467 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
468 llvmAsmlineno)));
469
470 if (inFunctionScope())
471 InsertValue(V, CurFun.LateResolveValues);
472 else
473 InsertValue(V, CurModule.LateResolveValues);
474 return V;
475}
476
477/// getBBVal - This is used for two purposes:
478/// * If isDefinition is true, a new basic block with the specified ID is being
479/// defined.
480/// * If isDefinition is true, this is a reference to a basic block, which may
481/// or may not be a forward reference.
482///
483static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
484 assert(inFunctionScope() && "Can't get basic block at global scope!");
485
486 std::string Name;
487 BasicBlock *BB = 0;
488 switch (ID.Type) {
489 default: ThrowException("Illegal label reference " + ID.getName());
490 case ValID::NumberVal: // Is it a numbered definition?
491 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
492 CurFun.NumberedBlocks.resize(ID.Num+1);
493 BB = CurFun.NumberedBlocks[ID.Num];
494 break;
495 case ValID::NameVal: // Is it a named definition?
496 Name = ID.Name;
497 if (Value *N = CurFun.CurrentFunction->
498 getSymbolTable().lookup(Type::LabelTy, Name))
499 BB = cast<BasicBlock>(N);
500 break;
501 }
502
503 // See if the block has already been defined.
504 if (BB) {
505 // If this is the definition of the block, make sure the existing value was
506 // just a forward reference. If it was a forward reference, there will be
507 // an entry for it in the PlaceHolderInfo map.
508 if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
509 // The existing value was a definition, not a forward reference.
510 ThrowException("Redefinition of label " + ID.getName());
511
512 ID.destroy(); // Free strdup'd memory.
513 return BB;
514 }
515
516 // Otherwise this block has not been seen before.
517 BB = new BasicBlock("", CurFun.CurrentFunction);
518 if (ID.Type == ValID::NameVal) {
519 BB->setName(ID.Name);
520 } else {
521 CurFun.NumberedBlocks[ID.Num] = BB;
522 }
523
524 // If this is not a definition, keep track of it so we can use it as a forward
525 // reference.
526 if (!isDefinition) {
527 // Remember where this forward reference came from.
528 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
529 } else {
530 // The forward declaration could have been inserted anywhere in the
531 // function: insert it into the correct place now.
532 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
533 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
534 }
535 ID.destroy();
536 return BB;
537}
538
539
540//===----------------------------------------------------------------------===//
541// Code to handle forward references in instructions
542//===----------------------------------------------------------------------===//
543//
544// This code handles the late binding needed with statements that reference
545// values not defined yet... for example, a forward branch, or the PHI node for
546// a loop body.
547//
548// This keeps a table (CurFun.LateResolveValues) of all such forward references
549// and back patchs after we are done.
550//
551
552// ResolveDefinitions - If we could not resolve some defs at parsing
553// time (forward branches, phi functions for loops, etc...) resolve the
554// defs now...
555//
556static void
557ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
558 std::map<const Type*,ValueList> *FutureLateResolvers) {
559 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
560 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
561 E = LateResolvers.end(); LRI != E; ++LRI) {
562 ValueList &List = LRI->second;
563 while (!List.empty()) {
564 Value *V = List.back();
565 List.pop_back();
566
567 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
568 CurModule.PlaceHolderInfo.find(V);
569 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
570
571 ValID &DID = PHI->second.first;
572
573 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
574 if (TheRealValue) {
575 V->replaceAllUsesWith(TheRealValue);
576 delete V;
577 CurModule.PlaceHolderInfo.erase(PHI);
578 } else if (FutureLateResolvers) {
579 // Functions have their unresolved items forwarded to the module late
580 // resolver table
581 InsertValue(V, *FutureLateResolvers);
582 } else {
583 if (DID.Type == ValID::NameVal)
584 ThrowException("Reference to an invalid definition: '" +DID.getName()+
585 "' of type '" + V->getType()->getDescription() + "'",
586 PHI->second.second);
587 else
588 ThrowException("Reference to an invalid definition: #" +
589 itostr(DID.Num) + " of type '" +
590 V->getType()->getDescription() + "'",
591 PHI->second.second);
592 }
593 }
594 }
595
596 LateResolvers.clear();
597}
598
599// ResolveTypeTo - A brand new type was just declared. This means that (if
600// name is not null) things referencing Name can be resolved. Otherwise, things
601// refering to the number can be resolved. Do this now.
602//
603static void ResolveTypeTo(char *Name, const Type *ToTy) {
604 ValID D;
605 if (Name) D = ValID::create(Name);
606 else D = ValID::create((int)CurModule.Types.size());
607
608 std::map<ValID, PATypeHolder>::iterator I =
609 CurModule.LateResolveTypes.find(D);
610 if (I != CurModule.LateResolveTypes.end()) {
611 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
612 CurModule.LateResolveTypes.erase(I);
613 }
614}
615
616// setValueName - Set the specified value to the name given. The name may be
617// null potentially, in which case this is a noop. The string passed in is
618// assumed to be a malloc'd string buffer, and is free'd by this function.
619//
620static void setValueName(Value *V, char *NameStr) {
621 if (NameStr) {
622 std::string Name(NameStr); // Copy string
623 free(NameStr); // Free old string
624
625 if (V->getType() == Type::VoidTy)
626 ThrowException("Can't assign name '" + Name+"' to value with void type!");
627
628 assert(inFunctionScope() && "Must be in function scope!");
629 SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable();
630 if (ST.lookup(V->getType(), Name))
631 ThrowException("Redefinition of value named '" + Name + "' in the '" +
632 V->getType()->getDescription() + "' type plane!");
633
634 // Set the name.
635 V->setName(Name);
636 }
637}
638
639/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
640/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +0000641static GlobalVariable *
642ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
643 bool isConstantGlobal, const Type *Ty,
644 Constant *Initializer) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000645 if (isa<FunctionType>(Ty))
646 ThrowException("Cannot declare global vars of function type!");
647
648 const PointerType *PTy = PointerType::get(Ty);
649
650 std::string Name;
651 if (NameStr) {
652 Name = NameStr; // Copy string
653 free(NameStr); // Free old string
654 }
655
656 // See if this global value was forward referenced. If so, recycle the
657 // object.
658 ValID ID;
659 if (!Name.empty()) {
660 ID = ValID::create((char*)Name.c_str());
661 } else {
662 ID = ValID::create((int)CurModule.Values[PTy].size());
663 }
664
665 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
666 // Move the global to the end of the list, from whereever it was
667 // previously inserted.
668 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
669 CurModule.CurrentModule->getGlobalList().remove(GV);
670 CurModule.CurrentModule->getGlobalList().push_back(GV);
671 GV->setInitializer(Initializer);
672 GV->setLinkage(Linkage);
673 GV->setConstant(isConstantGlobal);
674 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000675 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000676 }
677
678 // If this global has a name, check to see if there is already a definition
679 // of this global in the module. If so, merge as appropriate. Note that
680 // this is really just a hack around problems in the CFE. :(
681 if (!Name.empty()) {
682 // We are a simple redefinition of a value, check to see if it is defined
683 // the same as the old one.
684 if (GlobalVariable *EGV =
685 CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
686 // We are allowed to redefine a global variable in two circumstances:
687 // 1. If at least one of the globals is uninitialized or
688 // 2. If both initializers have the same value.
689 //
690 if (!EGV->hasInitializer() || !Initializer ||
691 EGV->getInitializer() == Initializer) {
692
693 // Make sure the existing global version gets the initializer! Make
694 // sure that it also gets marked const if the new version is.
695 if (Initializer && !EGV->hasInitializer())
696 EGV->setInitializer(Initializer);
697 if (isConstantGlobal)
698 EGV->setConstant(true);
699 EGV->setLinkage(Linkage);
Chris Lattnerb475c422005-11-12 18:22:38 +0000700 return EGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000701 }
702
703 ThrowException("Redefinition of global variable named '" + Name +
704 "' in the '" + Ty->getDescription() + "' type plane!");
705 }
706 }
707
708 // Otherwise there is no existing GV to use, create one now.
709 GlobalVariable *GV =
710 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
711 CurModule.CurrentModule);
712 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000713 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000714}
715
716// setTypeName - Set the specified type to the name given. The name may be
717// null potentially, in which case this is a noop. The string passed in is
718// assumed to be a malloc'd string buffer, and is freed by this function.
719//
720// This function returns true if the type has already been defined, but is
721// allowed to be redefined in the specified context. If the name is a new name
722// for the type plane, it is inserted and false is returned.
723static bool setTypeName(const Type *T, char *NameStr) {
724 assert(!inFunctionScope() && "Can't give types function-local names!");
725 if (NameStr == 0) return false;
726
727 std::string Name(NameStr); // Copy string
728 free(NameStr); // Free old string
729
730 // We don't allow assigning names to void type
731 if (T == Type::VoidTy)
732 ThrowException("Can't assign name '" + Name + "' to the void type!");
733
734 // Set the type name, checking for conflicts as we do so.
735 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
736
737 if (AlreadyExists) { // Inserting a name that is already defined???
738 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
739 assert(Existing && "Conflict but no matching type?");
740
741 // There is only one case where this is allowed: when we are refining an
742 // opaque type. In this case, Existing will be an opaque type.
743 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
744 // We ARE replacing an opaque type!
745 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
746 return true;
747 }
748
749 // Otherwise, this is an attempt to redefine a type. That's okay if
750 // the redefinition is identical to the original. This will be so if
751 // Existing and T point to the same Type object. In this one case we
752 // allow the equivalent redefinition.
753 if (Existing == T) return true; // Yes, it's equal.
754
755 // Any other kind of (non-equivalent) redefinition is an error.
756 ThrowException("Redefinition of type named '" + Name + "' in the '" +
757 T->getDescription() + "' type plane!");
758 }
759
760 return false;
761}
762
763//===----------------------------------------------------------------------===//
764// Code for handling upreferences in type names...
765//
766
767// TypeContains - Returns true if Ty directly contains E in it.
768//
769static bool TypeContains(const Type *Ty, const Type *E) {
770 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
771 E) != Ty->subtype_end();
772}
773
774namespace {
775 struct UpRefRecord {
776 // NestingLevel - The number of nesting levels that need to be popped before
777 // this type is resolved.
778 unsigned NestingLevel;
779
780 // LastContainedTy - This is the type at the current binding level for the
781 // type. Every time we reduce the nesting level, this gets updated.
782 const Type *LastContainedTy;
783
784 // UpRefTy - This is the actual opaque type that the upreference is
785 // represented with.
786 OpaqueType *UpRefTy;
787
788 UpRefRecord(unsigned NL, OpaqueType *URTy)
789 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
790 };
791}
792
793// UpRefs - A list of the outstanding upreferences that need to be resolved.
794static std::vector<UpRefRecord> UpRefs;
795
796/// HandleUpRefs - Every time we finish a new layer of types, this function is
797/// called. It loops through the UpRefs vector, which is a list of the
798/// currently active types. For each type, if the up reference is contained in
799/// the newly completed type, we decrement the level count. When the level
800/// count reaches zero, the upreferenced type is the type that is passed in:
801/// thus we can complete the cycle.
802///
803static PATypeHolder HandleUpRefs(const Type *ty) {
804 if (!ty->isAbstract()) return ty;
805 PATypeHolder Ty(ty);
806 UR_OUT("Type '" << Ty->getDescription() <<
807 "' newly formed. Resolving upreferences.\n" <<
808 UpRefs.size() << " upreferences active!\n");
809
810 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
811 // to zero), we resolve them all together before we resolve them to Ty. At
812 // the end of the loop, if there is anything to resolve to Ty, it will be in
813 // this variable.
814 OpaqueType *TypeToResolve = 0;
815
816 for (unsigned i = 0; i != UpRefs.size(); ++i) {
817 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
818 << UpRefs[i].second->getDescription() << ") = "
819 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
820 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
821 // Decrement level of upreference
822 unsigned Level = --UpRefs[i].NestingLevel;
823 UpRefs[i].LastContainedTy = Ty;
824 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
825 if (Level == 0) { // Upreference should be resolved!
826 if (!TypeToResolve) {
827 TypeToResolve = UpRefs[i].UpRefTy;
828 } else {
829 UR_OUT(" * Resolving upreference for "
830 << UpRefs[i].second->getDescription() << "\n";
831 std::string OldName = UpRefs[i].UpRefTy->getDescription());
832 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
833 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
834 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
835 }
836 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
837 --i; // Do not skip the next element...
838 }
839 }
840 }
841
842 if (TypeToResolve) {
843 UR_OUT(" * Resolving upreference for "
844 << UpRefs[i].second->getDescription() << "\n";
845 std::string OldName = TypeToResolve->getDescription());
846 TypeToResolve->refineAbstractTypeTo(Ty);
847 }
848
849 return Ty;
850}
851
852
853// common code from the two 'RunVMAsmParser' functions
854 static Module * RunParser(Module * M) {
855
856 llvmAsmlineno = 1; // Reset the current line number...
857 ObsoleteVarArgs = false;
858 NewVarArgs = false;
859
860 CurModule.CurrentModule = M;
861 yyparse(); // Parse the file, potentially throwing exception
862
863 Module *Result = ParserResult;
864 ParserResult = 0;
865
866 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
867 {
868 Function* F;
869 if ((F = Result->getNamedFunction("llvm.va_start"))
870 && F->getFunctionType()->getNumParams() == 0)
871 ObsoleteVarArgs = true;
872 if((F = Result->getNamedFunction("llvm.va_copy"))
873 && F->getFunctionType()->getNumParams() == 1)
874 ObsoleteVarArgs = true;
875 }
876
877 if (ObsoleteVarArgs && NewVarArgs)
878 ThrowException("This file is corrupt: it uses both new and old style varargs");
879
880 if(ObsoleteVarArgs) {
881 if(Function* F = Result->getNamedFunction("llvm.va_start")) {
882 if (F->arg_size() != 0)
883 ThrowException("Obsolete va_start takes 0 argument!");
884
885 //foo = va_start()
886 // ->
887 //bar = alloca typeof(foo)
888 //va_start(bar)
889 //foo = load bar
890
891 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
892 const Type* ArgTy = F->getFunctionType()->getReturnType();
893 const Type* ArgTyPtr = PointerType::get(ArgTy);
894 Function* NF = Result->getOrInsertFunction("llvm.va_start",
Jeff Cohen66c5fd62005-10-23 04:37:20 +0000895 RetTy, ArgTyPtr, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000896
897 while (!F->use_empty()) {
898 CallInst* CI = cast<CallInst>(F->use_back());
899 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
900 new CallInst(NF, bar, "", CI);
901 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
902 CI->replaceAllUsesWith(foo);
903 CI->getParent()->getInstList().erase(CI);
904 }
905 Result->getFunctionList().erase(F);
906 }
907
908 if(Function* F = Result->getNamedFunction("llvm.va_end")) {
909 if(F->arg_size() != 1)
910 ThrowException("Obsolete va_end takes 1 argument!");
911
912 //vaend foo
913 // ->
914 //bar = alloca 1 of typeof(foo)
915 //vaend bar
916 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
917 const Type* ArgTy = F->getFunctionType()->getParamType(0);
918 const Type* ArgTyPtr = PointerType::get(ArgTy);
919 Function* NF = Result->getOrInsertFunction("llvm.va_end",
Jeff Cohen66c5fd62005-10-23 04:37:20 +0000920 RetTy, ArgTyPtr, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000921
922 while (!F->use_empty()) {
923 CallInst* CI = cast<CallInst>(F->use_back());
924 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
925 new StoreInst(CI->getOperand(1), bar, CI);
926 new CallInst(NF, bar, "", CI);
927 CI->getParent()->getInstList().erase(CI);
928 }
929 Result->getFunctionList().erase(F);
930 }
931
932 if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
933 if(F->arg_size() != 1)
934 ThrowException("Obsolete va_copy takes 1 argument!");
935 //foo = vacopy(bar)
936 // ->
937 //a = alloca 1 of typeof(foo)
938 //b = alloca 1 of typeof(foo)
939 //store bar -> b
940 //vacopy(a, b)
941 //foo = load a
942
943 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
944 const Type* ArgTy = F->getFunctionType()->getReturnType();
945 const Type* ArgTyPtr = PointerType::get(ArgTy);
946 Function* NF = Result->getOrInsertFunction("llvm.va_copy",
Jeff Cohen66c5fd62005-10-23 04:37:20 +0000947 RetTy, ArgTyPtr, ArgTyPtr,
948 (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000949
950 while (!F->use_empty()) {
951 CallInst* CI = cast<CallInst>(F->use_back());
952 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
953 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
954 new StoreInst(CI->getOperand(1), b, CI);
955 new CallInst(NF, a, b, "", CI);
956 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
957 CI->replaceAllUsesWith(foo);
958 CI->getParent()->getInstList().erase(CI);
959 }
960 Result->getFunctionList().erase(F);
961 }
962 }
963
964 return Result;
965
966 }
967
968//===----------------------------------------------------------------------===//
969// RunVMAsmParser - Define an interface to this parser
970//===----------------------------------------------------------------------===//
971//
972Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
973 set_scan_file(F);
974
975 CurFilename = Filename;
976 return RunParser(new Module(CurFilename));
977}
978
979Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
980 set_scan_string(AsmString);
981
982 CurFilename = "from_memory";
983 if (M == NULL) {
984 return RunParser(new Module (CurFilename));
985 } else {
986 return RunParser(M);
987 }
988}
989
990
Chris Lattner0ad19702006-06-21 16:53:00 +0000991#line 890 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +0000992typedef union {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000993 llvm::Module *ModuleVal;
994 llvm::Function *FunctionVal;
995 std::pair<llvm::PATypeHolder*, char*> *ArgVal;
996 llvm::BasicBlock *BasicBlockVal;
997 llvm::TerminatorInst *TermInstVal;
998 llvm::Instruction *InstVal;
999 llvm::Constant *ConstVal;
1000
1001 const llvm::Type *PrimType;
1002 llvm::PATypeHolder *TypeVal;
1003 llvm::Value *ValueVal;
1004
1005 std::vector<std::pair<llvm::PATypeHolder*,char*> > *ArgList;
1006 std::vector<llvm::Value*> *ValueList;
1007 std::list<llvm::PATypeHolder> *TypeList;
1008 // Represent the RHS of PHI node
1009 std::list<std::pair<llvm::Value*,
1010 llvm::BasicBlock*> > *PHIList;
1011 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1012 std::vector<llvm::Constant*> *ConstVector;
1013
1014 llvm::GlobalValue::LinkageTypes Linkage;
1015 int64_t SInt64Val;
1016 uint64_t UInt64Val;
1017 int SIntVal;
1018 unsigned UIntVal;
1019 double FPVal;
1020 bool BoolVal;
1021
1022 char *StrVal; // This memory is strdup'd!
1023 llvm::ValID ValIDVal; // strdup'd memory maybe!
1024
1025 llvm::Instruction::BinaryOps BinaryOpVal;
1026 llvm::Instruction::TermOps TermOpVal;
1027 llvm::Instruction::MemoryOps MemOpVal;
1028 llvm::Instruction::OtherOps OtherOpVal;
1029 llvm::Module::Endianness Endianness;
1030} YYSTYPE;
Chris Lattner8335e842006-01-23 23:05:42 +00001031#include <stdio.h>
1032
1033#ifndef __cplusplus
1034#ifndef __STDC__
1035#define const
1036#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001037#endif
1038
1039
1040
Chris Lattner75466192006-05-19 21:28:53 +00001041#define YYFINAL 496
Chris Lattner8335e842006-01-23 23:05:42 +00001042#define YYFLAG -32768
Chris Lattner75466192006-05-19 21:28:53 +00001043#define YYNTBASE 117
Reid Spencer68a24bd2005-08-27 18:50:39 +00001044
Chris Lattner75466192006-05-19 21:28:53 +00001045#define YYTRANSLATE(x) ((unsigned)(x) <= 356 ? yytranslate[x] : 188)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001046
Chris Lattner8335e842006-01-23 23:05:42 +00001047static const char yytranslate[] = { 0,
1048 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1049 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1050 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Chris Lattner75466192006-05-19 21:28:53 +00001051 2, 2, 2, 2, 2, 2, 2, 2, 2, 106,
1052 107, 115, 2, 104, 2, 2, 2, 2, 2, 2,
1053 2, 2, 2, 2, 2, 2, 2, 2, 2, 111,
1054 103, 112, 2, 2, 2, 2, 2, 2, 2, 2,
Chris Lattner8335e842006-01-23 23:05:42 +00001055 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1056 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Chris Lattner75466192006-05-19 21:28:53 +00001057 108, 105, 110, 2, 2, 2, 2, 2, 116, 2,
Chris Lattner8335e842006-01-23 23:05:42 +00001058 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Chris Lattner75466192006-05-19 21:28:53 +00001059 2, 2, 2, 2, 2, 2, 2, 2, 2, 109,
1060 2, 2, 113, 2, 114, 2, 2, 2, 2, 2,
Chris Lattner8335e842006-01-23 23:05:42 +00001061 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, 2, 2, 2, 2, 2,
1073 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
1074 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1075 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1076 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
1077 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
1078 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
1079 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1080 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1081 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1082 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
Chris Lattner75466192006-05-19 21:28:53 +00001083 97, 98, 99, 100, 101, 102
Chris Lattner8335e842006-01-23 23:05:42 +00001084};
Reid Spencer68a24bd2005-08-27 18:50:39 +00001085
Chris Lattner8335e842006-01-23 23:05:42 +00001086#if YYDEBUG != 0
1087static const short yyprhs[] = { 0,
1088 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
1089 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
1090 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
1091 60, 62, 64, 67, 68, 70, 72, 74, 76, 77,
Chris Lattner75466192006-05-19 21:28:53 +00001092 78, 80, 82, 84, 86, 89, 90, 93, 94, 98,
1093 101, 102, 104, 105, 109, 111, 114, 116, 118, 120,
Chris Lattner8335e842006-01-23 23:05:42 +00001094 122, 124, 126, 128, 130, 132, 134, 136, 138, 140,
Chris Lattner75466192006-05-19 21:28:53 +00001095 142, 144, 146, 148, 150, 152, 154, 156, 159, 164,
1096 170, 176, 180, 183, 186, 188, 192, 194, 198, 200,
1097 201, 206, 210, 214, 219, 224, 228, 231, 234, 237,
1098 240, 243, 246, 249, 252, 255, 258, 265, 271, 280,
1099 287, 294, 301, 308, 315, 324, 333, 337, 339, 341,
1100 343, 345, 348, 351, 356, 359, 361, 366, 369, 374,
1101 375, 383, 384, 392, 396, 401, 402, 404, 406, 408,
1102 412, 416, 420, 424, 428, 430, 431, 433, 435, 437,
1103 438, 441, 445, 447, 449, 453, 455, 456, 465, 467,
1104 469, 473, 475, 477, 480, 481, 485, 486, 488, 490,
1105 492, 494, 496, 498, 500, 502, 504, 508, 510, 516,
1106 518, 520, 522, 524, 527, 530, 533, 537, 540, 541,
1107 543, 546, 549, 553, 563, 573, 582, 596, 598, 600,
1108 607, 613, 616, 623, 631, 633, 637, 639, 640, 643,
1109 645, 651, 657, 663, 666, 671, 676, 683, 688, 693,
1110 698, 703, 710, 717, 720, 728, 730, 733, 734, 736,
1111 737, 741, 748, 752, 759, 762, 767, 774
Chris Lattner8335e842006-01-23 23:05:42 +00001112};
Reid Spencer68a24bd2005-08-27 18:50:39 +00001113
Chris Lattner8335e842006-01-23 23:05:42 +00001114static const short yyrhs[] = { 5,
Chris Lattner75466192006-05-19 21:28:53 +00001115 0, 6, 0, 3, 0, 4, 0, 72, 0, 73,
1116 0, 74, 0, 75, 0, 76, 0, 77, 0, 78,
1117 0, 79, 0, 80, 0, 81, 0, 82, 0, 83,
1118 0, 84, 0, 85, 0, 95, 0, 96, 0, 16,
Chris Lattner8335e842006-01-23 23:05:42 +00001119 0, 14, 0, 12, 0, 10, 0, 17, 0, 15,
Chris Lattner75466192006-05-19 21:28:53 +00001120 0, 13, 0, 11, 0, 123, 0, 124, 0, 18,
1121 0, 19, 0, 157, 103, 0, 0, 41, 0, 42,
Chris Lattner0e9c3762006-01-25 22:27:16 +00001122 0, 43, 0, 44, 0, 0, 0, 62, 0, 63,
Chris Lattner75466192006-05-19 21:28:53 +00001123 0, 64, 0, 65, 0, 61, 4, 0, 0, 54,
1124 4, 0, 0, 104, 54, 4, 0, 34, 24, 0,
1125 0, 132, 0, 0, 104, 135, 134, 0, 132, 0,
1126 54, 4, 0, 138, 0, 8, 0, 140, 0, 8,
1127 0, 140, 0, 9, 0, 10, 0, 11, 0, 12,
1128 0, 13, 0, 14, 0, 15, 0, 16, 0, 17,
1129 0, 18, 0, 19, 0, 20, 0, 21, 0, 45,
1130 0, 139, 0, 171, 0, 105, 4, 0, 137, 106,
1131 142, 107, 0, 108, 4, 109, 140, 110, 0, 111,
1132 4, 109, 140, 112, 0, 113, 141, 114, 0, 113,
1133 114, 0, 140, 115, 0, 140, 0, 141, 104, 140,
1134 0, 141, 0, 141, 104, 37, 0, 37, 0, 0,
1135 138, 108, 145, 110, 0, 138, 108, 110, 0, 138,
1136 116, 24, 0, 138, 111, 145, 112, 0, 138, 113,
1137 145, 114, 0, 138, 113, 114, 0, 138, 38, 0,
1138 138, 39, 0, 138, 171, 0, 138, 144, 0, 138,
1139 26, 0, 123, 118, 0, 124, 4, 0, 9, 27,
1140 0, 9, 28, 0, 126, 7, 0, 93, 106, 143,
1141 36, 138, 107, 0, 91, 106, 143, 185, 107, 0,
1142 94, 106, 143, 104, 143, 104, 143, 107, 0, 119,
1143 106, 143, 104, 143, 107, 0, 120, 106, 143, 104,
1144 143, 107, 0, 121, 106, 143, 104, 143, 107, 0,
1145 122, 106, 143, 104, 143, 107, 0, 98, 106, 143,
1146 104, 143, 107, 0, 99, 106, 143, 104, 143, 104,
1147 143, 107, 0, 100, 106, 143, 104, 143, 104, 143,
1148 107, 0, 145, 104, 143, 0, 143, 0, 32, 0,
1149 33, 0, 148, 0, 148, 166, 0, 148, 167, 0,
1150 148, 59, 58, 152, 0, 148, 25, 0, 149, 0,
1151 149, 127, 20, 136, 0, 149, 167, 0, 149, 59,
1152 58, 152, 0, 0, 149, 127, 128, 146, 143, 150,
1153 134, 0, 0, 149, 127, 47, 146, 138, 151, 134,
1154 0, 149, 48, 154, 0, 149, 55, 103, 155, 0,
1155 0, 24, 0, 53, 0, 52, 0, 50, 103, 153,
1156 0, 51, 103, 4, 0, 49, 103, 24, 0, 108,
1157 156, 110, 0, 156, 104, 24, 0, 24, 0, 0,
1158 22, 0, 24, 0, 157, 0, 0, 138, 158, 0,
1159 160, 104, 159, 0, 159, 0, 160, 0, 160, 104,
1160 37, 0, 37, 0, 0, 129, 136, 157, 106, 161,
1161 107, 133, 130, 0, 29, 0, 113, 0, 128, 162,
1162 163, 0, 30, 0, 114, 0, 174, 165, 0, 0,
1163 31, 168, 162, 0, 0, 60, 0, 3, 0, 4,
1164 0, 7, 0, 27, 0, 28, 0, 38, 0, 39,
1165 0, 26, 0, 111, 145, 112, 0, 144, 0, 58,
1166 169, 24, 104, 24, 0, 117, 0, 157, 0, 171,
1167 0, 170, 0, 138, 172, 0, 174, 175, 0, 164,
1168 175, 0, 176, 127, 177, 0, 176, 179, 0, 0,
1169 23, 0, 66, 173, 0, 66, 8, 0, 67, 21,
1170 172, 0, 67, 9, 172, 104, 21, 172, 104, 21,
1171 172, 0, 68, 125, 172, 104, 21, 172, 108, 178,
1172 110, 0, 68, 125, 172, 104, 21, 172, 108, 110,
1173 0, 69, 129, 136, 172, 106, 182, 107, 36, 21,
1174 172, 70, 21, 172, 0, 70, 0, 71, 0, 178,
1175 125, 170, 104, 21, 172, 0, 125, 170, 104, 21,
1176 172, 0, 127, 184, 0, 138, 108, 172, 104, 172,
1177 110, 0, 180, 104, 108, 172, 104, 172, 110, 0,
1178 173, 0, 181, 104, 173, 0, 181, 0, 0, 57,
1179 56, 0, 56, 0, 119, 138, 172, 104, 172, 0,
1180 120, 138, 172, 104, 172, 0, 121, 138, 172, 104,
1181 172, 0, 46, 173, 0, 122, 173, 104, 173, 0,
1182 93, 173, 36, 138, 0, 94, 173, 104, 173, 104,
1183 173, 0, 97, 173, 104, 138, 0, 101, 173, 104,
1184 138, 0, 102, 173, 104, 138, 0, 98, 173, 104,
1185 173, 0, 99, 173, 104, 173, 104, 173, 0, 100,
1186 173, 104, 173, 104, 173, 0, 92, 180, 0, 183,
1187 129, 136, 172, 106, 182, 107, 0, 187, 0, 104,
1188 181, 0, 0, 35, 0, 0, 86, 138, 131, 0,
1189 86, 138, 104, 15, 172, 131, 0, 87, 138, 131,
1190 0, 87, 138, 104, 15, 172, 131, 0, 88, 173,
1191 0, 186, 89, 138, 172, 0, 186, 90, 173, 104,
1192 138, 172, 0, 91, 138, 172, 185, 0
Chris Lattner8335e842006-01-23 23:05:42 +00001193};
Reid Spencer68a24bd2005-08-27 18:50:39 +00001194
1195#endif
1196
Chris Lattner8335e842006-01-23 23:05:42 +00001197#if YYDEBUG != 0
1198static const short yyrline[] = { 0,
Chris Lattner0e9c3762006-01-25 22:27:16 +00001199 1010, 1011, 1018, 1019, 1028, 1028, 1028, 1028, 1028, 1029,
1200 1029, 1029, 1030, 1030, 1030, 1030, 1030, 1030, 1032, 1032,
1201 1036, 1036, 1036, 1036, 1037, 1037, 1037, 1037, 1038, 1038,
1202 1039, 1039, 1042, 1045, 1049, 1049, 1050, 1051, 1052, 1055,
Chris Lattner75466192006-05-19 21:28:53 +00001203 1055, 1056, 1057, 1058, 1059, 1068, 1068, 1074, 1074, 1082,
1204 1089, 1089, 1095, 1095, 1097, 1101, 1114, 1114, 1115, 1115,
1205 1117, 1126, 1126, 1126, 1126, 1126, 1126, 1126, 1127, 1127,
1206 1127, 1127, 1127, 1127, 1128, 1131, 1134, 1140, 1147, 1159,
1207 1163, 1174, 1183, 1186, 1194, 1198, 1203, 1204, 1207, 1210,
1208 1220, 1245, 1258, 1287, 1312, 1332, 1344, 1353, 1357, 1416,
1209 1422, 1430, 1435, 1440, 1443, 1446, 1453, 1463, 1494, 1501,
1210 1522, 1532, 1537, 1544, 1549, 1554, 1562, 1565, 1572, 1572,
1211 1582, 1589, 1593, 1596, 1599, 1602, 1615, 1635, 1637, 1639,
1212 1642, 1645, 1649, 1652, 1654, 1656, 1660, 1672, 1673, 1675,
1213 1678, 1686, 1691, 1693, 1697, 1701, 1709, 1709, 1710, 1710,
1214 1712, 1718, 1723, 1729, 1732, 1737, 1741, 1745, 1831, 1831,
1215 1833, 1841, 1841, 1843, 1847, 1847, 1856, 1859, 1863, 1866,
1216 1869, 1872, 1875, 1878, 1881, 1884, 1887, 1911, 1914, 1927,
1217 1930, 1935, 1935, 1941, 1945, 1948, 1956, 1965, 1969, 1979,
1218 1990, 1993, 1996, 1999, 2002, 2016, 2020, 2073, 2076, 2082,
1219 2090, 2100, 2107, 2112, 2119, 2123, 2129, 2129, 2131, 2134,
1220 2140, 2152, 2163, 2173, 2185, 2192, 2199, 2206, 2211, 2230,
1221 2252, 2257, 2262, 2267, 2281, 2338, 2344, 2346, 2350, 2353,
1222 2359, 2363, 2367, 2371, 2375, 2382, 2392, 2405
Chris Lattner8335e842006-01-23 23:05:42 +00001223};
1224#endif
1225
1226
1227#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
1228
1229static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL",
1230"EUINT64VAL","SINTVAL","UINTVAL","FPVAL","VOID","BOOL","SBYTE","UBYTE","SHORT",
1231"USHORT","INT","UINT","LONG","ULONG","FLOAT","DOUBLE","TYPE","LABEL","VAR_ID",
1232"LABELSTR","STRINGCONSTANT","IMPLEMENTATION","ZEROINITIALIZER","TRUETOK","FALSETOK",
1233"BEGINTOK","ENDTOK","DECLARE","GLOBAL","CONSTANT","SECTION","VOLATILE","TO",
1234"DOTDOTDOT","NULL_TOK","UNDEF","CONST","INTERNAL","LINKONCE","WEAK","APPENDING",
1235"OPAQUE","NOT","EXTERNAL","TARGET","TRIPLE","ENDIAN","POINTERSIZE","LITTLE",
Chris Lattner0e9c3762006-01-25 22:27:16 +00001236"BIG","ALIGN","DEPLIBS","CALL","TAIL","ASM_TOK","MODULE","SIDEEFFECT","CC_TOK",
Chris Lattner75466192006-05-19 21:28:53 +00001237"CCC_TOK","CSRETCC_TOK","FASTCC_TOK","COLDCC_TOK","RET","BR","SWITCH","INVOKE",
1238"UNWIND","UNREACHABLE","ADD","SUB","MUL","DIV","REM","AND","OR","XOR","SETLE",
1239"SETGE","SETLT","SETGT","SETEQ","SETNE","MALLOC","ALLOCA","FREE","LOAD","STORE",
1240"GETELEMENTPTR","PHI_TOK","CAST","SELECT","SHL","SHR","VAARG","EXTRACTELEMENT",
1241"INSERTELEMENT","SHUFFLEVECTOR","VAARG_old","VANEXT_old","'='","','","'\\\\'",
1242"'('","')'","'['","'x'","']'","'<'","'>'","'{'","'}'","'*'","'c'","INTVAL","EINT64VAL",
1243"ArithmeticOps","LogicalOps","SetCondOps","ShiftOps","SIntType","UIntType","IntType",
1244"FPType","OptAssign","OptLinkage","OptCallingConv","OptAlign","OptCAlign","SectionString",
1245"OptSection","GlobalVarAttributes","GlobalVarAttribute","TypesV","UpRTypesV",
1246"Types","PrimType","UpRTypes","TypeListI","ArgTypeListI","ConstVal","ConstExpr",
1247"ConstVector","GlobalType","Module","FunctionList","ConstPool","@1","@2","AsmBlock",
1248"BigOrLittle","TargetDefinition","LibrariesDefinition","LibList","Name","OptName",
1249"ArgVal","ArgListH","ArgList","FunctionHeaderH","BEGIN","FunctionHeader","END",
1250"Function","FunctionProto","@3","OptSideEffect","ConstValueRef","SymbolicValueRef",
1251"ValueRef","ResolvedVal","BasicBlockList","BasicBlock","InstructionList","BBTerminatorInst",
1252"JumpTable","Inst","PHIList","ValueRefList","ValueRefListE","OptTailCall","InstVal",
1253"IndexList","OptVolatile","MemoryInst", NULL
Chris Lattner8335e842006-01-23 23:05:42 +00001254};
1255#endif
1256
1257static const short yyr1[] = { 0,
Chris Lattner75466192006-05-19 21:28:53 +00001258 117, 117, 118, 118, 119, 119, 119, 119, 119, 120,
1259 120, 120, 121, 121, 121, 121, 121, 121, 122, 122,
1260 123, 123, 123, 123, 124, 124, 124, 124, 125, 125,
1261 126, 126, 127, 127, 128, 128, 128, 128, 128, 129,
1262 129, 129, 129, 129, 129, 130, 130, 131, 131, 132,
1263 133, 133, 134, 134, 135, 135, 136, 136, 137, 137,
1264 138, 139, 139, 139, 139, 139, 139, 139, 139, 139,
1265 139, 139, 139, 139, 140, 140, 140, 140, 140, 140,
1266 140, 140, 140, 140, 141, 141, 142, 142, 142, 142,
1267 143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
1268 143, 143, 143, 143, 143, 143, 144, 144, 144, 144,
1269 144, 144, 144, 144, 144, 144, 145, 145, 146, 146,
1270 147, 148, 148, 148, 148, 148, 149, 149, 149, 150,
1271 149, 151, 149, 149, 149, 149, 152, 153, 153, 154,
1272 154, 154, 155, 156, 156, 156, 157, 157, 158, 158,
1273 159, 160, 160, 161, 161, 161, 161, 162, 163, 163,
1274 164, 165, 165, 166, 168, 167, 169, 169, 170, 170,
1275 170, 170, 170, 170, 170, 170, 170, 170, 170, 171,
1276 171, 172, 172, 173, 174, 174, 175, 176, 176, 176,
1277 177, 177, 177, 177, 177, 177, 177, 177, 177, 178,
1278 178, 179, 180, 180, 181, 181, 182, 182, 183, 183,
1279 184, 184, 184, 184, 184, 184, 184, 184, 184, 184,
1280 184, 184, 184, 184, 184, 184, 185, 185, 186, 186,
1281 187, 187, 187, 187, 187, 187, 187, 187
Chris Lattner8335e842006-01-23 23:05:42 +00001282};
1283
1284static const short yyr2[] = { 0,
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, 1, 1, 1, 1, 1, 1, 1, 1,
1288 1, 1, 2, 0, 1, 1, 1, 1, 0, 0,
Chris Lattner75466192006-05-19 21:28:53 +00001289 1, 1, 1, 1, 2, 0, 2, 0, 3, 2,
1290 0, 1, 0, 3, 1, 2, 1, 1, 1, 1,
Chris Lattner8335e842006-01-23 23:05:42 +00001291 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Chris Lattner75466192006-05-19 21:28:53 +00001292 1, 1, 1, 1, 1, 1, 1, 2, 4, 5,
1293 5, 3, 2, 2, 1, 3, 1, 3, 1, 0,
1294 4, 3, 3, 4, 4, 3, 2, 2, 2, 2,
1295 2, 2, 2, 2, 2, 2, 6, 5, 8, 6,
1296 6, 6, 6, 6, 8, 8, 3, 1, 1, 1,
1297 1, 2, 2, 4, 2, 1, 4, 2, 4, 0,
1298 7, 0, 7, 3, 4, 0, 1, 1, 1, 3,
1299 3, 3, 3, 3, 1, 0, 1, 1, 1, 0,
1300 2, 3, 1, 1, 3, 1, 0, 8, 1, 1,
1301 3, 1, 1, 2, 0, 3, 0, 1, 1, 1,
1302 1, 1, 1, 1, 1, 1, 3, 1, 5, 1,
1303 1, 1, 1, 2, 2, 2, 3, 2, 0, 1,
1304 2, 2, 3, 9, 9, 8, 13, 1, 1, 6,
1305 5, 2, 6, 7, 1, 3, 1, 0, 2, 1,
1306 5, 5, 5, 2, 4, 4, 6, 4, 4, 4,
1307 4, 6, 6, 2, 7, 1, 2, 0, 1, 0,
1308 3, 6, 3, 6, 2, 4, 6, 4
Chris Lattner8335e842006-01-23 23:05:42 +00001309};
1310
Chris Lattner75466192006-05-19 21:28:53 +00001311static const short yydefact[] = { 136,
1312 39, 126, 125, 165, 35, 36, 37, 38, 0, 40,
1313 189, 122, 123, 189, 147, 148, 0, 0, 0, 39,
1314 0, 128, 40, 0, 0, 41, 42, 43, 44, 0,
1315 0, 190, 186, 34, 162, 163, 164, 185, 0, 0,
1316 0, 134, 0, 0, 0, 0, 0, 33, 166, 137,
1317 124, 45, 1, 2, 58, 62, 63, 64, 65, 66,
1318 67, 68, 69, 70, 71, 72, 73, 74, 75, 0,
1319 0, 0, 0, 180, 0, 0, 57, 76, 61, 181,
1320 77, 159, 160, 161, 230, 188, 0, 0, 0, 146,
1321 135, 129, 127, 119, 120, 0, 0, 78, 0, 0,
1322 60, 83, 85, 0, 0, 90, 84, 229, 0, 210,
1323 0, 0, 0, 0, 40, 198, 199, 5, 6, 7,
1324 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
1325 18, 0, 0, 0, 0, 0, 0, 0, 19, 20,
Chris Lattner8335e842006-01-23 23:05:42 +00001326 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner75466192006-05-19 21:28:53 +00001327 187, 40, 202, 0, 226, 142, 139, 138, 140, 141,
1328 145, 0, 132, 62, 63, 64, 65, 66, 67, 68,
1329 69, 70, 71, 72, 0, 0, 0, 0, 130, 0,
1330 0, 0, 82, 157, 89, 87, 0, 0, 214, 209,
1331 192, 191, 0, 0, 24, 28, 23, 27, 22, 26,
1332 21, 25, 29, 30, 0, 0, 48, 48, 235, 0,
1333 0, 224, 0, 0, 0, 0, 0, 0, 0, 0,
1334 0, 0, 0, 0, 0, 0, 0, 0, 143, 53,
1335 104, 105, 3, 4, 102, 103, 106, 101, 97, 98,
Chris Lattner66316012006-01-24 04:14:29 +00001336 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner75466192006-05-19 21:28:53 +00001337 0, 0, 0, 0, 100, 99, 53, 59, 59, 86,
1338 156, 150, 153, 154, 0, 0, 79, 169, 170, 171,
1339 176, 172, 173, 174, 175, 167, 0, 178, 183, 182,
1340 184, 0, 193, 0, 0, 0, 231, 0, 233, 228,
1341 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1342 0, 0, 0, 0, 0, 0, 0, 144, 0, 133,
1343 0, 0, 0, 0, 0, 0, 92, 118, 0, 0,
1344 96, 0, 93, 0, 0, 0, 0, 131, 80, 81,
1345 149, 151, 0, 51, 88, 168, 0, 0, 0, 0,
1346 0, 0, 0, 0, 0, 238, 0, 0, 216, 0,
1347 218, 221, 0, 0, 219, 220, 0, 0, 0, 215,
1348 0, 236, 0, 0, 0, 55, 53, 228, 0, 0,
1349 0, 0, 0, 0, 91, 94, 95, 0, 0, 0,
1350 0, 155, 152, 52, 46, 0, 177, 0, 0, 208,
1351 48, 49, 48, 205, 227, 0, 0, 0, 0, 0,
1352 211, 212, 213, 208, 0, 50, 56, 54, 0, 0,
1353 0, 0, 0, 0, 117, 0, 0, 0, 0, 0,
1354 158, 0, 0, 0, 207, 0, 0, 232, 234, 0,
1355 0, 0, 217, 222, 223, 0, 237, 108, 0, 0,
1356 0, 0, 0, 0, 0, 0, 0, 47, 179, 0,
1357 0, 0, 206, 203, 0, 225, 107, 0, 114, 0,
1358 0, 110, 111, 112, 113, 0, 196, 0, 0, 0,
1359 204, 0, 0, 0, 194, 0, 195, 0, 0, 109,
1360 115, 116, 0, 0, 0, 0, 0, 0, 201, 0,
1361 0, 200, 197, 0, 0, 0
Chris Lattner8335e842006-01-23 23:05:42 +00001362};
1363
Chris Lattner75466192006-05-19 21:28:53 +00001364static const short yydefgoto[] = { 74,
1365 235, 251, 252, 253, 254, 175, 176, 205, 177, 20,
1366 10, 30, 421, 287, 366, 385, 310, 367, 75, 76,
1367 178, 78, 79, 104, 187, 318, 278, 319, 96, 494,
1368 1, 2, 257, 230, 51, 159, 42, 91, 162, 80,
1369 332, 263, 264, 265, 31, 84, 11, 37, 12, 13,
1370 23, 337, 279, 81, 281, 394, 14, 33, 34, 151,
1371 469, 86, 212, 425, 426, 152, 153, 346, 154, 155
Chris Lattner8335e842006-01-23 23:05:42 +00001372};
1373
1374static const short yypact[] = {-32768,
Chris Lattner75466192006-05-19 21:28:53 +00001375 181, 372,-32768,-32768,-32768,-32768,-32768,-32768, -32, 94,
1376 38,-32768,-32768, -14,-32768,-32768, 45, -40, 18, 44,
1377 -25,-32768, 94, 57, 79,-32768,-32768,-32768,-32768, 1012,
1378 -21,-32768,-32768, 22,-32768,-32768,-32768,-32768, -6, -4,
1379 27,-32768, 26, 57, 1012, 77, 77,-32768,-32768,-32768,
1380-32768,-32768,-32768,-32768, 46,-32768,-32768,-32768,-32768,-32768,
1381-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 167,
1382 170, 171, 524,-32768, 22, 71,-32768,-32768, -17,-32768,
1383-32768,-32768,-32768,-32768, 1176,-32768, 154, 76, 175, 156,
1384-32768,-32768,-32768,-32768,-32768, 1050, 1088,-32768, 73, 74,
1385-32768,-32768, -17, -83, 78, 819,-32768,-32768, 1050,-32768,
1386 129, 1126, 56, 128, 94,-32768,-32768,-32768,-32768,-32768,
Chris Lattner8335e842006-01-23 23:05:42 +00001387-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
Chris Lattner75466192006-05-19 21:28:53 +00001388-32768, 1050, 1050, 1050, 1050, 1050, 1050, 1050,-32768,-32768,
1389 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050,
1390-32768, 94,-32768, 43,-32768,-32768,-32768,-32768,-32768,-32768,
1391-32768, -82,-32768, 119, 146, 183, 157, 190, 159, 194,
1392 166, 196, 195, 197, 169, 199, 198, 406,-32768, 1050,
1393 1050, 1050,-32768, 857,-32768, 97, 100, 617,-32768,-32768,
1394 46,-32768, 617, 617,-32768,-32768,-32768,-32768,-32768,-32768,
1395-32768,-32768,-32768,-32768, 617, 1012, 104, 105,-32768, 617,
1396 103, 109, 178, 111, 122, 123, 131, 132, 133, 134,
1397 617, 617, 617, 135, 1012, 1050, 1050, 209,-32768, 137,
1398-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1399 136, 138, 139, 140, 141, 144, 895, 1088, 566, 219,
1400 145, 147, 148, 149,-32768,-32768, 137, -48, -88, -17,
1401-32768, 22,-32768, 152, 150, 936,-32768,-32768,-32768,-32768,
1402-32768,-32768,-32768,-32768,-32768, 192, 1088,-32768,-32768,-32768,
1403-32768, 155,-32768, 158, 617, -5,-32768, 5,-32768, 172,
1404 617, 153, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050,
1405 173, 174, 176, 1050, 617, 617, 177,-32768, -20,-32768,
1406 1088, 1088, 1088, 1088, 1088, 1088,-32768,-32768, -62, -11,
1407-32768, -79,-32768, 1088, 1088, 1088, 1088,-32768,-32768,-32768,
1408-32768,-32768, 974, 224,-32768,-32768, 236, 23, 251, 252,
1409 180, 617, 271, 617, 1050,-32768, 179, 617,-32768, 184,
1410-32768,-32768, 185, 186,-32768,-32768, 617, 617, 617,-32768,
1411 191,-32768, 1050, 258, 280,-32768, 137, 172, 256, 200,
1412 201, 202, 203, 1088,-32768,-32768,-32768, 204, 205, 206,
1413 207,-32768,-32768,-32768, 242, 208,-32768, 617, 617, 1050,
1414 210,-32768, 210,-32768, 216, 617, 222, 1050, 1050, 1050,
1415-32768,-32768,-32768, 1050, 617,-32768,-32768,-32768, 220, 1050,
1416 1088, 1088, 1088, 1088,-32768, 1088, 1088, 1088, 1088, 294,
1417-32768, 275, 225, 226, 216, 221, 259,-32768,-32768, 1050,
1418 227, 617,-32768,-32768,-32768, 223,-32768,-32768, 228, 232,
1419 234, 238, 239, 237, 240, 243, 244,-32768,-32768, 324,
1420 41, 310,-32768,-32768, 245,-32768,-32768, 1088,-32768, 1088,
1421 1088,-32768,-32768,-32768,-32768, 617,-32768, 715, 58, 328,
1422-32768, 246, 247, 250,-32768, 248,-32768, 715, 617,-32768,
1423-32768,-32768, 338, 260, 297, 617, 350, 351,-32768, 617,
1424 617,-32768,-32768, 376, 377,-32768
Chris Lattner8335e842006-01-23 23:05:42 +00001425};
1426
1427static const short yypgoto[] = {-32768,
Chris Lattner75466192006-05-19 21:28:53 +00001428-32768, 296, 298, 299, 300, -113, -111, -439,-32768, 345,
1429 362, -92,-32768, -203, 52,-32768, -244,-32768, -39,-32768,
1430 -30,-32768, -56, 281,-32768, -95, 215, -230, 341,-32768,
1431-32768,-32768,-32768,-32768, 353,-32768,-32768,-32768,-32768, 9,
1432-32768, 62,-32768,-32768, 375,-32768,-32768,-32768,-32768, 397,
1433-32768,-32768, -388, -57, 168, -105,-32768, 387,-32768,-32768,
1434-32768,-32768,-32768, 61, -2,-32768,-32768, 39,-32768,-32768
Chris Lattner8335e842006-01-23 23:05:42 +00001435};
1436
1437
Chris Lattner75466192006-05-19 21:28:53 +00001438#define YYLAST 1278
Chris Lattner8335e842006-01-23 23:05:42 +00001439
1440
Chris Lattner75466192006-05-19 21:28:53 +00001441static const short yytable[] = { 77,
1442 203, 179, 204, 189, 289, 93, 192, 82, 32, 342,
1443 21, 468, 328, 364, 77, 35, 103, 320, 322, 344,
1444 182, 228, 206, 330, 374, 24, 107, 229, 209, 478,
1445 183, 213, 214, 365, 377, 215, 216, 217, 218, 219,
1446 220, 374, 21, 15, 224, 16, 338, 375, 343, 103,
1447 195, 196, 197, 198, 199, 200, 201, 202, 343, 225,
1448 32, 329, 43, 45, 193, 163, 107, 195, 196, 197,
1449 198, 199, 200, 201, 202, 44, 194, 48, 188, 476,
1450 50, 188, 52, 105, 5, 6, 7, 8, -59, 484,
1451 46, 83, 374, 39, 40, 41, 87, 107, 88, 36,
1452 376, 207, 208, 188, 210, 211, 188, 188, 94, 95,
1453 188, 188, 188, 188, 188, 188, 221, 222, 223, 188,
1454 256, 307, 408, 258, 259, 260, 374, 157, 158, 89,
1455 280, 226, 227, 90, 387, 280, 280, 195, 196, 197,
1456 198, 199, 200, 201, 202, 231, 232, 280, -24, -24,
1457 467, -60, 280, 262, 25, 26, 27, 28, 29, -23,
1458 -23, -22, -22, 280, 280, 280, 285, 477, -21, -21,
1459 98, 233, 234, 99, 100, 77, 106, 156, 160, 161,
1460 -121, 180, 181, 184, 190, 305, -28, 428, 350, 429,
1461 352, 353, 354, -27, 77, 306, 188, -26, 360, -25,
1462 266, -31, 236, -32, 237, 3, 267, 286, 288, 260,
1463 291, 4, 292, 293, 294, 368, 369, 370, 371, 372,
1464 373, 5, 6, 7, 8, 295, 296, 280, 378, 379,
1465 380, 381, 308, 280, 297, 298, 299, 300, 304, 9,
1466 309, 311, 323, 312, 313, 314, 315, 280, 280, 316,
1467 324, 336, 325, 326, 327, 333, 334, 364, 339, 386,
1468 348, 340, 349, 188, 351, 188, 188, 188, 355, 356,
1469 331, 388, 389, 188, 392, 345, 357, 358, 415, 359,
1470 363, 406, 396, 407, 280, 390, 280, 398, 399, 400,
1471 280, 410, 433, 434, 435, 420, 404, 448, 449, 280,
1472 280, 280, 262, 411, 412, 413, 414, 416, 417, 418,
1473 419, 422, 343, 427, 188, 440, 441, 442, 443, 430,
1474 444, 445, 446, 447, 453, 432, 438, 452, 450, 456,
1475 280, 280, 405, 451, 457, 458, 454, 203, 280, 204,
1476 459, 460, 461, 462, 466, 470, 463, 280, 479, 464,
1477 465, 483, 480, 481, 471, 203, 482, 204, 486, 188,
1478 282, 283, 472, 487, 473, 474, 488, 188, 188, 188,
1479 490, 491, 284, 188, 280, 495, 496, 290, 85, 439,
1480 147, 47, 148, 149, 150, 384, 186, 97, 301, 302,
1481 303, -34, 255, 15, 383, 16, 92, 49, 22, 188,
1482 38, 436, 4, -34, -34, 395, 409, 0, 280, 0,
1483 53, 54, -34, -34, -34, -34, 0, 0, -34, 17,
1484 0, 280, 0, 0, 0, 0, 18, 15, 280, 16,
1485 19, 238, 280, 280, 0, 0, 0, 0, 0, 0,
1486 0, 0, 0, 239, 240, 0, 0, 0, 0, 0,
1487 0, 0, 341, 0, 0, 0, 0, 0, 347, 0,
Chris Lattnerd25db202006-04-08 03:55:17 +00001488 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner75466192006-05-19 21:28:53 +00001489 0, 0, 361, 362, 0, 0, 0, 118, 119, 120,
1490 121, 122, 123, 124, 125, 126, 127, 128, 129, 130,
1491 131, 0, 0, 0, 0, 0, 241, 0, 242, 243,
1492 139, 140, 0, 244, 245, 246, 0, 0, 0, 391,
1493 0, 393, 0, 247, 0, 397, 248, 0, 249, 0,
1494 0, 250, 0, 0, 401, 402, 403, 0, 53, 54,
1495 0, 101, 56, 57, 58, 59, 60, 61, 62, 63,
1496 64, 65, 66, 67, 68, 15, 0, 16, 0, 0,
1497 0, 0, 0, 0, 0, 423, 424, 0, 0, 0,
1498 0, 0, 0, 431, 0, 0, 0, 0, 69, 0,
1499 53, 54, 437, 101, 164, 165, 166, 167, 168, 169,
1500 170, 171, 172, 173, 174, 67, 68, 15, 0, 16,
1501 0, 0, 0, 0, 0, 0, 0, 0, 0, 455,
Chris Lattner8335e842006-01-23 23:05:42 +00001502 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner75466192006-05-19 21:28:53 +00001503 69, 0, 0, 0, 0, 0, 0, 0, 0, 268,
1504 269, 53, 54, 270, 0, 0, 0, 0, 70, 0,
1505 0, 71, 0, 475, 72, 0, 73, 102, 15, 0,
1506 16, 0, 271, 272, 273, 0, 485, 0, 0, 0,
1507 0, 0, 0, 489, 274, 275, 0, 492, 493, 0,
Chris Lattner66316012006-01-24 04:14:29 +00001508 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner75466192006-05-19 21:28:53 +00001509 70, 0, 0, 71, 276, 0, 72, 0, 73, 321,
1510 0, 0, 0, 0, 0, 0, 0, 0, 118, 119,
Chris Lattnerd25db202006-04-08 03:55:17 +00001511 120, 121, 122, 123, 124, 125, 126, 127, 128, 129,
Chris Lattner75466192006-05-19 21:28:53 +00001512 130, 131, 0, 0, 0, 0, 0, 241, 0, 242,
1513 243, 139, 140, 0, 244, 245, 246, 268, 269, 0,
1514 0, 270, 0, 0, 0, 0, 0, 277, 0, 0,
Chris Lattnerd25db202006-04-08 03:55:17 +00001515 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner75466192006-05-19 21:28:53 +00001516 271, 272, 273, 0, 0, 0, 0, 0, 0, 0,
1517 0, 0, 274, 275, 0, 0, 0, 0, 0, 0,
1518 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1519 0, 0, 276, 0, 0, 0, 0, 0, 0, 0,
1520 0, 0, 0, 0, 0, 0, 118, 119, 120, 121,
1521 122, 123, 124, 125, 126, 127, 128, 129, 130, 131,
1522 0, 0, 0, 0, 0, 241, 0, 242, 243, 139,
1523 140, 0, 244, 245, 246, 0, 0, 0, 0, 0,
1524 0, 0, 0, 53, 54, 277, 101, 56, 57, 58,
1525 59, 60, 61, 62, 63, 64, 65, 66, 67, 68,
1526 15, 0, 16, 0, 0, 0, 0, 0, 0, 0,
1527 0, 0, 0, 0, 0, 185, 0, 0, 0, 0,
1528 0, 53, 54, 69, 101, 56, 57, 58, 59, 60,
1529 61, 62, 63, 64, 65, 66, 67, 68, 15, 0,
1530 16, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1531 0, 0, 0, 261, 0, 0, 0, 0, 0, 53,
1532 54, 69, 101, 164, 165, 166, 167, 168, 169, 170,
1533 171, 172, 173, 174, 67, 68, 15, 0, 16, 0,
1534 0, 0, 0, 70, 0, 0, 71, 0, 0, 72,
1535 0, 73, 0, 0, 0, 0, 0, 0, 0, 69,
1536 53, 54, 0, 101, 56, 57, 58, 59, 60, 61,
1537 62, 63, 64, 65, 66, 67, 68, 15, 0, 16,
1538 0, 70, 0, 0, 71, 0, 0, 72, 0, 73,
1539 0, 0, 335, 0, 0, 0, 0, 0, 53, 54,
1540 69, 101, 56, 57, 58, 59, 60, 61, 62, 63,
1541 64, 65, 66, 67, 68, 15, 0, 16, 0, 70,
1542 0, 0, 71, 0, 317, 72, 0, 73, 0, 0,
1543 382, 0, 0, 0, 0, 0, 53, 54, 69, 55,
1544 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
1545 66, 67, 68, 15, 0, 16, 0, 0, 0, 0,
1546 70, 0, 0, 71, 0, 0, 72, 0, 73, 0,
1547 0, 0, 0, 0, 53, 54, 69, 101, 56, 57,
1548 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
1549 68, 15, 0, 16, 0, 0, 0, 0, 70, 0,
1550 0, 71, 0, 0, 72, 0, 73, 0, 0, 0,
1551 0, 0, 53, 54, 69, 101, 164, 165, 166, 167,
1552 168, 169, 170, 171, 172, 173, 174, 67, 68, 15,
1553 0, 16, 0, 0, 0, 0, 70, 0, 0, 71,
1554 0, 0, 72, 0, 73, 0, 0, 0, 0, 0,
1555 53, 54, 69, 191, 56, 57, 58, 59, 60, 61,
1556 62, 63, 64, 65, 66, 67, 68, 15, 0, 16,
1557 0, 0, 0, 0, 70, 0, 0, 71, 0, 0,
1558 72, 0, 73, 0, 0, 0, 0, 0, 0, 0,
1559 69, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1560 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1561 0, 0, 70, 0, 0, 71, 0, 0, 72, 0,
1562 73, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1563 108, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1564 0, 109, 0, 0, 0, 0, 0, 0, 0, 0,
1565 70, 110, 111, 71, 0, 0, 72, 0, 73, 0,
1566 0, 112, 113, 114, 115, 116, 117, 118, 119, 120,
1567 121, 122, 123, 124, 125, 126, 127, 128, 129, 130,
1568 131, 132, 133, 134, 0, 0, 135, 136, 137, 138,
1569 139, 140, 141, 142, 143, 144, 145, 146
Chris Lattner8335e842006-01-23 23:05:42 +00001570};
1571
Chris Lattner75466192006-05-19 21:28:53 +00001572static const short yycheck[] = { 30,
1573 114, 97, 114, 109, 208, 45, 112, 29, 23, 15,
1574 2, 451, 257, 34, 45, 30, 73, 248, 249, 15,
1575 104, 104, 115, 112, 104, 58, 115, 110, 134, 469,
1576 114, 137, 138, 54, 114, 141, 142, 143, 144, 145,
1577 146, 104, 34, 22, 150, 24, 277, 110, 54, 106,
1578 10, 11, 12, 13, 14, 15, 16, 17, 54, 152,
1579 23, 110, 103, 20, 9, 96, 115, 10, 11, 12,
1580 13, 14, 15, 16, 17, 58, 21, 103, 109, 468,
1581 24, 112, 4, 75, 41, 42, 43, 44, 106, 478,
1582 47, 113, 104, 49, 50, 51, 103, 115, 103, 114,
1583 112, 132, 133, 134, 135, 136, 137, 138, 32, 33,
1584 141, 142, 143, 144, 145, 146, 147, 148, 149, 150,
1585 178, 227, 367, 180, 181, 182, 104, 52, 53, 103,
1586 188, 89, 90, 108, 112, 193, 194, 10, 11, 12,
1587 13, 14, 15, 16, 17, 27, 28, 205, 3, 4,
1588 110, 106, 210, 184, 61, 62, 63, 64, 65, 3,
1589 4, 3, 4, 221, 222, 223, 206, 110, 3, 4,
1590 4, 3, 4, 4, 4, 206, 106, 24, 4, 24,
1591 0, 109, 109, 106, 56, 225, 4, 391, 294, 393,
1592 296, 297, 298, 4, 225, 226, 227, 4, 304, 4,
1593 104, 7, 4, 7, 7, 25, 107, 104, 104, 266,
1594 108, 31, 104, 36, 104, 311, 312, 313, 314, 315,
1595 316, 41, 42, 43, 44, 104, 104, 285, 324, 325,
1596 326, 327, 24, 291, 104, 104, 104, 104, 104, 59,
1597 104, 106, 24, 106, 106, 106, 106, 305, 306, 106,
1598 106, 60, 106, 106, 106, 104, 107, 34, 104, 24,
1599 108, 104, 293, 294, 295, 296, 297, 298, 299, 300,
1600 262, 21, 21, 304, 4, 104, 104, 104, 374, 104,
1601 104, 24, 104, 4, 342, 106, 344, 104, 104, 104,
1602 348, 36, 398, 399, 400, 54, 106, 4, 24, 357,
1603 358, 359, 333, 104, 104, 104, 104, 104, 104, 104,
1604 104, 104, 54, 104, 345, 411, 412, 413, 414, 104,
1605 416, 417, 418, 419, 430, 104, 107, 107, 104, 107,
1606 388, 389, 363, 108, 107, 104, 110, 451, 396, 451,
1607 107, 104, 104, 107, 21, 36, 107, 405, 21, 107,
1608 107, 104, 107, 107, 110, 469, 107, 469, 21, 390,
1609 193, 194, 458, 104, 460, 461, 70, 398, 399, 400,
1610 21, 21, 205, 404, 432, 0, 0, 210, 34, 410,
1611 85, 20, 85, 85, 85, 334, 106, 47, 221, 222,
1612 223, 20, 178, 22, 333, 24, 44, 23, 2, 430,
1613 14, 404, 31, 32, 33, 345, 368, -1, 466, -1,
1614 5, 6, 41, 42, 43, 44, -1, -1, 47, 48,
1615 -1, 479, -1, -1, -1, -1, 55, 22, 486, 24,
1616 59, 26, 490, 491, -1, -1, -1, -1, -1, -1,
1617 -1, -1, -1, 38, 39, -1, -1, -1, -1, -1,
1618 -1, -1, 285, -1, -1, -1, -1, -1, 291, -1,
Chris Lattnerd25db202006-04-08 03:55:17 +00001619 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattner75466192006-05-19 21:28:53 +00001620 -1, -1, 305, 306, -1, -1, -1, 72, 73, 74,
1621 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1622 85, -1, -1, -1, -1, -1, 91, -1, 93, 94,
1623 95, 96, -1, 98, 99, 100, -1, -1, -1, 342,
1624 -1, 344, -1, 108, -1, 348, 111, -1, 113, -1,
1625 -1, 116, -1, -1, 357, 358, 359, -1, 5, 6,
1626 -1, 8, 9, 10, 11, 12, 13, 14, 15, 16,
Chris Lattnerd25db202006-04-08 03:55:17 +00001627 17, 18, 19, 20, 21, 22, -1, 24, -1, -1,
Chris Lattner75466192006-05-19 21:28:53 +00001628 -1, -1, -1, -1, -1, 388, 389, -1, -1, -1,
1629 -1, -1, -1, 396, -1, -1, -1, -1, 45, -1,
1630 5, 6, 405, 8, 9, 10, 11, 12, 13, 14,
1631 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
1632 -1, -1, -1, -1, -1, -1, -1, -1, -1, 432,
Chris Lattnerd25db202006-04-08 03:55:17 +00001633 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattner75466192006-05-19 21:28:53 +00001634 45, -1, -1, -1, -1, -1, -1, -1, -1, 3,
1635 4, 5, 6, 7, -1, -1, -1, -1, 105, -1,
1636 -1, 108, -1, 466, 111, -1, 113, 114, 22, -1,
1637 24, -1, 26, 27, 28, -1, 479, -1, -1, -1,
1638 -1, -1, -1, 486, 38, 39, -1, 490, 491, -1,
Chris Lattnerd25db202006-04-08 03:55:17 +00001639 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattner75466192006-05-19 21:28:53 +00001640 105, -1, -1, 108, 58, -1, 111, -1, 113, 114,
1641 -1, -1, -1, -1, -1, -1, -1, -1, 72, 73,
Chris Lattnerd25db202006-04-08 03:55:17 +00001642 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
Chris Lattner75466192006-05-19 21:28:53 +00001643 84, 85, -1, -1, -1, -1, -1, 91, -1, 93,
1644 94, 95, 96, -1, 98, 99, 100, 3, 4, -1,
1645 -1, 7, -1, -1, -1, -1, -1, 111, -1, -1,
1646 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1647 26, 27, 28, -1, -1, -1, -1, -1, -1, -1,
1648 -1, -1, 38, 39, -1, -1, -1, -1, -1, -1,
1649 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1650 -1, -1, 58, -1, -1, -1, -1, -1, -1, -1,
1651 -1, -1, -1, -1, -1, -1, 72, 73, 74, 75,
1652 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
1653 -1, -1, -1, -1, -1, 91, -1, 93, 94, 95,
1654 96, -1, 98, 99, 100, -1, -1, -1, -1, -1,
1655 -1, -1, -1, 5, 6, 111, 8, 9, 10, 11,
1656 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
1657 22, -1, 24, -1, -1, -1, -1, -1, -1, -1,
1658 -1, -1, -1, -1, -1, 37, -1, -1, -1, -1,
1659 -1, 5, 6, 45, 8, 9, 10, 11, 12, 13,
1660 14, 15, 16, 17, 18, 19, 20, 21, 22, -1,
1661 24, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1662 -1, -1, -1, 37, -1, -1, -1, -1, -1, 5,
1663 6, 45, 8, 9, 10, 11, 12, 13, 14, 15,
1664 16, 17, 18, 19, 20, 21, 22, -1, 24, -1,
1665 -1, -1, -1, 105, -1, -1, 108, -1, -1, 111,
1666 -1, 113, -1, -1, -1, -1, -1, -1, -1, 45,
1667 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
Chris Lattnerd25db202006-04-08 03:55:17 +00001668 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
Chris Lattner75466192006-05-19 21:28:53 +00001669 -1, 105, -1, -1, 108, -1, -1, 111, -1, 113,
1670 -1, -1, 37, -1, -1, -1, -1, -1, 5, 6,
Chris Lattnerd25db202006-04-08 03:55:17 +00001671 45, 8, 9, 10, 11, 12, 13, 14, 15, 16,
Chris Lattner75466192006-05-19 21:28:53 +00001672 17, 18, 19, 20, 21, 22, -1, 24, -1, 105,
1673 -1, -1, 108, -1, 110, 111, -1, 113, -1, -1,
Chris Lattnerd25db202006-04-08 03:55:17 +00001674 37, -1, -1, -1, -1, -1, 5, 6, 45, 8,
1675 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
Chris Lattner75466192006-05-19 21:28:53 +00001676 19, 20, 21, 22, -1, 24, -1, -1, -1, -1,
1677 105, -1, -1, 108, -1, -1, 111, -1, 113, -1,
Chris Lattnerd25db202006-04-08 03:55:17 +00001678 -1, -1, -1, -1, 5, 6, 45, 8, 9, 10,
1679 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
Chris Lattner75466192006-05-19 21:28:53 +00001680 21, 22, -1, 24, -1, -1, -1, -1, 105, -1,
1681 -1, 108, -1, -1, 111, -1, 113, -1, -1, -1,
Chris Lattnerd25db202006-04-08 03:55:17 +00001682 -1, -1, 5, 6, 45, 8, 9, 10, 11, 12,
1683 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
Chris Lattner75466192006-05-19 21:28:53 +00001684 -1, 24, -1, -1, -1, -1, 105, -1, -1, 108,
1685 -1, -1, 111, -1, 113, -1, -1, -1, -1, -1,
Chris Lattnerd25db202006-04-08 03:55:17 +00001686 5, 6, 45, 8, 9, 10, 11, 12, 13, 14,
1687 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
Chris Lattner75466192006-05-19 21:28:53 +00001688 -1, -1, -1, -1, 105, -1, -1, 108, -1, -1,
1689 111, -1, 113, -1, -1, -1, -1, -1, -1, -1,
1690 45, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001691 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattner75466192006-05-19 21:28:53 +00001692 -1, -1, 105, -1, -1, 108, -1, -1, 111, -1,
1693 113, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1694 35, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1695 -1, 46, -1, -1, -1, -1, -1, -1, -1, -1,
1696 105, 56, 57, 108, -1, -1, 111, -1, 113, -1,
1697 -1, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1698 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1699 85, 86, 87, 88, -1, -1, 91, 92, 93, 94,
1700 95, 96, 97, 98, 99, 100, 101, 102
Chris Lattner8335e842006-01-23 23:05:42 +00001701};
1702/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
1703#line 3 "/usr/share/bison.simple"
1704/* This file comes from bison-1.28. */
1705
1706/* Skeleton output parser for bison,
1707 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
1708
1709 This program is free software; you can redistribute it and/or modify
1710 it under the terms of the GNU General Public License as published by
1711 the Free Software Foundation; either version 2, or (at your option)
1712 any later version.
1713
1714 This program is distributed in the hope that it will be useful,
1715 but WITHOUT ANY WARRANTY; without even the implied warranty of
1716 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1717 GNU General Public License for more details.
1718
1719 You should have received a copy of the GNU General Public License
1720 along with this program; if not, write to the Free Software
1721 Foundation, Inc., 59 Temple Place - Suite 330,
1722 Boston, MA 02111-1307, USA. */
1723
1724/* As a special exception, when this file is copied by Bison into a
1725 Bison output file, you may use that output file without restriction.
1726 This special exception was added by the Free Software Foundation
1727 in version 1.24 of Bison. */
1728
1729/* This is the parser code that is written into each bison parser
1730 when the %semantic_parser declaration is not specified in the grammar.
1731 It was written by Richard Stallman by simplifying the hairy parser
1732 used when %semantic_parser is specified. */
1733
1734#ifndef YYSTACK_USE_ALLOCA
1735#ifdef alloca
1736#define YYSTACK_USE_ALLOCA
1737#else /* alloca not defined */
1738#ifdef __GNUC__
1739#define YYSTACK_USE_ALLOCA
1740#define alloca __builtin_alloca
1741#else /* not GNU C. */
1742#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
1743#define YYSTACK_USE_ALLOCA
1744#include <alloca.h>
1745#else /* not sparc */
1746/* We think this test detects Watcom and Microsoft C. */
1747/* This used to test MSDOS, but that is a bad idea
1748 since that symbol is in the user namespace. */
1749#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
1750#if 0 /* No need for malloc.h, which pollutes the namespace;
1751 instead, just don't use alloca. */
1752#include <malloc.h>
1753#endif
1754#else /* not MSDOS, or __TURBOC__ */
1755#if defined(_AIX)
1756/* I don't know what this was needed for, but it pollutes the namespace.
1757 So I turned it off. rms, 2 May 1997. */
1758/* #include <malloc.h> */
1759 #pragma alloca
1760#define YYSTACK_USE_ALLOCA
1761#else /* not MSDOS, or __TURBOC__, or _AIX */
1762#if 0
1763#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
1764 and on HPUX 10. Eventually we can turn this on. */
1765#define YYSTACK_USE_ALLOCA
1766#define alloca __builtin_alloca
1767#endif /* __hpux */
1768#endif
1769#endif /* not _AIX */
1770#endif /* not MSDOS, or __TURBOC__ */
1771#endif /* not sparc */
1772#endif /* not GNU C */
1773#endif /* alloca not defined */
1774#endif /* YYSTACK_USE_ALLOCA not defined */
1775
1776#ifdef YYSTACK_USE_ALLOCA
1777#define YYSTACK_ALLOC alloca
Reid Spencer68a24bd2005-08-27 18:50:39 +00001778#else
Chris Lattner8335e842006-01-23 23:05:42 +00001779#define YYSTACK_ALLOC malloc
Reid Spencer68a24bd2005-08-27 18:50:39 +00001780#endif
1781
Chris Lattner8335e842006-01-23 23:05:42 +00001782/* Note: there must be only one dollar sign in this file.
1783 It is replaced by the list of actions, each action
1784 as one case of the switch. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001785
1786#define yyerrok (yyerrstatus = 0)
1787#define yyclearin (yychar = YYEMPTY)
Chris Lattner8335e842006-01-23 23:05:42 +00001788#define YYEMPTY -2
Reid Spencer68a24bd2005-08-27 18:50:39 +00001789#define YYEOF 0
Reid Spencer68a24bd2005-08-27 18:50:39 +00001790#define YYACCEPT goto yyacceptlab
Chris Lattner8335e842006-01-23 23:05:42 +00001791#define YYABORT goto yyabortlab
1792#define YYERROR goto yyerrlab1
1793/* Like YYERROR except do call yyerror.
1794 This remains here temporarily to ease the
1795 transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00001796 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001797#define YYFAIL goto yyerrlab
Reid Spencer68a24bd2005-08-27 18:50:39 +00001798#define YYRECOVERING() (!!yyerrstatus)
Chris Lattner8335e842006-01-23 23:05:42 +00001799#define YYBACKUP(token, value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00001800do \
1801 if (yychar == YYEMPTY && yylen == 1) \
Chris Lattner8335e842006-01-23 23:05:42 +00001802 { yychar = (token), yylval = (value); \
1803 yychar1 = YYTRANSLATE (yychar); \
Reid Spencer68a24bd2005-08-27 18:50:39 +00001804 YYPOPSTACK; \
1805 goto yybackup; \
1806 } \
1807 else \
Chris Lattner8335e842006-01-23 23:05:42 +00001808 { yyerror ("syntax error: cannot back up"); YYERROR; } \
Reid Spencer68a24bd2005-08-27 18:50:39 +00001809while (0)
1810
1811#define YYTERROR 1
1812#define YYERRCODE 256
1813
Chris Lattner8335e842006-01-23 23:05:42 +00001814#ifndef YYPURE
1815#define YYLEX yylex()
Reid Spencer68a24bd2005-08-27 18:50:39 +00001816#endif
1817
Chris Lattner8335e842006-01-23 23:05:42 +00001818#ifdef YYPURE
1819#ifdef YYLSP_NEEDED
Reid Spencer68a24bd2005-08-27 18:50:39 +00001820#ifdef YYLEX_PARAM
Chris Lattner8335e842006-01-23 23:05:42 +00001821#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001822#else
Chris Lattner8335e842006-01-23 23:05:42 +00001823#define YYLEX yylex(&yylval, &yylloc)
1824#endif
1825#else /* not YYLSP_NEEDED */
1826#ifdef YYLEX_PARAM
1827#define YYLEX yylex(&yylval, YYLEX_PARAM)
1828#else
1829#define YYLEX yylex(&yylval)
1830#endif
1831#endif /* not YYLSP_NEEDED */
Robert Bocchino2def1b32006-01-17 20:06:25 +00001832#endif
Reid Spencere812fb22006-01-19 01:21:04 +00001833
Chris Lattner8335e842006-01-23 23:05:42 +00001834/* If nonreentrant, generate the variables here */
Reid Spencere812fb22006-01-19 01:21:04 +00001835
Chris Lattner8335e842006-01-23 23:05:42 +00001836#ifndef YYPURE
Reid Spencere812fb22006-01-19 01:21:04 +00001837
Chris Lattner8335e842006-01-23 23:05:42 +00001838int yychar; /* the lookahead symbol */
1839YYSTYPE yylval; /* the semantic value of the */
1840 /* lookahead symbol */
Reid Spencere812fb22006-01-19 01:21:04 +00001841
Chris Lattner8335e842006-01-23 23:05:42 +00001842#ifdef YYLSP_NEEDED
1843YYLTYPE yylloc; /* location data for the lookahead */
1844 /* symbol */
Robert Bocchino2def1b32006-01-17 20:06:25 +00001845#endif
Reid Spencere812fb22006-01-19 01:21:04 +00001846
Chris Lattner8335e842006-01-23 23:05:42 +00001847int yynerrs; /* number of parse errors so far */
1848#endif /* not YYPURE */
Reid Spencere812fb22006-01-19 01:21:04 +00001849
Chris Lattner8335e842006-01-23 23:05:42 +00001850#if YYDEBUG != 0
1851int yydebug; /* nonzero means print parse trace */
1852/* Since this is uninitialized, it does not stop multiple parsers
1853 from coexisting. */
Nate Begeman14b05292005-11-05 09:21:28 +00001854#endif
Reid Spencer0b118202006-01-16 21:12:35 +00001855
Chris Lattner8335e842006-01-23 23:05:42 +00001856/* YYINITDEPTH indicates the initial size of the parser's stacks */
Reid Spencer0b118202006-01-16 21:12:35 +00001857
Reid Spencer68a24bd2005-08-27 18:50:39 +00001858#ifndef YYINITDEPTH
Chris Lattner8335e842006-01-23 23:05:42 +00001859#define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00001860#endif
1861
Chris Lattner8335e842006-01-23 23:05:42 +00001862/* YYMAXDEPTH is the maximum size the stacks can grow to
1863 (effective only if the built-in stack extension method is used). */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001864
Chris Lattner8335e842006-01-23 23:05:42 +00001865#if YYMAXDEPTH == 0
1866#undef YYMAXDEPTH
Reid Spencer68a24bd2005-08-27 18:50:39 +00001867#endif
1868
1869#ifndef YYMAXDEPTH
Chris Lattner8335e842006-01-23 23:05:42 +00001870#define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00001871#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001872
Chris Lattner8335e842006-01-23 23:05:42 +00001873/* Define __yy_memcpy. Note that the size argument
1874 should be passed with type unsigned int, because that is what the non-GCC
1875 definitions require. With GCC, __builtin_memcpy takes an arg
1876 of type size_t, but it can handle unsigned int. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001877
Chris Lattner8335e842006-01-23 23:05:42 +00001878#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
1879#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
1880#else /* not GNU C or C++ */
1881#ifndef __cplusplus
Reid Spencer68a24bd2005-08-27 18:50:39 +00001882
Chris Lattner8335e842006-01-23 23:05:42 +00001883/* This is the most reliable way to avoid incompatibilities
1884 in available built-in functions on various systems. */
Reid Spencere812fb22006-01-19 01:21:04 +00001885static void
Chris Lattner8335e842006-01-23 23:05:42 +00001886__yy_memcpy (to, from, count)
1887 char *to;
1888 char *from;
1889 unsigned int count;
1890{
1891 register char *f = from;
1892 register char *t = to;
1893 register int i = count;
1894
1895 while (i-- > 0)
1896 *t++ = *f++;
1897}
1898
1899#else /* __cplusplus */
1900
1901/* This is the most reliable way to avoid incompatibilities
1902 in available built-in functions on various systems. */
Reid Spencere812fb22006-01-19 01:21:04 +00001903static void
Chris Lattner8335e842006-01-23 23:05:42 +00001904__yy_memcpy (char *to, char *from, unsigned int count)
1905{
1906 register char *t = to;
1907 register char *f = from;
1908 register int i = count;
1909
1910 while (i-- > 0)
1911 *t++ = *f++;
1912}
1913
Reid Spencer0b118202006-01-16 21:12:35 +00001914#endif
Reid Spencere812fb22006-01-19 01:21:04 +00001915#endif
Reid Spencere812fb22006-01-19 01:21:04 +00001916
Chris Lattner8335e842006-01-23 23:05:42 +00001917#line 217 "/usr/share/bison.simple"
Reid Spencere812fb22006-01-19 01:21:04 +00001918
Chris Lattner8335e842006-01-23 23:05:42 +00001919/* The user can define YYPARSE_PARAM as the name of an argument to be passed
1920 into yyparse. The argument should have type void *.
1921 It should actually point to an object.
1922 Grammar actions can access the variable by casting it
1923 to the proper pointer type. */
Reid Spencere812fb22006-01-19 01:21:04 +00001924
1925#ifdef YYPARSE_PARAM
Chris Lattner8335e842006-01-23 23:05:42 +00001926#ifdef __cplusplus
1927#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
1928#define YYPARSE_PARAM_DECL
1929#else /* not __cplusplus */
1930#define YYPARSE_PARAM_ARG YYPARSE_PARAM
1931#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
1932#endif /* not __cplusplus */
1933#else /* not YYPARSE_PARAM */
1934#define YYPARSE_PARAM_ARG
1935#define YYPARSE_PARAM_DECL
1936#endif /* not YYPARSE_PARAM */
1937
1938/* Prevent warning if -Wstrict-prototypes. */
1939#ifdef __GNUC__
1940#ifdef YYPARSE_PARAM
1941int yyparse (void *);
1942#else
Reid Spencere812fb22006-01-19 01:21:04 +00001943int yyparse (void);
Reid Spencere812fb22006-01-19 01:21:04 +00001944#endif
Chris Lattner8335e842006-01-23 23:05:42 +00001945#endif
Reid Spencere812fb22006-01-19 01:21:04 +00001946
Reid Spencere812fb22006-01-19 01:21:04 +00001947int
Chris Lattner8335e842006-01-23 23:05:42 +00001948yyparse(YYPARSE_PARAM_ARG)
1949 YYPARSE_PARAM_DECL
Reid Spencere812fb22006-01-19 01:21:04 +00001950{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001951 register int yystate;
1952 register int yyn;
Nate Begeman14b05292005-11-05 09:21:28 +00001953 register short *yyssp;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001954 register YYSTYPE *yyvsp;
Chris Lattner8335e842006-01-23 23:05:42 +00001955 int yyerrstatus; /* number of tokens to shift before error messages enabled */
1956 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001957
Chris Lattner8335e842006-01-23 23:05:42 +00001958 short yyssa[YYINITDEPTH]; /* the state stack */
1959 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001960
Chris Lattner8335e842006-01-23 23:05:42 +00001961 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
1962 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001963
Chris Lattner8335e842006-01-23 23:05:42 +00001964#ifdef YYLSP_NEEDED
1965 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
1966 YYLTYPE *yyls = yylsa;
1967 YYLTYPE *yylsp;
1968
1969#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
1970#else
Reid Spencer68a24bd2005-08-27 18:50:39 +00001971#define YYPOPSTACK (yyvsp--, yyssp--)
Chris Lattner8335e842006-01-23 23:05:42 +00001972#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001973
Chris Lattner8335e842006-01-23 23:05:42 +00001974 int yystacksize = YYINITDEPTH;
1975 int yyfree_stacks = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001976
Chris Lattner8335e842006-01-23 23:05:42 +00001977#ifdef YYPURE
1978 int yychar;
1979 YYSTYPE yylval;
1980 int yynerrs;
1981#ifdef YYLSP_NEEDED
1982 YYLTYPE yylloc;
1983#endif
1984#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001985
Chris Lattner8335e842006-01-23 23:05:42 +00001986 YYSTYPE yyval; /* the variable used to return */
1987 /* semantic values from the action */
1988 /* routines */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001989
Reid Spencer68a24bd2005-08-27 18:50:39 +00001990 int yylen;
1991
Chris Lattner8335e842006-01-23 23:05:42 +00001992#if YYDEBUG != 0
1993 if (yydebug)
1994 fprintf(stderr, "Starting parse\n");
1995#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001996
1997 yystate = 0;
1998 yyerrstatus = 0;
1999 yynerrs = 0;
2000 yychar = YYEMPTY; /* Cause a token to be read. */
2001
2002 /* Initialize stack pointers.
2003 Waste one element of value and location stack
2004 so that they stay on the same level as the state stack.
2005 The wasted elements are never initialized. */
2006
Chris Lattner8335e842006-01-23 23:05:42 +00002007 yyssp = yyss - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002008 yyvsp = yyvs;
Chris Lattner8335e842006-01-23 23:05:42 +00002009#ifdef YYLSP_NEEDED
2010 yylsp = yyls;
2011#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002012
Chris Lattner8335e842006-01-23 23:05:42 +00002013/* Push a new state, which is found in yystate . */
2014/* In all cases, when you get here, the value and location stacks
2015 have just been pushed. so pushing a state here evens the stacks. */
2016yynewstate:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002017
Chris Lattner8335e842006-01-23 23:05:42 +00002018 *++yyssp = yystate;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002019
Chris Lattner8335e842006-01-23 23:05:42 +00002020 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002021 {
Chris Lattner8335e842006-01-23 23:05:42 +00002022 /* Give user a chance to reallocate the stack */
2023 /* Use copies of these so that the &'s don't force the real ones into memory. */
2024 YYSTYPE *yyvs1 = yyvs;
2025 short *yyss1 = yyss;
2026#ifdef YYLSP_NEEDED
2027 YYLTYPE *yyls1 = yyls;
2028#endif
2029
Reid Spencer68a24bd2005-08-27 18:50:39 +00002030 /* Get the current used size of the three stacks, in elements. */
Chris Lattner8335e842006-01-23 23:05:42 +00002031 int size = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002032
2033#ifdef yyoverflow
Chris Lattner8335e842006-01-23 23:05:42 +00002034 /* Each stack pointer address is followed by the size of
2035 the data in use in that stack, in bytes. */
2036#ifdef YYLSP_NEEDED
2037 /* This used to be a conditional around just the two extra args,
2038 but that might be undefined if yyoverflow is a macro. */
2039 yyoverflow("parser stack overflow",
2040 &yyss1, size * sizeof (*yyssp),
2041 &yyvs1, size * sizeof (*yyvsp),
2042 &yyls1, size * sizeof (*yylsp),
2043 &yystacksize);
2044#else
2045 yyoverflow("parser stack overflow",
2046 &yyss1, size * sizeof (*yyssp),
2047 &yyvs1, size * sizeof (*yyvsp),
2048 &yystacksize);
2049#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002050
Chris Lattner8335e842006-01-23 23:05:42 +00002051 yyss = yyss1; yyvs = yyvs1;
2052#ifdef YYLSP_NEEDED
2053 yyls = yyls1;
2054#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002055#else /* no yyoverflow */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002056 /* Extend the stack our own way. */
Chris Lattner8335e842006-01-23 23:05:42 +00002057 if (yystacksize >= YYMAXDEPTH)
2058 {
2059 yyerror("parser stack overflow");
2060 if (yyfree_stacks)
2061 {
2062 free (yyss);
2063 free (yyvs);
2064#ifdef YYLSP_NEEDED
2065 free (yyls);
2066#endif
2067 }
2068 return 2;
2069 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002070 yystacksize *= 2;
Chris Lattner8335e842006-01-23 23:05:42 +00002071 if (yystacksize > YYMAXDEPTH)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002072 yystacksize = YYMAXDEPTH;
Chris Lattner8335e842006-01-23 23:05:42 +00002073#ifndef YYSTACK_USE_ALLOCA
2074 yyfree_stacks = 1;
2075#endif
2076 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
2077 __yy_memcpy ((char *)yyss, (char *)yyss1,
2078 size * (unsigned int) sizeof (*yyssp));
2079 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
2080 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
2081 size * (unsigned int) sizeof (*yyvsp));
2082#ifdef YYLSP_NEEDED
2083 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
2084 __yy_memcpy ((char *)yyls, (char *)yyls1,
2085 size * (unsigned int) sizeof (*yylsp));
2086#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002087#endif /* no yyoverflow */
2088
Chris Lattner8335e842006-01-23 23:05:42 +00002089 yyssp = yyss + size - 1;
2090 yyvsp = yyvs + size - 1;
2091#ifdef YYLSP_NEEDED
2092 yylsp = yyls + size - 1;
2093#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002094
Chris Lattner8335e842006-01-23 23:05:42 +00002095#if YYDEBUG != 0
2096 if (yydebug)
2097 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2098#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002099
Chris Lattner8335e842006-01-23 23:05:42 +00002100 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002101 YYABORT;
2102 }
2103
Chris Lattner8335e842006-01-23 23:05:42 +00002104#if YYDEBUG != 0
2105 if (yydebug)
2106 fprintf(stderr, "Entering state %d\n", yystate);
2107#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002108
2109 goto yybackup;
Chris Lattner8335e842006-01-23 23:05:42 +00002110 yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002111
2112/* Do appropriate processing given the current state. */
2113/* Read a lookahead token if we need one and don't already have one. */
2114/* yyresume: */
2115
2116 /* First try to decide what to do without reference to lookahead token. */
2117
2118 yyn = yypact[yystate];
Chris Lattner8335e842006-01-23 23:05:42 +00002119 if (yyn == YYFLAG)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002120 goto yydefault;
2121
2122 /* Not known => get a lookahead token if don't already have one. */
2123
Chris Lattner8335e842006-01-23 23:05:42 +00002124 /* yychar is either YYEMPTY or YYEOF
2125 or a valid token in external form. */
2126
Reid Spencer68a24bd2005-08-27 18:50:39 +00002127 if (yychar == YYEMPTY)
2128 {
Chris Lattner8335e842006-01-23 23:05:42 +00002129#if YYDEBUG != 0
2130 if (yydebug)
2131 fprintf(stderr, "Reading a token: ");
2132#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002133 yychar = YYLEX;
2134 }
2135
Chris Lattner8335e842006-01-23 23:05:42 +00002136 /* Convert token to internal form (in yychar1) for indexing tables with */
2137
2138 if (yychar <= 0) /* This means end of input. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002139 {
Chris Lattner8335e842006-01-23 23:05:42 +00002140 yychar1 = 0;
2141 yychar = YYEOF; /* Don't call YYLEX any more */
2142
2143#if YYDEBUG != 0
2144 if (yydebug)
2145 fprintf(stderr, "Now at end of input.\n");
2146#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002147 }
2148 else
2149 {
Chris Lattner8335e842006-01-23 23:05:42 +00002150 yychar1 = YYTRANSLATE(yychar);
2151
2152#if YYDEBUG != 0
2153 if (yydebug)
2154 {
2155 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2156 /* Give the individual parser a way to print the precise meaning
2157 of a token, for further debugging info. */
2158#ifdef YYPRINT
2159 YYPRINT (stderr, yychar, yylval);
2160#endif
2161 fprintf (stderr, ")\n");
2162 }
2163#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002164 }
2165
Chris Lattner8335e842006-01-23 23:05:42 +00002166 yyn += yychar1;
2167 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002168 goto yydefault;
Chris Lattner8335e842006-01-23 23:05:42 +00002169
Reid Spencer68a24bd2005-08-27 18:50:39 +00002170 yyn = yytable[yyn];
Chris Lattner8335e842006-01-23 23:05:42 +00002171
2172 /* yyn is what to do for this token type in this state.
2173 Negative => reduce, -yyn is rule number.
2174 Positive => shift, yyn is new state.
2175 New state is final state => don't bother to shift,
2176 just return success.
2177 0, or most negative number => error. */
2178
2179 if (yyn < 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002180 {
Chris Lattner8335e842006-01-23 23:05:42 +00002181 if (yyn == YYFLAG)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002182 goto yyerrlab;
2183 yyn = -yyn;
2184 goto yyreduce;
2185 }
Chris Lattner8335e842006-01-23 23:05:42 +00002186 else if (yyn == 0)
2187 goto yyerrlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002188
2189 if (yyn == YYFINAL)
2190 YYACCEPT;
2191
2192 /* Shift the lookahead token. */
Chris Lattner8335e842006-01-23 23:05:42 +00002193
2194#if YYDEBUG != 0
2195 if (yydebug)
2196 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2197#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002198
2199 /* Discard the token being shifted unless it is eof. */
2200 if (yychar != YYEOF)
2201 yychar = YYEMPTY;
2202
2203 *++yyvsp = yylval;
Chris Lattner8335e842006-01-23 23:05:42 +00002204#ifdef YYLSP_NEEDED
2205 *++yylsp = yylloc;
2206#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002207
Chris Lattner8335e842006-01-23 23:05:42 +00002208 /* count tokens shifted since error; after three, turn off error status. */
2209 if (yyerrstatus) yyerrstatus--;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002210
2211 yystate = yyn;
2212 goto yynewstate;
2213
Chris Lattner8335e842006-01-23 23:05:42 +00002214/* Do the default action for the current state. */
Reid Spencere812fb22006-01-19 01:21:04 +00002215yydefault:
Chris Lattner8335e842006-01-23 23:05:42 +00002216
Reid Spencer68a24bd2005-08-27 18:50:39 +00002217 yyn = yydefact[yystate];
2218 if (yyn == 0)
2219 goto yyerrlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002220
Chris Lattner8335e842006-01-23 23:05:42 +00002221/* Do a reduction. yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002222yyreduce:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002223 yylen = yyr2[yyn];
Chris Lattner8335e842006-01-23 23:05:42 +00002224 if (yylen > 0)
2225 yyval = yyvsp[1-yylen]; /* implement default value of the action */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002226
Chris Lattner8335e842006-01-23 23:05:42 +00002227#if YYDEBUG != 0
2228 if (yydebug)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002229 {
Chris Lattner8335e842006-01-23 23:05:42 +00002230 int i;
2231
2232 fprintf (stderr, "Reducing via rule %d (line %d), ",
2233 yyn, yyrline[yyn]);
2234
2235 /* Print the symbols being reduced, and their result. */
2236 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2237 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2238 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2239 }
2240#endif
2241
2242
2243 switch (yyn) {
2244
2245case 2:
Chris Lattner0ad19702006-06-21 16:53:00 +00002246#line 1011 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002247{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002248 if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX) // Outside of my range!
2249 ThrowException("Value too large for type!");
2250 yyval.SIntVal = (int32_t)yyvsp[0].UIntVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002251;
2252 break;}
2253case 4:
Chris Lattner0ad19702006-06-21 16:53:00 +00002254#line 1019 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002255{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002256 if (yyvsp[0].UInt64Val > (uint64_t)INT64_MAX) // Outside of my range!
2257 ThrowException("Value too large for type!");
2258 yyval.SInt64Val = (int64_t)yyvsp[0].UInt64Val;
Chris Lattner8335e842006-01-23 23:05:42 +00002259;
2260 break;}
2261case 33:
Chris Lattner0ad19702006-06-21 16:53:00 +00002262#line 1042 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002263{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002264 yyval.StrVal = yyvsp[-1].StrVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002265 ;
2266 break;}
2267case 34:
Chris Lattner0ad19702006-06-21 16:53:00 +00002268#line 1045 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002269{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002270 yyval.StrVal = 0;
Chris Lattner8335e842006-01-23 23:05:42 +00002271 ;
2272 break;}
2273case 35:
Chris Lattner0ad19702006-06-21 16:53:00 +00002274#line 1049 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002275{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2276 break;}
2277case 36:
Chris Lattner0ad19702006-06-21 16:53:00 +00002278#line 1050 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002279{ yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2280 break;}
2281case 37:
Chris Lattner0ad19702006-06-21 16:53:00 +00002282#line 1051 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002283{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2284 break;}
2285case 38:
Chris Lattner0ad19702006-06-21 16:53:00 +00002286#line 1052 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002287{ yyval.Linkage = GlobalValue::AppendingLinkage; ;
2288 break;}
2289case 39:
Chris Lattner0ad19702006-06-21 16:53:00 +00002290#line 1053 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002291{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2292 break;}
2293case 40:
Chris Lattner0ad19702006-06-21 16:53:00 +00002294#line 1055 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002295{ yyval.UIntVal = CallingConv::C; ;
2296 break;}
2297case 41:
Chris Lattner0ad19702006-06-21 16:53:00 +00002298#line 1056 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002299{ yyval.UIntVal = CallingConv::C; ;
2300 break;}
2301case 42:
Chris Lattner0ad19702006-06-21 16:53:00 +00002302#line 1057 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner75466192006-05-19 21:28:53 +00002303{ yyval.UIntVal = CallingConv::CSRet; ;
Chris Lattner8335e842006-01-23 23:05:42 +00002304 break;}
2305case 43:
Chris Lattner0ad19702006-06-21 16:53:00 +00002306#line 1058 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner75466192006-05-19 21:28:53 +00002307{ yyval.UIntVal = CallingConv::Fast; ;
Chris Lattner8335e842006-01-23 23:05:42 +00002308 break;}
2309case 44:
Chris Lattner0ad19702006-06-21 16:53:00 +00002310#line 1059 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner75466192006-05-19 21:28:53 +00002311{ yyval.UIntVal = CallingConv::Cold; ;
2312 break;}
2313case 45:
Chris Lattner0ad19702006-06-21 16:53:00 +00002314#line 1060 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002315{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002316 if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
2317 ThrowException("Calling conv too large!");
2318 yyval.UIntVal = yyvsp[0].UInt64Val;
Chris Lattner8335e842006-01-23 23:05:42 +00002319 ;
2320 break;}
Chris Lattner8335e842006-01-23 23:05:42 +00002321case 46:
Chris Lattner0ad19702006-06-21 16:53:00 +00002322#line 1068 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner75466192006-05-19 21:28:53 +00002323{ yyval.UIntVal = 0; ;
Chris Lattner8335e842006-01-23 23:05:42 +00002324 break;}
2325case 47:
Chris Lattner0ad19702006-06-21 16:53:00 +00002326#line 1069 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002327{
Chris Lattnerb475c422005-11-12 18:22:38 +00002328 yyval.UIntVal = yyvsp[0].UInt64Val;
2329 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
2330 ThrowException("Alignment must be a power of two!");
Chris Lattner8335e842006-01-23 23:05:42 +00002331;
2332 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002333case 48:
Chris Lattner0ad19702006-06-21 16:53:00 +00002334#line 1074 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner75466192006-05-19 21:28:53 +00002335{ yyval.UIntVal = 0; ;
2336 break;}
Chris Lattner8335e842006-01-23 23:05:42 +00002337case 49:
Chris Lattner0ad19702006-06-21 16:53:00 +00002338#line 1075 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner75466192006-05-19 21:28:53 +00002339{
2340 yyval.UIntVal = yyvsp[0].UInt64Val;
2341 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
2342 ThrowException("Alignment must be a power of two!");
2343;
2344 break;}
2345case 50:
Chris Lattner0ad19702006-06-21 16:53:00 +00002346#line 1082 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002347{
Chris Lattnere869eef2005-11-12 00:11:49 +00002348 for (unsigned i = 0, e = strlen(yyvsp[0].StrVal); i != e; ++i)
2349 if (yyvsp[0].StrVal[i] == '"' || yyvsp[0].StrVal[i] == '\\')
2350 ThrowException("Invalid character in section name!");
2351 yyval.StrVal = yyvsp[0].StrVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002352;
2353 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002354case 51:
Chris Lattner0ad19702006-06-21 16:53:00 +00002355#line 1089 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002356{ yyval.StrVal = 0; ;
2357 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002358case 52:
Chris Lattner0ad19702006-06-21 16:53:00 +00002359#line 1090 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002360{ yyval.StrVal = yyvsp[0].StrVal; ;
2361 break;}
Chris Lattner8335e842006-01-23 23:05:42 +00002362case 53:
Chris Lattner0ad19702006-06-21 16:53:00 +00002363#line 1095 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002364{;
2365 break;}
2366case 54:
Chris Lattner0ad19702006-06-21 16:53:00 +00002367#line 1096 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner75466192006-05-19 21:28:53 +00002368{;
2369 break;}
2370case 55:
Chris Lattner0ad19702006-06-21 16:53:00 +00002371#line 1097 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002372{
Chris Lattnerb475c422005-11-12 18:22:38 +00002373 CurGV->setSection(yyvsp[0].StrVal);
2374 free(yyvsp[0].StrVal);
Chris Lattner8335e842006-01-23 23:05:42 +00002375 ;
2376 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002377case 56:
Chris Lattner0ad19702006-06-21 16:53:00 +00002378#line 1101 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002379{
Chris Lattner7aa61892005-12-21 17:53:23 +00002380 if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val))
2381 ThrowException("Alignment must be a power of two!");
Chris Lattnerb475c422005-11-12 18:22:38 +00002382 CurGV->setAlignment(yyvsp[0].UInt64Val);
Chris Lattner8335e842006-01-23 23:05:42 +00002383 ;
2384 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002385case 58:
Chris Lattner0ad19702006-06-21 16:53:00 +00002386#line 1114 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002387{ yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2388 break;}
2389case 60:
Chris Lattner0ad19702006-06-21 16:53:00 +00002390#line 1115 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner75466192006-05-19 21:28:53 +00002391{ yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2392 break;}
2393case 61:
Chris Lattner0ad19702006-06-21 16:53:00 +00002394#line 1117 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002395{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002396 if (!UpRefs.empty())
2397 ThrowException("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
2398 yyval.TypeVal = yyvsp[0].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002399 ;
2400 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002401case 75:
Chris Lattner0ad19702006-06-21 16:53:00 +00002402#line 1128 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002403{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002404 yyval.TypeVal = new PATypeHolder(OpaqueType::get());
Chris Lattner8335e842006-01-23 23:05:42 +00002405 ;
2406 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002407case 76:
Chris Lattner0ad19702006-06-21 16:53:00 +00002408#line 1131 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002409{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002410 yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
Chris Lattner8335e842006-01-23 23:05:42 +00002411 ;
2412 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002413case 77:
Chris Lattner0ad19702006-06-21 16:53:00 +00002414#line 1134 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002415{ // Named types are also simple types...
Reid Spencer68a24bd2005-08-27 18:50:39 +00002416 yyval.TypeVal = new PATypeHolder(getTypeVal(yyvsp[0].ValIDVal));
Chris Lattner8335e842006-01-23 23:05:42 +00002417;
2418 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002419case 78:
Chris Lattner0ad19702006-06-21 16:53:00 +00002420#line 1140 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002421{ // Type UpReference
Reid Spencer68a24bd2005-08-27 18:50:39 +00002422 if (yyvsp[0].UInt64Val > (uint64_t)~0U) ThrowException("Value out of range!");
2423 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
2424 UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector...
2425 yyval.TypeVal = new PATypeHolder(OT);
2426 UR_OUT("New Upreference!\n");
Chris Lattner8335e842006-01-23 23:05:42 +00002427 ;
2428 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002429case 79:
Chris Lattner0ad19702006-06-21 16:53:00 +00002430#line 1147 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002431{ // Function derived type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002432 std::vector<const Type*> Params;
2433 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2434 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2435 Params.push_back(*I);
2436 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
2437 if (isVarArg) Params.pop_back();
2438
2439 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FunctionType::get(*yyvsp[-3].TypeVal,Params,isVarArg)));
2440 delete yyvsp[-1].TypeList; // Delete the argument list
2441 delete yyvsp[-3].TypeVal; // Delete the return type handle
Chris Lattner8335e842006-01-23 23:05:42 +00002442 ;
2443 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002444case 80:
Chris Lattner0ad19702006-06-21 16:53:00 +00002445#line 1159 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002446{ // Sized array type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002447 yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2448 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002449 ;
2450 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002451case 81:
Chris Lattner0ad19702006-06-21 16:53:00 +00002452#line 1163 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002453{ // Packed array type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002454 const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
Chris Lattner9547d7f2005-11-10 01:42:43 +00002455 if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002456 ThrowException("Unsigned result not equal to signed result");
Chris Lattner9547d7f2005-11-10 01:42:43 +00002457 if (!ElemTy->isPrimitiveType())
Reid Spencer68a24bd2005-08-27 18:50:39 +00002458 ThrowException("Elemental type of a PackedType must be primitive");
Chris Lattner9547d7f2005-11-10 01:42:43 +00002459 if (!isPowerOf2_32(yyvsp[-3].UInt64Val))
2460 ThrowException("Vector length should be a power of 2!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00002461 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PackedType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2462 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002463 ;
2464 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002465case 82:
Chris Lattner0ad19702006-06-21 16:53:00 +00002466#line 1174 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002467{ // Structure type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002468 std::vector<const Type*> Elements;
2469 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2470 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2471 Elements.push_back(*I);
2472
2473 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
2474 delete yyvsp[-1].TypeList;
Chris Lattner8335e842006-01-23 23:05:42 +00002475 ;
2476 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002477case 83:
Chris Lattner0ad19702006-06-21 16:53:00 +00002478#line 1183 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002479{ // Empty structure type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002480 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Chris Lattner8335e842006-01-23 23:05:42 +00002481 ;
2482 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002483case 84:
Chris Lattner0ad19702006-06-21 16:53:00 +00002484#line 1186 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002485{ // Pointer type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002486 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal)));
2487 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002488 ;
2489 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002490case 85:
Chris Lattner0ad19702006-06-21 16:53:00 +00002491#line 1194 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002492{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002493 yyval.TypeList = new std::list<PATypeHolder>();
2494 yyval.TypeList->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002495 ;
2496 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002497case 86:
Chris Lattner0ad19702006-06-21 16:53:00 +00002498#line 1198 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002499{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002500 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002501 ;
2502 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002503case 88:
Chris Lattner0ad19702006-06-21 16:53:00 +00002504#line 1204 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002505{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002506 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(Type::VoidTy);
Chris Lattner8335e842006-01-23 23:05:42 +00002507 ;
2508 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002509case 89:
Chris Lattner0ad19702006-06-21 16:53:00 +00002510#line 1207 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002511{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002512 (yyval.TypeList = new std::list<PATypeHolder>())->push_back(Type::VoidTy);
Chris Lattner8335e842006-01-23 23:05:42 +00002513 ;
2514 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002515case 90:
Chris Lattner0ad19702006-06-21 16:53:00 +00002516#line 1210 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002517{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002518 yyval.TypeList = new std::list<PATypeHolder>();
Chris Lattner8335e842006-01-23 23:05:42 +00002519 ;
2520 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002521case 91:
Chris Lattner0ad19702006-06-21 16:53:00 +00002522#line 1220 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002523{ // Nonempty unsized arr
Reid Spencer68a24bd2005-08-27 18:50:39 +00002524 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
2525 if (ATy == 0)
2526 ThrowException("Cannot make array constant with type: '" +
2527 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2528 const Type *ETy = ATy->getElementType();
2529 int NumElements = ATy->getNumElements();
2530
2531 // Verify that we have the correct size...
2532 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2533 ThrowException("Type mismatch: constant sized array initialized with " +
2534 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
2535 itostr(NumElements) + "!");
2536
2537 // Verify all elements are correct type!
2538 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2539 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2540 ThrowException("Element #" + utostr(i) + " is not of type '" +
2541 ETy->getDescription() +"' as required!\nIt is of type '"+
2542 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2543 }
2544
2545 yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
2546 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Chris Lattner8335e842006-01-23 23:05:42 +00002547 ;
2548 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002549case 92:
Chris Lattner0ad19702006-06-21 16:53:00 +00002550#line 1245 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002551{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002552 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2553 if (ATy == 0)
2554 ThrowException("Cannot make array constant with type: '" +
2555 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2556
2557 int NumElements = ATy->getNumElements();
2558 if (NumElements != -1 && NumElements != 0)
2559 ThrowException("Type mismatch: constant sized array initialized with 0"
2560 " arguments, but has size of " + itostr(NumElements) +"!");
2561 yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
2562 delete yyvsp[-2].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002563 ;
2564 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002565case 93:
Chris Lattner0ad19702006-06-21 16:53:00 +00002566#line 1258 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002567{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002568 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2569 if (ATy == 0)
2570 ThrowException("Cannot make array constant with type: '" +
2571 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2572
2573 int NumElements = ATy->getNumElements();
2574 const Type *ETy = ATy->getElementType();
2575 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
2576 if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal))
2577 ThrowException("Can't build string constant of size " +
2578 itostr((int)(EndStr-yyvsp[0].StrVal)) +
2579 " when array has size " + itostr(NumElements) + "!");
2580 std::vector<Constant*> Vals;
2581 if (ETy == Type::SByteTy) {
Chris Lattner66316012006-01-24 04:14:29 +00002582 for (signed char *C = (signed char *)yyvsp[0].StrVal; C != (signed char *)EndStr; ++C)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002583 Vals.push_back(ConstantSInt::get(ETy, *C));
2584 } else if (ETy == Type::UByteTy) {
Chris Lattner66316012006-01-24 04:14:29 +00002585 for (unsigned char *C = (unsigned char *)yyvsp[0].StrVal;
2586 C != (unsigned char*)EndStr; ++C)
2587 Vals.push_back(ConstantUInt::get(ETy, *C));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002588 } else {
2589 free(yyvsp[0].StrVal);
2590 ThrowException("Cannot build string arrays of non byte sized elements!");
2591 }
2592 free(yyvsp[0].StrVal);
2593 yyval.ConstVal = ConstantArray::get(ATy, Vals);
2594 delete yyvsp[-2].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002595 ;
2596 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002597case 94:
Chris Lattner0ad19702006-06-21 16:53:00 +00002598#line 1287 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002599{ // Nonempty unsized arr
Reid Spencer68a24bd2005-08-27 18:50:39 +00002600 const PackedType *PTy = dyn_cast<PackedType>(yyvsp[-3].TypeVal->get());
2601 if (PTy == 0)
2602 ThrowException("Cannot make packed constant with type: '" +
2603 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2604 const Type *ETy = PTy->getElementType();
2605 int NumElements = PTy->getNumElements();
2606
2607 // Verify that we have the correct size...
2608 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2609 ThrowException("Type mismatch: constant sized packed initialized with " +
2610 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
2611 itostr(NumElements) + "!");
2612
2613 // Verify all elements are correct type!
2614 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2615 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2616 ThrowException("Element #" + utostr(i) + " is not of type '" +
2617 ETy->getDescription() +"' as required!\nIt is of type '"+
2618 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2619 }
2620
2621 yyval.ConstVal = ConstantPacked::get(PTy, *yyvsp[-1].ConstVector);
2622 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Chris Lattner8335e842006-01-23 23:05:42 +00002623 ;
2624 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002625case 95:
Chris Lattner0ad19702006-06-21 16:53:00 +00002626#line 1312 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002627{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002628 const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
2629 if (STy == 0)
2630 ThrowException("Cannot make struct constant with type: '" +
2631 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2632
2633 if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
2634 ThrowException("Illegal number of initializers for structure type!");
2635
2636 // Check to ensure that constants are compatible with the type initializer!
2637 for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
2638 if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
2639 ThrowException("Expected type '" +
2640 STy->getElementType(i)->getDescription() +
2641 "' for element #" + utostr(i) +
2642 " of structure initializer!");
2643
2644 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
2645 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Chris Lattner8335e842006-01-23 23:05:42 +00002646 ;
2647 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002648case 96:
Chris Lattner0ad19702006-06-21 16:53:00 +00002649#line 1332 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002650{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002651 const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
2652 if (STy == 0)
2653 ThrowException("Cannot make struct constant with type: '" +
2654 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2655
2656 if (STy->getNumContainedTypes() != 0)
2657 ThrowException("Illegal number of initializers for structure type!");
2658
2659 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
2660 delete yyvsp[-2].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002661 ;
2662 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002663case 97:
Chris Lattner0ad19702006-06-21 16:53:00 +00002664#line 1344 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002665{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002666 const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
2667 if (PTy == 0)
2668 ThrowException("Cannot make null pointer constant with type: '" +
2669 (*yyvsp[-1].TypeVal)->getDescription() + "'!");
2670
2671 yyval.ConstVal = ConstantPointerNull::get(PTy);
2672 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002673 ;
2674 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002675case 98:
Chris Lattner0ad19702006-06-21 16:53:00 +00002676#line 1353 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002677{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002678 yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
2679 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002680 ;
2681 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002682case 99:
Chris Lattner0ad19702006-06-21 16:53:00 +00002683#line 1357 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002684{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002685 const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
2686 if (Ty == 0)
2687 ThrowException("Global const reference must be a pointer type!");
2688
2689 // ConstExprs can exist in the body of a function, thus creating
2690 // GlobalValues whenever they refer to a variable. Because we are in
2691 // the context of a function, getValNonImprovising will search the functions
2692 // symbol table instead of the module symbol table for the global symbol,
2693 // which throws things all off. To get around this, we just tell
2694 // getValNonImprovising that we are at global scope here.
2695 //
2696 Function *SavedCurFn = CurFun.CurrentFunction;
2697 CurFun.CurrentFunction = 0;
2698
2699 Value *V = getValNonImprovising(Ty, yyvsp[0].ValIDVal);
2700
2701 CurFun.CurrentFunction = SavedCurFn;
2702
2703 // If this is an initializer for a constant pointer, which is referencing a
2704 // (currently) undefined variable, create a stub now that shall be replaced
2705 // in the future with the right type of variable.
2706 //
2707 if (V == 0) {
2708 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
2709 const PointerType *PT = cast<PointerType>(Ty);
2710
2711 // First check to see if the forward references value is already created!
2712 PerModuleInfo::GlobalRefsType::iterator I =
2713 CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
2714
2715 if (I != CurModule.GlobalRefs.end()) {
2716 V = I->second; // Placeholder already exists, use it...
2717 yyvsp[0].ValIDVal.destroy();
2718 } else {
2719 std::string Name;
2720 if (yyvsp[0].ValIDVal.Type == ValID::NameVal) Name = yyvsp[0].ValIDVal.Name;
2721
2722 // Create the forward referenced global.
2723 GlobalValue *GV;
2724 if (const FunctionType *FTy =
2725 dyn_cast<FunctionType>(PT->getElementType())) {
2726 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
2727 CurModule.CurrentModule);
2728 } else {
2729 GV = new GlobalVariable(PT->getElementType(), false,
2730 GlobalValue::ExternalLinkage, 0,
2731 Name, CurModule.CurrentModule);
2732 }
2733
2734 // Keep track of the fact that we have a forward ref to recycle it
2735 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
2736 V = GV;
2737 }
2738 }
2739
2740 yyval.ConstVal = cast<GlobalValue>(V);
2741 delete yyvsp[-1].TypeVal; // Free the type handle
Chris Lattner8335e842006-01-23 23:05:42 +00002742 ;
2743 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002744case 100:
Chris Lattner0ad19702006-06-21 16:53:00 +00002745#line 1416 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002746{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002747 if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
2748 ThrowException("Mismatched types for constant expression!");
2749 yyval.ConstVal = yyvsp[0].ConstVal;
2750 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002751 ;
2752 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002753case 101:
Chris Lattner0ad19702006-06-21 16:53:00 +00002754#line 1422 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002755{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002756 const Type *Ty = yyvsp[-1].TypeVal->get();
2757 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
2758 ThrowException("Cannot create a null initialized value of this type!");
2759 yyval.ConstVal = Constant::getNullValue(Ty);
2760 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002761 ;
2762 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002763case 102:
Chris Lattner0ad19702006-06-21 16:53:00 +00002764#line 1430 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002765{ // integral constants
Reid Spencer68a24bd2005-08-27 18:50:39 +00002766 if (!ConstantSInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
2767 ThrowException("Constant value doesn't fit in type!");
2768 yyval.ConstVal = ConstantSInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val);
Chris Lattner8335e842006-01-23 23:05:42 +00002769 ;
2770 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002771case 103:
Chris Lattner0ad19702006-06-21 16:53:00 +00002772#line 1435 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002773{ // integral constants
Reid Spencer68a24bd2005-08-27 18:50:39 +00002774 if (!ConstantUInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
2775 ThrowException("Constant value doesn't fit in type!");
2776 yyval.ConstVal = ConstantUInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val);
Chris Lattner8335e842006-01-23 23:05:42 +00002777 ;
2778 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002779case 104:
Chris Lattner0ad19702006-06-21 16:53:00 +00002780#line 1440 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002781{ // Boolean constants
Reid Spencer68a24bd2005-08-27 18:50:39 +00002782 yyval.ConstVal = ConstantBool::True;
Chris Lattner8335e842006-01-23 23:05:42 +00002783 ;
2784 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002785case 105:
Chris Lattner0ad19702006-06-21 16:53:00 +00002786#line 1443 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002787{ // Boolean constants
Reid Spencer68a24bd2005-08-27 18:50:39 +00002788 yyval.ConstVal = ConstantBool::False;
Chris Lattner8335e842006-01-23 23:05:42 +00002789 ;
2790 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002791case 106:
Chris Lattner0ad19702006-06-21 16:53:00 +00002792#line 1446 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002793{ // Float & Double constants
Reid Spencer68a24bd2005-08-27 18:50:39 +00002794 if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal))
2795 ThrowException("Floating point constant invalid for type!!");
2796 yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal);
Chris Lattner8335e842006-01-23 23:05:42 +00002797 ;
2798 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002799case 107:
Chris Lattner0ad19702006-06-21 16:53:00 +00002800#line 1453 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002801{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002802 if (!yyvsp[-3].ConstVal->getType()->isFirstClassType())
2803 ThrowException("cast constant expression from a non-primitive type: '" +
2804 yyvsp[-3].ConstVal->getType()->getDescription() + "'!");
2805 if (!yyvsp[-1].TypeVal->get()->isFirstClassType())
2806 ThrowException("cast constant expression to a non-primitive type: '" +
2807 yyvsp[-1].TypeVal->get()->getDescription() + "'!");
2808 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-3].ConstVal, yyvsp[-1].TypeVal->get());
2809 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002810 ;
2811 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002812case 108:
Chris Lattner0ad19702006-06-21 16:53:00 +00002813#line 1463 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002814{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002815 if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
2816 ThrowException("GetElementPtr requires a pointer operand!");
2817
2818 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
2819 // indices to uint struct indices for compatibility.
2820 generic_gep_type_iterator<std::vector<Value*>::iterator>
2821 GTI = gep_type_begin(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end()),
2822 GTE = gep_type_end(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end());
2823 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
2824 if (isa<StructType>(*GTI)) // Only change struct indices
2825 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[-1].ValueList)[i]))
2826 if (CUI->getType() == Type::UByteTy)
2827 (*yyvsp[-1].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
2828
2829 const Type *IdxTy =
2830 GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), *yyvsp[-1].ValueList, true);
2831 if (!IdxTy)
2832 ThrowException("Index list invalid for constant getelementptr!");
2833
2834 std::vector<Constant*> IdxVec;
2835 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
2836 if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
2837 IdxVec.push_back(C);
2838 else
2839 ThrowException("Indices to constant getelementptr must be constants!");
2840
2841 delete yyvsp[-1].ValueList;
2842
2843 yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, IdxVec);
Chris Lattner8335e842006-01-23 23:05:42 +00002844 ;
2845 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002846case 109:
Chris Lattner0ad19702006-06-21 16:53:00 +00002847#line 1494 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002848{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002849 if (yyvsp[-5].ConstVal->getType() != Type::BoolTy)
2850 ThrowException("Select condition must be of boolean type!");
2851 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2852 ThrowException("Select operand types must match!");
2853 yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Chris Lattner8335e842006-01-23 23:05:42 +00002854 ;
2855 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002856case 110:
Chris Lattner0ad19702006-06-21 16:53:00 +00002857#line 1501 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002858{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002859 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2860 ThrowException("Binary operator types must match!");
2861 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
2862 // To retain backward compatibility with these early compilers, we emit a
2863 // cast to the appropriate integer type automatically if we are in the
2864 // broken case. See PR424 for more information.
2865 if (!isa<PointerType>(yyvsp[-3].ConstVal->getType())) {
2866 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2867 } else {
2868 const Type *IntPtrTy = 0;
2869 switch (CurModule.CurrentModule->getPointerSize()) {
2870 case Module::Pointer32: IntPtrTy = Type::IntTy; break;
2871 case Module::Pointer64: IntPtrTy = Type::LongTy; break;
2872 default: ThrowException("invalid pointer binary constant expr!");
2873 }
2874 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, ConstantExpr::getCast(yyvsp[-3].ConstVal, IntPtrTy),
2875 ConstantExpr::getCast(yyvsp[-1].ConstVal, IntPtrTy));
2876 yyval.ConstVal = ConstantExpr::getCast(yyval.ConstVal, yyvsp[-3].ConstVal->getType());
2877 }
Chris Lattner8335e842006-01-23 23:05:42 +00002878 ;
2879 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002880case 111:
Chris Lattner0ad19702006-06-21 16:53:00 +00002881#line 1522 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002882{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002883 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2884 ThrowException("Logical operator types must match!");
Chris Lattner524a1312005-12-21 18:31:50 +00002885 if (!yyvsp[-3].ConstVal->getType()->isIntegral()) {
2886 if (!isa<PackedType>(yyvsp[-3].ConstVal->getType()) ||
2887 !cast<PackedType>(yyvsp[-3].ConstVal->getType())->getElementType()->isIntegral())
2888 ThrowException("Logical operator requires integral operands!");
2889 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002890 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Chris Lattner8335e842006-01-23 23:05:42 +00002891 ;
2892 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002893case 112:
Chris Lattner0ad19702006-06-21 16:53:00 +00002894#line 1532 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002895{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002896 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2897 ThrowException("setcc operand types must match!");
2898 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Chris Lattner8335e842006-01-23 23:05:42 +00002899 ;
2900 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002901case 113:
Chris Lattner0ad19702006-06-21 16:53:00 +00002902#line 1537 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002903{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002904 if (yyvsp[-1].ConstVal->getType() != Type::UByteTy)
2905 ThrowException("Shift count for shift constant must be unsigned byte!");
2906 if (!yyvsp[-3].ConstVal->getType()->isInteger())
2907 ThrowException("Shift constant expression requires integer operand!");
2908 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].OtherOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Chris Lattner8335e842006-01-23 23:05:42 +00002909 ;
2910 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002911case 114:
Chris Lattner0ad19702006-06-21 16:53:00 +00002912#line 1544 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002913{
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00002914 if (!ExtractElementInst::isValidOperands(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
2915 ThrowException("Invalid extractelement operands!");
Robert Bocchino9c62b562006-01-10 19:04:32 +00002916 yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Chris Lattner8335e842006-01-23 23:05:42 +00002917 ;
2918 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002919case 115:
Chris Lattner0ad19702006-06-21 16:53:00 +00002920#line 1549 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerd25db202006-04-08 03:55:17 +00002921{
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00002922 if (!InsertElementInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
2923 ThrowException("Invalid insertelement operands!");
Chris Lattnerd25db202006-04-08 03:55:17 +00002924 yyval.ConstVal = ConstantExpr::getInsertElement(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2925 ;
2926 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002927case 116:
Chris Lattner0ad19702006-06-21 16:53:00 +00002928#line 1554 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerd25db202006-04-08 03:55:17 +00002929{
2930 if (!ShuffleVectorInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
2931 ThrowException("Invalid shufflevector operands!");
2932 yyval.ConstVal = ConstantExpr::getShuffleVector(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2933 ;
2934 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002935case 117:
Chris Lattner0ad19702006-06-21 16:53:00 +00002936#line 1562 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002937{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002938 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
Chris Lattner8335e842006-01-23 23:05:42 +00002939 ;
2940 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002941case 118:
Chris Lattner0ad19702006-06-21 16:53:00 +00002942#line 1565 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002943{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002944 yyval.ConstVector = new std::vector<Constant*>();
2945 yyval.ConstVector->push_back(yyvsp[0].ConstVal);
Chris Lattner8335e842006-01-23 23:05:42 +00002946 ;
2947 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002948case 119:
Chris Lattner0ad19702006-06-21 16:53:00 +00002949#line 1572 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002950{ yyval.BoolVal = false; ;
2951 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002952case 120:
Chris Lattner0ad19702006-06-21 16:53:00 +00002953#line 1572 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002954{ yyval.BoolVal = true; ;
2955 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002956case 121:
Chris Lattner0ad19702006-06-21 16:53:00 +00002957#line 1582 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002958{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002959 yyval.ModuleVal = ParserResult = yyvsp[0].ModuleVal;
2960 CurModule.ModuleDone();
Chris Lattner8335e842006-01-23 23:05:42 +00002961;
2962 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002963case 122:
Chris Lattner0ad19702006-06-21 16:53:00 +00002964#line 1589 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002965{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002966 yyval.ModuleVal = yyvsp[-1].ModuleVal;
2967 CurFun.FunctionDone();
Chris Lattner8335e842006-01-23 23:05:42 +00002968 ;
2969 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002970case 123:
Chris Lattner0ad19702006-06-21 16:53:00 +00002971#line 1593 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002972{
Robert Bocchino9c62b562006-01-10 19:04:32 +00002973 yyval.ModuleVal = yyvsp[-1].ModuleVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002974 ;
2975 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002976case 124:
Chris Lattner0ad19702006-06-21 16:53:00 +00002977#line 1596 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerd25db202006-04-08 03:55:17 +00002978{
2979 yyval.ModuleVal = yyvsp[-3].ModuleVal;
2980 ;
2981 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002982case 125:
Chris Lattner0ad19702006-06-21 16:53:00 +00002983#line 1599 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerd25db202006-04-08 03:55:17 +00002984{
2985 yyval.ModuleVal = yyvsp[-1].ModuleVal;
2986 ;
2987 break;}
Chris Lattner75466192006-05-19 21:28:53 +00002988case 126:
Chris Lattner0ad19702006-06-21 16:53:00 +00002989#line 1602 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002990{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002991 yyval.ModuleVal = CurModule.CurrentModule;
2992 // Emit an error if there are any unresolved types left.
2993 if (!CurModule.LateResolveTypes.empty()) {
2994 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
2995 if (DID.Type == ValID::NameVal)
2996 ThrowException("Reference to an undefined type: '"+DID.getName() + "'");
2997 else
2998 ThrowException("Reference to an undefined type: #" + itostr(DID.Num));
2999 }
Chris Lattner8335e842006-01-23 23:05:42 +00003000 ;
3001 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003002case 127:
Chris Lattner0ad19702006-06-21 16:53:00 +00003003#line 1615 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003004{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003005 // Eagerly resolve types. This is not an optimization, this is a
3006 // requirement that is due to the fact that we could have this:
3007 //
3008 // %list = type { %list * }
3009 // %list = type { %list * } ; repeated type decl
3010 //
3011 // If types are not resolved eagerly, then the two types will not be
3012 // determined to be the same type!
3013 //
3014 ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
3015
3016 if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
3017 // If this is a named type that is not a redefinition, add it to the slot
3018 // table.
3019 CurModule.Types.push_back(*yyvsp[0].TypeVal);
3020 }
3021
3022 delete yyvsp[0].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003023 ;
3024 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003025case 128:
Chris Lattner0ad19702006-06-21 16:53:00 +00003026#line 1635 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003027{ // Function prototypes can be in const pool
3028 ;
3029 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003030case 129:
Chris Lattner0ad19702006-06-21 16:53:00 +00003031#line 1637 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner66316012006-01-24 04:14:29 +00003032{ // Asm blocks can be in the const pool
Chris Lattner8335e842006-01-23 23:05:42 +00003033 ;
3034 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003035case 130:
Chris Lattner0ad19702006-06-21 16:53:00 +00003036#line 1639 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003037{
Chris Lattnerb475c422005-11-12 18:22:38 +00003038 if (yyvsp[0].ConstVal == 0) ThrowException("Global value initializer is not a constant!");
3039 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 +00003040 ;
3041 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003042case 131:
Chris Lattner0ad19702006-06-21 16:53:00 +00003043#line 1642 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003044{
Chris Lattnerb475c422005-11-12 18:22:38 +00003045 CurGV = 0;
Chris Lattner8335e842006-01-23 23:05:42 +00003046 ;
3047 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003048case 132:
Chris Lattner0ad19702006-06-21 16:53:00 +00003049#line 1645 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003050{
Chris Lattnerb475c422005-11-12 18:22:38 +00003051 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalLinkage,
3052 yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0);
3053 delete yyvsp[0].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003054 ;
3055 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003056case 133:
Chris Lattner0ad19702006-06-21 16:53:00 +00003057#line 1649 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003058{
Chris Lattnerb475c422005-11-12 18:22:38 +00003059 CurGV = 0;
Chris Lattner8335e842006-01-23 23:05:42 +00003060 ;
3061 break;}
Chris Lattner8335e842006-01-23 23:05:42 +00003062case 134:
Chris Lattner0ad19702006-06-21 16:53:00 +00003063#line 1652 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner75466192006-05-19 21:28:53 +00003064{
Chris Lattnerd25db202006-04-08 03:55:17 +00003065 ;
3066 break;}
3067case 135:
Chris Lattner0ad19702006-06-21 16:53:00 +00003068#line 1654 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner75466192006-05-19 21:28:53 +00003069{
Chris Lattnerd25db202006-04-08 03:55:17 +00003070 ;
3071 break;}
3072case 136:
Chris Lattner0ad19702006-06-21 16:53:00 +00003073#line 1656 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner75466192006-05-19 21:28:53 +00003074{
3075 ;
3076 break;}
3077case 137:
Chris Lattner0ad19702006-06-21 16:53:00 +00003078#line 1660 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003079{
Chris Lattner66316012006-01-24 04:14:29 +00003080 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
3081 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
3082 std::string NewAsm(yyvsp[0].StrVal, EndStr);
Chris Lattner8335e842006-01-23 23:05:42 +00003083 free(yyvsp[0].StrVal);
Chris Lattner66316012006-01-24 04:14:29 +00003084
3085 if (AsmSoFar.empty())
3086 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
3087 else
3088 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Chris Lattner8335e842006-01-23 23:05:42 +00003089;
3090 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003091case 138:
Chris Lattner0ad19702006-06-21 16:53:00 +00003092#line 1672 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003093{ yyval.Endianness = Module::BigEndian; ;
3094 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003095case 139:
Chris Lattner0ad19702006-06-21 16:53:00 +00003096#line 1673 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003097{ yyval.Endianness = Module::LittleEndian; ;
3098 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003099case 140:
Chris Lattner0ad19702006-06-21 16:53:00 +00003100#line 1675 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003101{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003102 CurModule.CurrentModule->setEndianness(yyvsp[0].Endianness);
Chris Lattner8335e842006-01-23 23:05:42 +00003103 ;
3104 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003105case 141:
Chris Lattner0ad19702006-06-21 16:53:00 +00003106#line 1678 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003107{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003108 if (yyvsp[0].UInt64Val == 32)
3109 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
3110 else if (yyvsp[0].UInt64Val == 64)
3111 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
3112 else
3113 ThrowException("Invalid pointer size: '" + utostr(yyvsp[0].UInt64Val) + "'!");
Chris Lattner8335e842006-01-23 23:05:42 +00003114 ;
3115 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003116case 142:
Chris Lattner0ad19702006-06-21 16:53:00 +00003117#line 1686 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003118{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003119 CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal);
3120 free(yyvsp[0].StrVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003121 ;
3122 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003123case 144:
Chris Lattner0ad19702006-06-21 16:53:00 +00003124#line 1693 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerd25db202006-04-08 03:55:17 +00003125{
3126 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3127 free(yyvsp[0].StrVal);
3128 ;
3129 break;}
3130case 145:
Chris Lattner0ad19702006-06-21 16:53:00 +00003131#line 1697 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner75466192006-05-19 21:28:53 +00003132{
3133 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3134 free(yyvsp[0].StrVal);
3135 ;
3136 break;}
3137case 146:
Chris Lattner0ad19702006-06-21 16:53:00 +00003138#line 1701 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner66316012006-01-24 04:14:29 +00003139{
Chris Lattner8335e842006-01-23 23:05:42 +00003140 ;
3141 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003142case 150:
Chris Lattner0ad19702006-06-21 16:53:00 +00003143#line 1710 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003144{ yyval.StrVal = 0; ;
3145 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003146case 151:
Chris Lattner0ad19702006-06-21 16:53:00 +00003147#line 1712 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003148{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003149 if (*yyvsp[-1].TypeVal == Type::VoidTy)
3150 ThrowException("void typed arguments are invalid!");
3151 yyval.ArgVal = new std::pair<PATypeHolder*, char*>(yyvsp[-1].TypeVal, yyvsp[0].StrVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003152;
3153 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003154case 152:
Chris Lattner0ad19702006-06-21 16:53:00 +00003155#line 1718 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003156{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003157 yyval.ArgList = yyvsp[-2].ArgList;
3158 yyvsp[-2].ArgList->push_back(*yyvsp[0].ArgVal);
3159 delete yyvsp[0].ArgVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003160 ;
3161 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003162case 153:
Chris Lattner0ad19702006-06-21 16:53:00 +00003163#line 1723 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003164{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003165 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
3166 yyval.ArgList->push_back(*yyvsp[0].ArgVal);
3167 delete yyvsp[0].ArgVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003168 ;
3169 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003170case 154:
Chris Lattner0ad19702006-06-21 16:53:00 +00003171#line 1729 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003172{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003173 yyval.ArgList = yyvsp[0].ArgList;
Chris Lattner8335e842006-01-23 23:05:42 +00003174 ;
3175 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003176case 155:
Chris Lattner0ad19702006-06-21 16:53:00 +00003177#line 1732 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003178{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003179 yyval.ArgList = yyvsp[-2].ArgList;
3180 yyval.ArgList->push_back(std::pair<PATypeHolder*,
3181 char*>(new PATypeHolder(Type::VoidTy), 0));
Chris Lattner8335e842006-01-23 23:05:42 +00003182 ;
3183 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003184case 156:
Chris Lattner0ad19702006-06-21 16:53:00 +00003185#line 1737 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003186{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003187 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
3188 yyval.ArgList->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0));
Chris Lattner8335e842006-01-23 23:05:42 +00003189 ;
3190 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003191case 157:
Chris Lattner0ad19702006-06-21 16:53:00 +00003192#line 1741 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003193{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003194 yyval.ArgList = 0;
Chris Lattner8335e842006-01-23 23:05:42 +00003195 ;
3196 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003197case 158:
Chris Lattner0ad19702006-06-21 16:53:00 +00003198#line 1746 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003199{
Chris Lattnere869eef2005-11-12 00:11:49 +00003200 UnEscapeLexed(yyvsp[-5].StrVal);
3201 std::string FunctionName(yyvsp[-5].StrVal);
3202 free(yyvsp[-5].StrVal); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00003203
Chris Lattnere869eef2005-11-12 00:11:49 +00003204 if (!(*yyvsp[-6].TypeVal)->isFirstClassType() && *yyvsp[-6].TypeVal != Type::VoidTy)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003205 ThrowException("LLVM functions cannot return aggregate types!");
3206
3207 std::vector<const Type*> ParamTypeList;
Chris Lattnere869eef2005-11-12 00:11:49 +00003208 if (yyvsp[-3].ArgList) { // If there are arguments...
3209 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-3].ArgList->begin();
3210 I != yyvsp[-3].ArgList->end(); ++I)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003211 ParamTypeList.push_back(I->first->get());
3212 }
3213
3214 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
3215 if (isVarArg) ParamTypeList.pop_back();
3216
Chris Lattnere869eef2005-11-12 00:11:49 +00003217 const FunctionType *FT = FunctionType::get(*yyvsp[-6].TypeVal, ParamTypeList, isVarArg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003218 const PointerType *PFT = PointerType::get(FT);
Chris Lattnere869eef2005-11-12 00:11:49 +00003219 delete yyvsp[-6].TypeVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003220
3221 ValID ID;
3222 if (!FunctionName.empty()) {
3223 ID = ValID::create((char*)FunctionName.c_str());
3224 } else {
3225 ID = ValID::create((int)CurModule.Values[PFT].size());
3226 }
3227
3228 Function *Fn = 0;
3229 // See if this function was forward referenced. If so, recycle the object.
3230 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
3231 // Move the function to the end of the list, from whereever it was
3232 // previously inserted.
3233 Fn = cast<Function>(FWRef);
3234 CurModule.CurrentModule->getFunctionList().remove(Fn);
3235 CurModule.CurrentModule->getFunctionList().push_back(Fn);
3236 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
3237 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
3238 // If this is the case, either we need to be a forward decl, or it needs
3239 // to be.
3240 if (!CurFun.isDeclare && !Fn->isExternal())
3241 ThrowException("Redefinition of function '" + FunctionName + "'!");
3242
3243 // Make sure to strip off any argument names so we can't get conflicts.
3244 if (Fn->isExternal())
3245 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
3246 AI != AE; ++AI)
3247 AI->setName("");
3248
3249 } else { // Not already defined?
3250 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
3251 CurModule.CurrentModule);
3252 InsertValue(Fn, CurModule.Values);
3253 }
3254
3255 CurFun.FunctionStart(Fn);
Chris Lattnere869eef2005-11-12 00:11:49 +00003256 Fn->setCallingConv(yyvsp[-7].UIntVal);
Chris Lattner0019bbe2005-11-06 06:46:53 +00003257 Fn->setAlignment(yyvsp[0].UIntVal);
Chris Lattnere869eef2005-11-12 00:11:49 +00003258 if (yyvsp[-1].StrVal) {
3259 Fn->setSection(yyvsp[-1].StrVal);
3260 free(yyvsp[-1].StrVal);
3261 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00003262
3263 // Add all of the arguments we parsed to the function...
Chris Lattnere869eef2005-11-12 00:11:49 +00003264 if (yyvsp[-3].ArgList) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00003265 if (isVarArg) { // Nuke the last entry
Chris Lattnere869eef2005-11-12 00:11:49 +00003266 assert(yyvsp[-3].ArgList->back().first->get() == Type::VoidTy && yyvsp[-3].ArgList->back().second == 0&&
Reid Spencer68a24bd2005-08-27 18:50:39 +00003267 "Not a varargs marker!");
Chris Lattnere869eef2005-11-12 00:11:49 +00003268 delete yyvsp[-3].ArgList->back().first;
3269 yyvsp[-3].ArgList->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00003270 }
3271 Function::arg_iterator ArgIt = Fn->arg_begin();
Chris Lattnere869eef2005-11-12 00:11:49 +00003272 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-3].ArgList->begin();
3273 I != yyvsp[-3].ArgList->end(); ++I, ++ArgIt) {
Reid Spencer68a24bd2005-08-27 18:50:39 +00003274 delete I->first; // Delete the typeholder...
3275
3276 setValueName(ArgIt, I->second); // Insert arg into symtab...
3277 InsertValue(ArgIt);
3278 }
3279
Chris Lattnere869eef2005-11-12 00:11:49 +00003280 delete yyvsp[-3].ArgList; // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00003281 }
Chris Lattner8335e842006-01-23 23:05:42 +00003282;
3283 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003284case 161:
Chris Lattner0ad19702006-06-21 16:53:00 +00003285#line 1833 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003286{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003287 yyval.FunctionVal = CurFun.CurrentFunction;
3288
3289 // Make sure that we keep track of the linkage type even if there was a
3290 // previous "declare".
3291 yyval.FunctionVal->setLinkage(yyvsp[-2].Linkage);
Chris Lattner8335e842006-01-23 23:05:42 +00003292;
3293 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003294case 164:
Chris Lattner0ad19702006-06-21 16:53:00 +00003295#line 1843 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003296{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003297 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003298;
3299 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003300case 165:
Chris Lattner0ad19702006-06-21 16:53:00 +00003301#line 1847 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003302{ CurFun.isDeclare = true; ;
3303 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003304case 166:
Chris Lattner0ad19702006-06-21 16:53:00 +00003305#line 1847 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003306{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003307 yyval.FunctionVal = CurFun.CurrentFunction;
3308 CurFun.FunctionDone();
Chris Lattner8335e842006-01-23 23:05:42 +00003309;
3310 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003311case 167:
Chris Lattner0ad19702006-06-21 16:53:00 +00003312#line 1856 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner0e9c3762006-01-25 22:27:16 +00003313{
3314 yyval.BoolVal = false;
3315 ;
3316 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003317case 168:
Chris Lattner0ad19702006-06-21 16:53:00 +00003318#line 1859 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner0e9c3762006-01-25 22:27:16 +00003319{
3320 yyval.BoolVal = true;
3321 ;
3322 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003323case 169:
Chris Lattner0ad19702006-06-21 16:53:00 +00003324#line 1863 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003325{ // A reference to a direct constant
Reid Spencer68a24bd2005-08-27 18:50:39 +00003326 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
Chris Lattner8335e842006-01-23 23:05:42 +00003327 ;
3328 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003329case 170:
Chris Lattner0ad19702006-06-21 16:53:00 +00003330#line 1866 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003331{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003332 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
Chris Lattner8335e842006-01-23 23:05:42 +00003333 ;
3334 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003335case 171:
Chris Lattner0ad19702006-06-21 16:53:00 +00003336#line 1869 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003337{ // Perhaps it's an FP constant?
Reid Spencer68a24bd2005-08-27 18:50:39 +00003338 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003339 ;
3340 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003341case 172:
Chris Lattner0ad19702006-06-21 16:53:00 +00003342#line 1872 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003343{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003344 yyval.ValIDVal = ValID::create(ConstantBool::True);
Chris Lattner8335e842006-01-23 23:05:42 +00003345 ;
3346 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003347case 173:
Chris Lattner0ad19702006-06-21 16:53:00 +00003348#line 1875 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003349{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003350 yyval.ValIDVal = ValID::create(ConstantBool::False);
Chris Lattner8335e842006-01-23 23:05:42 +00003351 ;
3352 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003353case 174:
Chris Lattner0ad19702006-06-21 16:53:00 +00003354#line 1878 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003355{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003356 yyval.ValIDVal = ValID::createNull();
Chris Lattner8335e842006-01-23 23:05:42 +00003357 ;
3358 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003359case 175:
Chris Lattner0ad19702006-06-21 16:53:00 +00003360#line 1881 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003361{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003362 yyval.ValIDVal = ValID::createUndef();
Chris Lattner8335e842006-01-23 23:05:42 +00003363 ;
3364 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003365case 176:
Chris Lattner0ad19702006-06-21 16:53:00 +00003366#line 1884 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003367{ // A vector zero constant.
Chris Lattner7aa61892005-12-21 17:53:23 +00003368 yyval.ValIDVal = ValID::createZeroInit();
Chris Lattner8335e842006-01-23 23:05:42 +00003369 ;
3370 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003371case 177:
Chris Lattner0ad19702006-06-21 16:53:00 +00003372#line 1887 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003373{ // Nonempty unsized packed vector
Reid Spencer68a24bd2005-08-27 18:50:39 +00003374 const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
3375 int NumElements = yyvsp[-1].ConstVector->size();
3376
3377 PackedType* pt = PackedType::get(ETy, NumElements);
3378 PATypeHolder* PTy = new PATypeHolder(
3379 HandleUpRefs(
3380 PackedType::get(
3381 ETy,
3382 NumElements)
3383 )
3384 );
3385
3386 // Verify all elements are correct type!
3387 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3388 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
3389 ThrowException("Element #" + utostr(i) + " is not of type '" +
3390 ETy->getDescription() +"' as required!\nIt is of type '" +
3391 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
3392 }
3393
3394 yyval.ValIDVal = ValID::create(ConstantPacked::get(pt, *yyvsp[-1].ConstVector));
3395 delete PTy; delete yyvsp[-1].ConstVector;
Chris Lattner8335e842006-01-23 23:05:42 +00003396 ;
3397 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003398case 178:
Chris Lattner0ad19702006-06-21 16:53:00 +00003399#line 1911 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003400{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003401 yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003402 ;
3403 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003404case 179:
Chris Lattner0ad19702006-06-21 16:53:00 +00003405#line 1914 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner0e9c3762006-01-25 22:27:16 +00003406{
3407 char *End = UnEscapeLexed(yyvsp[-2].StrVal, true);
3408 std::string AsmStr = std::string(yyvsp[-2].StrVal, End);
3409 End = UnEscapeLexed(yyvsp[0].StrVal, true);
3410 std::string Constraints = std::string(yyvsp[0].StrVal, End);
3411 yyval.ValIDVal = ValID::createInlineAsm(AsmStr, Constraints, yyvsp[-3].BoolVal);
3412 free(yyvsp[-2].StrVal);
3413 free(yyvsp[0].StrVal);
3414 ;
3415 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003416case 180:
Chris Lattner0ad19702006-06-21 16:53:00 +00003417#line 1927 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003418{ // Is it an integer reference...?
Reid Spencer68a24bd2005-08-27 18:50:39 +00003419 yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003420 ;
3421 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003422case 181:
Chris Lattner0ad19702006-06-21 16:53:00 +00003423#line 1930 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003424{ // Is it a named reference...?
Reid Spencer68a24bd2005-08-27 18:50:39 +00003425 yyval.ValIDVal = ValID::create(yyvsp[0].StrVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003426 ;
3427 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003428case 184:
Chris Lattner0ad19702006-06-21 16:53:00 +00003429#line 1941 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003430{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003431 yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003432 ;
3433 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003434case 185:
Chris Lattner0ad19702006-06-21 16:53:00 +00003435#line 1945 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003436{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003437 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003438 ;
3439 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003440case 186:
Chris Lattner0ad19702006-06-21 16:53:00 +00003441#line 1948 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003442{ // Do not allow functions with 0 basic blocks
Reid Spencer68a24bd2005-08-27 18:50:39 +00003443 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003444 ;
3445 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003446case 187:
Chris Lattner0ad19702006-06-21 16:53:00 +00003447#line 1956 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003448{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003449 setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
3450 InsertValue(yyvsp[0].TermInstVal);
3451
3452 yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
3453 InsertValue(yyvsp[-2].BasicBlockVal);
3454 yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003455 ;
3456 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003457case 188:
Chris Lattner0ad19702006-06-21 16:53:00 +00003458#line 1965 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003459{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003460 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
3461 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003462 ;
3463 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003464case 189:
Chris Lattner0ad19702006-06-21 16:53:00 +00003465#line 1969 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003466{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003467 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
3468
3469 // Make sure to move the basic block to the correct location in the
3470 // function, instead of leaving it inserted wherever it was first
3471 // referenced.
3472 Function::BasicBlockListType &BBL =
3473 CurFun.CurrentFunction->getBasicBlockList();
3474 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003475 ;
3476 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003477case 190:
Chris Lattner0ad19702006-06-21 16:53:00 +00003478#line 1979 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003479{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003480 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create(yyvsp[0].StrVal), true);
3481
3482 // Make sure to move the basic block to the correct location in the
3483 // function, instead of leaving it inserted wherever it was first
3484 // referenced.
3485 Function::BasicBlockListType &BBL =
3486 CurFun.CurrentFunction->getBasicBlockList();
3487 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003488 ;
3489 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003490case 191:
Chris Lattner0ad19702006-06-21 16:53:00 +00003491#line 1990 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003492{ // Return with a result...
Reid Spencer68a24bd2005-08-27 18:50:39 +00003493 yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003494 ;
3495 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003496case 192:
Chris Lattner0ad19702006-06-21 16:53:00 +00003497#line 1993 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003498{ // Return with no result...
Reid Spencer68a24bd2005-08-27 18:50:39 +00003499 yyval.TermInstVal = new ReturnInst();
Chris Lattner8335e842006-01-23 23:05:42 +00003500 ;
3501 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003502case 193:
Chris Lattner0ad19702006-06-21 16:53:00 +00003503#line 1996 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003504{ // Unconditional Branch...
Reid Spencer68a24bd2005-08-27 18:50:39 +00003505 yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[0].ValIDVal));
Chris Lattner8335e842006-01-23 23:05:42 +00003506 ;
3507 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003508case 194:
Chris Lattner0ad19702006-06-21 16:53:00 +00003509#line 1999 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003510{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003511 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 +00003512 ;
3513 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003514case 195:
Chris Lattner0ad19702006-06-21 16:53:00 +00003515#line 2002 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003516{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003517 SwitchInst *S = new SwitchInst(getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal), getBBVal(yyvsp[-3].ValIDVal), yyvsp[-1].JumpTable->size());
3518 yyval.TermInstVal = S;
3519
3520 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
3521 E = yyvsp[-1].JumpTable->end();
3522 for (; I != E; ++I) {
3523 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
3524 S->addCase(CI, I->second);
3525 else
3526 ThrowException("Switch case is constant, but not a simple integer!");
3527 }
3528 delete yyvsp[-1].JumpTable;
Chris Lattner8335e842006-01-23 23:05:42 +00003529 ;
3530 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003531case 196:
Chris Lattner0ad19702006-06-21 16:53:00 +00003532#line 2016 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003533{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003534 SwitchInst *S = new SwitchInst(getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal), getBBVal(yyvsp[-2].ValIDVal), 0);
3535 yyval.TermInstVal = S;
Chris Lattner8335e842006-01-23 23:05:42 +00003536 ;
3537 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003538case 197:
Chris Lattner0ad19702006-06-21 16:53:00 +00003539#line 2021 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003540{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003541 const PointerType *PFTy;
3542 const FunctionType *Ty;
3543
3544 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-10].TypeVal->get())) ||
3545 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3546 // Pull out the types of all of the arguments...
3547 std::vector<const Type*> ParamTypes;
3548 if (yyvsp[-7].ValueList) {
3549 for (std::vector<Value*>::iterator I = yyvsp[-7].ValueList->begin(), E = yyvsp[-7].ValueList->end();
3550 I != E; ++I)
3551 ParamTypes.push_back((*I)->getType());
3552 }
3553
3554 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3555 if (isVarArg) ParamTypes.pop_back();
3556
3557 Ty = FunctionType::get(yyvsp[-10].TypeVal->get(), ParamTypes, isVarArg);
3558 PFTy = PointerType::get(Ty);
3559 }
3560
3561 Value *V = getVal(PFTy, yyvsp[-9].ValIDVal); // Get the function we're calling...
3562
3563 BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
3564 BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
3565
3566 // Create the call node...
3567 if (!yyvsp[-7].ValueList) { // Has no arguments?
3568 yyval.TermInstVal = new InvokeInst(V, Normal, Except, std::vector<Value*>());
3569 } else { // Has arguments?
3570 // Loop through FunctionType's arguments and ensure they are specified
3571 // correctly!
3572 //
3573 FunctionType::param_iterator I = Ty->param_begin();
3574 FunctionType::param_iterator E = Ty->param_end();
3575 std::vector<Value*>::iterator ArgI = yyvsp[-7].ValueList->begin(), ArgE = yyvsp[-7].ValueList->end();
3576
3577 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3578 if ((*ArgI)->getType() != *I)
3579 ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
3580 (*I)->getDescription() + "'!");
3581
3582 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
3583 ThrowException("Invalid number of parameters detected!");
3584
3585 yyval.TermInstVal = new InvokeInst(V, Normal, Except, *yyvsp[-7].ValueList);
3586 }
3587 cast<InvokeInst>(yyval.TermInstVal)->setCallingConv(yyvsp[-11].UIntVal);
3588
3589 delete yyvsp[-10].TypeVal;
3590 delete yyvsp[-7].ValueList;
Chris Lattner8335e842006-01-23 23:05:42 +00003591 ;
3592 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003593case 198:
Chris Lattner0ad19702006-06-21 16:53:00 +00003594#line 2073 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003595{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003596 yyval.TermInstVal = new UnwindInst();
Chris Lattner8335e842006-01-23 23:05:42 +00003597 ;
3598 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003599case 199:
Chris Lattner0ad19702006-06-21 16:53:00 +00003600#line 2076 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003601{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003602 yyval.TermInstVal = new UnreachableInst();
Chris Lattner8335e842006-01-23 23:05:42 +00003603 ;
3604 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003605case 200:
Chris Lattner0ad19702006-06-21 16:53:00 +00003606#line 2082 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003607{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003608 yyval.JumpTable = yyvsp[-5].JumpTable;
3609 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
3610 if (V == 0)
3611 ThrowException("May only switch on a constant pool value!");
3612
3613 yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
Chris Lattner8335e842006-01-23 23:05:42 +00003614 ;
3615 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003616case 201:
Chris Lattner0ad19702006-06-21 16:53:00 +00003617#line 2090 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003618{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003619 yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
3620 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
3621
3622 if (V == 0)
3623 ThrowException("May only switch on a constant pool value!");
3624
3625 yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
Chris Lattner8335e842006-01-23 23:05:42 +00003626 ;
3627 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003628case 202:
Chris Lattner0ad19702006-06-21 16:53:00 +00003629#line 2100 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003630{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003631 // Is this definition named?? if so, assign the name...
3632 setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
3633 InsertValue(yyvsp[0].InstVal);
3634 yyval.InstVal = yyvsp[0].InstVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003635;
3636 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003637case 203:
Chris Lattner0ad19702006-06-21 16:53:00 +00003638#line 2107 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003639{ // Used for PHI nodes
Reid Spencer68a24bd2005-08-27 18:50:39 +00003640 yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
3641 yyval.PHIList->push_back(std::make_pair(getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal), getBBVal(yyvsp[-1].ValIDVal)));
3642 delete yyvsp[-5].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003643 ;
3644 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003645case 204:
Chris Lattner0ad19702006-06-21 16:53:00 +00003646#line 2112 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003647{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003648 yyval.PHIList = yyvsp[-6].PHIList;
3649 yyvsp[-6].PHIList->push_back(std::make_pair(getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal),
3650 getBBVal(yyvsp[-1].ValIDVal)));
Chris Lattner8335e842006-01-23 23:05:42 +00003651 ;
3652 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003653case 205:
Chris Lattner0ad19702006-06-21 16:53:00 +00003654#line 2119 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003655{ // Used for call statements, and memory insts...
Reid Spencer68a24bd2005-08-27 18:50:39 +00003656 yyval.ValueList = new std::vector<Value*>();
3657 yyval.ValueList->push_back(yyvsp[0].ValueVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003658 ;
3659 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003660case 206:
Chris Lattner0ad19702006-06-21 16:53:00 +00003661#line 2123 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003662{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003663 yyval.ValueList = yyvsp[-2].ValueList;
3664 yyvsp[-2].ValueList->push_back(yyvsp[0].ValueVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003665 ;
3666 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003667case 208:
Chris Lattner0ad19702006-06-21 16:53:00 +00003668#line 2129 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003669{ yyval.ValueList = 0; ;
3670 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003671case 209:
Chris Lattner0ad19702006-06-21 16:53:00 +00003672#line 2131 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003673{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003674 yyval.BoolVal = true;
Chris Lattner8335e842006-01-23 23:05:42 +00003675 ;
3676 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003677case 210:
Chris Lattner0ad19702006-06-21 16:53:00 +00003678#line 2134 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003679{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003680 yyval.BoolVal = false;
Chris Lattner8335e842006-01-23 23:05:42 +00003681 ;
3682 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003683case 211:
Chris Lattner0ad19702006-06-21 16:53:00 +00003684#line 2140 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003685{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003686 if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
3687 !isa<PackedType>((*yyvsp[-3].TypeVal).get()))
3688 ThrowException(
3689 "Arithmetic operator requires integer, FP, or packed operands!");
3690 if (isa<PackedType>((*yyvsp[-3].TypeVal).get()) && yyvsp[-4].BinaryOpVal == Instruction::Rem)
3691 ThrowException("Rem not supported on packed types!");
3692 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3693 if (yyval.InstVal == 0)
3694 ThrowException("binary operator returned null!");
3695 delete yyvsp[-3].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003696 ;
3697 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003698case 212:
Chris Lattner0ad19702006-06-21 16:53:00 +00003699#line 2152 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003700{
Chris Lattner524a1312005-12-21 18:31:50 +00003701 if (!(*yyvsp[-3].TypeVal)->isIntegral()) {
3702 if (!isa<PackedType>(yyvsp[-3].TypeVal->get()) ||
3703 !cast<PackedType>(yyvsp[-3].TypeVal->get())->getElementType()->isIntegral())
3704 ThrowException("Logical operator requires integral operands!");
3705 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00003706 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3707 if (yyval.InstVal == 0)
3708 ThrowException("binary operator returned null!");
3709 delete yyvsp[-3].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003710 ;
3711 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003712case 213:
Chris Lattner0ad19702006-06-21 16:53:00 +00003713#line 2163 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003714{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003715 if(isa<PackedType>((*yyvsp[-3].TypeVal).get())) {
3716 ThrowException(
3717 "PackedTypes currently not supported in setcc instructions!");
3718 }
3719 yyval.InstVal = new SetCondInst(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3720 if (yyval.InstVal == 0)
3721 ThrowException("binary operator returned null!");
3722 delete yyvsp[-3].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003723 ;
3724 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003725case 214:
Chris Lattner0ad19702006-06-21 16:53:00 +00003726#line 2173 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003727{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003728 std::cerr << "WARNING: Use of eliminated 'not' instruction:"
3729 << " Replacing with 'xor'.\n";
3730
3731 Value *Ones = ConstantIntegral::getAllOnesValue(yyvsp[0].ValueVal->getType());
3732 if (Ones == 0)
3733 ThrowException("Expected integral type for not instruction!");
3734
3735 yyval.InstVal = BinaryOperator::create(Instruction::Xor, yyvsp[0].ValueVal, Ones);
3736 if (yyval.InstVal == 0)
3737 ThrowException("Could not create a xor instruction!");
Chris Lattner8335e842006-01-23 23:05:42 +00003738 ;
3739 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003740case 215:
Chris Lattner0ad19702006-06-21 16:53:00 +00003741#line 2185 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003742{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003743 if (yyvsp[0].ValueVal->getType() != Type::UByteTy)
3744 ThrowException("Shift amount must be ubyte!");
3745 if (!yyvsp[-2].ValueVal->getType()->isInteger())
3746 ThrowException("Shift constant expression requires integer operand!");
3747 yyval.InstVal = new ShiftInst(yyvsp[-3].OtherOpVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003748 ;
3749 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003750case 216:
Chris Lattner0ad19702006-06-21 16:53:00 +00003751#line 2192 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003752{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003753 if (!yyvsp[0].TypeVal->get()->isFirstClassType())
3754 ThrowException("cast instruction to a non-primitive type: '" +
3755 yyvsp[0].TypeVal->get()->getDescription() + "'!");
3756 yyval.InstVal = new CastInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
3757 delete yyvsp[0].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003758 ;
3759 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003760case 217:
Chris Lattner0ad19702006-06-21 16:53:00 +00003761#line 2199 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003762{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003763 if (yyvsp[-4].ValueVal->getType() != Type::BoolTy)
3764 ThrowException("select condition must be boolean!");
3765 if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
3766 ThrowException("select value types should match!");
3767 yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003768 ;
3769 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003770case 218:
Chris Lattner0ad19702006-06-21 16:53:00 +00003771#line 2206 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003772{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003773 NewVarArgs = true;
3774 yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
3775 delete yyvsp[0].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003776 ;
3777 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003778case 219:
Chris Lattner0ad19702006-06-21 16:53:00 +00003779#line 2211 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003780{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003781 ObsoleteVarArgs = true;
3782 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
3783 Function* NF = CurModule.CurrentModule->
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003784 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003785
3786 //b = vaarg a, t ->
3787 //foo = alloca 1 of t
3788 //bar = vacopy a
3789 //store bar -> foo
3790 //b = vaarg foo, t
3791 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
3792 CurBB->getInstList().push_back(foo);
3793 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
3794 CurBB->getInstList().push_back(bar);
3795 CurBB->getInstList().push_back(new StoreInst(bar, foo));
3796 yyval.InstVal = new VAArgInst(foo, *yyvsp[0].TypeVal);
3797 delete yyvsp[0].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003798 ;
3799 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003800case 220:
Chris Lattner0ad19702006-06-21 16:53:00 +00003801#line 2230 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003802{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003803 ObsoleteVarArgs = true;
3804 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
3805 Function* NF = CurModule.CurrentModule->
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003806 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003807
3808 //b = vanext a, t ->
3809 //foo = alloca 1 of t
3810 //bar = vacopy a
3811 //store bar -> foo
3812 //tmp = vaarg foo, t
3813 //b = load foo
3814 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
3815 CurBB->getInstList().push_back(foo);
3816 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
3817 CurBB->getInstList().push_back(bar);
3818 CurBB->getInstList().push_back(new StoreInst(bar, foo));
3819 Instruction* tmp = new VAArgInst(foo, *yyvsp[0].TypeVal);
3820 CurBB->getInstList().push_back(tmp);
3821 yyval.InstVal = new LoadInst(foo);
3822 delete yyvsp[0].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003823 ;
3824 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003825case 221:
Chris Lattner0ad19702006-06-21 16:53:00 +00003826#line 2252 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003827{
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003828 if (!ExtractElementInst::isValidOperands(yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
3829 ThrowException("Invalid extractelement operands!");
Robert Bocchino9c62b562006-01-10 19:04:32 +00003830 yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003831 ;
3832 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003833case 222:
Chris Lattner0ad19702006-06-21 16:53:00 +00003834#line 2257 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003835{
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003836 if (!InsertElementInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
3837 ThrowException("Invalid insertelement operands!");
Robert Bocchino2def1b32006-01-17 20:06:25 +00003838 yyval.InstVal = new InsertElementInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003839 ;
3840 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003841case 223:
Chris Lattner0ad19702006-06-21 16:53:00 +00003842#line 2262 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerd5efe842006-04-08 01:18:56 +00003843{
Chris Lattnerd25db202006-04-08 03:55:17 +00003844 if (!ShuffleVectorInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
3845 ThrowException("Invalid shufflevector operands!");
Chris Lattnerd5efe842006-04-08 01:18:56 +00003846 yyval.InstVal = new ShuffleVectorInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
3847 ;
3848 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003849case 224:
Chris Lattner0ad19702006-06-21 16:53:00 +00003850#line 2267 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003851{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003852 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
3853 if (!Ty->isFirstClassType())
3854 ThrowException("PHI node operands must be of first class type!");
3855 yyval.InstVal = new PHINode(Ty);
3856 ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
3857 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
3858 if (yyvsp[0].PHIList->front().first->getType() != Ty)
3859 ThrowException("All elements of a PHI node must be of the same type!");
3860 cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
3861 yyvsp[0].PHIList->pop_front();
3862 }
3863 delete yyvsp[0].PHIList; // Free the list...
Chris Lattner8335e842006-01-23 23:05:42 +00003864 ;
3865 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003866case 225:
Chris Lattner0ad19702006-06-21 16:53:00 +00003867#line 2281 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003868{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003869 const PointerType *PFTy;
3870 const FunctionType *Ty;
3871
3872 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-4].TypeVal->get())) ||
3873 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3874 // Pull out the types of all of the arguments...
3875 std::vector<const Type*> ParamTypes;
3876 if (yyvsp[-1].ValueList) {
3877 for (std::vector<Value*>::iterator I = yyvsp[-1].ValueList->begin(), E = yyvsp[-1].ValueList->end();
3878 I != E; ++I)
3879 ParamTypes.push_back((*I)->getType());
3880 }
3881
3882 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3883 if (isVarArg) ParamTypes.pop_back();
3884
3885 if (!(*yyvsp[-4].TypeVal)->isFirstClassType() && *yyvsp[-4].TypeVal != Type::VoidTy)
3886 ThrowException("LLVM functions cannot return aggregate types!");
3887
3888 Ty = FunctionType::get(yyvsp[-4].TypeVal->get(), ParamTypes, isVarArg);
3889 PFTy = PointerType::get(Ty);
3890 }
3891
3892 Value *V = getVal(PFTy, yyvsp[-3].ValIDVal); // Get the function we're calling...
3893
3894 // Create the call node...
3895 if (!yyvsp[-1].ValueList) { // Has no arguments?
3896 // Make sure no arguments is a good thing!
3897 if (Ty->getNumParams() != 0)
3898 ThrowException("No arguments passed to a function that "
3899 "expects arguments!");
3900
3901 yyval.InstVal = new CallInst(V, std::vector<Value*>());
3902 } else { // Has arguments?
3903 // Loop through FunctionType's arguments and ensure they are specified
3904 // correctly!
3905 //
3906 FunctionType::param_iterator I = Ty->param_begin();
3907 FunctionType::param_iterator E = Ty->param_end();
3908 std::vector<Value*>::iterator ArgI = yyvsp[-1].ValueList->begin(), ArgE = yyvsp[-1].ValueList->end();
3909
3910 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3911 if ((*ArgI)->getType() != *I)
3912 ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
3913 (*I)->getDescription() + "'!");
3914
3915 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
3916 ThrowException("Invalid number of parameters detected!");
3917
3918 yyval.InstVal = new CallInst(V, *yyvsp[-1].ValueList);
3919 }
3920 cast<CallInst>(yyval.InstVal)->setTailCall(yyvsp[-6].BoolVal);
3921 cast<CallInst>(yyval.InstVal)->setCallingConv(yyvsp[-5].UIntVal);
3922 delete yyvsp[-4].TypeVal;
3923 delete yyvsp[-1].ValueList;
Chris Lattner8335e842006-01-23 23:05:42 +00003924 ;
3925 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003926case 226:
Chris Lattner0ad19702006-06-21 16:53:00 +00003927#line 2338 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003928{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003929 yyval.InstVal = yyvsp[0].InstVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003930 ;
3931 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003932case 227:
Chris Lattner0ad19702006-06-21 16:53:00 +00003933#line 2344 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003934{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003935 yyval.ValueList = yyvsp[0].ValueList;
Chris Lattner8335e842006-01-23 23:05:42 +00003936 ;
3937 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003938case 228:
Chris Lattner0ad19702006-06-21 16:53:00 +00003939#line 2346 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003940{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003941 yyval.ValueList = new std::vector<Value*>();
Chris Lattner8335e842006-01-23 23:05:42 +00003942 ;
3943 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003944case 229:
Chris Lattner0ad19702006-06-21 16:53:00 +00003945#line 2350 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003946{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003947 yyval.BoolVal = true;
Chris Lattner8335e842006-01-23 23:05:42 +00003948 ;
3949 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003950case 230:
Chris Lattner0ad19702006-06-21 16:53:00 +00003951#line 2353 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003952{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003953 yyval.BoolVal = false;
Chris Lattner8335e842006-01-23 23:05:42 +00003954 ;
3955 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003956case 231:
Chris Lattner0ad19702006-06-21 16:53:00 +00003957#line 2359 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003958{
Chris Lattner7d09ab62005-11-06 06:34:34 +00003959 yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
3960 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003961 ;
3962 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003963case 232:
Chris Lattner0ad19702006-06-21 16:53:00 +00003964#line 2363 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003965{
Chris Lattner7d09ab62005-11-06 06:34:34 +00003966 yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal);
3967 delete yyvsp[-4].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003968 ;
3969 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003970case 233:
Chris Lattner0ad19702006-06-21 16:53:00 +00003971#line 2367 "/Volumes/ProjectsDisk/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 AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
3974 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003975 ;
3976 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003977case 234:
Chris Lattner0ad19702006-06-21 16:53:00 +00003978#line 2371 "/Volumes/ProjectsDisk/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 AllocaInst(*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 Lattner75466192006-05-19 21:28:53 +00003984case 235:
Chris Lattner0ad19702006-06-21 16:53:00 +00003985#line 2375 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003986{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003987 if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
3988 ThrowException("Trying to free nonpointer type " +
3989 yyvsp[0].ValueVal->getType()->getDescription() + "!");
3990 yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003991 ;
3992 break;}
Chris Lattner75466192006-05-19 21:28:53 +00003993case 236:
Chris Lattner0ad19702006-06-21 16:53:00 +00003994#line 2382 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003995{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003996 if (!isa<PointerType>(yyvsp[-1].TypeVal->get()))
3997 ThrowException("Can't load from nonpointer type: " +
3998 (*yyvsp[-1].TypeVal)->getDescription());
3999 if (!cast<PointerType>(yyvsp[-1].TypeVal->get())->getElementType()->isFirstClassType())
4000 ThrowException("Can't load from pointer of non-first-class type: " +
4001 (*yyvsp[-1].TypeVal)->getDescription());
4002 yyval.InstVal = new LoadInst(getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), "", yyvsp[-3].BoolVal);
4003 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00004004 ;
4005 break;}
Chris Lattner75466192006-05-19 21:28:53 +00004006case 237:
Chris Lattner0ad19702006-06-21 16:53:00 +00004007#line 2392 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00004008{
Reid Spencer68a24bd2005-08-27 18:50:39 +00004009 const PointerType *PT = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
4010 if (!PT)
4011 ThrowException("Can't store to a nonpointer type: " +
4012 (*yyvsp[-1].TypeVal)->getDescription());
4013 const Type *ElTy = PT->getElementType();
4014 if (ElTy != yyvsp[-3].ValueVal->getType())
4015 ThrowException("Can't store '" + yyvsp[-3].ValueVal->getType()->getDescription() +
4016 "' into space of type '" + ElTy->getDescription() + "'!");
4017
4018 yyval.InstVal = new StoreInst(yyvsp[-3].ValueVal, getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), yyvsp[-5].BoolVal);
4019 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00004020 ;
4021 break;}
Chris Lattner75466192006-05-19 21:28:53 +00004022case 238:
Chris Lattner0ad19702006-06-21 16:53:00 +00004023#line 2405 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00004024{
Reid Spencer68a24bd2005-08-27 18:50:39 +00004025 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
4026 ThrowException("getelementptr insn requires pointer operand!");
4027
4028 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
4029 // indices to uint struct indices for compatibility.
4030 generic_gep_type_iterator<std::vector<Value*>::iterator>
4031 GTI = gep_type_begin(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end()),
4032 GTE = gep_type_end(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end());
4033 for (unsigned i = 0, e = yyvsp[0].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
4034 if (isa<StructType>(*GTI)) // Only change struct indices
4035 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[0].ValueList)[i]))
4036 if (CUI->getType() == Type::UByteTy)
4037 (*yyvsp[0].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
4038
4039 if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, *yyvsp[0].ValueList, true))
4040 ThrowException("Invalid getelementptr indices for type '" +
4041 (*yyvsp[-2].TypeVal)->getDescription()+ "'!");
4042 yyval.InstVal = new GetElementPtrInst(getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal), *yyvsp[0].ValueList);
4043 delete yyvsp[-2].TypeVal; delete yyvsp[0].ValueList;
Chris Lattner8335e842006-01-23 23:05:42 +00004044 ;
4045 break;}
4046}
4047 /* the action file gets copied in in place of this dollarsign */
4048#line 543 "/usr/share/bison.simple"
Reid Spencer68a24bd2005-08-27 18:50:39 +00004049
4050 yyvsp -= yylen;
4051 yyssp -= yylen;
Chris Lattner8335e842006-01-23 23:05:42 +00004052#ifdef YYLSP_NEEDED
4053 yylsp -= yylen;
4054#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00004055
Chris Lattner8335e842006-01-23 23:05:42 +00004056#if YYDEBUG != 0
4057 if (yydebug)
4058 {
4059 short *ssp1 = yyss - 1;
4060 fprintf (stderr, "state stack now");
4061 while (ssp1 != yyssp)
4062 fprintf (stderr, " %d", *++ssp1);
4063 fprintf (stderr, "\n");
4064 }
4065#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00004066
4067 *++yyvsp = yyval;
4068
Chris Lattner8335e842006-01-23 23:05:42 +00004069#ifdef YYLSP_NEEDED
4070 yylsp++;
4071 if (yylen == 0)
4072 {
4073 yylsp->first_line = yylloc.first_line;
4074 yylsp->first_column = yylloc.first_column;
4075 yylsp->last_line = (yylsp-1)->last_line;
4076 yylsp->last_column = (yylsp-1)->last_column;
4077 yylsp->text = 0;
4078 }
4079 else
4080 {
4081 yylsp->last_line = (yylsp+yylen-1)->last_line;
4082 yylsp->last_column = (yylsp+yylen-1)->last_column;
4083 }
4084#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00004085
Chris Lattner8335e842006-01-23 23:05:42 +00004086 /* Now "shift" the result of the reduction.
4087 Determine what state that goes to,
4088 based on the state we popped back to
4089 and the rule number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004090
4091 yyn = yyr1[yyn];
4092
Chris Lattner8335e842006-01-23 23:05:42 +00004093 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
4094 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004095 yystate = yytable[yystate];
4096 else
Chris Lattner8335e842006-01-23 23:05:42 +00004097 yystate = yydefgoto[yyn - YYNTBASE];
Reid Spencer68a24bd2005-08-27 18:50:39 +00004098
4099 goto yynewstate;
4100
Chris Lattner8335e842006-01-23 23:05:42 +00004101yyerrlab: /* here on detecting error */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004102
Chris Lattner8335e842006-01-23 23:05:42 +00004103 if (! yyerrstatus)
4104 /* If not already recovering from an error, report this error. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004105 {
4106 ++yynerrs;
Chris Lattner8335e842006-01-23 23:05:42 +00004107
4108#ifdef YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00004109 yyn = yypact[yystate];
4110
Chris Lattner8335e842006-01-23 23:05:42 +00004111 if (yyn > YYFLAG && yyn < YYLAST)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004112 {
Chris Lattner8335e842006-01-23 23:05:42 +00004113 int size = 0;
4114 char *msg;
4115 int x, count;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004116
Chris Lattner8335e842006-01-23 23:05:42 +00004117 count = 0;
4118 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
4119 for (x = (yyn < 0 ? -yyn : 0);
4120 x < (sizeof(yytname) / sizeof(char *)); x++)
4121 if (yycheck[x + yyn] == x)
4122 size += strlen(yytname[x]) + 15, count++;
4123 msg = (char *) malloc(size + 15);
4124 if (msg != 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004125 {
Chris Lattner8335e842006-01-23 23:05:42 +00004126 strcpy(msg, "parse error");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004127
Chris Lattner8335e842006-01-23 23:05:42 +00004128 if (count < 5)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004129 {
Chris Lattner8335e842006-01-23 23:05:42 +00004130 count = 0;
4131 for (x = (yyn < 0 ? -yyn : 0);
4132 x < (sizeof(yytname) / sizeof(char *)); x++)
4133 if (yycheck[x + yyn] == x)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004134 {
Chris Lattner8335e842006-01-23 23:05:42 +00004135 strcat(msg, count == 0 ? ", expecting `" : " or `");
4136 strcat(msg, yytname[x]);
4137 strcat(msg, "'");
4138 count++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004139 }
4140 }
Chris Lattner8335e842006-01-23 23:05:42 +00004141 yyerror(msg);
4142 free(msg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004143 }
4144 else
Chris Lattner8335e842006-01-23 23:05:42 +00004145 yyerror ("parse error; also virtual memory exceeded");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004146 }
4147 else
4148#endif /* YYERROR_VERBOSE */
Chris Lattner8335e842006-01-23 23:05:42 +00004149 yyerror("parse error");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004150 }
4151
Chris Lattner8335e842006-01-23 23:05:42 +00004152 goto yyerrlab1;
4153yyerrlab1: /* here on error raised explicitly by an action */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004154
4155 if (yyerrstatus == 3)
4156 {
Chris Lattner8335e842006-01-23 23:05:42 +00004157 /* if just tried and failed to reuse lookahead token after an error, discard it. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004158
Chris Lattner8335e842006-01-23 23:05:42 +00004159 /* return failure if at end of input */
4160 if (yychar == YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004161 YYABORT;
4162
Chris Lattner8335e842006-01-23 23:05:42 +00004163#if YYDEBUG != 0
4164 if (yydebug)
4165 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
4166#endif
4167
4168 yychar = YYEMPTY;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004169 }
4170
Chris Lattner8335e842006-01-23 23:05:42 +00004171 /* Else will try to reuse lookahead token
4172 after shifting the error token. */
4173
4174 yyerrstatus = 3; /* Each real token shifted decrements this */
4175
4176 goto yyerrhandle;
4177
4178yyerrdefault: /* current state does not do anything special for the error token. */
4179
4180#if 0
4181 /* This is wrong; only states that explicitly want error tokens
4182 should shift them. */
4183 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
4184 if (yyn) goto yydefault;
4185#endif
4186
4187yyerrpop: /* pop the current state because it cannot handle the error token */
4188
4189 if (yyssp == yyss) YYABORT;
4190 yyvsp--;
4191 yystate = *--yyssp;
4192#ifdef YYLSP_NEEDED
4193 yylsp--;
4194#endif
4195
4196#if YYDEBUG != 0
4197 if (yydebug)
4198 {
4199 short *ssp1 = yyss - 1;
4200 fprintf (stderr, "Error: state stack now");
4201 while (ssp1 != yyssp)
4202 fprintf (stderr, " %d", *++ssp1);
4203 fprintf (stderr, "\n");
4204 }
4205#endif
4206
4207yyerrhandle:
4208
4209 yyn = yypact[yystate];
4210 if (yyn == YYFLAG)
4211 goto yyerrdefault;
4212
4213 yyn += YYTERROR;
4214 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
4215 goto yyerrdefault;
4216
4217 yyn = yytable[yyn];
4218 if (yyn < 0)
4219 {
4220 if (yyn == YYFLAG)
4221 goto yyerrpop;
4222 yyn = -yyn;
4223 goto yyreduce;
4224 }
4225 else if (yyn == 0)
4226 goto yyerrpop;
4227
Reid Spencer68a24bd2005-08-27 18:50:39 +00004228 if (yyn == YYFINAL)
4229 YYACCEPT;
4230
Chris Lattner8335e842006-01-23 23:05:42 +00004231#if YYDEBUG != 0
4232 if (yydebug)
4233 fprintf(stderr, "Shifting error token, ");
4234#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00004235
4236 *++yyvsp = yylval;
Chris Lattner8335e842006-01-23 23:05:42 +00004237#ifdef YYLSP_NEEDED
4238 *++yylsp = yylloc;
4239#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00004240
4241 yystate = yyn;
4242 goto yynewstate;
4243
Chris Lattner8335e842006-01-23 23:05:42 +00004244 yyacceptlab:
4245 /* YYACCEPT comes here. */
4246 if (yyfree_stacks)
4247 {
4248 free (yyss);
4249 free (yyvs);
4250#ifdef YYLSP_NEEDED
4251 free (yyls);
Reid Spencer0b118202006-01-16 21:12:35 +00004252#endif
Chris Lattner8335e842006-01-23 23:05:42 +00004253 }
4254 return 0;
Reid Spencere812fb22006-01-19 01:21:04 +00004255
Chris Lattner8335e842006-01-23 23:05:42 +00004256 yyabortlab:
4257 /* YYABORT comes here. */
4258 if (yyfree_stacks)
4259 {
4260 free (yyss);
4261 free (yyvs);
4262#ifdef YYLSP_NEEDED
4263 free (yyls);
Reid Spencere812fb22006-01-19 01:21:04 +00004264#endif
Chris Lattner8335e842006-01-23 23:05:42 +00004265 }
4266 return 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004267}
Chris Lattner0ad19702006-06-21 16:53:00 +00004268#line 2428 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00004269
4270int yyerror(const char *ErrorMsg) {
4271 std::string where
4272 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
4273 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
4274 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
4275 if (yychar == YYEMPTY || yychar == 0)
4276 errMsg += "end-of-file.";
4277 else
4278 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
4279 ThrowException(errMsg);
4280 return 0;
4281}