blob: 4439a2077ddff26ae8e9baa9a3d604cf78cd0c27 [file] [log] [blame]
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001
Chris Lattnerb467a4f2005-11-05 21:54:23 +00002/* A Bison parser, made from /Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y
Nate Begeman848622f2005-11-05 09:21:28 +00003 by GNU Bison version 1.28 */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004
Nate Begeman848622f2005-11-05 09:21:28 +00005#define YYBISON 1 /* Identify Bison output. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00006
Reid Spencerdfb3fb42005-08-27 18:50:39 +00007#define yyparse llvmAsmparse
Nate Begeman848622f2005-11-05 09:21:28 +00008#define yylex llvmAsmlex
Reid Spencerdfb3fb42005-08-27 18:50:39 +00009#define yyerror llvmAsmerror
Nate Begeman848622f2005-11-05 09:21:28 +000010#define yylval llvmAsmlval
11#define yychar llvmAsmchar
Reid Spencerdfb3fb42005-08-27 18:50:39 +000012#define yydebug llvmAsmdebug
13#define yynerrs llvmAsmnerrs
Nate Begeman848622f2005-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
45#define VOLATILE 288
46#define TO 289
47#define DOTDOTDOT 290
48#define NULL_TOK 291
49#define UNDEF 292
50#define CONST 293
51#define INTERNAL 294
52#define LINKONCE 295
53#define WEAK 296
54#define APPENDING 297
55#define OPAQUE 298
56#define NOT 299
57#define EXTERNAL 300
58#define TARGET 301
59#define TRIPLE 302
60#define ENDIAN 303
61#define POINTERSIZE 304
62#define LITTLE 305
63#define BIG 306
64#define ALIGN 307
65#define DEPLIBS 308
66#define CALL 309
67#define TAIL 310
68#define CC_TOK 311
69#define CCC_TOK 312
70#define FASTCC_TOK 313
71#define COLDCC_TOK 314
72#define RET 315
73#define BR 316
74#define SWITCH 317
75#define INVOKE 318
76#define UNWIND 319
77#define UNREACHABLE 320
78#define ADD 321
79#define SUB 322
80#define MUL 323
81#define DIV 324
82#define REM 325
83#define AND 326
84#define OR 327
85#define XOR 328
86#define SETLE 329
87#define SETGE 330
88#define SETLT 331
89#define SETGT 332
90#define SETEQ 333
91#define SETNE 334
92#define MALLOC 335
93#define ALLOCA 336
94#define FREE 337
95#define LOAD 338
96#define STORE 339
97#define GETELEMENTPTR 340
98#define PHI_TOK 341
99#define CAST 342
100#define SELECT 343
101#define SHL 344
102#define SHR 345
103#define VAARG 346
104#define VAARG_old 347
105#define VANEXT_old 348
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000106
Chris Lattnerb467a4f2005-11-05 21:54:23 +0000107#line 14 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000108
109#include "ParserInternals.h"
110#include "llvm/CallingConv.h"
111#include "llvm/Instructions.h"
112#include "llvm/Module.h"
113#include "llvm/SymbolTable.h"
114#include "llvm/Support/GetElementPtrTypeIterator.h"
115#include "llvm/ADT/STLExtras.h"
Chris Lattner840f7892005-11-06 06:46:53 +0000116#include "llvm/Support/MathExtras.h"
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000117#include <algorithm>
118#include <iostream>
119#include <list>
120#include <utility>
121
122int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
123int yylex(); // declaration" of xxx warnings.
124int yyparse();
125
126namespace llvm {
127 std::string CurFilename;
128}
129using namespace llvm;
130
131static Module *ParserResult;
132
133// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
134// relating to upreferences in the input stream.
135//
136//#define DEBUG_UPREFS 1
137#ifdef DEBUG_UPREFS
138#define UR_OUT(X) std::cerr << X
139#else
140#define UR_OUT(X)
141#endif
142
143#define YYERROR_VERBOSE 1
144
145static bool ObsoleteVarArgs;
146static bool NewVarArgs;
147static BasicBlock* CurBB;
148
149
150// This contains info used when building the body of a function. It is
151// destroyed when the function is completed.
152//
153typedef std::vector<Value *> ValueList; // Numbered defs
154static void
155ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
156 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
157
158static struct PerModuleInfo {
159 Module *CurrentModule;
160 std::map<const Type *, ValueList> Values; // Module level numbered definitions
161 std::map<const Type *,ValueList> LateResolveValues;
162 std::vector<PATypeHolder> Types;
163 std::map<ValID, PATypeHolder> LateResolveTypes;
164
165 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
166 /// how they were referenced and one which line of the input they came from so
167 /// that we can resolve them later and print error messages as appropriate.
168 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
169
170 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
171 // references to global values. Global values may be referenced before they
172 // are defined, and if so, the temporary object that they represent is held
173 // here. This is used for forward references of GlobalValues.
174 //
175 typedef std::map<std::pair<const PointerType *,
176 ValID>, GlobalValue*> GlobalRefsType;
177 GlobalRefsType GlobalRefs;
178
179 void ModuleDone() {
180 // If we could not resolve some functions at function compilation time
181 // (calls to functions before they are defined), resolve them now... Types
182 // are resolved when the constant pool has been completely parsed.
183 //
184 ResolveDefinitions(LateResolveValues);
185
186 // Check to make sure that all global value forward references have been
187 // resolved!
188 //
189 if (!GlobalRefs.empty()) {
190 std::string UndefinedReferences = "Unresolved global references exist:\n";
191
192 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
193 I != E; ++I) {
194 UndefinedReferences += " " + I->first.first->getDescription() + " " +
195 I->first.second.getName() + "\n";
196 }
197 ThrowException(UndefinedReferences);
198 }
199
200 Values.clear(); // Clear out function local definitions
201 Types.clear();
202 CurrentModule = 0;
203 }
204
205
206 // GetForwardRefForGlobal - Check to see if there is a forward reference
207 // for this global. If so, remove it from the GlobalRefs map and return it.
208 // If not, just return null.
209 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
210 // Check to see if there is a forward reference to this global variable...
211 // if there is, eliminate it and patch the reference to use the new def'n.
212 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
213 GlobalValue *Ret = 0;
214 if (I != GlobalRefs.end()) {
215 Ret = I->second;
216 GlobalRefs.erase(I);
217 }
218 return Ret;
219 }
220} CurModule;
221
222static struct PerFunctionInfo {
223 Function *CurrentFunction; // Pointer to current function being created
224
225 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
226 std::map<const Type*, ValueList> LateResolveValues;
227 bool isDeclare; // Is this function a forward declararation?
228
229 /// BBForwardRefs - When we see forward references to basic blocks, keep
230 /// track of them here.
231 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
232 std::vector<BasicBlock*> NumberedBlocks;
233 unsigned NextBBNum;
234
235 inline PerFunctionInfo() {
236 CurrentFunction = 0;
237 isDeclare = false;
238 }
239
240 inline void FunctionStart(Function *M) {
241 CurrentFunction = M;
242 NextBBNum = 0;
243 }
244
245 void FunctionDone() {
246 NumberedBlocks.clear();
247
248 // Any forward referenced blocks left?
249 if (!BBForwardRefs.empty())
250 ThrowException("Undefined reference to label " +
251 BBForwardRefs.begin()->first->getName());
252
253 // Resolve all forward references now.
254 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
255
256 Values.clear(); // Clear out function local definitions
257 CurrentFunction = 0;
258 isDeclare = false;
259 }
260} CurFun; // Info for the current function...
261
262static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
263
264
265//===----------------------------------------------------------------------===//
266// Code to handle definitions of all the types
267//===----------------------------------------------------------------------===//
268
269static int InsertValue(Value *V,
270 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
271 if (V->hasName()) return -1; // Is this a numbered definition?
272
273 // Yes, insert the value into the value table...
274 ValueList &List = ValueTab[V->getType()];
275 List.push_back(V);
276 return List.size()-1;
277}
278
279static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
280 switch (D.Type) {
281 case ValID::NumberVal: // Is it a numbered definition?
282 // Module constants occupy the lowest numbered slots...
283 if ((unsigned)D.Num < CurModule.Types.size())
284 return CurModule.Types[(unsigned)D.Num];
285 break;
286 case ValID::NameVal: // Is it a named definition?
287 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
288 D.destroy(); // Free old strdup'd memory...
289 return N;
290 }
291 break;
292 default:
293 ThrowException("Internal parser error: Invalid symbol type reference!");
294 }
295
296 // If we reached here, we referenced either a symbol that we don't know about
297 // or an id number that hasn't been read yet. We may be referencing something
298 // forward, so just create an entry to be resolved later and get to it...
299 //
300 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
301
302
303 if (inFunctionScope()) {
304 if (D.Type == ValID::NameVal)
305 ThrowException("Reference to an undefined type: '" + D.getName() + "'");
306 else
307 ThrowException("Reference to an undefined type: #" + itostr(D.Num));
308 }
309
310 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
311 if (I != CurModule.LateResolveTypes.end())
312 return I->second;
313
314 Type *Typ = OpaqueType::get();
315 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
316 return Typ;
317 }
318
319static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
320 SymbolTable &SymTab =
321 inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() :
322 CurModule.CurrentModule->getSymbolTable();
323 return SymTab.lookup(Ty, Name);
324}
325
326// getValNonImprovising - Look up the value specified by the provided type and
327// the provided ValID. If the value exists and has already been defined, return
328// it. Otherwise return null.
329//
330static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
331 if (isa<FunctionType>(Ty))
332 ThrowException("Functions are not values and "
333 "must be referenced as pointers");
334
335 switch (D.Type) {
336 case ValID::NumberVal: { // Is it a numbered definition?
337 unsigned Num = (unsigned)D.Num;
338
339 // Module constants occupy the lowest numbered slots...
340 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
341 if (VI != CurModule.Values.end()) {
342 if (Num < VI->second.size())
343 return VI->second[Num];
344 Num -= VI->second.size();
345 }
346
347 // Make sure that our type is within bounds
348 VI = CurFun.Values.find(Ty);
349 if (VI == CurFun.Values.end()) return 0;
350
351 // Check that the number is within bounds...
352 if (VI->second.size() <= Num) return 0;
353
354 return VI->second[Num];
355 }
356
357 case ValID::NameVal: { // Is it a named definition?
358 Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
359 if (N == 0) return 0;
360
361 D.destroy(); // Free old strdup'd memory...
362 return N;
363 }
364
365 // Check to make sure that "Ty" is an integral type, and that our
366 // value will fit into the specified type...
367 case ValID::ConstSIntVal: // Is it a constant pool reference??
368 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64))
369 ThrowException("Signed integral constant '" +
370 itostr(D.ConstPool64) + "' is invalid for type '" +
371 Ty->getDescription() + "'!");
372 return ConstantSInt::get(Ty, D.ConstPool64);
373
374 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
375 if (!ConstantUInt::isValueValidForType(Ty, D.UConstPool64)) {
376 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) {
377 ThrowException("Integral constant '" + utostr(D.UConstPool64) +
378 "' is invalid or out of range!");
379 } else { // This is really a signed reference. Transmogrify.
380 return ConstantSInt::get(Ty, D.ConstPool64);
381 }
382 } else {
383 return ConstantUInt::get(Ty, D.UConstPool64);
384 }
385
386 case ValID::ConstFPVal: // Is it a floating point const pool reference?
387 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
388 ThrowException("FP constant invalid for type!!");
389 return ConstantFP::get(Ty, D.ConstPoolFP);
390
391 case ValID::ConstNullVal: // Is it a null value?
392 if (!isa<PointerType>(Ty))
393 ThrowException("Cannot create a a non pointer null!");
394 return ConstantPointerNull::get(cast<PointerType>(Ty));
395
396 case ValID::ConstUndefVal: // Is it an undef value?
397 return UndefValue::get(Ty);
398
399 case ValID::ConstantVal: // Fully resolved constant?
400 if (D.ConstantValue->getType() != Ty)
401 ThrowException("Constant expression type different from required type!");
402 return D.ConstantValue;
403
404 default:
405 assert(0 && "Unhandled case!");
406 return 0;
407 } // End of switch
408
409 assert(0 && "Unhandled case!");
410 return 0;
411}
412
413// getVal - This function is identical to getValNonImprovising, except that if a
414// value is not already defined, it "improvises" by creating a placeholder var
415// that looks and acts just like the requested variable. When the value is
416// defined later, all uses of the placeholder variable are replaced with the
417// real thing.
418//
419static Value *getVal(const Type *Ty, const ValID &ID) {
420 if (Ty == Type::LabelTy)
421 ThrowException("Cannot use a basic block here");
422
423 // See if the value has already been defined.
424 Value *V = getValNonImprovising(Ty, ID);
425 if (V) return V;
426
427 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
428 ThrowException("Invalid use of a composite type!");
429
430 // If we reached here, we referenced either a symbol that we don't know about
431 // or an id number that hasn't been read yet. We may be referencing something
432 // forward, so just create an entry to be resolved later and get to it...
433 //
434 V = new Argument(Ty);
435
436 // Remember where this forward reference came from. FIXME, shouldn't we try
437 // to recycle these things??
438 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
439 llvmAsmlineno)));
440
441 if (inFunctionScope())
442 InsertValue(V, CurFun.LateResolveValues);
443 else
444 InsertValue(V, CurModule.LateResolveValues);
445 return V;
446}
447
448/// getBBVal - This is used for two purposes:
449/// * If isDefinition is true, a new basic block with the specified ID is being
450/// defined.
451/// * If isDefinition is true, this is a reference to a basic block, which may
452/// or may not be a forward reference.
453///
454static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
455 assert(inFunctionScope() && "Can't get basic block at global scope!");
456
457 std::string Name;
458 BasicBlock *BB = 0;
459 switch (ID.Type) {
460 default: ThrowException("Illegal label reference " + ID.getName());
461 case ValID::NumberVal: // Is it a numbered definition?
462 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
463 CurFun.NumberedBlocks.resize(ID.Num+1);
464 BB = CurFun.NumberedBlocks[ID.Num];
465 break;
466 case ValID::NameVal: // Is it a named definition?
467 Name = ID.Name;
468 if (Value *N = CurFun.CurrentFunction->
469 getSymbolTable().lookup(Type::LabelTy, Name))
470 BB = cast<BasicBlock>(N);
471 break;
472 }
473
474 // See if the block has already been defined.
475 if (BB) {
476 // If this is the definition of the block, make sure the existing value was
477 // just a forward reference. If it was a forward reference, there will be
478 // an entry for it in the PlaceHolderInfo map.
479 if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
480 // The existing value was a definition, not a forward reference.
481 ThrowException("Redefinition of label " + ID.getName());
482
483 ID.destroy(); // Free strdup'd memory.
484 return BB;
485 }
486
487 // Otherwise this block has not been seen before.
488 BB = new BasicBlock("", CurFun.CurrentFunction);
489 if (ID.Type == ValID::NameVal) {
490 BB->setName(ID.Name);
491 } else {
492 CurFun.NumberedBlocks[ID.Num] = BB;
493 }
494
495 // If this is not a definition, keep track of it so we can use it as a forward
496 // reference.
497 if (!isDefinition) {
498 // Remember where this forward reference came from.
499 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
500 } else {
501 // The forward declaration could have been inserted anywhere in the
502 // function: insert it into the correct place now.
503 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
504 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
505 }
506 ID.destroy();
507 return BB;
508}
509
510
511//===----------------------------------------------------------------------===//
512// Code to handle forward references in instructions
513//===----------------------------------------------------------------------===//
514//
515// This code handles the late binding needed with statements that reference
516// values not defined yet... for example, a forward branch, or the PHI node for
517// a loop body.
518//
519// This keeps a table (CurFun.LateResolveValues) of all such forward references
520// and back patchs after we are done.
521//
522
523// ResolveDefinitions - If we could not resolve some defs at parsing
524// time (forward branches, phi functions for loops, etc...) resolve the
525// defs now...
526//
527static void
528ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
529 std::map<const Type*,ValueList> *FutureLateResolvers) {
530 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
531 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
532 E = LateResolvers.end(); LRI != E; ++LRI) {
533 ValueList &List = LRI->second;
534 while (!List.empty()) {
535 Value *V = List.back();
536 List.pop_back();
537
538 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
539 CurModule.PlaceHolderInfo.find(V);
540 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
541
542 ValID &DID = PHI->second.first;
543
544 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
545 if (TheRealValue) {
546 V->replaceAllUsesWith(TheRealValue);
547 delete V;
548 CurModule.PlaceHolderInfo.erase(PHI);
549 } else if (FutureLateResolvers) {
550 // Functions have their unresolved items forwarded to the module late
551 // resolver table
552 InsertValue(V, *FutureLateResolvers);
553 } else {
554 if (DID.Type == ValID::NameVal)
555 ThrowException("Reference to an invalid definition: '" +DID.getName()+
556 "' of type '" + V->getType()->getDescription() + "'",
557 PHI->second.second);
558 else
559 ThrowException("Reference to an invalid definition: #" +
560 itostr(DID.Num) + " of type '" +
561 V->getType()->getDescription() + "'",
562 PHI->second.second);
563 }
564 }
565 }
566
567 LateResolvers.clear();
568}
569
570// ResolveTypeTo - A brand new type was just declared. This means that (if
571// name is not null) things referencing Name can be resolved. Otherwise, things
572// refering to the number can be resolved. Do this now.
573//
574static void ResolveTypeTo(char *Name, const Type *ToTy) {
575 ValID D;
576 if (Name) D = ValID::create(Name);
577 else D = ValID::create((int)CurModule.Types.size());
578
579 std::map<ValID, PATypeHolder>::iterator I =
580 CurModule.LateResolveTypes.find(D);
581 if (I != CurModule.LateResolveTypes.end()) {
582 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
583 CurModule.LateResolveTypes.erase(I);
584 }
585}
586
587// setValueName - Set the specified value to the name given. The name may be
588// null potentially, in which case this is a noop. The string passed in is
589// assumed to be a malloc'd string buffer, and is free'd by this function.
590//
591static void setValueName(Value *V, char *NameStr) {
592 if (NameStr) {
593 std::string Name(NameStr); // Copy string
594 free(NameStr); // Free old string
595
596 if (V->getType() == Type::VoidTy)
597 ThrowException("Can't assign name '" + Name+"' to value with void type!");
598
599 assert(inFunctionScope() && "Must be in function scope!");
600 SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable();
601 if (ST.lookup(V->getType(), Name))
602 ThrowException("Redefinition of value named '" + Name + "' in the '" +
603 V->getType()->getDescription() + "' type plane!");
604
605 // Set the name.
606 V->setName(Name);
607 }
608}
609
610/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
611/// this is a declaration, otherwise it is a definition.
612static void ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
613 bool isConstantGlobal, const Type *Ty,
Chris Lattner840f7892005-11-06 06:46:53 +0000614 Constant *Initializer, unsigned Align) {
615 if (Align != 0 && !isPowerOf2_32(Align))
616 ThrowException("Global alignment must be a power of two!");
617
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000618 if (isa<FunctionType>(Ty))
619 ThrowException("Cannot declare global vars of function type!");
620
621 const PointerType *PTy = PointerType::get(Ty);
622
623 std::string Name;
624 if (NameStr) {
625 Name = NameStr; // Copy string
626 free(NameStr); // Free old string
627 }
628
629 // See if this global value was forward referenced. If so, recycle the
630 // object.
631 ValID ID;
632 if (!Name.empty()) {
633 ID = ValID::create((char*)Name.c_str());
634 } else {
635 ID = ValID::create((int)CurModule.Values[PTy].size());
636 }
637
638 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
639 // Move the global to the end of the list, from whereever it was
640 // previously inserted.
641 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
642 CurModule.CurrentModule->getGlobalList().remove(GV);
643 CurModule.CurrentModule->getGlobalList().push_back(GV);
644 GV->setInitializer(Initializer);
645 GV->setLinkage(Linkage);
646 GV->setConstant(isConstantGlobal);
Chris Lattner840f7892005-11-06 06:46:53 +0000647 GV->setAlignment(Align);
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000648 InsertValue(GV, CurModule.Values);
649 return;
650 }
651
652 // If this global has a name, check to see if there is already a definition
653 // of this global in the module. If so, merge as appropriate. Note that
654 // this is really just a hack around problems in the CFE. :(
655 if (!Name.empty()) {
656 // We are a simple redefinition of a value, check to see if it is defined
657 // the same as the old one.
658 if (GlobalVariable *EGV =
659 CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
660 // We are allowed to redefine a global variable in two circumstances:
661 // 1. If at least one of the globals is uninitialized or
662 // 2. If both initializers have the same value.
663 //
664 if (!EGV->hasInitializer() || !Initializer ||
665 EGV->getInitializer() == Initializer) {
666
667 // Make sure the existing global version gets the initializer! Make
668 // sure that it also gets marked const if the new version is.
669 if (Initializer && !EGV->hasInitializer())
670 EGV->setInitializer(Initializer);
671 if (isConstantGlobal)
672 EGV->setConstant(true);
673 EGV->setLinkage(Linkage);
Chris Lattner840f7892005-11-06 06:46:53 +0000674 EGV->setAlignment(Align);
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000675 return;
676 }
677
678 ThrowException("Redefinition of global variable named '" + Name +
679 "' in the '" + Ty->getDescription() + "' type plane!");
680 }
681 }
682
683 // Otherwise there is no existing GV to use, create one now.
684 GlobalVariable *GV =
685 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
686 CurModule.CurrentModule);
Chris Lattner840f7892005-11-06 06:46:53 +0000687 GV->setAlignment(Align);
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000688 InsertValue(GV, CurModule.Values);
689}
690
691// setTypeName - Set the specified type to the name given. The name may be
692// null potentially, in which case this is a noop. The string passed in is
693// assumed to be a malloc'd string buffer, and is freed by this function.
694//
695// This function returns true if the type has already been defined, but is
696// allowed to be redefined in the specified context. If the name is a new name
697// for the type plane, it is inserted and false is returned.
698static bool setTypeName(const Type *T, char *NameStr) {
699 assert(!inFunctionScope() && "Can't give types function-local names!");
700 if (NameStr == 0) return false;
701
702 std::string Name(NameStr); // Copy string
703 free(NameStr); // Free old string
704
705 // We don't allow assigning names to void type
706 if (T == Type::VoidTy)
707 ThrowException("Can't assign name '" + Name + "' to the void type!");
708
709 // Set the type name, checking for conflicts as we do so.
710 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
711
712 if (AlreadyExists) { // Inserting a name that is already defined???
713 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
714 assert(Existing && "Conflict but no matching type?");
715
716 // There is only one case where this is allowed: when we are refining an
717 // opaque type. In this case, Existing will be an opaque type.
718 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
719 // We ARE replacing an opaque type!
720 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
721 return true;
722 }
723
724 // Otherwise, this is an attempt to redefine a type. That's okay if
725 // the redefinition is identical to the original. This will be so if
726 // Existing and T point to the same Type object. In this one case we
727 // allow the equivalent redefinition.
728 if (Existing == T) return true; // Yes, it's equal.
729
730 // Any other kind of (non-equivalent) redefinition is an error.
731 ThrowException("Redefinition of type named '" + Name + "' in the '" +
732 T->getDescription() + "' type plane!");
733 }
734
735 return false;
736}
737
738//===----------------------------------------------------------------------===//
739// Code for handling upreferences in type names...
740//
741
742// TypeContains - Returns true if Ty directly contains E in it.
743//
744static bool TypeContains(const Type *Ty, const Type *E) {
745 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
746 E) != Ty->subtype_end();
747}
748
749namespace {
750 struct UpRefRecord {
751 // NestingLevel - The number of nesting levels that need to be popped before
752 // this type is resolved.
753 unsigned NestingLevel;
754
755 // LastContainedTy - This is the type at the current binding level for the
756 // type. Every time we reduce the nesting level, this gets updated.
757 const Type *LastContainedTy;
758
759 // UpRefTy - This is the actual opaque type that the upreference is
760 // represented with.
761 OpaqueType *UpRefTy;
762
763 UpRefRecord(unsigned NL, OpaqueType *URTy)
764 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
765 };
766}
767
768// UpRefs - A list of the outstanding upreferences that need to be resolved.
769static std::vector<UpRefRecord> UpRefs;
770
771/// HandleUpRefs - Every time we finish a new layer of types, this function is
772/// called. It loops through the UpRefs vector, which is a list of the
773/// currently active types. For each type, if the up reference is contained in
774/// the newly completed type, we decrement the level count. When the level
775/// count reaches zero, the upreferenced type is the type that is passed in:
776/// thus we can complete the cycle.
777///
778static PATypeHolder HandleUpRefs(const Type *ty) {
779 if (!ty->isAbstract()) return ty;
780 PATypeHolder Ty(ty);
781 UR_OUT("Type '" << Ty->getDescription() <<
782 "' newly formed. Resolving upreferences.\n" <<
783 UpRefs.size() << " upreferences active!\n");
784
785 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
786 // to zero), we resolve them all together before we resolve them to Ty. At
787 // the end of the loop, if there is anything to resolve to Ty, it will be in
788 // this variable.
789 OpaqueType *TypeToResolve = 0;
790
791 for (unsigned i = 0; i != UpRefs.size(); ++i) {
792 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
793 << UpRefs[i].second->getDescription() << ") = "
794 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
795 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
796 // Decrement level of upreference
797 unsigned Level = --UpRefs[i].NestingLevel;
798 UpRefs[i].LastContainedTy = Ty;
799 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
800 if (Level == 0) { // Upreference should be resolved!
801 if (!TypeToResolve) {
802 TypeToResolve = UpRefs[i].UpRefTy;
803 } else {
804 UR_OUT(" * Resolving upreference for "
805 << UpRefs[i].second->getDescription() << "\n";
806 std::string OldName = UpRefs[i].UpRefTy->getDescription());
807 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
808 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
809 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
810 }
811 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
812 --i; // Do not skip the next element...
813 }
814 }
815 }
816
817 if (TypeToResolve) {
818 UR_OUT(" * Resolving upreference for "
819 << UpRefs[i].second->getDescription() << "\n";
820 std::string OldName = TypeToResolve->getDescription());
821 TypeToResolve->refineAbstractTypeTo(Ty);
822 }
823
824 return Ty;
825}
826
827
828// common code from the two 'RunVMAsmParser' functions
829 static Module * RunParser(Module * M) {
830
831 llvmAsmlineno = 1; // Reset the current line number...
832 ObsoleteVarArgs = false;
833 NewVarArgs = false;
834
835 CurModule.CurrentModule = M;
836 yyparse(); // Parse the file, potentially throwing exception
837
838 Module *Result = ParserResult;
839 ParserResult = 0;
840
841 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
842 {
843 Function* F;
844 if ((F = Result->getNamedFunction("llvm.va_start"))
845 && F->getFunctionType()->getNumParams() == 0)
846 ObsoleteVarArgs = true;
847 if((F = Result->getNamedFunction("llvm.va_copy"))
848 && F->getFunctionType()->getNumParams() == 1)
849 ObsoleteVarArgs = true;
850 }
851
852 if (ObsoleteVarArgs && NewVarArgs)
853 ThrowException("This file is corrupt: it uses both new and old style varargs");
854
855 if(ObsoleteVarArgs) {
856 if(Function* F = Result->getNamedFunction("llvm.va_start")) {
857 if (F->arg_size() != 0)
858 ThrowException("Obsolete va_start takes 0 argument!");
859
860 //foo = va_start()
861 // ->
862 //bar = alloca typeof(foo)
863 //va_start(bar)
864 //foo = load bar
865
866 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
867 const Type* ArgTy = F->getFunctionType()->getReturnType();
868 const Type* ArgTyPtr = PointerType::get(ArgTy);
869 Function* NF = Result->getOrInsertFunction("llvm.va_start",
Jeff Cohen11e26b52005-10-23 04:37:20 +0000870 RetTy, ArgTyPtr, (Type *)0);
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000871
872 while (!F->use_empty()) {
873 CallInst* CI = cast<CallInst>(F->use_back());
874 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
875 new CallInst(NF, bar, "", CI);
876 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
877 CI->replaceAllUsesWith(foo);
878 CI->getParent()->getInstList().erase(CI);
879 }
880 Result->getFunctionList().erase(F);
881 }
882
883 if(Function* F = Result->getNamedFunction("llvm.va_end")) {
884 if(F->arg_size() != 1)
885 ThrowException("Obsolete va_end takes 1 argument!");
886
887 //vaend foo
888 // ->
889 //bar = alloca 1 of typeof(foo)
890 //vaend bar
891 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
892 const Type* ArgTy = F->getFunctionType()->getParamType(0);
893 const Type* ArgTyPtr = PointerType::get(ArgTy);
894 Function* NF = Result->getOrInsertFunction("llvm.va_end",
Jeff Cohen11e26b52005-10-23 04:37:20 +0000895 RetTy, ArgTyPtr, (Type *)0);
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000896
897 while (!F->use_empty()) {
898 CallInst* CI = cast<CallInst>(F->use_back());
899 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
900 new StoreInst(CI->getOperand(1), bar, CI);
901 new CallInst(NF, bar, "", CI);
902 CI->getParent()->getInstList().erase(CI);
903 }
904 Result->getFunctionList().erase(F);
905 }
906
907 if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
908 if(F->arg_size() != 1)
909 ThrowException("Obsolete va_copy takes 1 argument!");
910 //foo = vacopy(bar)
911 // ->
912 //a = alloca 1 of typeof(foo)
913 //b = alloca 1 of typeof(foo)
914 //store bar -> b
915 //vacopy(a, b)
916 //foo = load a
917
918 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
919 const Type* ArgTy = F->getFunctionType()->getReturnType();
920 const Type* ArgTyPtr = PointerType::get(ArgTy);
921 Function* NF = Result->getOrInsertFunction("llvm.va_copy",
Jeff Cohen11e26b52005-10-23 04:37:20 +0000922 RetTy, ArgTyPtr, ArgTyPtr,
923 (Type *)0);
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000924
925 while (!F->use_empty()) {
926 CallInst* CI = cast<CallInst>(F->use_back());
927 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
928 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
929 new StoreInst(CI->getOperand(1), b, CI);
930 new CallInst(NF, a, b, "", CI);
931 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
932 CI->replaceAllUsesWith(foo);
933 CI->getParent()->getInstList().erase(CI);
934 }
935 Result->getFunctionList().erase(F);
936 }
937 }
938
939 return Result;
940
941 }
942
943//===----------------------------------------------------------------------===//
944// RunVMAsmParser - Define an interface to this parser
945//===----------------------------------------------------------------------===//
946//
947Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
948 set_scan_file(F);
949
950 CurFilename = Filename;
951 return RunParser(new Module(CurFilename));
952}
953
954Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
955 set_scan_string(AsmString);
956
957 CurFilename = "from_memory";
958 if (M == NULL) {
959 return RunParser(new Module (CurFilename));
960 } else {
961 return RunParser(M);
962 }
963}
964
965
Chris Lattner840f7892005-11-06 06:46:53 +0000966#line 873 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +0000967typedef union {
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000968 llvm::Module *ModuleVal;
969 llvm::Function *FunctionVal;
970 std::pair<llvm::PATypeHolder*, char*> *ArgVal;
971 llvm::BasicBlock *BasicBlockVal;
972 llvm::TerminatorInst *TermInstVal;
973 llvm::Instruction *InstVal;
974 llvm::Constant *ConstVal;
975
976 const llvm::Type *PrimType;
977 llvm::PATypeHolder *TypeVal;
978 llvm::Value *ValueVal;
979
980 std::vector<std::pair<llvm::PATypeHolder*,char*> > *ArgList;
981 std::vector<llvm::Value*> *ValueList;
982 std::list<llvm::PATypeHolder> *TypeList;
983 // Represent the RHS of PHI node
984 std::list<std::pair<llvm::Value*,
985 llvm::BasicBlock*> > *PHIList;
986 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
987 std::vector<llvm::Constant*> *ConstVector;
988
989 llvm::GlobalValue::LinkageTypes Linkage;
990 int64_t SInt64Val;
991 uint64_t UInt64Val;
992 int SIntVal;
993 unsigned UIntVal;
994 double FPVal;
995 bool BoolVal;
996
997 char *StrVal; // This memory is strdup'd!
998 llvm::ValID ValIDVal; // strdup'd memory maybe!
999
1000 llvm::Instruction::BinaryOps BinaryOpVal;
1001 llvm::Instruction::TermOps TermOpVal;
1002 llvm::Instruction::MemoryOps MemOpVal;
1003 llvm::Instruction::OtherOps OtherOpVal;
1004 llvm::Module::Endianness Endianness;
1005} YYSTYPE;
Nate Begeman848622f2005-11-05 09:21:28 +00001006#include <stdio.h>
1007
1008#ifndef __cplusplus
1009#ifndef __STDC__
1010#define const
1011#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001012#endif
1013
1014
1015
Chris Lattner840f7892005-11-06 06:46:53 +00001016#define YYFINAL 431
Nate Begeman848622f2005-11-05 09:21:28 +00001017#define YYFLAG -32768
1018#define YYNTBASE 109
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001019
Chris Lattner840f7892005-11-06 06:46:53 +00001020#define YYTRANSLATE(x) ((unsigned)(x) <= 348 ? yytranslate[x] : 172)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001021
Nate Begeman848622f2005-11-05 09:21:28 +00001022static const char yytranslate[] = { 0,
1023 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1024 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1025 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Chris Lattner86c352b2005-11-06 06:34:34 +00001026 2, 2, 2, 2, 2, 2, 2, 2, 2, 98,
1027 99, 107, 2, 96, 2, 2, 2, 2, 2, 2,
1028 2, 2, 2, 2, 2, 2, 2, 2, 2, 103,
1029 95, 104, 2, 2, 2, 2, 2, 2, 2, 2,
Nate Begeman848622f2005-11-05 09:21:28 +00001030 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1031 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Chris Lattner86c352b2005-11-06 06:34:34 +00001032 100, 97, 102, 2, 2, 2, 2, 2, 108, 2,
Nate Begeman848622f2005-11-05 09:21:28 +00001033 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Chris Lattner86c352b2005-11-06 06:34:34 +00001034 2, 2, 2, 2, 2, 2, 2, 2, 2, 101,
1035 2, 2, 105, 2, 106, 2, 2, 2, 2, 2,
Nate Begeman848622f2005-11-05 09:21:28 +00001036 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1037 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, 1, 3, 4, 5, 6,
1049 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1050 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1051 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
1052 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
1053 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
1054 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1055 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1056 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1057 87, 88, 89, 90, 91, 92, 93, 94
1058};
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001059
Nate Begeman848622f2005-11-05 09:21:28 +00001060#if YYDEBUG != 0
1061static const short yyprhs[] = { 0,
1062 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
1063 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
1064 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
1065 60, 62, 64, 67, 68, 70, 72, 74, 76, 77,
Chris Lattner840f7892005-11-06 06:46:53 +00001066 78, 80, 82, 84, 87, 88, 91, 92, 96, 98,
Chris Lattner86c352b2005-11-06 06:34:34 +00001067 100, 102, 104, 106, 108, 110, 112, 114, 116, 118,
Chris Lattner840f7892005-11-06 06:46:53 +00001068 120, 122, 124, 126, 128, 130, 132, 134, 136, 138,
1069 141, 146, 152, 158, 162, 165, 168, 170, 174, 176,
1070 180, 182, 183, 188, 192, 196, 201, 206, 210, 213,
1071 216, 219, 222, 225, 228, 231, 234, 237, 240, 247,
1072 253, 262, 269, 276, 283, 290, 294, 296, 298, 300,
1073 302, 305, 308, 311, 313, 318, 321, 328, 335, 339,
1074 344, 345, 347, 349, 353, 357, 361, 365, 369, 371,
1075 372, 374, 376, 378, 379, 382, 386, 388, 390, 394,
1076 396, 397, 405, 407, 409, 413, 415, 417, 420, 421,
1077 425, 427, 429, 431, 433, 435, 437, 439, 443, 445,
1078 447, 449, 451, 453, 456, 459, 462, 466, 469, 470,
1079 472, 475, 478, 482, 492, 502, 511, 525, 527, 529,
1080 536, 542, 545, 552, 560, 562, 566, 568, 569, 572,
1081 574, 580, 586, 592, 595, 600, 605, 612, 617, 622,
1082 627, 630, 638, 640, 643, 644, 646, 647, 651, 658,
1083 662, 669, 672, 677, 684
Nate Begeman848622f2005-11-05 09:21:28 +00001084};
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001085
Nate Begeman848622f2005-11-05 09:21:28 +00001086static const short yyrhs[] = { 5,
1087 0, 6, 0, 3, 0, 4, 0, 67, 0, 68,
1088 0, 69, 0, 70, 0, 71, 0, 72, 0, 73,
1089 0, 74, 0, 75, 0, 76, 0, 77, 0, 78,
1090 0, 79, 0, 80, 0, 90, 0, 91, 0, 16,
1091 0, 14, 0, 12, 0, 10, 0, 17, 0, 15,
1092 0, 13, 0, 11, 0, 115, 0, 116, 0, 18,
Chris Lattner840f7892005-11-06 06:46:53 +00001093 0, 19, 0, 142, 95, 0, 0, 40, 0, 41,
Nate Begeman848622f2005-11-05 09:21:28 +00001094 0, 42, 0, 43, 0, 0, 0, 58, 0, 59,
Chris Lattner840f7892005-11-06 06:46:53 +00001095 0, 60, 0, 57, 4, 0, 0, 53, 4, 0,
1096 0, 96, 53, 4, 0, 126, 0, 8, 0, 128,
1097 0, 8, 0, 128, 0, 9, 0, 10, 0, 11,
1098 0, 12, 0, 13, 0, 14, 0, 15, 0, 16,
1099 0, 17, 0, 18, 0, 19, 0, 20, 0, 21,
1100 0, 44, 0, 127, 0, 155, 0, 97, 4, 0,
1101 125, 98, 130, 99, 0, 100, 4, 101, 128, 102,
1102 0, 103, 4, 101, 128, 104, 0, 105, 129, 106,
1103 0, 105, 106, 0, 128, 107, 0, 128, 0, 129,
1104 96, 128, 0, 129, 0, 129, 96, 36, 0, 36,
1105 0, 0, 126, 100, 133, 102, 0, 126, 100, 102,
1106 0, 126, 108, 24, 0, 126, 103, 133, 104, 0,
1107 126, 105, 133, 106, 0, 126, 105, 106, 0, 126,
1108 37, 0, 126, 38, 0, 126, 155, 0, 126, 132,
1109 0, 126, 26, 0, 115, 110, 0, 116, 4, 0,
1110 9, 27, 0, 9, 28, 0, 118, 7, 0, 88,
1111 98, 131, 35, 126, 99, 0, 86, 98, 131, 169,
1112 99, 0, 89, 98, 131, 96, 131, 96, 131, 99,
1113 0, 111, 98, 131, 96, 131, 99, 0, 112, 98,
1114 131, 96, 131, 99, 0, 113, 98, 131, 96, 131,
1115 99, 0, 114, 98, 131, 96, 131, 99, 0, 133,
1116 96, 131, 0, 131, 0, 32, 0, 33, 0, 136,
1117 0, 136, 151, 0, 136, 152, 0, 136, 25, 0,
1118 137, 0, 137, 119, 20, 124, 0, 137, 152, 0,
1119 137, 119, 120, 134, 131, 123, 0, 137, 119, 46,
1120 134, 126, 123, 0, 137, 47, 139, 0, 137, 54,
1121 95, 140, 0, 0, 52, 0, 51, 0, 49, 95,
1122 138, 0, 50, 95, 4, 0, 48, 95, 24, 0,
1123 100, 141, 102, 0, 141, 96, 24, 0, 24, 0,
1124 0, 22, 0, 24, 0, 142, 0, 0, 126, 143,
1125 0, 145, 96, 144, 0, 144, 0, 145, 0, 145,
1126 96, 36, 0, 36, 0, 0, 121, 124, 142, 98,
1127 146, 99, 122, 0, 29, 0, 105, 0, 120, 147,
1128 148, 0, 30, 0, 106, 0, 158, 150, 0, 0,
1129 31, 153, 147, 0, 3, 0, 4, 0, 7, 0,
1130 27, 0, 28, 0, 37, 0, 38, 0, 103, 133,
1131 104, 0, 132, 0, 109, 0, 142, 0, 155, 0,
1132 154, 0, 126, 156, 0, 158, 159, 0, 149, 159,
1133 0, 160, 119, 161, 0, 160, 163, 0, 0, 23,
1134 0, 61, 157, 0, 61, 8, 0, 62, 21, 156,
1135 0, 62, 9, 156, 96, 21, 156, 96, 21, 156,
1136 0, 63, 117, 156, 96, 21, 156, 100, 162, 102,
1137 0, 63, 117, 156, 96, 21, 156, 100, 102, 0,
1138 64, 121, 124, 156, 98, 166, 99, 35, 21, 156,
1139 65, 21, 156, 0, 65, 0, 66, 0, 162, 117,
1140 154, 96, 21, 156, 0, 117, 154, 96, 21, 156,
1141 0, 119, 168, 0, 126, 100, 156, 96, 156, 102,
1142 0, 164, 96, 100, 156, 96, 156, 102, 0, 157,
1143 0, 165, 96, 157, 0, 165, 0, 0, 56, 55,
1144 0, 55, 0, 111, 126, 156, 96, 156, 0, 112,
1145 126, 156, 96, 156, 0, 113, 126, 156, 96, 156,
1146 0, 45, 157, 0, 114, 157, 96, 157, 0, 88,
1147 157, 35, 126, 0, 89, 157, 96, 157, 96, 157,
1148 0, 92, 157, 96, 126, 0, 93, 157, 96, 126,
1149 0, 94, 157, 96, 126, 0, 87, 164, 0, 167,
1150 121, 124, 156, 98, 166, 99, 0, 171, 0, 96,
1151 165, 0, 0, 34, 0, 0, 81, 126, 123, 0,
1152 81, 126, 96, 15, 156, 123, 0, 82, 126, 123,
1153 0, 82, 126, 96, 15, 156, 123, 0, 83, 157,
1154 0, 170, 84, 126, 156, 0, 170, 85, 157, 96,
1155 126, 156, 0, 86, 126, 156, 169, 0
Nate Begeman848622f2005-11-05 09:21:28 +00001156};
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001157
1158#endif
1159
Nate Begeman848622f2005-11-05 09:21:28 +00001160#if YYDEBUG != 0
1161static const short yyrline[] = { 0,
Chris Lattner840f7892005-11-06 06:46:53 +00001162 990, 991, 998, 999, 1008, 1008, 1008, 1008, 1008, 1009,
1163 1009, 1009, 1010, 1010, 1010, 1010, 1010, 1010, 1012, 1012,
1164 1016, 1016, 1016, 1016, 1017, 1017, 1017, 1017, 1018, 1018,
1165 1019, 1019, 1022, 1025, 1029, 1029, 1030, 1031, 1032, 1035,
1166 1035, 1036, 1037, 1038, 1047, 1047, 1049, 1049, 1059, 1059,
1167 1060, 1060, 1062, 1071, 1071, 1071, 1071, 1071, 1071, 1071,
1168 1072, 1072, 1072, 1072, 1072, 1072, 1073, 1076, 1079, 1085,
1169 1092, 1104, 1108, 1119, 1128, 1131, 1139, 1143, 1148, 1149,
1170 1152, 1155, 1165, 1190, 1203, 1231, 1256, 1276, 1288, 1297,
1171 1301, 1360, 1366, 1374, 1379, 1384, 1387, 1390, 1397, 1407,
1172 1438, 1445, 1466, 1473, 1478, 1488, 1491, 1498, 1498, 1508,
1173 1515, 1519, 1522, 1525, 1538, 1558, 1560, 1564, 1568, 1570,
1174 1572, 1577, 1578, 1580, 1583, 1591, 1596, 1598, 1602, 1606,
1175 1614, 1614, 1615, 1615, 1617, 1623, 1628, 1634, 1637, 1642,
1176 1646, 1650, 1733, 1733, 1735, 1743, 1743, 1745, 1749, 1749,
1177 1758, 1761, 1764, 1767, 1770, 1773, 1776, 1779, 1803, 1810,
1178 1813, 1818, 1818, 1824, 1828, 1831, 1839, 1848, 1852, 1862,
1179 1873, 1876, 1879, 1882, 1885, 1899, 1903, 1956, 1959, 1965,
1180 1973, 1983, 1990, 1995, 2002, 2006, 2012, 2012, 2014, 2017,
1181 2023, 2035, 2043, 2053, 2065, 2072, 2079, 2086, 2091, 2110,
1182 2132, 2146, 2203, 2209, 2211, 2215, 2218, 2224, 2231, 2238,
1183 2245, 2252, 2259, 2269, 2282
Nate Begeman848622f2005-11-05 09:21:28 +00001184};
1185#endif
1186
1187
1188#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
1189
1190static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL",
1191"EUINT64VAL","SINTVAL","UINTVAL","FPVAL","VOID","BOOL","SBYTE","UBYTE","SHORT",
1192"USHORT","INT","UINT","LONG","ULONG","FLOAT","DOUBLE","TYPE","LABEL","VAR_ID",
1193"LABELSTR","STRINGCONSTANT","IMPLEMENTATION","ZEROINITIALIZER","TRUETOK","FALSETOK",
1194"BEGINTOK","ENDTOK","DECLARE","GLOBAL","CONSTANT","VOLATILE","TO","DOTDOTDOT",
1195"NULL_TOK","UNDEF","CONST","INTERNAL","LINKONCE","WEAK","APPENDING","OPAQUE",
1196"NOT","EXTERNAL","TARGET","TRIPLE","ENDIAN","POINTERSIZE","LITTLE","BIG","ALIGN",
1197"DEPLIBS","CALL","TAIL","CC_TOK","CCC_TOK","FASTCC_TOK","COLDCC_TOK","RET","BR",
1198"SWITCH","INVOKE","UNWIND","UNREACHABLE","ADD","SUB","MUL","DIV","REM","AND",
1199"OR","XOR","SETLE","SETGE","SETLT","SETGT","SETEQ","SETNE","MALLOC","ALLOCA",
1200"FREE","LOAD","STORE","GETELEMENTPTR","PHI_TOK","CAST","SELECT","SHL","SHR",
Chris Lattner86c352b2005-11-06 06:34:34 +00001201"VAARG","VAARG_old","VANEXT_old","'='","','","'\\\\'","'('","')'","'['","'x'",
1202"']'","'<'","'>'","'{'","'}'","'*'","'c'","INTVAL","EINT64VAL","ArithmeticOps",
Nate Begeman848622f2005-11-05 09:21:28 +00001203"LogicalOps","SetCondOps","ShiftOps","SIntType","UIntType","IntType","FPType",
Chris Lattner840f7892005-11-06 06:46:53 +00001204"OptAssign","OptLinkage","OptCallingConv","OptAlign","OptCAlign","TypesV","UpRTypesV",
1205"Types","PrimType","UpRTypes","TypeListI","ArgTypeListI","ConstVal","ConstExpr",
1206"ConstVector","GlobalType","Module","FunctionList","ConstPool","BigOrLittle",
1207"TargetDefinition","LibrariesDefinition","LibList","Name","OptName","ArgVal",
1208"ArgListH","ArgList","FunctionHeaderH","BEGIN","FunctionHeader","END","Function",
1209"FunctionProto","@1","ConstValueRef","SymbolicValueRef","ValueRef","ResolvedVal",
1210"BasicBlockList","BasicBlock","InstructionList","BBTerminatorInst","JumpTable",
1211"Inst","PHIList","ValueRefList","ValueRefListE","OptTailCall","InstVal","IndexList",
1212"OptVolatile","MemoryInst", NULL
Nate Begeman848622f2005-11-05 09:21:28 +00001213};
1214#endif
1215
1216static const short yyr1[] = { 0,
1217 109, 109, 110, 110, 111, 111, 111, 111, 111, 112,
1218 112, 112, 113, 113, 113, 113, 113, 113, 114, 114,
1219 115, 115, 115, 115, 116, 116, 116, 116, 117, 117,
1220 118, 118, 119, 119, 120, 120, 120, 120, 120, 121,
Chris Lattner86c352b2005-11-06 06:34:34 +00001221 121, 121, 121, 121, 122, 122, 123, 123, 124, 124,
Chris Lattner840f7892005-11-06 06:46:53 +00001222 125, 125, 126, 127, 127, 127, 127, 127, 127, 127,
1223 127, 127, 127, 127, 127, 127, 128, 128, 128, 128,
1224 128, 128, 128, 128, 128, 128, 129, 129, 130, 130,
1225 130, 130, 131, 131, 131, 131, 131, 131, 131, 131,
1226 131, 131, 131, 131, 131, 131, 131, 131, 132, 132,
1227 132, 132, 132, 132, 132, 133, 133, 134, 134, 135,
1228 136, 136, 136, 136, 137, 137, 137, 137, 137, 137,
1229 137, 138, 138, 139, 139, 139, 140, 141, 141, 141,
1230 142, 142, 143, 143, 144, 145, 145, 146, 146, 146,
1231 146, 147, 148, 148, 149, 150, 150, 151, 153, 152,
1232 154, 154, 154, 154, 154, 154, 154, 154, 154, 155,
1233 155, 156, 156, 157, 158, 158, 159, 160, 160, 160,
1234 161, 161, 161, 161, 161, 161, 161, 161, 161, 162,
1235 162, 163, 164, 164, 165, 165, 166, 166, 167, 167,
1236 168, 168, 168, 168, 168, 168, 168, 168, 168, 168,
1237 168, 168, 168, 169, 169, 170, 170, 171, 171, 171,
1238 171, 171, 171, 171, 171
Nate Begeman848622f2005-11-05 09:21:28 +00001239};
1240
1241static const short yyr2[] = { 0,
1242 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1243 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1244 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1245 1, 1, 2, 0, 1, 1, 1, 1, 0, 0,
Chris Lattner840f7892005-11-06 06:46:53 +00001246 1, 1, 1, 2, 0, 2, 0, 3, 1, 1,
Nate Begeman848622f2005-11-05 09:21:28 +00001247 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Chris Lattner840f7892005-11-06 06:46:53 +00001248 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
1249 4, 5, 5, 3, 2, 2, 1, 3, 1, 3,
1250 1, 0, 4, 3, 3, 4, 4, 3, 2, 2,
1251 2, 2, 2, 2, 2, 2, 2, 2, 6, 5,
1252 8, 6, 6, 6, 6, 3, 1, 1, 1, 1,
1253 2, 2, 2, 1, 4, 2, 6, 6, 3, 4,
1254 0, 1, 1, 3, 3, 3, 3, 3, 1, 0,
1255 1, 1, 1, 0, 2, 3, 1, 1, 3, 1,
1256 0, 7, 1, 1, 3, 1, 1, 2, 0, 3,
1257 1, 1, 1, 1, 1, 1, 1, 3, 1, 1,
1258 1, 1, 1, 2, 2, 2, 3, 2, 0, 1,
1259 2, 2, 3, 9, 9, 8, 13, 1, 1, 6,
1260 5, 2, 6, 7, 1, 3, 1, 0, 2, 1,
1261 5, 5, 5, 2, 4, 4, 6, 4, 4, 4,
1262 2, 7, 1, 2, 0, 1, 0, 3, 6, 3,
1263 6, 2, 4, 6, 4
Nate Begeman848622f2005-11-05 09:21:28 +00001264};
1265
Chris Lattner840f7892005-11-06 06:46:53 +00001266static const short yydefact[] = { 121,
1267 39, 114, 113, 149, 35, 36, 37, 38, 40, 169,
1268 111, 112, 169, 131, 132, 0, 0, 39, 0, 116,
1269 40, 0, 41, 42, 43, 0, 0, 170, 166, 34,
1270 146, 147, 148, 165, 0, 0, 0, 119, 0, 0,
1271 0, 0, 33, 150, 44, 1, 2, 50, 54, 55,
1272 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
1273 66, 67, 0, 0, 0, 0, 160, 0, 0, 49,
1274 68, 53, 161, 69, 143, 144, 145, 207, 168, 0,
1275 0, 0, 130, 120, 115, 108, 109, 0, 0, 70,
1276 0, 0, 52, 75, 77, 0, 0, 82, 76, 206,
1277 0, 190, 0, 0, 0, 0, 40, 178, 179, 5,
Nate Begeman848622f2005-11-05 09:21:28 +00001278 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
1279 16, 17, 18, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner840f7892005-11-06 06:46:53 +00001280 19, 20, 0, 0, 0, 0, 0, 0, 0, 167,
1281 40, 182, 0, 203, 126, 123, 122, 124, 125, 129,
1282 0, 47, 54, 55, 56, 57, 58, 59, 60, 61,
1283 62, 63, 64, 0, 0, 0, 0, 47, 0, 0,
1284 0, 74, 141, 81, 79, 0, 0, 194, 189, 172,
1285 171, 0, 0, 24, 28, 23, 27, 22, 26, 21,
1286 25, 29, 30, 0, 0, 47, 47, 212, 0, 0,
1287 201, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1288 0, 0, 0, 0, 127, 0, 118, 96, 97, 3,
1289 4, 94, 95, 98, 93, 89, 90, 0, 0, 0,
1290 0, 0, 0, 0, 0, 0, 0, 0, 92, 91,
1291 117, 51, 51, 78, 140, 134, 137, 138, 0, 0,
1292 71, 151, 152, 153, 154, 155, 156, 157, 0, 159,
1293 163, 162, 164, 0, 173, 0, 0, 0, 208, 0,
1294 210, 205, 0, 0, 0, 0, 0, 0, 0, 0,
1295 0, 0, 0, 0, 0, 0, 128, 0, 0, 0,
1296 0, 84, 107, 0, 0, 88, 0, 85, 0, 0,
1297 0, 0, 72, 73, 133, 135, 0, 45, 80, 0,
1298 0, 0, 0, 0, 0, 0, 215, 0, 0, 196,
1299 0, 198, 199, 200, 0, 0, 0, 195, 0, 213,
1300 0, 48, 205, 0, 0, 0, 83, 86, 87, 0,
1301 0, 0, 0, 139, 136, 0, 142, 158, 0, 0,
1302 188, 47, 47, 185, 204, 0, 0, 0, 191, 192,
1303 193, 188, 0, 0, 0, 0, 106, 0, 0, 0,
1304 0, 46, 0, 0, 187, 0, 209, 211, 0, 0,
1305 0, 197, 0, 214, 100, 0, 0, 0, 0, 0,
1306 0, 0, 0, 0, 186, 183, 0, 202, 99, 0,
1307 102, 103, 104, 105, 0, 176, 0, 0, 0, 184,
1308 0, 174, 0, 175, 0, 0, 101, 0, 0, 0,
1309 0, 0, 0, 181, 0, 0, 180, 177, 0, 0,
1310 0
Nate Begeman848622f2005-11-05 09:21:28 +00001311};
1312
1313static const short yydefgoto[] = { 67,
Chris Lattner840f7892005-11-06 06:46:53 +00001314 222, 235, 236, 237, 238, 164, 165, 194, 166, 18,
1315 9, 26, 347, 217, 68, 69, 167, 71, 72, 96,
1316 176, 293, 260, 294, 88, 429, 1, 2, 148, 38,
1317 84, 151, 73, 306, 247, 248, 249, 27, 77, 10,
1318 33, 11, 12, 21, 261, 74, 263, 354, 13, 29,
1319 30, 140, 408, 79, 201, 375, 376, 141, 142, 317,
1320 143, 144
Nate Begeman848622f2005-11-05 09:21:28 +00001321};
1322
1323static const short yypact[] = {-32768,
Chris Lattner840f7892005-11-06 06:46:53 +00001324 191, 336,-32768,-32768,-32768,-32768,-32768,-32768, 37, 19,
1325-32768,-32768, -17,-32768,-32768, 101, -32, 31, -25,-32768,
1326 37, 53,-32768,-32768,-32768, 896, -13,-32768,-32768, 130,
1327-32768,-32768,-32768,-32768, -19, -16, 33,-32768, 26, 896,
1328 58, 58,-32768,-32768,-32768,-32768,-32768, 55,-32768,-32768,
Nate Begeman848622f2005-11-05 09:21:28 +00001329-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
Chris Lattner840f7892005-11-06 06:46:53 +00001330-32768,-32768, 127, 156, 166, 124,-32768, 130, 82,-32768,
1331-32768, -81,-32768,-32768,-32768,-32768,-32768, 1053,-32768, 157,
1332 54, 178, 160,-32768,-32768,-32768,-32768, 933, 970,-32768,
1333 88, 91,-32768,-32768, -81, -42, 85, 711,-32768,-32768,
1334 933,-32768, 141, 1007, 0, 104, 37,-32768,-32768,-32768,
Nate Begeman848622f2005-11-05 09:21:28 +00001335-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
Chris Lattner840f7892005-11-06 06:46:53 +00001336-32768,-32768,-32768, 933, 933, 933, 933, 933, 933, 933,
1337-32768,-32768, 933, 933, 933, 933, 933, 933, 933,-32768,
1338 37,-32768, 71,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1339 -77, 102, 131, 159, 195, 161, 196, 163, 201, 171,
1340 202, 203, 204, 175, 208, 206, 387, 102, 933, 933,
1341 933,-32768, 748,-32768, 118, 116, 560,-32768,-32768, 55,
1342-32768, 560, 560,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1343-32768,-32768,-32768, 560, 896, 129, 132,-32768, 560, 123,
1344 139, 205, 140, 142, 143, 145, 560, 560, 560, 146,
1345 896, 933, 933, 213,-32768, 173,-32768,-32768,-32768,-32768,
1346-32768,-32768,-32768,-32768,-32768,-32768,-32768, 148, 149, 150,
1347 785, 970, 511, 219, 158, 162, 164, 165,-32768,-32768,
1348-32768, -14, -48, -81,-32768, 130,-32768, 168, 167, 822,
1349-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 970,-32768,
1350-32768,-32768,-32768, 169,-32768, 172, 560, -12,-32768, -7,
1351-32768, 174, 560, 144, 933, 933, 933, 933, 933, 177,
1352 179, 180, 933, 560, 560, 181,-32768, 251, 970, 970,
1353 970,-32768,-32768, -74, -36,-32768, -41,-32768, 970, 970,
1354 970, 970,-32768,-32768,-32768,-32768, 859, 216,-32768, -35,
1355 237, 238, 176, 560, 560, 933,-32768, 184, 560,-32768,
1356 186,-32768,-32768,-32768, 560, 560, 560,-32768, 185,-32768,
1357 933,-32768, 174, 236, 189, 970,-32768,-32768,-32768, 198,
1358 199, 200, 207,-32768,-32768, 293,-32768,-32768, 560, 560,
1359 933, 102, 102,-32768, 214, 560, 215, 933,-32768,-32768,
1360-32768, 933, 560, 217, 933, 970,-32768, 970, 970, 970,
1361 970,-32768, 218, 212, 214, 223,-32768,-32768, 933, 197,
1362 560,-32768, 224,-32768,-32768, 225, 221, 227, 228, 229,
1363 230, 277, 20, 265,-32768,-32768, 231,-32768,-32768, 970,
1364-32768,-32768,-32768,-32768, 560,-32768, 615, 70, 280,-32768,
1365 232,-32768, 234,-32768, 615, 560,-32768, 281, 239, 250,
1366 560, 283, 313,-32768, 560, 560,-32768,-32768, 340, 341,
Chris Lattner86c352b2005-11-06 06:34:34 +00001367-32768
Nate Begeman848622f2005-11-05 09:21:28 +00001368};
1369
Chris Lattner840f7892005-11-06 06:46:53 +00001370static const short yypgoto[] = {-32768,
1371-32768, 264, 267, 268, 269, -102, -101, -381,-32768, 318,
1372 333, -96,-32768, -158, -38,-32768, -26,-32768, -46, 254,
1373-32768, -82, 188, -209, 317,-32768,-32768,-32768,-32768,-32768,
1374-32768,-32768, -1,-32768, 59,-32768,-32768, 344,-32768,-32768,
1375-32768,-32768, 359,-32768, -349, -6, 155, -86,-32768, 357,
1376-32768,-32768,-32768,-32768,-32768, 56, 9,-32768,-32768, 40,
1377-32768,-32768
1378};
Nate Begeman848622f2005-11-05 09:21:28 +00001379
Chris Lattner840f7892005-11-06 06:46:53 +00001380
1381#define YYLAST 1147
Nate Begeman848622f2005-11-05 09:21:28 +00001382
1383
1384static const short yytable[] = { 70,
Chris Lattner840f7892005-11-06 06:46:53 +00001385 19, 85, 314, 192, 193, 28, 168, 315, 182, 241,
1386 195, 407, 31, 70, 178, 75, -51, 181, 214, 95,
1387 183, 336, 295, 297, 215, 99, 415, 337, 19, 184,
1388 185, 186, 187, 188, 189, 190, 191, 269, 271, 198,
1389 288, 28, 202, 203, 211, 288, 204, 205, 206, 310,
1390 40, 95, 210, 171, 336, 304, 45, 413, 99, 336,
1391 336, 152, 39, 172, 339, 419, 97, 338, 348, 43,
1392 5, 6, 7, 8, 177, 80, 41, 177, 81, 184,
1393 185, 186, 187, 188, 189, 190, 191, 303, 32, 86,
1394 87, 76, 99, 22, 23, 24, 25, 196, 197, 177,
1395 199, 200, 177, 177, 146, 147, 177, 177, 177, 207,
1396 208, 209, 177, 184, 185, 186, 187, 188, 189, 190,
1397 191, 406, 242, 243, 244, 83, 286, 82, 46, 47,
1398 90, 93, 49, 50, 51, 52, 53, 54, 55, 56,
1399 57, 58, 59, 60, 61, 14, 246, 15, 35, 36,
1400 37, 14, -52, 15, 212, 213, 267, 218, 219, 91,
1401 240, -24, -24, -23, -23, -22, -22, 62, 70, 92,
1402 262, 414, 284, -21, -21, 262, 262, 220, 221, 98,
1403 145, 149, 173, 150, 70, 285, 177, 262, 169, 321,
1404 -110, 170, 262, 377, 378, 179, 328, 216, -28, -27,
1405 262, 262, 262, 244, -26, -25, 333, 334, 335, -31,
1406 -32, 223, 224, 250, 251, 3, 340, 341, 342, 343,
1407 63, 4, 273, 64, 268, 288, 65, 270, 66, 94,
1408 5, 6, 7, 8, 274, 276, 287, 277, 278, 275,
1409 279, 283, 298, 319, 305, 289, 290, 291, 320, 177,
1410 322, 323, 324, 367, 332, 299, 177, 349, 350, 300,
1411 262, 301, 302, 307, 311, 308, 262, 312, 346, 316,
1412 365, 382, 325, 351, 326, 327, 331, 262, 262, 356,
1413 246, 358, 362, 387, 366, 388, 389, 390, 391, 177,
1414 192, 193, 395, 368, 369, 370, 372, 405, 396, 409,
1415 416, 421, 371, 425, 363, 192, 193, 262, 262, 379,
1416 381, 393, 262, 392, 423, 385, 400, 411, 262, 262,
1417 262, 394, 398, 399, 177, 401, 402, 403, 404, 418,
1418 417, 177, 410, 426, 422, 177, 264, 265, 386, 430,
1419 431, 136, 262, 262, 137, 138, 139, 78, 266, 262,
1420 42, 175, 177, 272, 239, -34, 262, 14, 89, 15,
1421 20, 280, 281, 282, 44, 345, 4, -34, -34, 34,
1422 383, 355, 364, 0, 262, -34, -34, -34, -34, 0,
1423 0, -34, 16, 0, 0, 0, 0, 0, 0, 17,
1424 0, 46, 47, 0, 0, 0, 0, 0, 262, 0,
1425 0, 0, 0, 0, 0, 0, 0, 0, 14, 262,
1426 15, 0, 225, 0, 262, 0, 0, 0, 262, 262,
1427 0, 313, 0, 226, 227, 0, 0, 318, 0, 0,
1428 0, 0, 0, 0, 0, 0, 0, 0, 329, 330,
Nate Begeman848622f2005-11-05 09:21:28 +00001429 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner840f7892005-11-06 06:46:53 +00001430 0, 0, 0, 110, 111, 112, 113, 114, 115, 116,
1431 117, 118, 119, 120, 121, 122, 123, 0, 352, 353,
1432 0, 0, 228, 357, 229, 230, 131, 132, 0, 359,
1433 360, 361, 0, 0, 0, 0, 231, 0, 0, 232,
1434 0, 233, 0, 0, 234, 0, 0, 0, 0, 0,
1435 0, 0, 0, 373, 374, 0, 0, 0, 0, 0,
1436 380, 0, 0, 0, 0, 46, 47, 384, 93, 153,
1437 154, 155, 156, 157, 158, 159, 160, 161, 162, 163,
1438 60, 61, 14, 0, 15, 397, 0, 0, 0, 0,
Nate Begeman848622f2005-11-05 09:21:28 +00001439 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner840f7892005-11-06 06:46:53 +00001440 0, 0, 0, 0, 62, 0, 0, 0, 0, 412,
1441 0, 0, 252, 253, 46, 47, 254, 0, 0, 0,
1442 420, 0, 0, 0, 0, 424, 0, 0, 0, 427,
1443 428, 14, 0, 15, 0, 0, 255, 256, 0, 0,
1444 0, 0, 0, 0, 0, 0, 257, 258, 0, 0,
1445 0, 0, 0, 0, 0, 0, 0, 63, 0, 0,
1446 64, 0, 0, 65, 0, 66, 296, 252, 253, 0,
1447 0, 254, 0, 0, 0, 0, 110, 111, 112, 113,
1448 114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
1449 0, 255, 256, 0, 0, 228, 0, 229, 230, 131,
1450 132, 257, 258, 0, 0, 0, 0, 0, 0, 0,
1451 0, 0, 259, 0, 0, 0, 0, 0, 0, 0,
1452 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner86c352b2005-11-06 06:34:34 +00001453 0, 110, 111, 112, 113, 114, 115, 116, 117, 118,
Chris Lattner840f7892005-11-06 06:46:53 +00001454 119, 120, 121, 122, 123, 0, 0, 0, 0, 0,
1455 228, 0, 229, 230, 131, 132, 0, 0, 0, 0,
1456 0, 0, 0, 0, 0, 46, 47, 259, 93, 49,
Chris Lattner86c352b2005-11-06 06:34:34 +00001457 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
Chris Lattner840f7892005-11-06 06:46:53 +00001458 60, 61, 14, 0, 15, 0, 0, 0, 0, 0,
1459 0, 0, 0, 0, 0, 0, 174, 0, 0, 0,
1460 0, 0, 46, 47, 62, 93, 49, 50, 51, 52,
1461 53, 54, 55, 56, 57, 58, 59, 60, 61, 14,
1462 0, 15, 0, 0, 0, 0, 0, 0, 0, 0,
1463 0, 0, 0, 245, 0, 0, 0, 0, 0, 46,
1464 47, 62, 93, 153, 154, 155, 156, 157, 158, 159,
1465 160, 161, 162, 163, 60, 61, 14, 63, 15, 0,
Chris Lattner86c352b2005-11-06 06:34:34 +00001466 64, 0, 0, 65, 0, 66, 0, 0, 0, 0,
Chris Lattner840f7892005-11-06 06:46:53 +00001467 0, 0, 0, 0, 0, 0, 46, 47, 62, 93,
1468 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
1469 59, 60, 61, 14, 63, 15, 0, 64, 0, 0,
1470 65, 0, 66, 0, 0, 0, 0, 309, 0, 0,
1471 0, 0, 0, 46, 47, 62, 93, 49, 50, 51,
1472 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
1473 14, 63, 15, 0, 64, 0, 292, 65, 0, 66,
1474 0, 0, 0, 0, 344, 0, 0, 0, 0, 0,
1475 46, 47, 62, 48, 49, 50, 51, 52, 53, 54,
1476 55, 56, 57, 58, 59, 60, 61, 14, 63, 15,
1477 0, 64, 0, 0, 65, 0, 66, 0, 0, 0,
1478 0, 0, 0, 0, 0, 0, 0, 46, 47, 62,
1479 93, 49, 50, 51, 52, 53, 54, 55, 56, 57,
1480 58, 59, 60, 61, 14, 63, 15, 0, 64, 0,
1481 0, 65, 0, 66, 0, 0, 0, 0, 0, 0,
1482 0, 0, 0, 0, 46, 47, 62, 93, 153, 154,
1483 155, 156, 157, 158, 159, 160, 161, 162, 163, 60,
1484 61, 14, 63, 15, 0, 64, 0, 0, 65, 0,
1485 66, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1486 0, 46, 47, 62, 180, 49, 50, 51, 52, 53,
1487 54, 55, 56, 57, 58, 59, 60, 61, 14, 63,
1488 15, 0, 64, 0, 0, 65, 0, 66, 0, 0,
Chris Lattner86c352b2005-11-06 06:34:34 +00001489 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner840f7892005-11-06 06:46:53 +00001490 62, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1491 0, 0, 0, 0, 0, 0, 63, 0, 0, 64,
1492 0, 0, 65, 0, 66, 0, 0, 0, 0, 0,
1493 0, 0, 0, 0, 0, 0, 100, 0, 0, 0,
1494 0, 0, 0, 0, 0, 0, 0, 101, 0, 0,
1495 0, 0, 0, 63, 0, 0, 64, 102, 103, 65,
1496 0, 66, 0, 104, 105, 106, 107, 108, 109, 110,
1497 111, 112, 113, 114, 115, 116, 117, 118, 119, 120,
1498 121, 122, 123, 124, 125, 126, 0, 0, 127, 128,
1499 129, 130, 131, 132, 133, 134, 135
Nate Begeman848622f2005-11-05 09:21:28 +00001500};
1501
1502static const short yycheck[] = { 26,
Chris Lattner840f7892005-11-06 06:46:53 +00001503 2, 40, 15, 106, 106, 23, 89, 15, 9, 168,
1504 107, 393, 30, 40, 101, 29, 98, 104, 96, 66,
1505 21, 96, 232, 233, 102, 107, 408, 102, 30, 10,
1506 11, 12, 13, 14, 15, 16, 17, 196, 197, 126,
1507 53, 23, 129, 130, 141, 53, 133, 134, 135, 259,
1508 20, 98, 139, 96, 96, 104, 4, 407, 107, 96,
1509 96, 88, 95, 106, 106, 415, 68, 104, 104, 95,
1510 40, 41, 42, 43, 101, 95, 46, 104, 95, 10,
1511 11, 12, 13, 14, 15, 16, 17, 102, 106, 32,
1512 33, 105, 107, 57, 58, 59, 60, 124, 125, 126,
1513 127, 128, 129, 130, 51, 52, 133, 134, 135, 136,
1514 137, 138, 139, 10, 11, 12, 13, 14, 15, 16,
1515 17, 102, 169, 170, 171, 100, 213, 95, 5, 6,
1516 4, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1517 17, 18, 19, 20, 21, 22, 173, 24, 48, 49,
1518 50, 22, 98, 24, 84, 85, 195, 27, 28, 4,
1519 167, 3, 4, 3, 4, 3, 4, 44, 195, 4,
1520 177, 102, 211, 3, 4, 182, 183, 3, 4, 98,
1521 24, 4, 98, 24, 211, 212, 213, 194, 101, 276,
1522 0, 101, 199, 352, 353, 55, 283, 96, 4, 4,
1523 207, 208, 209, 250, 4, 4, 289, 290, 291, 7,
1524 7, 4, 7, 96, 99, 25, 299, 300, 301, 302,
1525 97, 31, 100, 100, 96, 53, 103, 96, 105, 106,
1526 40, 41, 42, 43, 96, 96, 24, 96, 96, 35,
1527 96, 96, 24, 100, 246, 98, 98, 98, 275, 276,
1528 277, 278, 279, 336, 4, 98, 283, 21, 21, 98,
1529 267, 98, 98, 96, 96, 99, 273, 96, 53, 96,
1530 35, 358, 96, 98, 96, 96, 96, 284, 285, 96,
1531 307, 96, 98, 366, 96, 368, 369, 370, 371, 316,
1532 393, 393, 379, 96, 96, 96, 4, 21, 102, 35,
1533 21, 21, 96, 21, 331, 408, 408, 314, 315, 96,
1534 96, 100, 319, 96, 65, 99, 96, 400, 325, 326,
1535 327, 99, 99, 99, 351, 99, 99, 99, 99, 96,
1536 99, 358, 102, 21, 96, 362, 182, 183, 365, 0,
1537 0, 78, 349, 350, 78, 78, 78, 30, 194, 356,
1538 18, 98, 379, 199, 167, 20, 363, 22, 42, 24,
1539 2, 207, 208, 209, 21, 307, 31, 32, 33, 13,
1540 362, 316, 333, -1, 381, 40, 41, 42, 43, -1,
1541 -1, 46, 47, -1, -1, -1, -1, -1, -1, 54,
1542 -1, 5, 6, -1, -1, -1, -1, -1, 405, -1,
1543 -1, -1, -1, -1, -1, -1, -1, -1, 22, 416,
1544 24, -1, 26, -1, 421, -1, -1, -1, 425, 426,
1545 -1, 267, -1, 37, 38, -1, -1, 273, -1, -1,
1546 -1, -1, -1, -1, -1, -1, -1, -1, 284, 285,
Nate Begeman848622f2005-11-05 09:21:28 +00001547 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattner840f7892005-11-06 06:46:53 +00001548 -1, -1, -1, 67, 68, 69, 70, 71, 72, 73,
1549 74, 75, 76, 77, 78, 79, 80, -1, 314, 315,
1550 -1, -1, 86, 319, 88, 89, 90, 91, -1, 325,
1551 326, 327, -1, -1, -1, -1, 100, -1, -1, 103,
1552 -1, 105, -1, -1, 108, -1, -1, -1, -1, -1,
1553 -1, -1, -1, 349, 350, -1, -1, -1, -1, -1,
1554 356, -1, -1, -1, -1, 5, 6, 363, 8, 9,
Chris Lattner86c352b2005-11-06 06:34:34 +00001555 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
Chris Lattner840f7892005-11-06 06:46:53 +00001556 20, 21, 22, -1, 24, 381, -1, -1, -1, -1,
Nate Begeman848622f2005-11-05 09:21:28 +00001557 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattner840f7892005-11-06 06:46:53 +00001558 -1, -1, -1, -1, 44, -1, -1, -1, -1, 405,
1559 -1, -1, 3, 4, 5, 6, 7, -1, -1, -1,
1560 416, -1, -1, -1, -1, 421, -1, -1, -1, 425,
1561 426, 22, -1, 24, -1, -1, 27, 28, -1, -1,
1562 -1, -1, -1, -1, -1, -1, 37, 38, -1, -1,
1563 -1, -1, -1, -1, -1, -1, -1, 97, -1, -1,
1564 100, -1, -1, 103, -1, 105, 106, 3, 4, -1,
1565 -1, 7, -1, -1, -1, -1, 67, 68, 69, 70,
1566 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
1567 -1, 27, 28, -1, -1, 86, -1, 88, 89, 90,
1568 91, 37, 38, -1, -1, -1, -1, -1, -1, -1,
1569 -1, -1, 103, -1, -1, -1, -1, -1, -1, -1,
1570 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattner86c352b2005-11-06 06:34:34 +00001571 -1, 67, 68, 69, 70, 71, 72, 73, 74, 75,
Chris Lattner840f7892005-11-06 06:46:53 +00001572 76, 77, 78, 79, 80, -1, -1, -1, -1, -1,
Chris Lattner86c352b2005-11-06 06:34:34 +00001573 86, -1, 88, 89, 90, 91, -1, -1, -1, -1,
Chris Lattner840f7892005-11-06 06:46:53 +00001574 -1, -1, -1, -1, -1, 5, 6, 103, 8, 9,
1575 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
1576 20, 21, 22, -1, 24, -1, -1, -1, -1, -1,
1577 -1, -1, -1, -1, -1, -1, 36, -1, -1, -1,
1578 -1, -1, 5, 6, 44, 8, 9, 10, 11, 12,
1579 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
1580 -1, 24, -1, -1, -1, -1, -1, -1, -1, -1,
1581 -1, -1, -1, 36, -1, -1, -1, -1, -1, 5,
1582 6, 44, 8, 9, 10, 11, 12, 13, 14, 15,
1583 16, 17, 18, 19, 20, 21, 22, 97, 24, -1,
1584 100, -1, -1, 103, -1, 105, -1, -1, -1, -1,
1585 -1, -1, -1, -1, -1, -1, 5, 6, 44, 8,
1586 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
1587 19, 20, 21, 22, 97, 24, -1, 100, -1, -1,
1588 103, -1, 105, -1, -1, -1, -1, 36, -1, -1,
1589 -1, -1, -1, 5, 6, 44, 8, 9, 10, 11,
Chris Lattner86c352b2005-11-06 06:34:34 +00001590 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
Chris Lattner840f7892005-11-06 06:46:53 +00001591 22, 97, 24, -1, 100, -1, 102, 103, -1, 105,
Chris Lattner86c352b2005-11-06 06:34:34 +00001592 -1, -1, -1, -1, 36, -1, -1, -1, -1, -1,
1593 5, 6, 44, 8, 9, 10, 11, 12, 13, 14,
Chris Lattner840f7892005-11-06 06:46:53 +00001594 15, 16, 17, 18, 19, 20, 21, 22, 97, 24,
1595 -1, 100, -1, -1, 103, -1, 105, -1, -1, -1,
1596 -1, -1, -1, -1, -1, -1, -1, 5, 6, 44,
Nate Begeman848622f2005-11-05 09:21:28 +00001597 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
Chris Lattner86c352b2005-11-06 06:34:34 +00001598 18, 19, 20, 21, 22, 97, 24, -1, 100, -1,
1599 -1, 103, -1, 105, -1, -1, -1, -1, -1, -1,
1600 -1, -1, -1, -1, 5, 6, 44, 8, 9, 10,
1601 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
1602 21, 22, 97, 24, -1, 100, -1, -1, 103, -1,
Chris Lattner840f7892005-11-06 06:46:53 +00001603 105, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattner86c352b2005-11-06 06:34:34 +00001604 -1, 5, 6, 44, 8, 9, 10, 11, 12, 13,
1605 14, 15, 16, 17, 18, 19, 20, 21, 22, 97,
Chris Lattner840f7892005-11-06 06:46:53 +00001606 24, -1, 100, -1, -1, 103, -1, 105, -1, -1,
Nate Begeman848622f2005-11-05 09:21:28 +00001607 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattner840f7892005-11-06 06:46:53 +00001608 44, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1609 -1, -1, -1, -1, -1, -1, 97, -1, -1, 100,
1610 -1, -1, 103, -1, 105, -1, -1, -1, -1, -1,
1611 -1, -1, -1, -1, -1, -1, 34, -1, -1, -1,
1612 -1, -1, -1, -1, -1, -1, -1, 45, -1, -1,
1613 -1, -1, -1, 97, -1, -1, 100, 55, 56, 103,
1614 -1, 105, -1, 61, 62, 63, 64, 65, 66, 67,
1615 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
1616 78, 79, 80, 81, 82, 83, -1, -1, 86, 87,
1617 88, 89, 90, 91, 92, 93, 94
Nate Begeman848622f2005-11-05 09:21:28 +00001618};
1619/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
1620#line 3 "/usr/share/bison.simple"
1621/* This file comes from bison-1.28. */
1622
1623/* Skeleton output parser for bison,
1624 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
1625
1626 This program is free software; you can redistribute it and/or modify
1627 it under the terms of the GNU General Public License as published by
1628 the Free Software Foundation; either version 2, or (at your option)
1629 any later version.
1630
1631 This program is distributed in the hope that it will be useful,
1632 but WITHOUT ANY WARRANTY; without even the implied warranty of
1633 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1634 GNU General Public License for more details.
1635
1636 You should have received a copy of the GNU General Public License
1637 along with this program; if not, write to the Free Software
1638 Foundation, Inc., 59 Temple Place - Suite 330,
1639 Boston, MA 02111-1307, USA. */
1640
1641/* As a special exception, when this file is copied by Bison into a
1642 Bison output file, you may use that output file without restriction.
1643 This special exception was added by the Free Software Foundation
1644 in version 1.24 of Bison. */
1645
1646/* This is the parser code that is written into each bison parser
1647 when the %semantic_parser declaration is not specified in the grammar.
1648 It was written by Richard Stallman by simplifying the hairy parser
1649 used when %semantic_parser is specified. */
1650
1651#ifndef YYSTACK_USE_ALLOCA
1652#ifdef alloca
1653#define YYSTACK_USE_ALLOCA
1654#else /* alloca not defined */
1655#ifdef __GNUC__
1656#define YYSTACK_USE_ALLOCA
1657#define alloca __builtin_alloca
1658#else /* not GNU C. */
1659#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
1660#define YYSTACK_USE_ALLOCA
1661#include <alloca.h>
1662#else /* not sparc */
1663/* We think this test detects Watcom and Microsoft C. */
1664/* This used to test MSDOS, but that is a bad idea
1665 since that symbol is in the user namespace. */
1666#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
1667#if 0 /* No need for malloc.h, which pollutes the namespace;
1668 instead, just don't use alloca. */
1669#include <malloc.h>
1670#endif
1671#else /* not MSDOS, or __TURBOC__ */
1672#if defined(_AIX)
1673/* I don't know what this was needed for, but it pollutes the namespace.
1674 So I turned it off. rms, 2 May 1997. */
1675/* #include <malloc.h> */
1676 #pragma alloca
1677#define YYSTACK_USE_ALLOCA
1678#else /* not MSDOS, or __TURBOC__, or _AIX */
1679#if 0
1680#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
1681 and on HPUX 10. Eventually we can turn this on. */
1682#define YYSTACK_USE_ALLOCA
1683#define alloca __builtin_alloca
1684#endif /* __hpux */
1685#endif
1686#endif /* not _AIX */
1687#endif /* not MSDOS, or __TURBOC__ */
1688#endif /* not sparc */
1689#endif /* not GNU C */
1690#endif /* alloca not defined */
1691#endif /* YYSTACK_USE_ALLOCA not defined */
1692
1693#ifdef YYSTACK_USE_ALLOCA
1694#define YYSTACK_ALLOC alloca
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001695#else
Nate Begeman848622f2005-11-05 09:21:28 +00001696#define YYSTACK_ALLOC malloc
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001697#endif
1698
Nate Begeman848622f2005-11-05 09:21:28 +00001699/* Note: there must be only one dollar sign in this file.
1700 It is replaced by the list of actions, each action
1701 as one case of the switch. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001702
1703#define yyerrok (yyerrstatus = 0)
1704#define yyclearin (yychar = YYEMPTY)
Nate Begeman848622f2005-11-05 09:21:28 +00001705#define YYEMPTY -2
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001706#define YYEOF 0
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001707#define YYACCEPT goto yyacceptlab
Nate Begeman848622f2005-11-05 09:21:28 +00001708#define YYABORT goto yyabortlab
1709#define YYERROR goto yyerrlab1
1710/* Like YYERROR except do call yyerror.
1711 This remains here temporarily to ease the
1712 transition to the new meaning of YYERROR, for GCC.
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001713 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001714#define YYFAIL goto yyerrlab
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001715#define YYRECOVERING() (!!yyerrstatus)
Nate Begeman848622f2005-11-05 09:21:28 +00001716#define YYBACKUP(token, value) \
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001717do \
1718 if (yychar == YYEMPTY && yylen == 1) \
Nate Begeman848622f2005-11-05 09:21:28 +00001719 { yychar = (token), yylval = (value); \
1720 yychar1 = YYTRANSLATE (yychar); \
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001721 YYPOPSTACK; \
1722 goto yybackup; \
1723 } \
1724 else \
Nate Begeman848622f2005-11-05 09:21:28 +00001725 { yyerror ("syntax error: cannot back up"); YYERROR; } \
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001726while (0)
1727
1728#define YYTERROR 1
1729#define YYERRCODE 256
1730
Nate Begeman848622f2005-11-05 09:21:28 +00001731#ifndef YYPURE
1732#define YYLEX yylex()
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001733#endif
1734
Nate Begeman848622f2005-11-05 09:21:28 +00001735#ifdef YYPURE
1736#ifdef YYLSP_NEEDED
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001737#ifdef YYLEX_PARAM
Nate Begeman848622f2005-11-05 09:21:28 +00001738#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001739#else
Nate Begeman848622f2005-11-05 09:21:28 +00001740#define YYLEX yylex(&yylval, &yylloc)
1741#endif
1742#else /* not YYLSP_NEEDED */
1743#ifdef YYLEX_PARAM
1744#define YYLEX yylex(&yylval, YYLEX_PARAM)
1745#else
1746#define YYLEX yylex(&yylval)
1747#endif
1748#endif /* not YYLSP_NEEDED */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001749#endif
1750
Nate Begeman848622f2005-11-05 09:21:28 +00001751/* If nonreentrant, generate the variables here */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001752
Nate Begeman848622f2005-11-05 09:21:28 +00001753#ifndef YYPURE
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001754
Nate Begeman848622f2005-11-05 09:21:28 +00001755int yychar; /* the lookahead symbol */
1756YYSTYPE yylval; /* the semantic value of the */
1757 /* lookahead symbol */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001758
Nate Begeman848622f2005-11-05 09:21:28 +00001759#ifdef YYLSP_NEEDED
1760YYLTYPE yylloc; /* location data for the lookahead */
1761 /* symbol */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001762#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001763
Nate Begeman848622f2005-11-05 09:21:28 +00001764int yynerrs; /* number of parse errors so far */
1765#endif /* not YYPURE */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001766
Nate Begeman848622f2005-11-05 09:21:28 +00001767#if YYDEBUG != 0
1768int yydebug; /* nonzero means print parse trace */
1769/* Since this is uninitialized, it does not stop multiple parsers
1770 from coexisting. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001771#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001772
Nate Begeman848622f2005-11-05 09:21:28 +00001773/* YYINITDEPTH indicates the initial size of the parser's stacks */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001774
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001775#ifndef YYINITDEPTH
Nate Begeman848622f2005-11-05 09:21:28 +00001776#define YYINITDEPTH 200
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001777#endif
1778
Nate Begeman848622f2005-11-05 09:21:28 +00001779/* YYMAXDEPTH is the maximum size the stacks can grow to
1780 (effective only if the built-in stack extension method is used). */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001781
Nate Begeman848622f2005-11-05 09:21:28 +00001782#if YYMAXDEPTH == 0
1783#undef YYMAXDEPTH
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001784#endif
1785
1786#ifndef YYMAXDEPTH
Nate Begeman848622f2005-11-05 09:21:28 +00001787#define YYMAXDEPTH 10000
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001788#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001789
Nate Begeman848622f2005-11-05 09:21:28 +00001790/* Define __yy_memcpy. Note that the size argument
1791 should be passed with type unsigned int, because that is what the non-GCC
1792 definitions require. With GCC, __builtin_memcpy takes an arg
1793 of type size_t, but it can handle unsigned int. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001794
Nate Begeman848622f2005-11-05 09:21:28 +00001795#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
1796#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
1797#else /* not GNU C or C++ */
1798#ifndef __cplusplus
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001799
Nate Begeman848622f2005-11-05 09:21:28 +00001800/* This is the most reliable way to avoid incompatibilities
1801 in available built-in functions on various systems. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001802static void
Nate Begeman848622f2005-11-05 09:21:28 +00001803__yy_memcpy (to, from, count)
1804 char *to;
1805 char *from;
1806 unsigned int count;
1807{
1808 register char *f = from;
1809 register char *t = to;
1810 register int i = count;
1811
1812 while (i-- > 0)
1813 *t++ = *f++;
1814}
1815
1816#else /* __cplusplus */
1817
1818/* This is the most reliable way to avoid incompatibilities
1819 in available built-in functions on various systems. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001820static void
Nate Begeman848622f2005-11-05 09:21:28 +00001821__yy_memcpy (char *to, char *from, unsigned int count)
1822{
1823 register char *t = to;
1824 register char *f = from;
1825 register int i = count;
1826
1827 while (i-- > 0)
1828 *t++ = *f++;
1829}
1830
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001831#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001832#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001833
Nate Begeman848622f2005-11-05 09:21:28 +00001834#line 217 "/usr/share/bison.simple"
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001835
Nate Begeman848622f2005-11-05 09:21:28 +00001836/* The user can define YYPARSE_PARAM as the name of an argument to be passed
1837 into yyparse. The argument should have type void *.
1838 It should actually point to an object.
1839 Grammar actions can access the variable by casting it
1840 to the proper pointer type. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001841
1842#ifdef YYPARSE_PARAM
Nate Begeman848622f2005-11-05 09:21:28 +00001843#ifdef __cplusplus
1844#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
1845#define YYPARSE_PARAM_DECL
1846#else /* not __cplusplus */
1847#define YYPARSE_PARAM_ARG YYPARSE_PARAM
1848#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
1849#endif /* not __cplusplus */
1850#else /* not YYPARSE_PARAM */
1851#define YYPARSE_PARAM_ARG
1852#define YYPARSE_PARAM_DECL
1853#endif /* not YYPARSE_PARAM */
1854
1855/* Prevent warning if -Wstrict-prototypes. */
1856#ifdef __GNUC__
1857#ifdef YYPARSE_PARAM
1858int yyparse (void *);
1859#else
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001860int yyparse (void);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001861#endif
Nate Begeman848622f2005-11-05 09:21:28 +00001862#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001863
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001864int
Nate Begeman848622f2005-11-05 09:21:28 +00001865yyparse(YYPARSE_PARAM_ARG)
1866 YYPARSE_PARAM_DECL
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001867{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001868 register int yystate;
1869 register int yyn;
Nate Begeman848622f2005-11-05 09:21:28 +00001870 register short *yyssp;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001871 register YYSTYPE *yyvsp;
Nate Begeman848622f2005-11-05 09:21:28 +00001872 int yyerrstatus; /* number of tokens to shift before error messages enabled */
1873 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001874
Nate Begeman848622f2005-11-05 09:21:28 +00001875 short yyssa[YYINITDEPTH]; /* the state stack */
1876 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001877
Nate Begeman848622f2005-11-05 09:21:28 +00001878 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
1879 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001880
Nate Begeman848622f2005-11-05 09:21:28 +00001881#ifdef YYLSP_NEEDED
1882 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
1883 YYLTYPE *yyls = yylsa;
1884 YYLTYPE *yylsp;
1885
1886#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
1887#else
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001888#define YYPOPSTACK (yyvsp--, yyssp--)
Nate Begeman848622f2005-11-05 09:21:28 +00001889#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001890
Nate Begeman848622f2005-11-05 09:21:28 +00001891 int yystacksize = YYINITDEPTH;
1892 int yyfree_stacks = 0;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001893
Nate Begeman848622f2005-11-05 09:21:28 +00001894#ifdef YYPURE
1895 int yychar;
1896 YYSTYPE yylval;
1897 int yynerrs;
1898#ifdef YYLSP_NEEDED
1899 YYLTYPE yylloc;
1900#endif
1901#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001902
Nate Begeman848622f2005-11-05 09:21:28 +00001903 YYSTYPE yyval; /* the variable used to return */
1904 /* semantic values from the action */
1905 /* routines */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001906
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001907 int yylen;
1908
Nate Begeman848622f2005-11-05 09:21:28 +00001909#if YYDEBUG != 0
1910 if (yydebug)
1911 fprintf(stderr, "Starting parse\n");
1912#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001913
1914 yystate = 0;
1915 yyerrstatus = 0;
1916 yynerrs = 0;
1917 yychar = YYEMPTY; /* Cause a token to be read. */
1918
1919 /* Initialize stack pointers.
1920 Waste one element of value and location stack
1921 so that they stay on the same level as the state stack.
1922 The wasted elements are never initialized. */
1923
Nate Begeman848622f2005-11-05 09:21:28 +00001924 yyssp = yyss - 1;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001925 yyvsp = yyvs;
Nate Begeman848622f2005-11-05 09:21:28 +00001926#ifdef YYLSP_NEEDED
1927 yylsp = yyls;
1928#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001929
Nate Begeman848622f2005-11-05 09:21:28 +00001930/* Push a new state, which is found in yystate . */
1931/* In all cases, when you get here, the value and location stacks
1932 have just been pushed. so pushing a state here evens the stacks. */
1933yynewstate:
Jeff Cohen11e26b52005-10-23 04:37:20 +00001934
Nate Begeman848622f2005-11-05 09:21:28 +00001935 *++yyssp = yystate;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001936
Nate Begeman848622f2005-11-05 09:21:28 +00001937 if (yyssp >= yyss + yystacksize - 1)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001938 {
Nate Begeman848622f2005-11-05 09:21:28 +00001939 /* Give user a chance to reallocate the stack */
1940 /* Use copies of these so that the &'s don't force the real ones into memory. */
1941 YYSTYPE *yyvs1 = yyvs;
1942 short *yyss1 = yyss;
1943#ifdef YYLSP_NEEDED
1944 YYLTYPE *yyls1 = yyls;
1945#endif
1946
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001947 /* Get the current used size of the three stacks, in elements. */
Nate Begeman848622f2005-11-05 09:21:28 +00001948 int size = yyssp - yyss + 1;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001949
1950#ifdef yyoverflow
Nate Begeman848622f2005-11-05 09:21:28 +00001951 /* Each stack pointer address is followed by the size of
1952 the data in use in that stack, in bytes. */
1953#ifdef YYLSP_NEEDED
1954 /* This used to be a conditional around just the two extra args,
1955 but that might be undefined if yyoverflow is a macro. */
1956 yyoverflow("parser stack overflow",
1957 &yyss1, size * sizeof (*yyssp),
1958 &yyvs1, size * sizeof (*yyvsp),
1959 &yyls1, size * sizeof (*yylsp),
1960 &yystacksize);
1961#else
1962 yyoverflow("parser stack overflow",
1963 &yyss1, size * sizeof (*yyssp),
1964 &yyvs1, size * sizeof (*yyvsp),
1965 &yystacksize);
1966#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001967
Nate Begeman848622f2005-11-05 09:21:28 +00001968 yyss = yyss1; yyvs = yyvs1;
1969#ifdef YYLSP_NEEDED
1970 yyls = yyls1;
1971#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001972#else /* no yyoverflow */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001973 /* Extend the stack our own way. */
Nate Begeman848622f2005-11-05 09:21:28 +00001974 if (yystacksize >= YYMAXDEPTH)
1975 {
1976 yyerror("parser stack overflow");
1977 if (yyfree_stacks)
1978 {
1979 free (yyss);
1980 free (yyvs);
1981#ifdef YYLSP_NEEDED
1982 free (yyls);
1983#endif
1984 }
1985 return 2;
1986 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001987 yystacksize *= 2;
Nate Begeman848622f2005-11-05 09:21:28 +00001988 if (yystacksize > YYMAXDEPTH)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001989 yystacksize = YYMAXDEPTH;
Nate Begeman848622f2005-11-05 09:21:28 +00001990#ifndef YYSTACK_USE_ALLOCA
1991 yyfree_stacks = 1;
1992#endif
1993 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
1994 __yy_memcpy ((char *)yyss, (char *)yyss1,
1995 size * (unsigned int) sizeof (*yyssp));
1996 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
1997 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
1998 size * (unsigned int) sizeof (*yyvsp));
1999#ifdef YYLSP_NEEDED
2000 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
2001 __yy_memcpy ((char *)yyls, (char *)yyls1,
2002 size * (unsigned int) sizeof (*yylsp));
2003#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002004#endif /* no yyoverflow */
2005
Nate Begeman848622f2005-11-05 09:21:28 +00002006 yyssp = yyss + size - 1;
2007 yyvsp = yyvs + size - 1;
2008#ifdef YYLSP_NEEDED
2009 yylsp = yyls + size - 1;
2010#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002011
Nate Begeman848622f2005-11-05 09:21:28 +00002012#if YYDEBUG != 0
2013 if (yydebug)
2014 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2015#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002016
Nate Begeman848622f2005-11-05 09:21:28 +00002017 if (yyssp >= yyss + yystacksize - 1)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002018 YYABORT;
2019 }
2020
Nate Begeman848622f2005-11-05 09:21:28 +00002021#if YYDEBUG != 0
2022 if (yydebug)
2023 fprintf(stderr, "Entering state %d\n", yystate);
2024#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002025
2026 goto yybackup;
Nate Begeman848622f2005-11-05 09:21:28 +00002027 yybackup:
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002028
2029/* Do appropriate processing given the current state. */
2030/* Read a lookahead token if we need one and don't already have one. */
2031/* yyresume: */
2032
2033 /* First try to decide what to do without reference to lookahead token. */
2034
2035 yyn = yypact[yystate];
Nate Begeman848622f2005-11-05 09:21:28 +00002036 if (yyn == YYFLAG)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002037 goto yydefault;
2038
2039 /* Not known => get a lookahead token if don't already have one. */
2040
Nate Begeman848622f2005-11-05 09:21:28 +00002041 /* yychar is either YYEMPTY or YYEOF
2042 or a valid token in external form. */
2043
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002044 if (yychar == YYEMPTY)
2045 {
Nate Begeman848622f2005-11-05 09:21:28 +00002046#if YYDEBUG != 0
2047 if (yydebug)
2048 fprintf(stderr, "Reading a token: ");
2049#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002050 yychar = YYLEX;
2051 }
2052
Nate Begeman848622f2005-11-05 09:21:28 +00002053 /* Convert token to internal form (in yychar1) for indexing tables with */
2054
2055 if (yychar <= 0) /* This means end of input. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002056 {
Nate Begeman848622f2005-11-05 09:21:28 +00002057 yychar1 = 0;
2058 yychar = YYEOF; /* Don't call YYLEX any more */
2059
2060#if YYDEBUG != 0
2061 if (yydebug)
2062 fprintf(stderr, "Now at end of input.\n");
2063#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002064 }
2065 else
2066 {
Nate Begeman848622f2005-11-05 09:21:28 +00002067 yychar1 = YYTRANSLATE(yychar);
2068
2069#if YYDEBUG != 0
2070 if (yydebug)
2071 {
2072 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2073 /* Give the individual parser a way to print the precise meaning
2074 of a token, for further debugging info. */
2075#ifdef YYPRINT
2076 YYPRINT (stderr, yychar, yylval);
2077#endif
2078 fprintf (stderr, ")\n");
2079 }
2080#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002081 }
2082
Nate Begeman848622f2005-11-05 09:21:28 +00002083 yyn += yychar1;
2084 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002085 goto yydefault;
Nate Begeman848622f2005-11-05 09:21:28 +00002086
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002087 yyn = yytable[yyn];
Nate Begeman848622f2005-11-05 09:21:28 +00002088
2089 /* yyn is what to do for this token type in this state.
2090 Negative => reduce, -yyn is rule number.
2091 Positive => shift, yyn is new state.
2092 New state is final state => don't bother to shift,
2093 just return success.
2094 0, or most negative number => error. */
2095
2096 if (yyn < 0)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002097 {
Nate Begeman848622f2005-11-05 09:21:28 +00002098 if (yyn == YYFLAG)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002099 goto yyerrlab;
2100 yyn = -yyn;
2101 goto yyreduce;
2102 }
Nate Begeman848622f2005-11-05 09:21:28 +00002103 else if (yyn == 0)
2104 goto yyerrlab;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002105
2106 if (yyn == YYFINAL)
2107 YYACCEPT;
2108
2109 /* Shift the lookahead token. */
Nate Begeman848622f2005-11-05 09:21:28 +00002110
2111#if YYDEBUG != 0
2112 if (yydebug)
2113 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2114#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002115
2116 /* Discard the token being shifted unless it is eof. */
2117 if (yychar != YYEOF)
2118 yychar = YYEMPTY;
2119
2120 *++yyvsp = yylval;
Nate Begeman848622f2005-11-05 09:21:28 +00002121#ifdef YYLSP_NEEDED
2122 *++yylsp = yylloc;
2123#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002124
Nate Begeman848622f2005-11-05 09:21:28 +00002125 /* count tokens shifted since error; after three, turn off error status. */
2126 if (yyerrstatus) yyerrstatus--;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002127
2128 yystate = yyn;
2129 goto yynewstate;
2130
Nate Begeman848622f2005-11-05 09:21:28 +00002131/* Do the default action for the current state. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002132yydefault:
Nate Begeman848622f2005-11-05 09:21:28 +00002133
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002134 yyn = yydefact[yystate];
2135 if (yyn == 0)
2136 goto yyerrlab;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002137
Nate Begeman848622f2005-11-05 09:21:28 +00002138/* Do a reduction. yyn is the number of a rule to reduce with. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002139yyreduce:
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002140 yylen = yyr2[yyn];
Nate Begeman848622f2005-11-05 09:21:28 +00002141 if (yylen > 0)
2142 yyval = yyvsp[1-yylen]; /* implement default value of the action */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002143
Nate Begeman848622f2005-11-05 09:21:28 +00002144#if YYDEBUG != 0
2145 if (yydebug)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002146 {
Nate Begeman848622f2005-11-05 09:21:28 +00002147 int i;
2148
2149 fprintf (stderr, "Reducing via rule %d (line %d), ",
2150 yyn, yyrline[yyn]);
2151
2152 /* Print the symbols being reduced, and their result. */
2153 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2154 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2155 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2156 }
2157#endif
2158
2159
2160 switch (yyn) {
2161
2162case 2:
Chris Lattner840f7892005-11-06 06:46:53 +00002163#line 991 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002164{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002165 if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX) // Outside of my range!
2166 ThrowException("Value too large for type!");
2167 yyval.SIntVal = (int32_t)yyvsp[0].UIntVal;
Nate Begeman848622f2005-11-05 09:21:28 +00002168;
2169 break;}
2170case 4:
Chris Lattner840f7892005-11-06 06:46:53 +00002171#line 999 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002172{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002173 if (yyvsp[0].UInt64Val > (uint64_t)INT64_MAX) // Outside of my range!
2174 ThrowException("Value too large for type!");
2175 yyval.SInt64Val = (int64_t)yyvsp[0].UInt64Val;
Nate Begeman848622f2005-11-05 09:21:28 +00002176;
2177 break;}
2178case 33:
Chris Lattner840f7892005-11-06 06:46:53 +00002179#line 1022 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002180{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002181 yyval.StrVal = yyvsp[-1].StrVal;
Nate Begeman848622f2005-11-05 09:21:28 +00002182 ;
2183 break;}
2184case 34:
Chris Lattner840f7892005-11-06 06:46:53 +00002185#line 1025 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002186{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002187 yyval.StrVal = 0;
Nate Begeman848622f2005-11-05 09:21:28 +00002188 ;
2189 break;}
2190case 35:
Chris Lattner840f7892005-11-06 06:46:53 +00002191#line 1029 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002192{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2193 break;}
2194case 36:
Chris Lattner840f7892005-11-06 06:46:53 +00002195#line 1030 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002196{ yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2197 break;}
2198case 37:
Chris Lattner840f7892005-11-06 06:46:53 +00002199#line 1031 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002200{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2201 break;}
2202case 38:
Chris Lattner840f7892005-11-06 06:46:53 +00002203#line 1032 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002204{ yyval.Linkage = GlobalValue::AppendingLinkage; ;
2205 break;}
2206case 39:
Chris Lattner840f7892005-11-06 06:46:53 +00002207#line 1033 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002208{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2209 break;}
2210case 40:
Chris Lattner840f7892005-11-06 06:46:53 +00002211#line 1035 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002212{ yyval.UIntVal = CallingConv::C; ;
2213 break;}
2214case 41:
Chris Lattner840f7892005-11-06 06:46:53 +00002215#line 1036 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002216{ yyval.UIntVal = CallingConv::C; ;
2217 break;}
2218case 42:
Chris Lattner840f7892005-11-06 06:46:53 +00002219#line 1037 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002220{ yyval.UIntVal = CallingConv::Fast; ;
2221 break;}
2222case 43:
Chris Lattner840f7892005-11-06 06:46:53 +00002223#line 1038 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002224{ yyval.UIntVal = CallingConv::Cold; ;
2225 break;}
2226case 44:
Chris Lattner840f7892005-11-06 06:46:53 +00002227#line 1039 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002228{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002229 if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
2230 ThrowException("Calling conv too large!");
2231 yyval.UIntVal = yyvsp[0].UInt64Val;
Nate Begeman848622f2005-11-05 09:21:28 +00002232 ;
2233 break;}
Chris Lattner86c352b2005-11-06 06:34:34 +00002234case 45:
Chris Lattner840f7892005-11-06 06:46:53 +00002235#line 1047 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner86c352b2005-11-06 06:34:34 +00002236{ yyval.UIntVal = 0; ;
2237 break;}
Nate Begeman848622f2005-11-05 09:21:28 +00002238case 46:
Chris Lattner840f7892005-11-06 06:46:53 +00002239#line 1048 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner86c352b2005-11-06 06:34:34 +00002240{ yyval.UIntVal = yyvsp[0].UInt64Val; ;
Nate Begeman848622f2005-11-05 09:21:28 +00002241 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002242case 47:
2243#line 1049 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2244{ yyval.UIntVal = 0; ;
2245 break;}
Nate Begeman848622f2005-11-05 09:21:28 +00002246case 48:
Chris Lattner86c352b2005-11-06 06:34:34 +00002247#line 1050 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner840f7892005-11-06 06:46:53 +00002248{ yyval.UIntVal = yyvsp[0].UInt64Val; ;
Nate Begeman848622f2005-11-05 09:21:28 +00002249 break;}
Chris Lattner86c352b2005-11-06 06:34:34 +00002250case 50:
Chris Lattner840f7892005-11-06 06:46:53 +00002251#line 1059 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner86c352b2005-11-06 06:34:34 +00002252{ yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2253 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002254case 52:
2255#line 1060 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2256{ yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2257 break;}
2258case 53:
2259#line 1062 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002260{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002261 if (!UpRefs.empty())
2262 ThrowException("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
2263 yyval.TypeVal = yyvsp[0].TypeVal;
Nate Begeman848622f2005-11-05 09:21:28 +00002264 ;
2265 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002266case 67:
2267#line 1073 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002268{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002269 yyval.TypeVal = new PATypeHolder(OpaqueType::get());
Nate Begeman848622f2005-11-05 09:21:28 +00002270 ;
2271 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002272case 68:
2273#line 1076 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002274{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002275 yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
Nate Begeman848622f2005-11-05 09:21:28 +00002276 ;
2277 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002278case 69:
2279#line 1079 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002280{ // Named types are also simple types...
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002281 yyval.TypeVal = new PATypeHolder(getTypeVal(yyvsp[0].ValIDVal));
Nate Begeman848622f2005-11-05 09:21:28 +00002282;
2283 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002284case 70:
2285#line 1085 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002286{ // Type UpReference
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002287 if (yyvsp[0].UInt64Val > (uint64_t)~0U) ThrowException("Value out of range!");
2288 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
2289 UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector...
2290 yyval.TypeVal = new PATypeHolder(OT);
2291 UR_OUT("New Upreference!\n");
Nate Begeman848622f2005-11-05 09:21:28 +00002292 ;
2293 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002294case 71:
2295#line 1092 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002296{ // Function derived type?
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002297 std::vector<const Type*> Params;
2298 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2299 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2300 Params.push_back(*I);
2301 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
2302 if (isVarArg) Params.pop_back();
2303
2304 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FunctionType::get(*yyvsp[-3].TypeVal,Params,isVarArg)));
2305 delete yyvsp[-1].TypeList; // Delete the argument list
2306 delete yyvsp[-3].TypeVal; // Delete the return type handle
Nate Begeman848622f2005-11-05 09:21:28 +00002307 ;
2308 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002309case 72:
2310#line 1104 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002311{ // Sized array type?
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002312 yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2313 delete yyvsp[-1].TypeVal;
Nate Begeman848622f2005-11-05 09:21:28 +00002314 ;
2315 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002316case 73:
2317#line 1108 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002318{ // Packed array type?
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002319 const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
2320 if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val) {
2321 ThrowException("Unsigned result not equal to signed result");
2322 }
2323 if(!ElemTy->isPrimitiveType()) {
2324 ThrowException("Elemental type of a PackedType must be primitive");
2325 }
2326 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PackedType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2327 delete yyvsp[-1].TypeVal;
Nate Begeman848622f2005-11-05 09:21:28 +00002328 ;
2329 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002330case 74:
2331#line 1119 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002332{ // Structure type?
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002333 std::vector<const Type*> Elements;
2334 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2335 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2336 Elements.push_back(*I);
2337
2338 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
2339 delete yyvsp[-1].TypeList;
Nate Begeman848622f2005-11-05 09:21:28 +00002340 ;
2341 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002342case 75:
2343#line 1128 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002344{ // Empty structure type?
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002345 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Nate Begeman848622f2005-11-05 09:21:28 +00002346 ;
2347 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002348case 76:
2349#line 1131 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002350{ // Pointer type?
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002351 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal)));
2352 delete yyvsp[-1].TypeVal;
Nate Begeman848622f2005-11-05 09:21:28 +00002353 ;
2354 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002355case 77:
2356#line 1139 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002357{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002358 yyval.TypeList = new std::list<PATypeHolder>();
2359 yyval.TypeList->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
Nate Begeman848622f2005-11-05 09:21:28 +00002360 ;
2361 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002362case 78:
2363#line 1143 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002364{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002365 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
Nate Begeman848622f2005-11-05 09:21:28 +00002366 ;
2367 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002368case 80:
2369#line 1149 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002370{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002371 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(Type::VoidTy);
Nate Begeman848622f2005-11-05 09:21:28 +00002372 ;
2373 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002374case 81:
2375#line 1152 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002376{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002377 (yyval.TypeList = new std::list<PATypeHolder>())->push_back(Type::VoidTy);
Nate Begeman848622f2005-11-05 09:21:28 +00002378 ;
2379 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002380case 82:
2381#line 1155 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002382{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002383 yyval.TypeList = new std::list<PATypeHolder>();
Nate Begeman848622f2005-11-05 09:21:28 +00002384 ;
2385 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002386case 83:
2387#line 1165 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002388{ // Nonempty unsized arr
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002389 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
2390 if (ATy == 0)
2391 ThrowException("Cannot make array constant with type: '" +
2392 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2393 const Type *ETy = ATy->getElementType();
2394 int NumElements = ATy->getNumElements();
2395
2396 // Verify that we have the correct size...
2397 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2398 ThrowException("Type mismatch: constant sized array initialized with " +
2399 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
2400 itostr(NumElements) + "!");
2401
2402 // Verify all elements are correct type!
2403 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2404 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2405 ThrowException("Element #" + utostr(i) + " is not of type '" +
2406 ETy->getDescription() +"' as required!\nIt is of type '"+
2407 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2408 }
2409
2410 yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
2411 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Nate Begeman848622f2005-11-05 09:21:28 +00002412 ;
2413 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002414case 84:
2415#line 1190 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002416{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002417 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2418 if (ATy == 0)
2419 ThrowException("Cannot make array constant with type: '" +
2420 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2421
2422 int NumElements = ATy->getNumElements();
2423 if (NumElements != -1 && NumElements != 0)
2424 ThrowException("Type mismatch: constant sized array initialized with 0"
2425 " arguments, but has size of " + itostr(NumElements) +"!");
2426 yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
2427 delete yyvsp[-2].TypeVal;
Nate Begeman848622f2005-11-05 09:21:28 +00002428 ;
2429 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002430case 85:
2431#line 1203 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002432{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002433 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2434 if (ATy == 0)
2435 ThrowException("Cannot make array constant with type: '" +
2436 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2437
2438 int NumElements = ATy->getNumElements();
2439 const Type *ETy = ATy->getElementType();
2440 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
2441 if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal))
2442 ThrowException("Can't build string constant of size " +
2443 itostr((int)(EndStr-yyvsp[0].StrVal)) +
2444 " when array has size " + itostr(NumElements) + "!");
2445 std::vector<Constant*> Vals;
2446 if (ETy == Type::SByteTy) {
2447 for (char *C = yyvsp[0].StrVal; C != EndStr; ++C)
2448 Vals.push_back(ConstantSInt::get(ETy, *C));
2449 } else if (ETy == Type::UByteTy) {
2450 for (char *C = yyvsp[0].StrVal; C != EndStr; ++C)
2451 Vals.push_back(ConstantUInt::get(ETy, (unsigned char)*C));
2452 } else {
2453 free(yyvsp[0].StrVal);
2454 ThrowException("Cannot build string arrays of non byte sized elements!");
2455 }
2456 free(yyvsp[0].StrVal);
2457 yyval.ConstVal = ConstantArray::get(ATy, Vals);
2458 delete yyvsp[-2].TypeVal;
Nate Begeman848622f2005-11-05 09:21:28 +00002459 ;
2460 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002461case 86:
2462#line 1231 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002463{ // Nonempty unsized arr
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002464 const PackedType *PTy = dyn_cast<PackedType>(yyvsp[-3].TypeVal->get());
2465 if (PTy == 0)
2466 ThrowException("Cannot make packed constant with type: '" +
2467 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2468 const Type *ETy = PTy->getElementType();
2469 int NumElements = PTy->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 packed 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 = ConstantPacked::get(PTy, *yyvsp[-1].ConstVector);
2486 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Nate Begeman848622f2005-11-05 09:21:28 +00002487 ;
2488 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002489case 87:
2490#line 1256 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002491{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002492 const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
2493 if (STy == 0)
2494 ThrowException("Cannot make struct constant with type: '" +
2495 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2496
2497 if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
2498 ThrowException("Illegal number of initializers for structure type!");
2499
2500 // Check to ensure that constants are compatible with the type initializer!
2501 for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
2502 if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
2503 ThrowException("Expected type '" +
2504 STy->getElementType(i)->getDescription() +
2505 "' for element #" + utostr(i) +
2506 " of structure initializer!");
2507
2508 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
2509 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Nate Begeman848622f2005-11-05 09:21:28 +00002510 ;
2511 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002512case 88:
2513#line 1276 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002514{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002515 const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
2516 if (STy == 0)
2517 ThrowException("Cannot make struct constant with type: '" +
2518 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2519
2520 if (STy->getNumContainedTypes() != 0)
2521 ThrowException("Illegal number of initializers for structure type!");
2522
2523 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
2524 delete yyvsp[-2].TypeVal;
Nate Begeman848622f2005-11-05 09:21:28 +00002525 ;
2526 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002527case 89:
2528#line 1288 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002529{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002530 const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
2531 if (PTy == 0)
2532 ThrowException("Cannot make null pointer constant with type: '" +
2533 (*yyvsp[-1].TypeVal)->getDescription() + "'!");
2534
2535 yyval.ConstVal = ConstantPointerNull::get(PTy);
2536 delete yyvsp[-1].TypeVal;
Nate Begeman848622f2005-11-05 09:21:28 +00002537 ;
2538 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002539case 90:
2540#line 1297 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002541{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002542 yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
2543 delete yyvsp[-1].TypeVal;
Nate Begeman848622f2005-11-05 09:21:28 +00002544 ;
2545 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002546case 91:
2547#line 1301 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002548{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002549 const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
2550 if (Ty == 0)
2551 ThrowException("Global const reference must be a pointer type!");
2552
2553 // ConstExprs can exist in the body of a function, thus creating
2554 // GlobalValues whenever they refer to a variable. Because we are in
2555 // the context of a function, getValNonImprovising will search the functions
2556 // symbol table instead of the module symbol table for the global symbol,
2557 // which throws things all off. To get around this, we just tell
2558 // getValNonImprovising that we are at global scope here.
2559 //
2560 Function *SavedCurFn = CurFun.CurrentFunction;
2561 CurFun.CurrentFunction = 0;
2562
2563 Value *V = getValNonImprovising(Ty, yyvsp[0].ValIDVal);
2564
2565 CurFun.CurrentFunction = SavedCurFn;
2566
2567 // If this is an initializer for a constant pointer, which is referencing a
2568 // (currently) undefined variable, create a stub now that shall be replaced
2569 // in the future with the right type of variable.
2570 //
2571 if (V == 0) {
2572 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
2573 const PointerType *PT = cast<PointerType>(Ty);
2574
2575 // First check to see if the forward references value is already created!
2576 PerModuleInfo::GlobalRefsType::iterator I =
2577 CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
2578
2579 if (I != CurModule.GlobalRefs.end()) {
2580 V = I->second; // Placeholder already exists, use it...
2581 yyvsp[0].ValIDVal.destroy();
2582 } else {
2583 std::string Name;
2584 if (yyvsp[0].ValIDVal.Type == ValID::NameVal) Name = yyvsp[0].ValIDVal.Name;
2585
2586 // Create the forward referenced global.
2587 GlobalValue *GV;
2588 if (const FunctionType *FTy =
2589 dyn_cast<FunctionType>(PT->getElementType())) {
2590 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
2591 CurModule.CurrentModule);
2592 } else {
2593 GV = new GlobalVariable(PT->getElementType(), false,
2594 GlobalValue::ExternalLinkage, 0,
2595 Name, CurModule.CurrentModule);
2596 }
2597
2598 // Keep track of the fact that we have a forward ref to recycle it
2599 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
2600 V = GV;
2601 }
2602 }
2603
2604 yyval.ConstVal = cast<GlobalValue>(V);
2605 delete yyvsp[-1].TypeVal; // Free the type handle
Nate Begeman848622f2005-11-05 09:21:28 +00002606 ;
2607 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002608case 92:
2609#line 1360 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002610{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002611 if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
2612 ThrowException("Mismatched types for constant expression!");
2613 yyval.ConstVal = yyvsp[0].ConstVal;
2614 delete yyvsp[-1].TypeVal;
Nate Begeman848622f2005-11-05 09:21:28 +00002615 ;
2616 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002617case 93:
2618#line 1366 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002619{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002620 const Type *Ty = yyvsp[-1].TypeVal->get();
2621 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
2622 ThrowException("Cannot create a null initialized value of this type!");
2623 yyval.ConstVal = Constant::getNullValue(Ty);
2624 delete yyvsp[-1].TypeVal;
Nate Begeman848622f2005-11-05 09:21:28 +00002625 ;
2626 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002627case 94:
2628#line 1374 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002629{ // integral constants
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002630 if (!ConstantSInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
2631 ThrowException("Constant value doesn't fit in type!");
2632 yyval.ConstVal = ConstantSInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val);
Nate Begeman848622f2005-11-05 09:21:28 +00002633 ;
2634 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002635case 95:
2636#line 1379 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002637{ // integral constants
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002638 if (!ConstantUInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
2639 ThrowException("Constant value doesn't fit in type!");
2640 yyval.ConstVal = ConstantUInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val);
Nate Begeman848622f2005-11-05 09:21:28 +00002641 ;
2642 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002643case 96:
2644#line 1384 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002645{ // Boolean constants
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002646 yyval.ConstVal = ConstantBool::True;
Nate Begeman848622f2005-11-05 09:21:28 +00002647 ;
2648 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002649case 97:
2650#line 1387 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002651{ // Boolean constants
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002652 yyval.ConstVal = ConstantBool::False;
Nate Begeman848622f2005-11-05 09:21:28 +00002653 ;
2654 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002655case 98:
2656#line 1390 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002657{ // Float & Double constants
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002658 if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal))
2659 ThrowException("Floating point constant invalid for type!!");
2660 yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal);
Nate Begeman848622f2005-11-05 09:21:28 +00002661 ;
2662 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002663case 99:
2664#line 1397 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002665{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002666 if (!yyvsp[-3].ConstVal->getType()->isFirstClassType())
2667 ThrowException("cast constant expression from a non-primitive type: '" +
2668 yyvsp[-3].ConstVal->getType()->getDescription() + "'!");
2669 if (!yyvsp[-1].TypeVal->get()->isFirstClassType())
2670 ThrowException("cast constant expression to a non-primitive type: '" +
2671 yyvsp[-1].TypeVal->get()->getDescription() + "'!");
2672 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-3].ConstVal, yyvsp[-1].TypeVal->get());
2673 delete yyvsp[-1].TypeVal;
Nate Begeman848622f2005-11-05 09:21:28 +00002674 ;
2675 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002676case 100:
2677#line 1407 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002678{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002679 if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
2680 ThrowException("GetElementPtr requires a pointer operand!");
2681
2682 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
2683 // indices to uint struct indices for compatibility.
2684 generic_gep_type_iterator<std::vector<Value*>::iterator>
2685 GTI = gep_type_begin(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end()),
2686 GTE = gep_type_end(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end());
2687 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
2688 if (isa<StructType>(*GTI)) // Only change struct indices
2689 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[-1].ValueList)[i]))
2690 if (CUI->getType() == Type::UByteTy)
2691 (*yyvsp[-1].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
2692
2693 const Type *IdxTy =
2694 GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), *yyvsp[-1].ValueList, true);
2695 if (!IdxTy)
2696 ThrowException("Index list invalid for constant getelementptr!");
2697
2698 std::vector<Constant*> IdxVec;
2699 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
2700 if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
2701 IdxVec.push_back(C);
2702 else
2703 ThrowException("Indices to constant getelementptr must be constants!");
2704
2705 delete yyvsp[-1].ValueList;
2706
2707 yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, IdxVec);
Nate Begeman848622f2005-11-05 09:21:28 +00002708 ;
2709 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002710case 101:
2711#line 1438 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002712{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002713 if (yyvsp[-5].ConstVal->getType() != Type::BoolTy)
2714 ThrowException("Select condition must be of boolean type!");
2715 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2716 ThrowException("Select operand types must match!");
2717 yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Nate Begeman848622f2005-11-05 09:21:28 +00002718 ;
2719 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002720case 102:
2721#line 1445 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002722{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002723 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2724 ThrowException("Binary operator types must match!");
2725 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
2726 // To retain backward compatibility with these early compilers, we emit a
2727 // cast to the appropriate integer type automatically if we are in the
2728 // broken case. See PR424 for more information.
2729 if (!isa<PointerType>(yyvsp[-3].ConstVal->getType())) {
2730 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2731 } else {
2732 const Type *IntPtrTy = 0;
2733 switch (CurModule.CurrentModule->getPointerSize()) {
2734 case Module::Pointer32: IntPtrTy = Type::IntTy; break;
2735 case Module::Pointer64: IntPtrTy = Type::LongTy; break;
2736 default: ThrowException("invalid pointer binary constant expr!");
2737 }
2738 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, ConstantExpr::getCast(yyvsp[-3].ConstVal, IntPtrTy),
2739 ConstantExpr::getCast(yyvsp[-1].ConstVal, IntPtrTy));
2740 yyval.ConstVal = ConstantExpr::getCast(yyval.ConstVal, yyvsp[-3].ConstVal->getType());
2741 }
Nate Begeman848622f2005-11-05 09:21:28 +00002742 ;
2743 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002744case 103:
2745#line 1466 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002746{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002747 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2748 ThrowException("Logical operator types must match!");
2749 if (!yyvsp[-3].ConstVal->getType()->isIntegral())
2750 ThrowException("Logical operands must have integral types!");
2751 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Nate Begeman848622f2005-11-05 09:21:28 +00002752 ;
2753 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002754case 104:
2755#line 1473 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002756{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002757 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2758 ThrowException("setcc operand types must match!");
2759 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Nate Begeman848622f2005-11-05 09:21:28 +00002760 ;
2761 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002762case 105:
2763#line 1478 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002764{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002765 if (yyvsp[-1].ConstVal->getType() != Type::UByteTy)
2766 ThrowException("Shift count for shift constant must be unsigned byte!");
2767 if (!yyvsp[-3].ConstVal->getType()->isInteger())
2768 ThrowException("Shift constant expression requires integer operand!");
2769 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].OtherOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Nate Begeman848622f2005-11-05 09:21:28 +00002770 ;
2771 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002772case 106:
2773#line 1488 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002774{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002775 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
Nate Begeman848622f2005-11-05 09:21:28 +00002776 ;
2777 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002778case 107:
2779#line 1491 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002780{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002781 yyval.ConstVector = new std::vector<Constant*>();
2782 yyval.ConstVector->push_back(yyvsp[0].ConstVal);
Nate Begeman848622f2005-11-05 09:21:28 +00002783 ;
2784 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002785case 108:
2786#line 1498 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002787{ yyval.BoolVal = false; ;
2788 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002789case 109:
2790#line 1498 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002791{ yyval.BoolVal = true; ;
2792 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002793case 110:
2794#line 1508 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002795{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002796 yyval.ModuleVal = ParserResult = yyvsp[0].ModuleVal;
2797 CurModule.ModuleDone();
Nate Begeman848622f2005-11-05 09:21:28 +00002798;
2799 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002800case 111:
2801#line 1515 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002802{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002803 yyval.ModuleVal = yyvsp[-1].ModuleVal;
2804 CurFun.FunctionDone();
Nate Begeman848622f2005-11-05 09:21:28 +00002805 ;
2806 break;}
Chris Lattner86c352b2005-11-06 06:34:34 +00002807case 112:
Chris Lattner840f7892005-11-06 06:46:53 +00002808#line 1519 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2809{
2810 yyval.ModuleVal = yyvsp[-1].ModuleVal;
2811 ;
2812 break;}
2813case 113:
2814#line 1522 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2815{
2816 yyval.ModuleVal = yyvsp[-1].ModuleVal;
2817 ;
2818 break;}
2819case 114:
2820#line 1525 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002821{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002822 yyval.ModuleVal = CurModule.CurrentModule;
2823 // Emit an error if there are any unresolved types left.
2824 if (!CurModule.LateResolveTypes.empty()) {
2825 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
2826 if (DID.Type == ValID::NameVal)
2827 ThrowException("Reference to an undefined type: '"+DID.getName() + "'");
2828 else
2829 ThrowException("Reference to an undefined type: #" + itostr(DID.Num));
2830 }
Nate Begeman848622f2005-11-05 09:21:28 +00002831 ;
2832 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002833case 115:
2834#line 1538 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002835{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002836 // Eagerly resolve types. This is not an optimization, this is a
2837 // requirement that is due to the fact that we could have this:
2838 //
2839 // %list = type { %list * }
2840 // %list = type { %list * } ; repeated type decl
2841 //
2842 // If types are not resolved eagerly, then the two types will not be
2843 // determined to be the same type!
2844 //
2845 ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
2846
2847 if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
2848 // If this is a named type that is not a redefinition, add it to the slot
2849 // table.
2850 CurModule.Types.push_back(*yyvsp[0].TypeVal);
2851 }
2852
2853 delete yyvsp[0].TypeVal;
Nate Begeman848622f2005-11-05 09:21:28 +00002854 ;
2855 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002856case 116:
2857#line 1558 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002858{ // Function prototypes can be in const pool
2859 ;
2860 break;}
Nate Begeman848622f2005-11-05 09:21:28 +00002861case 117:
Chris Lattner840f7892005-11-06 06:46:53 +00002862#line 1560 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2863{
2864 if (yyvsp[-1].ConstVal == 0) ThrowException("Global value initializer is not a constant!");
2865 ParseGlobalVariable(yyvsp[-4].StrVal, yyvsp[-3].Linkage, yyvsp[-2].BoolVal, yyvsp[-1].ConstVal->getType(), yyvsp[-1].ConstVal, yyvsp[0].UIntVal);
Nate Begeman848622f2005-11-05 09:21:28 +00002866 ;
2867 break;}
2868case 118:
Chris Lattner840f7892005-11-06 06:46:53 +00002869#line 1564 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner86c352b2005-11-06 06:34:34 +00002870{
Chris Lattner840f7892005-11-06 06:46:53 +00002871 ParseGlobalVariable(yyvsp[-4].StrVal, GlobalValue::ExternalLinkage, yyvsp[-2].BoolVal, *yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
2872 delete yyvsp[-1].TypeVal;
Chris Lattner86c352b2005-11-06 06:34:34 +00002873 ;
Nate Begeman848622f2005-11-05 09:21:28 +00002874 break;}
2875case 119:
Chris Lattner840f7892005-11-06 06:46:53 +00002876#line 1568 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner86c352b2005-11-06 06:34:34 +00002877{
2878 ;
Nate Begeman848622f2005-11-05 09:21:28 +00002879 break;}
2880case 120:
Chris Lattner840f7892005-11-06 06:46:53 +00002881#line 1570 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2882{
2883 ;
Chris Lattner86c352b2005-11-06 06:34:34 +00002884 break;}
2885case 121:
Chris Lattner840f7892005-11-06 06:46:53 +00002886#line 1572 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2887{
2888 ;
Chris Lattner86c352b2005-11-06 06:34:34 +00002889 break;}
2890case 122:
Chris Lattner840f7892005-11-06 06:46:53 +00002891#line 1577 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2892{ yyval.Endianness = Module::BigEndian; ;
2893 break;}
2894case 123:
2895#line 1578 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2896{ yyval.Endianness = Module::LittleEndian; ;
2897 break;}
2898case 124:
2899#line 1580 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002900{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002901 CurModule.CurrentModule->setEndianness(yyvsp[0].Endianness);
Nate Begeman848622f2005-11-05 09:21:28 +00002902 ;
2903 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002904case 125:
2905#line 1583 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002906{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002907 if (yyvsp[0].UInt64Val == 32)
2908 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
2909 else if (yyvsp[0].UInt64Val == 64)
2910 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
2911 else
2912 ThrowException("Invalid pointer size: '" + utostr(yyvsp[0].UInt64Val) + "'!");
Nate Begeman848622f2005-11-05 09:21:28 +00002913 ;
2914 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002915case 126:
2916#line 1591 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002917{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002918 CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal);
2919 free(yyvsp[0].StrVal);
Nate Begeman848622f2005-11-05 09:21:28 +00002920 ;
2921 break;}
Chris Lattner86c352b2005-11-06 06:34:34 +00002922case 128:
Chris Lattner840f7892005-11-06 06:46:53 +00002923#line 1598 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2924{
2925 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
2926 free(yyvsp[0].StrVal);
2927 ;
2928 break;}
2929case 129:
2930#line 1602 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2931{
2932 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
2933 free(yyvsp[0].StrVal);
2934 ;
2935 break;}
2936case 130:
2937#line 1606 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002938{
2939 ;
2940 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002941case 134:
2942#line 1615 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002943{ yyval.StrVal = 0; ;
2944 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002945case 135:
2946#line 1617 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002947{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002948 if (*yyvsp[-1].TypeVal == Type::VoidTy)
2949 ThrowException("void typed arguments are invalid!");
2950 yyval.ArgVal = new std::pair<PATypeHolder*, char*>(yyvsp[-1].TypeVal, yyvsp[0].StrVal);
Nate Begeman848622f2005-11-05 09:21:28 +00002951;
2952 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002953case 136:
2954#line 1623 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002955{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002956 yyval.ArgList = yyvsp[-2].ArgList;
2957 yyvsp[-2].ArgList->push_back(*yyvsp[0].ArgVal);
2958 delete yyvsp[0].ArgVal;
Nate Begeman848622f2005-11-05 09:21:28 +00002959 ;
2960 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002961case 137:
2962#line 1628 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002963{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002964 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
2965 yyval.ArgList->push_back(*yyvsp[0].ArgVal);
2966 delete yyvsp[0].ArgVal;
Nate Begeman848622f2005-11-05 09:21:28 +00002967 ;
2968 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002969case 138:
2970#line 1634 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002971{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002972 yyval.ArgList = yyvsp[0].ArgList;
Nate Begeman848622f2005-11-05 09:21:28 +00002973 ;
2974 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002975case 139:
2976#line 1637 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002977{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002978 yyval.ArgList = yyvsp[-2].ArgList;
2979 yyval.ArgList->push_back(std::pair<PATypeHolder*,
2980 char*>(new PATypeHolder(Type::VoidTy), 0));
Nate Begeman848622f2005-11-05 09:21:28 +00002981 ;
2982 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002983case 140:
2984#line 1642 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002985{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002986 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
2987 yyval.ArgList->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0));
Nate Begeman848622f2005-11-05 09:21:28 +00002988 ;
2989 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002990case 141:
2991#line 1646 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002992{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002993 yyval.ArgList = 0;
Nate Begeman848622f2005-11-05 09:21:28 +00002994 ;
2995 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00002996case 142:
2997#line 1650 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00002998{
Chris Lattner840f7892005-11-06 06:46:53 +00002999 UnEscapeLexed(yyvsp[-4].StrVal);
3000 std::string FunctionName(yyvsp[-4].StrVal);
3001 free(yyvsp[-4].StrVal); // Free strdup'd memory!
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003002
Chris Lattner840f7892005-11-06 06:46:53 +00003003 if (!(*yyvsp[-5].TypeVal)->isFirstClassType() && *yyvsp[-5].TypeVal != Type::VoidTy)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003004 ThrowException("LLVM functions cannot return aggregate types!");
Chris Lattner840f7892005-11-06 06:46:53 +00003005 if (yyvsp[0].UIntVal != 0 && !isPowerOf2_32(yyvsp[0].UIntVal))
3006 ThrowException("Function alignment must be a power of two!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003007
3008 std::vector<const Type*> ParamTypeList;
Chris Lattner840f7892005-11-06 06:46:53 +00003009 if (yyvsp[-2].ArgList) { // If there are arguments...
3010 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-2].ArgList->begin();
3011 I != yyvsp[-2].ArgList->end(); ++I)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003012 ParamTypeList.push_back(I->first->get());
3013 }
3014
3015 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
3016 if (isVarArg) ParamTypeList.pop_back();
3017
Chris Lattner840f7892005-11-06 06:46:53 +00003018 const FunctionType *FT = FunctionType::get(*yyvsp[-5].TypeVal, ParamTypeList, isVarArg);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003019 const PointerType *PFT = PointerType::get(FT);
Chris Lattner840f7892005-11-06 06:46:53 +00003020 delete yyvsp[-5].TypeVal;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003021
3022 ValID ID;
3023 if (!FunctionName.empty()) {
3024 ID = ValID::create((char*)FunctionName.c_str());
3025 } else {
3026 ID = ValID::create((int)CurModule.Values[PFT].size());
3027 }
3028
3029 Function *Fn = 0;
3030 // See if this function was forward referenced. If so, recycle the object.
3031 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
3032 // Move the function to the end of the list, from whereever it was
3033 // previously inserted.
3034 Fn = cast<Function>(FWRef);
3035 CurModule.CurrentModule->getFunctionList().remove(Fn);
3036 CurModule.CurrentModule->getFunctionList().push_back(Fn);
3037 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
3038 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
3039 // If this is the case, either we need to be a forward decl, or it needs
3040 // to be.
3041 if (!CurFun.isDeclare && !Fn->isExternal())
3042 ThrowException("Redefinition of function '" + FunctionName + "'!");
3043
3044 // Make sure to strip off any argument names so we can't get conflicts.
3045 if (Fn->isExternal())
3046 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
3047 AI != AE; ++AI)
3048 AI->setName("");
3049
3050 } else { // Not already defined?
3051 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
3052 CurModule.CurrentModule);
3053 InsertValue(Fn, CurModule.Values);
3054 }
3055
3056 CurFun.FunctionStart(Fn);
Chris Lattner840f7892005-11-06 06:46:53 +00003057 Fn->setCallingConv(yyvsp[-6].UIntVal);
3058 Fn->setAlignment(yyvsp[0].UIntVal);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003059
3060 // Add all of the arguments we parsed to the function...
Chris Lattner840f7892005-11-06 06:46:53 +00003061 if (yyvsp[-2].ArgList) { // Is null if empty...
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003062 if (isVarArg) { // Nuke the last entry
Chris Lattner840f7892005-11-06 06:46:53 +00003063 assert(yyvsp[-2].ArgList->back().first->get() == Type::VoidTy && yyvsp[-2].ArgList->back().second == 0&&
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003064 "Not a varargs marker!");
Chris Lattner840f7892005-11-06 06:46:53 +00003065 delete yyvsp[-2].ArgList->back().first;
3066 yyvsp[-2].ArgList->pop_back(); // Delete the last entry
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003067 }
3068 Function::arg_iterator ArgIt = Fn->arg_begin();
Chris Lattner840f7892005-11-06 06:46:53 +00003069 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-2].ArgList->begin();
3070 I != yyvsp[-2].ArgList->end(); ++I, ++ArgIt) {
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003071 delete I->first; // Delete the typeholder...
3072
3073 setValueName(ArgIt, I->second); // Insert arg into symtab...
3074 InsertValue(ArgIt);
3075 }
3076
Chris Lattner840f7892005-11-06 06:46:53 +00003077 delete yyvsp[-2].ArgList; // We're now done with the argument list
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003078 }
Nate Begeman848622f2005-11-05 09:21:28 +00003079;
3080 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003081case 145:
3082#line 1735 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003083{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003084 yyval.FunctionVal = CurFun.CurrentFunction;
3085
3086 // Make sure that we keep track of the linkage type even if there was a
3087 // previous "declare".
3088 yyval.FunctionVal->setLinkage(yyvsp[-2].Linkage);
Nate Begeman848622f2005-11-05 09:21:28 +00003089;
3090 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003091case 148:
3092#line 1745 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003093{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003094 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Nate Begeman848622f2005-11-05 09:21:28 +00003095;
3096 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003097case 149:
3098#line 1749 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003099{ CurFun.isDeclare = true; ;
3100 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003101case 150:
3102#line 1749 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003103{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003104 yyval.FunctionVal = CurFun.CurrentFunction;
3105 CurFun.FunctionDone();
Nate Begeman848622f2005-11-05 09:21:28 +00003106;
3107 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003108case 151:
3109#line 1758 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003110{ // A reference to a direct constant
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003111 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
Nate Begeman848622f2005-11-05 09:21:28 +00003112 ;
3113 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003114case 152:
3115#line 1761 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003116{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003117 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
Nate Begeman848622f2005-11-05 09:21:28 +00003118 ;
3119 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003120case 153:
3121#line 1764 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003122{ // Perhaps it's an FP constant?
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003123 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
Nate Begeman848622f2005-11-05 09:21:28 +00003124 ;
3125 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003126case 154:
3127#line 1767 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003128{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003129 yyval.ValIDVal = ValID::create(ConstantBool::True);
Nate Begeman848622f2005-11-05 09:21:28 +00003130 ;
3131 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003132case 155:
3133#line 1770 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003134{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003135 yyval.ValIDVal = ValID::create(ConstantBool::False);
Nate Begeman848622f2005-11-05 09:21:28 +00003136 ;
3137 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003138case 156:
3139#line 1773 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003140{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003141 yyval.ValIDVal = ValID::createNull();
Nate Begeman848622f2005-11-05 09:21:28 +00003142 ;
3143 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003144case 157:
3145#line 1776 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003146{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003147 yyval.ValIDVal = ValID::createUndef();
Nate Begeman848622f2005-11-05 09:21:28 +00003148 ;
3149 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003150case 158:
3151#line 1779 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003152{ // Nonempty unsized packed vector
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003153 const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
3154 int NumElements = yyvsp[-1].ConstVector->size();
3155
3156 PackedType* pt = PackedType::get(ETy, NumElements);
3157 PATypeHolder* PTy = new PATypeHolder(
3158 HandleUpRefs(
3159 PackedType::get(
3160 ETy,
3161 NumElements)
3162 )
3163 );
3164
3165 // Verify all elements are correct type!
3166 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3167 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
3168 ThrowException("Element #" + utostr(i) + " is not of type '" +
3169 ETy->getDescription() +"' as required!\nIt is of type '" +
3170 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
3171 }
3172
3173 yyval.ValIDVal = ValID::create(ConstantPacked::get(pt, *yyvsp[-1].ConstVector));
3174 delete PTy; delete yyvsp[-1].ConstVector;
Nate Begeman848622f2005-11-05 09:21:28 +00003175 ;
3176 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003177case 159:
3178#line 1803 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003179{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003180 yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
Nate Begeman848622f2005-11-05 09:21:28 +00003181 ;
3182 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003183case 160:
3184#line 1810 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003185{ // Is it an integer reference...?
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003186 yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal);
Nate Begeman848622f2005-11-05 09:21:28 +00003187 ;
3188 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003189case 161:
3190#line 1813 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003191{ // Is it a named reference...?
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003192 yyval.ValIDVal = ValID::create(yyvsp[0].StrVal);
Nate Begeman848622f2005-11-05 09:21:28 +00003193 ;
3194 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003195case 164:
3196#line 1824 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003197{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003198 yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); delete yyvsp[-1].TypeVal;
Nate Begeman848622f2005-11-05 09:21:28 +00003199 ;
3200 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003201case 165:
3202#line 1828 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003203{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003204 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Nate Begeman848622f2005-11-05 09:21:28 +00003205 ;
3206 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003207case 166:
3208#line 1831 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003209{ // Do not allow functions with 0 basic blocks
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003210 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Nate Begeman848622f2005-11-05 09:21:28 +00003211 ;
3212 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003213case 167:
3214#line 1839 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003215{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003216 setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
3217 InsertValue(yyvsp[0].TermInstVal);
3218
3219 yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
3220 InsertValue(yyvsp[-2].BasicBlockVal);
3221 yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
Nate Begeman848622f2005-11-05 09:21:28 +00003222 ;
3223 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003224case 168:
3225#line 1848 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003226{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003227 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
3228 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
Nate Begeman848622f2005-11-05 09:21:28 +00003229 ;
3230 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003231case 169:
3232#line 1852 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003233{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003234 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
3235
3236 // Make sure to move the basic block to the correct location in the
3237 // function, instead of leaving it inserted wherever it was first
3238 // referenced.
3239 Function::BasicBlockListType &BBL =
3240 CurFun.CurrentFunction->getBasicBlockList();
3241 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
Nate Begeman848622f2005-11-05 09:21:28 +00003242 ;
3243 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003244case 170:
3245#line 1862 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003246{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003247 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create(yyvsp[0].StrVal), true);
3248
3249 // Make sure to move the basic block to the correct location in the
3250 // function, instead of leaving it inserted wherever it was first
3251 // referenced.
3252 Function::BasicBlockListType &BBL =
3253 CurFun.CurrentFunction->getBasicBlockList();
3254 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
Nate Begeman848622f2005-11-05 09:21:28 +00003255 ;
3256 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003257case 171:
3258#line 1873 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003259{ // Return with a result...
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003260 yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
Nate Begeman848622f2005-11-05 09:21:28 +00003261 ;
3262 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003263case 172:
3264#line 1876 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003265{ // Return with no result...
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003266 yyval.TermInstVal = new ReturnInst();
Nate Begeman848622f2005-11-05 09:21:28 +00003267 ;
3268 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003269case 173:
3270#line 1879 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003271{ // Unconditional Branch...
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003272 yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[0].ValIDVal));
Nate Begeman848622f2005-11-05 09:21:28 +00003273 ;
3274 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003275case 174:
3276#line 1882 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003277{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003278 yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[-3].ValIDVal), getBBVal(yyvsp[0].ValIDVal), getVal(Type::BoolTy, yyvsp[-6].ValIDVal));
Nate Begeman848622f2005-11-05 09:21:28 +00003279 ;
3280 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003281case 175:
3282#line 1885 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003283{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003284 SwitchInst *S = new SwitchInst(getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal), getBBVal(yyvsp[-3].ValIDVal), yyvsp[-1].JumpTable->size());
3285 yyval.TermInstVal = S;
3286
3287 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
3288 E = yyvsp[-1].JumpTable->end();
3289 for (; I != E; ++I) {
3290 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
3291 S->addCase(CI, I->second);
3292 else
3293 ThrowException("Switch case is constant, but not a simple integer!");
3294 }
3295 delete yyvsp[-1].JumpTable;
Nate Begeman848622f2005-11-05 09:21:28 +00003296 ;
3297 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003298case 176:
3299#line 1899 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003300{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003301 SwitchInst *S = new SwitchInst(getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal), getBBVal(yyvsp[-2].ValIDVal), 0);
3302 yyval.TermInstVal = S;
Nate Begeman848622f2005-11-05 09:21:28 +00003303 ;
3304 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003305case 177:
3306#line 1904 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003307{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003308 const PointerType *PFTy;
3309 const FunctionType *Ty;
3310
3311 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-10].TypeVal->get())) ||
3312 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3313 // Pull out the types of all of the arguments...
3314 std::vector<const Type*> ParamTypes;
3315 if (yyvsp[-7].ValueList) {
3316 for (std::vector<Value*>::iterator I = yyvsp[-7].ValueList->begin(), E = yyvsp[-7].ValueList->end();
3317 I != E; ++I)
3318 ParamTypes.push_back((*I)->getType());
3319 }
3320
3321 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3322 if (isVarArg) ParamTypes.pop_back();
3323
3324 Ty = FunctionType::get(yyvsp[-10].TypeVal->get(), ParamTypes, isVarArg);
3325 PFTy = PointerType::get(Ty);
3326 }
3327
3328 Value *V = getVal(PFTy, yyvsp[-9].ValIDVal); // Get the function we're calling...
3329
3330 BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
3331 BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
3332
3333 // Create the call node...
3334 if (!yyvsp[-7].ValueList) { // Has no arguments?
3335 yyval.TermInstVal = new InvokeInst(V, Normal, Except, std::vector<Value*>());
3336 } else { // Has arguments?
3337 // Loop through FunctionType's arguments and ensure they are specified
3338 // correctly!
3339 //
3340 FunctionType::param_iterator I = Ty->param_begin();
3341 FunctionType::param_iterator E = Ty->param_end();
3342 std::vector<Value*>::iterator ArgI = yyvsp[-7].ValueList->begin(), ArgE = yyvsp[-7].ValueList->end();
3343
3344 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3345 if ((*ArgI)->getType() != *I)
3346 ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
3347 (*I)->getDescription() + "'!");
3348
3349 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
3350 ThrowException("Invalid number of parameters detected!");
3351
3352 yyval.TermInstVal = new InvokeInst(V, Normal, Except, *yyvsp[-7].ValueList);
3353 }
3354 cast<InvokeInst>(yyval.TermInstVal)->setCallingConv(yyvsp[-11].UIntVal);
3355
3356 delete yyvsp[-10].TypeVal;
3357 delete yyvsp[-7].ValueList;
Nate Begeman848622f2005-11-05 09:21:28 +00003358 ;
3359 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003360case 178:
3361#line 1956 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003362{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003363 yyval.TermInstVal = new UnwindInst();
Nate Begeman848622f2005-11-05 09:21:28 +00003364 ;
3365 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003366case 179:
3367#line 1959 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003368{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003369 yyval.TermInstVal = new UnreachableInst();
Nate Begeman848622f2005-11-05 09:21:28 +00003370 ;
3371 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003372case 180:
3373#line 1965 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003374{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003375 yyval.JumpTable = yyvsp[-5].JumpTable;
3376 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
3377 if (V == 0)
3378 ThrowException("May only switch on a constant pool value!");
3379
3380 yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
Nate Begeman848622f2005-11-05 09:21:28 +00003381 ;
3382 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003383case 181:
3384#line 1973 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003385{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003386 yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
3387 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
3388
3389 if (V == 0)
3390 ThrowException("May only switch on a constant pool value!");
3391
3392 yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
Nate Begeman848622f2005-11-05 09:21:28 +00003393 ;
3394 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003395case 182:
3396#line 1983 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003397{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003398 // Is this definition named?? if so, assign the name...
3399 setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
3400 InsertValue(yyvsp[0].InstVal);
3401 yyval.InstVal = yyvsp[0].InstVal;
Nate Begeman848622f2005-11-05 09:21:28 +00003402;
3403 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003404case 183:
3405#line 1990 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003406{ // Used for PHI nodes
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003407 yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
3408 yyval.PHIList->push_back(std::make_pair(getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal), getBBVal(yyvsp[-1].ValIDVal)));
3409 delete yyvsp[-5].TypeVal;
Nate Begeman848622f2005-11-05 09:21:28 +00003410 ;
3411 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003412case 184:
3413#line 1995 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003414{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003415 yyval.PHIList = yyvsp[-6].PHIList;
3416 yyvsp[-6].PHIList->push_back(std::make_pair(getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal),
3417 getBBVal(yyvsp[-1].ValIDVal)));
Nate Begeman848622f2005-11-05 09:21:28 +00003418 ;
3419 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003420case 185:
3421#line 2002 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003422{ // Used for call statements, and memory insts...
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003423 yyval.ValueList = new std::vector<Value*>();
3424 yyval.ValueList->push_back(yyvsp[0].ValueVal);
Nate Begeman848622f2005-11-05 09:21:28 +00003425 ;
3426 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003427case 186:
3428#line 2006 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003429{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003430 yyval.ValueList = yyvsp[-2].ValueList;
3431 yyvsp[-2].ValueList->push_back(yyvsp[0].ValueVal);
Nate Begeman848622f2005-11-05 09:21:28 +00003432 ;
3433 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003434case 188:
3435#line 2012 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003436{ yyval.ValueList = 0; ;
3437 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003438case 189:
3439#line 2014 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003440{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003441 yyval.BoolVal = true;
Nate Begeman848622f2005-11-05 09:21:28 +00003442 ;
3443 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003444case 190:
3445#line 2017 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003446{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003447 yyval.BoolVal = false;
Nate Begeman848622f2005-11-05 09:21:28 +00003448 ;
3449 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003450case 191:
3451#line 2023 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003452{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003453 if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
3454 !isa<PackedType>((*yyvsp[-3].TypeVal).get()))
3455 ThrowException(
3456 "Arithmetic operator requires integer, FP, or packed operands!");
3457 if (isa<PackedType>((*yyvsp[-3].TypeVal).get()) && yyvsp[-4].BinaryOpVal == Instruction::Rem)
3458 ThrowException("Rem not supported on packed types!");
3459 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3460 if (yyval.InstVal == 0)
3461 ThrowException("binary operator returned null!");
3462 delete yyvsp[-3].TypeVal;
Nate Begeman848622f2005-11-05 09:21:28 +00003463 ;
3464 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003465case 192:
3466#line 2035 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003467{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003468 if (!(*yyvsp[-3].TypeVal)->isIntegral())
3469 ThrowException("Logical operator requires integral operands!");
3470 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3471 if (yyval.InstVal == 0)
3472 ThrowException("binary operator returned null!");
3473 delete yyvsp[-3].TypeVal;
Nate Begeman848622f2005-11-05 09:21:28 +00003474 ;
3475 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003476case 193:
3477#line 2043 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003478{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003479 if(isa<PackedType>((*yyvsp[-3].TypeVal).get())) {
3480 ThrowException(
3481 "PackedTypes currently not supported in setcc instructions!");
3482 }
3483 yyval.InstVal = new SetCondInst(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3484 if (yyval.InstVal == 0)
3485 ThrowException("binary operator returned null!");
3486 delete yyvsp[-3].TypeVal;
Nate Begeman848622f2005-11-05 09:21:28 +00003487 ;
3488 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003489case 194:
3490#line 2053 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003491{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003492 std::cerr << "WARNING: Use of eliminated 'not' instruction:"
3493 << " Replacing with 'xor'.\n";
3494
3495 Value *Ones = ConstantIntegral::getAllOnesValue(yyvsp[0].ValueVal->getType());
3496 if (Ones == 0)
3497 ThrowException("Expected integral type for not instruction!");
3498
3499 yyval.InstVal = BinaryOperator::create(Instruction::Xor, yyvsp[0].ValueVal, Ones);
3500 if (yyval.InstVal == 0)
3501 ThrowException("Could not create a xor instruction!");
Nate Begeman848622f2005-11-05 09:21:28 +00003502 ;
3503 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003504case 195:
3505#line 2065 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003506{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003507 if (yyvsp[0].ValueVal->getType() != Type::UByteTy)
3508 ThrowException("Shift amount must be ubyte!");
3509 if (!yyvsp[-2].ValueVal->getType()->isInteger())
3510 ThrowException("Shift constant expression requires integer operand!");
3511 yyval.InstVal = new ShiftInst(yyvsp[-3].OtherOpVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Nate Begeman848622f2005-11-05 09:21:28 +00003512 ;
3513 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003514case 196:
3515#line 2072 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003516{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003517 if (!yyvsp[0].TypeVal->get()->isFirstClassType())
3518 ThrowException("cast instruction to a non-primitive type: '" +
3519 yyvsp[0].TypeVal->get()->getDescription() + "'!");
3520 yyval.InstVal = new CastInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
3521 delete yyvsp[0].TypeVal;
Nate Begeman848622f2005-11-05 09:21:28 +00003522 ;
3523 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003524case 197:
3525#line 2079 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003526{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003527 if (yyvsp[-4].ValueVal->getType() != Type::BoolTy)
3528 ThrowException("select condition must be boolean!");
3529 if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
3530 ThrowException("select value types should match!");
3531 yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Nate Begeman848622f2005-11-05 09:21:28 +00003532 ;
3533 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003534case 198:
3535#line 2086 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003536{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003537 NewVarArgs = true;
3538 yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
3539 delete yyvsp[0].TypeVal;
Nate Begeman848622f2005-11-05 09:21:28 +00003540 ;
3541 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003542case 199:
3543#line 2091 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003544{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003545 ObsoleteVarArgs = true;
3546 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
3547 Function* NF = CurModule.CurrentModule->
Jeff Cohen11e26b52005-10-23 04:37:20 +00003548 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003549
3550 //b = vaarg a, t ->
3551 //foo = alloca 1 of t
3552 //bar = vacopy a
3553 //store bar -> foo
3554 //b = vaarg foo, t
3555 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
3556 CurBB->getInstList().push_back(foo);
3557 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
3558 CurBB->getInstList().push_back(bar);
3559 CurBB->getInstList().push_back(new StoreInst(bar, foo));
3560 yyval.InstVal = new VAArgInst(foo, *yyvsp[0].TypeVal);
3561 delete yyvsp[0].TypeVal;
Nate Begeman848622f2005-11-05 09:21:28 +00003562 ;
3563 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003564case 200:
3565#line 2110 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003566{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003567 ObsoleteVarArgs = true;
3568 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
3569 Function* NF = CurModule.CurrentModule->
Jeff Cohen11e26b52005-10-23 04:37:20 +00003570 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003571
3572 //b = vanext a, t ->
3573 //foo = alloca 1 of t
3574 //bar = vacopy a
3575 //store bar -> foo
3576 //tmp = vaarg foo, t
3577 //b = load foo
3578 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
3579 CurBB->getInstList().push_back(foo);
3580 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
3581 CurBB->getInstList().push_back(bar);
3582 CurBB->getInstList().push_back(new StoreInst(bar, foo));
3583 Instruction* tmp = new VAArgInst(foo, *yyvsp[0].TypeVal);
3584 CurBB->getInstList().push_back(tmp);
3585 yyval.InstVal = new LoadInst(foo);
3586 delete yyvsp[0].TypeVal;
Nate Begeman848622f2005-11-05 09:21:28 +00003587 ;
3588 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003589case 201:
3590#line 2132 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003591{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003592 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
3593 if (!Ty->isFirstClassType())
3594 ThrowException("PHI node operands must be of first class type!");
3595 yyval.InstVal = new PHINode(Ty);
3596 ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
3597 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
3598 if (yyvsp[0].PHIList->front().first->getType() != Ty)
3599 ThrowException("All elements of a PHI node must be of the same type!");
3600 cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
3601 yyvsp[0].PHIList->pop_front();
3602 }
3603 delete yyvsp[0].PHIList; // Free the list...
Nate Begeman848622f2005-11-05 09:21:28 +00003604 ;
3605 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003606case 202:
3607#line 2146 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003608{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003609 const PointerType *PFTy;
3610 const FunctionType *Ty;
3611
3612 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-4].TypeVal->get())) ||
3613 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3614 // Pull out the types of all of the arguments...
3615 std::vector<const Type*> ParamTypes;
3616 if (yyvsp[-1].ValueList) {
3617 for (std::vector<Value*>::iterator I = yyvsp[-1].ValueList->begin(), E = yyvsp[-1].ValueList->end();
3618 I != E; ++I)
3619 ParamTypes.push_back((*I)->getType());
3620 }
3621
3622 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3623 if (isVarArg) ParamTypes.pop_back();
3624
3625 if (!(*yyvsp[-4].TypeVal)->isFirstClassType() && *yyvsp[-4].TypeVal != Type::VoidTy)
3626 ThrowException("LLVM functions cannot return aggregate types!");
3627
3628 Ty = FunctionType::get(yyvsp[-4].TypeVal->get(), ParamTypes, isVarArg);
3629 PFTy = PointerType::get(Ty);
3630 }
3631
3632 Value *V = getVal(PFTy, yyvsp[-3].ValIDVal); // Get the function we're calling...
3633
3634 // Create the call node...
3635 if (!yyvsp[-1].ValueList) { // Has no arguments?
3636 // Make sure no arguments is a good thing!
3637 if (Ty->getNumParams() != 0)
3638 ThrowException("No arguments passed to a function that "
3639 "expects arguments!");
3640
3641 yyval.InstVal = new CallInst(V, std::vector<Value*>());
3642 } else { // Has arguments?
3643 // Loop through FunctionType's arguments and ensure they are specified
3644 // correctly!
3645 //
3646 FunctionType::param_iterator I = Ty->param_begin();
3647 FunctionType::param_iterator E = Ty->param_end();
3648 std::vector<Value*>::iterator ArgI = yyvsp[-1].ValueList->begin(), ArgE = yyvsp[-1].ValueList->end();
3649
3650 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3651 if ((*ArgI)->getType() != *I)
3652 ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
3653 (*I)->getDescription() + "'!");
3654
3655 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
3656 ThrowException("Invalid number of parameters detected!");
3657
3658 yyval.InstVal = new CallInst(V, *yyvsp[-1].ValueList);
3659 }
3660 cast<CallInst>(yyval.InstVal)->setTailCall(yyvsp[-6].BoolVal);
3661 cast<CallInst>(yyval.InstVal)->setCallingConv(yyvsp[-5].UIntVal);
3662 delete yyvsp[-4].TypeVal;
3663 delete yyvsp[-1].ValueList;
Nate Begeman848622f2005-11-05 09:21:28 +00003664 ;
3665 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003666case 203:
3667#line 2203 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003668{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003669 yyval.InstVal = yyvsp[0].InstVal;
Nate Begeman848622f2005-11-05 09:21:28 +00003670 ;
3671 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003672case 204:
3673#line 2209 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003674{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003675 yyval.ValueList = yyvsp[0].ValueList;
Nate Begeman848622f2005-11-05 09:21:28 +00003676 ;
3677 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003678case 205:
3679#line 2211 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003680{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003681 yyval.ValueList = new std::vector<Value*>();
Nate Begeman848622f2005-11-05 09:21:28 +00003682 ;
3683 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003684case 206:
3685#line 2215 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003686{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003687 yyval.BoolVal = true;
Nate Begeman848622f2005-11-05 09:21:28 +00003688 ;
3689 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003690case 207:
3691#line 2218 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003692{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003693 yyval.BoolVal = false;
Nate Begeman848622f2005-11-05 09:21:28 +00003694 ;
3695 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003696case 208:
3697#line 2224 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003698{
Chris Lattner840f7892005-11-06 06:46:53 +00003699 if (yyvsp[0].UIntVal != 0 && !isPowerOf2_32(yyvsp[0].UIntVal))
3700 ThrowException("Alignment amount '" + utostr(yyvsp[0].UIntVal) +
3701 "' is not a power of 2!");
Chris Lattner86c352b2005-11-06 06:34:34 +00003702 yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
3703 delete yyvsp[-1].TypeVal;
Nate Begeman848622f2005-11-05 09:21:28 +00003704 ;
3705 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003706case 209:
3707#line 2231 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003708{
Chris Lattner840f7892005-11-06 06:46:53 +00003709 if (yyvsp[0].UIntVal != 0 && !isPowerOf2_32(yyvsp[0].UIntVal))
Chris Lattner86c352b2005-11-06 06:34:34 +00003710 ThrowException("Alignment amount '" + utostr(yyvsp[0].UIntVal) +
Chris Lattnerb467a4f2005-11-05 21:54:23 +00003711 "' is not a power of 2!");
Chris Lattner86c352b2005-11-06 06:34:34 +00003712 yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal);
3713 delete yyvsp[-4].TypeVal;
Nate Begeman848622f2005-11-05 09:21:28 +00003714 ;
3715 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003716case 210:
3717#line 2238 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003718{
Chris Lattner840f7892005-11-06 06:46:53 +00003719 if (yyvsp[0].UIntVal != 0 && !isPowerOf2_32(yyvsp[0].UIntVal))
Chris Lattner86c352b2005-11-06 06:34:34 +00003720 ThrowException("Alignment amount '" + utostr(yyvsp[0].UIntVal) +
3721 "' is not a power of 2!");
3722 yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
3723 delete yyvsp[-1].TypeVal;
Nate Begeman848622f2005-11-05 09:21:28 +00003724 ;
3725 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003726case 211:
3727#line 2245 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003728{
Chris Lattner840f7892005-11-06 06:46:53 +00003729 if (yyvsp[0].UIntVal != 0 && !isPowerOf2_32(yyvsp[0].UIntVal))
Chris Lattner86c352b2005-11-06 06:34:34 +00003730 ThrowException("Alignment amount '" + utostr(yyvsp[0].UIntVal) +
Chris Lattnerb467a4f2005-11-05 21:54:23 +00003731 "' is not a power of 2!");
Chris Lattner86c352b2005-11-06 06:34:34 +00003732 yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal);
3733 delete yyvsp[-4].TypeVal;
Nate Begeman848622f2005-11-05 09:21:28 +00003734 ;
3735 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003736case 212:
3737#line 2252 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003738{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003739 if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
3740 ThrowException("Trying to free nonpointer type " +
3741 yyvsp[0].ValueVal->getType()->getDescription() + "!");
3742 yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
Nate Begeman848622f2005-11-05 09:21:28 +00003743 ;
3744 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003745case 213:
3746#line 2259 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003747{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003748 if (!isa<PointerType>(yyvsp[-1].TypeVal->get()))
3749 ThrowException("Can't load from nonpointer type: " +
3750 (*yyvsp[-1].TypeVal)->getDescription());
3751 if (!cast<PointerType>(yyvsp[-1].TypeVal->get())->getElementType()->isFirstClassType())
3752 ThrowException("Can't load from pointer of non-first-class type: " +
3753 (*yyvsp[-1].TypeVal)->getDescription());
3754 yyval.InstVal = new LoadInst(getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), "", yyvsp[-3].BoolVal);
3755 delete yyvsp[-1].TypeVal;
Nate Begeman848622f2005-11-05 09:21:28 +00003756 ;
3757 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003758case 214:
3759#line 2269 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003760{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003761 const PointerType *PT = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
3762 if (!PT)
3763 ThrowException("Can't store to a nonpointer type: " +
3764 (*yyvsp[-1].TypeVal)->getDescription());
3765 const Type *ElTy = PT->getElementType();
3766 if (ElTy != yyvsp[-3].ValueVal->getType())
3767 ThrowException("Can't store '" + yyvsp[-3].ValueVal->getType()->getDescription() +
3768 "' into space of type '" + ElTy->getDescription() + "'!");
3769
3770 yyval.InstVal = new StoreInst(yyvsp[-3].ValueVal, getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), yyvsp[-5].BoolVal);
3771 delete yyvsp[-1].TypeVal;
Nate Begeman848622f2005-11-05 09:21:28 +00003772 ;
3773 break;}
Chris Lattner840f7892005-11-06 06:46:53 +00003774case 215:
3775#line 2282 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman848622f2005-11-05 09:21:28 +00003776{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003777 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
3778 ThrowException("getelementptr insn requires pointer operand!");
3779
3780 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
3781 // indices to uint struct indices for compatibility.
3782 generic_gep_type_iterator<std::vector<Value*>::iterator>
3783 GTI = gep_type_begin(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end()),
3784 GTE = gep_type_end(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end());
3785 for (unsigned i = 0, e = yyvsp[0].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
3786 if (isa<StructType>(*GTI)) // Only change struct indices
3787 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[0].ValueList)[i]))
3788 if (CUI->getType() == Type::UByteTy)
3789 (*yyvsp[0].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
3790
3791 if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, *yyvsp[0].ValueList, true))
3792 ThrowException("Invalid getelementptr indices for type '" +
3793 (*yyvsp[-2].TypeVal)->getDescription()+ "'!");
3794 yyval.InstVal = new GetElementPtrInst(getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal), *yyvsp[0].ValueList);
3795 delete yyvsp[-2].TypeVal; delete yyvsp[0].ValueList;
Nate Begeman848622f2005-11-05 09:21:28 +00003796 ;
3797 break;}
3798}
3799 /* the action file gets copied in in place of this dollarsign */
3800#line 543 "/usr/share/bison.simple"
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003801
3802 yyvsp -= yylen;
3803 yyssp -= yylen;
Nate Begeman848622f2005-11-05 09:21:28 +00003804#ifdef YYLSP_NEEDED
3805 yylsp -= yylen;
3806#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003807
Nate Begeman848622f2005-11-05 09:21:28 +00003808#if YYDEBUG != 0
3809 if (yydebug)
3810 {
3811 short *ssp1 = yyss - 1;
3812 fprintf (stderr, "state stack now");
3813 while (ssp1 != yyssp)
3814 fprintf (stderr, " %d", *++ssp1);
3815 fprintf (stderr, "\n");
3816 }
3817#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003818
3819 *++yyvsp = yyval;
3820
Nate Begeman848622f2005-11-05 09:21:28 +00003821#ifdef YYLSP_NEEDED
3822 yylsp++;
3823 if (yylen == 0)
3824 {
3825 yylsp->first_line = yylloc.first_line;
3826 yylsp->first_column = yylloc.first_column;
3827 yylsp->last_line = (yylsp-1)->last_line;
3828 yylsp->last_column = (yylsp-1)->last_column;
3829 yylsp->text = 0;
3830 }
3831 else
3832 {
3833 yylsp->last_line = (yylsp+yylen-1)->last_line;
3834 yylsp->last_column = (yylsp+yylen-1)->last_column;
3835 }
3836#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003837
Nate Begeman848622f2005-11-05 09:21:28 +00003838 /* Now "shift" the result of the reduction.
3839 Determine what state that goes to,
3840 based on the state we popped back to
3841 and the rule number reduced by. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003842
3843 yyn = yyr1[yyn];
3844
Nate Begeman848622f2005-11-05 09:21:28 +00003845 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
3846 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003847 yystate = yytable[yystate];
3848 else
Nate Begeman848622f2005-11-05 09:21:28 +00003849 yystate = yydefgoto[yyn - YYNTBASE];
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003850
3851 goto yynewstate;
3852
Nate Begeman848622f2005-11-05 09:21:28 +00003853yyerrlab: /* here on detecting error */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003854
Nate Begeman848622f2005-11-05 09:21:28 +00003855 if (! yyerrstatus)
3856 /* If not already recovering from an error, report this error. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003857 {
3858 ++yynerrs;
Nate Begeman848622f2005-11-05 09:21:28 +00003859
3860#ifdef YYERROR_VERBOSE
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003861 yyn = yypact[yystate];
3862
Nate Begeman848622f2005-11-05 09:21:28 +00003863 if (yyn > YYFLAG && yyn < YYLAST)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003864 {
Nate Begeman848622f2005-11-05 09:21:28 +00003865 int size = 0;
3866 char *msg;
3867 int x, count;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003868
Nate Begeman848622f2005-11-05 09:21:28 +00003869 count = 0;
3870 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
3871 for (x = (yyn < 0 ? -yyn : 0);
3872 x < (sizeof(yytname) / sizeof(char *)); x++)
3873 if (yycheck[x + yyn] == x)
3874 size += strlen(yytname[x]) + 15, count++;
3875 msg = (char *) malloc(size + 15);
3876 if (msg != 0)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003877 {
Nate Begeman848622f2005-11-05 09:21:28 +00003878 strcpy(msg, "parse error");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003879
Nate Begeman848622f2005-11-05 09:21:28 +00003880 if (count < 5)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003881 {
Nate Begeman848622f2005-11-05 09:21:28 +00003882 count = 0;
3883 for (x = (yyn < 0 ? -yyn : 0);
3884 x < (sizeof(yytname) / sizeof(char *)); x++)
3885 if (yycheck[x + yyn] == x)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003886 {
Nate Begeman848622f2005-11-05 09:21:28 +00003887 strcat(msg, count == 0 ? ", expecting `" : " or `");
3888 strcat(msg, yytname[x]);
3889 strcat(msg, "'");
3890 count++;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003891 }
3892 }
Nate Begeman848622f2005-11-05 09:21:28 +00003893 yyerror(msg);
3894 free(msg);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003895 }
3896 else
Nate Begeman848622f2005-11-05 09:21:28 +00003897 yyerror ("parse error; also virtual memory exceeded");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003898 }
3899 else
3900#endif /* YYERROR_VERBOSE */
Nate Begeman848622f2005-11-05 09:21:28 +00003901 yyerror("parse error");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003902 }
3903
Nate Begeman848622f2005-11-05 09:21:28 +00003904 goto yyerrlab1;
3905yyerrlab1: /* here on error raised explicitly by an action */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003906
3907 if (yyerrstatus == 3)
3908 {
Nate Begeman848622f2005-11-05 09:21:28 +00003909 /* if just tried and failed to reuse lookahead token after an error, discard it. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003910
Nate Begeman848622f2005-11-05 09:21:28 +00003911 /* return failure if at end of input */
3912 if (yychar == YYEOF)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003913 YYABORT;
3914
Nate Begeman848622f2005-11-05 09:21:28 +00003915#if YYDEBUG != 0
3916 if (yydebug)
3917 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
3918#endif
3919
3920 yychar = YYEMPTY;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003921 }
3922
Nate Begeman848622f2005-11-05 09:21:28 +00003923 /* Else will try to reuse lookahead token
3924 after shifting the error token. */
3925
3926 yyerrstatus = 3; /* Each real token shifted decrements this */
3927
3928 goto yyerrhandle;
3929
3930yyerrdefault: /* current state does not do anything special for the error token. */
3931
3932#if 0
3933 /* This is wrong; only states that explicitly want error tokens
3934 should shift them. */
3935 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
3936 if (yyn) goto yydefault;
3937#endif
3938
3939yyerrpop: /* pop the current state because it cannot handle the error token */
3940
3941 if (yyssp == yyss) YYABORT;
3942 yyvsp--;
3943 yystate = *--yyssp;
3944#ifdef YYLSP_NEEDED
3945 yylsp--;
3946#endif
3947
3948#if YYDEBUG != 0
3949 if (yydebug)
3950 {
3951 short *ssp1 = yyss - 1;
3952 fprintf (stderr, "Error: state stack now");
3953 while (ssp1 != yyssp)
3954 fprintf (stderr, " %d", *++ssp1);
3955 fprintf (stderr, "\n");
3956 }
3957#endif
3958
3959yyerrhandle:
3960
3961 yyn = yypact[yystate];
3962 if (yyn == YYFLAG)
3963 goto yyerrdefault;
3964
3965 yyn += YYTERROR;
3966 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
3967 goto yyerrdefault;
3968
3969 yyn = yytable[yyn];
3970 if (yyn < 0)
3971 {
3972 if (yyn == YYFLAG)
3973 goto yyerrpop;
3974 yyn = -yyn;
3975 goto yyreduce;
3976 }
3977 else if (yyn == 0)
3978 goto yyerrpop;
3979
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003980 if (yyn == YYFINAL)
3981 YYACCEPT;
3982
Nate Begeman848622f2005-11-05 09:21:28 +00003983#if YYDEBUG != 0
3984 if (yydebug)
3985 fprintf(stderr, "Shifting error token, ");
3986#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003987
3988 *++yyvsp = yylval;
Nate Begeman848622f2005-11-05 09:21:28 +00003989#ifdef YYLSP_NEEDED
3990 *++yylsp = yylloc;
3991#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003992
3993 yystate = yyn;
3994 goto yynewstate;
3995
Nate Begeman848622f2005-11-05 09:21:28 +00003996 yyacceptlab:
3997 /* YYACCEPT comes here. */
3998 if (yyfree_stacks)
3999 {
4000 free (yyss);
4001 free (yyvs);
4002#ifdef YYLSP_NEEDED
4003 free (yyls);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004004#endif
Nate Begeman848622f2005-11-05 09:21:28 +00004005 }
4006 return 0;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004007
Nate Begeman848622f2005-11-05 09:21:28 +00004008 yyabortlab:
4009 /* YYABORT comes here. */
4010 if (yyfree_stacks)
4011 {
4012 free (yyss);
4013 free (yyvs);
4014#ifdef YYLSP_NEEDED
4015 free (yyls);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004016#endif
Nate Begeman848622f2005-11-05 09:21:28 +00004017 }
4018 return 1;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004019}
Chris Lattner840f7892005-11-06 06:46:53 +00004020#line 2305 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004021
4022int yyerror(const char *ErrorMsg) {
4023 std::string where
4024 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
4025 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
4026 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
4027 if (yychar == YYEMPTY || yychar == 0)
4028 errMsg += "end-of-file.";
4029 else
4030 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
4031 ThrowException(errMsg);
4032 return 0;
4033}