blob: 93235c963f8ce8720374a1581ae4869e8c503764 [file] [log] [blame]
Reid Spencer68a24bd2005-08-27 18:50:39 +00001
Chris Lattner7aa61892005-12-21 17:53:23 +00002/* A Bison parser, made from /Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y
Nate Begeman14b05292005-11-05 09:21:28 +00003 by GNU Bison version 1.28 */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004
Nate Begeman14b05292005-11-05 09:21:28 +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
Nate Begeman14b05292005-11-05 09:21:28 +00008#define yylex llvmAsmlex
Reid Spencer68a24bd2005-08-27 18:50:39 +00009#define yyerror llvmAsmerror
Nate Begeman14b05292005-11-05 09:21:28 +000010#define yylval llvmAsmlval
11#define yychar llvmAsmchar
Reid Spencer68a24bd2005-08-27 18:50:39 +000012#define yydebug llvmAsmdebug
13#define yynerrs llvmAsmnerrs
Nate Begeman14b05292005-11-05 09:21:28 +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
Chris Lattnere869eef2005-11-12 00:11:49 +000045#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 CC_TOK 312
70#define CCC_TOK 313
71#define FASTCC_TOK 314
72#define COLDCC_TOK 315
73#define RET 316
74#define BR 317
75#define SWITCH 318
76#define INVOKE 319
77#define UNWIND 320
78#define UNREACHABLE 321
79#define ADD 322
80#define SUB 323
81#define MUL 324
82#define DIV 325
83#define REM 326
84#define AND 327
85#define OR 328
86#define XOR 329
87#define SETLE 330
88#define SETGE 331
89#define SETLT 332
90#define SETGT 333
91#define SETEQ 334
92#define SETNE 335
93#define MALLOC 336
94#define ALLOCA 337
95#define FREE 338
96#define LOAD 339
97#define STORE 340
98#define GETELEMENTPTR 341
99#define PHI_TOK 342
100#define CAST 343
101#define SELECT 344
102#define SHL 345
103#define SHR 346
104#define VAARG 347
105#define VAARG_old 348
106#define VANEXT_old 349
Reid Spencer68a24bd2005-08-27 18:50:39 +0000107
Chris Lattner7aa61892005-12-21 17:53:23 +0000108#line 14 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000109
110#include "ParserInternals.h"
111#include "llvm/CallingConv.h"
112#include "llvm/Instructions.h"
113#include "llvm/Module.h"
114#include "llvm/SymbolTable.h"
115#include "llvm/Support/GetElementPtrTypeIterator.h"
116#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000117#include "llvm/Support/MathExtras.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000118#include <algorithm>
119#include <iostream>
120#include <list>
121#include <utility>
122
123int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
124int yylex(); // declaration" of xxx warnings.
125int yyparse();
126
127namespace llvm {
128 std::string CurFilename;
129}
130using namespace llvm;
131
132static Module *ParserResult;
133
134// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
135// relating to upreferences in the input stream.
136//
137//#define DEBUG_UPREFS 1
138#ifdef DEBUG_UPREFS
139#define UR_OUT(X) std::cerr << X
140#else
141#define UR_OUT(X)
142#endif
143
144#define YYERROR_VERBOSE 1
145
146static bool ObsoleteVarArgs;
147static bool NewVarArgs;
Chris Lattnerb475c422005-11-12 18:22:38 +0000148static BasicBlock *CurBB;
149static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000150
151
152// This contains info used when building the body of a function. It is
153// destroyed when the function is completed.
154//
155typedef std::vector<Value *> ValueList; // Numbered defs
156static void
157ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
158 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
159
160static struct PerModuleInfo {
161 Module *CurrentModule;
162 std::map<const Type *, ValueList> Values; // Module level numbered definitions
163 std::map<const Type *,ValueList> LateResolveValues;
164 std::vector<PATypeHolder> Types;
165 std::map<ValID, PATypeHolder> LateResolveTypes;
166
167 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
168 /// how they were referenced and one which line of the input they came from so
169 /// that we can resolve them later and print error messages as appropriate.
170 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
171
172 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
173 // references to global values. Global values may be referenced before they
174 // are defined, and if so, the temporary object that they represent is held
175 // here. This is used for forward references of GlobalValues.
176 //
177 typedef std::map<std::pair<const PointerType *,
178 ValID>, GlobalValue*> GlobalRefsType;
179 GlobalRefsType GlobalRefs;
180
181 void ModuleDone() {
182 // If we could not resolve some functions at function compilation time
183 // (calls to functions before they are defined), resolve them now... Types
184 // are resolved when the constant pool has been completely parsed.
185 //
186 ResolveDefinitions(LateResolveValues);
187
188 // Check to make sure that all global value forward references have been
189 // resolved!
190 //
191 if (!GlobalRefs.empty()) {
192 std::string UndefinedReferences = "Unresolved global references exist:\n";
193
194 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
195 I != E; ++I) {
196 UndefinedReferences += " " + I->first.first->getDescription() + " " +
197 I->first.second.getName() + "\n";
198 }
199 ThrowException(UndefinedReferences);
200 }
201
202 Values.clear(); // Clear out function local definitions
203 Types.clear();
204 CurrentModule = 0;
205 }
206
207
208 // GetForwardRefForGlobal - Check to see if there is a forward reference
209 // for this global. If so, remove it from the GlobalRefs map and return it.
210 // If not, just return null.
211 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
212 // Check to see if there is a forward reference to this global variable...
213 // if there is, eliminate it and patch the reference to use the new def'n.
214 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
215 GlobalValue *Ret = 0;
216 if (I != GlobalRefs.end()) {
217 Ret = I->second;
218 GlobalRefs.erase(I);
219 }
220 return Ret;
221 }
222} CurModule;
223
224static struct PerFunctionInfo {
225 Function *CurrentFunction; // Pointer to current function being created
226
227 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
228 std::map<const Type*, ValueList> LateResolveValues;
229 bool isDeclare; // Is this function a forward declararation?
230
231 /// BBForwardRefs - When we see forward references to basic blocks, keep
232 /// track of them here.
233 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
234 std::vector<BasicBlock*> NumberedBlocks;
235 unsigned NextBBNum;
236
237 inline PerFunctionInfo() {
238 CurrentFunction = 0;
239 isDeclare = false;
240 }
241
242 inline void FunctionStart(Function *M) {
243 CurrentFunction = M;
244 NextBBNum = 0;
245 }
246
247 void FunctionDone() {
248 NumberedBlocks.clear();
249
250 // Any forward referenced blocks left?
251 if (!BBForwardRefs.empty())
252 ThrowException("Undefined reference to label " +
253 BBForwardRefs.begin()->first->getName());
254
255 // Resolve all forward references now.
256 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
257
258 Values.clear(); // Clear out function local definitions
259 CurrentFunction = 0;
260 isDeclare = false;
261 }
262} CurFun; // Info for the current function...
263
264static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
265
266
267//===----------------------------------------------------------------------===//
268// Code to handle definitions of all the types
269//===----------------------------------------------------------------------===//
270
271static int InsertValue(Value *V,
272 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
273 if (V->hasName()) return -1; // Is this a numbered definition?
274
275 // Yes, insert the value into the value table...
276 ValueList &List = ValueTab[V->getType()];
277 List.push_back(V);
278 return List.size()-1;
279}
280
281static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
282 switch (D.Type) {
283 case ValID::NumberVal: // Is it a numbered definition?
284 // Module constants occupy the lowest numbered slots...
285 if ((unsigned)D.Num < CurModule.Types.size())
286 return CurModule.Types[(unsigned)D.Num];
287 break;
288 case ValID::NameVal: // Is it a named definition?
289 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
290 D.destroy(); // Free old strdup'd memory...
291 return N;
292 }
293 break;
294 default:
295 ThrowException("Internal parser error: Invalid symbol type reference!");
296 }
297
298 // If we reached here, we referenced either a symbol that we don't know about
299 // or an id number that hasn't been read yet. We may be referencing something
300 // forward, so just create an entry to be resolved later and get to it...
301 //
302 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
303
304
305 if (inFunctionScope()) {
306 if (D.Type == ValID::NameVal)
307 ThrowException("Reference to an undefined type: '" + D.getName() + "'");
308 else
309 ThrowException("Reference to an undefined type: #" + itostr(D.Num));
310 }
311
312 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
313 if (I != CurModule.LateResolveTypes.end())
314 return I->second;
315
316 Type *Typ = OpaqueType::get();
317 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
318 return Typ;
319 }
320
321static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
322 SymbolTable &SymTab =
323 inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() :
324 CurModule.CurrentModule->getSymbolTable();
325 return SymTab.lookup(Ty, Name);
326}
327
328// getValNonImprovising - Look up the value specified by the provided type and
329// the provided ValID. If the value exists and has already been defined, return
330// it. Otherwise return null.
331//
332static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
333 if (isa<FunctionType>(Ty))
334 ThrowException("Functions are not values and "
335 "must be referenced as pointers");
336
337 switch (D.Type) {
338 case ValID::NumberVal: { // Is it a numbered definition?
339 unsigned Num = (unsigned)D.Num;
340
341 // Module constants occupy the lowest numbered slots...
342 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
343 if (VI != CurModule.Values.end()) {
344 if (Num < VI->second.size())
345 return VI->second[Num];
346 Num -= VI->second.size();
347 }
348
349 // Make sure that our type is within bounds
350 VI = CurFun.Values.find(Ty);
351 if (VI == CurFun.Values.end()) return 0;
352
353 // Check that the number is within bounds...
354 if (VI->second.size() <= Num) return 0;
355
356 return VI->second[Num];
357 }
358
359 case ValID::NameVal: { // Is it a named definition?
360 Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
361 if (N == 0) return 0;
362
363 D.destroy(); // Free old strdup'd memory...
364 return N;
365 }
366
367 // Check to make sure that "Ty" is an integral type, and that our
368 // value will fit into the specified type...
369 case ValID::ConstSIntVal: // Is it a constant pool reference??
370 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64))
371 ThrowException("Signed integral constant '" +
372 itostr(D.ConstPool64) + "' is invalid for type '" +
373 Ty->getDescription() + "'!");
374 return ConstantSInt::get(Ty, D.ConstPool64);
375
376 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
377 if (!ConstantUInt::isValueValidForType(Ty, D.UConstPool64)) {
378 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) {
379 ThrowException("Integral constant '" + utostr(D.UConstPool64) +
380 "' is invalid or out of range!");
381 } else { // This is really a signed reference. Transmogrify.
382 return ConstantSInt::get(Ty, D.ConstPool64);
383 }
384 } else {
385 return ConstantUInt::get(Ty, D.UConstPool64);
386 }
387
388 case ValID::ConstFPVal: // Is it a floating point const pool reference?
389 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
390 ThrowException("FP constant invalid for type!!");
391 return ConstantFP::get(Ty, D.ConstPoolFP);
392
393 case ValID::ConstNullVal: // Is it a null value?
394 if (!isa<PointerType>(Ty))
395 ThrowException("Cannot create a a non pointer null!");
396 return ConstantPointerNull::get(cast<PointerType>(Ty));
397
398 case ValID::ConstUndefVal: // Is it an undef value?
399 return UndefValue::get(Ty);
400
Chris Lattner7aa61892005-12-21 17:53:23 +0000401 case ValID::ConstZeroVal: // Is it a zero value?
402 return Constant::getNullValue(Ty);
403
Reid Spencer68a24bd2005-08-27 18:50:39 +0000404 case ValID::ConstantVal: // Fully resolved constant?
405 if (D.ConstantValue->getType() != Ty)
406 ThrowException("Constant expression type different from required type!");
407 return D.ConstantValue;
408
409 default:
410 assert(0 && "Unhandled case!");
411 return 0;
412 } // End of switch
413
414 assert(0 && "Unhandled case!");
415 return 0;
416}
417
418// getVal - This function is identical to getValNonImprovising, except that if a
419// value is not already defined, it "improvises" by creating a placeholder var
420// that looks and acts just like the requested variable. When the value is
421// defined later, all uses of the placeholder variable are replaced with the
422// real thing.
423//
424static Value *getVal(const Type *Ty, const ValID &ID) {
425 if (Ty == Type::LabelTy)
426 ThrowException("Cannot use a basic block here");
427
428 // See if the value has already been defined.
429 Value *V = getValNonImprovising(Ty, ID);
430 if (V) return V;
431
432 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
433 ThrowException("Invalid use of a composite type!");
434
435 // If we reached here, we referenced either a symbol that we don't know about
436 // or an id number that hasn't been read yet. We may be referencing something
437 // forward, so just create an entry to be resolved later and get to it...
438 //
439 V = new Argument(Ty);
440
441 // Remember where this forward reference came from. FIXME, shouldn't we try
442 // to recycle these things??
443 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
444 llvmAsmlineno)));
445
446 if (inFunctionScope())
447 InsertValue(V, CurFun.LateResolveValues);
448 else
449 InsertValue(V, CurModule.LateResolveValues);
450 return V;
451}
452
453/// getBBVal - This is used for two purposes:
454/// * If isDefinition is true, a new basic block with the specified ID is being
455/// defined.
456/// * If isDefinition is true, this is a reference to a basic block, which may
457/// or may not be a forward reference.
458///
459static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
460 assert(inFunctionScope() && "Can't get basic block at global scope!");
461
462 std::string Name;
463 BasicBlock *BB = 0;
464 switch (ID.Type) {
465 default: ThrowException("Illegal label reference " + ID.getName());
466 case ValID::NumberVal: // Is it a numbered definition?
467 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
468 CurFun.NumberedBlocks.resize(ID.Num+1);
469 BB = CurFun.NumberedBlocks[ID.Num];
470 break;
471 case ValID::NameVal: // Is it a named definition?
472 Name = ID.Name;
473 if (Value *N = CurFun.CurrentFunction->
474 getSymbolTable().lookup(Type::LabelTy, Name))
475 BB = cast<BasicBlock>(N);
476 break;
477 }
478
479 // See if the block has already been defined.
480 if (BB) {
481 // If this is the definition of the block, make sure the existing value was
482 // just a forward reference. If it was a forward reference, there will be
483 // an entry for it in the PlaceHolderInfo map.
484 if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
485 // The existing value was a definition, not a forward reference.
486 ThrowException("Redefinition of label " + ID.getName());
487
488 ID.destroy(); // Free strdup'd memory.
489 return BB;
490 }
491
492 // Otherwise this block has not been seen before.
493 BB = new BasicBlock("", CurFun.CurrentFunction);
494 if (ID.Type == ValID::NameVal) {
495 BB->setName(ID.Name);
496 } else {
497 CurFun.NumberedBlocks[ID.Num] = BB;
498 }
499
500 // If this is not a definition, keep track of it so we can use it as a forward
501 // reference.
502 if (!isDefinition) {
503 // Remember where this forward reference came from.
504 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
505 } else {
506 // The forward declaration could have been inserted anywhere in the
507 // function: insert it into the correct place now.
508 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
509 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
510 }
511 ID.destroy();
512 return BB;
513}
514
515
516//===----------------------------------------------------------------------===//
517// Code to handle forward references in instructions
518//===----------------------------------------------------------------------===//
519//
520// This code handles the late binding needed with statements that reference
521// values not defined yet... for example, a forward branch, or the PHI node for
522// a loop body.
523//
524// This keeps a table (CurFun.LateResolveValues) of all such forward references
525// and back patchs after we are done.
526//
527
528// ResolveDefinitions - If we could not resolve some defs at parsing
529// time (forward branches, phi functions for loops, etc...) resolve the
530// defs now...
531//
532static void
533ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
534 std::map<const Type*,ValueList> *FutureLateResolvers) {
535 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
536 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
537 E = LateResolvers.end(); LRI != E; ++LRI) {
538 ValueList &List = LRI->second;
539 while (!List.empty()) {
540 Value *V = List.back();
541 List.pop_back();
542
543 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
544 CurModule.PlaceHolderInfo.find(V);
545 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
546
547 ValID &DID = PHI->second.first;
548
549 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
550 if (TheRealValue) {
551 V->replaceAllUsesWith(TheRealValue);
552 delete V;
553 CurModule.PlaceHolderInfo.erase(PHI);
554 } else if (FutureLateResolvers) {
555 // Functions have their unresolved items forwarded to the module late
556 // resolver table
557 InsertValue(V, *FutureLateResolvers);
558 } else {
559 if (DID.Type == ValID::NameVal)
560 ThrowException("Reference to an invalid definition: '" +DID.getName()+
561 "' of type '" + V->getType()->getDescription() + "'",
562 PHI->second.second);
563 else
564 ThrowException("Reference to an invalid definition: #" +
565 itostr(DID.Num) + " of type '" +
566 V->getType()->getDescription() + "'",
567 PHI->second.second);
568 }
569 }
570 }
571
572 LateResolvers.clear();
573}
574
575// ResolveTypeTo - A brand new type was just declared. This means that (if
576// name is not null) things referencing Name can be resolved. Otherwise, things
577// refering to the number can be resolved. Do this now.
578//
579static void ResolveTypeTo(char *Name, const Type *ToTy) {
580 ValID D;
581 if (Name) D = ValID::create(Name);
582 else D = ValID::create((int)CurModule.Types.size());
583
584 std::map<ValID, PATypeHolder>::iterator I =
585 CurModule.LateResolveTypes.find(D);
586 if (I != CurModule.LateResolveTypes.end()) {
587 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
588 CurModule.LateResolveTypes.erase(I);
589 }
590}
591
592// setValueName - Set the specified value to the name given. The name may be
593// null potentially, in which case this is a noop. The string passed in is
594// assumed to be a malloc'd string buffer, and is free'd by this function.
595//
596static void setValueName(Value *V, char *NameStr) {
597 if (NameStr) {
598 std::string Name(NameStr); // Copy string
599 free(NameStr); // Free old string
600
601 if (V->getType() == Type::VoidTy)
602 ThrowException("Can't assign name '" + Name+"' to value with void type!");
603
604 assert(inFunctionScope() && "Must be in function scope!");
605 SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable();
606 if (ST.lookup(V->getType(), Name))
607 ThrowException("Redefinition of value named '" + Name + "' in the '" +
608 V->getType()->getDescription() + "' type plane!");
609
610 // Set the name.
611 V->setName(Name);
612 }
613}
614
615/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
616/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +0000617static GlobalVariable *
618ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
619 bool isConstantGlobal, const Type *Ty,
620 Constant *Initializer) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000621 if (isa<FunctionType>(Ty))
622 ThrowException("Cannot declare global vars of function type!");
623
624 const PointerType *PTy = PointerType::get(Ty);
625
626 std::string Name;
627 if (NameStr) {
628 Name = NameStr; // Copy string
629 free(NameStr); // Free old string
630 }
631
632 // See if this global value was forward referenced. If so, recycle the
633 // object.
634 ValID ID;
635 if (!Name.empty()) {
636 ID = ValID::create((char*)Name.c_str());
637 } else {
638 ID = ValID::create((int)CurModule.Values[PTy].size());
639 }
640
641 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
642 // Move the global to the end of the list, from whereever it was
643 // previously inserted.
644 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
645 CurModule.CurrentModule->getGlobalList().remove(GV);
646 CurModule.CurrentModule->getGlobalList().push_back(GV);
647 GV->setInitializer(Initializer);
648 GV->setLinkage(Linkage);
649 GV->setConstant(isConstantGlobal);
650 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000651 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000652 }
653
654 // If this global has a name, check to see if there is already a definition
655 // of this global in the module. If so, merge as appropriate. Note that
656 // this is really just a hack around problems in the CFE. :(
657 if (!Name.empty()) {
658 // We are a simple redefinition of a value, check to see if it is defined
659 // the same as the old one.
660 if (GlobalVariable *EGV =
661 CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
662 // We are allowed to redefine a global variable in two circumstances:
663 // 1. If at least one of the globals is uninitialized or
664 // 2. If both initializers have the same value.
665 //
666 if (!EGV->hasInitializer() || !Initializer ||
667 EGV->getInitializer() == Initializer) {
668
669 // Make sure the existing global version gets the initializer! Make
670 // sure that it also gets marked const if the new version is.
671 if (Initializer && !EGV->hasInitializer())
672 EGV->setInitializer(Initializer);
673 if (isConstantGlobal)
674 EGV->setConstant(true);
675 EGV->setLinkage(Linkage);
Chris Lattnerb475c422005-11-12 18:22:38 +0000676 return EGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000677 }
678
679 ThrowException("Redefinition of global variable named '" + Name +
680 "' in the '" + Ty->getDescription() + "' type plane!");
681 }
682 }
683
684 // Otherwise there is no existing GV to use, create one now.
685 GlobalVariable *GV =
686 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
687 CurModule.CurrentModule);
688 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000689 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000690}
691
692// setTypeName - Set the specified type to the name given. The name may be
693// null potentially, in which case this is a noop. The string passed in is
694// assumed to be a malloc'd string buffer, and is freed by this function.
695//
696// This function returns true if the type has already been defined, but is
697// allowed to be redefined in the specified context. If the name is a new name
698// for the type plane, it is inserted and false is returned.
699static bool setTypeName(const Type *T, char *NameStr) {
700 assert(!inFunctionScope() && "Can't give types function-local names!");
701 if (NameStr == 0) return false;
702
703 std::string Name(NameStr); // Copy string
704 free(NameStr); // Free old string
705
706 // We don't allow assigning names to void type
707 if (T == Type::VoidTy)
708 ThrowException("Can't assign name '" + Name + "' to the void type!");
709
710 // Set the type name, checking for conflicts as we do so.
711 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
712
713 if (AlreadyExists) { // Inserting a name that is already defined???
714 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
715 assert(Existing && "Conflict but no matching type?");
716
717 // There is only one case where this is allowed: when we are refining an
718 // opaque type. In this case, Existing will be an opaque type.
719 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
720 // We ARE replacing an opaque type!
721 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
722 return true;
723 }
724
725 // Otherwise, this is an attempt to redefine a type. That's okay if
726 // the redefinition is identical to the original. This will be so if
727 // Existing and T point to the same Type object. In this one case we
728 // allow the equivalent redefinition.
729 if (Existing == T) return true; // Yes, it's equal.
730
731 // Any other kind of (non-equivalent) redefinition is an error.
732 ThrowException("Redefinition of type named '" + Name + "' in the '" +
733 T->getDescription() + "' type plane!");
734 }
735
736 return false;
737}
738
739//===----------------------------------------------------------------------===//
740// Code for handling upreferences in type names...
741//
742
743// TypeContains - Returns true if Ty directly contains E in it.
744//
745static bool TypeContains(const Type *Ty, const Type *E) {
746 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
747 E) != Ty->subtype_end();
748}
749
750namespace {
751 struct UpRefRecord {
752 // NestingLevel - The number of nesting levels that need to be popped before
753 // this type is resolved.
754 unsigned NestingLevel;
755
756 // LastContainedTy - This is the type at the current binding level for the
757 // type. Every time we reduce the nesting level, this gets updated.
758 const Type *LastContainedTy;
759
760 // UpRefTy - This is the actual opaque type that the upreference is
761 // represented with.
762 OpaqueType *UpRefTy;
763
764 UpRefRecord(unsigned NL, OpaqueType *URTy)
765 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
766 };
767}
768
769// UpRefs - A list of the outstanding upreferences that need to be resolved.
770static std::vector<UpRefRecord> UpRefs;
771
772/// HandleUpRefs - Every time we finish a new layer of types, this function is
773/// called. It loops through the UpRefs vector, which is a list of the
774/// currently active types. For each type, if the up reference is contained in
775/// the newly completed type, we decrement the level count. When the level
776/// count reaches zero, the upreferenced type is the type that is passed in:
777/// thus we can complete the cycle.
778///
779static PATypeHolder HandleUpRefs(const Type *ty) {
780 if (!ty->isAbstract()) return ty;
781 PATypeHolder Ty(ty);
782 UR_OUT("Type '" << Ty->getDescription() <<
783 "' newly formed. Resolving upreferences.\n" <<
784 UpRefs.size() << " upreferences active!\n");
785
786 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
787 // to zero), we resolve them all together before we resolve them to Ty. At
788 // the end of the loop, if there is anything to resolve to Ty, it will be in
789 // this variable.
790 OpaqueType *TypeToResolve = 0;
791
792 for (unsigned i = 0; i != UpRefs.size(); ++i) {
793 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
794 << UpRefs[i].second->getDescription() << ") = "
795 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
796 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
797 // Decrement level of upreference
798 unsigned Level = --UpRefs[i].NestingLevel;
799 UpRefs[i].LastContainedTy = Ty;
800 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
801 if (Level == 0) { // Upreference should be resolved!
802 if (!TypeToResolve) {
803 TypeToResolve = UpRefs[i].UpRefTy;
804 } else {
805 UR_OUT(" * Resolving upreference for "
806 << UpRefs[i].second->getDescription() << "\n";
807 std::string OldName = UpRefs[i].UpRefTy->getDescription());
808 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
809 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
810 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
811 }
812 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
813 --i; // Do not skip the next element...
814 }
815 }
816 }
817
818 if (TypeToResolve) {
819 UR_OUT(" * Resolving upreference for "
820 << UpRefs[i].second->getDescription() << "\n";
821 std::string OldName = TypeToResolve->getDescription());
822 TypeToResolve->refineAbstractTypeTo(Ty);
823 }
824
825 return Ty;
826}
827
828
829// common code from the two 'RunVMAsmParser' functions
830 static Module * RunParser(Module * M) {
831
832 llvmAsmlineno = 1; // Reset the current line number...
833 ObsoleteVarArgs = false;
834 NewVarArgs = false;
835
836 CurModule.CurrentModule = M;
837 yyparse(); // Parse the file, potentially throwing exception
838
839 Module *Result = ParserResult;
840 ParserResult = 0;
841
842 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
843 {
844 Function* F;
845 if ((F = Result->getNamedFunction("llvm.va_start"))
846 && F->getFunctionType()->getNumParams() == 0)
847 ObsoleteVarArgs = true;
848 if((F = Result->getNamedFunction("llvm.va_copy"))
849 && F->getFunctionType()->getNumParams() == 1)
850 ObsoleteVarArgs = true;
851 }
852
853 if (ObsoleteVarArgs && NewVarArgs)
854 ThrowException("This file is corrupt: it uses both new and old style varargs");
855
856 if(ObsoleteVarArgs) {
857 if(Function* F = Result->getNamedFunction("llvm.va_start")) {
858 if (F->arg_size() != 0)
859 ThrowException("Obsolete va_start takes 0 argument!");
860
861 //foo = va_start()
862 // ->
863 //bar = alloca typeof(foo)
864 //va_start(bar)
865 //foo = load bar
866
867 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
868 const Type* ArgTy = F->getFunctionType()->getReturnType();
869 const Type* ArgTyPtr = PointerType::get(ArgTy);
870 Function* NF = Result->getOrInsertFunction("llvm.va_start",
Jeff Cohen66c5fd62005-10-23 04:37:20 +0000871 RetTy, ArgTyPtr, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000872
873 while (!F->use_empty()) {
874 CallInst* CI = cast<CallInst>(F->use_back());
875 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
876 new CallInst(NF, bar, "", CI);
877 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
878 CI->replaceAllUsesWith(foo);
879 CI->getParent()->getInstList().erase(CI);
880 }
881 Result->getFunctionList().erase(F);
882 }
883
884 if(Function* F = Result->getNamedFunction("llvm.va_end")) {
885 if(F->arg_size() != 1)
886 ThrowException("Obsolete va_end takes 1 argument!");
887
888 //vaend foo
889 // ->
890 //bar = alloca 1 of typeof(foo)
891 //vaend bar
892 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
893 const Type* ArgTy = F->getFunctionType()->getParamType(0);
894 const Type* ArgTyPtr = PointerType::get(ArgTy);
895 Function* NF = Result->getOrInsertFunction("llvm.va_end",
Jeff Cohen66c5fd62005-10-23 04:37:20 +0000896 RetTy, ArgTyPtr, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000897
898 while (!F->use_empty()) {
899 CallInst* CI = cast<CallInst>(F->use_back());
900 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
901 new StoreInst(CI->getOperand(1), bar, CI);
902 new CallInst(NF, bar, "", CI);
903 CI->getParent()->getInstList().erase(CI);
904 }
905 Result->getFunctionList().erase(F);
906 }
907
908 if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
909 if(F->arg_size() != 1)
910 ThrowException("Obsolete va_copy takes 1 argument!");
911 //foo = vacopy(bar)
912 // ->
913 //a = alloca 1 of typeof(foo)
914 //b = alloca 1 of typeof(foo)
915 //store bar -> b
916 //vacopy(a, b)
917 //foo = load a
918
919 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
920 const Type* ArgTy = F->getFunctionType()->getReturnType();
921 const Type* ArgTyPtr = PointerType::get(ArgTy);
922 Function* NF = Result->getOrInsertFunction("llvm.va_copy",
Jeff Cohen66c5fd62005-10-23 04:37:20 +0000923 RetTy, ArgTyPtr, ArgTyPtr,
924 (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000925
926 while (!F->use_empty()) {
927 CallInst* CI = cast<CallInst>(F->use_back());
928 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
929 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
930 new StoreInst(CI->getOperand(1), b, CI);
931 new CallInst(NF, a, b, "", CI);
932 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
933 CI->replaceAllUsesWith(foo);
934 CI->getParent()->getInstList().erase(CI);
935 }
936 Result->getFunctionList().erase(F);
937 }
938 }
939
940 return Result;
941
942 }
943
944//===----------------------------------------------------------------------===//
945// RunVMAsmParser - Define an interface to this parser
946//===----------------------------------------------------------------------===//
947//
948Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
949 set_scan_file(F);
950
951 CurFilename = Filename;
952 return RunParser(new Module(CurFilename));
953}
954
955Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
956 set_scan_string(AsmString);
957
958 CurFilename = "from_memory";
959 if (M == NULL) {
960 return RunParser(new Module (CurFilename));
961 } else {
962 return RunParser(M);
963 }
964}
965
966
Chris Lattner7aa61892005-12-21 17:53:23 +0000967#line 873 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +0000968typedef union {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000969 llvm::Module *ModuleVal;
970 llvm::Function *FunctionVal;
971 std::pair<llvm::PATypeHolder*, char*> *ArgVal;
972 llvm::BasicBlock *BasicBlockVal;
973 llvm::TerminatorInst *TermInstVal;
974 llvm::Instruction *InstVal;
975 llvm::Constant *ConstVal;
976
977 const llvm::Type *PrimType;
978 llvm::PATypeHolder *TypeVal;
979 llvm::Value *ValueVal;
980
981 std::vector<std::pair<llvm::PATypeHolder*,char*> > *ArgList;
982 std::vector<llvm::Value*> *ValueList;
983 std::list<llvm::PATypeHolder> *TypeList;
984 // Represent the RHS of PHI node
985 std::list<std::pair<llvm::Value*,
986 llvm::BasicBlock*> > *PHIList;
987 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
988 std::vector<llvm::Constant*> *ConstVector;
989
990 llvm::GlobalValue::LinkageTypes Linkage;
991 int64_t SInt64Val;
992 uint64_t UInt64Val;
993 int SIntVal;
994 unsigned UIntVal;
995 double FPVal;
996 bool BoolVal;
997
998 char *StrVal; // This memory is strdup'd!
999 llvm::ValID ValIDVal; // strdup'd memory maybe!
1000
1001 llvm::Instruction::BinaryOps BinaryOpVal;
1002 llvm::Instruction::TermOps TermOpVal;
1003 llvm::Instruction::MemoryOps MemOpVal;
1004 llvm::Instruction::OtherOps OtherOpVal;
1005 llvm::Module::Endianness Endianness;
1006} YYSTYPE;
Nate Begeman14b05292005-11-05 09:21:28 +00001007#include <stdio.h>
1008
1009#ifndef __cplusplus
1010#ifndef __STDC__
1011#define const
1012#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001013#endif
1014
1015
1016
Chris Lattner7aa61892005-12-21 17:53:23 +00001017#define YYFINAL 444
Nate Begeman14b05292005-11-05 09:21:28 +00001018#define YYFLAG -32768
Chris Lattnere869eef2005-11-12 00:11:49 +00001019#define YYNTBASE 110
Reid Spencer68a24bd2005-08-27 18:50:39 +00001020
Chris Lattnerb475c422005-11-12 18:22:38 +00001021#define YYTRANSLATE(x) ((unsigned)(x) <= 349 ? yytranslate[x] : 179)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001022
Nate Begeman14b05292005-11-05 09:21:28 +00001023static const char yytranslate[] = { 0,
1024 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1025 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1026 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Chris Lattnere869eef2005-11-12 00:11:49 +00001027 2, 2, 2, 2, 2, 2, 2, 2, 2, 99,
1028 100, 108, 2, 97, 2, 2, 2, 2, 2, 2,
1029 2, 2, 2, 2, 2, 2, 2, 2, 2, 104,
1030 96, 105, 2, 2, 2, 2, 2, 2, 2, 2,
Nate Begeman14b05292005-11-05 09:21:28 +00001031 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1032 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Chris Lattnere869eef2005-11-12 00:11:49 +00001033 101, 98, 103, 2, 2, 2, 2, 2, 109, 2,
Nate Begeman14b05292005-11-05 09:21:28 +00001034 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Chris Lattnere869eef2005-11-12 00:11:49 +00001035 2, 2, 2, 2, 2, 2, 2, 2, 2, 102,
1036 2, 2, 106, 2, 107, 2, 2, 2, 2, 2,
Nate Begeman14b05292005-11-05 09:21:28 +00001037 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1038 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1039 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1040 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1041 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1042 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1043 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1044 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1045 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1046 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1047 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1048 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1049 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
1050 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1051 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1052 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
1053 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
1054 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
1055 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1056 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1057 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
Chris Lattnere869eef2005-11-12 00:11:49 +00001058 87, 88, 89, 90, 91, 92, 93, 94, 95
Nate Begeman14b05292005-11-05 09:21:28 +00001059};
Reid Spencer68a24bd2005-08-27 18:50:39 +00001060
Nate Begeman14b05292005-11-05 09:21:28 +00001061#if YYDEBUG != 0
1062static const short yyprhs[] = { 0,
1063 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
1064 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
1065 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
1066 60, 62, 64, 67, 68, 70, 72, 74, 76, 77,
Chris Lattnere869eef2005-11-12 00:11:49 +00001067 78, 80, 82, 84, 87, 88, 91, 92, 96, 99,
Chris Lattnerb475c422005-11-12 18:22:38 +00001068 100, 102, 103, 107, 109, 112, 114, 116, 118, 120,
1069 122, 124, 126, 128, 130, 132, 134, 136, 138, 140,
1070 142, 144, 146, 148, 150, 152, 154, 157, 162, 168,
1071 174, 178, 181, 184, 186, 190, 192, 196, 198, 199,
1072 204, 208, 212, 217, 222, 226, 229, 232, 235, 238,
1073 241, 244, 247, 250, 253, 256, 263, 269, 278, 285,
1074 292, 299, 306, 310, 312, 314, 316, 318, 321, 324,
1075 327, 329, 334, 337, 338, 346, 347, 355, 359, 364,
1076 365, 367, 369, 373, 377, 381, 385, 389, 391, 392,
1077 394, 396, 398, 399, 402, 406, 408, 410, 414, 416,
1078 417, 426, 428, 430, 434, 436, 438, 441, 442, 446,
Chris Lattner7aa61892005-12-21 17:53:23 +00001079 448, 450, 452, 454, 456, 458, 460, 462, 466, 468,
1080 470, 472, 474, 476, 479, 482, 485, 489, 492, 493,
1081 495, 498, 501, 505, 515, 525, 534, 548, 550, 552,
1082 559, 565, 568, 575, 583, 585, 589, 591, 592, 595,
1083 597, 603, 609, 615, 618, 623, 628, 635, 640, 645,
1084 650, 653, 661, 663, 666, 667, 669, 670, 674, 681,
1085 685, 692, 695, 700, 707
Nate Begeman14b05292005-11-05 09:21:28 +00001086};
Reid Spencer68a24bd2005-08-27 18:50:39 +00001087
Nate Begeman14b05292005-11-05 09:21:28 +00001088static const short yyrhs[] = { 5,
Chris Lattnere869eef2005-11-12 00:11:49 +00001089 0, 6, 0, 3, 0, 4, 0, 68, 0, 69,
1090 0, 70, 0, 71, 0, 72, 0, 73, 0, 74,
1091 0, 75, 0, 76, 0, 77, 0, 78, 0, 79,
1092 0, 80, 0, 81, 0, 91, 0, 92, 0, 16,
Nate Begeman14b05292005-11-05 09:21:28 +00001093 0, 14, 0, 12, 0, 10, 0, 17, 0, 15,
Chris Lattnere869eef2005-11-12 00:11:49 +00001094 0, 13, 0, 11, 0, 116, 0, 117, 0, 18,
Chris Lattnerb475c422005-11-12 18:22:38 +00001095 0, 19, 0, 149, 96, 0, 0, 41, 0, 42,
Chris Lattnere869eef2005-11-12 00:11:49 +00001096 0, 43, 0, 44, 0, 0, 0, 59, 0, 60,
1097 0, 61, 0, 58, 4, 0, 0, 54, 4, 0,
1098 0, 97, 54, 4, 0, 34, 24, 0, 0, 125,
Chris Lattnerb475c422005-11-12 18:22:38 +00001099 0, 0, 97, 128, 127, 0, 125, 0, 54, 4,
1100 0, 131, 0, 8, 0, 133, 0, 8, 0, 133,
1101 0, 9, 0, 10, 0, 11, 0, 12, 0, 13,
1102 0, 14, 0, 15, 0, 16, 0, 17, 0, 18,
1103 0, 19, 0, 20, 0, 21, 0, 45, 0, 132,
1104 0, 162, 0, 98, 4, 0, 130, 99, 135, 100,
1105 0, 101, 4, 102, 133, 103, 0, 104, 4, 102,
1106 133, 105, 0, 106, 134, 107, 0, 106, 107, 0,
1107 133, 108, 0, 133, 0, 134, 97, 133, 0, 134,
1108 0, 134, 97, 37, 0, 37, 0, 0, 131, 101,
1109 138, 103, 0, 131, 101, 103, 0, 131, 109, 24,
1110 0, 131, 104, 138, 105, 0, 131, 106, 138, 107,
1111 0, 131, 106, 107, 0, 131, 38, 0, 131, 39,
1112 0, 131, 162, 0, 131, 137, 0, 131, 26, 0,
1113 116, 111, 0, 117, 4, 0, 9, 27, 0, 9,
1114 28, 0, 119, 7, 0, 89, 99, 136, 36, 131,
1115 100, 0, 87, 99, 136, 176, 100, 0, 90, 99,
1116 136, 97, 136, 97, 136, 100, 0, 112, 99, 136,
1117 97, 136, 100, 0, 113, 99, 136, 97, 136, 100,
1118 0, 114, 99, 136, 97, 136, 100, 0, 115, 99,
1119 136, 97, 136, 100, 0, 138, 97, 136, 0, 136,
1120 0, 32, 0, 33, 0, 141, 0, 141, 158, 0,
1121 141, 159, 0, 141, 25, 0, 142, 0, 142, 120,
1122 20, 129, 0, 142, 159, 0, 0, 142, 120, 121,
1123 139, 136, 143, 127, 0, 0, 142, 120, 47, 139,
1124 131, 144, 127, 0, 142, 48, 146, 0, 142, 55,
1125 96, 147, 0, 0, 53, 0, 52, 0, 50, 96,
1126 145, 0, 51, 96, 4, 0, 49, 96, 24, 0,
1127 101, 148, 103, 0, 148, 97, 24, 0, 24, 0,
1128 0, 22, 0, 24, 0, 149, 0, 0, 131, 150,
1129 0, 152, 97, 151, 0, 151, 0, 152, 0, 152,
1130 97, 37, 0, 37, 0, 0, 122, 129, 149, 99,
1131 153, 100, 126, 123, 0, 29, 0, 106, 0, 121,
1132 154, 155, 0, 30, 0, 107, 0, 165, 157, 0,
1133 0, 31, 160, 154, 0, 3, 0, 4, 0, 7,
Chris Lattner7aa61892005-12-21 17:53:23 +00001134 0, 27, 0, 28, 0, 38, 0, 39, 0, 26,
1135 0, 104, 138, 105, 0, 137, 0, 110, 0, 149,
1136 0, 162, 0, 161, 0, 131, 163, 0, 165, 166,
1137 0, 156, 166, 0, 167, 120, 168, 0, 167, 170,
1138 0, 0, 23, 0, 62, 164, 0, 62, 8, 0,
1139 63, 21, 163, 0, 63, 9, 163, 97, 21, 163,
1140 97, 21, 163, 0, 64, 118, 163, 97, 21, 163,
1141 101, 169, 103, 0, 64, 118, 163, 97, 21, 163,
1142 101, 103, 0, 65, 122, 129, 163, 99, 173, 100,
1143 36, 21, 163, 66, 21, 163, 0, 66, 0, 67,
1144 0, 169, 118, 161, 97, 21, 163, 0, 118, 161,
1145 97, 21, 163, 0, 120, 175, 0, 131, 101, 163,
1146 97, 163, 103, 0, 171, 97, 101, 163, 97, 163,
1147 103, 0, 164, 0, 172, 97, 164, 0, 172, 0,
1148 0, 57, 56, 0, 56, 0, 112, 131, 163, 97,
1149 163, 0, 113, 131, 163, 97, 163, 0, 114, 131,
1150 163, 97, 163, 0, 46, 164, 0, 115, 164, 97,
1151 164, 0, 89, 164, 36, 131, 0, 90, 164, 97,
1152 164, 97, 164, 0, 93, 164, 97, 131, 0, 94,
1153 164, 97, 131, 0, 95, 164, 97, 131, 0, 88,
1154 171, 0, 174, 122, 129, 163, 99, 173, 100, 0,
1155 178, 0, 97, 172, 0, 0, 35, 0, 0, 82,
1156 131, 124, 0, 82, 131, 97, 15, 163, 124, 0,
1157 83, 131, 124, 0, 83, 131, 97, 15, 163, 124,
1158 0, 84, 164, 0, 177, 85, 131, 163, 0, 177,
1159 86, 164, 97, 131, 163, 0, 87, 131, 163, 176,
1160 0
Nate Begeman14b05292005-11-05 09:21:28 +00001161};
Reid Spencer68a24bd2005-08-27 18:50:39 +00001162
1163#endif
1164
Nate Begeman14b05292005-11-05 09:21:28 +00001165#if YYDEBUG != 0
1166static const short yyrline[] = { 0,
Chris Lattner7aa61892005-12-21 17:53:23 +00001167 991, 992, 999, 1000, 1009, 1009, 1009, 1009, 1009, 1010,
1168 1010, 1010, 1011, 1011, 1011, 1011, 1011, 1011, 1013, 1013,
1169 1017, 1017, 1017, 1017, 1018, 1018, 1018, 1018, 1019, 1019,
1170 1020, 1020, 1023, 1026, 1030, 1030, 1031, 1032, 1033, 1036,
1171 1036, 1037, 1038, 1039, 1048, 1048, 1054, 1054, 1062, 1069,
1172 1069, 1075, 1075, 1077, 1081, 1094, 1094, 1095, 1095, 1097,
1173 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1107, 1107, 1107,
1174 1107, 1107, 1107, 1108, 1111, 1114, 1120, 1127, 1139, 1143,
1175 1154, 1163, 1166, 1174, 1178, 1183, 1184, 1187, 1190, 1200,
1176 1225, 1238, 1266, 1291, 1311, 1323, 1332, 1336, 1395, 1401,
1177 1409, 1414, 1419, 1422, 1425, 1432, 1442, 1473, 1480, 1501,
Chris Lattner524a1312005-12-21 18:31:50 +00001178 1511, 1516, 1526, 1529, 1536, 1536, 1546, 1553, 1557, 1560,
1179 1563, 1576, 1596, 1598, 1601, 1604, 1608, 1611, 1613, 1615,
1180 1620, 1621, 1623, 1626, 1634, 1639, 1641, 1645, 1649, 1657,
1181 1657, 1658, 1658, 1660, 1666, 1671, 1677, 1680, 1685, 1689,
1182 1693, 1779, 1779, 1781, 1789, 1789, 1791, 1795, 1795, 1804,
1183 1807, 1810, 1813, 1816, 1819, 1822, 1825, 1828, 1852, 1859,
1184 1862, 1867, 1867, 1873, 1877, 1880, 1888, 1897, 1901, 1911,
1185 1922, 1925, 1928, 1931, 1934, 1948, 1952, 2005, 2008, 2014,
1186 2022, 2032, 2039, 2044, 2051, 2055, 2061, 2061, 2063, 2066,
1187 2072, 2084, 2095, 2105, 2117, 2124, 2131, 2138, 2143, 2162,
1188 2184, 2198, 2255, 2261, 2263, 2267, 2270, 2276, 2280, 2284,
1189 2288, 2292, 2299, 2309, 2322
Nate Begeman14b05292005-11-05 09:21:28 +00001190};
1191#endif
1192
1193
1194#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
1195
1196static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL",
1197"EUINT64VAL","SINTVAL","UINTVAL","FPVAL","VOID","BOOL","SBYTE","UBYTE","SHORT",
1198"USHORT","INT","UINT","LONG","ULONG","FLOAT","DOUBLE","TYPE","LABEL","VAR_ID",
1199"LABELSTR","STRINGCONSTANT","IMPLEMENTATION","ZEROINITIALIZER","TRUETOK","FALSETOK",
Chris Lattnere869eef2005-11-12 00:11:49 +00001200"BEGINTOK","ENDTOK","DECLARE","GLOBAL","CONSTANT","SECTION","VOLATILE","TO",
1201"DOTDOTDOT","NULL_TOK","UNDEF","CONST","INTERNAL","LINKONCE","WEAK","APPENDING",
1202"OPAQUE","NOT","EXTERNAL","TARGET","TRIPLE","ENDIAN","POINTERSIZE","LITTLE",
1203"BIG","ALIGN","DEPLIBS","CALL","TAIL","CC_TOK","CCC_TOK","FASTCC_TOK","COLDCC_TOK",
1204"RET","BR","SWITCH","INVOKE","UNWIND","UNREACHABLE","ADD","SUB","MUL","DIV",
1205"REM","AND","OR","XOR","SETLE","SETGE","SETLT","SETGT","SETEQ","SETNE","MALLOC",
1206"ALLOCA","FREE","LOAD","STORE","GETELEMENTPTR","PHI_TOK","CAST","SELECT","SHL",
1207"SHR","VAARG","VAARG_old","VANEXT_old","'='","','","'\\\\'","'('","')'","'['",
1208"'x'","']'","'<'","'>'","'{'","'}'","'*'","'c'","INTVAL","EINT64VAL","ArithmeticOps",
Nate Begeman14b05292005-11-05 09:21:28 +00001209"LogicalOps","SetCondOps","ShiftOps","SIntType","UIntType","IntType","FPType",
Chris Lattnere869eef2005-11-12 00:11:49 +00001210"OptAssign","OptLinkage","OptCallingConv","OptAlign","OptCAlign","SectionString",
Chris Lattnerb475c422005-11-12 18:22:38 +00001211"OptSection","GlobalVarAttributes","GlobalVarAttribute","TypesV","UpRTypesV",
1212"Types","PrimType","UpRTypes","TypeListI","ArgTypeListI","ConstVal","ConstExpr",
1213"ConstVector","GlobalType","Module","FunctionList","ConstPool","@1","@2","BigOrLittle",
1214"TargetDefinition","LibrariesDefinition","LibList","Name","OptName","ArgVal",
1215"ArgListH","ArgList","FunctionHeaderH","BEGIN","FunctionHeader","END","Function",
1216"FunctionProto","@3","ConstValueRef","SymbolicValueRef","ValueRef","ResolvedVal",
1217"BasicBlockList","BasicBlock","InstructionList","BBTerminatorInst","JumpTable",
1218"Inst","PHIList","ValueRefList","ValueRefListE","OptTailCall","InstVal","IndexList",
1219"OptVolatile","MemoryInst", NULL
Nate Begeman14b05292005-11-05 09:21:28 +00001220};
1221#endif
1222
1223static const short yyr1[] = { 0,
Chris Lattnere869eef2005-11-12 00:11:49 +00001224 110, 110, 111, 111, 112, 112, 112, 112, 112, 113,
1225 113, 113, 114, 114, 114, 114, 114, 114, 115, 115,
1226 116, 116, 116, 116, 117, 117, 117, 117, 118, 118,
1227 119, 119, 120, 120, 121, 121, 121, 121, 121, 122,
1228 122, 122, 122, 122, 123, 123, 124, 124, 125, 126,
Chris Lattnerb475c422005-11-12 18:22:38 +00001229 126, 127, 127, 128, 128, 129, 129, 130, 130, 131,
1230 132, 132, 132, 132, 132, 132, 132, 132, 132, 132,
1231 132, 132, 132, 133, 133, 133, 133, 133, 133, 133,
1232 133, 133, 133, 134, 134, 135, 135, 135, 135, 136,
1233 136, 136, 136, 136, 136, 136, 136, 136, 136, 136,
1234 136, 136, 136, 136, 136, 137, 137, 137, 137, 137,
1235 137, 137, 138, 138, 139, 139, 140, 141, 141, 141,
1236 141, 142, 142, 143, 142, 144, 142, 142, 142, 142,
1237 145, 145, 146, 146, 146, 147, 148, 148, 148, 149,
1238 149, 150, 150, 151, 152, 152, 153, 153, 153, 153,
1239 154, 155, 155, 156, 157, 157, 158, 160, 159, 161,
Chris Lattner7aa61892005-12-21 17:53:23 +00001240 161, 161, 161, 161, 161, 161, 161, 161, 161, 162,
1241 162, 163, 163, 164, 165, 165, 166, 167, 167, 167,
1242 168, 168, 168, 168, 168, 168, 168, 168, 168, 169,
1243 169, 170, 171, 171, 172, 172, 173, 173, 174, 174,
Chris Lattnerb475c422005-11-12 18:22:38 +00001244 175, 175, 175, 175, 175, 175, 175, 175, 175, 175,
Chris Lattner7aa61892005-12-21 17:53:23 +00001245 175, 175, 175, 176, 176, 177, 177, 178, 178, 178,
1246 178, 178, 178, 178, 178
Nate Begeman14b05292005-11-05 09:21:28 +00001247};
1248
1249static const short yyr2[] = { 0,
1250 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1251 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1252 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1253 1, 1, 2, 0, 1, 1, 1, 1, 0, 0,
Chris Lattnere869eef2005-11-12 00:11:49 +00001254 1, 1, 1, 2, 0, 2, 0, 3, 2, 0,
Chris Lattnerb475c422005-11-12 18:22:38 +00001255 1, 0, 3, 1, 2, 1, 1, 1, 1, 1,
Nate Begeman14b05292005-11-05 09:21:28 +00001256 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Chris Lattnerb475c422005-11-12 18:22:38 +00001257 1, 1, 1, 1, 1, 1, 2, 4, 5, 5,
1258 3, 2, 2, 1, 3, 1, 3, 1, 0, 4,
1259 3, 3, 4, 4, 3, 2, 2, 2, 2, 2,
1260 2, 2, 2, 2, 2, 6, 5, 8, 6, 6,
1261 6, 6, 3, 1, 1, 1, 1, 2, 2, 2,
1262 1, 4, 2, 0, 7, 0, 7, 3, 4, 0,
1263 1, 1, 3, 3, 3, 3, 3, 1, 0, 1,
1264 1, 1, 0, 2, 3, 1, 1, 3, 1, 0,
1265 8, 1, 1, 3, 1, 1, 2, 0, 3, 1,
Chris Lattner7aa61892005-12-21 17:53:23 +00001266 1, 1, 1, 1, 1, 1, 1, 3, 1, 1,
1267 1, 1, 1, 2, 2, 2, 3, 2, 0, 1,
1268 2, 2, 3, 9, 9, 8, 13, 1, 1, 6,
1269 5, 2, 6, 7, 1, 3, 1, 0, 2, 1,
1270 5, 5, 5, 2, 4, 4, 6, 4, 4, 4,
1271 2, 7, 1, 2, 0, 1, 0, 3, 6, 3,
1272 6, 2, 4, 6, 4
Nate Begeman14b05292005-11-05 09:21:28 +00001273};
1274
Chris Lattnerb475c422005-11-12 18:22:38 +00001275static const short yydefact[] = { 130,
Chris Lattner7aa61892005-12-21 17:53:23 +00001276 39, 121, 120, 158, 35, 36, 37, 38, 40, 179,
1277 118, 119, 179, 140, 141, 0, 0, 39, 0, 123,
1278 40, 0, 41, 42, 43, 0, 0, 180, 176, 34,
1279 155, 156, 157, 175, 0, 0, 0, 128, 0, 0,
Chris Lattnerb475c422005-11-12 18:22:38 +00001280 0, 0, 33, 159, 44, 1, 2, 57, 61, 62,
1281 63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
Chris Lattner7aa61892005-12-21 17:53:23 +00001282 73, 74, 0, 0, 0, 0, 170, 0, 0, 56,
1283 75, 60, 171, 76, 152, 153, 154, 217, 178, 0,
Chris Lattnerb475c422005-11-12 18:22:38 +00001284 0, 0, 139, 129, 122, 115, 116, 0, 0, 77,
Chris Lattner7aa61892005-12-21 17:53:23 +00001285 0, 0, 59, 82, 84, 0, 0, 89, 83, 216,
1286 0, 200, 0, 0, 0, 0, 40, 188, 189, 5,
Nate Begeman14b05292005-11-05 09:21:28 +00001287 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
1288 16, 17, 18, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner7aa61892005-12-21 17:53:23 +00001289 19, 20, 0, 0, 0, 0, 0, 0, 0, 177,
1290 40, 192, 0, 213, 135, 132, 131, 133, 134, 138,
Chris Lattnerb475c422005-11-12 18:22:38 +00001291 0, 126, 61, 62, 63, 64, 65, 66, 67, 68,
1292 69, 70, 71, 0, 0, 0, 0, 124, 0, 0,
Chris Lattner7aa61892005-12-21 17:53:23 +00001293 0, 81, 150, 88, 86, 0, 0, 204, 199, 182,
1294 181, 0, 0, 24, 28, 23, 27, 22, 26, 21,
1295 25, 29, 30, 0, 0, 47, 47, 222, 0, 0,
1296 211, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattnerb475c422005-11-12 18:22:38 +00001297 0, 0, 0, 0, 136, 52, 103, 104, 3, 4,
1298 101, 102, 105, 100, 96, 97, 0, 0, 0, 0,
1299 0, 0, 0, 0, 0, 0, 0, 99, 98, 52,
1300 58, 58, 85, 149, 143, 146, 147, 0, 0, 78,
Chris Lattner7aa61892005-12-21 17:53:23 +00001301 160, 161, 162, 167, 163, 164, 165, 166, 0, 169,
1302 173, 172, 174, 0, 183, 0, 0, 0, 218, 0,
1303 220, 215, 0, 0, 0, 0, 0, 0, 0, 0,
1304 0, 0, 0, 0, 0, 0, 137, 0, 127, 0,
1305 0, 0, 91, 114, 0, 0, 95, 0, 92, 0,
1306 0, 0, 0, 125, 79, 80, 142, 144, 0, 50,
1307 87, 0, 0, 0, 0, 0, 0, 0, 0, 225,
1308 0, 0, 206, 0, 208, 209, 210, 0, 0, 0,
1309 205, 0, 223, 0, 0, 0, 54, 52, 215, 0,
1310 0, 0, 90, 93, 94, 0, 0, 0, 0, 148,
1311 145, 51, 45, 168, 0, 0, 198, 47, 48, 47,
1312 195, 214, 0, 0, 0, 201, 202, 203, 198, 0,
1313 49, 55, 53, 0, 0, 0, 113, 0, 0, 0,
1314 0, 0, 151, 0, 0, 197, 0, 0, 219, 221,
1315 0, 0, 0, 207, 0, 224, 107, 0, 0, 0,
1316 0, 0, 0, 46, 0, 0, 0, 196, 193, 0,
1317 212, 106, 0, 109, 110, 111, 112, 0, 186, 0,
1318 0, 0, 194, 0, 184, 0, 185, 0, 0, 108,
1319 0, 0, 0, 0, 0, 0, 191, 0, 0, 190,
1320 187, 0, 0, 0
Nate Begeman14b05292005-11-05 09:21:28 +00001321};
1322
1323static const short yydefgoto[] = { 67,
Chris Lattnerb475c422005-11-12 18:22:38 +00001324 221, 234, 235, 236, 237, 164, 165, 194, 166, 18,
Chris Lattner7aa61892005-12-21 17:53:23 +00001325 9, 26, 383, 269, 337, 353, 289, 338, 68, 69,
1326 167, 71, 72, 96, 176, 294, 260, 295, 88, 442,
1327 1, 2, 240, 216, 148, 38, 84, 151, 73, 308,
Chris Lattnerb475c422005-11-12 18:22:38 +00001328 246, 247, 248, 27, 77, 10, 33, 11, 12, 21,
Chris Lattner7aa61892005-12-21 17:53:23 +00001329 261, 74, 263, 361, 13, 29, 30, 140, 421, 79,
1330 201, 386, 387, 141, 142, 320, 143, 144
Nate Begeman14b05292005-11-05 09:21:28 +00001331};
1332
1333static const short yypact[] = {-32768,
Chris Lattner7aa61892005-12-21 17:53:23 +00001334 43, 304,-32768,-32768,-32768,-32768,-32768,-32768, 94, -17,
1335-32768,-32768, -11,-32768,-32768, 72, -58, 47, -35,-32768,
1336 94, 66,-32768,-32768,-32768, 995, -25,-32768,-32768, 111,
1337-32768,-32768,-32768,-32768, -3, 10, 23,-32768, 35, 995,
1338 112, 112,-32768,-32768,-32768,-32768,-32768, 42,-32768,-32768,
Nate Begeman14b05292005-11-05 09:21:28 +00001339-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
Chris Lattner7aa61892005-12-21 17:53:23 +00001340-32768,-32768, 134, 142, 146, 512,-32768, 111, 58,-32768,
1341-32768, -39,-32768,-32768,-32768,-32768,-32768, 1110,-32768, 139,
1342 27, 163, 149,-32768,-32768,-32768,-32768, 1015, 1059,-32768,
1343 79, 80,-32768,-32768, -39, -87, 85, 752,-32768,-32768,
1344 1015,-32768, 133, 1117, 50, 115, 94,-32768,-32768,-32768,
Nate Begeman14b05292005-11-05 09:21:28 +00001345-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
Chris Lattner7aa61892005-12-21 17:53:23 +00001346-32768,-32768,-32768, 1015, 1015, 1015, 1015, 1015, 1015, 1015,
1347-32768,-32768, 1015, 1015, 1015, 1015, 1015, 1015, 1015,-32768,
1348 94,-32768, 63,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1349 -20,-32768, 132, 158, 184, 168, 187, 172, 188, 174,
1350 189, 190, 191, 176, 195, 193, 410,-32768, 1015, 1015,
1351 1015,-32768, 790,-32768, 97, 95, 576,-32768,-32768, 42,
1352-32768, 576, 576,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1353-32768,-32768,-32768, 576, 995, 104, 105,-32768, 576, 102,
1354 107, 169, 113, 114, 116, 117, 576, 576, 576, 118,
1355 995, 1015, 1015, 185,-32768, 125,-32768,-32768,-32768,-32768,
1356-32768,-32768,-32768,-32768,-32768,-32768, 124, 126, 127, 854,
1357 1059, 532, 203, 129, 130, 135, 136,-32768,-32768, 125,
1358 -69, -13, -39,-32768, 111,-32768, 141, 131, 892,-32768,
1359-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 1059,-32768,
1360-32768,-32768,-32768, 143,-32768, 147, 576, -6,-32768, 3,
1361-32768, 151, 576, 138, 1015, 1015, 1015, 1015, 1015, 157,
1362 159, 164, 1015, 576, 576, 165,-32768, -19,-32768, 1059,
1363 1059, 1059,-32768,-32768, 40, -33,-32768, -31,-32768, 1059,
1364 1059, 1059, 1059,-32768,-32768,-32768,-32768,-32768, 957, 178,
1365-32768, -32, 212, 215, 144, 576, 251, 576, 1015,-32768,
1366 166, 576,-32768, 167,-32768,-32768,-32768, 576, 576, 576,
1367-32768, 161,-32768, 1015, 241, 262,-32768, 125, 151, 231,
1368 171, 1059,-32768,-32768,-32768, 173, 177, 179, 180,-32768,
1369-32768,-32768, 217,-32768, 576, 576, 1015, 181,-32768, 181,
1370-32768, 183, 576, 192, 1015,-32768,-32768,-32768, 1015, 576,
1371-32768,-32768,-32768, 182, 1015, 1059,-32768, 1059, 1059, 1059,
1372 1059, 265,-32768, 194, 198, 183, 200, 227,-32768,-32768,
1373 1015, 201, 576,-32768, 206,-32768,-32768, 207, 213, 209,
1374 214, 218, 219,-32768, 263, 11, 252,-32768,-32768, 222,
1375-32768,-32768, 1059,-32768,-32768,-32768,-32768, 576,-32768, 655,
1376 39, 269,-32768, 221,-32768, 233,-32768, 655, 576,-32768,
1377 282, 235, 249, 576, 312, 313,-32768, 576, 576,-32768,
1378-32768, 338, 340,-32768
Nate Begeman14b05292005-11-05 09:21:28 +00001379};
1380
Chris Lattner0019bbe2005-11-06 06:46:53 +00001381static const short yypgoto[] = {-32768,
Chris Lattner7aa61892005-12-21 17:53:23 +00001382-32768, 264, 266, 275, 277, -105, -104, -374,-32768, 311,
1383 339, -78,-32768, -190, 48,-32768, -223,-32768, -37,-32768,
1384 -26,-32768, -53, 271,-32768, -84, 196, -201, 319,-32768,
1385-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 14,-32768,
1386 53,-32768,-32768, 343,-32768,-32768,-32768,-32768, 368,-32768,
1387 -323, -43, 38, -93,-32768, 358,-32768,-32768,-32768,-32768,
1388-32768, 54, 5,-32768,-32768, 33,-32768,-32768
Chris Lattner0019bbe2005-11-06 06:46:53 +00001389};
Nate Begeman14b05292005-11-05 09:21:28 +00001390
Chris Lattner0019bbe2005-11-06 06:46:53 +00001391
Chris Lattner7aa61892005-12-21 17:53:23 +00001392#define YYLAST 1223
Nate Begeman14b05292005-11-05 09:21:28 +00001393
1394
1395static const short yytable[] = { 70,
Chris Lattner7aa61892005-12-21 17:53:23 +00001396 192, 193, 85, 75, 168, 28, 271, 178, 316, 171,
1397 181, 28, 95, 70, 335, 19, 304, 318, 31, 172,
1398 184, 185, 186, 187, 188, 189, 190, 191, 195, 296,
1399 298, 420, 198, 305, 336, 202, 203, 39, 99, 204,
1400 205, 206, -117, 19, 95, 210, 428, 317, 184, 185,
1401 186, 187, 188, 189, 190, 191, 317, 312, 182, -58,
1402 43, 152, 211, 342, 342, 342, 40, 3, 99, 45,
1403 183, 344, 354, 4, 177, 345, 214, 177, 146, 147,
1404 76, 97, 215, 5, 6, 7, 8, 5, 6, 7,
1405 8, 306, 80, 41, 99, 32, 426, 196, 197, 177,
1406 199, 200, 177, 177, 432, 81, 177, 177, 177, 207,
1407 208, 209, 177, 419, 373, 241, 242, 243, 82, 286,
1408 35, 36, 37, 239, 184, 185, 186, 187, 188, 189,
1409 190, 191, 14, 262, 15, 83, 342, 90, 262, 262,
1410 -59, 427, 343, 86, 87, 91, 245, 212, 213, 92,
1411 262, 22, 23, 24, 25, 262, 98, 267, 217, 218,
1412 -24, -24, 145, 262, 262, 262, 149, 389, 70, 390,
1413 -23, -23, 150, 284, -22, -22, -21, -21, 219, 220,
1414 169, 170, 324, 173, 70, 285, 177, -28, 179, 331,
1415 -27, -26, -25, 249, 250, 243, -31, -32, 222, 223,
1416 268, 270, 273, 274, 275, 339, 340, 341, 287, 276,
1417 277, 335, 278, 279, 283, 346, 347, 348, 349, 264,
1418 265, 288, 290, 262, 291, 292, 299, 300, 301, 262,
1419 310, 266, 355, 302, 303, 356, 272, 309, 322, 313,
1420 262, 262, 357, 314, 280, 281, 282, 319, 323, 177,
1421 325, 326, 327, 328, 359, 329, 177, 377, 307, 369,
1422 330, 334, 363, 365, 371, 372, 375, 376, 404, 378,
1423 382, 394, 262, 379, 262, 380, 381, 388, 262, 391,
1424 317, 397, 245, 418, 262, 262, 262, 422, 393, 429,
1425 405, 399, 177, 400, 401, 402, 403, 408, 406, 407,
1426 192, 193, 434, 409, 315, 411, 412, 370, 414, 413,
1427 321, 262, 262, 415, 436, 192, 193, 416, 417, 262,
1428 430, 332, 333, -34, 423, 14, 262, 15, 424, 431,
1429 177, 435, 438, 439, 4, -34, -34, 443, 177, 444,
1430 78, 136, 177, 137, -34, -34, -34, -34, 398, 262,
1431 -34, 16, 138, 358, 139, 360, 42, 352, 17, 364,
1432 89, 351, 238, 44, 177, 366, 367, 368, 175, 20,
1433 34, 374, 362, 395, 262, 0, 0, 0, 0, 0,
1434 0, 0, 0, 0, 0, 262, 0, 0, 0, 0,
1435 262, 0, 384, 385, 262, 262, 0, 0, 0, 0,
1436 392, 0, 0, 0, 0, 0, 0, 396, 0, 0,
1437 0, 0, 0, 0, 46, 47, 0, 0, 0, 0,
Nate Begeman14b05292005-11-05 09:21:28 +00001438 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner7aa61892005-12-21 17:53:23 +00001439 410, 14, 0, 15, 0, 224, 0, 0, 0, 0,
1440 0, 0, 0, 0, 0, 0, 0, 225, 226, 0,
1441 0, 0, 0, 0, 0, 425, 0, 0, 0, 0,
1442 0, 0, 0, 0, 0, 0, 433, 0, 0, 0,
1443 0, 437, 0, 0, 0, 440, 441, 110, 111, 112,
1444 113, 114, 115, 116, 117, 118, 119, 120, 121, 122,
1445 123, 0, 0, 0, 0, 0, 227, 0, 228, 229,
1446 131, 132, 0, 0, 0, 0, 0, 0, 0, 0,
1447 230, 0, 0, 231, 0, 232, 46, 47, 233, 93,
1448 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
1449 59, 60, 61, 14, 0, 15, 46, 47, 0, 93,
1450 153, 154, 155, 156, 157, 158, 159, 160, 161, 162,
1451 163, 60, 61, 14, 0, 15, 62, 0, 0, 0,
1452 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1453 0, 0, 0, 0, 0, 0, 62, 0, 251, 252,
1454 46, 47, 253, 0, 0, 0, 0, 0, 0, 0,
1455 0, 0, 0, 0, 0, 0, 0, 14, 0, 15,
1456 0, 254, 255, 256, 0, 0, 0, 0, 0, 63,
1457 0, 0, 64, 257, 258, 65, 0, 66, 94, 0,
1458 0, 0, 0, 0, 0, 0, 0, 0, 0, 63,
1459 0, 0, 64, 0, 0, 65, 0, 66, 297, 0,
1460 0, 0, 0, 110, 111, 112, 113, 114, 115, 116,
1461 117, 118, 119, 120, 121, 122, 123, 251, 252, 0,
1462 0, 253, 227, 0, 228, 229, 131, 132, 0, 0,
1463 0, 0, 0, 0, 0, 0, 0, 0, 0, 259,
1464 254, 255, 256, 0, 0, 0, 0, 0, 0, 0,
1465 0, 0, 257, 258, 0, 0, 0, 0, 0, 0,
1466 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1467 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattnerb475c422005-11-12 18:22:38 +00001468 0, 0, 110, 111, 112, 113, 114, 115, 116, 117,
Chris Lattner7aa61892005-12-21 17:53:23 +00001469 118, 119, 120, 121, 122, 123, 0, 0, 0, 0,
1470 0, 227, 0, 228, 229, 131, 132, 0, 0, 0,
1471 0, 0, 0, 0, 0, 0, 46, 47, 259, 93,
1472 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
1473 59, 60, 61, 14, 0, 15, 0, 0, 0, 0,
1474 0, 0, 0, 0, 0, 0, 0, 0, 174, 0,
1475 0, 0, 0, 0, 46, 47, 62, 93, 49, 50,
1476 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
1477 61, 14, 0, 15, 0, 0, 0, 0, 0, 0,
1478 0, 0, 0, 0, 0, 0, 244, 0, 0, 0,
1479 0, 0, 0, 0, 62, 0, 0, 0, 0, 0,
1480 0, 0, 0, 0, 0, 0, 0, 0, 0, 63,
1481 0, 0, 64, 0, 0, 65, 0, 66, 46, 47,
1482 0, 93, 153, 154, 155, 156, 157, 158, 159, 160,
1483 161, 162, 163, 60, 61, 14, 0, 15, 0, 0,
1484 0, 0, 0, 0, 0, 0, 0, 63, 0, 0,
1485 64, 0, 0, 65, 0, 66, 46, 47, 62, 93,
1486 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
1487 59, 60, 61, 14, 0, 15, 0, 0, 0, 0,
1488 0, 0, 0, 0, 0, 0, 0, 0, 311, 0,
1489 0, 0, 0, 0, 0, 0, 62, 0, 0, 0,
Chris Lattner0019bbe2005-11-06 06:46:53 +00001490 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner7aa61892005-12-21 17:53:23 +00001491 0, 63, 0, 0, 64, 0, 293, 65, 0, 66,
1492 0, 46, 47, 0, 93, 49, 50, 51, 52, 53,
1493 54, 55, 56, 57, 58, 59, 60, 61, 14, 0,
1494 15, 0, 0, 0, 0, 0, 0, 0, 0, 63,
1495 0, 0, 64, 350, 0, 65, 0, 66, 0, 46,
1496 47, 62, 48, 49, 50, 51, 52, 53, 54, 55,
1497 56, 57, 58, 59, 60, 61, 14, 0, 15, 46,
1498 47, 0, 93, 49, 50, 51, 52, 53, 54, 55,
1499 56, 57, 58, 59, 60, 61, 14, 0, 15, 62,
Chris Lattnere869eef2005-11-12 00:11:49 +00001500 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner7aa61892005-12-21 17:53:23 +00001501 0, 0, 0, 0, 63, 0, 0, 64, 0, 62,
1502 65, 0, 66, 46, 47, 0, 93, 153, 154, 155,
1503 156, 157, 158, 159, 160, 161, 162, 163, 60, 61,
Chris Lattnere869eef2005-11-12 00:11:49 +00001504 14, 0, 15, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner7aa61892005-12-21 17:53:23 +00001505 0, 0, 63, 0, 0, 64, 0, 0, 65, 0,
1506 66, 0, 0, 62, 0, 0, 0, 0, 0, 0,
1507 0, 0, 63, 0, 0, 64, 0, 0, 65, 0,
1508 66, 46, 47, 0, 180, 49, 50, 51, 52, 53,
1509 54, 55, 56, 57, 58, 59, 60, 61, 14, 0,
1510 15, 0, 0, 0, 100, 0, 0, 0, 0, 0,
1511 0, 0, 0, 0, 0, 101, 63, 0, 0, 64,
1512 0, 62, 65, 0, 66, 102, 103, 0, 0, 0,
1513 0, 104, 105, 106, 107, 108, 109, 110, 111, 112,
1514 113, 114, 115, 116, 117, 118, 119, 120, 121, 122,
1515 123, 124, 125, 126, 0, 0, 127, 128, 129, 130,
1516 131, 132, 133, 134, 135, 0, 0, 0, 0, 0,
1517 0, 0, 0, 0, 63, 0, 0, 64, 0, 0,
1518 65, 0, 66
Nate Begeman14b05292005-11-05 09:21:28 +00001519};
1520
1521static const short yycheck[] = { 26,
Chris Lattner7aa61892005-12-21 17:53:23 +00001522 106, 106, 40, 29, 89, 23, 197, 101, 15, 97,
1523 104, 23, 66, 40, 34, 2, 240, 15, 30, 107,
1524 10, 11, 12, 13, 14, 15, 16, 17, 107, 231,
1525 232, 406, 126, 103, 54, 129, 130, 96, 108, 133,
1526 134, 135, 0, 30, 98, 139, 421, 54, 10, 11,
1527 12, 13, 14, 15, 16, 17, 54, 259, 9, 99,
1528 96, 88, 141, 97, 97, 97, 20, 25, 108, 4,
1529 21, 105, 105, 31, 101, 107, 97, 104, 52, 53,
1530 106, 68, 103, 41, 42, 43, 44, 41, 42, 43,
1531 44, 105, 96, 47, 108, 107, 420, 124, 125, 126,
1532 127, 128, 129, 130, 428, 96, 133, 134, 135, 136,
1533 137, 138, 139, 103, 338, 169, 170, 171, 96, 213,
1534 49, 50, 51, 167, 10, 11, 12, 13, 14, 15,
1535 16, 17, 22, 177, 24, 101, 97, 4, 182, 183,
1536 99, 103, 103, 32, 33, 4, 173, 85, 86, 4,
1537 194, 58, 59, 60, 61, 199, 99, 195, 27, 28,
1538 3, 4, 24, 207, 208, 209, 4, 358, 195, 360,
1539 3, 4, 24, 211, 3, 4, 3, 4, 3, 4,
1540 102, 102, 276, 99, 211, 212, 213, 4, 56, 283,
1541 4, 4, 4, 97, 100, 249, 7, 7, 4, 7,
1542 97, 97, 101, 97, 36, 290, 291, 292, 24, 97,
1543 97, 34, 97, 97, 97, 300, 301, 302, 303, 182,
1544 183, 97, 99, 267, 99, 99, 24, 99, 99, 273,
1545 100, 194, 21, 99, 99, 21, 199, 97, 101, 97,
1546 284, 285, 99, 97, 207, 208, 209, 97, 275, 276,
1547 277, 278, 279, 97, 4, 97, 283, 342, 245, 99,
1548 97, 97, 97, 97, 24, 4, 36, 97, 4, 97,
1549 54, 365, 316, 97, 318, 97, 97, 97, 322, 97,
1550 54, 100, 309, 21, 328, 329, 330, 36, 97, 21,
1551 97, 376, 319, 378, 379, 380, 381, 391, 101, 100,
1552 406, 406, 21, 103, 267, 100, 100, 334, 100, 97,
1553 273, 355, 356, 100, 66, 421, 421, 100, 100, 363,
1554 100, 284, 285, 20, 103, 22, 370, 24, 413, 97,
1555 357, 97, 21, 21, 31, 32, 33, 0, 365, 0,
1556 30, 78, 369, 78, 41, 42, 43, 44, 375, 393,
1557 47, 48, 78, 316, 78, 318, 18, 310, 55, 322,
1558 42, 309, 167, 21, 391, 328, 329, 330, 98, 2,
1559 13, 339, 319, 369, 418, -1, -1, -1, -1, -1,
1560 -1, -1, -1, -1, -1, 429, -1, -1, -1, -1,
1561 434, -1, 355, 356, 438, 439, -1, -1, -1, -1,
1562 363, -1, -1, -1, -1, -1, -1, 370, -1, -1,
1563 -1, -1, -1, -1, 5, 6, -1, -1, -1, -1,
Chris Lattnerb475c422005-11-12 18:22:38 +00001564 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattner7aa61892005-12-21 17:53:23 +00001565 393, 22, -1, 24, -1, 26, -1, -1, -1, -1,
1566 -1, -1, -1, -1, -1, -1, -1, 38, 39, -1,
1567 -1, -1, -1, -1, -1, 418, -1, -1, -1, -1,
1568 -1, -1, -1, -1, -1, -1, 429, -1, -1, -1,
1569 -1, 434, -1, -1, -1, 438, 439, 68, 69, 70,
1570 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
1571 81, -1, -1, -1, -1, -1, 87, -1, 89, 90,
1572 91, 92, -1, -1, -1, -1, -1, -1, -1, -1,
1573 101, -1, -1, 104, -1, 106, 5, 6, 109, 8,
1574 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
1575 19, 20, 21, 22, -1, 24, 5, 6, -1, 8,
1576 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
1577 19, 20, 21, 22, -1, 24, 45, -1, -1, -1,
1578 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1579 -1, -1, -1, -1, -1, -1, 45, -1, 3, 4,
1580 5, 6, 7, -1, -1, -1, -1, -1, -1, -1,
1581 -1, -1, -1, -1, -1, -1, -1, 22, -1, 24,
1582 -1, 26, 27, 28, -1, -1, -1, -1, -1, 98,
1583 -1, -1, 101, 38, 39, 104, -1, 106, 107, -1,
1584 -1, -1, -1, -1, -1, -1, -1, -1, -1, 98,
1585 -1, -1, 101, -1, -1, 104, -1, 106, 107, -1,
1586 -1, -1, -1, 68, 69, 70, 71, 72, 73, 74,
1587 75, 76, 77, 78, 79, 80, 81, 3, 4, -1,
1588 -1, 7, 87, -1, 89, 90, 91, 92, -1, -1,
1589 -1, -1, -1, -1, -1, -1, -1, -1, -1, 104,
1590 26, 27, 28, -1, -1, -1, -1, -1, -1, -1,
1591 -1, -1, 38, 39, -1, -1, -1, -1, -1, -1,
1592 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1593 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattnerb475c422005-11-12 18:22:38 +00001594 -1, -1, 68, 69, 70, 71, 72, 73, 74, 75,
Chris Lattner7aa61892005-12-21 17:53:23 +00001595 76, 77, 78, 79, 80, 81, -1, -1, -1, -1,
1596 -1, 87, -1, 89, 90, 91, 92, -1, -1, -1,
1597 -1, -1, -1, -1, -1, -1, 5, 6, 104, 8,
1598 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
1599 19, 20, 21, 22, -1, 24, -1, -1, -1, -1,
1600 -1, -1, -1, -1, -1, -1, -1, -1, 37, -1,
1601 -1, -1, -1, -1, 5, 6, 45, 8, 9, 10,
1602 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
1603 21, 22, -1, 24, -1, -1, -1, -1, -1, -1,
1604 -1, -1, -1, -1, -1, -1, 37, -1, -1, -1,
1605 -1, -1, -1, -1, 45, -1, -1, -1, -1, -1,
1606 -1, -1, -1, -1, -1, -1, -1, -1, -1, 98,
1607 -1, -1, 101, -1, -1, 104, -1, 106, 5, 6,
1608 -1, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1609 17, 18, 19, 20, 21, 22, -1, 24, -1, -1,
1610 -1, -1, -1, -1, -1, -1, -1, 98, -1, -1,
1611 101, -1, -1, 104, -1, 106, 5, 6, 45, 8,
1612 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
1613 19, 20, 21, 22, -1, 24, -1, -1, -1, -1,
1614 -1, -1, -1, -1, -1, -1, -1, -1, 37, -1,
1615 -1, -1, -1, -1, -1, -1, 45, -1, -1, -1,
Chris Lattnerb475c422005-11-12 18:22:38 +00001616 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattner7aa61892005-12-21 17:53:23 +00001617 -1, 98, -1, -1, 101, -1, 103, 104, -1, 106,
1618 -1, 5, 6, -1, 8, 9, 10, 11, 12, 13,
1619 14, 15, 16, 17, 18, 19, 20, 21, 22, -1,
1620 24, -1, -1, -1, -1, -1, -1, -1, -1, 98,
1621 -1, -1, 101, 37, -1, 104, -1, 106, -1, 5,
1622 6, 45, 8, 9, 10, 11, 12, 13, 14, 15,
1623 16, 17, 18, 19, 20, 21, 22, -1, 24, 5,
1624 6, -1, 8, 9, 10, 11, 12, 13, 14, 15,
1625 16, 17, 18, 19, 20, 21, 22, -1, 24, 45,
Chris Lattnerb475c422005-11-12 18:22:38 +00001626 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattner7aa61892005-12-21 17:53:23 +00001627 -1, -1, -1, -1, 98, -1, -1, 101, -1, 45,
1628 104, -1, 106, 5, 6, -1, 8, 9, 10, 11,
Chris Lattnerb475c422005-11-12 18:22:38 +00001629 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
1630 22, -1, 24, -1, -1, -1, -1, -1, -1, -1,
Chris Lattner7aa61892005-12-21 17:53:23 +00001631 -1, -1, 98, -1, -1, 101, -1, -1, 104, -1,
1632 106, -1, -1, 45, -1, -1, -1, -1, -1, -1,
1633 -1, -1, 98, -1, -1, 101, -1, -1, 104, -1,
1634 106, 5, 6, -1, 8, 9, 10, 11, 12, 13,
1635 14, 15, 16, 17, 18, 19, 20, 21, 22, -1,
1636 24, -1, -1, -1, 35, -1, -1, -1, -1, -1,
1637 -1, -1, -1, -1, -1, 46, 98, -1, -1, 101,
1638 -1, 45, 104, -1, 106, 56, 57, -1, -1, -1,
1639 -1, 62, 63, 64, 65, 66, 67, 68, 69, 70,
1640 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
1641 81, 82, 83, 84, -1, -1, 87, 88, 89, 90,
1642 91, 92, 93, 94, 95, -1, -1, -1, -1, -1,
1643 -1, -1, -1, -1, 98, -1, -1, 101, -1, -1,
1644 104, -1, 106
Nate Begeman14b05292005-11-05 09:21:28 +00001645};
1646/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
1647#line 3 "/usr/share/bison.simple"
1648/* This file comes from bison-1.28. */
1649
1650/* Skeleton output parser for bison,
1651 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
1652
1653 This program is free software; you can redistribute it and/or modify
1654 it under the terms of the GNU General Public License as published by
1655 the Free Software Foundation; either version 2, or (at your option)
1656 any later version.
1657
1658 This program is distributed in the hope that it will be useful,
1659 but WITHOUT ANY WARRANTY; without even the implied warranty of
1660 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1661 GNU General Public License for more details.
1662
1663 You should have received a copy of the GNU General Public License
1664 along with this program; if not, write to the Free Software
1665 Foundation, Inc., 59 Temple Place - Suite 330,
1666 Boston, MA 02111-1307, USA. */
1667
1668/* As a special exception, when this file is copied by Bison into a
1669 Bison output file, you may use that output file without restriction.
1670 This special exception was added by the Free Software Foundation
1671 in version 1.24 of Bison. */
1672
1673/* This is the parser code that is written into each bison parser
1674 when the %semantic_parser declaration is not specified in the grammar.
1675 It was written by Richard Stallman by simplifying the hairy parser
1676 used when %semantic_parser is specified. */
1677
1678#ifndef YYSTACK_USE_ALLOCA
1679#ifdef alloca
1680#define YYSTACK_USE_ALLOCA
1681#else /* alloca not defined */
1682#ifdef __GNUC__
1683#define YYSTACK_USE_ALLOCA
1684#define alloca __builtin_alloca
1685#else /* not GNU C. */
1686#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
1687#define YYSTACK_USE_ALLOCA
1688#include <alloca.h>
1689#else /* not sparc */
1690/* We think this test detects Watcom and Microsoft C. */
1691/* This used to test MSDOS, but that is a bad idea
1692 since that symbol is in the user namespace. */
1693#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
1694#if 0 /* No need for malloc.h, which pollutes the namespace;
1695 instead, just don't use alloca. */
1696#include <malloc.h>
1697#endif
1698#else /* not MSDOS, or __TURBOC__ */
1699#if defined(_AIX)
1700/* I don't know what this was needed for, but it pollutes the namespace.
1701 So I turned it off. rms, 2 May 1997. */
1702/* #include <malloc.h> */
1703 #pragma alloca
1704#define YYSTACK_USE_ALLOCA
1705#else /* not MSDOS, or __TURBOC__, or _AIX */
1706#if 0
1707#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
1708 and on HPUX 10. Eventually we can turn this on. */
1709#define YYSTACK_USE_ALLOCA
1710#define alloca __builtin_alloca
1711#endif /* __hpux */
1712#endif
1713#endif /* not _AIX */
1714#endif /* not MSDOS, or __TURBOC__ */
1715#endif /* not sparc */
1716#endif /* not GNU C */
1717#endif /* alloca not defined */
1718#endif /* YYSTACK_USE_ALLOCA not defined */
1719
1720#ifdef YYSTACK_USE_ALLOCA
1721#define YYSTACK_ALLOC alloca
Reid Spencer68a24bd2005-08-27 18:50:39 +00001722#else
Nate Begeman14b05292005-11-05 09:21:28 +00001723#define YYSTACK_ALLOC malloc
Reid Spencer68a24bd2005-08-27 18:50:39 +00001724#endif
1725
Nate Begeman14b05292005-11-05 09:21:28 +00001726/* Note: there must be only one dollar sign in this file.
1727 It is replaced by the list of actions, each action
1728 as one case of the switch. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001729
1730#define yyerrok (yyerrstatus = 0)
1731#define yyclearin (yychar = YYEMPTY)
Nate Begeman14b05292005-11-05 09:21:28 +00001732#define YYEMPTY -2
Reid Spencer68a24bd2005-08-27 18:50:39 +00001733#define YYEOF 0
Reid Spencer68a24bd2005-08-27 18:50:39 +00001734#define YYACCEPT goto yyacceptlab
Nate Begeman14b05292005-11-05 09:21:28 +00001735#define YYABORT goto yyabortlab
1736#define YYERROR goto yyerrlab1
1737/* Like YYERROR except do call yyerror.
1738 This remains here temporarily to ease the
1739 transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00001740 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001741#define YYFAIL goto yyerrlab
Reid Spencer68a24bd2005-08-27 18:50:39 +00001742#define YYRECOVERING() (!!yyerrstatus)
Nate Begeman14b05292005-11-05 09:21:28 +00001743#define YYBACKUP(token, value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00001744do \
1745 if (yychar == YYEMPTY && yylen == 1) \
Nate Begeman14b05292005-11-05 09:21:28 +00001746 { yychar = (token), yylval = (value); \
1747 yychar1 = YYTRANSLATE (yychar); \
Reid Spencer68a24bd2005-08-27 18:50:39 +00001748 YYPOPSTACK; \
1749 goto yybackup; \
1750 } \
1751 else \
Nate Begeman14b05292005-11-05 09:21:28 +00001752 { yyerror ("syntax error: cannot back up"); YYERROR; } \
Reid Spencer68a24bd2005-08-27 18:50:39 +00001753while (0)
1754
1755#define YYTERROR 1
1756#define YYERRCODE 256
1757
Nate Begeman14b05292005-11-05 09:21:28 +00001758#ifndef YYPURE
1759#define YYLEX yylex()
Reid Spencer68a24bd2005-08-27 18:50:39 +00001760#endif
1761
Nate Begeman14b05292005-11-05 09:21:28 +00001762#ifdef YYPURE
1763#ifdef YYLSP_NEEDED
Reid Spencer68a24bd2005-08-27 18:50:39 +00001764#ifdef YYLEX_PARAM
Nate Begeman14b05292005-11-05 09:21:28 +00001765#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001766#else
Nate Begeman14b05292005-11-05 09:21:28 +00001767#define YYLEX yylex(&yylval, &yylloc)
1768#endif
1769#else /* not YYLSP_NEEDED */
1770#ifdef YYLEX_PARAM
1771#define YYLEX yylex(&yylval, YYLEX_PARAM)
1772#else
1773#define YYLEX yylex(&yylval)
1774#endif
1775#endif /* not YYLSP_NEEDED */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001776#endif
1777
Nate Begeman14b05292005-11-05 09:21:28 +00001778/* If nonreentrant, generate the variables here */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001779
Nate Begeman14b05292005-11-05 09:21:28 +00001780#ifndef YYPURE
Reid Spencer68a24bd2005-08-27 18:50:39 +00001781
Nate Begeman14b05292005-11-05 09:21:28 +00001782int yychar; /* the lookahead symbol */
1783YYSTYPE yylval; /* the semantic value of the */
1784 /* lookahead symbol */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001785
Nate Begeman14b05292005-11-05 09:21:28 +00001786#ifdef YYLSP_NEEDED
1787YYLTYPE yylloc; /* location data for the lookahead */
1788 /* symbol */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001789#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001790
Nate Begeman14b05292005-11-05 09:21:28 +00001791int yynerrs; /* number of parse errors so far */
1792#endif /* not YYPURE */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001793
Nate Begeman14b05292005-11-05 09:21:28 +00001794#if YYDEBUG != 0
1795int yydebug; /* nonzero means print parse trace */
1796/* Since this is uninitialized, it does not stop multiple parsers
1797 from coexisting. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001798#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001799
Nate Begeman14b05292005-11-05 09:21:28 +00001800/* YYINITDEPTH indicates the initial size of the parser's stacks */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001801
Reid Spencer68a24bd2005-08-27 18:50:39 +00001802#ifndef YYINITDEPTH
Nate Begeman14b05292005-11-05 09:21:28 +00001803#define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00001804#endif
1805
Nate Begeman14b05292005-11-05 09:21:28 +00001806/* YYMAXDEPTH is the maximum size the stacks can grow to
1807 (effective only if the built-in stack extension method is used). */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001808
Nate Begeman14b05292005-11-05 09:21:28 +00001809#if YYMAXDEPTH == 0
1810#undef YYMAXDEPTH
Reid Spencer68a24bd2005-08-27 18:50:39 +00001811#endif
1812
1813#ifndef YYMAXDEPTH
Nate Begeman14b05292005-11-05 09:21:28 +00001814#define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00001815#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001816
Nate Begeman14b05292005-11-05 09:21:28 +00001817/* Define __yy_memcpy. Note that the size argument
1818 should be passed with type unsigned int, because that is what the non-GCC
1819 definitions require. With GCC, __builtin_memcpy takes an arg
1820 of type size_t, but it can handle unsigned int. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001821
Nate Begeman14b05292005-11-05 09:21:28 +00001822#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
1823#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
1824#else /* not GNU C or C++ */
1825#ifndef __cplusplus
Reid Spencer68a24bd2005-08-27 18:50:39 +00001826
Nate Begeman14b05292005-11-05 09:21:28 +00001827/* This is the most reliable way to avoid incompatibilities
1828 in available built-in functions on various systems. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001829static void
Nate Begeman14b05292005-11-05 09:21:28 +00001830__yy_memcpy (to, from, count)
1831 char *to;
1832 char *from;
1833 unsigned int count;
1834{
1835 register char *f = from;
1836 register char *t = to;
1837 register int i = count;
1838
1839 while (i-- > 0)
1840 *t++ = *f++;
1841}
1842
1843#else /* __cplusplus */
1844
1845/* This is the most reliable way to avoid incompatibilities
1846 in available built-in functions on various systems. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001847static void
Nate Begeman14b05292005-11-05 09:21:28 +00001848__yy_memcpy (char *to, char *from, unsigned int count)
1849{
1850 register char *t = to;
1851 register char *f = from;
1852 register int i = count;
1853
1854 while (i-- > 0)
1855 *t++ = *f++;
1856}
1857
Reid Spencer68a24bd2005-08-27 18:50:39 +00001858#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001859#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001860
Nate Begeman14b05292005-11-05 09:21:28 +00001861#line 217 "/usr/share/bison.simple"
Reid Spencer68a24bd2005-08-27 18:50:39 +00001862
Nate Begeman14b05292005-11-05 09:21:28 +00001863/* The user can define YYPARSE_PARAM as the name of an argument to be passed
1864 into yyparse. The argument should have type void *.
1865 It should actually point to an object.
1866 Grammar actions can access the variable by casting it
1867 to the proper pointer type. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001868
1869#ifdef YYPARSE_PARAM
Nate Begeman14b05292005-11-05 09:21:28 +00001870#ifdef __cplusplus
1871#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
1872#define YYPARSE_PARAM_DECL
1873#else /* not __cplusplus */
1874#define YYPARSE_PARAM_ARG YYPARSE_PARAM
1875#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
1876#endif /* not __cplusplus */
1877#else /* not YYPARSE_PARAM */
1878#define YYPARSE_PARAM_ARG
1879#define YYPARSE_PARAM_DECL
1880#endif /* not YYPARSE_PARAM */
1881
1882/* Prevent warning if -Wstrict-prototypes. */
1883#ifdef __GNUC__
1884#ifdef YYPARSE_PARAM
1885int yyparse (void *);
1886#else
Reid Spencer68a24bd2005-08-27 18:50:39 +00001887int yyparse (void);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001888#endif
Nate Begeman14b05292005-11-05 09:21:28 +00001889#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001890
Reid Spencer68a24bd2005-08-27 18:50:39 +00001891int
Nate Begeman14b05292005-11-05 09:21:28 +00001892yyparse(YYPARSE_PARAM_ARG)
1893 YYPARSE_PARAM_DECL
Reid Spencer68a24bd2005-08-27 18:50:39 +00001894{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001895 register int yystate;
1896 register int yyn;
Nate Begeman14b05292005-11-05 09:21:28 +00001897 register short *yyssp;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001898 register YYSTYPE *yyvsp;
Nate Begeman14b05292005-11-05 09:21:28 +00001899 int yyerrstatus; /* number of tokens to shift before error messages enabled */
1900 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001901
Nate Begeman14b05292005-11-05 09:21:28 +00001902 short yyssa[YYINITDEPTH]; /* the state stack */
1903 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001904
Nate Begeman14b05292005-11-05 09:21:28 +00001905 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
1906 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001907
Nate Begeman14b05292005-11-05 09:21:28 +00001908#ifdef YYLSP_NEEDED
1909 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
1910 YYLTYPE *yyls = yylsa;
1911 YYLTYPE *yylsp;
1912
1913#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
1914#else
Reid Spencer68a24bd2005-08-27 18:50:39 +00001915#define YYPOPSTACK (yyvsp--, yyssp--)
Nate Begeman14b05292005-11-05 09:21:28 +00001916#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001917
Nate Begeman14b05292005-11-05 09:21:28 +00001918 int yystacksize = YYINITDEPTH;
1919 int yyfree_stacks = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001920
Nate Begeman14b05292005-11-05 09:21:28 +00001921#ifdef YYPURE
1922 int yychar;
1923 YYSTYPE yylval;
1924 int yynerrs;
1925#ifdef YYLSP_NEEDED
1926 YYLTYPE yylloc;
1927#endif
1928#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001929
Nate Begeman14b05292005-11-05 09:21:28 +00001930 YYSTYPE yyval; /* the variable used to return */
1931 /* semantic values from the action */
1932 /* routines */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001933
Reid Spencer68a24bd2005-08-27 18:50:39 +00001934 int yylen;
1935
Nate Begeman14b05292005-11-05 09:21:28 +00001936#if YYDEBUG != 0
1937 if (yydebug)
1938 fprintf(stderr, "Starting parse\n");
1939#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001940
1941 yystate = 0;
1942 yyerrstatus = 0;
1943 yynerrs = 0;
1944 yychar = YYEMPTY; /* Cause a token to be read. */
1945
1946 /* Initialize stack pointers.
1947 Waste one element of value and location stack
1948 so that they stay on the same level as the state stack.
1949 The wasted elements are never initialized. */
1950
Nate Begeman14b05292005-11-05 09:21:28 +00001951 yyssp = yyss - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001952 yyvsp = yyvs;
Nate Begeman14b05292005-11-05 09:21:28 +00001953#ifdef YYLSP_NEEDED
1954 yylsp = yyls;
1955#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001956
Nate Begeman14b05292005-11-05 09:21:28 +00001957/* Push a new state, which is found in yystate . */
1958/* In all cases, when you get here, the value and location stacks
1959 have just been pushed. so pushing a state here evens the stacks. */
1960yynewstate:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001961
Nate Begeman14b05292005-11-05 09:21:28 +00001962 *++yyssp = yystate;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001963
Nate Begeman14b05292005-11-05 09:21:28 +00001964 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001965 {
Nate Begeman14b05292005-11-05 09:21:28 +00001966 /* Give user a chance to reallocate the stack */
1967 /* Use copies of these so that the &'s don't force the real ones into memory. */
1968 YYSTYPE *yyvs1 = yyvs;
1969 short *yyss1 = yyss;
1970#ifdef YYLSP_NEEDED
1971 YYLTYPE *yyls1 = yyls;
1972#endif
1973
Reid Spencer68a24bd2005-08-27 18:50:39 +00001974 /* Get the current used size of the three stacks, in elements. */
Nate Begeman14b05292005-11-05 09:21:28 +00001975 int size = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001976
1977#ifdef yyoverflow
Nate Begeman14b05292005-11-05 09:21:28 +00001978 /* Each stack pointer address is followed by the size of
1979 the data in use in that stack, in bytes. */
1980#ifdef YYLSP_NEEDED
1981 /* This used to be a conditional around just the two extra args,
1982 but that might be undefined if yyoverflow is a macro. */
1983 yyoverflow("parser stack overflow",
1984 &yyss1, size * sizeof (*yyssp),
1985 &yyvs1, size * sizeof (*yyvsp),
1986 &yyls1, size * sizeof (*yylsp),
1987 &yystacksize);
1988#else
1989 yyoverflow("parser stack overflow",
1990 &yyss1, size * sizeof (*yyssp),
1991 &yyvs1, size * sizeof (*yyvsp),
1992 &yystacksize);
1993#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001994
Nate Begeman14b05292005-11-05 09:21:28 +00001995 yyss = yyss1; yyvs = yyvs1;
1996#ifdef YYLSP_NEEDED
1997 yyls = yyls1;
1998#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001999#else /* no yyoverflow */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002000 /* Extend the stack our own way. */
Nate Begeman14b05292005-11-05 09:21:28 +00002001 if (yystacksize >= YYMAXDEPTH)
2002 {
2003 yyerror("parser stack overflow");
2004 if (yyfree_stacks)
2005 {
2006 free (yyss);
2007 free (yyvs);
2008#ifdef YYLSP_NEEDED
2009 free (yyls);
2010#endif
2011 }
2012 return 2;
2013 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002014 yystacksize *= 2;
Nate Begeman14b05292005-11-05 09:21:28 +00002015 if (yystacksize > YYMAXDEPTH)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002016 yystacksize = YYMAXDEPTH;
Nate Begeman14b05292005-11-05 09:21:28 +00002017#ifndef YYSTACK_USE_ALLOCA
2018 yyfree_stacks = 1;
2019#endif
2020 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
2021 __yy_memcpy ((char *)yyss, (char *)yyss1,
2022 size * (unsigned int) sizeof (*yyssp));
2023 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
2024 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
2025 size * (unsigned int) sizeof (*yyvsp));
2026#ifdef YYLSP_NEEDED
2027 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
2028 __yy_memcpy ((char *)yyls, (char *)yyls1,
2029 size * (unsigned int) sizeof (*yylsp));
2030#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002031#endif /* no yyoverflow */
2032
Nate Begeman14b05292005-11-05 09:21:28 +00002033 yyssp = yyss + size - 1;
2034 yyvsp = yyvs + size - 1;
2035#ifdef YYLSP_NEEDED
2036 yylsp = yyls + size - 1;
2037#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002038
Nate Begeman14b05292005-11-05 09:21:28 +00002039#if YYDEBUG != 0
2040 if (yydebug)
2041 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2042#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002043
Nate Begeman14b05292005-11-05 09:21:28 +00002044 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002045 YYABORT;
2046 }
2047
Nate Begeman14b05292005-11-05 09:21:28 +00002048#if YYDEBUG != 0
2049 if (yydebug)
2050 fprintf(stderr, "Entering state %d\n", yystate);
2051#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002052
2053 goto yybackup;
Nate Begeman14b05292005-11-05 09:21:28 +00002054 yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002055
2056/* Do appropriate processing given the current state. */
2057/* Read a lookahead token if we need one and don't already have one. */
2058/* yyresume: */
2059
2060 /* First try to decide what to do without reference to lookahead token. */
2061
2062 yyn = yypact[yystate];
Nate Begeman14b05292005-11-05 09:21:28 +00002063 if (yyn == YYFLAG)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002064 goto yydefault;
2065
2066 /* Not known => get a lookahead token if don't already have one. */
2067
Nate Begeman14b05292005-11-05 09:21:28 +00002068 /* yychar is either YYEMPTY or YYEOF
2069 or a valid token in external form. */
2070
Reid Spencer68a24bd2005-08-27 18:50:39 +00002071 if (yychar == YYEMPTY)
2072 {
Nate Begeman14b05292005-11-05 09:21:28 +00002073#if YYDEBUG != 0
2074 if (yydebug)
2075 fprintf(stderr, "Reading a token: ");
2076#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002077 yychar = YYLEX;
2078 }
2079
Nate Begeman14b05292005-11-05 09:21:28 +00002080 /* Convert token to internal form (in yychar1) for indexing tables with */
2081
2082 if (yychar <= 0) /* This means end of input. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002083 {
Nate Begeman14b05292005-11-05 09:21:28 +00002084 yychar1 = 0;
2085 yychar = YYEOF; /* Don't call YYLEX any more */
2086
2087#if YYDEBUG != 0
2088 if (yydebug)
2089 fprintf(stderr, "Now at end of input.\n");
2090#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002091 }
2092 else
2093 {
Nate Begeman14b05292005-11-05 09:21:28 +00002094 yychar1 = YYTRANSLATE(yychar);
2095
2096#if YYDEBUG != 0
2097 if (yydebug)
2098 {
2099 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2100 /* Give the individual parser a way to print the precise meaning
2101 of a token, for further debugging info. */
2102#ifdef YYPRINT
2103 YYPRINT (stderr, yychar, yylval);
2104#endif
2105 fprintf (stderr, ")\n");
2106 }
2107#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002108 }
2109
Nate Begeman14b05292005-11-05 09:21:28 +00002110 yyn += yychar1;
2111 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002112 goto yydefault;
Nate Begeman14b05292005-11-05 09:21:28 +00002113
Reid Spencer68a24bd2005-08-27 18:50:39 +00002114 yyn = yytable[yyn];
Nate Begeman14b05292005-11-05 09:21:28 +00002115
2116 /* yyn is what to do for this token type in this state.
2117 Negative => reduce, -yyn is rule number.
2118 Positive => shift, yyn is new state.
2119 New state is final state => don't bother to shift,
2120 just return success.
2121 0, or most negative number => error. */
2122
2123 if (yyn < 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002124 {
Nate Begeman14b05292005-11-05 09:21:28 +00002125 if (yyn == YYFLAG)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002126 goto yyerrlab;
2127 yyn = -yyn;
2128 goto yyreduce;
2129 }
Nate Begeman14b05292005-11-05 09:21:28 +00002130 else if (yyn == 0)
2131 goto yyerrlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002132
2133 if (yyn == YYFINAL)
2134 YYACCEPT;
2135
2136 /* Shift the lookahead token. */
Nate Begeman14b05292005-11-05 09:21:28 +00002137
2138#if YYDEBUG != 0
2139 if (yydebug)
2140 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2141#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002142
2143 /* Discard the token being shifted unless it is eof. */
2144 if (yychar != YYEOF)
2145 yychar = YYEMPTY;
2146
2147 *++yyvsp = yylval;
Nate Begeman14b05292005-11-05 09:21:28 +00002148#ifdef YYLSP_NEEDED
2149 *++yylsp = yylloc;
2150#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002151
Nate Begeman14b05292005-11-05 09:21:28 +00002152 /* count tokens shifted since error; after three, turn off error status. */
2153 if (yyerrstatus) yyerrstatus--;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002154
2155 yystate = yyn;
2156 goto yynewstate;
2157
Nate Begeman14b05292005-11-05 09:21:28 +00002158/* Do the default action for the current state. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002159yydefault:
Nate Begeman14b05292005-11-05 09:21:28 +00002160
Reid Spencer68a24bd2005-08-27 18:50:39 +00002161 yyn = yydefact[yystate];
2162 if (yyn == 0)
2163 goto yyerrlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002164
Nate Begeman14b05292005-11-05 09:21:28 +00002165/* Do a reduction. yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002166yyreduce:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002167 yylen = yyr2[yyn];
Nate Begeman14b05292005-11-05 09:21:28 +00002168 if (yylen > 0)
2169 yyval = yyvsp[1-yylen]; /* implement default value of the action */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002170
Nate Begeman14b05292005-11-05 09:21:28 +00002171#if YYDEBUG != 0
2172 if (yydebug)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002173 {
Nate Begeman14b05292005-11-05 09:21:28 +00002174 int i;
2175
2176 fprintf (stderr, "Reducing via rule %d (line %d), ",
2177 yyn, yyrline[yyn]);
2178
2179 /* Print the symbols being reduced, and their result. */
2180 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2181 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2182 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2183 }
2184#endif
2185
2186
2187 switch (yyn) {
2188
2189case 2:
Chris Lattner7aa61892005-12-21 17:53:23 +00002190#line 992 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002191{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002192 if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX) // Outside of my range!
2193 ThrowException("Value too large for type!");
2194 yyval.SIntVal = (int32_t)yyvsp[0].UIntVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002195;
2196 break;}
2197case 4:
Chris Lattner7aa61892005-12-21 17:53:23 +00002198#line 1000 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002199{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002200 if (yyvsp[0].UInt64Val > (uint64_t)INT64_MAX) // Outside of my range!
2201 ThrowException("Value too large for type!");
2202 yyval.SInt64Val = (int64_t)yyvsp[0].UInt64Val;
Nate Begeman14b05292005-11-05 09:21:28 +00002203;
2204 break;}
2205case 33:
Chris Lattner7aa61892005-12-21 17:53:23 +00002206#line 1023 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002207{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002208 yyval.StrVal = yyvsp[-1].StrVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002209 ;
2210 break;}
2211case 34:
Chris Lattner7aa61892005-12-21 17:53:23 +00002212#line 1026 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002213{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002214 yyval.StrVal = 0;
Nate Begeman14b05292005-11-05 09:21:28 +00002215 ;
2216 break;}
2217case 35:
Chris Lattner7aa61892005-12-21 17:53:23 +00002218#line 1030 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002219{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2220 break;}
2221case 36:
Chris Lattner7aa61892005-12-21 17:53:23 +00002222#line 1031 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002223{ yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2224 break;}
2225case 37:
Chris Lattner7aa61892005-12-21 17:53:23 +00002226#line 1032 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002227{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2228 break;}
2229case 38:
Chris Lattner7aa61892005-12-21 17:53:23 +00002230#line 1033 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002231{ yyval.Linkage = GlobalValue::AppendingLinkage; ;
2232 break;}
2233case 39:
Chris Lattner7aa61892005-12-21 17:53:23 +00002234#line 1034 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002235{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2236 break;}
2237case 40:
Chris Lattner7aa61892005-12-21 17:53:23 +00002238#line 1036 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002239{ yyval.UIntVal = CallingConv::C; ;
2240 break;}
2241case 41:
Chris Lattner7aa61892005-12-21 17:53:23 +00002242#line 1037 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002243{ yyval.UIntVal = CallingConv::C; ;
2244 break;}
2245case 42:
Chris Lattner7aa61892005-12-21 17:53:23 +00002246#line 1038 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002247{ yyval.UIntVal = CallingConv::Fast; ;
2248 break;}
2249case 43:
Chris Lattner7aa61892005-12-21 17:53:23 +00002250#line 1039 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002251{ yyval.UIntVal = CallingConv::Cold; ;
2252 break;}
2253case 44:
Chris Lattner7aa61892005-12-21 17:53:23 +00002254#line 1040 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002255{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002256 if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
2257 ThrowException("Calling conv too large!");
2258 yyval.UIntVal = yyvsp[0].UInt64Val;
Nate Begeman14b05292005-11-05 09:21:28 +00002259 ;
2260 break;}
Chris Lattner7d09ab62005-11-06 06:34:34 +00002261case 45:
Chris Lattner7aa61892005-12-21 17:53:23 +00002262#line 1048 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner7d09ab62005-11-06 06:34:34 +00002263{ yyval.UIntVal = 0; ;
2264 break;}
Nate Begeman14b05292005-11-05 09:21:28 +00002265case 46:
Chris Lattner7aa61892005-12-21 17:53:23 +00002266#line 1049 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerb475c422005-11-12 18:22:38 +00002267{
2268 yyval.UIntVal = yyvsp[0].UInt64Val;
2269 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
2270 ThrowException("Alignment must be a power of two!");
2271;
Nate Begeman14b05292005-11-05 09:21:28 +00002272 break;}
Chris Lattner0019bbe2005-11-06 06:46:53 +00002273case 47:
Chris Lattner7aa61892005-12-21 17:53:23 +00002274#line 1054 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner0019bbe2005-11-06 06:46:53 +00002275{ yyval.UIntVal = 0; ;
2276 break;}
Nate Begeman14b05292005-11-05 09:21:28 +00002277case 48:
Chris Lattner7aa61892005-12-21 17:53:23 +00002278#line 1055 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerb475c422005-11-12 18:22:38 +00002279{
2280 yyval.UIntVal = yyvsp[0].UInt64Val;
2281 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
2282 ThrowException("Alignment must be a power of two!");
2283;
Nate Begeman14b05292005-11-05 09:21:28 +00002284 break;}
Chris Lattnere869eef2005-11-12 00:11:49 +00002285case 49:
Chris Lattner7aa61892005-12-21 17:53:23 +00002286#line 1062 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnere869eef2005-11-12 00:11:49 +00002287{
2288 for (unsigned i = 0, e = strlen(yyvsp[0].StrVal); i != e; ++i)
2289 if (yyvsp[0].StrVal[i] == '"' || yyvsp[0].StrVal[i] == '\\')
2290 ThrowException("Invalid character in section name!");
2291 yyval.StrVal = yyvsp[0].StrVal;
2292;
2293 break;}
Chris Lattner7d09ab62005-11-06 06:34:34 +00002294case 50:
Chris Lattner7aa61892005-12-21 17:53:23 +00002295#line 1069 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnere869eef2005-11-12 00:11:49 +00002296{ yyval.StrVal = 0; ;
2297 break;}
2298case 51:
Chris Lattner7aa61892005-12-21 17:53:23 +00002299#line 1070 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnere869eef2005-11-12 00:11:49 +00002300{ yyval.StrVal = yyvsp[0].StrVal; ;
Chris Lattner7d09ab62005-11-06 06:34:34 +00002301 break;}
Chris Lattner0019bbe2005-11-06 06:46:53 +00002302case 52:
Chris Lattner7aa61892005-12-21 17:53:23 +00002303#line 1075 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerb475c422005-11-12 18:22:38 +00002304{;
Chris Lattner0019bbe2005-11-06 06:46:53 +00002305 break;}
2306case 53:
Chris Lattner7aa61892005-12-21 17:53:23 +00002307#line 1076 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerb475c422005-11-12 18:22:38 +00002308{;
2309 break;}
2310case 54:
Chris Lattner7aa61892005-12-21 17:53:23 +00002311#line 1077 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerb475c422005-11-12 18:22:38 +00002312{
2313 CurGV->setSection(yyvsp[0].StrVal);
2314 free(yyvsp[0].StrVal);
2315 ;
Chris Lattnere869eef2005-11-12 00:11:49 +00002316 break;}
2317case 55:
Chris Lattner7aa61892005-12-21 17:53:23 +00002318#line 1081 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerb475c422005-11-12 18:22:38 +00002319{
Chris Lattner7aa61892005-12-21 17:53:23 +00002320 if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val))
2321 ThrowException("Alignment must be a power of two!");
Chris Lattnerb475c422005-11-12 18:22:38 +00002322 CurGV->setAlignment(yyvsp[0].UInt64Val);
2323 ;
Chris Lattnere869eef2005-11-12 00:11:49 +00002324 break;}
2325case 57:
Chris Lattner7aa61892005-12-21 17:53:23 +00002326#line 1094 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnere869eef2005-11-12 00:11:49 +00002327{ yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2328 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002329case 59:
Chris Lattner7aa61892005-12-21 17:53:23 +00002330#line 1095 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerb475c422005-11-12 18:22:38 +00002331{ yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2332 break;}
2333case 60:
Chris Lattner7aa61892005-12-21 17:53:23 +00002334#line 1097 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002335{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002336 if (!UpRefs.empty())
2337 ThrowException("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
2338 yyval.TypeVal = yyvsp[0].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002339 ;
2340 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002341case 74:
Chris Lattner7aa61892005-12-21 17:53:23 +00002342#line 1108 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002343{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002344 yyval.TypeVal = new PATypeHolder(OpaqueType::get());
Nate Begeman14b05292005-11-05 09:21:28 +00002345 ;
2346 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002347case 75:
Chris Lattner7aa61892005-12-21 17:53:23 +00002348#line 1111 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002349{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002350 yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
Nate Begeman14b05292005-11-05 09:21:28 +00002351 ;
2352 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002353case 76:
Chris Lattner7aa61892005-12-21 17:53:23 +00002354#line 1114 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002355{ // Named types are also simple types...
Reid Spencer68a24bd2005-08-27 18:50:39 +00002356 yyval.TypeVal = new PATypeHolder(getTypeVal(yyvsp[0].ValIDVal));
Nate Begeman14b05292005-11-05 09:21:28 +00002357;
2358 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002359case 77:
Chris Lattner7aa61892005-12-21 17:53:23 +00002360#line 1120 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002361{ // Type UpReference
Reid Spencer68a24bd2005-08-27 18:50:39 +00002362 if (yyvsp[0].UInt64Val > (uint64_t)~0U) ThrowException("Value out of range!");
2363 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
2364 UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector...
2365 yyval.TypeVal = new PATypeHolder(OT);
2366 UR_OUT("New Upreference!\n");
Nate Begeman14b05292005-11-05 09:21:28 +00002367 ;
2368 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002369case 78:
Chris Lattner7aa61892005-12-21 17:53:23 +00002370#line 1127 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002371{ // Function derived type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002372 std::vector<const Type*> Params;
2373 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2374 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2375 Params.push_back(*I);
2376 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
2377 if (isVarArg) Params.pop_back();
2378
2379 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FunctionType::get(*yyvsp[-3].TypeVal,Params,isVarArg)));
2380 delete yyvsp[-1].TypeList; // Delete the argument list
2381 delete yyvsp[-3].TypeVal; // Delete the return type handle
Nate Begeman14b05292005-11-05 09:21:28 +00002382 ;
2383 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002384case 79:
Chris Lattner7aa61892005-12-21 17:53:23 +00002385#line 1139 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002386{ // Sized array type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002387 yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2388 delete yyvsp[-1].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002389 ;
2390 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002391case 80:
Chris Lattner7aa61892005-12-21 17:53:23 +00002392#line 1143 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002393{ // Packed array type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002394 const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
Chris Lattner9547d7f2005-11-10 01:42:43 +00002395 if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002396 ThrowException("Unsigned result not equal to signed result");
Chris Lattner9547d7f2005-11-10 01:42:43 +00002397 if (!ElemTy->isPrimitiveType())
Reid Spencer68a24bd2005-08-27 18:50:39 +00002398 ThrowException("Elemental type of a PackedType must be primitive");
Chris Lattner9547d7f2005-11-10 01:42:43 +00002399 if (!isPowerOf2_32(yyvsp[-3].UInt64Val))
2400 ThrowException("Vector length should be a power of 2!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00002401 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PackedType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2402 delete yyvsp[-1].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002403 ;
2404 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002405case 81:
Chris Lattner7aa61892005-12-21 17:53:23 +00002406#line 1154 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002407{ // Structure type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002408 std::vector<const Type*> Elements;
2409 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2410 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2411 Elements.push_back(*I);
2412
2413 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
2414 delete yyvsp[-1].TypeList;
Nate Begeman14b05292005-11-05 09:21:28 +00002415 ;
2416 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002417case 82:
Chris Lattner7aa61892005-12-21 17:53:23 +00002418#line 1163 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002419{ // Empty structure type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002420 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Nate Begeman14b05292005-11-05 09:21:28 +00002421 ;
2422 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002423case 83:
Chris Lattner7aa61892005-12-21 17:53:23 +00002424#line 1166 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002425{ // Pointer type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002426 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal)));
2427 delete yyvsp[-1].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002428 ;
2429 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002430case 84:
Chris Lattner7aa61892005-12-21 17:53:23 +00002431#line 1174 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002432{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002433 yyval.TypeList = new std::list<PATypeHolder>();
2434 yyval.TypeList->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002435 ;
2436 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002437case 85:
Chris Lattner7aa61892005-12-21 17:53:23 +00002438#line 1178 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002439{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002440 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002441 ;
2442 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002443case 87:
Chris Lattner7aa61892005-12-21 17:53:23 +00002444#line 1184 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002445{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002446 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(Type::VoidTy);
Nate Begeman14b05292005-11-05 09:21:28 +00002447 ;
2448 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002449case 88:
Chris Lattner7aa61892005-12-21 17:53:23 +00002450#line 1187 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002451{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002452 (yyval.TypeList = new std::list<PATypeHolder>())->push_back(Type::VoidTy);
Nate Begeman14b05292005-11-05 09:21:28 +00002453 ;
2454 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002455case 89:
Chris Lattner7aa61892005-12-21 17:53:23 +00002456#line 1190 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002457{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002458 yyval.TypeList = new std::list<PATypeHolder>();
Nate Begeman14b05292005-11-05 09:21:28 +00002459 ;
2460 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002461case 90:
Chris Lattner7aa61892005-12-21 17:53:23 +00002462#line 1200 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002463{ // Nonempty unsized arr
Reid Spencer68a24bd2005-08-27 18:50:39 +00002464 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
2465 if (ATy == 0)
2466 ThrowException("Cannot make array constant with type: '" +
2467 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2468 const Type *ETy = ATy->getElementType();
2469 int NumElements = ATy->getNumElements();
2470
2471 // Verify that we have the correct size...
2472 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2473 ThrowException("Type mismatch: constant sized array initialized with " +
2474 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
2475 itostr(NumElements) + "!");
2476
2477 // Verify all elements are correct type!
2478 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2479 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2480 ThrowException("Element #" + utostr(i) + " is not of type '" +
2481 ETy->getDescription() +"' as required!\nIt is of type '"+
2482 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2483 }
2484
2485 yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
2486 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Nate Begeman14b05292005-11-05 09:21:28 +00002487 ;
2488 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002489case 91:
Chris Lattner7aa61892005-12-21 17:53:23 +00002490#line 1225 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002491{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002492 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2493 if (ATy == 0)
2494 ThrowException("Cannot make array constant with type: '" +
2495 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2496
2497 int NumElements = ATy->getNumElements();
2498 if (NumElements != -1 && NumElements != 0)
2499 ThrowException("Type mismatch: constant sized array initialized with 0"
2500 " arguments, but has size of " + itostr(NumElements) +"!");
2501 yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
2502 delete yyvsp[-2].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002503 ;
2504 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002505case 92:
Chris Lattner7aa61892005-12-21 17:53:23 +00002506#line 1238 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002507{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002508 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2509 if (ATy == 0)
2510 ThrowException("Cannot make array constant with type: '" +
2511 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2512
2513 int NumElements = ATy->getNumElements();
2514 const Type *ETy = ATy->getElementType();
2515 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
2516 if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal))
2517 ThrowException("Can't build string constant of size " +
2518 itostr((int)(EndStr-yyvsp[0].StrVal)) +
2519 " when array has size " + itostr(NumElements) + "!");
2520 std::vector<Constant*> Vals;
2521 if (ETy == Type::SByteTy) {
2522 for (char *C = yyvsp[0].StrVal; C != EndStr; ++C)
2523 Vals.push_back(ConstantSInt::get(ETy, *C));
2524 } else if (ETy == Type::UByteTy) {
2525 for (char *C = yyvsp[0].StrVal; C != EndStr; ++C)
2526 Vals.push_back(ConstantUInt::get(ETy, (unsigned char)*C));
2527 } else {
2528 free(yyvsp[0].StrVal);
2529 ThrowException("Cannot build string arrays of non byte sized elements!");
2530 }
2531 free(yyvsp[0].StrVal);
2532 yyval.ConstVal = ConstantArray::get(ATy, Vals);
2533 delete yyvsp[-2].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002534 ;
2535 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002536case 93:
Chris Lattner7aa61892005-12-21 17:53:23 +00002537#line 1266 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002538{ // Nonempty unsized arr
Reid Spencer68a24bd2005-08-27 18:50:39 +00002539 const PackedType *PTy = dyn_cast<PackedType>(yyvsp[-3].TypeVal->get());
2540 if (PTy == 0)
2541 ThrowException("Cannot make packed constant with type: '" +
2542 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2543 const Type *ETy = PTy->getElementType();
2544 int NumElements = PTy->getNumElements();
2545
2546 // Verify that we have the correct size...
2547 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2548 ThrowException("Type mismatch: constant sized packed initialized with " +
2549 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
2550 itostr(NumElements) + "!");
2551
2552 // Verify all elements are correct type!
2553 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2554 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2555 ThrowException("Element #" + utostr(i) + " is not of type '" +
2556 ETy->getDescription() +"' as required!\nIt is of type '"+
2557 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2558 }
2559
2560 yyval.ConstVal = ConstantPacked::get(PTy, *yyvsp[-1].ConstVector);
2561 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Nate Begeman14b05292005-11-05 09:21:28 +00002562 ;
2563 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002564case 94:
Chris Lattner7aa61892005-12-21 17:53:23 +00002565#line 1291 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002566{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002567 const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
2568 if (STy == 0)
2569 ThrowException("Cannot make struct constant with type: '" +
2570 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2571
2572 if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
2573 ThrowException("Illegal number of initializers for structure type!");
2574
2575 // Check to ensure that constants are compatible with the type initializer!
2576 for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
2577 if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
2578 ThrowException("Expected type '" +
2579 STy->getElementType(i)->getDescription() +
2580 "' for element #" + utostr(i) +
2581 " of structure initializer!");
2582
2583 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
2584 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Nate Begeman14b05292005-11-05 09:21:28 +00002585 ;
2586 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002587case 95:
Chris Lattner7aa61892005-12-21 17:53:23 +00002588#line 1311 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002589{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002590 const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
2591 if (STy == 0)
2592 ThrowException("Cannot make struct constant with type: '" +
2593 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2594
2595 if (STy->getNumContainedTypes() != 0)
2596 ThrowException("Illegal number of initializers for structure type!");
2597
2598 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
2599 delete yyvsp[-2].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002600 ;
2601 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002602case 96:
Chris Lattner7aa61892005-12-21 17:53:23 +00002603#line 1323 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002604{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002605 const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
2606 if (PTy == 0)
2607 ThrowException("Cannot make null pointer constant with type: '" +
2608 (*yyvsp[-1].TypeVal)->getDescription() + "'!");
2609
2610 yyval.ConstVal = ConstantPointerNull::get(PTy);
2611 delete yyvsp[-1].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002612 ;
2613 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002614case 97:
Chris Lattner7aa61892005-12-21 17:53:23 +00002615#line 1332 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002616{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002617 yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
2618 delete yyvsp[-1].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002619 ;
2620 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002621case 98:
Chris Lattner7aa61892005-12-21 17:53:23 +00002622#line 1336 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002623{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002624 const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
2625 if (Ty == 0)
2626 ThrowException("Global const reference must be a pointer type!");
2627
2628 // ConstExprs can exist in the body of a function, thus creating
2629 // GlobalValues whenever they refer to a variable. Because we are in
2630 // the context of a function, getValNonImprovising will search the functions
2631 // symbol table instead of the module symbol table for the global symbol,
2632 // which throws things all off. To get around this, we just tell
2633 // getValNonImprovising that we are at global scope here.
2634 //
2635 Function *SavedCurFn = CurFun.CurrentFunction;
2636 CurFun.CurrentFunction = 0;
2637
2638 Value *V = getValNonImprovising(Ty, yyvsp[0].ValIDVal);
2639
2640 CurFun.CurrentFunction = SavedCurFn;
2641
2642 // If this is an initializer for a constant pointer, which is referencing a
2643 // (currently) undefined variable, create a stub now that shall be replaced
2644 // in the future with the right type of variable.
2645 //
2646 if (V == 0) {
2647 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
2648 const PointerType *PT = cast<PointerType>(Ty);
2649
2650 // First check to see if the forward references value is already created!
2651 PerModuleInfo::GlobalRefsType::iterator I =
2652 CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
2653
2654 if (I != CurModule.GlobalRefs.end()) {
2655 V = I->second; // Placeholder already exists, use it...
2656 yyvsp[0].ValIDVal.destroy();
2657 } else {
2658 std::string Name;
2659 if (yyvsp[0].ValIDVal.Type == ValID::NameVal) Name = yyvsp[0].ValIDVal.Name;
2660
2661 // Create the forward referenced global.
2662 GlobalValue *GV;
2663 if (const FunctionType *FTy =
2664 dyn_cast<FunctionType>(PT->getElementType())) {
2665 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
2666 CurModule.CurrentModule);
2667 } else {
2668 GV = new GlobalVariable(PT->getElementType(), false,
2669 GlobalValue::ExternalLinkage, 0,
2670 Name, CurModule.CurrentModule);
2671 }
2672
2673 // Keep track of the fact that we have a forward ref to recycle it
2674 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
2675 V = GV;
2676 }
2677 }
2678
2679 yyval.ConstVal = cast<GlobalValue>(V);
2680 delete yyvsp[-1].TypeVal; // Free the type handle
Nate Begeman14b05292005-11-05 09:21:28 +00002681 ;
2682 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002683case 99:
Chris Lattner7aa61892005-12-21 17:53:23 +00002684#line 1395 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002685{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002686 if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
2687 ThrowException("Mismatched types for constant expression!");
2688 yyval.ConstVal = yyvsp[0].ConstVal;
2689 delete yyvsp[-1].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002690 ;
2691 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002692case 100:
Chris Lattner7aa61892005-12-21 17:53:23 +00002693#line 1401 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002694{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002695 const Type *Ty = yyvsp[-1].TypeVal->get();
2696 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
2697 ThrowException("Cannot create a null initialized value of this type!");
2698 yyval.ConstVal = Constant::getNullValue(Ty);
2699 delete yyvsp[-1].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002700 ;
2701 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002702case 101:
Chris Lattner7aa61892005-12-21 17:53:23 +00002703#line 1409 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002704{ // integral constants
Reid Spencer68a24bd2005-08-27 18:50:39 +00002705 if (!ConstantSInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
2706 ThrowException("Constant value doesn't fit in type!");
2707 yyval.ConstVal = ConstantSInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val);
Nate Begeman14b05292005-11-05 09:21:28 +00002708 ;
2709 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002710case 102:
Chris Lattner7aa61892005-12-21 17:53:23 +00002711#line 1414 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002712{ // integral constants
Reid Spencer68a24bd2005-08-27 18:50:39 +00002713 if (!ConstantUInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
2714 ThrowException("Constant value doesn't fit in type!");
2715 yyval.ConstVal = ConstantUInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val);
Nate Begeman14b05292005-11-05 09:21:28 +00002716 ;
2717 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002718case 103:
Chris Lattner7aa61892005-12-21 17:53:23 +00002719#line 1419 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002720{ // Boolean constants
Reid Spencer68a24bd2005-08-27 18:50:39 +00002721 yyval.ConstVal = ConstantBool::True;
Nate Begeman14b05292005-11-05 09:21:28 +00002722 ;
2723 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002724case 104:
Chris Lattner7aa61892005-12-21 17:53:23 +00002725#line 1422 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002726{ // Boolean constants
Reid Spencer68a24bd2005-08-27 18:50:39 +00002727 yyval.ConstVal = ConstantBool::False;
Nate Begeman14b05292005-11-05 09:21:28 +00002728 ;
2729 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002730case 105:
Chris Lattner7aa61892005-12-21 17:53:23 +00002731#line 1425 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002732{ // Float & Double constants
Reid Spencer68a24bd2005-08-27 18:50:39 +00002733 if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal))
2734 ThrowException("Floating point constant invalid for type!!");
2735 yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal);
Nate Begeman14b05292005-11-05 09:21:28 +00002736 ;
2737 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002738case 106:
Chris Lattner7aa61892005-12-21 17:53:23 +00002739#line 1432 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002740{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002741 if (!yyvsp[-3].ConstVal->getType()->isFirstClassType())
2742 ThrowException("cast constant expression from a non-primitive type: '" +
2743 yyvsp[-3].ConstVal->getType()->getDescription() + "'!");
2744 if (!yyvsp[-1].TypeVal->get()->isFirstClassType())
2745 ThrowException("cast constant expression to a non-primitive type: '" +
2746 yyvsp[-1].TypeVal->get()->getDescription() + "'!");
2747 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-3].ConstVal, yyvsp[-1].TypeVal->get());
2748 delete yyvsp[-1].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002749 ;
2750 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002751case 107:
Chris Lattner7aa61892005-12-21 17:53:23 +00002752#line 1442 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002753{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002754 if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
2755 ThrowException("GetElementPtr requires a pointer operand!");
2756
2757 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
2758 // indices to uint struct indices for compatibility.
2759 generic_gep_type_iterator<std::vector<Value*>::iterator>
2760 GTI = gep_type_begin(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end()),
2761 GTE = gep_type_end(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end());
2762 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
2763 if (isa<StructType>(*GTI)) // Only change struct indices
2764 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[-1].ValueList)[i]))
2765 if (CUI->getType() == Type::UByteTy)
2766 (*yyvsp[-1].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
2767
2768 const Type *IdxTy =
2769 GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), *yyvsp[-1].ValueList, true);
2770 if (!IdxTy)
2771 ThrowException("Index list invalid for constant getelementptr!");
2772
2773 std::vector<Constant*> IdxVec;
2774 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
2775 if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
2776 IdxVec.push_back(C);
2777 else
2778 ThrowException("Indices to constant getelementptr must be constants!");
2779
2780 delete yyvsp[-1].ValueList;
2781
2782 yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, IdxVec);
Nate Begeman14b05292005-11-05 09:21:28 +00002783 ;
2784 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002785case 108:
Chris Lattner7aa61892005-12-21 17:53:23 +00002786#line 1473 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002787{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002788 if (yyvsp[-5].ConstVal->getType() != Type::BoolTy)
2789 ThrowException("Select condition must be of boolean type!");
2790 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2791 ThrowException("Select operand types must match!");
2792 yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Nate Begeman14b05292005-11-05 09:21:28 +00002793 ;
2794 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002795case 109:
Chris Lattner7aa61892005-12-21 17:53:23 +00002796#line 1480 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002797{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002798 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2799 ThrowException("Binary operator types must match!");
2800 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
2801 // To retain backward compatibility with these early compilers, we emit a
2802 // cast to the appropriate integer type automatically if we are in the
2803 // broken case. See PR424 for more information.
2804 if (!isa<PointerType>(yyvsp[-3].ConstVal->getType())) {
2805 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2806 } else {
2807 const Type *IntPtrTy = 0;
2808 switch (CurModule.CurrentModule->getPointerSize()) {
2809 case Module::Pointer32: IntPtrTy = Type::IntTy; break;
2810 case Module::Pointer64: IntPtrTy = Type::LongTy; break;
2811 default: ThrowException("invalid pointer binary constant expr!");
2812 }
2813 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, ConstantExpr::getCast(yyvsp[-3].ConstVal, IntPtrTy),
2814 ConstantExpr::getCast(yyvsp[-1].ConstVal, IntPtrTy));
2815 yyval.ConstVal = ConstantExpr::getCast(yyval.ConstVal, yyvsp[-3].ConstVal->getType());
2816 }
Nate Begeman14b05292005-11-05 09:21:28 +00002817 ;
2818 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002819case 110:
Chris Lattner7aa61892005-12-21 17:53:23 +00002820#line 1501 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002821{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002822 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2823 ThrowException("Logical operator types must match!");
Chris Lattner524a1312005-12-21 18:31:50 +00002824 if (!yyvsp[-3].ConstVal->getType()->isIntegral()) {
2825 if (!isa<PackedType>(yyvsp[-3].ConstVal->getType()) ||
2826 !cast<PackedType>(yyvsp[-3].ConstVal->getType())->getElementType()->isIntegral())
2827 ThrowException("Logical operator requires integral operands!");
2828 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002829 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Nate Begeman14b05292005-11-05 09:21:28 +00002830 ;
2831 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002832case 111:
Chris Lattner524a1312005-12-21 18:31:50 +00002833#line 1511 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002834{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002835 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2836 ThrowException("setcc operand types must match!");
2837 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Nate Begeman14b05292005-11-05 09:21:28 +00002838 ;
2839 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002840case 112:
Chris Lattner524a1312005-12-21 18:31:50 +00002841#line 1516 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002842{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002843 if (yyvsp[-1].ConstVal->getType() != Type::UByteTy)
2844 ThrowException("Shift count for shift constant must be unsigned byte!");
2845 if (!yyvsp[-3].ConstVal->getType()->isInteger())
2846 ThrowException("Shift constant expression requires integer operand!");
2847 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].OtherOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Nate Begeman14b05292005-11-05 09:21:28 +00002848 ;
2849 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002850case 113:
Chris Lattner524a1312005-12-21 18:31:50 +00002851#line 1526 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002852{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002853 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
Nate Begeman14b05292005-11-05 09:21:28 +00002854 ;
2855 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002856case 114:
Chris Lattner524a1312005-12-21 18:31:50 +00002857#line 1529 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002858{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002859 yyval.ConstVector = new std::vector<Constant*>();
2860 yyval.ConstVector->push_back(yyvsp[0].ConstVal);
Nate Begeman14b05292005-11-05 09:21:28 +00002861 ;
2862 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002863case 115:
Chris Lattner524a1312005-12-21 18:31:50 +00002864#line 1536 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002865{ yyval.BoolVal = false; ;
2866 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002867case 116:
Chris Lattner524a1312005-12-21 18:31:50 +00002868#line 1536 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002869{ yyval.BoolVal = true; ;
2870 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002871case 117:
Chris Lattner524a1312005-12-21 18:31:50 +00002872#line 1546 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002873{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002874 yyval.ModuleVal = ParserResult = yyvsp[0].ModuleVal;
2875 CurModule.ModuleDone();
Nate Begeman14b05292005-11-05 09:21:28 +00002876;
2877 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002878case 118:
Chris Lattner524a1312005-12-21 18:31:50 +00002879#line 1553 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002880{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002881 yyval.ModuleVal = yyvsp[-1].ModuleVal;
2882 CurFun.FunctionDone();
Nate Begeman14b05292005-11-05 09:21:28 +00002883 ;
2884 break;}
Chris Lattnere869eef2005-11-12 00:11:49 +00002885case 119:
Chris Lattner7aa61892005-12-21 17:53:23 +00002886#line 1557 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerb475c422005-11-12 18:22:38 +00002887{
2888 yyval.ModuleVal = yyvsp[-1].ModuleVal;
2889 ;
2890 break;}
Chris Lattner524a1312005-12-21 18:31:50 +00002891case 120:
Chris Lattner7aa61892005-12-21 17:53:23 +00002892#line 1560 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002893{
Chris Lattner524a1312005-12-21 18:31:50 +00002894 yyval.ModuleVal = yyvsp[-1].ModuleVal;
2895 ;
2896 break;}
2897case 121:
2898#line 1563 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2899{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002900 yyval.ModuleVal = CurModule.CurrentModule;
2901 // Emit an error if there are any unresolved types left.
2902 if (!CurModule.LateResolveTypes.empty()) {
2903 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
2904 if (DID.Type == ValID::NameVal)
2905 ThrowException("Reference to an undefined type: '"+DID.getName() + "'");
2906 else
2907 ThrowException("Reference to an undefined type: #" + itostr(DID.Num));
2908 }
Nate Begeman14b05292005-11-05 09:21:28 +00002909 ;
2910 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002911case 122:
Chris Lattner524a1312005-12-21 18:31:50 +00002912#line 1576 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002913{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002914 // Eagerly resolve types. This is not an optimization, this is a
2915 // requirement that is due to the fact that we could have this:
2916 //
2917 // %list = type { %list * }
2918 // %list = type { %list * } ; repeated type decl
2919 //
2920 // If types are not resolved eagerly, then the two types will not be
2921 // determined to be the same type!
2922 //
2923 ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
2924
2925 if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
2926 // If this is a named type that is not a redefinition, add it to the slot
2927 // table.
2928 CurModule.Types.push_back(*yyvsp[0].TypeVal);
2929 }
2930
2931 delete yyvsp[0].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002932 ;
2933 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002934case 123:
Chris Lattner524a1312005-12-21 18:31:50 +00002935#line 1596 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002936{ // Function prototypes can be in const pool
2937 ;
2938 break;}
Chris Lattner0019bbe2005-11-06 06:46:53 +00002939case 124:
Chris Lattner524a1312005-12-21 18:31:50 +00002940#line 1598 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerb475c422005-11-12 18:22:38 +00002941{
2942 if (yyvsp[0].ConstVal == 0) ThrowException("Global value initializer is not a constant!");
2943 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, yyvsp[-2].Linkage, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal);
2944 ;
Chris Lattnere869eef2005-11-12 00:11:49 +00002945 break;}
2946case 125:
Chris Lattner524a1312005-12-21 18:31:50 +00002947#line 1601 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnere869eef2005-11-12 00:11:49 +00002948{
Chris Lattnerb475c422005-11-12 18:22:38 +00002949 CurGV = 0;
Chris Lattnere869eef2005-11-12 00:11:49 +00002950 ;
2951 break;}
2952case 126:
Chris Lattner524a1312005-12-21 18:31:50 +00002953#line 1604 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerb475c422005-11-12 18:22:38 +00002954{
2955 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalLinkage,
2956 yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0);
2957 delete yyvsp[0].TypeVal;
2958 ;
2959 break;}
2960case 127:
Chris Lattner524a1312005-12-21 18:31:50 +00002961#line 1608 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerb475c422005-11-12 18:22:38 +00002962{
2963 CurGV = 0;
2964 ;
2965 break;}
2966case 128:
Chris Lattner524a1312005-12-21 18:31:50 +00002967#line 1611 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnere869eef2005-11-12 00:11:49 +00002968{
2969 ;
2970 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002971case 129:
Chris Lattner524a1312005-12-21 18:31:50 +00002972#line 1613 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerb475c422005-11-12 18:22:38 +00002973{
2974 ;
2975 break;}
2976case 130:
Chris Lattner524a1312005-12-21 18:31:50 +00002977#line 1615 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerb475c422005-11-12 18:22:38 +00002978{
2979 ;
2980 break;}
2981case 131:
Chris Lattner524a1312005-12-21 18:31:50 +00002982#line 1620 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnere869eef2005-11-12 00:11:49 +00002983{ yyval.Endianness = Module::BigEndian; ;
2984 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002985case 132:
Chris Lattner524a1312005-12-21 18:31:50 +00002986#line 1621 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnere869eef2005-11-12 00:11:49 +00002987{ yyval.Endianness = Module::LittleEndian; ;
2988 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002989case 133:
Chris Lattner524a1312005-12-21 18:31:50 +00002990#line 1623 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002991{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002992 CurModule.CurrentModule->setEndianness(yyvsp[0].Endianness);
Nate Begeman14b05292005-11-05 09:21:28 +00002993 ;
2994 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002995case 134:
Chris Lattner524a1312005-12-21 18:31:50 +00002996#line 1626 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002997{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002998 if (yyvsp[0].UInt64Val == 32)
2999 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
3000 else if (yyvsp[0].UInt64Val == 64)
3001 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
3002 else
3003 ThrowException("Invalid pointer size: '" + utostr(yyvsp[0].UInt64Val) + "'!");
Nate Begeman14b05292005-11-05 09:21:28 +00003004 ;
3005 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00003006case 135:
Chris Lattner524a1312005-12-21 18:31:50 +00003007#line 1634 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003008{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003009 CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal);
3010 free(yyvsp[0].StrVal);
Nate Begeman14b05292005-11-05 09:21:28 +00003011 ;
3012 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00003013case 137:
Chris Lattner524a1312005-12-21 18:31:50 +00003014#line 1641 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner0019bbe2005-11-06 06:46:53 +00003015{
3016 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3017 free(yyvsp[0].StrVal);
3018 ;
3019 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00003020case 138:
Chris Lattner524a1312005-12-21 18:31:50 +00003021#line 1645 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnere869eef2005-11-12 00:11:49 +00003022{
3023 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3024 free(yyvsp[0].StrVal);
3025 ;
Nate Begeman14b05292005-11-05 09:21:28 +00003026 break;}
Chris Lattnere869eef2005-11-12 00:11:49 +00003027case 139:
Chris Lattner524a1312005-12-21 18:31:50 +00003028#line 1649 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerb475c422005-11-12 18:22:38 +00003029{
3030 ;
3031 break;}
3032case 143:
Chris Lattner524a1312005-12-21 18:31:50 +00003033#line 1658 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnere869eef2005-11-12 00:11:49 +00003034{ yyval.StrVal = 0; ;
3035 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00003036case 144:
Chris Lattner524a1312005-12-21 18:31:50 +00003037#line 1660 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003038{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003039 if (*yyvsp[-1].TypeVal == Type::VoidTy)
3040 ThrowException("void typed arguments are invalid!");
3041 yyval.ArgVal = new std::pair<PATypeHolder*, char*>(yyvsp[-1].TypeVal, yyvsp[0].StrVal);
Nate Begeman14b05292005-11-05 09:21:28 +00003042;
3043 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00003044case 145:
Chris Lattner524a1312005-12-21 18:31:50 +00003045#line 1666 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003046{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003047 yyval.ArgList = yyvsp[-2].ArgList;
3048 yyvsp[-2].ArgList->push_back(*yyvsp[0].ArgVal);
3049 delete yyvsp[0].ArgVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003050 ;
3051 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00003052case 146:
Chris Lattner524a1312005-12-21 18:31:50 +00003053#line 1671 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003054{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003055 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
3056 yyval.ArgList->push_back(*yyvsp[0].ArgVal);
3057 delete yyvsp[0].ArgVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003058 ;
3059 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00003060case 147:
Chris Lattner524a1312005-12-21 18:31:50 +00003061#line 1677 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003062{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003063 yyval.ArgList = yyvsp[0].ArgList;
Nate Begeman14b05292005-11-05 09:21:28 +00003064 ;
3065 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00003066case 148:
Chris Lattner524a1312005-12-21 18:31:50 +00003067#line 1680 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003068{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003069 yyval.ArgList = yyvsp[-2].ArgList;
3070 yyval.ArgList->push_back(std::pair<PATypeHolder*,
3071 char*>(new PATypeHolder(Type::VoidTy), 0));
Nate Begeman14b05292005-11-05 09:21:28 +00003072 ;
3073 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00003074case 149:
Chris Lattner524a1312005-12-21 18:31:50 +00003075#line 1685 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003076{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003077 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
3078 yyval.ArgList->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0));
Nate Begeman14b05292005-11-05 09:21:28 +00003079 ;
3080 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00003081case 150:
Chris Lattner524a1312005-12-21 18:31:50 +00003082#line 1689 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003083{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003084 yyval.ArgList = 0;
Nate Begeman14b05292005-11-05 09:21:28 +00003085 ;
3086 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00003087case 151:
Chris Lattner524a1312005-12-21 18:31:50 +00003088#line 1694 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003089{
Chris Lattnere869eef2005-11-12 00:11:49 +00003090 UnEscapeLexed(yyvsp[-5].StrVal);
3091 std::string FunctionName(yyvsp[-5].StrVal);
3092 free(yyvsp[-5].StrVal); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00003093
Chris Lattnere869eef2005-11-12 00:11:49 +00003094 if (!(*yyvsp[-6].TypeVal)->isFirstClassType() && *yyvsp[-6].TypeVal != Type::VoidTy)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003095 ThrowException("LLVM functions cannot return aggregate types!");
3096
3097 std::vector<const Type*> ParamTypeList;
Chris Lattnere869eef2005-11-12 00:11:49 +00003098 if (yyvsp[-3].ArgList) { // If there are arguments...
3099 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-3].ArgList->begin();
3100 I != yyvsp[-3].ArgList->end(); ++I)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003101 ParamTypeList.push_back(I->first->get());
3102 }
3103
3104 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
3105 if (isVarArg) ParamTypeList.pop_back();
3106
Chris Lattnere869eef2005-11-12 00:11:49 +00003107 const FunctionType *FT = FunctionType::get(*yyvsp[-6].TypeVal, ParamTypeList, isVarArg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003108 const PointerType *PFT = PointerType::get(FT);
Chris Lattnere869eef2005-11-12 00:11:49 +00003109 delete yyvsp[-6].TypeVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003110
3111 ValID ID;
3112 if (!FunctionName.empty()) {
3113 ID = ValID::create((char*)FunctionName.c_str());
3114 } else {
3115 ID = ValID::create((int)CurModule.Values[PFT].size());
3116 }
3117
3118 Function *Fn = 0;
3119 // See if this function was forward referenced. If so, recycle the object.
3120 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
3121 // Move the function to the end of the list, from whereever it was
3122 // previously inserted.
3123 Fn = cast<Function>(FWRef);
3124 CurModule.CurrentModule->getFunctionList().remove(Fn);
3125 CurModule.CurrentModule->getFunctionList().push_back(Fn);
3126 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
3127 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
3128 // If this is the case, either we need to be a forward decl, or it needs
3129 // to be.
3130 if (!CurFun.isDeclare && !Fn->isExternal())
3131 ThrowException("Redefinition of function '" + FunctionName + "'!");
3132
3133 // Make sure to strip off any argument names so we can't get conflicts.
3134 if (Fn->isExternal())
3135 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
3136 AI != AE; ++AI)
3137 AI->setName("");
3138
3139 } else { // Not already defined?
3140 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
3141 CurModule.CurrentModule);
3142 InsertValue(Fn, CurModule.Values);
3143 }
3144
3145 CurFun.FunctionStart(Fn);
Chris Lattnere869eef2005-11-12 00:11:49 +00003146 Fn->setCallingConv(yyvsp[-7].UIntVal);
Chris Lattner0019bbe2005-11-06 06:46:53 +00003147 Fn->setAlignment(yyvsp[0].UIntVal);
Chris Lattnere869eef2005-11-12 00:11:49 +00003148 if (yyvsp[-1].StrVal) {
3149 Fn->setSection(yyvsp[-1].StrVal);
3150 free(yyvsp[-1].StrVal);
3151 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00003152
3153 // Add all of the arguments we parsed to the function...
Chris Lattnere869eef2005-11-12 00:11:49 +00003154 if (yyvsp[-3].ArgList) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00003155 if (isVarArg) { // Nuke the last entry
Chris Lattnere869eef2005-11-12 00:11:49 +00003156 assert(yyvsp[-3].ArgList->back().first->get() == Type::VoidTy && yyvsp[-3].ArgList->back().second == 0&&
Reid Spencer68a24bd2005-08-27 18:50:39 +00003157 "Not a varargs marker!");
Chris Lattnere869eef2005-11-12 00:11:49 +00003158 delete yyvsp[-3].ArgList->back().first;
3159 yyvsp[-3].ArgList->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00003160 }
3161 Function::arg_iterator ArgIt = Fn->arg_begin();
Chris Lattnere869eef2005-11-12 00:11:49 +00003162 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-3].ArgList->begin();
3163 I != yyvsp[-3].ArgList->end(); ++I, ++ArgIt) {
Reid Spencer68a24bd2005-08-27 18:50:39 +00003164 delete I->first; // Delete the typeholder...
3165
3166 setValueName(ArgIt, I->second); // Insert arg into symtab...
3167 InsertValue(ArgIt);
3168 }
3169
Chris Lattnere869eef2005-11-12 00:11:49 +00003170 delete yyvsp[-3].ArgList; // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00003171 }
Nate Begeman14b05292005-11-05 09:21:28 +00003172;
3173 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00003174case 154:
Chris Lattner524a1312005-12-21 18:31:50 +00003175#line 1781 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003176{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003177 yyval.FunctionVal = CurFun.CurrentFunction;
3178
3179 // Make sure that we keep track of the linkage type even if there was a
3180 // previous "declare".
3181 yyval.FunctionVal->setLinkage(yyvsp[-2].Linkage);
Nate Begeman14b05292005-11-05 09:21:28 +00003182;
3183 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00003184case 157:
Chris Lattner524a1312005-12-21 18:31:50 +00003185#line 1791 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003186{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003187 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003188;
3189 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00003190case 158:
Chris Lattner524a1312005-12-21 18:31:50 +00003191#line 1795 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003192{ CurFun.isDeclare = true; ;
3193 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00003194case 159:
Chris Lattner524a1312005-12-21 18:31:50 +00003195#line 1795 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003196{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003197 yyval.FunctionVal = CurFun.CurrentFunction;
3198 CurFun.FunctionDone();
Nate Begeman14b05292005-11-05 09:21:28 +00003199;
3200 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00003201case 160:
Chris Lattner524a1312005-12-21 18:31:50 +00003202#line 1804 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003203{ // A reference to a direct constant
Reid Spencer68a24bd2005-08-27 18:50:39 +00003204 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
Nate Begeman14b05292005-11-05 09:21:28 +00003205 ;
3206 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00003207case 161:
Chris Lattner524a1312005-12-21 18:31:50 +00003208#line 1807 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003209{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003210 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
Nate Begeman14b05292005-11-05 09:21:28 +00003211 ;
3212 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00003213case 162:
Chris Lattner524a1312005-12-21 18:31:50 +00003214#line 1810 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003215{ // Perhaps it's an FP constant?
Reid Spencer68a24bd2005-08-27 18:50:39 +00003216 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
Nate Begeman14b05292005-11-05 09:21:28 +00003217 ;
3218 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00003219case 163:
Chris Lattner524a1312005-12-21 18:31:50 +00003220#line 1813 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003221{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003222 yyval.ValIDVal = ValID::create(ConstantBool::True);
Nate Begeman14b05292005-11-05 09:21:28 +00003223 ;
3224 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00003225case 164:
Chris Lattner524a1312005-12-21 18:31:50 +00003226#line 1816 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003227{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003228 yyval.ValIDVal = ValID::create(ConstantBool::False);
Nate Begeman14b05292005-11-05 09:21:28 +00003229 ;
3230 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00003231case 165:
Chris Lattner524a1312005-12-21 18:31:50 +00003232#line 1819 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003233{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003234 yyval.ValIDVal = ValID::createNull();
Nate Begeman14b05292005-11-05 09:21:28 +00003235 ;
3236 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00003237case 166:
Chris Lattner524a1312005-12-21 18:31:50 +00003238#line 1822 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003239{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003240 yyval.ValIDVal = ValID::createUndef();
Nate Begeman14b05292005-11-05 09:21:28 +00003241 ;
3242 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00003243case 167:
Chris Lattner524a1312005-12-21 18:31:50 +00003244#line 1825 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner7aa61892005-12-21 17:53:23 +00003245{ // A vector zero constant.
3246 yyval.ValIDVal = ValID::createZeroInit();
3247 ;
3248 break;}
3249case 168:
Chris Lattner524a1312005-12-21 18:31:50 +00003250#line 1828 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003251{ // Nonempty unsized packed vector
Reid Spencer68a24bd2005-08-27 18:50:39 +00003252 const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
3253 int NumElements = yyvsp[-1].ConstVector->size();
3254
3255 PackedType* pt = PackedType::get(ETy, NumElements);
3256 PATypeHolder* PTy = new PATypeHolder(
3257 HandleUpRefs(
3258 PackedType::get(
3259 ETy,
3260 NumElements)
3261 )
3262 );
3263
3264 // Verify all elements are correct type!
3265 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3266 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
3267 ThrowException("Element #" + utostr(i) + " is not of type '" +
3268 ETy->getDescription() +"' as required!\nIt is of type '" +
3269 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
3270 }
3271
3272 yyval.ValIDVal = ValID::create(ConstantPacked::get(pt, *yyvsp[-1].ConstVector));
3273 delete PTy; delete yyvsp[-1].ConstVector;
Nate Begeman14b05292005-11-05 09:21:28 +00003274 ;
3275 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003276case 169:
Chris Lattner524a1312005-12-21 18:31:50 +00003277#line 1852 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003278{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003279 yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
Nate Begeman14b05292005-11-05 09:21:28 +00003280 ;
3281 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003282case 170:
Chris Lattner524a1312005-12-21 18:31:50 +00003283#line 1859 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003284{ // Is it an integer reference...?
Reid Spencer68a24bd2005-08-27 18:50:39 +00003285 yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal);
Nate Begeman14b05292005-11-05 09:21:28 +00003286 ;
3287 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003288case 171:
Chris Lattner524a1312005-12-21 18:31:50 +00003289#line 1862 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003290{ // Is it a named reference...?
Reid Spencer68a24bd2005-08-27 18:50:39 +00003291 yyval.ValIDVal = ValID::create(yyvsp[0].StrVal);
Nate Begeman14b05292005-11-05 09:21:28 +00003292 ;
3293 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003294case 174:
Chris Lattner524a1312005-12-21 18:31:50 +00003295#line 1873 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003296{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003297 yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); delete yyvsp[-1].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003298 ;
3299 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003300case 175:
Chris Lattner524a1312005-12-21 18:31:50 +00003301#line 1877 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003302{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003303 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003304 ;
3305 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003306case 176:
Chris Lattner524a1312005-12-21 18:31:50 +00003307#line 1880 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003308{ // Do not allow functions with 0 basic blocks
Reid Spencer68a24bd2005-08-27 18:50:39 +00003309 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003310 ;
3311 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003312case 177:
Chris Lattner524a1312005-12-21 18:31:50 +00003313#line 1888 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003314{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003315 setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
3316 InsertValue(yyvsp[0].TermInstVal);
3317
3318 yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
3319 InsertValue(yyvsp[-2].BasicBlockVal);
3320 yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003321 ;
3322 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003323case 178:
Chris Lattner524a1312005-12-21 18:31:50 +00003324#line 1897 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003325{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003326 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
3327 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003328 ;
3329 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003330case 179:
Chris Lattner524a1312005-12-21 18:31:50 +00003331#line 1901 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003332{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003333 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
3334
3335 // Make sure to move the basic block to the correct location in the
3336 // function, instead of leaving it inserted wherever it was first
3337 // referenced.
3338 Function::BasicBlockListType &BBL =
3339 CurFun.CurrentFunction->getBasicBlockList();
3340 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
Nate Begeman14b05292005-11-05 09:21:28 +00003341 ;
3342 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003343case 180:
Chris Lattner524a1312005-12-21 18:31:50 +00003344#line 1911 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003345{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003346 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create(yyvsp[0].StrVal), true);
3347
3348 // Make sure to move the basic block to the correct location in the
3349 // function, instead of leaving it inserted wherever it was first
3350 // referenced.
3351 Function::BasicBlockListType &BBL =
3352 CurFun.CurrentFunction->getBasicBlockList();
3353 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
Nate Begeman14b05292005-11-05 09:21:28 +00003354 ;
3355 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003356case 181:
Chris Lattner524a1312005-12-21 18:31:50 +00003357#line 1922 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003358{ // Return with a result...
Reid Spencer68a24bd2005-08-27 18:50:39 +00003359 yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
Nate Begeman14b05292005-11-05 09:21:28 +00003360 ;
3361 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003362case 182:
Chris Lattner524a1312005-12-21 18:31:50 +00003363#line 1925 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003364{ // Return with no result...
Reid Spencer68a24bd2005-08-27 18:50:39 +00003365 yyval.TermInstVal = new ReturnInst();
Nate Begeman14b05292005-11-05 09:21:28 +00003366 ;
3367 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003368case 183:
Chris Lattner524a1312005-12-21 18:31:50 +00003369#line 1928 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003370{ // Unconditional Branch...
Reid Spencer68a24bd2005-08-27 18:50:39 +00003371 yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[0].ValIDVal));
Nate Begeman14b05292005-11-05 09:21:28 +00003372 ;
3373 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003374case 184:
Chris Lattner524a1312005-12-21 18:31:50 +00003375#line 1931 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003376{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003377 yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[-3].ValIDVal), getBBVal(yyvsp[0].ValIDVal), getVal(Type::BoolTy, yyvsp[-6].ValIDVal));
Nate Begeman14b05292005-11-05 09:21:28 +00003378 ;
3379 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003380case 185:
Chris Lattner524a1312005-12-21 18:31:50 +00003381#line 1934 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003382{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003383 SwitchInst *S = new SwitchInst(getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal), getBBVal(yyvsp[-3].ValIDVal), yyvsp[-1].JumpTable->size());
3384 yyval.TermInstVal = S;
3385
3386 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
3387 E = yyvsp[-1].JumpTable->end();
3388 for (; I != E; ++I) {
3389 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
3390 S->addCase(CI, I->second);
3391 else
3392 ThrowException("Switch case is constant, but not a simple integer!");
3393 }
3394 delete yyvsp[-1].JumpTable;
Nate Begeman14b05292005-11-05 09:21:28 +00003395 ;
3396 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003397case 186:
Chris Lattner524a1312005-12-21 18:31:50 +00003398#line 1948 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003399{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003400 SwitchInst *S = new SwitchInst(getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal), getBBVal(yyvsp[-2].ValIDVal), 0);
3401 yyval.TermInstVal = S;
Nate Begeman14b05292005-11-05 09:21:28 +00003402 ;
3403 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003404case 187:
Chris Lattner524a1312005-12-21 18:31:50 +00003405#line 1953 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003406{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003407 const PointerType *PFTy;
3408 const FunctionType *Ty;
3409
3410 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-10].TypeVal->get())) ||
3411 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3412 // Pull out the types of all of the arguments...
3413 std::vector<const Type*> ParamTypes;
3414 if (yyvsp[-7].ValueList) {
3415 for (std::vector<Value*>::iterator I = yyvsp[-7].ValueList->begin(), E = yyvsp[-7].ValueList->end();
3416 I != E; ++I)
3417 ParamTypes.push_back((*I)->getType());
3418 }
3419
3420 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3421 if (isVarArg) ParamTypes.pop_back();
3422
3423 Ty = FunctionType::get(yyvsp[-10].TypeVal->get(), ParamTypes, isVarArg);
3424 PFTy = PointerType::get(Ty);
3425 }
3426
3427 Value *V = getVal(PFTy, yyvsp[-9].ValIDVal); // Get the function we're calling...
3428
3429 BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
3430 BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
3431
3432 // Create the call node...
3433 if (!yyvsp[-7].ValueList) { // Has no arguments?
3434 yyval.TermInstVal = new InvokeInst(V, Normal, Except, std::vector<Value*>());
3435 } else { // Has arguments?
3436 // Loop through FunctionType's arguments and ensure they are specified
3437 // correctly!
3438 //
3439 FunctionType::param_iterator I = Ty->param_begin();
3440 FunctionType::param_iterator E = Ty->param_end();
3441 std::vector<Value*>::iterator ArgI = yyvsp[-7].ValueList->begin(), ArgE = yyvsp[-7].ValueList->end();
3442
3443 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3444 if ((*ArgI)->getType() != *I)
3445 ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
3446 (*I)->getDescription() + "'!");
3447
3448 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
3449 ThrowException("Invalid number of parameters detected!");
3450
3451 yyval.TermInstVal = new InvokeInst(V, Normal, Except, *yyvsp[-7].ValueList);
3452 }
3453 cast<InvokeInst>(yyval.TermInstVal)->setCallingConv(yyvsp[-11].UIntVal);
3454
3455 delete yyvsp[-10].TypeVal;
3456 delete yyvsp[-7].ValueList;
Nate Begeman14b05292005-11-05 09:21:28 +00003457 ;
3458 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003459case 188:
Chris Lattner524a1312005-12-21 18:31:50 +00003460#line 2005 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003461{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003462 yyval.TermInstVal = new UnwindInst();
Nate Begeman14b05292005-11-05 09:21:28 +00003463 ;
3464 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003465case 189:
Chris Lattner524a1312005-12-21 18:31:50 +00003466#line 2008 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003467{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003468 yyval.TermInstVal = new UnreachableInst();
Nate Begeman14b05292005-11-05 09:21:28 +00003469 ;
3470 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003471case 190:
Chris Lattner524a1312005-12-21 18:31:50 +00003472#line 2014 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003473{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003474 yyval.JumpTable = yyvsp[-5].JumpTable;
3475 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
3476 if (V == 0)
3477 ThrowException("May only switch on a constant pool value!");
3478
3479 yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
Nate Begeman14b05292005-11-05 09:21:28 +00003480 ;
3481 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003482case 191:
Chris Lattner524a1312005-12-21 18:31:50 +00003483#line 2022 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003484{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003485 yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
3486 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
3487
3488 if (V == 0)
3489 ThrowException("May only switch on a constant pool value!");
3490
3491 yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
Nate Begeman14b05292005-11-05 09:21:28 +00003492 ;
3493 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003494case 192:
Chris Lattner524a1312005-12-21 18:31:50 +00003495#line 2032 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003496{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003497 // Is this definition named?? if so, assign the name...
3498 setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
3499 InsertValue(yyvsp[0].InstVal);
3500 yyval.InstVal = yyvsp[0].InstVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003501;
3502 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003503case 193:
Chris Lattner524a1312005-12-21 18:31:50 +00003504#line 2039 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003505{ // Used for PHI nodes
Reid Spencer68a24bd2005-08-27 18:50:39 +00003506 yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
3507 yyval.PHIList->push_back(std::make_pair(getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal), getBBVal(yyvsp[-1].ValIDVal)));
3508 delete yyvsp[-5].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003509 ;
3510 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003511case 194:
Chris Lattner524a1312005-12-21 18:31:50 +00003512#line 2044 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003513{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003514 yyval.PHIList = yyvsp[-6].PHIList;
3515 yyvsp[-6].PHIList->push_back(std::make_pair(getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal),
3516 getBBVal(yyvsp[-1].ValIDVal)));
Nate Begeman14b05292005-11-05 09:21:28 +00003517 ;
3518 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003519case 195:
Chris Lattner524a1312005-12-21 18:31:50 +00003520#line 2051 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003521{ // Used for call statements, and memory insts...
Reid Spencer68a24bd2005-08-27 18:50:39 +00003522 yyval.ValueList = new std::vector<Value*>();
3523 yyval.ValueList->push_back(yyvsp[0].ValueVal);
Nate Begeman14b05292005-11-05 09:21:28 +00003524 ;
3525 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003526case 196:
Chris Lattner524a1312005-12-21 18:31:50 +00003527#line 2055 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003528{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003529 yyval.ValueList = yyvsp[-2].ValueList;
3530 yyvsp[-2].ValueList->push_back(yyvsp[0].ValueVal);
Nate Begeman14b05292005-11-05 09:21:28 +00003531 ;
3532 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003533case 198:
Chris Lattner524a1312005-12-21 18:31:50 +00003534#line 2061 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003535{ yyval.ValueList = 0; ;
3536 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003537case 199:
Chris Lattner524a1312005-12-21 18:31:50 +00003538#line 2063 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003539{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003540 yyval.BoolVal = true;
Nate Begeman14b05292005-11-05 09:21:28 +00003541 ;
3542 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003543case 200:
Chris Lattner524a1312005-12-21 18:31:50 +00003544#line 2066 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003545{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003546 yyval.BoolVal = false;
Nate Begeman14b05292005-11-05 09:21:28 +00003547 ;
3548 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003549case 201:
Chris Lattner524a1312005-12-21 18:31:50 +00003550#line 2072 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003551{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003552 if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
3553 !isa<PackedType>((*yyvsp[-3].TypeVal).get()))
3554 ThrowException(
3555 "Arithmetic operator requires integer, FP, or packed operands!");
3556 if (isa<PackedType>((*yyvsp[-3].TypeVal).get()) && yyvsp[-4].BinaryOpVal == Instruction::Rem)
3557 ThrowException("Rem not supported on packed types!");
3558 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3559 if (yyval.InstVal == 0)
3560 ThrowException("binary operator returned null!");
3561 delete yyvsp[-3].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003562 ;
3563 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003564case 202:
Chris Lattner524a1312005-12-21 18:31:50 +00003565#line 2084 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003566{
Chris Lattner524a1312005-12-21 18:31:50 +00003567 if (!(*yyvsp[-3].TypeVal)->isIntegral()) {
3568 if (!isa<PackedType>(yyvsp[-3].TypeVal->get()) ||
3569 !cast<PackedType>(yyvsp[-3].TypeVal->get())->getElementType()->isIntegral())
3570 ThrowException("Logical operator requires integral operands!");
3571 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00003572 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3573 if (yyval.InstVal == 0)
3574 ThrowException("binary operator returned null!");
3575 delete yyvsp[-3].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003576 ;
3577 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003578case 203:
Chris Lattner524a1312005-12-21 18:31:50 +00003579#line 2095 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003580{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003581 if(isa<PackedType>((*yyvsp[-3].TypeVal).get())) {
3582 ThrowException(
3583 "PackedTypes currently not supported in setcc instructions!");
3584 }
3585 yyval.InstVal = new SetCondInst(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3586 if (yyval.InstVal == 0)
3587 ThrowException("binary operator returned null!");
3588 delete yyvsp[-3].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003589 ;
3590 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003591case 204:
Chris Lattner524a1312005-12-21 18:31:50 +00003592#line 2105 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003593{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003594 std::cerr << "WARNING: Use of eliminated 'not' instruction:"
3595 << " Replacing with 'xor'.\n";
3596
3597 Value *Ones = ConstantIntegral::getAllOnesValue(yyvsp[0].ValueVal->getType());
3598 if (Ones == 0)
3599 ThrowException("Expected integral type for not instruction!");
3600
3601 yyval.InstVal = BinaryOperator::create(Instruction::Xor, yyvsp[0].ValueVal, Ones);
3602 if (yyval.InstVal == 0)
3603 ThrowException("Could not create a xor instruction!");
Nate Begeman14b05292005-11-05 09:21:28 +00003604 ;
3605 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003606case 205:
Chris Lattner524a1312005-12-21 18:31:50 +00003607#line 2117 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003608{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003609 if (yyvsp[0].ValueVal->getType() != Type::UByteTy)
3610 ThrowException("Shift amount must be ubyte!");
3611 if (!yyvsp[-2].ValueVal->getType()->isInteger())
3612 ThrowException("Shift constant expression requires integer operand!");
3613 yyval.InstVal = new ShiftInst(yyvsp[-3].OtherOpVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Nate Begeman14b05292005-11-05 09:21:28 +00003614 ;
3615 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003616case 206:
Chris Lattner524a1312005-12-21 18:31:50 +00003617#line 2124 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003618{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003619 if (!yyvsp[0].TypeVal->get()->isFirstClassType())
3620 ThrowException("cast instruction to a non-primitive type: '" +
3621 yyvsp[0].TypeVal->get()->getDescription() + "'!");
3622 yyval.InstVal = new CastInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
3623 delete yyvsp[0].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003624 ;
3625 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003626case 207:
Chris Lattner524a1312005-12-21 18:31:50 +00003627#line 2131 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003628{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003629 if (yyvsp[-4].ValueVal->getType() != Type::BoolTy)
3630 ThrowException("select condition must be boolean!");
3631 if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
3632 ThrowException("select value types should match!");
3633 yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Nate Begeman14b05292005-11-05 09:21:28 +00003634 ;
3635 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003636case 208:
Chris Lattner524a1312005-12-21 18:31:50 +00003637#line 2138 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003638{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003639 NewVarArgs = true;
3640 yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
3641 delete yyvsp[0].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003642 ;
3643 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003644case 209:
Chris Lattner524a1312005-12-21 18:31:50 +00003645#line 2143 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003646{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003647 ObsoleteVarArgs = true;
3648 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
3649 Function* NF = CurModule.CurrentModule->
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003650 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003651
3652 //b = vaarg a, t ->
3653 //foo = alloca 1 of t
3654 //bar = vacopy a
3655 //store bar -> foo
3656 //b = vaarg foo, t
3657 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
3658 CurBB->getInstList().push_back(foo);
3659 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
3660 CurBB->getInstList().push_back(bar);
3661 CurBB->getInstList().push_back(new StoreInst(bar, foo));
3662 yyval.InstVal = new VAArgInst(foo, *yyvsp[0].TypeVal);
3663 delete yyvsp[0].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003664 ;
3665 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003666case 210:
Chris Lattner524a1312005-12-21 18:31:50 +00003667#line 2162 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003668{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003669 ObsoleteVarArgs = true;
3670 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
3671 Function* NF = CurModule.CurrentModule->
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003672 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003673
3674 //b = vanext a, t ->
3675 //foo = alloca 1 of t
3676 //bar = vacopy a
3677 //store bar -> foo
3678 //tmp = vaarg foo, t
3679 //b = load foo
3680 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
3681 CurBB->getInstList().push_back(foo);
3682 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
3683 CurBB->getInstList().push_back(bar);
3684 CurBB->getInstList().push_back(new StoreInst(bar, foo));
3685 Instruction* tmp = new VAArgInst(foo, *yyvsp[0].TypeVal);
3686 CurBB->getInstList().push_back(tmp);
3687 yyval.InstVal = new LoadInst(foo);
3688 delete yyvsp[0].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003689 ;
3690 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003691case 211:
Chris Lattner524a1312005-12-21 18:31:50 +00003692#line 2184 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003693{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003694 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
3695 if (!Ty->isFirstClassType())
3696 ThrowException("PHI node operands must be of first class type!");
3697 yyval.InstVal = new PHINode(Ty);
3698 ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
3699 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
3700 if (yyvsp[0].PHIList->front().first->getType() != Ty)
3701 ThrowException("All elements of a PHI node must be of the same type!");
3702 cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
3703 yyvsp[0].PHIList->pop_front();
3704 }
3705 delete yyvsp[0].PHIList; // Free the list...
Nate Begeman14b05292005-11-05 09:21:28 +00003706 ;
3707 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003708case 212:
Chris Lattner524a1312005-12-21 18:31:50 +00003709#line 2198 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003710{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003711 const PointerType *PFTy;
3712 const FunctionType *Ty;
3713
3714 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-4].TypeVal->get())) ||
3715 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3716 // Pull out the types of all of the arguments...
3717 std::vector<const Type*> ParamTypes;
3718 if (yyvsp[-1].ValueList) {
3719 for (std::vector<Value*>::iterator I = yyvsp[-1].ValueList->begin(), E = yyvsp[-1].ValueList->end();
3720 I != E; ++I)
3721 ParamTypes.push_back((*I)->getType());
3722 }
3723
3724 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3725 if (isVarArg) ParamTypes.pop_back();
3726
3727 if (!(*yyvsp[-4].TypeVal)->isFirstClassType() && *yyvsp[-4].TypeVal != Type::VoidTy)
3728 ThrowException("LLVM functions cannot return aggregate types!");
3729
3730 Ty = FunctionType::get(yyvsp[-4].TypeVal->get(), ParamTypes, isVarArg);
3731 PFTy = PointerType::get(Ty);
3732 }
3733
3734 Value *V = getVal(PFTy, yyvsp[-3].ValIDVal); // Get the function we're calling...
3735
3736 // Create the call node...
3737 if (!yyvsp[-1].ValueList) { // Has no arguments?
3738 // Make sure no arguments is a good thing!
3739 if (Ty->getNumParams() != 0)
3740 ThrowException("No arguments passed to a function that "
3741 "expects arguments!");
3742
3743 yyval.InstVal = new CallInst(V, std::vector<Value*>());
3744 } else { // Has arguments?
3745 // Loop through FunctionType's arguments and ensure they are specified
3746 // correctly!
3747 //
3748 FunctionType::param_iterator I = Ty->param_begin();
3749 FunctionType::param_iterator E = Ty->param_end();
3750 std::vector<Value*>::iterator ArgI = yyvsp[-1].ValueList->begin(), ArgE = yyvsp[-1].ValueList->end();
3751
3752 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3753 if ((*ArgI)->getType() != *I)
3754 ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
3755 (*I)->getDescription() + "'!");
3756
3757 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
3758 ThrowException("Invalid number of parameters detected!");
3759
3760 yyval.InstVal = new CallInst(V, *yyvsp[-1].ValueList);
3761 }
3762 cast<CallInst>(yyval.InstVal)->setTailCall(yyvsp[-6].BoolVal);
3763 cast<CallInst>(yyval.InstVal)->setCallingConv(yyvsp[-5].UIntVal);
3764 delete yyvsp[-4].TypeVal;
3765 delete yyvsp[-1].ValueList;
Nate Begeman14b05292005-11-05 09:21:28 +00003766 ;
3767 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003768case 213:
Chris Lattner524a1312005-12-21 18:31:50 +00003769#line 2255 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003770{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003771 yyval.InstVal = yyvsp[0].InstVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003772 ;
3773 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003774case 214:
Chris Lattner524a1312005-12-21 18:31:50 +00003775#line 2261 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003776{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003777 yyval.ValueList = yyvsp[0].ValueList;
Nate Begeman14b05292005-11-05 09:21:28 +00003778 ;
3779 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003780case 215:
Chris Lattner524a1312005-12-21 18:31:50 +00003781#line 2263 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003782{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003783 yyval.ValueList = new std::vector<Value*>();
Nate Begeman14b05292005-11-05 09:21:28 +00003784 ;
3785 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003786case 216:
Chris Lattner524a1312005-12-21 18:31:50 +00003787#line 2267 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003788{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003789 yyval.BoolVal = true;
Nate Begeman14b05292005-11-05 09:21:28 +00003790 ;
3791 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003792case 217:
Chris Lattner524a1312005-12-21 18:31:50 +00003793#line 2270 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003794{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003795 yyval.BoolVal = false;
Nate Begeman14b05292005-11-05 09:21:28 +00003796 ;
3797 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003798case 218:
Chris Lattner524a1312005-12-21 18:31:50 +00003799#line 2276 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003800{
Chris Lattner7d09ab62005-11-06 06:34:34 +00003801 yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
3802 delete yyvsp[-1].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003803 ;
3804 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003805case 219:
Chris Lattner524a1312005-12-21 18:31:50 +00003806#line 2280 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003807{
Chris Lattner7d09ab62005-11-06 06:34:34 +00003808 yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal);
3809 delete yyvsp[-4].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003810 ;
3811 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003812case 220:
Chris Lattner524a1312005-12-21 18:31:50 +00003813#line 2284 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003814{
Chris Lattner7d09ab62005-11-06 06:34:34 +00003815 yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
3816 delete yyvsp[-1].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003817 ;
3818 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003819case 221:
Chris Lattner524a1312005-12-21 18:31:50 +00003820#line 2288 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003821{
Chris Lattner7d09ab62005-11-06 06:34:34 +00003822 yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal);
3823 delete yyvsp[-4].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003824 ;
3825 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003826case 222:
Chris Lattner524a1312005-12-21 18:31:50 +00003827#line 2292 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003828{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003829 if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
3830 ThrowException("Trying to free nonpointer type " +
3831 yyvsp[0].ValueVal->getType()->getDescription() + "!");
3832 yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
Nate Begeman14b05292005-11-05 09:21:28 +00003833 ;
3834 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003835case 223:
Chris Lattner524a1312005-12-21 18:31:50 +00003836#line 2299 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003837{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003838 if (!isa<PointerType>(yyvsp[-1].TypeVal->get()))
3839 ThrowException("Can't load from nonpointer type: " +
3840 (*yyvsp[-1].TypeVal)->getDescription());
3841 if (!cast<PointerType>(yyvsp[-1].TypeVal->get())->getElementType()->isFirstClassType())
3842 ThrowException("Can't load from pointer of non-first-class type: " +
3843 (*yyvsp[-1].TypeVal)->getDescription());
3844 yyval.InstVal = new LoadInst(getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), "", yyvsp[-3].BoolVal);
3845 delete yyvsp[-1].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003846 ;
3847 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003848case 224:
Chris Lattner524a1312005-12-21 18:31:50 +00003849#line 2309 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003850{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003851 const PointerType *PT = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
3852 if (!PT)
3853 ThrowException("Can't store to a nonpointer type: " +
3854 (*yyvsp[-1].TypeVal)->getDescription());
3855 const Type *ElTy = PT->getElementType();
3856 if (ElTy != yyvsp[-3].ValueVal->getType())
3857 ThrowException("Can't store '" + yyvsp[-3].ValueVal->getType()->getDescription() +
3858 "' into space of type '" + ElTy->getDescription() + "'!");
3859
3860 yyval.InstVal = new StoreInst(yyvsp[-3].ValueVal, getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), yyvsp[-5].BoolVal);
3861 delete yyvsp[-1].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003862 ;
3863 break;}
Chris Lattner7aa61892005-12-21 17:53:23 +00003864case 225:
Chris Lattner524a1312005-12-21 18:31:50 +00003865#line 2322 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003866{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003867 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
3868 ThrowException("getelementptr insn requires pointer operand!");
3869
3870 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
3871 // indices to uint struct indices for compatibility.
3872 generic_gep_type_iterator<std::vector<Value*>::iterator>
3873 GTI = gep_type_begin(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end()),
3874 GTE = gep_type_end(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end());
3875 for (unsigned i = 0, e = yyvsp[0].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
3876 if (isa<StructType>(*GTI)) // Only change struct indices
3877 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[0].ValueList)[i]))
3878 if (CUI->getType() == Type::UByteTy)
3879 (*yyvsp[0].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
3880
3881 if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, *yyvsp[0].ValueList, true))
3882 ThrowException("Invalid getelementptr indices for type '" +
3883 (*yyvsp[-2].TypeVal)->getDescription()+ "'!");
3884 yyval.InstVal = new GetElementPtrInst(getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal), *yyvsp[0].ValueList);
3885 delete yyvsp[-2].TypeVal; delete yyvsp[0].ValueList;
Nate Begeman14b05292005-11-05 09:21:28 +00003886 ;
3887 break;}
3888}
3889 /* the action file gets copied in in place of this dollarsign */
3890#line 543 "/usr/share/bison.simple"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003891
3892 yyvsp -= yylen;
3893 yyssp -= yylen;
Nate Begeman14b05292005-11-05 09:21:28 +00003894#ifdef YYLSP_NEEDED
3895 yylsp -= yylen;
3896#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00003897
Nate Begeman14b05292005-11-05 09:21:28 +00003898#if YYDEBUG != 0
3899 if (yydebug)
3900 {
3901 short *ssp1 = yyss - 1;
3902 fprintf (stderr, "state stack now");
3903 while (ssp1 != yyssp)
3904 fprintf (stderr, " %d", *++ssp1);
3905 fprintf (stderr, "\n");
3906 }
3907#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00003908
3909 *++yyvsp = yyval;
3910
Nate Begeman14b05292005-11-05 09:21:28 +00003911#ifdef YYLSP_NEEDED
3912 yylsp++;
3913 if (yylen == 0)
3914 {
3915 yylsp->first_line = yylloc.first_line;
3916 yylsp->first_column = yylloc.first_column;
3917 yylsp->last_line = (yylsp-1)->last_line;
3918 yylsp->last_column = (yylsp-1)->last_column;
3919 yylsp->text = 0;
3920 }
3921 else
3922 {
3923 yylsp->last_line = (yylsp+yylen-1)->last_line;
3924 yylsp->last_column = (yylsp+yylen-1)->last_column;
3925 }
3926#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00003927
Nate Begeman14b05292005-11-05 09:21:28 +00003928 /* Now "shift" the result of the reduction.
3929 Determine what state that goes to,
3930 based on the state we popped back to
3931 and the rule number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003932
3933 yyn = yyr1[yyn];
3934
Nate Begeman14b05292005-11-05 09:21:28 +00003935 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
3936 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003937 yystate = yytable[yystate];
3938 else
Nate Begeman14b05292005-11-05 09:21:28 +00003939 yystate = yydefgoto[yyn - YYNTBASE];
Reid Spencer68a24bd2005-08-27 18:50:39 +00003940
3941 goto yynewstate;
3942
Nate Begeman14b05292005-11-05 09:21:28 +00003943yyerrlab: /* here on detecting error */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003944
Nate Begeman14b05292005-11-05 09:21:28 +00003945 if (! yyerrstatus)
3946 /* If not already recovering from an error, report this error. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003947 {
3948 ++yynerrs;
Nate Begeman14b05292005-11-05 09:21:28 +00003949
3950#ifdef YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00003951 yyn = yypact[yystate];
3952
Nate Begeman14b05292005-11-05 09:21:28 +00003953 if (yyn > YYFLAG && yyn < YYLAST)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003954 {
Nate Begeman14b05292005-11-05 09:21:28 +00003955 int size = 0;
3956 char *msg;
3957 int x, count;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003958
Nate Begeman14b05292005-11-05 09:21:28 +00003959 count = 0;
3960 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
3961 for (x = (yyn < 0 ? -yyn : 0);
3962 x < (sizeof(yytname) / sizeof(char *)); x++)
3963 if (yycheck[x + yyn] == x)
3964 size += strlen(yytname[x]) + 15, count++;
3965 msg = (char *) malloc(size + 15);
3966 if (msg != 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003967 {
Nate Begeman14b05292005-11-05 09:21:28 +00003968 strcpy(msg, "parse error");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003969
Nate Begeman14b05292005-11-05 09:21:28 +00003970 if (count < 5)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003971 {
Nate Begeman14b05292005-11-05 09:21:28 +00003972 count = 0;
3973 for (x = (yyn < 0 ? -yyn : 0);
3974 x < (sizeof(yytname) / sizeof(char *)); x++)
3975 if (yycheck[x + yyn] == x)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003976 {
Nate Begeman14b05292005-11-05 09:21:28 +00003977 strcat(msg, count == 0 ? ", expecting `" : " or `");
3978 strcat(msg, yytname[x]);
3979 strcat(msg, "'");
3980 count++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003981 }
3982 }
Nate Begeman14b05292005-11-05 09:21:28 +00003983 yyerror(msg);
3984 free(msg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003985 }
3986 else
Nate Begeman14b05292005-11-05 09:21:28 +00003987 yyerror ("parse error; also virtual memory exceeded");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003988 }
3989 else
3990#endif /* YYERROR_VERBOSE */
Nate Begeman14b05292005-11-05 09:21:28 +00003991 yyerror("parse error");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003992 }
3993
Nate Begeman14b05292005-11-05 09:21:28 +00003994 goto yyerrlab1;
3995yyerrlab1: /* here on error raised explicitly by an action */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003996
3997 if (yyerrstatus == 3)
3998 {
Nate Begeman14b05292005-11-05 09:21:28 +00003999 /* if just tried and failed to reuse lookahead token after an error, discard it. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004000
Nate Begeman14b05292005-11-05 09:21:28 +00004001 /* return failure if at end of input */
4002 if (yychar == YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004003 YYABORT;
4004
Nate Begeman14b05292005-11-05 09:21:28 +00004005#if YYDEBUG != 0
4006 if (yydebug)
4007 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
4008#endif
4009
4010 yychar = YYEMPTY;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004011 }
4012
Nate Begeman14b05292005-11-05 09:21:28 +00004013 /* Else will try to reuse lookahead token
4014 after shifting the error token. */
4015
4016 yyerrstatus = 3; /* Each real token shifted decrements this */
4017
4018 goto yyerrhandle;
4019
4020yyerrdefault: /* current state does not do anything special for the error token. */
4021
4022#if 0
4023 /* This is wrong; only states that explicitly want error tokens
4024 should shift them. */
4025 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
4026 if (yyn) goto yydefault;
4027#endif
4028
4029yyerrpop: /* pop the current state because it cannot handle the error token */
4030
4031 if (yyssp == yyss) YYABORT;
4032 yyvsp--;
4033 yystate = *--yyssp;
4034#ifdef YYLSP_NEEDED
4035 yylsp--;
4036#endif
4037
4038#if YYDEBUG != 0
4039 if (yydebug)
4040 {
4041 short *ssp1 = yyss - 1;
4042 fprintf (stderr, "Error: state stack now");
4043 while (ssp1 != yyssp)
4044 fprintf (stderr, " %d", *++ssp1);
4045 fprintf (stderr, "\n");
4046 }
4047#endif
4048
4049yyerrhandle:
4050
4051 yyn = yypact[yystate];
4052 if (yyn == YYFLAG)
4053 goto yyerrdefault;
4054
4055 yyn += YYTERROR;
4056 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
4057 goto yyerrdefault;
4058
4059 yyn = yytable[yyn];
4060 if (yyn < 0)
4061 {
4062 if (yyn == YYFLAG)
4063 goto yyerrpop;
4064 yyn = -yyn;
4065 goto yyreduce;
4066 }
4067 else if (yyn == 0)
4068 goto yyerrpop;
4069
Reid Spencer68a24bd2005-08-27 18:50:39 +00004070 if (yyn == YYFINAL)
4071 YYACCEPT;
4072
Nate Begeman14b05292005-11-05 09:21:28 +00004073#if YYDEBUG != 0
4074 if (yydebug)
4075 fprintf(stderr, "Shifting error token, ");
4076#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00004077
4078 *++yyvsp = yylval;
Nate Begeman14b05292005-11-05 09:21:28 +00004079#ifdef YYLSP_NEEDED
4080 *++yylsp = yylloc;
4081#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00004082
4083 yystate = yyn;
4084 goto yynewstate;
4085
Nate Begeman14b05292005-11-05 09:21:28 +00004086 yyacceptlab:
4087 /* YYACCEPT comes here. */
4088 if (yyfree_stacks)
4089 {
4090 free (yyss);
4091 free (yyvs);
4092#ifdef YYLSP_NEEDED
4093 free (yyls);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004094#endif
Nate Begeman14b05292005-11-05 09:21:28 +00004095 }
4096 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004097
Nate Begeman14b05292005-11-05 09:21:28 +00004098 yyabortlab:
4099 /* YYABORT comes here. */
4100 if (yyfree_stacks)
4101 {
4102 free (yyss);
4103 free (yyvs);
4104#ifdef YYLSP_NEEDED
4105 free (yyls);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004106#endif
Nate Begeman14b05292005-11-05 09:21:28 +00004107 }
4108 return 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004109}
Chris Lattner524a1312005-12-21 18:31:50 +00004110#line 2345 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00004111
4112int yyerror(const char *ErrorMsg) {
4113 std::string where
4114 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
4115 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
4116 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
4117 if (yychar == YYEMPTY || yychar == 0)
4118 errMsg += "end-of-file.";
4119 else
4120 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
4121 ThrowException(errMsg);
4122 return 0;
4123}