blob: 54ab7ee31c8b0c88b22c3e506da13c4d64be61cc [file] [log] [blame]
Reid Spencer68a24bd2005-08-27 18:50:39 +00001
Chris Lattnerd91c3212005-11-05 21:54:23 +00002/* A Bison parser, made from /Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y
Nate Begeman14b05292005-11-05 09:21:28 +00003 by GNU Bison version 1.28 */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004
Nate Begeman14b05292005-11-05 09:21:28 +00005#define YYBISON 1 /* Identify Bison output. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00006
Reid Spencer68a24bd2005-08-27 18:50:39 +00007#define yyparse llvmAsmparse
Nate Begeman14b05292005-11-05 09:21:28 +00008#define yylex llvmAsmlex
Reid Spencer68a24bd2005-08-27 18:50:39 +00009#define yyerror llvmAsmerror
Nate Begeman14b05292005-11-05 09:21:28 +000010#define yylval llvmAsmlval
11#define yychar llvmAsmchar
Reid Spencer68a24bd2005-08-27 18:50:39 +000012#define yydebug llvmAsmdebug
13#define yynerrs llvmAsmnerrs
Nate Begeman14b05292005-11-05 09:21:28 +000014#define ESINT64VAL 257
15#define EUINT64VAL 258
16#define SINTVAL 259
17#define UINTVAL 260
18#define FPVAL 261
19#define VOID 262
20#define BOOL 263
21#define SBYTE 264
22#define UBYTE 265
23#define SHORT 266
24#define USHORT 267
25#define INT 268
26#define UINT 269
27#define LONG 270
28#define ULONG 271
29#define FLOAT 272
30#define DOUBLE 273
31#define TYPE 274
32#define LABEL 275
33#define VAR_ID 276
34#define LABELSTR 277
35#define STRINGCONSTANT 278
36#define IMPLEMENTATION 279
37#define ZEROINITIALIZER 280
38#define TRUETOK 281
39#define FALSETOK 282
40#define BEGINTOK 283
41#define ENDTOK 284
42#define DECLARE 285
43#define GLOBAL 286
44#define CONSTANT 287
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 Spencer68a24bd2005-08-27 18:50:39 +0000106
Chris Lattnerd91c3212005-11-05 21:54:23 +0000107#line 14 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-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"
116#include <algorithm>
117#include <iostream>
118#include <list>
119#include <utility>
120
121int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
122int yylex(); // declaration" of xxx warnings.
123int yyparse();
124
125namespace llvm {
126 std::string CurFilename;
127}
128using namespace llvm;
129
130static Module *ParserResult;
131
132// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
133// relating to upreferences in the input stream.
134//
135//#define DEBUG_UPREFS 1
136#ifdef DEBUG_UPREFS
137#define UR_OUT(X) std::cerr << X
138#else
139#define UR_OUT(X)
140#endif
141
142#define YYERROR_VERBOSE 1
143
144static bool ObsoleteVarArgs;
145static bool NewVarArgs;
146static BasicBlock* CurBB;
147
148
149// This contains info used when building the body of a function. It is
150// destroyed when the function is completed.
151//
152typedef std::vector<Value *> ValueList; // Numbered defs
153static void
154ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
155 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
156
157static struct PerModuleInfo {
158 Module *CurrentModule;
159 std::map<const Type *, ValueList> Values; // Module level numbered definitions
160 std::map<const Type *,ValueList> LateResolveValues;
161 std::vector<PATypeHolder> Types;
162 std::map<ValID, PATypeHolder> LateResolveTypes;
163
164 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
165 /// how they were referenced and one which line of the input they came from so
166 /// that we can resolve them later and print error messages as appropriate.
167 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
168
169 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
170 // references to global values. Global values may be referenced before they
171 // are defined, and if so, the temporary object that they represent is held
172 // here. This is used for forward references of GlobalValues.
173 //
174 typedef std::map<std::pair<const PointerType *,
175 ValID>, GlobalValue*> GlobalRefsType;
176 GlobalRefsType GlobalRefs;
177
178 void ModuleDone() {
179 // If we could not resolve some functions at function compilation time
180 // (calls to functions before they are defined), resolve them now... Types
181 // are resolved when the constant pool has been completely parsed.
182 //
183 ResolveDefinitions(LateResolveValues);
184
185 // Check to make sure that all global value forward references have been
186 // resolved!
187 //
188 if (!GlobalRefs.empty()) {
189 std::string UndefinedReferences = "Unresolved global references exist:\n";
190
191 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
192 I != E; ++I) {
193 UndefinedReferences += " " + I->first.first->getDescription() + " " +
194 I->first.second.getName() + "\n";
195 }
196 ThrowException(UndefinedReferences);
197 }
198
199 Values.clear(); // Clear out function local definitions
200 Types.clear();
201 CurrentModule = 0;
202 }
203
204
205 // GetForwardRefForGlobal - Check to see if there is a forward reference
206 // for this global. If so, remove it from the GlobalRefs map and return it.
207 // If not, just return null.
208 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
209 // Check to see if there is a forward reference to this global variable...
210 // if there is, eliminate it and patch the reference to use the new def'n.
211 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
212 GlobalValue *Ret = 0;
213 if (I != GlobalRefs.end()) {
214 Ret = I->second;
215 GlobalRefs.erase(I);
216 }
217 return Ret;
218 }
219} CurModule;
220
221static struct PerFunctionInfo {
222 Function *CurrentFunction; // Pointer to current function being created
223
224 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
225 std::map<const Type*, ValueList> LateResolveValues;
226 bool isDeclare; // Is this function a forward declararation?
227
228 /// BBForwardRefs - When we see forward references to basic blocks, keep
229 /// track of them here.
230 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
231 std::vector<BasicBlock*> NumberedBlocks;
232 unsigned NextBBNum;
233
234 inline PerFunctionInfo() {
235 CurrentFunction = 0;
236 isDeclare = false;
237 }
238
239 inline void FunctionStart(Function *M) {
240 CurrentFunction = M;
241 NextBBNum = 0;
242 }
243
244 void FunctionDone() {
245 NumberedBlocks.clear();
246
247 // Any forward referenced blocks left?
248 if (!BBForwardRefs.empty())
249 ThrowException("Undefined reference to label " +
250 BBForwardRefs.begin()->first->getName());
251
252 // Resolve all forward references now.
253 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
254
255 Values.clear(); // Clear out function local definitions
256 CurrentFunction = 0;
257 isDeclare = false;
258 }
259} CurFun; // Info for the current function...
260
261static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
262
263
264//===----------------------------------------------------------------------===//
265// Code to handle definitions of all the types
266//===----------------------------------------------------------------------===//
267
268static int InsertValue(Value *V,
269 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
270 if (V->hasName()) return -1; // Is this a numbered definition?
271
272 // Yes, insert the value into the value table...
273 ValueList &List = ValueTab[V->getType()];
274 List.push_back(V);
275 return List.size()-1;
276}
277
278static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
279 switch (D.Type) {
280 case ValID::NumberVal: // Is it a numbered definition?
281 // Module constants occupy the lowest numbered slots...
282 if ((unsigned)D.Num < CurModule.Types.size())
283 return CurModule.Types[(unsigned)D.Num];
284 break;
285 case ValID::NameVal: // Is it a named definition?
286 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
287 D.destroy(); // Free old strdup'd memory...
288 return N;
289 }
290 break;
291 default:
292 ThrowException("Internal parser error: Invalid symbol type reference!");
293 }
294
295 // If we reached here, we referenced either a symbol that we don't know about
296 // or an id number that hasn't been read yet. We may be referencing something
297 // forward, so just create an entry to be resolved later and get to it...
298 //
299 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
300
301
302 if (inFunctionScope()) {
303 if (D.Type == ValID::NameVal)
304 ThrowException("Reference to an undefined type: '" + D.getName() + "'");
305 else
306 ThrowException("Reference to an undefined type: #" + itostr(D.Num));
307 }
308
309 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
310 if (I != CurModule.LateResolveTypes.end())
311 return I->second;
312
313 Type *Typ = OpaqueType::get();
314 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
315 return Typ;
316 }
317
318static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
319 SymbolTable &SymTab =
320 inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() :
321 CurModule.CurrentModule->getSymbolTable();
322 return SymTab.lookup(Ty, Name);
323}
324
325// getValNonImprovising - Look up the value specified by the provided type and
326// the provided ValID. If the value exists and has already been defined, return
327// it. Otherwise return null.
328//
329static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
330 if (isa<FunctionType>(Ty))
331 ThrowException("Functions are not values and "
332 "must be referenced as pointers");
333
334 switch (D.Type) {
335 case ValID::NumberVal: { // Is it a numbered definition?
336 unsigned Num = (unsigned)D.Num;
337
338 // Module constants occupy the lowest numbered slots...
339 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
340 if (VI != CurModule.Values.end()) {
341 if (Num < VI->second.size())
342 return VI->second[Num];
343 Num -= VI->second.size();
344 }
345
346 // Make sure that our type is within bounds
347 VI = CurFun.Values.find(Ty);
348 if (VI == CurFun.Values.end()) return 0;
349
350 // Check that the number is within bounds...
351 if (VI->second.size() <= Num) return 0;
352
353 return VI->second[Num];
354 }
355
356 case ValID::NameVal: { // Is it a named definition?
357 Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
358 if (N == 0) return 0;
359
360 D.destroy(); // Free old strdup'd memory...
361 return N;
362 }
363
364 // Check to make sure that "Ty" is an integral type, and that our
365 // value will fit into the specified type...
366 case ValID::ConstSIntVal: // Is it a constant pool reference??
367 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64))
368 ThrowException("Signed integral constant '" +
369 itostr(D.ConstPool64) + "' is invalid for type '" +
370 Ty->getDescription() + "'!");
371 return ConstantSInt::get(Ty, D.ConstPool64);
372
373 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
374 if (!ConstantUInt::isValueValidForType(Ty, D.UConstPool64)) {
375 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) {
376 ThrowException("Integral constant '" + utostr(D.UConstPool64) +
377 "' is invalid or out of range!");
378 } else { // This is really a signed reference. Transmogrify.
379 return ConstantSInt::get(Ty, D.ConstPool64);
380 }
381 } else {
382 return ConstantUInt::get(Ty, D.UConstPool64);
383 }
384
385 case ValID::ConstFPVal: // Is it a floating point const pool reference?
386 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
387 ThrowException("FP constant invalid for type!!");
388 return ConstantFP::get(Ty, D.ConstPoolFP);
389
390 case ValID::ConstNullVal: // Is it a null value?
391 if (!isa<PointerType>(Ty))
392 ThrowException("Cannot create a a non pointer null!");
393 return ConstantPointerNull::get(cast<PointerType>(Ty));
394
395 case ValID::ConstUndefVal: // Is it an undef value?
396 return UndefValue::get(Ty);
397
398 case ValID::ConstantVal: // Fully resolved constant?
399 if (D.ConstantValue->getType() != Ty)
400 ThrowException("Constant expression type different from required type!");
401 return D.ConstantValue;
402
403 default:
404 assert(0 && "Unhandled case!");
405 return 0;
406 } // End of switch
407
408 assert(0 && "Unhandled case!");
409 return 0;
410}
411
412// getVal - This function is identical to getValNonImprovising, except that if a
413// value is not already defined, it "improvises" by creating a placeholder var
414// that looks and acts just like the requested variable. When the value is
415// defined later, all uses of the placeholder variable are replaced with the
416// real thing.
417//
418static Value *getVal(const Type *Ty, const ValID &ID) {
419 if (Ty == Type::LabelTy)
420 ThrowException("Cannot use a basic block here");
421
422 // See if the value has already been defined.
423 Value *V = getValNonImprovising(Ty, ID);
424 if (V) return V;
425
426 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
427 ThrowException("Invalid use of a composite type!");
428
429 // If we reached here, we referenced either a symbol that we don't know about
430 // or an id number that hasn't been read yet. We may be referencing something
431 // forward, so just create an entry to be resolved later and get to it...
432 //
433 V = new Argument(Ty);
434
435 // Remember where this forward reference came from. FIXME, shouldn't we try
436 // to recycle these things??
437 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
438 llvmAsmlineno)));
439
440 if (inFunctionScope())
441 InsertValue(V, CurFun.LateResolveValues);
442 else
443 InsertValue(V, CurModule.LateResolveValues);
444 return V;
445}
446
447/// getBBVal - This is used for two purposes:
448/// * If isDefinition is true, a new basic block with the specified ID is being
449/// defined.
450/// * If isDefinition is true, this is a reference to a basic block, which may
451/// or may not be a forward reference.
452///
453static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
454 assert(inFunctionScope() && "Can't get basic block at global scope!");
455
456 std::string Name;
457 BasicBlock *BB = 0;
458 switch (ID.Type) {
459 default: ThrowException("Illegal label reference " + ID.getName());
460 case ValID::NumberVal: // Is it a numbered definition?
461 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
462 CurFun.NumberedBlocks.resize(ID.Num+1);
463 BB = CurFun.NumberedBlocks[ID.Num];
464 break;
465 case ValID::NameVal: // Is it a named definition?
466 Name = ID.Name;
467 if (Value *N = CurFun.CurrentFunction->
468 getSymbolTable().lookup(Type::LabelTy, Name))
469 BB = cast<BasicBlock>(N);
470 break;
471 }
472
473 // See if the block has already been defined.
474 if (BB) {
475 // If this is the definition of the block, make sure the existing value was
476 // just a forward reference. If it was a forward reference, there will be
477 // an entry for it in the PlaceHolderInfo map.
478 if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
479 // The existing value was a definition, not a forward reference.
480 ThrowException("Redefinition of label " + ID.getName());
481
482 ID.destroy(); // Free strdup'd memory.
483 return BB;
484 }
485
486 // Otherwise this block has not been seen before.
487 BB = new BasicBlock("", CurFun.CurrentFunction);
488 if (ID.Type == ValID::NameVal) {
489 BB->setName(ID.Name);
490 } else {
491 CurFun.NumberedBlocks[ID.Num] = BB;
492 }
493
494 // If this is not a definition, keep track of it so we can use it as a forward
495 // reference.
496 if (!isDefinition) {
497 // Remember where this forward reference came from.
498 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
499 } else {
500 // The forward declaration could have been inserted anywhere in the
501 // function: insert it into the correct place now.
502 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
503 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
504 }
505 ID.destroy();
506 return BB;
507}
508
509
510//===----------------------------------------------------------------------===//
511// Code to handle forward references in instructions
512//===----------------------------------------------------------------------===//
513//
514// This code handles the late binding needed with statements that reference
515// values not defined yet... for example, a forward branch, or the PHI node for
516// a loop body.
517//
518// This keeps a table (CurFun.LateResolveValues) of all such forward references
519// and back patchs after we are done.
520//
521
522// ResolveDefinitions - If we could not resolve some defs at parsing
523// time (forward branches, phi functions for loops, etc...) resolve the
524// defs now...
525//
526static void
527ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
528 std::map<const Type*,ValueList> *FutureLateResolvers) {
529 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
530 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
531 E = LateResolvers.end(); LRI != E; ++LRI) {
532 ValueList &List = LRI->second;
533 while (!List.empty()) {
534 Value *V = List.back();
535 List.pop_back();
536
537 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
538 CurModule.PlaceHolderInfo.find(V);
539 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
540
541 ValID &DID = PHI->second.first;
542
543 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
544 if (TheRealValue) {
545 V->replaceAllUsesWith(TheRealValue);
546 delete V;
547 CurModule.PlaceHolderInfo.erase(PHI);
548 } else if (FutureLateResolvers) {
549 // Functions have their unresolved items forwarded to the module late
550 // resolver table
551 InsertValue(V, *FutureLateResolvers);
552 } else {
553 if (DID.Type == ValID::NameVal)
554 ThrowException("Reference to an invalid definition: '" +DID.getName()+
555 "' of type '" + V->getType()->getDescription() + "'",
556 PHI->second.second);
557 else
558 ThrowException("Reference to an invalid definition: #" +
559 itostr(DID.Num) + " of type '" +
560 V->getType()->getDescription() + "'",
561 PHI->second.second);
562 }
563 }
564 }
565
566 LateResolvers.clear();
567}
568
569// ResolveTypeTo - A brand new type was just declared. This means that (if
570// name is not null) things referencing Name can be resolved. Otherwise, things
571// refering to the number can be resolved. Do this now.
572//
573static void ResolveTypeTo(char *Name, const Type *ToTy) {
574 ValID D;
575 if (Name) D = ValID::create(Name);
576 else D = ValID::create((int)CurModule.Types.size());
577
578 std::map<ValID, PATypeHolder>::iterator I =
579 CurModule.LateResolveTypes.find(D);
580 if (I != CurModule.LateResolveTypes.end()) {
581 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
582 CurModule.LateResolveTypes.erase(I);
583 }
584}
585
586// setValueName - Set the specified value to the name given. The name may be
587// null potentially, in which case this is a noop. The string passed in is
588// assumed to be a malloc'd string buffer, and is free'd by this function.
589//
590static void setValueName(Value *V, char *NameStr) {
591 if (NameStr) {
592 std::string Name(NameStr); // Copy string
593 free(NameStr); // Free old string
594
595 if (V->getType() == Type::VoidTy)
596 ThrowException("Can't assign name '" + Name+"' to value with void type!");
597
598 assert(inFunctionScope() && "Must be in function scope!");
599 SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable();
600 if (ST.lookup(V->getType(), Name))
601 ThrowException("Redefinition of value named '" + Name + "' in the '" +
602 V->getType()->getDescription() + "' type plane!");
603
604 // Set the name.
605 V->setName(Name);
606 }
607}
608
609/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
610/// this is a declaration, otherwise it is a definition.
611static void ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
612 bool isConstantGlobal, const Type *Ty,
613 Constant *Initializer) {
614 if (isa<FunctionType>(Ty))
615 ThrowException("Cannot declare global vars of function type!");
616
617 const PointerType *PTy = PointerType::get(Ty);
618
619 std::string Name;
620 if (NameStr) {
621 Name = NameStr; // Copy string
622 free(NameStr); // Free old string
623 }
624
625 // See if this global value was forward referenced. If so, recycle the
626 // object.
627 ValID ID;
628 if (!Name.empty()) {
629 ID = ValID::create((char*)Name.c_str());
630 } else {
631 ID = ValID::create((int)CurModule.Values[PTy].size());
632 }
633
634 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
635 // Move the global to the end of the list, from whereever it was
636 // previously inserted.
637 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
638 CurModule.CurrentModule->getGlobalList().remove(GV);
639 CurModule.CurrentModule->getGlobalList().push_back(GV);
640 GV->setInitializer(Initializer);
641 GV->setLinkage(Linkage);
642 GV->setConstant(isConstantGlobal);
643 InsertValue(GV, CurModule.Values);
644 return;
645 }
646
647 // If this global has a name, check to see if there is already a definition
648 // of this global in the module. If so, merge as appropriate. Note that
649 // this is really just a hack around problems in the CFE. :(
650 if (!Name.empty()) {
651 // We are a simple redefinition of a value, check to see if it is defined
652 // the same as the old one.
653 if (GlobalVariable *EGV =
654 CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
655 // We are allowed to redefine a global variable in two circumstances:
656 // 1. If at least one of the globals is uninitialized or
657 // 2. If both initializers have the same value.
658 //
659 if (!EGV->hasInitializer() || !Initializer ||
660 EGV->getInitializer() == Initializer) {
661
662 // Make sure the existing global version gets the initializer! Make
663 // sure that it also gets marked const if the new version is.
664 if (Initializer && !EGV->hasInitializer())
665 EGV->setInitializer(Initializer);
666 if (isConstantGlobal)
667 EGV->setConstant(true);
668 EGV->setLinkage(Linkage);
669 return;
670 }
671
672 ThrowException("Redefinition of global variable named '" + Name +
673 "' in the '" + Ty->getDescription() + "' type plane!");
674 }
675 }
676
677 // Otherwise there is no existing GV to use, create one now.
678 GlobalVariable *GV =
679 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
680 CurModule.CurrentModule);
681 InsertValue(GV, CurModule.Values);
682}
683
684// setTypeName - Set the specified type to the name given. The name may be
685// null potentially, in which case this is a noop. The string passed in is
686// assumed to be a malloc'd string buffer, and is freed by this function.
687//
688// This function returns true if the type has already been defined, but is
689// allowed to be redefined in the specified context. If the name is a new name
690// for the type plane, it is inserted and false is returned.
691static bool setTypeName(const Type *T, char *NameStr) {
692 assert(!inFunctionScope() && "Can't give types function-local names!");
693 if (NameStr == 0) return false;
694
695 std::string Name(NameStr); // Copy string
696 free(NameStr); // Free old string
697
698 // We don't allow assigning names to void type
699 if (T == Type::VoidTy)
700 ThrowException("Can't assign name '" + Name + "' to the void type!");
701
702 // Set the type name, checking for conflicts as we do so.
703 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
704
705 if (AlreadyExists) { // Inserting a name that is already defined???
706 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
707 assert(Existing && "Conflict but no matching type?");
708
709 // There is only one case where this is allowed: when we are refining an
710 // opaque type. In this case, Existing will be an opaque type.
711 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
712 // We ARE replacing an opaque type!
713 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
714 return true;
715 }
716
717 // Otherwise, this is an attempt to redefine a type. That's okay if
718 // the redefinition is identical to the original. This will be so if
719 // Existing and T point to the same Type object. In this one case we
720 // allow the equivalent redefinition.
721 if (Existing == T) return true; // Yes, it's equal.
722
723 // Any other kind of (non-equivalent) redefinition is an error.
724 ThrowException("Redefinition of type named '" + Name + "' in the '" +
725 T->getDescription() + "' type plane!");
726 }
727
728 return false;
729}
730
731//===----------------------------------------------------------------------===//
732// Code for handling upreferences in type names...
733//
734
735// TypeContains - Returns true if Ty directly contains E in it.
736//
737static bool TypeContains(const Type *Ty, const Type *E) {
738 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
739 E) != Ty->subtype_end();
740}
741
742namespace {
743 struct UpRefRecord {
744 // NestingLevel - The number of nesting levels that need to be popped before
745 // this type is resolved.
746 unsigned NestingLevel;
747
748 // LastContainedTy - This is the type at the current binding level for the
749 // type. Every time we reduce the nesting level, this gets updated.
750 const Type *LastContainedTy;
751
752 // UpRefTy - This is the actual opaque type that the upreference is
753 // represented with.
754 OpaqueType *UpRefTy;
755
756 UpRefRecord(unsigned NL, OpaqueType *URTy)
757 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
758 };
759}
760
761// UpRefs - A list of the outstanding upreferences that need to be resolved.
762static std::vector<UpRefRecord> UpRefs;
763
764/// HandleUpRefs - Every time we finish a new layer of types, this function is
765/// called. It loops through the UpRefs vector, which is a list of the
766/// currently active types. For each type, if the up reference is contained in
767/// the newly completed type, we decrement the level count. When the level
768/// count reaches zero, the upreferenced type is the type that is passed in:
769/// thus we can complete the cycle.
770///
771static PATypeHolder HandleUpRefs(const Type *ty) {
772 if (!ty->isAbstract()) return ty;
773 PATypeHolder Ty(ty);
774 UR_OUT("Type '" << Ty->getDescription() <<
775 "' newly formed. Resolving upreferences.\n" <<
776 UpRefs.size() << " upreferences active!\n");
777
778 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
779 // to zero), we resolve them all together before we resolve them to Ty. At
780 // the end of the loop, if there is anything to resolve to Ty, it will be in
781 // this variable.
782 OpaqueType *TypeToResolve = 0;
783
784 for (unsigned i = 0; i != UpRefs.size(); ++i) {
785 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
786 << UpRefs[i].second->getDescription() << ") = "
787 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
788 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
789 // Decrement level of upreference
790 unsigned Level = --UpRefs[i].NestingLevel;
791 UpRefs[i].LastContainedTy = Ty;
792 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
793 if (Level == 0) { // Upreference should be resolved!
794 if (!TypeToResolve) {
795 TypeToResolve = UpRefs[i].UpRefTy;
796 } else {
797 UR_OUT(" * Resolving upreference for "
798 << UpRefs[i].second->getDescription() << "\n";
799 std::string OldName = UpRefs[i].UpRefTy->getDescription());
800 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
801 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
802 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
803 }
804 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
805 --i; // Do not skip the next element...
806 }
807 }
808 }
809
810 if (TypeToResolve) {
811 UR_OUT(" * Resolving upreference for "
812 << UpRefs[i].second->getDescription() << "\n";
813 std::string OldName = TypeToResolve->getDescription());
814 TypeToResolve->refineAbstractTypeTo(Ty);
815 }
816
817 return Ty;
818}
819
820
821// common code from the two 'RunVMAsmParser' functions
822 static Module * RunParser(Module * M) {
823
824 llvmAsmlineno = 1; // Reset the current line number...
825 ObsoleteVarArgs = false;
826 NewVarArgs = false;
827
828 CurModule.CurrentModule = M;
829 yyparse(); // Parse the file, potentially throwing exception
830
831 Module *Result = ParserResult;
832 ParserResult = 0;
833
834 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
835 {
836 Function* F;
837 if ((F = Result->getNamedFunction("llvm.va_start"))
838 && F->getFunctionType()->getNumParams() == 0)
839 ObsoleteVarArgs = true;
840 if((F = Result->getNamedFunction("llvm.va_copy"))
841 && F->getFunctionType()->getNumParams() == 1)
842 ObsoleteVarArgs = true;
843 }
844
845 if (ObsoleteVarArgs && NewVarArgs)
846 ThrowException("This file is corrupt: it uses both new and old style varargs");
847
848 if(ObsoleteVarArgs) {
849 if(Function* F = Result->getNamedFunction("llvm.va_start")) {
850 if (F->arg_size() != 0)
851 ThrowException("Obsolete va_start takes 0 argument!");
852
853 //foo = va_start()
854 // ->
855 //bar = alloca typeof(foo)
856 //va_start(bar)
857 //foo = load bar
858
859 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
860 const Type* ArgTy = F->getFunctionType()->getReturnType();
861 const Type* ArgTyPtr = PointerType::get(ArgTy);
862 Function* NF = Result->getOrInsertFunction("llvm.va_start",
Jeff Cohen66c5fd62005-10-23 04:37:20 +0000863 RetTy, ArgTyPtr, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000864
865 while (!F->use_empty()) {
866 CallInst* CI = cast<CallInst>(F->use_back());
867 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
868 new CallInst(NF, bar, "", CI);
869 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
870 CI->replaceAllUsesWith(foo);
871 CI->getParent()->getInstList().erase(CI);
872 }
873 Result->getFunctionList().erase(F);
874 }
875
876 if(Function* F = Result->getNamedFunction("llvm.va_end")) {
877 if(F->arg_size() != 1)
878 ThrowException("Obsolete va_end takes 1 argument!");
879
880 //vaend foo
881 // ->
882 //bar = alloca 1 of typeof(foo)
883 //vaend bar
884 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
885 const Type* ArgTy = F->getFunctionType()->getParamType(0);
886 const Type* ArgTyPtr = PointerType::get(ArgTy);
887 Function* NF = Result->getOrInsertFunction("llvm.va_end",
Jeff Cohen66c5fd62005-10-23 04:37:20 +0000888 RetTy, ArgTyPtr, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000889
890 while (!F->use_empty()) {
891 CallInst* CI = cast<CallInst>(F->use_back());
892 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
893 new StoreInst(CI->getOperand(1), bar, CI);
894 new CallInst(NF, bar, "", CI);
895 CI->getParent()->getInstList().erase(CI);
896 }
897 Result->getFunctionList().erase(F);
898 }
899
900 if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
901 if(F->arg_size() != 1)
902 ThrowException("Obsolete va_copy takes 1 argument!");
903 //foo = vacopy(bar)
904 // ->
905 //a = alloca 1 of typeof(foo)
906 //b = alloca 1 of typeof(foo)
907 //store bar -> b
908 //vacopy(a, b)
909 //foo = load a
910
911 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
912 const Type* ArgTy = F->getFunctionType()->getReturnType();
913 const Type* ArgTyPtr = PointerType::get(ArgTy);
914 Function* NF = Result->getOrInsertFunction("llvm.va_copy",
Jeff Cohen66c5fd62005-10-23 04:37:20 +0000915 RetTy, ArgTyPtr, ArgTyPtr,
916 (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000917
918 while (!F->use_empty()) {
919 CallInst* CI = cast<CallInst>(F->use_back());
920 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
921 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
922 new StoreInst(CI->getOperand(1), b, CI);
923 new CallInst(NF, a, b, "", CI);
924 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
925 CI->replaceAllUsesWith(foo);
926 CI->getParent()->getInstList().erase(CI);
927 }
928 Result->getFunctionList().erase(F);
929 }
930 }
931
932 return Result;
933
934 }
935
936//===----------------------------------------------------------------------===//
937// RunVMAsmParser - Define an interface to this parser
938//===----------------------------------------------------------------------===//
939//
940Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
941 set_scan_file(F);
942
943 CurFilename = Filename;
944 return RunParser(new Module(CurFilename));
945}
946
947Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
948 set_scan_string(AsmString);
949
950 CurFilename = "from_memory";
951 if (M == NULL) {
952 return RunParser(new Module (CurFilename));
953 } else {
954 return RunParser(M);
955 }
956}
957
958
Chris Lattnerd91c3212005-11-05 21:54:23 +0000959#line 866 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +0000960typedef union {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000961 llvm::Module *ModuleVal;
962 llvm::Function *FunctionVal;
963 std::pair<llvm::PATypeHolder*, char*> *ArgVal;
964 llvm::BasicBlock *BasicBlockVal;
965 llvm::TerminatorInst *TermInstVal;
966 llvm::Instruction *InstVal;
967 llvm::Constant *ConstVal;
968
969 const llvm::Type *PrimType;
970 llvm::PATypeHolder *TypeVal;
971 llvm::Value *ValueVal;
972
973 std::vector<std::pair<llvm::PATypeHolder*,char*> > *ArgList;
974 std::vector<llvm::Value*> *ValueList;
975 std::list<llvm::PATypeHolder> *TypeList;
976 // Represent the RHS of PHI node
977 std::list<std::pair<llvm::Value*,
978 llvm::BasicBlock*> > *PHIList;
979 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
980 std::vector<llvm::Constant*> *ConstVector;
981
982 llvm::GlobalValue::LinkageTypes Linkage;
983 int64_t SInt64Val;
984 uint64_t UInt64Val;
985 int SIntVal;
986 unsigned UIntVal;
987 double FPVal;
988 bool BoolVal;
989
990 char *StrVal; // This memory is strdup'd!
991 llvm::ValID ValIDVal; // strdup'd memory maybe!
992
993 llvm::Instruction::BinaryOps BinaryOpVal;
994 llvm::Instruction::TermOps TermOpVal;
995 llvm::Instruction::MemoryOps MemOpVal;
996 llvm::Instruction::OtherOps OtherOpVal;
997 llvm::Module::Endianness Endianness;
998} YYSTYPE;
Nate Begeman14b05292005-11-05 09:21:28 +0000999#include <stdio.h>
1000
1001#ifndef __cplusplus
1002#ifndef __STDC__
1003#define const
1004#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001005#endif
1006
1007
1008
Nate Begeman14b05292005-11-05 09:21:28 +00001009#define YYFINAL 429
1010#define YYFLAG -32768
1011#define YYNTBASE 109
Reid Spencer68a24bd2005-08-27 18:50:39 +00001012
Nate Begeman14b05292005-11-05 09:21:28 +00001013#define YYTRANSLATE(x) ((unsigned)(x) <= 348 ? yytranslate[x] : 170)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001014
Nate Begeman14b05292005-11-05 09:21:28 +00001015static const char yytranslate[] = { 0,
1016 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1017 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1018 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1019 2, 2, 2, 2, 2, 2, 2, 2, 2, 97,
1020 98, 106, 2, 107, 2, 2, 2, 2, 2, 2,
1021 2, 2, 2, 2, 2, 2, 2, 2, 2, 102,
1022 95, 103, 2, 2, 2, 2, 2, 2, 2, 2,
1023 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1024 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1025 99, 96, 101, 2, 2, 2, 2, 2, 108, 2,
1026 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1027 2, 2, 2, 2, 2, 2, 2, 2, 2, 100,
1028 2, 2, 104, 2, 105, 2, 2, 2, 2, 2,
1029 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1030 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1031 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1032 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1033 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1034 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1035 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1036 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, 1, 3, 4, 5, 6,
1042 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1043 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1044 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
1045 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
1046 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
1047 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1048 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1049 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1050 87, 88, 89, 90, 91, 92, 93, 94
1051};
Reid Spencer68a24bd2005-08-27 18:50:39 +00001052
Nate Begeman14b05292005-11-05 09:21:28 +00001053#if YYDEBUG != 0
1054static const short yyprhs[] = { 0,
1055 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
1056 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
1057 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
1058 60, 62, 64, 67, 68, 70, 72, 74, 76, 77,
1059 78, 80, 82, 84, 87, 89, 91, 93, 95, 97,
1060 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
1061 119, 121, 123, 125, 127, 129, 132, 137, 143, 149,
1062 153, 156, 159, 161, 165, 167, 171, 173, 174, 179,
1063 183, 187, 192, 197, 201, 204, 207, 210, 213, 216,
1064 219, 222, 225, 228, 231, 238, 244, 253, 260, 267,
1065 274, 281, 285, 287, 289, 291, 293, 296, 299, 302,
1066 304, 309, 312, 318, 324, 328, 333, 334, 336, 338,
1067 342, 346, 350, 354, 358, 360, 361, 363, 365, 367,
1068 368, 371, 375, 377, 379, 383, 385, 386, 393, 395,
1069 397, 401, 403, 405, 408, 409, 413, 415, 417, 419,
1070 421, 423, 425, 427, 431, 433, 435, 437, 439, 441,
1071 444, 447, 450, 454, 457, 458, 460, 463, 466, 470,
1072 480, 490, 499, 513, 515, 517, 524, 530, 533, 540,
1073 548, 550, 554, 556, 557, 560, 562, 568, 574, 580,
1074 583, 588, 593, 600, 605, 610, 615, 618, 626, 628,
1075 631, 632, 634, 635, 638, 644, 650, 659, 662, 668,
1076 674, 683, 686, 691, 698
1077};
Reid Spencer68a24bd2005-08-27 18:50:39 +00001078
Nate Begeman14b05292005-11-05 09:21:28 +00001079static const short yyrhs[] = { 5,
1080 0, 6, 0, 3, 0, 4, 0, 67, 0, 68,
1081 0, 69, 0, 70, 0, 71, 0, 72, 0, 73,
1082 0, 74, 0, 75, 0, 76, 0, 77, 0, 78,
1083 0, 79, 0, 80, 0, 90, 0, 91, 0, 16,
1084 0, 14, 0, 12, 0, 10, 0, 17, 0, 15,
1085 0, 13, 0, 11, 0, 115, 0, 116, 0, 18,
1086 0, 19, 0, 140, 95, 0, 0, 40, 0, 41,
1087 0, 42, 0, 43, 0, 0, 0, 58, 0, 59,
1088 0, 60, 0, 57, 4, 0, 124, 0, 8, 0,
1089 126, 0, 8, 0, 126, 0, 9, 0, 10, 0,
1090 11, 0, 12, 0, 13, 0, 14, 0, 15, 0,
1091 16, 0, 17, 0, 18, 0, 19, 0, 20, 0,
1092 21, 0, 44, 0, 125, 0, 153, 0, 96, 4,
1093 0, 123, 97, 128, 98, 0, 99, 4, 100, 126,
1094 101, 0, 102, 4, 100, 126, 103, 0, 104, 127,
1095 105, 0, 104, 105, 0, 126, 106, 0, 126, 0,
1096 127, 107, 126, 0, 127, 0, 127, 107, 36, 0,
1097 36, 0, 0, 124, 99, 131, 101, 0, 124, 99,
1098 101, 0, 124, 108, 24, 0, 124, 102, 131, 103,
1099 0, 124, 104, 131, 105, 0, 124, 104, 105, 0,
1100 124, 37, 0, 124, 38, 0, 124, 153, 0, 124,
1101 130, 0, 124, 26, 0, 115, 110, 0, 116, 4,
1102 0, 9, 27, 0, 9, 28, 0, 118, 7, 0,
1103 88, 97, 129, 35, 124, 98, 0, 86, 97, 129,
1104 167, 98, 0, 89, 97, 129, 107, 129, 107, 129,
1105 98, 0, 111, 97, 129, 107, 129, 98, 0, 112,
1106 97, 129, 107, 129, 98, 0, 113, 97, 129, 107,
1107 129, 98, 0, 114, 97, 129, 107, 129, 98, 0,
1108 131, 107, 129, 0, 129, 0, 32, 0, 33, 0,
1109 134, 0, 134, 149, 0, 134, 150, 0, 134, 25,
1110 0, 135, 0, 135, 119, 20, 122, 0, 135, 150,
1111 0, 135, 119, 120, 132, 129, 0, 135, 119, 46,
1112 132, 124, 0, 135, 47, 137, 0, 135, 54, 95,
1113 138, 0, 0, 52, 0, 51, 0, 49, 95, 136,
1114 0, 50, 95, 4, 0, 48, 95, 24, 0, 99,
1115 139, 101, 0, 139, 107, 24, 0, 24, 0, 0,
1116 22, 0, 24, 0, 140, 0, 0, 124, 141, 0,
1117 143, 107, 142, 0, 142, 0, 143, 0, 143, 107,
1118 36, 0, 36, 0, 0, 121, 122, 140, 97, 144,
1119 98, 0, 29, 0, 104, 0, 120, 145, 146, 0,
1120 30, 0, 105, 0, 156, 148, 0, 0, 31, 151,
1121 145, 0, 3, 0, 4, 0, 7, 0, 27, 0,
1122 28, 0, 37, 0, 38, 0, 102, 131, 103, 0,
1123 130, 0, 109, 0, 140, 0, 153, 0, 152, 0,
1124 124, 154, 0, 156, 157, 0, 147, 157, 0, 158,
1125 119, 159, 0, 158, 161, 0, 0, 23, 0, 61,
1126 155, 0, 61, 8, 0, 62, 21, 154, 0, 62,
1127 9, 154, 107, 21, 154, 107, 21, 154, 0, 63,
1128 117, 154, 107, 21, 154, 99, 160, 101, 0, 63,
1129 117, 154, 107, 21, 154, 99, 101, 0, 64, 121,
1130 122, 154, 97, 164, 98, 35, 21, 154, 65, 21,
1131 154, 0, 65, 0, 66, 0, 160, 117, 152, 107,
1132 21, 154, 0, 117, 152, 107, 21, 154, 0, 119,
1133 166, 0, 124, 99, 154, 107, 154, 101, 0, 162,
1134 107, 99, 154, 107, 154, 101, 0, 155, 0, 163,
1135 107, 155, 0, 163, 0, 0, 56, 55, 0, 55,
1136 0, 111, 124, 154, 107, 154, 0, 112, 124, 154,
1137 107, 154, 0, 113, 124, 154, 107, 154, 0, 45,
1138 155, 0, 114, 155, 107, 155, 0, 88, 155, 35,
1139 124, 0, 89, 155, 107, 155, 107, 155, 0, 92,
1140 155, 107, 124, 0, 93, 155, 107, 124, 0, 94,
1141 155, 107, 124, 0, 87, 162, 0, 165, 121, 122,
1142 154, 97, 164, 98, 0, 169, 0, 107, 163, 0,
1143 0, 34, 0, 0, 81, 124, 0, 81, 124, 107,
1144 53, 4, 0, 81, 124, 107, 15, 154, 0, 81,
1145 124, 107, 15, 154, 107, 53, 4, 0, 82, 124,
1146 0, 82, 124, 107, 53, 4, 0, 82, 124, 107,
1147 15, 154, 0, 82, 124, 107, 15, 154, 107, 53,
1148 4, 0, 83, 155, 0, 168, 84, 124, 154, 0,
1149 168, 85, 155, 107, 124, 154, 0, 86, 124, 154,
1150 167, 0
1151};
Reid Spencer68a24bd2005-08-27 18:50:39 +00001152
1153#endif
1154
Nate Begeman14b05292005-11-05 09:21:28 +00001155#if YYDEBUG != 0
1156static const short yyrline[] = { 0,
1157 983, 984, 991, 992, 1001, 1001, 1001, 1001, 1001, 1002,
1158 1002, 1002, 1003, 1003, 1003, 1003, 1003, 1003, 1005, 1005,
1159 1009, 1009, 1009, 1009, 1010, 1010, 1010, 1010, 1011, 1011,
1160 1012, 1012, 1015, 1018, 1022, 1022, 1023, 1024, 1025, 1028,
1161 1028, 1029, 1030, 1031, 1045, 1045, 1046, 1046, 1048, 1057,
1162 1057, 1057, 1057, 1057, 1057, 1057, 1058, 1058, 1058, 1058,
1163 1058, 1058, 1059, 1062, 1065, 1071, 1078, 1090, 1094, 1105,
1164 1114, 1117, 1125, 1129, 1134, 1135, 1138, 1141, 1151, 1176,
1165 1189, 1217, 1242, 1262, 1274, 1283, 1287, 1346, 1352, 1360,
1166 1365, 1370, 1373, 1376, 1383, 1393, 1424, 1431, 1452, 1459,
1167 1464, 1474, 1477, 1484, 1484, 1494, 1501, 1505, 1508, 1511,
1168 1524, 1544, 1546, 1550, 1554, 1556, 1558, 1563, 1564, 1566,
1169 1569, 1577, 1582, 1584, 1588, 1592, 1600, 1600, 1601, 1601,
1170 1603, 1609, 1614, 1620, 1623, 1628, 1632, 1636, 1716, 1716,
1171 1718, 1726, 1726, 1728, 1732, 1732, 1741, 1744, 1747, 1750,
1172 1753, 1756, 1759, 1762, 1786, 1793, 1796, 1801, 1801, 1807,
1173 1811, 1814, 1822, 1831, 1835, 1845, 1856, 1859, 1862, 1865,
1174 1868, 1882, 1886, 1939, 1942, 1948, 1956, 1966, 1973, 1978,
1175 1985, 1989, 1995, 1995, 1997, 2000, 2006, 2018, 2026, 2036,
1176 2048, 2055, 2062, 2069, 2074, 2093, 2115, 2129, 2186, 2192,
Chris Lattnerd91c3212005-11-05 21:54:23 +00001177 2194, 2198, 2201, 2207, 2211, 2218, 2222, 2229, 2233, 2240,
1178 2244, 2251, 2258, 2268, 2281
Nate Begeman14b05292005-11-05 09:21:28 +00001179};
1180#endif
1181
1182
1183#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
1184
1185static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL",
1186"EUINT64VAL","SINTVAL","UINTVAL","FPVAL","VOID","BOOL","SBYTE","UBYTE","SHORT",
1187"USHORT","INT","UINT","LONG","ULONG","FLOAT","DOUBLE","TYPE","LABEL","VAR_ID",
1188"LABELSTR","STRINGCONSTANT","IMPLEMENTATION","ZEROINITIALIZER","TRUETOK","FALSETOK",
1189"BEGINTOK","ENDTOK","DECLARE","GLOBAL","CONSTANT","VOLATILE","TO","DOTDOTDOT",
1190"NULL_TOK","UNDEF","CONST","INTERNAL","LINKONCE","WEAK","APPENDING","OPAQUE",
1191"NOT","EXTERNAL","TARGET","TRIPLE","ENDIAN","POINTERSIZE","LITTLE","BIG","ALIGN",
1192"DEPLIBS","CALL","TAIL","CC_TOK","CCC_TOK","FASTCC_TOK","COLDCC_TOK","RET","BR",
1193"SWITCH","INVOKE","UNWIND","UNREACHABLE","ADD","SUB","MUL","DIV","REM","AND",
1194"OR","XOR","SETLE","SETGE","SETLT","SETGT","SETEQ","SETNE","MALLOC","ALLOCA",
1195"FREE","LOAD","STORE","GETELEMENTPTR","PHI_TOK","CAST","SELECT","SHL","SHR",
1196"VAARG","VAARG_old","VANEXT_old","'='","'\\\\'","'('","')'","'['","'x'","']'",
1197"'<'","'>'","'{'","'}'","'*'","','","'c'","INTVAL","EINT64VAL","ArithmeticOps",
1198"LogicalOps","SetCondOps","ShiftOps","SIntType","UIntType","IntType","FPType",
1199"OptAssign","OptLinkage","OptCallingConv","TypesV","UpRTypesV","Types","PrimType",
1200"UpRTypes","TypeListI","ArgTypeListI","ConstVal","ConstExpr","ConstVector","GlobalType",
1201"Module","FunctionList","ConstPool","BigOrLittle","TargetDefinition","LibrariesDefinition",
1202"LibList","Name","OptName","ArgVal","ArgListH","ArgList","FunctionHeaderH","BEGIN",
1203"FunctionHeader","END","Function","FunctionProto","@1","ConstValueRef","SymbolicValueRef",
1204"ValueRef","ResolvedVal","BasicBlockList","BasicBlock","InstructionList","BBTerminatorInst",
1205"JumpTable","Inst","PHIList","ValueRefList","ValueRefListE","OptTailCall","InstVal",
1206"IndexList","OptVolatile","MemoryInst", NULL
1207};
1208#endif
1209
1210static const short yyr1[] = { 0,
1211 109, 109, 110, 110, 111, 111, 111, 111, 111, 112,
1212 112, 112, 113, 113, 113, 113, 113, 113, 114, 114,
1213 115, 115, 115, 115, 116, 116, 116, 116, 117, 117,
1214 118, 118, 119, 119, 120, 120, 120, 120, 120, 121,
1215 121, 121, 121, 121, 122, 122, 123, 123, 124, 125,
1216 125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
1217 125, 125, 126, 126, 126, 126, 126, 126, 126, 126,
1218 126, 126, 127, 127, 128, 128, 128, 128, 129, 129,
1219 129, 129, 129, 129, 129, 129, 129, 129, 129, 129,
1220 129, 129, 129, 129, 130, 130, 130, 130, 130, 130,
1221 130, 131, 131, 132, 132, 133, 134, 134, 134, 134,
1222 135, 135, 135, 135, 135, 135, 135, 136, 136, 137,
1223 137, 137, 138, 139, 139, 139, 140, 140, 141, 141,
1224 142, 143, 143, 144, 144, 144, 144, 145, 146, 146,
1225 147, 148, 148, 149, 151, 150, 152, 152, 152, 152,
1226 152, 152, 152, 152, 152, 153, 153, 154, 154, 155,
1227 156, 156, 157, 158, 158, 158, 159, 159, 159, 159,
1228 159, 159, 159, 159, 159, 160, 160, 161, 162, 162,
1229 163, 163, 164, 164, 165, 165, 166, 166, 166, 166,
1230 166, 166, 166, 166, 166, 166, 166, 166, 166, 167,
1231 167, 168, 168, 169, 169, 169, 169, 169, 169, 169,
1232 169, 169, 169, 169, 169
1233};
1234
1235static const short yyr2[] = { 0,
1236 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1237 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1238 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1239 1, 1, 2, 0, 1, 1, 1, 1, 0, 0,
1240 1, 1, 1, 2, 1, 1, 1, 1, 1, 1,
1241 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1242 1, 1, 1, 1, 1, 2, 4, 5, 5, 3,
1243 2, 2, 1, 3, 1, 3, 1, 0, 4, 3,
1244 3, 4, 4, 3, 2, 2, 2, 2, 2, 2,
1245 2, 2, 2, 2, 6, 5, 8, 6, 6, 6,
1246 6, 3, 1, 1, 1, 1, 2, 2, 2, 1,
1247 4, 2, 5, 5, 3, 4, 0, 1, 1, 3,
1248 3, 3, 3, 3, 1, 0, 1, 1, 1, 0,
1249 2, 3, 1, 1, 3, 1, 0, 6, 1, 1,
1250 3, 1, 1, 2, 0, 3, 1, 1, 1, 1,
1251 1, 1, 1, 3, 1, 1, 1, 1, 1, 2,
1252 2, 2, 3, 2, 0, 1, 2, 2, 3, 9,
1253 9, 8, 13, 1, 1, 6, 5, 2, 6, 7,
1254 1, 3, 1, 0, 2, 1, 5, 5, 5, 2,
1255 4, 4, 6, 4, 4, 4, 2, 7, 1, 2,
1256 0, 1, 0, 2, 5, 5, 8, 2, 5, 5,
1257 8, 2, 4, 6, 4
1258};
1259
1260static const short yydefact[] = { 117,
1261 39, 110, 109, 145, 35, 36, 37, 38, 40, 165,
1262 107, 108, 165, 127, 128, 0, 0, 39, 0, 112,
1263 40, 0, 41, 42, 43, 0, 0, 166, 162, 34,
1264 142, 143, 144, 161, 0, 0, 0, 115, 0, 0,
1265 0, 0, 33, 146, 44, 1, 2, 46, 50, 51,
1266 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
1267 62, 63, 0, 0, 0, 0, 156, 0, 0, 45,
1268 64, 49, 157, 65, 139, 140, 141, 203, 164, 0,
1269 0, 0, 126, 116, 111, 104, 105, 0, 0, 66,
1270 0, 0, 48, 71, 73, 0, 0, 78, 72, 202,
1271 0, 186, 0, 0, 0, 0, 40, 174, 175, 5,
1272 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
1273 16, 17, 18, 0, 0, 0, 0, 0, 0, 0,
1274 19, 20, 0, 0, 0, 0, 0, 0, 0, 163,
1275 40, 178, 0, 199, 122, 119, 118, 120, 121, 125,
1276 0, 114, 50, 51, 52, 53, 54, 55, 56, 57,
1277 58, 59, 60, 0, 0, 0, 0, 113, 0, 0,
1278 70, 0, 137, 77, 75, 0, 0, 190, 185, 168,
1279 167, 0, 0, 24, 28, 23, 27, 22, 26, 21,
1280 25, 29, 30, 0, 0, 204, 208, 212, 0, 0,
1281 197, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1282 0, 0, 0, 123, 0, 92, 93, 3, 4, 90,
1283 91, 94, 89, 85, 86, 0, 0, 0, 0, 0,
1284 0, 0, 0, 0, 0, 0, 88, 87, 47, 47,
1285 74, 136, 130, 133, 134, 0, 0, 67, 147, 148,
1286 149, 150, 151, 152, 153, 0, 155, 159, 158, 160,
1287 0, 169, 0, 0, 0, 0, 201, 0, 0, 0,
1288 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1289 0, 124, 0, 0, 0, 80, 103, 0, 0, 84,
1290 0, 81, 0, 0, 0, 0, 68, 69, 129, 131,
1291 0, 138, 76, 0, 0, 0, 0, 0, 0, 0,
1292 0, 0, 215, 0, 0, 192, 0, 194, 195, 196,
1293 0, 0, 0, 191, 0, 213, 0, 201, 0, 0,
1294 79, 0, 82, 83, 0, 0, 0, 0, 135, 132,
1295 154, 0, 0, 184, 206, 205, 210, 209, 181, 200,
1296 0, 0, 0, 187, 188, 189, 184, 0, 0, 0,
1297 0, 102, 0, 0, 0, 0, 0, 0, 183, 0,
1298 0, 0, 0, 0, 0, 193, 0, 214, 96, 0,
1299 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1300 182, 179, 0, 198, 95, 0, 98, 99, 100, 101,
1301 0, 172, 0, 0, 0, 207, 211, 180, 0, 170,
1302 0, 171, 0, 0, 97, 0, 0, 0, 0, 0,
1303 0, 177, 0, 0, 176, 173, 0, 0, 0
1304};
1305
1306static const short yydefgoto[] = { 67,
1307 220, 233, 234, 235, 236, 164, 165, 194, 166, 18,
1308 9, 26, 68, 69, 167, 71, 72, 96, 176, 287,
1309 257, 288, 88, 427, 1, 2, 148, 38, 84, 151,
1310 73, 300, 244, 245, 246, 27, 77, 10, 33, 11,
1311 12, 21, 258, 74, 260, 349, 13, 29, 30, 140,
1312 404, 79, 201, 369, 370, 141, 142, 313, 143, 144
1313};
1314
1315static const short yypact[] = {-32768,
1316 40, 341,-32768,-32768,-32768,-32768,-32768,-32768, 62, 12,
1317-32768,-32768, -20,-32768,-32768, 110, -67, 48, -50,-32768,
1318 62, 65,-32768,-32768,-32768, 1073, -18,-32768,-32768, 71,
1319-32768,-32768,-32768,-32768, -19, -8, 2,-32768, -15, 1073,
1320 31, 31,-32768,-32768,-32768,-32768,-32768, 8,-32768,-32768,
1321-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1322-32768,-32768, 123, 152, 163, 120,-32768, 71, 17,-32768,
1323-32768, -36,-32768,-32768,-32768,-32768,-32768, 1228,-32768, 148,
1324 72, 170, 164,-32768,-32768,-32768,-32768, 1136, 1173,-32768,
1325 89, 90,-32768,-32768, -36, 58, 94, 835,-32768,-32768,
1326 1136,-32768, 137, 1236, 27, 138, 62,-32768,-32768,-32768,
1327-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1328-32768,-32768,-32768, 1136, 1136, 1136, 1136, 1136, 1136, 1136,
1329-32768,-32768, 1136, 1136, 1136, 1136, 1136, 1136, 1136,-32768,
1330 62,-32768, 77,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1331 -35,-32768, 118, 167, 190, 173, 191, 175, 192, 177,
1332 193, 196, 197, 180, 194, 198, 519,-32768, 1136, 1136,
1333-32768, 1136, 872,-32768, 92, 108, 662,-32768,-32768, 8,
1334-32768, 662, 662,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1335-32768,-32768,-32768, 662, 1073, 100, 101,-32768, 662, 115,
1336 102, 182, 111, 113, 114, 119, 662, 662, 662, 121,
1337 1073, 1136, 1136,-32768, 203,-32768,-32768,-32768,-32768,-32768,
1338-32768,-32768,-32768,-32768,-32768, 132, 133, 134, 935, 1173,
1339 620, 208, 139, 140, 143, 144,-32768,-32768, -74, -29,
1340 -36,-32768, 71,-32768, 127, 117, 972,-32768,-32768,-32768,
1341-32768,-32768,-32768,-32768,-32768, 1173,-32768,-32768,-32768,-32768,
1342 128,-32768, 136, 662, -6, -2, 146, 662, 155, 1136,
1343 1136, 1136, 1136, 1136, 149, 151, 153, 1136, 662, 662,
1344 154,-32768, 1173, 1173, 1173,-32768,-32768, -28, -57,-32768,
1345 61,-32768, 1173, 1173, 1173, 1173,-32768,-32768,-32768,-32768,
1346 1036,-32768,-32768, -11, 230, 238, 165, 662, 262, 662,
1347 263, 1136,-32768, 162, 662,-32768, 166,-32768,-32768,-32768,
1348 662, 662, 662,-32768, 171,-32768, 1136, 146, 235, 169,
1349-32768, 1173,-32768,-32768, 172, 183, 184, 185,-32768,-32768,
1350-32768, 662, 662, 1136, 186,-32768, 187,-32768,-32768, 188,
1351 662, 189, 1136,-32768,-32768,-32768, 1136, 662, 174, 1136,
1352 1173,-32768, 1173, 1173, 1173, 1173, 199, 200, 188, 176,
1353 218, 231, 1136, 202, 662,-32768, 206,-32768,-32768, 209,
1354 201, 211, 212, 213, 214, 266, 5, 254, 293, 294,
1355-32768,-32768, 215,-32768,-32768, 1173,-32768,-32768,-32768,-32768,
1356 662,-32768, 740, 42, 279,-32768,-32768,-32768, 216,-32768,
1357 210,-32768, 740, 662,-32768, 298, 219, 250, 662, 300,
1358 301,-32768, 662, 662,-32768,-32768, 323, 325,-32768
1359};
1360
1361static const short yypgoto[] = {-32768,
1362-32768, 251, 252, 255, 259, -102, -99, -362,-32768, 302,
1363 310, -81, -38,-32768, -26,-32768, -54, 240,-32768, -83,
1364 178, -207, 297,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1365 -1,-32768, 39,-32768,-32768, 320,-32768,-32768,-32768,-32768,
1366 340,-32768, -372, 56, 161, -96,-32768, 333,-32768,-32768,
1367-32768,-32768,-32768, 36, -7,-32768,-32768, 21,-32768,-32768
1368};
1369
1370
1371#define YYLAST 1340
1372
1373
1374static const short yytable[] = { 70,
1375 19, 85, 28, 192, 178, 168, 193, 181, 308, 31,
1376 75, 95, 310, 70, 184, 185, 186, 187, 188, 189,
1377 190, 191, 289, 291, 403, 195, 297, 39, 19, 198,
1378 411, 99, 202, 203, 28, 182, 204, 205, 206, -106,
1379 417, 413, 210, 95, 43, 333, 309, 183, 304, 332,
1380 311, 184, 185, 186, 187, 188, 189, 190, 191, 211,
1381 -47, 152, 86, 87, 3, 214, 97, 40, 45, 99,
1382 4, 215, 331, 298, 177, 80, 99, 177, 332, 5,
1383 6, 7, 8, 83, 32, 76, 81, 5, 6, 7,
1384 8, 341, 14, 41, 15, 332, 82, 196, 197, 177,
1385 199, 200, 177, 177, -48, 402, 177, 177, 177, 207,
1386 208, 209, 177, 98, 239, 240, 281, 241, 22, 23,
1387 24, 25, 146, 147, 46, 47, 90, 93, 49, 50,
1388 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
1389 61, 14, 412, 15, 216, 217, 243, 184, 185, 186,
1390 187, 188, 189, 190, 191, 91, 264, 35, 36, 37,
1391 212, 213, 171, 62, 172, 334, 92, 332, 70, -24,
1392 -24, 145, 279, 149, 317, -23, -23, -22, -22, -21,
1393 -21, 324, 218, 219, 70, 280, 177, 150, 169, 170,
1394 173, 179, 241, -28, -27, -26, -25, 221, 247, 328,
1395 329, 330, -31, -32, 222, 248, 265, 266, 269, 335,
1396 336, 337, 338, 268, 302, 63, 270, 271, 64, 272,
1397 273, 65, 238, 66, 94, 274, 282, 278, 283, 284,
1398 285, 292, 259, 301, 305, 293, 294, 259, 259, 295,
1399 296, 299, 306, 316, 177, 318, 319, 320, 362, 259,
1400 342, 177, 312, 315, 259, 321, 376, 322, 343, 323,
1401 327, 344, 259, 259, 259, 346, 348, 357, 351, 360,
1402 389, 379, 353, 388, 243, 361, 391, 381, 363, 382,
1403 383, 384, 385, 390, 192, 177, 401, 193, 405, 364,
1404 365, 366, 371, 372, 373, 375, 406, 407, 387, 414,
1405 358, 192, 392, 394, 193, 386, 395, 396, 397, 398,
1406 399, 400, 409, 415, 421, 408, 416, 177, 419, 259,
1407 423, 424, 428, 259, 429, 420, 177, 42, 136, 137,
1408 177, 78, 138, 380, 259, 259, 139, 175, 89, 340,
1409 44, 20, 261, 262, 237, 34, 177, 350, 359, 377,
1410 0, 0, 0, 0, 263, 0, 0, 0, 0, 267,
1411 -34, 0, 14, 259, 15, 259, 0, 275, 276, 277,
1412 259, 4, -34, -34, 0, 0, 259, 259, 259, 0,
1413 -34, -34, -34, -34, 0, 0, -34, 16, 0, 0,
1414 0, 0, 0, 0, 17, 0, 0, 259, 259, 0,
1415 0, 0, 0, 0, 0, 0, 259, 0, 0, 0,
1416 0, 0, 0, 259, 0, 0, 0, 0, 0, 0,
1417 0, 0, 0, 0, 307, 0, 0, 0, 314, 0,
1418 259, 0, 0, 0, 0, 0, 0, 0, 0, 325,
1419 326, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1420 0, 0, 0, 0, 0, 0, 259, 0, 0, 0,
1421 0, 0, 0, 0, 0, 0, 0, 0, 345, 259,
1422 347, 0, 0, 0, 259, 352, 0, 0, 259, 259,
1423 0, 354, 355, 356, 0, 0, 0, 0, 0, 0,
1424 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1425 0, 0, 367, 368, 0, 0, 0, 0, 0, 0,
1426 0, 374, 0, 0, 0, 0, 0, 0, 378, 0,
1427 0, 0, 0, 46, 47, 0, 0, 0, 0, 0,
1428 0, 0, 0, 0, 0, 393, 0, 0, 0, 0,
1429 14, 0, 15, 0, 223, 0, 0, 0, 0, 0,
1430 0, 0, 0, 0, 0, 224, 225, 0, 0, 0,
1431 0, 410, 0, 0, 0, 0, 0, 0, 0, 0,
1432 0, 0, 0, 0, 418, 0, 0, 0, 0, 422,
1433 0, 0, 0, 425, 426, 110, 111, 112, 113, 114,
1434 115, 116, 117, 118, 119, 120, 121, 122, 123, 0,
1435 0, 0, 0, 0, 226, 0, 227, 228, 131, 132,
1436 0, 0, 0, 0, 0, 0, 0, 229, 0, 0,
1437 230, 0, 231, 0, 46, 47, 232, 93, 153, 154,
1438 155, 156, 157, 158, 159, 160, 161, 162, 163, 60,
1439 61, 14, 0, 15, 0, 0, 0, 0, 0, 0,
1440 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1441 0, 0, 0, 62, 249, 250, 46, 47, 251, 0,
1442 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1443 0, 0, 0, 14, 0, 15, 0, 0, 252, 253,
1444 0, 0, 0, 0, 0, 0, 0, 0, 254, 255,
1445 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1446 0, 0, 0, 0, 0, 63, 0, 0, 64, 0,
1447 0, 65, 0, 66, 290, 0, 0, 0, 110, 111,
1448 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
1449 122, 123, 249, 250, 0, 0, 251, 226, 0, 227,
1450 228, 131, 132, 0, 0, 0, 0, 0, 0, 0,
1451 0, 0, 0, 256, 0, 0, 252, 253, 0, 0,
1452 0, 0, 0, 0, 0, 0, 254, 255, 0, 0,
1453 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1454 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1455 0, 0, 0, 0, 0, 0, 110, 111, 112, 113,
1456 114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
1457 0, 0, 0, 0, 0, 226, 0, 227, 228, 131,
1458 132, 0, 0, 0, 0, 0, 0, 0, 0, 46,
1459 47, 256, 93, 49, 50, 51, 52, 53, 54, 55,
1460 56, 57, 58, 59, 60, 61, 14, 0, 15, 0,
1461 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1462 174, 0, 0, 0, 0, 0, 46, 47, 62, 93,
1463 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
1464 59, 60, 61, 14, 0, 15, 0, 0, 0, 0,
1465 0, 0, 0, 0, 0, 0, 0, 242, 0, 0,
1466 0, 0, 0, 0, 0, 62, 0, 0, 0, 0,
1467 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1468 63, 0, 0, 64, 0, 0, 65, 0, 66, 46,
1469 47, 0, 93, 153, 154, 155, 156, 157, 158, 159,
1470 160, 161, 162, 163, 60, 61, 14, 0, 15, 0,
1471 0, 0, 0, 0, 0, 0, 0, 63, 0, 0,
1472 64, 0, 0, 65, 0, 66, 46, 47, 62, 93,
1473 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
1474 59, 60, 61, 14, 0, 15, 0, 0, 0, 0,
1475 0, 0, 0, 0, 0, 0, 0, 303, 0, 0,
1476 0, 0, 0, 0, 0, 62, 0, 0, 0, 0,
1477 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1478 63, 0, 0, 64, 0, 286, 65, 0, 66, 0,
1479 46, 47, 0, 93, 49, 50, 51, 52, 53, 54,
1480 55, 56, 57, 58, 59, 60, 61, 14, 0, 15,
1481 0, 0, 0, 0, 0, 0, 0, 63, 0, 0,
1482 64, 339, 0, 65, 0, 66, 0, 46, 47, 62,
1483 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
1484 58, 59, 60, 61, 14, 0, 15, 0, 0, 0,
1485 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1486 0, 0, 0, 0, 0, 0, 62, 0, 0, 0,
1487 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1488 0, 63, 0, 0, 64, 0, 0, 65, 0, 66,
1489 46, 47, 0, 93, 49, 50, 51, 52, 53, 54,
1490 55, 56, 57, 58, 59, 60, 61, 14, 0, 15,
1491 0, 0, 0, 0, 0, 0, 0, 0, 63, 0,
1492 0, 64, 0, 0, 65, 0, 66, 46, 47, 62,
1493 93, 153, 154, 155, 156, 157, 158, 159, 160, 161,
1494 162, 163, 60, 61, 14, 0, 15, 0, 0, 0,
1495 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1496 0, 0, 0, 0, 0, 0, 62, 0, 0, 0,
1497 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1498 0, 63, 0, 0, 64, 0, 0, 65, 0, 66,
1499 46, 47, 0, 180, 49, 50, 51, 52, 53, 54,
1500 55, 56, 57, 58, 59, 60, 61, 14, 0, 15,
1501 0, 100, 0, 0, 0, 0, 0, 0, 63, 0,
1502 0, 64, 101, 0, 65, 0, 66, 0, 0, 62,
1503 0, 0, 102, 103, 0, 0, 0, 0, 104, 105,
1504 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
1505 116, 117, 118, 119, 120, 121, 122, 123, 124, 125,
1506 126, 0, 0, 127, 128, 129, 130, 131, 132, 133,
1507 134, 135, 0, 0, 0, 0, 0, 0, 0, 0,
1508 0, 63, 0, 0, 64, 0, 0, 65, 0, 66
1509};
1510
1511static const short yycheck[] = { 26,
1512 2, 40, 23, 106, 101, 89, 106, 104, 15, 30,
1513 29, 66, 15, 40, 10, 11, 12, 13, 14, 15,
1514 16, 17, 230, 231, 387, 107, 101, 95, 30, 126,
1515 403, 106, 129, 130, 23, 9, 133, 134, 135, 0,
1516 413, 404, 139, 98, 95, 103, 53, 21, 256, 107,
1517 53, 10, 11, 12, 13, 14, 15, 16, 17, 141,
1518 97, 88, 32, 33, 25, 101, 68, 20, 4, 106,
1519 31, 107, 101, 103, 101, 95, 106, 104, 107, 40,
1520 41, 42, 43, 99, 105, 104, 95, 40, 41, 42,
1521 43, 103, 22, 46, 24, 107, 95, 124, 125, 126,
1522 127, 128, 129, 130, 97, 101, 133, 134, 135, 136,
1523 137, 138, 139, 97, 169, 170, 213, 172, 57, 58,
1524 59, 60, 51, 52, 5, 6, 4, 8, 9, 10,
1525 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
1526 21, 22, 101, 24, 27, 28, 173, 10, 11, 12,
1527 13, 14, 15, 16, 17, 4, 195, 48, 49, 50,
1528 84, 85, 105, 44, 107, 105, 4, 107, 195, 3,
1529 4, 24, 211, 4, 271, 3, 4, 3, 4, 3,
1530 4, 278, 3, 4, 211, 212, 213, 24, 100, 100,
1531 97, 55, 247, 4, 4, 4, 4, 4, 107, 283,
1532 284, 285, 7, 7, 7, 98, 107, 107, 107, 293,
1533 294, 295, 296, 99, 98, 96, 35, 107, 99, 107,
1534 107, 102, 167, 104, 105, 107, 24, 107, 97, 97,
1535 97, 24, 177, 107, 107, 97, 97, 182, 183, 97,
1536 97, 243, 107, 270, 271, 272, 273, 274, 332, 194,
1537 21, 278, 107, 99, 199, 107, 353, 107, 21, 107,
1538 107, 97, 207, 208, 209, 4, 4, 97, 107, 35,
1539 53, 98, 107, 98, 301, 107, 373, 361, 107, 363,
1540 364, 365, 366, 53, 387, 312, 21, 387, 35, 107,
1541 107, 107, 107, 107, 107, 107, 4, 4, 99, 21,
1542 327, 404, 101, 98, 404, 107, 98, 107, 98, 98,
1543 98, 98, 396, 98, 65, 101, 107, 344, 21, 264,
1544 21, 21, 0, 268, 0, 107, 353, 18, 78, 78,
1545 357, 30, 78, 360, 279, 280, 78, 98, 42, 301,
1546 21, 2, 182, 183, 167, 13, 373, 312, 328, 357,
1547 -1, -1, -1, -1, 194, -1, -1, -1, -1, 199,
1548 20, -1, 22, 308, 24, 310, -1, 207, 208, 209,
1549 315, 31, 32, 33, -1, -1, 321, 322, 323, -1,
1550 40, 41, 42, 43, -1, -1, 46, 47, -1, -1,
1551 -1, -1, -1, -1, 54, -1, -1, 342, 343, -1,
1552 -1, -1, -1, -1, -1, -1, 351, -1, -1, -1,
1553 -1, -1, -1, 358, -1, -1, -1, -1, -1, -1,
1554 -1, -1, -1, -1, 264, -1, -1, -1, 268, -1,
1555 375, -1, -1, -1, -1, -1, -1, -1, -1, 279,
1556 280, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1557 -1, -1, -1, -1, -1, -1, 401, -1, -1, -1,
1558 -1, -1, -1, -1, -1, -1, -1, -1, 308, 414,
1559 310, -1, -1, -1, 419, 315, -1, -1, 423, 424,
1560 -1, 321, 322, 323, -1, -1, -1, -1, -1, -1,
1561 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1562 -1, -1, 342, 343, -1, -1, -1, -1, -1, -1,
1563 -1, 351, -1, -1, -1, -1, -1, -1, 358, -1,
1564 -1, -1, -1, 5, 6, -1, -1, -1, -1, -1,
1565 -1, -1, -1, -1, -1, 375, -1, -1, -1, -1,
1566 22, -1, 24, -1, 26, -1, -1, -1, -1, -1,
1567 -1, -1, -1, -1, -1, 37, 38, -1, -1, -1,
1568 -1, 401, -1, -1, -1, -1, -1, -1, -1, -1,
1569 -1, -1, -1, -1, 414, -1, -1, -1, -1, 419,
1570 -1, -1, -1, 423, 424, 67, 68, 69, 70, 71,
1571 72, 73, 74, 75, 76, 77, 78, 79, 80, -1,
1572 -1, -1, -1, -1, 86, -1, 88, 89, 90, 91,
1573 -1, -1, -1, -1, -1, -1, -1, 99, -1, -1,
1574 102, -1, 104, -1, 5, 6, 108, 8, 9, 10,
1575 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
1576 21, 22, -1, 24, -1, -1, -1, -1, -1, -1,
1577 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1578 -1, -1, -1, 44, 3, 4, 5, 6, 7, -1,
1579 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1580 -1, -1, -1, 22, -1, 24, -1, -1, 27, 28,
1581 -1, -1, -1, -1, -1, -1, -1, -1, 37, 38,
1582 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1583 -1, -1, -1, -1, -1, 96, -1, -1, 99, -1,
1584 -1, 102, -1, 104, 105, -1, -1, -1, 67, 68,
1585 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
1586 79, 80, 3, 4, -1, -1, 7, 86, -1, 88,
1587 89, 90, 91, -1, -1, -1, -1, -1, -1, -1,
1588 -1, -1, -1, 102, -1, -1, 27, 28, -1, -1,
1589 -1, -1, -1, -1, -1, -1, 37, 38, -1, -1,
1590 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1591 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1592 -1, -1, -1, -1, -1, -1, 67, 68, 69, 70,
1593 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
1594 -1, -1, -1, -1, -1, 86, -1, 88, 89, 90,
1595 91, -1, -1, -1, -1, -1, -1, -1, -1, 5,
1596 6, 102, 8, 9, 10, 11, 12, 13, 14, 15,
1597 16, 17, 18, 19, 20, 21, 22, -1, 24, -1,
1598 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1599 36, -1, -1, -1, -1, -1, 5, 6, 44, 8,
1600 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
1601 19, 20, 21, 22, -1, 24, -1, -1, -1, -1,
1602 -1, -1, -1, -1, -1, -1, -1, 36, -1, -1,
1603 -1, -1, -1, -1, -1, 44, -1, -1, -1, -1,
1604 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1605 96, -1, -1, 99, -1, -1, 102, -1, 104, 5,
1606 6, -1, 8, 9, 10, 11, 12, 13, 14, 15,
1607 16, 17, 18, 19, 20, 21, 22, -1, 24, -1,
1608 -1, -1, -1, -1, -1, -1, -1, 96, -1, -1,
1609 99, -1, -1, 102, -1, 104, 5, 6, 44, 8,
1610 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
1611 19, 20, 21, 22, -1, 24, -1, -1, -1, -1,
1612 -1, -1, -1, -1, -1, -1, -1, 36, -1, -1,
1613 -1, -1, -1, -1, -1, 44, -1, -1, -1, -1,
1614 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1615 96, -1, -1, 99, -1, 101, 102, -1, 104, -1,
1616 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
1617 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
1618 -1, -1, -1, -1, -1, -1, -1, 96, -1, -1,
1619 99, 36, -1, 102, -1, 104, -1, 5, 6, 44,
1620 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
1621 18, 19, 20, 21, 22, -1, 24, -1, -1, -1,
1622 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1623 -1, -1, -1, -1, -1, -1, 44, -1, -1, -1,
1624 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1625 -1, 96, -1, -1, 99, -1, -1, 102, -1, 104,
1626 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
1627 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
1628 -1, -1, -1, -1, -1, -1, -1, -1, 96, -1,
1629 -1, 99, -1, -1, 102, -1, 104, 5, 6, 44,
1630 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
1631 18, 19, 20, 21, 22, -1, 24, -1, -1, -1,
1632 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1633 -1, -1, -1, -1, -1, -1, 44, -1, -1, -1,
1634 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1635 -1, 96, -1, -1, 99, -1, -1, 102, -1, 104,
1636 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
1637 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
1638 -1, 34, -1, -1, -1, -1, -1, -1, 96, -1,
1639 -1, 99, 45, -1, 102, -1, 104, -1, -1, 44,
1640 -1, -1, 55, 56, -1, -1, -1, -1, 61, 62,
1641 63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
1642 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
1643 83, -1, -1, 86, 87, 88, 89, 90, 91, 92,
1644 93, 94, -1, -1, -1, -1, -1, -1, -1, -1,
1645 -1, 96, -1, -1, 99, -1, -1, 102, -1, 104
1646};
1647/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
1648#line 3 "/usr/share/bison.simple"
1649/* This file comes from bison-1.28. */
1650
1651/* Skeleton output parser for bison,
1652 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
1653
1654 This program is free software; you can redistribute it and/or modify
1655 it under the terms of the GNU General Public License as published by
1656 the Free Software Foundation; either version 2, or (at your option)
1657 any later version.
1658
1659 This program is distributed in the hope that it will be useful,
1660 but WITHOUT ANY WARRANTY; without even the implied warranty of
1661 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1662 GNU General Public License for more details.
1663
1664 You should have received a copy of the GNU General Public License
1665 along with this program; if not, write to the Free Software
1666 Foundation, Inc., 59 Temple Place - Suite 330,
1667 Boston, MA 02111-1307, USA. */
1668
1669/* As a special exception, when this file is copied by Bison into a
1670 Bison output file, you may use that output file without restriction.
1671 This special exception was added by the Free Software Foundation
1672 in version 1.24 of Bison. */
1673
1674/* This is the parser code that is written into each bison parser
1675 when the %semantic_parser declaration is not specified in the grammar.
1676 It was written by Richard Stallman by simplifying the hairy parser
1677 used when %semantic_parser is specified. */
1678
1679#ifndef YYSTACK_USE_ALLOCA
1680#ifdef alloca
1681#define YYSTACK_USE_ALLOCA
1682#else /* alloca not defined */
1683#ifdef __GNUC__
1684#define YYSTACK_USE_ALLOCA
1685#define alloca __builtin_alloca
1686#else /* not GNU C. */
1687#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
1688#define YYSTACK_USE_ALLOCA
1689#include <alloca.h>
1690#else /* not sparc */
1691/* We think this test detects Watcom and Microsoft C. */
1692/* This used to test MSDOS, but that is a bad idea
1693 since that symbol is in the user namespace. */
1694#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
1695#if 0 /* No need for malloc.h, which pollutes the namespace;
1696 instead, just don't use alloca. */
1697#include <malloc.h>
1698#endif
1699#else /* not MSDOS, or __TURBOC__ */
1700#if defined(_AIX)
1701/* I don't know what this was needed for, but it pollutes the namespace.
1702 So I turned it off. rms, 2 May 1997. */
1703/* #include <malloc.h> */
1704 #pragma alloca
1705#define YYSTACK_USE_ALLOCA
1706#else /* not MSDOS, or __TURBOC__, or _AIX */
1707#if 0
1708#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
1709 and on HPUX 10. Eventually we can turn this on. */
1710#define YYSTACK_USE_ALLOCA
1711#define alloca __builtin_alloca
1712#endif /* __hpux */
1713#endif
1714#endif /* not _AIX */
1715#endif /* not MSDOS, or __TURBOC__ */
1716#endif /* not sparc */
1717#endif /* not GNU C */
1718#endif /* alloca not defined */
1719#endif /* YYSTACK_USE_ALLOCA not defined */
1720
1721#ifdef YYSTACK_USE_ALLOCA
1722#define YYSTACK_ALLOC alloca
Reid Spencer68a24bd2005-08-27 18:50:39 +00001723#else
Nate Begeman14b05292005-11-05 09:21:28 +00001724#define YYSTACK_ALLOC malloc
Reid Spencer68a24bd2005-08-27 18:50:39 +00001725#endif
1726
Nate Begeman14b05292005-11-05 09:21:28 +00001727/* Note: there must be only one dollar sign in this file.
1728 It is replaced by the list of actions, each action
1729 as one case of the switch. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001730
1731#define yyerrok (yyerrstatus = 0)
1732#define yyclearin (yychar = YYEMPTY)
Nate Begeman14b05292005-11-05 09:21:28 +00001733#define YYEMPTY -2
Reid Spencer68a24bd2005-08-27 18:50:39 +00001734#define YYEOF 0
Reid Spencer68a24bd2005-08-27 18:50:39 +00001735#define YYACCEPT goto yyacceptlab
Nate Begeman14b05292005-11-05 09:21:28 +00001736#define YYABORT goto yyabortlab
1737#define YYERROR goto yyerrlab1
1738/* Like YYERROR except do call yyerror.
1739 This remains here temporarily to ease the
1740 transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00001741 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001742#define YYFAIL goto yyerrlab
Reid Spencer68a24bd2005-08-27 18:50:39 +00001743#define YYRECOVERING() (!!yyerrstatus)
Nate Begeman14b05292005-11-05 09:21:28 +00001744#define YYBACKUP(token, value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00001745do \
1746 if (yychar == YYEMPTY && yylen == 1) \
Nate Begeman14b05292005-11-05 09:21:28 +00001747 { yychar = (token), yylval = (value); \
1748 yychar1 = YYTRANSLATE (yychar); \
Reid Spencer68a24bd2005-08-27 18:50:39 +00001749 YYPOPSTACK; \
1750 goto yybackup; \
1751 } \
1752 else \
Nate Begeman14b05292005-11-05 09:21:28 +00001753 { yyerror ("syntax error: cannot back up"); YYERROR; } \
Reid Spencer68a24bd2005-08-27 18:50:39 +00001754while (0)
1755
1756#define YYTERROR 1
1757#define YYERRCODE 256
1758
Nate Begeman14b05292005-11-05 09:21:28 +00001759#ifndef YYPURE
1760#define YYLEX yylex()
Reid Spencer68a24bd2005-08-27 18:50:39 +00001761#endif
1762
Nate Begeman14b05292005-11-05 09:21:28 +00001763#ifdef YYPURE
1764#ifdef YYLSP_NEEDED
Reid Spencer68a24bd2005-08-27 18:50:39 +00001765#ifdef YYLEX_PARAM
Nate Begeman14b05292005-11-05 09:21:28 +00001766#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001767#else
Nate Begeman14b05292005-11-05 09:21:28 +00001768#define YYLEX yylex(&yylval, &yylloc)
1769#endif
1770#else /* not YYLSP_NEEDED */
1771#ifdef YYLEX_PARAM
1772#define YYLEX yylex(&yylval, YYLEX_PARAM)
1773#else
1774#define YYLEX yylex(&yylval)
1775#endif
1776#endif /* not YYLSP_NEEDED */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001777#endif
1778
Nate Begeman14b05292005-11-05 09:21:28 +00001779/* If nonreentrant, generate the variables here */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001780
Nate Begeman14b05292005-11-05 09:21:28 +00001781#ifndef YYPURE
Reid Spencer68a24bd2005-08-27 18:50:39 +00001782
Nate Begeman14b05292005-11-05 09:21:28 +00001783int yychar; /* the lookahead symbol */
1784YYSTYPE yylval; /* the semantic value of the */
1785 /* lookahead symbol */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001786
Nate Begeman14b05292005-11-05 09:21:28 +00001787#ifdef YYLSP_NEEDED
1788YYLTYPE yylloc; /* location data for the lookahead */
1789 /* symbol */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001790#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001791
Nate Begeman14b05292005-11-05 09:21:28 +00001792int yynerrs; /* number of parse errors so far */
1793#endif /* not YYPURE */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001794
Nate Begeman14b05292005-11-05 09:21:28 +00001795#if YYDEBUG != 0
1796int yydebug; /* nonzero means print parse trace */
1797/* Since this is uninitialized, it does not stop multiple parsers
1798 from coexisting. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001799#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001800
Nate Begeman14b05292005-11-05 09:21:28 +00001801/* YYINITDEPTH indicates the initial size of the parser's stacks */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001802
Reid Spencer68a24bd2005-08-27 18:50:39 +00001803#ifndef YYINITDEPTH
Nate Begeman14b05292005-11-05 09:21:28 +00001804#define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00001805#endif
1806
Nate Begeman14b05292005-11-05 09:21:28 +00001807/* YYMAXDEPTH is the maximum size the stacks can grow to
1808 (effective only if the built-in stack extension method is used). */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001809
Nate Begeman14b05292005-11-05 09:21:28 +00001810#if YYMAXDEPTH == 0
1811#undef YYMAXDEPTH
Reid Spencer68a24bd2005-08-27 18:50:39 +00001812#endif
1813
1814#ifndef YYMAXDEPTH
Nate Begeman14b05292005-11-05 09:21:28 +00001815#define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00001816#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001817
Nate Begeman14b05292005-11-05 09:21:28 +00001818/* Define __yy_memcpy. Note that the size argument
1819 should be passed with type unsigned int, because that is what the non-GCC
1820 definitions require. With GCC, __builtin_memcpy takes an arg
1821 of type size_t, but it can handle unsigned int. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001822
Nate Begeman14b05292005-11-05 09:21:28 +00001823#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
1824#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
1825#else /* not GNU C or C++ */
1826#ifndef __cplusplus
Reid Spencer68a24bd2005-08-27 18:50:39 +00001827
Nate Begeman14b05292005-11-05 09:21:28 +00001828/* This is the most reliable way to avoid incompatibilities
1829 in available built-in functions on various systems. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001830static void
Nate Begeman14b05292005-11-05 09:21:28 +00001831__yy_memcpy (to, from, count)
1832 char *to;
1833 char *from;
1834 unsigned int count;
1835{
1836 register char *f = from;
1837 register char *t = to;
1838 register int i = count;
1839
1840 while (i-- > 0)
1841 *t++ = *f++;
1842}
1843
1844#else /* __cplusplus */
1845
1846/* This is the most reliable way to avoid incompatibilities
1847 in available built-in functions on various systems. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001848static void
Nate Begeman14b05292005-11-05 09:21:28 +00001849__yy_memcpy (char *to, char *from, unsigned int count)
1850{
1851 register char *t = to;
1852 register char *f = from;
1853 register int i = count;
1854
1855 while (i-- > 0)
1856 *t++ = *f++;
1857}
1858
Reid Spencer68a24bd2005-08-27 18:50:39 +00001859#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001860#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001861
Nate Begeman14b05292005-11-05 09:21:28 +00001862#line 217 "/usr/share/bison.simple"
Reid Spencer68a24bd2005-08-27 18:50:39 +00001863
Nate Begeman14b05292005-11-05 09:21:28 +00001864/* The user can define YYPARSE_PARAM as the name of an argument to be passed
1865 into yyparse. The argument should have type void *.
1866 It should actually point to an object.
1867 Grammar actions can access the variable by casting it
1868 to the proper pointer type. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001869
1870#ifdef YYPARSE_PARAM
Nate Begeman14b05292005-11-05 09:21:28 +00001871#ifdef __cplusplus
1872#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
1873#define YYPARSE_PARAM_DECL
1874#else /* not __cplusplus */
1875#define YYPARSE_PARAM_ARG YYPARSE_PARAM
1876#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
1877#endif /* not __cplusplus */
1878#else /* not YYPARSE_PARAM */
1879#define YYPARSE_PARAM_ARG
1880#define YYPARSE_PARAM_DECL
1881#endif /* not YYPARSE_PARAM */
1882
1883/* Prevent warning if -Wstrict-prototypes. */
1884#ifdef __GNUC__
1885#ifdef YYPARSE_PARAM
1886int yyparse (void *);
1887#else
Reid Spencer68a24bd2005-08-27 18:50:39 +00001888int yyparse (void);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001889#endif
Nate Begeman14b05292005-11-05 09:21:28 +00001890#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001891
Reid Spencer68a24bd2005-08-27 18:50:39 +00001892int
Nate Begeman14b05292005-11-05 09:21:28 +00001893yyparse(YYPARSE_PARAM_ARG)
1894 YYPARSE_PARAM_DECL
Reid Spencer68a24bd2005-08-27 18:50:39 +00001895{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001896 register int yystate;
1897 register int yyn;
Nate Begeman14b05292005-11-05 09:21:28 +00001898 register short *yyssp;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001899 register YYSTYPE *yyvsp;
Nate Begeman14b05292005-11-05 09:21:28 +00001900 int yyerrstatus; /* number of tokens to shift before error messages enabled */
1901 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001902
Nate Begeman14b05292005-11-05 09:21:28 +00001903 short yyssa[YYINITDEPTH]; /* the state stack */
1904 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001905
Nate Begeman14b05292005-11-05 09:21:28 +00001906 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
1907 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001908
Nate Begeman14b05292005-11-05 09:21:28 +00001909#ifdef YYLSP_NEEDED
1910 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
1911 YYLTYPE *yyls = yylsa;
1912 YYLTYPE *yylsp;
1913
1914#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
1915#else
Reid Spencer68a24bd2005-08-27 18:50:39 +00001916#define YYPOPSTACK (yyvsp--, yyssp--)
Nate Begeman14b05292005-11-05 09:21:28 +00001917#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001918
Nate Begeman14b05292005-11-05 09:21:28 +00001919 int yystacksize = YYINITDEPTH;
1920 int yyfree_stacks = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001921
Nate Begeman14b05292005-11-05 09:21:28 +00001922#ifdef YYPURE
1923 int yychar;
1924 YYSTYPE yylval;
1925 int yynerrs;
1926#ifdef YYLSP_NEEDED
1927 YYLTYPE yylloc;
1928#endif
1929#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001930
Nate Begeman14b05292005-11-05 09:21:28 +00001931 YYSTYPE yyval; /* the variable used to return */
1932 /* semantic values from the action */
1933 /* routines */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001934
Reid Spencer68a24bd2005-08-27 18:50:39 +00001935 int yylen;
1936
Nate Begeman14b05292005-11-05 09:21:28 +00001937#if YYDEBUG != 0
1938 if (yydebug)
1939 fprintf(stderr, "Starting parse\n");
1940#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001941
1942 yystate = 0;
1943 yyerrstatus = 0;
1944 yynerrs = 0;
1945 yychar = YYEMPTY; /* Cause a token to be read. */
1946
1947 /* Initialize stack pointers.
1948 Waste one element of value and location stack
1949 so that they stay on the same level as the state stack.
1950 The wasted elements are never initialized. */
1951
Nate Begeman14b05292005-11-05 09:21:28 +00001952 yyssp = yyss - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001953 yyvsp = yyvs;
Nate Begeman14b05292005-11-05 09:21:28 +00001954#ifdef YYLSP_NEEDED
1955 yylsp = yyls;
1956#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001957
Nate Begeman14b05292005-11-05 09:21:28 +00001958/* Push a new state, which is found in yystate . */
1959/* In all cases, when you get here, the value and location stacks
1960 have just been pushed. so pushing a state here evens the stacks. */
1961yynewstate:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001962
Nate Begeman14b05292005-11-05 09:21:28 +00001963 *++yyssp = yystate;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001964
Nate Begeman14b05292005-11-05 09:21:28 +00001965 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001966 {
Nate Begeman14b05292005-11-05 09:21:28 +00001967 /* Give user a chance to reallocate the stack */
1968 /* Use copies of these so that the &'s don't force the real ones into memory. */
1969 YYSTYPE *yyvs1 = yyvs;
1970 short *yyss1 = yyss;
1971#ifdef YYLSP_NEEDED
1972 YYLTYPE *yyls1 = yyls;
1973#endif
1974
Reid Spencer68a24bd2005-08-27 18:50:39 +00001975 /* Get the current used size of the three stacks, in elements. */
Nate Begeman14b05292005-11-05 09:21:28 +00001976 int size = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001977
1978#ifdef yyoverflow
Nate Begeman14b05292005-11-05 09:21:28 +00001979 /* Each stack pointer address is followed by the size of
1980 the data in use in that stack, in bytes. */
1981#ifdef YYLSP_NEEDED
1982 /* This used to be a conditional around just the two extra args,
1983 but that might be undefined if yyoverflow is a macro. */
1984 yyoverflow("parser stack overflow",
1985 &yyss1, size * sizeof (*yyssp),
1986 &yyvs1, size * sizeof (*yyvsp),
1987 &yyls1, size * sizeof (*yylsp),
1988 &yystacksize);
1989#else
1990 yyoverflow("parser stack overflow",
1991 &yyss1, size * sizeof (*yyssp),
1992 &yyvs1, size * sizeof (*yyvsp),
1993 &yystacksize);
1994#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001995
Nate Begeman14b05292005-11-05 09:21:28 +00001996 yyss = yyss1; yyvs = yyvs1;
1997#ifdef YYLSP_NEEDED
1998 yyls = yyls1;
1999#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002000#else /* no yyoverflow */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002001 /* Extend the stack our own way. */
Nate Begeman14b05292005-11-05 09:21:28 +00002002 if (yystacksize >= YYMAXDEPTH)
2003 {
2004 yyerror("parser stack overflow");
2005 if (yyfree_stacks)
2006 {
2007 free (yyss);
2008 free (yyvs);
2009#ifdef YYLSP_NEEDED
2010 free (yyls);
2011#endif
2012 }
2013 return 2;
2014 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002015 yystacksize *= 2;
Nate Begeman14b05292005-11-05 09:21:28 +00002016 if (yystacksize > YYMAXDEPTH)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002017 yystacksize = YYMAXDEPTH;
Nate Begeman14b05292005-11-05 09:21:28 +00002018#ifndef YYSTACK_USE_ALLOCA
2019 yyfree_stacks = 1;
2020#endif
2021 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
2022 __yy_memcpy ((char *)yyss, (char *)yyss1,
2023 size * (unsigned int) sizeof (*yyssp));
2024 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
2025 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
2026 size * (unsigned int) sizeof (*yyvsp));
2027#ifdef YYLSP_NEEDED
2028 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
2029 __yy_memcpy ((char *)yyls, (char *)yyls1,
2030 size * (unsigned int) sizeof (*yylsp));
2031#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002032#endif /* no yyoverflow */
2033
Nate Begeman14b05292005-11-05 09:21:28 +00002034 yyssp = yyss + size - 1;
2035 yyvsp = yyvs + size - 1;
2036#ifdef YYLSP_NEEDED
2037 yylsp = yyls + size - 1;
2038#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002039
Nate Begeman14b05292005-11-05 09:21:28 +00002040#if YYDEBUG != 0
2041 if (yydebug)
2042 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2043#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002044
Nate Begeman14b05292005-11-05 09:21:28 +00002045 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002046 YYABORT;
2047 }
2048
Nate Begeman14b05292005-11-05 09:21:28 +00002049#if YYDEBUG != 0
2050 if (yydebug)
2051 fprintf(stderr, "Entering state %d\n", yystate);
2052#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002053
2054 goto yybackup;
Nate Begeman14b05292005-11-05 09:21:28 +00002055 yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002056
2057/* Do appropriate processing given the current state. */
2058/* Read a lookahead token if we need one and don't already have one. */
2059/* yyresume: */
2060
2061 /* First try to decide what to do without reference to lookahead token. */
2062
2063 yyn = yypact[yystate];
Nate Begeman14b05292005-11-05 09:21:28 +00002064 if (yyn == YYFLAG)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002065 goto yydefault;
2066
2067 /* Not known => get a lookahead token if don't already have one. */
2068
Nate Begeman14b05292005-11-05 09:21:28 +00002069 /* yychar is either YYEMPTY or YYEOF
2070 or a valid token in external form. */
2071
Reid Spencer68a24bd2005-08-27 18:50:39 +00002072 if (yychar == YYEMPTY)
2073 {
Nate Begeman14b05292005-11-05 09:21:28 +00002074#if YYDEBUG != 0
2075 if (yydebug)
2076 fprintf(stderr, "Reading a token: ");
2077#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002078 yychar = YYLEX;
2079 }
2080
Nate Begeman14b05292005-11-05 09:21:28 +00002081 /* Convert token to internal form (in yychar1) for indexing tables with */
2082
2083 if (yychar <= 0) /* This means end of input. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002084 {
Nate Begeman14b05292005-11-05 09:21:28 +00002085 yychar1 = 0;
2086 yychar = YYEOF; /* Don't call YYLEX any more */
2087
2088#if YYDEBUG != 0
2089 if (yydebug)
2090 fprintf(stderr, "Now at end of input.\n");
2091#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002092 }
2093 else
2094 {
Nate Begeman14b05292005-11-05 09:21:28 +00002095 yychar1 = YYTRANSLATE(yychar);
2096
2097#if YYDEBUG != 0
2098 if (yydebug)
2099 {
2100 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2101 /* Give the individual parser a way to print the precise meaning
2102 of a token, for further debugging info. */
2103#ifdef YYPRINT
2104 YYPRINT (stderr, yychar, yylval);
2105#endif
2106 fprintf (stderr, ")\n");
2107 }
2108#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002109 }
2110
Nate Begeman14b05292005-11-05 09:21:28 +00002111 yyn += yychar1;
2112 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002113 goto yydefault;
Nate Begeman14b05292005-11-05 09:21:28 +00002114
Reid Spencer68a24bd2005-08-27 18:50:39 +00002115 yyn = yytable[yyn];
Nate Begeman14b05292005-11-05 09:21:28 +00002116
2117 /* yyn is what to do for this token type in this state.
2118 Negative => reduce, -yyn is rule number.
2119 Positive => shift, yyn is new state.
2120 New state is final state => don't bother to shift,
2121 just return success.
2122 0, or most negative number => error. */
2123
2124 if (yyn < 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002125 {
Nate Begeman14b05292005-11-05 09:21:28 +00002126 if (yyn == YYFLAG)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002127 goto yyerrlab;
2128 yyn = -yyn;
2129 goto yyreduce;
2130 }
Nate Begeman14b05292005-11-05 09:21:28 +00002131 else if (yyn == 0)
2132 goto yyerrlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002133
2134 if (yyn == YYFINAL)
2135 YYACCEPT;
2136
2137 /* Shift the lookahead token. */
Nate Begeman14b05292005-11-05 09:21:28 +00002138
2139#if YYDEBUG != 0
2140 if (yydebug)
2141 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2142#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002143
2144 /* Discard the token being shifted unless it is eof. */
2145 if (yychar != YYEOF)
2146 yychar = YYEMPTY;
2147
2148 *++yyvsp = yylval;
Nate Begeman14b05292005-11-05 09:21:28 +00002149#ifdef YYLSP_NEEDED
2150 *++yylsp = yylloc;
2151#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002152
Nate Begeman14b05292005-11-05 09:21:28 +00002153 /* count tokens shifted since error; after three, turn off error status. */
2154 if (yyerrstatus) yyerrstatus--;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002155
2156 yystate = yyn;
2157 goto yynewstate;
2158
Nate Begeman14b05292005-11-05 09:21:28 +00002159/* Do the default action for the current state. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002160yydefault:
Nate Begeman14b05292005-11-05 09:21:28 +00002161
Reid Spencer68a24bd2005-08-27 18:50:39 +00002162 yyn = yydefact[yystate];
2163 if (yyn == 0)
2164 goto yyerrlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002165
Nate Begeman14b05292005-11-05 09:21:28 +00002166/* Do a reduction. yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002167yyreduce:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002168 yylen = yyr2[yyn];
Nate Begeman14b05292005-11-05 09:21:28 +00002169 if (yylen > 0)
2170 yyval = yyvsp[1-yylen]; /* implement default value of the action */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002171
Nate Begeman14b05292005-11-05 09:21:28 +00002172#if YYDEBUG != 0
2173 if (yydebug)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002174 {
Nate Begeman14b05292005-11-05 09:21:28 +00002175 int i;
2176
2177 fprintf (stderr, "Reducing via rule %d (line %d), ",
2178 yyn, yyrline[yyn]);
2179
2180 /* Print the symbols being reduced, and their result. */
2181 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2182 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2183 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2184 }
2185#endif
2186
2187
2188 switch (yyn) {
2189
2190case 2:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002191#line 984 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002192{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002193 if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX) // Outside of my range!
2194 ThrowException("Value too large for type!");
2195 yyval.SIntVal = (int32_t)yyvsp[0].UIntVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002196;
2197 break;}
2198case 4:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002199#line 992 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002200{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002201 if (yyvsp[0].UInt64Val > (uint64_t)INT64_MAX) // Outside of my range!
2202 ThrowException("Value too large for type!");
2203 yyval.SInt64Val = (int64_t)yyvsp[0].UInt64Val;
Nate Begeman14b05292005-11-05 09:21:28 +00002204;
2205 break;}
2206case 33:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002207#line 1015 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002208{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002209 yyval.StrVal = yyvsp[-1].StrVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002210 ;
2211 break;}
2212case 34:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002213#line 1018 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002214{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002215 yyval.StrVal = 0;
Nate Begeman14b05292005-11-05 09:21:28 +00002216 ;
2217 break;}
2218case 35:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002219#line 1022 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002220{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2221 break;}
2222case 36:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002223#line 1023 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002224{ yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2225 break;}
2226case 37:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002227#line 1024 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002228{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2229 break;}
2230case 38:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002231#line 1025 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002232{ yyval.Linkage = GlobalValue::AppendingLinkage; ;
2233 break;}
2234case 39:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002235#line 1026 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002236{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2237 break;}
2238case 40:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002239#line 1028 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002240{ yyval.UIntVal = CallingConv::C; ;
2241 break;}
2242case 41:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002243#line 1029 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002244{ yyval.UIntVal = CallingConv::C; ;
2245 break;}
2246case 42:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002247#line 1030 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002248{ yyval.UIntVal = CallingConv::Fast; ;
2249 break;}
2250case 43:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002251#line 1031 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002252{ yyval.UIntVal = CallingConv::Cold; ;
2253 break;}
2254case 44:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002255#line 1032 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002256{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002257 if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
2258 ThrowException("Calling conv too large!");
2259 yyval.UIntVal = yyvsp[0].UInt64Val;
Nate Begeman14b05292005-11-05 09:21:28 +00002260 ;
2261 break;}
2262case 46:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002263#line 1045 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002264{ yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2265 break;}
2266case 48:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002267#line 1046 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002268{ yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2269 break;}
2270case 49:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002271#line 1048 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002272{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002273 if (!UpRefs.empty())
2274 ThrowException("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
2275 yyval.TypeVal = yyvsp[0].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002276 ;
2277 break;}
2278case 63:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002279#line 1059 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002280{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002281 yyval.TypeVal = new PATypeHolder(OpaqueType::get());
Nate Begeman14b05292005-11-05 09:21:28 +00002282 ;
2283 break;}
2284case 64:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002285#line 1062 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002286{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002287 yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
Nate Begeman14b05292005-11-05 09:21:28 +00002288 ;
2289 break;}
2290case 65:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002291#line 1065 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002292{ // Named types are also simple types...
Reid Spencer68a24bd2005-08-27 18:50:39 +00002293 yyval.TypeVal = new PATypeHolder(getTypeVal(yyvsp[0].ValIDVal));
Nate Begeman14b05292005-11-05 09:21:28 +00002294;
2295 break;}
2296case 66:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002297#line 1071 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002298{ // Type UpReference
Reid Spencer68a24bd2005-08-27 18:50:39 +00002299 if (yyvsp[0].UInt64Val > (uint64_t)~0U) ThrowException("Value out of range!");
2300 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
2301 UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector...
2302 yyval.TypeVal = new PATypeHolder(OT);
2303 UR_OUT("New Upreference!\n");
Nate Begeman14b05292005-11-05 09:21:28 +00002304 ;
2305 break;}
2306case 67:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002307#line 1078 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002308{ // Function derived type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002309 std::vector<const Type*> Params;
2310 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2311 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2312 Params.push_back(*I);
2313 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
2314 if (isVarArg) Params.pop_back();
2315
2316 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FunctionType::get(*yyvsp[-3].TypeVal,Params,isVarArg)));
2317 delete yyvsp[-1].TypeList; // Delete the argument list
2318 delete yyvsp[-3].TypeVal; // Delete the return type handle
Nate Begeman14b05292005-11-05 09:21:28 +00002319 ;
2320 break;}
2321case 68:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002322#line 1090 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002323{ // Sized array type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002324 yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2325 delete yyvsp[-1].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002326 ;
2327 break;}
2328case 69:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002329#line 1094 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002330{ // Packed array type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002331 const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
2332 if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val) {
2333 ThrowException("Unsigned result not equal to signed result");
2334 }
2335 if(!ElemTy->isPrimitiveType()) {
2336 ThrowException("Elemental type of a PackedType must be primitive");
2337 }
2338 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PackedType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2339 delete yyvsp[-1].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002340 ;
2341 break;}
2342case 70:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002343#line 1105 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002344{ // Structure type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002345 std::vector<const Type*> Elements;
2346 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2347 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2348 Elements.push_back(*I);
2349
2350 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
2351 delete yyvsp[-1].TypeList;
Nate Begeman14b05292005-11-05 09:21:28 +00002352 ;
2353 break;}
2354case 71:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002355#line 1114 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002356{ // Empty structure type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002357 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Nate Begeman14b05292005-11-05 09:21:28 +00002358 ;
2359 break;}
2360case 72:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002361#line 1117 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002362{ // Pointer type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002363 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal)));
2364 delete yyvsp[-1].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002365 ;
2366 break;}
2367case 73:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002368#line 1125 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002369{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002370 yyval.TypeList = new std::list<PATypeHolder>();
2371 yyval.TypeList->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002372 ;
2373 break;}
2374case 74:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002375#line 1129 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002376{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002377 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002378 ;
2379 break;}
2380case 76:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002381#line 1135 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002382{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002383 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(Type::VoidTy);
Nate Begeman14b05292005-11-05 09:21:28 +00002384 ;
2385 break;}
2386case 77:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002387#line 1138 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002388{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002389 (yyval.TypeList = new std::list<PATypeHolder>())->push_back(Type::VoidTy);
Nate Begeman14b05292005-11-05 09:21:28 +00002390 ;
2391 break;}
2392case 78:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002393#line 1141 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002394{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002395 yyval.TypeList = new std::list<PATypeHolder>();
Nate Begeman14b05292005-11-05 09:21:28 +00002396 ;
2397 break;}
2398case 79:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002399#line 1151 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002400{ // Nonempty unsized arr
Reid Spencer68a24bd2005-08-27 18:50:39 +00002401 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
2402 if (ATy == 0)
2403 ThrowException("Cannot make array constant with type: '" +
2404 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2405 const Type *ETy = ATy->getElementType();
2406 int NumElements = ATy->getNumElements();
2407
2408 // Verify that we have the correct size...
2409 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2410 ThrowException("Type mismatch: constant sized array initialized with " +
2411 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
2412 itostr(NumElements) + "!");
2413
2414 // Verify all elements are correct type!
2415 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2416 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2417 ThrowException("Element #" + utostr(i) + " is not of type '" +
2418 ETy->getDescription() +"' as required!\nIt is of type '"+
2419 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2420 }
2421
2422 yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
2423 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Nate Begeman14b05292005-11-05 09:21:28 +00002424 ;
2425 break;}
2426case 80:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002427#line 1176 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002428{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002429 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2430 if (ATy == 0)
2431 ThrowException("Cannot make array constant with type: '" +
2432 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2433
2434 int NumElements = ATy->getNumElements();
2435 if (NumElements != -1 && NumElements != 0)
2436 ThrowException("Type mismatch: constant sized array initialized with 0"
2437 " arguments, but has size of " + itostr(NumElements) +"!");
2438 yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
2439 delete yyvsp[-2].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002440 ;
2441 break;}
2442case 81:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002443#line 1189 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002444{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002445 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2446 if (ATy == 0)
2447 ThrowException("Cannot make array constant with type: '" +
2448 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2449
2450 int NumElements = ATy->getNumElements();
2451 const Type *ETy = ATy->getElementType();
2452 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
2453 if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal))
2454 ThrowException("Can't build string constant of size " +
2455 itostr((int)(EndStr-yyvsp[0].StrVal)) +
2456 " when array has size " + itostr(NumElements) + "!");
2457 std::vector<Constant*> Vals;
2458 if (ETy == Type::SByteTy) {
2459 for (char *C = yyvsp[0].StrVal; C != EndStr; ++C)
2460 Vals.push_back(ConstantSInt::get(ETy, *C));
2461 } else if (ETy == Type::UByteTy) {
2462 for (char *C = yyvsp[0].StrVal; C != EndStr; ++C)
2463 Vals.push_back(ConstantUInt::get(ETy, (unsigned char)*C));
2464 } else {
2465 free(yyvsp[0].StrVal);
2466 ThrowException("Cannot build string arrays of non byte sized elements!");
2467 }
2468 free(yyvsp[0].StrVal);
2469 yyval.ConstVal = ConstantArray::get(ATy, Vals);
2470 delete yyvsp[-2].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002471 ;
2472 break;}
2473case 82:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002474#line 1217 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002475{ // Nonempty unsized arr
Reid Spencer68a24bd2005-08-27 18:50:39 +00002476 const PackedType *PTy = dyn_cast<PackedType>(yyvsp[-3].TypeVal->get());
2477 if (PTy == 0)
2478 ThrowException("Cannot make packed constant with type: '" +
2479 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2480 const Type *ETy = PTy->getElementType();
2481 int NumElements = PTy->getNumElements();
2482
2483 // Verify that we have the correct size...
2484 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2485 ThrowException("Type mismatch: constant sized packed initialized with " +
2486 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
2487 itostr(NumElements) + "!");
2488
2489 // Verify all elements are correct type!
2490 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2491 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2492 ThrowException("Element #" + utostr(i) + " is not of type '" +
2493 ETy->getDescription() +"' as required!\nIt is of type '"+
2494 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2495 }
2496
2497 yyval.ConstVal = ConstantPacked::get(PTy, *yyvsp[-1].ConstVector);
2498 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Nate Begeman14b05292005-11-05 09:21:28 +00002499 ;
2500 break;}
2501case 83:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002502#line 1242 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002503{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002504 const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
2505 if (STy == 0)
2506 ThrowException("Cannot make struct constant with type: '" +
2507 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2508
2509 if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
2510 ThrowException("Illegal number of initializers for structure type!");
2511
2512 // Check to ensure that constants are compatible with the type initializer!
2513 for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
2514 if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
2515 ThrowException("Expected type '" +
2516 STy->getElementType(i)->getDescription() +
2517 "' for element #" + utostr(i) +
2518 " of structure initializer!");
2519
2520 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
2521 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Nate Begeman14b05292005-11-05 09:21:28 +00002522 ;
2523 break;}
2524case 84:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002525#line 1262 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002526{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002527 const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
2528 if (STy == 0)
2529 ThrowException("Cannot make struct constant with type: '" +
2530 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2531
2532 if (STy->getNumContainedTypes() != 0)
2533 ThrowException("Illegal number of initializers for structure type!");
2534
2535 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
2536 delete yyvsp[-2].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002537 ;
2538 break;}
2539case 85:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002540#line 1274 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002541{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002542 const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
2543 if (PTy == 0)
2544 ThrowException("Cannot make null pointer constant with type: '" +
2545 (*yyvsp[-1].TypeVal)->getDescription() + "'!");
2546
2547 yyval.ConstVal = ConstantPointerNull::get(PTy);
2548 delete yyvsp[-1].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002549 ;
2550 break;}
2551case 86:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002552#line 1283 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002553{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002554 yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
2555 delete yyvsp[-1].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002556 ;
2557 break;}
2558case 87:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002559#line 1287 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002560{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002561 const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
2562 if (Ty == 0)
2563 ThrowException("Global const reference must be a pointer type!");
2564
2565 // ConstExprs can exist in the body of a function, thus creating
2566 // GlobalValues whenever they refer to a variable. Because we are in
2567 // the context of a function, getValNonImprovising will search the functions
2568 // symbol table instead of the module symbol table for the global symbol,
2569 // which throws things all off. To get around this, we just tell
2570 // getValNonImprovising that we are at global scope here.
2571 //
2572 Function *SavedCurFn = CurFun.CurrentFunction;
2573 CurFun.CurrentFunction = 0;
2574
2575 Value *V = getValNonImprovising(Ty, yyvsp[0].ValIDVal);
2576
2577 CurFun.CurrentFunction = SavedCurFn;
2578
2579 // If this is an initializer for a constant pointer, which is referencing a
2580 // (currently) undefined variable, create a stub now that shall be replaced
2581 // in the future with the right type of variable.
2582 //
2583 if (V == 0) {
2584 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
2585 const PointerType *PT = cast<PointerType>(Ty);
2586
2587 // First check to see if the forward references value is already created!
2588 PerModuleInfo::GlobalRefsType::iterator I =
2589 CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
2590
2591 if (I != CurModule.GlobalRefs.end()) {
2592 V = I->second; // Placeholder already exists, use it...
2593 yyvsp[0].ValIDVal.destroy();
2594 } else {
2595 std::string Name;
2596 if (yyvsp[0].ValIDVal.Type == ValID::NameVal) Name = yyvsp[0].ValIDVal.Name;
2597
2598 // Create the forward referenced global.
2599 GlobalValue *GV;
2600 if (const FunctionType *FTy =
2601 dyn_cast<FunctionType>(PT->getElementType())) {
2602 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
2603 CurModule.CurrentModule);
2604 } else {
2605 GV = new GlobalVariable(PT->getElementType(), false,
2606 GlobalValue::ExternalLinkage, 0,
2607 Name, CurModule.CurrentModule);
2608 }
2609
2610 // Keep track of the fact that we have a forward ref to recycle it
2611 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
2612 V = GV;
2613 }
2614 }
2615
2616 yyval.ConstVal = cast<GlobalValue>(V);
2617 delete yyvsp[-1].TypeVal; // Free the type handle
Nate Begeman14b05292005-11-05 09:21:28 +00002618 ;
2619 break;}
2620case 88:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002621#line 1346 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002622{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002623 if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
2624 ThrowException("Mismatched types for constant expression!");
2625 yyval.ConstVal = yyvsp[0].ConstVal;
2626 delete yyvsp[-1].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002627 ;
2628 break;}
2629case 89:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002630#line 1352 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002631{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002632 const Type *Ty = yyvsp[-1].TypeVal->get();
2633 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
2634 ThrowException("Cannot create a null initialized value of this type!");
2635 yyval.ConstVal = Constant::getNullValue(Ty);
2636 delete yyvsp[-1].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002637 ;
2638 break;}
2639case 90:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002640#line 1360 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002641{ // integral constants
Reid Spencer68a24bd2005-08-27 18:50:39 +00002642 if (!ConstantSInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
2643 ThrowException("Constant value doesn't fit in type!");
2644 yyval.ConstVal = ConstantSInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val);
Nate Begeman14b05292005-11-05 09:21:28 +00002645 ;
2646 break;}
2647case 91:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002648#line 1365 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002649{ // integral constants
Reid Spencer68a24bd2005-08-27 18:50:39 +00002650 if (!ConstantUInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
2651 ThrowException("Constant value doesn't fit in type!");
2652 yyval.ConstVal = ConstantUInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val);
Nate Begeman14b05292005-11-05 09:21:28 +00002653 ;
2654 break;}
2655case 92:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002656#line 1370 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002657{ // Boolean constants
Reid Spencer68a24bd2005-08-27 18:50:39 +00002658 yyval.ConstVal = ConstantBool::True;
Nate Begeman14b05292005-11-05 09:21:28 +00002659 ;
2660 break;}
2661case 93:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002662#line 1373 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002663{ // Boolean constants
Reid Spencer68a24bd2005-08-27 18:50:39 +00002664 yyval.ConstVal = ConstantBool::False;
Nate Begeman14b05292005-11-05 09:21:28 +00002665 ;
2666 break;}
2667case 94:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002668#line 1376 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002669{ // Float & Double constants
Reid Spencer68a24bd2005-08-27 18:50:39 +00002670 if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal))
2671 ThrowException("Floating point constant invalid for type!!");
2672 yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal);
Nate Begeman14b05292005-11-05 09:21:28 +00002673 ;
2674 break;}
2675case 95:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002676#line 1383 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002677{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002678 if (!yyvsp[-3].ConstVal->getType()->isFirstClassType())
2679 ThrowException("cast constant expression from a non-primitive type: '" +
2680 yyvsp[-3].ConstVal->getType()->getDescription() + "'!");
2681 if (!yyvsp[-1].TypeVal->get()->isFirstClassType())
2682 ThrowException("cast constant expression to a non-primitive type: '" +
2683 yyvsp[-1].TypeVal->get()->getDescription() + "'!");
2684 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-3].ConstVal, yyvsp[-1].TypeVal->get());
2685 delete yyvsp[-1].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002686 ;
2687 break;}
2688case 96:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002689#line 1393 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002690{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002691 if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
2692 ThrowException("GetElementPtr requires a pointer operand!");
2693
2694 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
2695 // indices to uint struct indices for compatibility.
2696 generic_gep_type_iterator<std::vector<Value*>::iterator>
2697 GTI = gep_type_begin(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end()),
2698 GTE = gep_type_end(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end());
2699 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
2700 if (isa<StructType>(*GTI)) // Only change struct indices
2701 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[-1].ValueList)[i]))
2702 if (CUI->getType() == Type::UByteTy)
2703 (*yyvsp[-1].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
2704
2705 const Type *IdxTy =
2706 GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), *yyvsp[-1].ValueList, true);
2707 if (!IdxTy)
2708 ThrowException("Index list invalid for constant getelementptr!");
2709
2710 std::vector<Constant*> IdxVec;
2711 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
2712 if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
2713 IdxVec.push_back(C);
2714 else
2715 ThrowException("Indices to constant getelementptr must be constants!");
2716
2717 delete yyvsp[-1].ValueList;
2718
2719 yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, IdxVec);
Nate Begeman14b05292005-11-05 09:21:28 +00002720 ;
2721 break;}
2722case 97:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002723#line 1424 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002724{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002725 if (yyvsp[-5].ConstVal->getType() != Type::BoolTy)
2726 ThrowException("Select condition must be of boolean type!");
2727 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2728 ThrowException("Select operand types must match!");
2729 yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Nate Begeman14b05292005-11-05 09:21:28 +00002730 ;
2731 break;}
2732case 98:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002733#line 1431 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002734{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002735 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2736 ThrowException("Binary operator types must match!");
2737 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
2738 // To retain backward compatibility with these early compilers, we emit a
2739 // cast to the appropriate integer type automatically if we are in the
2740 // broken case. See PR424 for more information.
2741 if (!isa<PointerType>(yyvsp[-3].ConstVal->getType())) {
2742 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2743 } else {
2744 const Type *IntPtrTy = 0;
2745 switch (CurModule.CurrentModule->getPointerSize()) {
2746 case Module::Pointer32: IntPtrTy = Type::IntTy; break;
2747 case Module::Pointer64: IntPtrTy = Type::LongTy; break;
2748 default: ThrowException("invalid pointer binary constant expr!");
2749 }
2750 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, ConstantExpr::getCast(yyvsp[-3].ConstVal, IntPtrTy),
2751 ConstantExpr::getCast(yyvsp[-1].ConstVal, IntPtrTy));
2752 yyval.ConstVal = ConstantExpr::getCast(yyval.ConstVal, yyvsp[-3].ConstVal->getType());
2753 }
Nate Begeman14b05292005-11-05 09:21:28 +00002754 ;
2755 break;}
2756case 99:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002757#line 1452 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002758{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002759 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2760 ThrowException("Logical operator types must match!");
2761 if (!yyvsp[-3].ConstVal->getType()->isIntegral())
2762 ThrowException("Logical operands must have integral types!");
2763 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Nate Begeman14b05292005-11-05 09:21:28 +00002764 ;
2765 break;}
2766case 100:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002767#line 1459 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002768{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002769 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2770 ThrowException("setcc operand types must match!");
2771 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Nate Begeman14b05292005-11-05 09:21:28 +00002772 ;
2773 break;}
2774case 101:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002775#line 1464 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002776{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002777 if (yyvsp[-1].ConstVal->getType() != Type::UByteTy)
2778 ThrowException("Shift count for shift constant must be unsigned byte!");
2779 if (!yyvsp[-3].ConstVal->getType()->isInteger())
2780 ThrowException("Shift constant expression requires integer operand!");
2781 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].OtherOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Nate Begeman14b05292005-11-05 09:21:28 +00002782 ;
2783 break;}
2784case 102:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002785#line 1474 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002786{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002787 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
Nate Begeman14b05292005-11-05 09:21:28 +00002788 ;
2789 break;}
2790case 103:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002791#line 1477 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002792{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002793 yyval.ConstVector = new std::vector<Constant*>();
2794 yyval.ConstVector->push_back(yyvsp[0].ConstVal);
Nate Begeman14b05292005-11-05 09:21:28 +00002795 ;
2796 break;}
2797case 104:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002798#line 1484 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002799{ yyval.BoolVal = false; ;
2800 break;}
2801case 105:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002802#line 1484 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002803{ yyval.BoolVal = true; ;
2804 break;}
2805case 106:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002806#line 1494 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002807{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002808 yyval.ModuleVal = ParserResult = yyvsp[0].ModuleVal;
2809 CurModule.ModuleDone();
Nate Begeman14b05292005-11-05 09:21:28 +00002810;
2811 break;}
2812case 107:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002813#line 1501 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002814{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002815 yyval.ModuleVal = yyvsp[-1].ModuleVal;
2816 CurFun.FunctionDone();
Nate Begeman14b05292005-11-05 09:21:28 +00002817 ;
2818 break;}
2819case 108:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002820#line 1505 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002821{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002822 yyval.ModuleVal = yyvsp[-1].ModuleVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002823 ;
2824 break;}
2825case 109:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002826#line 1508 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002827{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002828 yyval.ModuleVal = yyvsp[-1].ModuleVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002829 ;
2830 break;}
2831case 110:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002832#line 1511 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002833{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002834 yyval.ModuleVal = CurModule.CurrentModule;
2835 // Emit an error if there are any unresolved types left.
2836 if (!CurModule.LateResolveTypes.empty()) {
2837 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
2838 if (DID.Type == ValID::NameVal)
2839 ThrowException("Reference to an undefined type: '"+DID.getName() + "'");
2840 else
2841 ThrowException("Reference to an undefined type: #" + itostr(DID.Num));
2842 }
Nate Begeman14b05292005-11-05 09:21:28 +00002843 ;
2844 break;}
2845case 111:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002846#line 1524 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002847{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002848 // Eagerly resolve types. This is not an optimization, this is a
2849 // requirement that is due to the fact that we could have this:
2850 //
2851 // %list = type { %list * }
2852 // %list = type { %list * } ; repeated type decl
2853 //
2854 // If types are not resolved eagerly, then the two types will not be
2855 // determined to be the same type!
2856 //
2857 ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
2858
2859 if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
2860 // If this is a named type that is not a redefinition, add it to the slot
2861 // table.
2862 CurModule.Types.push_back(*yyvsp[0].TypeVal);
2863 }
2864
2865 delete yyvsp[0].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002866 ;
2867 break;}
2868case 112:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002869#line 1544 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002870{ // Function prototypes can be in const pool
2871 ;
2872 break;}
2873case 113:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002874#line 1546 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002875{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002876 if (yyvsp[0].ConstVal == 0) ThrowException("Global value initializer is not a constant!");
2877 ParseGlobalVariable(yyvsp[-3].StrVal, yyvsp[-2].Linkage, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal);
Nate Begeman14b05292005-11-05 09:21:28 +00002878 ;
2879 break;}
2880case 114:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002881#line 1550 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002882{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002883 ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalLinkage, yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0);
2884 delete yyvsp[0].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002885 ;
2886 break;}
2887case 115:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002888#line 1554 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002889{
2890 ;
2891 break;}
2892case 116:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002893#line 1556 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002894{
2895 ;
2896 break;}
2897case 117:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002898#line 1558 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002899{
2900 ;
2901 break;}
2902case 118:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002903#line 1563 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002904{ yyval.Endianness = Module::BigEndian; ;
2905 break;}
2906case 119:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002907#line 1564 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002908{ yyval.Endianness = Module::LittleEndian; ;
2909 break;}
2910case 120:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002911#line 1566 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002912{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002913 CurModule.CurrentModule->setEndianness(yyvsp[0].Endianness);
Nate Begeman14b05292005-11-05 09:21:28 +00002914 ;
2915 break;}
2916case 121:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002917#line 1569 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002918{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002919 if (yyvsp[0].UInt64Val == 32)
2920 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
2921 else if (yyvsp[0].UInt64Val == 64)
2922 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
2923 else
2924 ThrowException("Invalid pointer size: '" + utostr(yyvsp[0].UInt64Val) + "'!");
Nate Begeman14b05292005-11-05 09:21:28 +00002925 ;
2926 break;}
2927case 122:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002928#line 1577 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002929{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002930 CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal);
2931 free(yyvsp[0].StrVal);
Nate Begeman14b05292005-11-05 09:21:28 +00002932 ;
2933 break;}
2934case 124:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002935#line 1584 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002936{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002937 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
2938 free(yyvsp[0].StrVal);
Nate Begeman14b05292005-11-05 09:21:28 +00002939 ;
2940 break;}
2941case 125:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002942#line 1588 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002943{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002944 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
2945 free(yyvsp[0].StrVal);
Nate Begeman14b05292005-11-05 09:21:28 +00002946 ;
2947 break;}
2948case 126:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002949#line 1592 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002950{
2951 ;
2952 break;}
2953case 130:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002954#line 1601 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002955{ yyval.StrVal = 0; ;
2956 break;}
2957case 131:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002958#line 1603 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002959{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002960 if (*yyvsp[-1].TypeVal == Type::VoidTy)
2961 ThrowException("void typed arguments are invalid!");
2962 yyval.ArgVal = new std::pair<PATypeHolder*, char*>(yyvsp[-1].TypeVal, yyvsp[0].StrVal);
Nate Begeman14b05292005-11-05 09:21:28 +00002963;
2964 break;}
2965case 132:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002966#line 1609 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002967{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002968 yyval.ArgList = yyvsp[-2].ArgList;
2969 yyvsp[-2].ArgList->push_back(*yyvsp[0].ArgVal);
2970 delete yyvsp[0].ArgVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002971 ;
2972 break;}
2973case 133:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002974#line 1614 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002975{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002976 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
2977 yyval.ArgList->push_back(*yyvsp[0].ArgVal);
2978 delete yyvsp[0].ArgVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002979 ;
2980 break;}
2981case 134:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002982#line 1620 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002983{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002984 yyval.ArgList = yyvsp[0].ArgList;
Nate Begeman14b05292005-11-05 09:21:28 +00002985 ;
2986 break;}
2987case 135:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002988#line 1623 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002989{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002990 yyval.ArgList = yyvsp[-2].ArgList;
2991 yyval.ArgList->push_back(std::pair<PATypeHolder*,
2992 char*>(new PATypeHolder(Type::VoidTy), 0));
Nate Begeman14b05292005-11-05 09:21:28 +00002993 ;
2994 break;}
2995case 136:
Chris Lattnerd91c3212005-11-05 21:54:23 +00002996#line 1628 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002997{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002998 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
2999 yyval.ArgList->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0));
Nate Begeman14b05292005-11-05 09:21:28 +00003000 ;
3001 break;}
3002case 137:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003003#line 1632 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003004{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003005 yyval.ArgList = 0;
Nate Begeman14b05292005-11-05 09:21:28 +00003006 ;
3007 break;}
3008case 138:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003009#line 1636 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003010{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003011 UnEscapeLexed(yyvsp[-3].StrVal);
3012 std::string FunctionName(yyvsp[-3].StrVal);
3013 free(yyvsp[-3].StrVal); // Free strdup'd memory!
3014
3015 if (!(*yyvsp[-4].TypeVal)->isFirstClassType() && *yyvsp[-4].TypeVal != Type::VoidTy)
3016 ThrowException("LLVM functions cannot return aggregate types!");
3017
3018 std::vector<const Type*> ParamTypeList;
3019 if (yyvsp[-1].ArgList) { // If there are arguments...
3020 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-1].ArgList->begin();
3021 I != yyvsp[-1].ArgList->end(); ++I)
3022 ParamTypeList.push_back(I->first->get());
3023 }
3024
3025 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
3026 if (isVarArg) ParamTypeList.pop_back();
3027
3028 const FunctionType *FT = FunctionType::get(*yyvsp[-4].TypeVal, ParamTypeList, isVarArg);
3029 const PointerType *PFT = PointerType::get(FT);
3030 delete yyvsp[-4].TypeVal;
3031
3032 ValID ID;
3033 if (!FunctionName.empty()) {
3034 ID = ValID::create((char*)FunctionName.c_str());
3035 } else {
3036 ID = ValID::create((int)CurModule.Values[PFT].size());
3037 }
3038
3039 Function *Fn = 0;
3040 // See if this function was forward referenced. If so, recycle the object.
3041 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
3042 // Move the function to the end of the list, from whereever it was
3043 // previously inserted.
3044 Fn = cast<Function>(FWRef);
3045 CurModule.CurrentModule->getFunctionList().remove(Fn);
3046 CurModule.CurrentModule->getFunctionList().push_back(Fn);
3047 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
3048 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
3049 // If this is the case, either we need to be a forward decl, or it needs
3050 // to be.
3051 if (!CurFun.isDeclare && !Fn->isExternal())
3052 ThrowException("Redefinition of function '" + FunctionName + "'!");
3053
3054 // Make sure to strip off any argument names so we can't get conflicts.
3055 if (Fn->isExternal())
3056 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
3057 AI != AE; ++AI)
3058 AI->setName("");
3059
3060 } else { // Not already defined?
3061 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
3062 CurModule.CurrentModule);
3063 InsertValue(Fn, CurModule.Values);
3064 }
3065
3066 CurFun.FunctionStart(Fn);
3067 Fn->setCallingConv(yyvsp[-5].UIntVal);
3068
3069 // Add all of the arguments we parsed to the function...
3070 if (yyvsp[-1].ArgList) { // Is null if empty...
3071 if (isVarArg) { // Nuke the last entry
3072 assert(yyvsp[-1].ArgList->back().first->get() == Type::VoidTy && yyvsp[-1].ArgList->back().second == 0&&
3073 "Not a varargs marker!");
3074 delete yyvsp[-1].ArgList->back().first;
3075 yyvsp[-1].ArgList->pop_back(); // Delete the last entry
3076 }
3077 Function::arg_iterator ArgIt = Fn->arg_begin();
3078 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-1].ArgList->begin();
3079 I != yyvsp[-1].ArgList->end(); ++I, ++ArgIt) {
3080 delete I->first; // Delete the typeholder...
3081
3082 setValueName(ArgIt, I->second); // Insert arg into symtab...
3083 InsertValue(ArgIt);
3084 }
3085
3086 delete yyvsp[-1].ArgList; // We're now done with the argument list
3087 }
Nate Begeman14b05292005-11-05 09:21:28 +00003088;
3089 break;}
3090case 141:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003091#line 1718 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003092{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003093 yyval.FunctionVal = CurFun.CurrentFunction;
3094
3095 // Make sure that we keep track of the linkage type even if there was a
3096 // previous "declare".
3097 yyval.FunctionVal->setLinkage(yyvsp[-2].Linkage);
Nate Begeman14b05292005-11-05 09:21:28 +00003098;
3099 break;}
3100case 144:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003101#line 1728 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003102{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003103 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003104;
3105 break;}
3106case 145:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003107#line 1732 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003108{ CurFun.isDeclare = true; ;
3109 break;}
3110case 146:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003111#line 1732 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003112{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003113 yyval.FunctionVal = CurFun.CurrentFunction;
3114 CurFun.FunctionDone();
Nate Begeman14b05292005-11-05 09:21:28 +00003115;
3116 break;}
3117case 147:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003118#line 1741 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003119{ // A reference to a direct constant
Reid Spencer68a24bd2005-08-27 18:50:39 +00003120 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
Nate Begeman14b05292005-11-05 09:21:28 +00003121 ;
3122 break;}
3123case 148:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003124#line 1744 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003125{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003126 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
Nate Begeman14b05292005-11-05 09:21:28 +00003127 ;
3128 break;}
3129case 149:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003130#line 1747 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003131{ // Perhaps it's an FP constant?
Reid Spencer68a24bd2005-08-27 18:50:39 +00003132 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
Nate Begeman14b05292005-11-05 09:21:28 +00003133 ;
3134 break;}
3135case 150:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003136#line 1750 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003137{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003138 yyval.ValIDVal = ValID::create(ConstantBool::True);
Nate Begeman14b05292005-11-05 09:21:28 +00003139 ;
3140 break;}
3141case 151:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003142#line 1753 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003143{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003144 yyval.ValIDVal = ValID::create(ConstantBool::False);
Nate Begeman14b05292005-11-05 09:21:28 +00003145 ;
3146 break;}
3147case 152:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003148#line 1756 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003149{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003150 yyval.ValIDVal = ValID::createNull();
Nate Begeman14b05292005-11-05 09:21:28 +00003151 ;
3152 break;}
3153case 153:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003154#line 1759 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003155{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003156 yyval.ValIDVal = ValID::createUndef();
Nate Begeman14b05292005-11-05 09:21:28 +00003157 ;
3158 break;}
3159case 154:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003160#line 1762 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003161{ // Nonempty unsized packed vector
Reid Spencer68a24bd2005-08-27 18:50:39 +00003162 const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
3163 int NumElements = yyvsp[-1].ConstVector->size();
3164
3165 PackedType* pt = PackedType::get(ETy, NumElements);
3166 PATypeHolder* PTy = new PATypeHolder(
3167 HandleUpRefs(
3168 PackedType::get(
3169 ETy,
3170 NumElements)
3171 )
3172 );
3173
3174 // Verify all elements are correct type!
3175 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3176 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
3177 ThrowException("Element #" + utostr(i) + " is not of type '" +
3178 ETy->getDescription() +"' as required!\nIt is of type '" +
3179 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
3180 }
3181
3182 yyval.ValIDVal = ValID::create(ConstantPacked::get(pt, *yyvsp[-1].ConstVector));
3183 delete PTy; delete yyvsp[-1].ConstVector;
Nate Begeman14b05292005-11-05 09:21:28 +00003184 ;
3185 break;}
3186case 155:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003187#line 1786 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003188{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003189 yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
Nate Begeman14b05292005-11-05 09:21:28 +00003190 ;
3191 break;}
3192case 156:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003193#line 1793 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003194{ // Is it an integer reference...?
Reid Spencer68a24bd2005-08-27 18:50:39 +00003195 yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal);
Nate Begeman14b05292005-11-05 09:21:28 +00003196 ;
3197 break;}
3198case 157:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003199#line 1796 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003200{ // Is it a named reference...?
Reid Spencer68a24bd2005-08-27 18:50:39 +00003201 yyval.ValIDVal = ValID::create(yyvsp[0].StrVal);
Nate Begeman14b05292005-11-05 09:21:28 +00003202 ;
3203 break;}
3204case 160:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003205#line 1807 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003206{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003207 yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); delete yyvsp[-1].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003208 ;
3209 break;}
3210case 161:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003211#line 1811 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003212{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003213 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003214 ;
3215 break;}
3216case 162:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003217#line 1814 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003218{ // Do not allow functions with 0 basic blocks
Reid Spencer68a24bd2005-08-27 18:50:39 +00003219 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003220 ;
3221 break;}
3222case 163:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003223#line 1822 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003224{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003225 setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
3226 InsertValue(yyvsp[0].TermInstVal);
3227
3228 yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
3229 InsertValue(yyvsp[-2].BasicBlockVal);
3230 yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003231 ;
3232 break;}
3233case 164:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003234#line 1831 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003235{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003236 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
3237 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003238 ;
3239 break;}
3240case 165:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003241#line 1835 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003242{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003243 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
3244
3245 // Make sure to move the basic block to the correct location in the
3246 // function, instead of leaving it inserted wherever it was first
3247 // referenced.
3248 Function::BasicBlockListType &BBL =
3249 CurFun.CurrentFunction->getBasicBlockList();
3250 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
Nate Begeman14b05292005-11-05 09:21:28 +00003251 ;
3252 break;}
3253case 166:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003254#line 1845 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003255{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003256 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create(yyvsp[0].StrVal), true);
3257
3258 // Make sure to move the basic block to the correct location in the
3259 // function, instead of leaving it inserted wherever it was first
3260 // referenced.
3261 Function::BasicBlockListType &BBL =
3262 CurFun.CurrentFunction->getBasicBlockList();
3263 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
Nate Begeman14b05292005-11-05 09:21:28 +00003264 ;
3265 break;}
3266case 167:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003267#line 1856 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003268{ // Return with a result...
Reid Spencer68a24bd2005-08-27 18:50:39 +00003269 yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
Nate Begeman14b05292005-11-05 09:21:28 +00003270 ;
3271 break;}
3272case 168:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003273#line 1859 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003274{ // Return with no result...
Reid Spencer68a24bd2005-08-27 18:50:39 +00003275 yyval.TermInstVal = new ReturnInst();
Nate Begeman14b05292005-11-05 09:21:28 +00003276 ;
3277 break;}
3278case 169:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003279#line 1862 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003280{ // Unconditional Branch...
Reid Spencer68a24bd2005-08-27 18:50:39 +00003281 yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[0].ValIDVal));
Nate Begeman14b05292005-11-05 09:21:28 +00003282 ;
3283 break;}
3284case 170:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003285#line 1865 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003286{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003287 yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[-3].ValIDVal), getBBVal(yyvsp[0].ValIDVal), getVal(Type::BoolTy, yyvsp[-6].ValIDVal));
Nate Begeman14b05292005-11-05 09:21:28 +00003288 ;
3289 break;}
3290case 171:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003291#line 1868 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003292{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003293 SwitchInst *S = new SwitchInst(getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal), getBBVal(yyvsp[-3].ValIDVal), yyvsp[-1].JumpTable->size());
3294 yyval.TermInstVal = S;
3295
3296 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
3297 E = yyvsp[-1].JumpTable->end();
3298 for (; I != E; ++I) {
3299 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
3300 S->addCase(CI, I->second);
3301 else
3302 ThrowException("Switch case is constant, but not a simple integer!");
3303 }
3304 delete yyvsp[-1].JumpTable;
Nate Begeman14b05292005-11-05 09:21:28 +00003305 ;
3306 break;}
3307case 172:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003308#line 1882 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003309{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003310 SwitchInst *S = new SwitchInst(getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal), getBBVal(yyvsp[-2].ValIDVal), 0);
3311 yyval.TermInstVal = S;
Nate Begeman14b05292005-11-05 09:21:28 +00003312 ;
3313 break;}
3314case 173:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003315#line 1887 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003316{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003317 const PointerType *PFTy;
3318 const FunctionType *Ty;
3319
3320 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-10].TypeVal->get())) ||
3321 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3322 // Pull out the types of all of the arguments...
3323 std::vector<const Type*> ParamTypes;
3324 if (yyvsp[-7].ValueList) {
3325 for (std::vector<Value*>::iterator I = yyvsp[-7].ValueList->begin(), E = yyvsp[-7].ValueList->end();
3326 I != E; ++I)
3327 ParamTypes.push_back((*I)->getType());
3328 }
3329
3330 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3331 if (isVarArg) ParamTypes.pop_back();
3332
3333 Ty = FunctionType::get(yyvsp[-10].TypeVal->get(), ParamTypes, isVarArg);
3334 PFTy = PointerType::get(Ty);
3335 }
3336
3337 Value *V = getVal(PFTy, yyvsp[-9].ValIDVal); // Get the function we're calling...
3338
3339 BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
3340 BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
3341
3342 // Create the call node...
3343 if (!yyvsp[-7].ValueList) { // Has no arguments?
3344 yyval.TermInstVal = new InvokeInst(V, Normal, Except, std::vector<Value*>());
3345 } else { // Has arguments?
3346 // Loop through FunctionType's arguments and ensure they are specified
3347 // correctly!
3348 //
3349 FunctionType::param_iterator I = Ty->param_begin();
3350 FunctionType::param_iterator E = Ty->param_end();
3351 std::vector<Value*>::iterator ArgI = yyvsp[-7].ValueList->begin(), ArgE = yyvsp[-7].ValueList->end();
3352
3353 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3354 if ((*ArgI)->getType() != *I)
3355 ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
3356 (*I)->getDescription() + "'!");
3357
3358 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
3359 ThrowException("Invalid number of parameters detected!");
3360
3361 yyval.TermInstVal = new InvokeInst(V, Normal, Except, *yyvsp[-7].ValueList);
3362 }
3363 cast<InvokeInst>(yyval.TermInstVal)->setCallingConv(yyvsp[-11].UIntVal);
3364
3365 delete yyvsp[-10].TypeVal;
3366 delete yyvsp[-7].ValueList;
Nate Begeman14b05292005-11-05 09:21:28 +00003367 ;
3368 break;}
3369case 174:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003370#line 1939 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003371{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003372 yyval.TermInstVal = new UnwindInst();
Nate Begeman14b05292005-11-05 09:21:28 +00003373 ;
3374 break;}
3375case 175:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003376#line 1942 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003377{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003378 yyval.TermInstVal = new UnreachableInst();
Nate Begeman14b05292005-11-05 09:21:28 +00003379 ;
3380 break;}
3381case 176:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003382#line 1948 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003383{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003384 yyval.JumpTable = yyvsp[-5].JumpTable;
3385 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
3386 if (V == 0)
3387 ThrowException("May only switch on a constant pool value!");
3388
3389 yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
Nate Begeman14b05292005-11-05 09:21:28 +00003390 ;
3391 break;}
3392case 177:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003393#line 1956 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003394{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003395 yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
3396 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
3397
3398 if (V == 0)
3399 ThrowException("May only switch on a constant pool value!");
3400
3401 yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
Nate Begeman14b05292005-11-05 09:21:28 +00003402 ;
3403 break;}
3404case 178:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003405#line 1966 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003406{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003407 // Is this definition named?? if so, assign the name...
3408 setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
3409 InsertValue(yyvsp[0].InstVal);
3410 yyval.InstVal = yyvsp[0].InstVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003411;
3412 break;}
3413case 179:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003414#line 1973 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003415{ // Used for PHI nodes
Reid Spencer68a24bd2005-08-27 18:50:39 +00003416 yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
3417 yyval.PHIList->push_back(std::make_pair(getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal), getBBVal(yyvsp[-1].ValIDVal)));
3418 delete yyvsp[-5].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003419 ;
3420 break;}
3421case 180:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003422#line 1978 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003423{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003424 yyval.PHIList = yyvsp[-6].PHIList;
3425 yyvsp[-6].PHIList->push_back(std::make_pair(getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal),
3426 getBBVal(yyvsp[-1].ValIDVal)));
Nate Begeman14b05292005-11-05 09:21:28 +00003427 ;
3428 break;}
3429case 181:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003430#line 1985 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003431{ // Used for call statements, and memory insts...
Reid Spencer68a24bd2005-08-27 18:50:39 +00003432 yyval.ValueList = new std::vector<Value*>();
3433 yyval.ValueList->push_back(yyvsp[0].ValueVal);
Nate Begeman14b05292005-11-05 09:21:28 +00003434 ;
3435 break;}
3436case 182:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003437#line 1989 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003438{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003439 yyval.ValueList = yyvsp[-2].ValueList;
3440 yyvsp[-2].ValueList->push_back(yyvsp[0].ValueVal);
Nate Begeman14b05292005-11-05 09:21:28 +00003441 ;
3442 break;}
3443case 184:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003444#line 1995 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003445{ yyval.ValueList = 0; ;
3446 break;}
3447case 185:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003448#line 1997 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003449{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003450 yyval.BoolVal = true;
Nate Begeman14b05292005-11-05 09:21:28 +00003451 ;
3452 break;}
3453case 186:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003454#line 2000 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003455{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003456 yyval.BoolVal = false;
Nate Begeman14b05292005-11-05 09:21:28 +00003457 ;
3458 break;}
3459case 187:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003460#line 2006 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003461{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003462 if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
3463 !isa<PackedType>((*yyvsp[-3].TypeVal).get()))
3464 ThrowException(
3465 "Arithmetic operator requires integer, FP, or packed operands!");
3466 if (isa<PackedType>((*yyvsp[-3].TypeVal).get()) && yyvsp[-4].BinaryOpVal == Instruction::Rem)
3467 ThrowException("Rem not supported on packed types!");
3468 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3469 if (yyval.InstVal == 0)
3470 ThrowException("binary operator returned null!");
3471 delete yyvsp[-3].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003472 ;
3473 break;}
3474case 188:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003475#line 2018 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003476{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003477 if (!(*yyvsp[-3].TypeVal)->isIntegral())
3478 ThrowException("Logical operator requires integral operands!");
3479 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3480 if (yyval.InstVal == 0)
3481 ThrowException("binary operator returned null!");
3482 delete yyvsp[-3].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003483 ;
3484 break;}
3485case 189:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003486#line 2026 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003487{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003488 if(isa<PackedType>((*yyvsp[-3].TypeVal).get())) {
3489 ThrowException(
3490 "PackedTypes currently not supported in setcc instructions!");
3491 }
3492 yyval.InstVal = new SetCondInst(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3493 if (yyval.InstVal == 0)
3494 ThrowException("binary operator returned null!");
3495 delete yyvsp[-3].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003496 ;
3497 break;}
3498case 190:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003499#line 2036 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003500{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003501 std::cerr << "WARNING: Use of eliminated 'not' instruction:"
3502 << " Replacing with 'xor'.\n";
3503
3504 Value *Ones = ConstantIntegral::getAllOnesValue(yyvsp[0].ValueVal->getType());
3505 if (Ones == 0)
3506 ThrowException("Expected integral type for not instruction!");
3507
3508 yyval.InstVal = BinaryOperator::create(Instruction::Xor, yyvsp[0].ValueVal, Ones);
3509 if (yyval.InstVal == 0)
3510 ThrowException("Could not create a xor instruction!");
Nate Begeman14b05292005-11-05 09:21:28 +00003511 ;
3512 break;}
3513case 191:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003514#line 2048 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003515{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003516 if (yyvsp[0].ValueVal->getType() != Type::UByteTy)
3517 ThrowException("Shift amount must be ubyte!");
3518 if (!yyvsp[-2].ValueVal->getType()->isInteger())
3519 ThrowException("Shift constant expression requires integer operand!");
3520 yyval.InstVal = new ShiftInst(yyvsp[-3].OtherOpVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Nate Begeman14b05292005-11-05 09:21:28 +00003521 ;
3522 break;}
3523case 192:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003524#line 2055 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003525{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003526 if (!yyvsp[0].TypeVal->get()->isFirstClassType())
3527 ThrowException("cast instruction to a non-primitive type: '" +
3528 yyvsp[0].TypeVal->get()->getDescription() + "'!");
3529 yyval.InstVal = new CastInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
3530 delete yyvsp[0].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003531 ;
3532 break;}
3533case 193:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003534#line 2062 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003535{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003536 if (yyvsp[-4].ValueVal->getType() != Type::BoolTy)
3537 ThrowException("select condition must be boolean!");
3538 if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
3539 ThrowException("select value types should match!");
3540 yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Nate Begeman14b05292005-11-05 09:21:28 +00003541 ;
3542 break;}
3543case 194:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003544#line 2069 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003545{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003546 NewVarArgs = true;
3547 yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
3548 delete yyvsp[0].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003549 ;
3550 break;}
3551case 195:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003552#line 2074 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003553{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003554 ObsoleteVarArgs = true;
3555 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
3556 Function* NF = CurModule.CurrentModule->
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003557 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003558
3559 //b = vaarg a, t ->
3560 //foo = alloca 1 of t
3561 //bar = vacopy a
3562 //store bar -> foo
3563 //b = vaarg foo, t
3564 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
3565 CurBB->getInstList().push_back(foo);
3566 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
3567 CurBB->getInstList().push_back(bar);
3568 CurBB->getInstList().push_back(new StoreInst(bar, foo));
3569 yyval.InstVal = new VAArgInst(foo, *yyvsp[0].TypeVal);
3570 delete yyvsp[0].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003571 ;
3572 break;}
3573case 196:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003574#line 2093 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003575{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003576 ObsoleteVarArgs = true;
3577 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
3578 Function* NF = CurModule.CurrentModule->
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003579 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003580
3581 //b = vanext a, t ->
3582 //foo = alloca 1 of t
3583 //bar = vacopy a
3584 //store bar -> foo
3585 //tmp = vaarg foo, t
3586 //b = load foo
3587 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
3588 CurBB->getInstList().push_back(foo);
3589 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
3590 CurBB->getInstList().push_back(bar);
3591 CurBB->getInstList().push_back(new StoreInst(bar, foo));
3592 Instruction* tmp = new VAArgInst(foo, *yyvsp[0].TypeVal);
3593 CurBB->getInstList().push_back(tmp);
3594 yyval.InstVal = new LoadInst(foo);
3595 delete yyvsp[0].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003596 ;
3597 break;}
3598case 197:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003599#line 2115 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003600{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003601 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
3602 if (!Ty->isFirstClassType())
3603 ThrowException("PHI node operands must be of first class type!");
3604 yyval.InstVal = new PHINode(Ty);
3605 ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
3606 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
3607 if (yyvsp[0].PHIList->front().first->getType() != Ty)
3608 ThrowException("All elements of a PHI node must be of the same type!");
3609 cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
3610 yyvsp[0].PHIList->pop_front();
3611 }
3612 delete yyvsp[0].PHIList; // Free the list...
Nate Begeman14b05292005-11-05 09:21:28 +00003613 ;
3614 break;}
3615case 198:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003616#line 2129 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003617{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003618 const PointerType *PFTy;
3619 const FunctionType *Ty;
3620
3621 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-4].TypeVal->get())) ||
3622 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3623 // Pull out the types of all of the arguments...
3624 std::vector<const Type*> ParamTypes;
3625 if (yyvsp[-1].ValueList) {
3626 for (std::vector<Value*>::iterator I = yyvsp[-1].ValueList->begin(), E = yyvsp[-1].ValueList->end();
3627 I != E; ++I)
3628 ParamTypes.push_back((*I)->getType());
3629 }
3630
3631 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3632 if (isVarArg) ParamTypes.pop_back();
3633
3634 if (!(*yyvsp[-4].TypeVal)->isFirstClassType() && *yyvsp[-4].TypeVal != Type::VoidTy)
3635 ThrowException("LLVM functions cannot return aggregate types!");
3636
3637 Ty = FunctionType::get(yyvsp[-4].TypeVal->get(), ParamTypes, isVarArg);
3638 PFTy = PointerType::get(Ty);
3639 }
3640
3641 Value *V = getVal(PFTy, yyvsp[-3].ValIDVal); // Get the function we're calling...
3642
3643 // Create the call node...
3644 if (!yyvsp[-1].ValueList) { // Has no arguments?
3645 // Make sure no arguments is a good thing!
3646 if (Ty->getNumParams() != 0)
3647 ThrowException("No arguments passed to a function that "
3648 "expects arguments!");
3649
3650 yyval.InstVal = new CallInst(V, std::vector<Value*>());
3651 } else { // Has arguments?
3652 // Loop through FunctionType's arguments and ensure they are specified
3653 // correctly!
3654 //
3655 FunctionType::param_iterator I = Ty->param_begin();
3656 FunctionType::param_iterator E = Ty->param_end();
3657 std::vector<Value*>::iterator ArgI = yyvsp[-1].ValueList->begin(), ArgE = yyvsp[-1].ValueList->end();
3658
3659 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3660 if ((*ArgI)->getType() != *I)
3661 ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
3662 (*I)->getDescription() + "'!");
3663
3664 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
3665 ThrowException("Invalid number of parameters detected!");
3666
3667 yyval.InstVal = new CallInst(V, *yyvsp[-1].ValueList);
3668 }
3669 cast<CallInst>(yyval.InstVal)->setTailCall(yyvsp[-6].BoolVal);
3670 cast<CallInst>(yyval.InstVal)->setCallingConv(yyvsp[-5].UIntVal);
3671 delete yyvsp[-4].TypeVal;
3672 delete yyvsp[-1].ValueList;
Nate Begeman14b05292005-11-05 09:21:28 +00003673 ;
3674 break;}
3675case 199:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003676#line 2186 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003677{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003678 yyval.InstVal = yyvsp[0].InstVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003679 ;
3680 break;}
3681case 200:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003682#line 2192 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003683{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003684 yyval.ValueList = yyvsp[0].ValueList;
Nate Begeman14b05292005-11-05 09:21:28 +00003685 ;
3686 break;}
3687case 201:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003688#line 2194 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003689{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003690 yyval.ValueList = new std::vector<Value*>();
Nate Begeman14b05292005-11-05 09:21:28 +00003691 ;
3692 break;}
3693case 202:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003694#line 2198 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003695{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003696 yyval.BoolVal = true;
Nate Begeman14b05292005-11-05 09:21:28 +00003697 ;
3698 break;}
3699case 203:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003700#line 2201 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003701{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003702 yyval.BoolVal = false;
Nate Begeman14b05292005-11-05 09:21:28 +00003703 ;
3704 break;}
3705case 204:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003706#line 2207 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003707{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003708 yyval.InstVal = new MallocInst(*yyvsp[0].TypeVal);
3709 delete yyvsp[0].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003710 ;
3711 break;}
3712case 205:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003713#line 2211 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003714{
Chris Lattnerd91c3212005-11-05 21:54:23 +00003715 if (yyvsp[0].UInt64Val & (yyvsp[0].UInt64Val-1))
3716 ThrowException("Alignment amount '" + utostr(yyvsp[0].UInt64Val) +
3717 "' is not a power of 2!");
Nate Begeman14b05292005-11-05 09:21:28 +00003718 yyval.InstVal = new MallocInst(*yyvsp[-3].TypeVal, 0, yyvsp[0].UInt64Val);
3719 delete yyvsp[-3].TypeVal;
3720 ;
3721 break;}
3722case 206:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003723#line 2218 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003724{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003725 yyval.InstVal = new MallocInst(*yyvsp[-3].TypeVal, getVal(yyvsp[-1].PrimType, yyvsp[0].ValIDVal));
3726 delete yyvsp[-3].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003727 ;
3728 break;}
3729case 207:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003730#line 2222 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003731{
Chris Lattnerd91c3212005-11-05 21:54:23 +00003732 if (yyvsp[0].UInt64Val & (yyvsp[0].UInt64Val-1))
3733 ThrowException("Alignment amount '" + utostr(yyvsp[0].UInt64Val) +
3734 "' is not a power of 2!");
Nate Begeman14b05292005-11-05 09:21:28 +00003735 yyval.InstVal = new MallocInst(*yyvsp[-6].TypeVal, getVal(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal), yyvsp[0].UInt64Val);
3736 delete yyvsp[-6].TypeVal;
3737 ;
3738 break;}
3739case 208:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003740#line 2229 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003741{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003742 yyval.InstVal = new AllocaInst(*yyvsp[0].TypeVal);
3743 delete yyvsp[0].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003744 ;
3745 break;}
3746case 209:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003747#line 2233 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003748{
Chris Lattnerd91c3212005-11-05 21:54:23 +00003749 if (yyvsp[0].UInt64Val & (yyvsp[0].UInt64Val-1))
3750 ThrowException("Alignment amount '" + utostr(yyvsp[0].UInt64Val) +
3751 "' is not a power of 2!");
Nate Begeman14b05292005-11-05 09:21:28 +00003752 yyval.InstVal = new AllocaInst(*yyvsp[-3].TypeVal, 0, yyvsp[0].UInt64Val);
3753 delete yyvsp[-3].TypeVal;
3754 ;
3755 break;}
3756case 210:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003757#line 2240 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003758{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003759 yyval.InstVal = new AllocaInst(*yyvsp[-3].TypeVal, getVal(yyvsp[-1].PrimType, yyvsp[0].ValIDVal));
3760 delete yyvsp[-3].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003761 ;
3762 break;}
3763case 211:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003764#line 2244 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003765{
Chris Lattnerd91c3212005-11-05 21:54:23 +00003766 if (yyvsp[0].UInt64Val & (yyvsp[0].UInt64Val-1))
3767 ThrowException("Alignment amount '" + utostr(yyvsp[0].UInt64Val) +
3768 "' is not a power of 2!");
Nate Begeman14b05292005-11-05 09:21:28 +00003769 yyval.InstVal = new AllocaInst(*yyvsp[-6].TypeVal, getVal(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal), yyvsp[0].UInt64Val);
3770 delete yyvsp[-6].TypeVal;
3771 ;
3772 break;}
3773case 212:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003774#line 2251 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003775{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003776 if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
3777 ThrowException("Trying to free nonpointer type " +
3778 yyvsp[0].ValueVal->getType()->getDescription() + "!");
3779 yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
Nate Begeman14b05292005-11-05 09:21:28 +00003780 ;
3781 break;}
3782case 213:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003783#line 2258 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003784{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003785 if (!isa<PointerType>(yyvsp[-1].TypeVal->get()))
3786 ThrowException("Can't load from nonpointer type: " +
3787 (*yyvsp[-1].TypeVal)->getDescription());
3788 if (!cast<PointerType>(yyvsp[-1].TypeVal->get())->getElementType()->isFirstClassType())
3789 ThrowException("Can't load from pointer of non-first-class type: " +
3790 (*yyvsp[-1].TypeVal)->getDescription());
3791 yyval.InstVal = new LoadInst(getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), "", yyvsp[-3].BoolVal);
3792 delete yyvsp[-1].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003793 ;
3794 break;}
3795case 214:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003796#line 2268 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003797{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003798 const PointerType *PT = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
3799 if (!PT)
3800 ThrowException("Can't store to a nonpointer type: " +
3801 (*yyvsp[-1].TypeVal)->getDescription());
3802 const Type *ElTy = PT->getElementType();
3803 if (ElTy != yyvsp[-3].ValueVal->getType())
3804 ThrowException("Can't store '" + yyvsp[-3].ValueVal->getType()->getDescription() +
3805 "' into space of type '" + ElTy->getDescription() + "'!");
3806
3807 yyval.InstVal = new StoreInst(yyvsp[-3].ValueVal, getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), yyvsp[-5].BoolVal);
3808 delete yyvsp[-1].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003809 ;
3810 break;}
3811case 215:
Chris Lattnerd91c3212005-11-05 21:54:23 +00003812#line 2281 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003813{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003814 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
3815 ThrowException("getelementptr insn requires pointer operand!");
3816
3817 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
3818 // indices to uint struct indices for compatibility.
3819 generic_gep_type_iterator<std::vector<Value*>::iterator>
3820 GTI = gep_type_begin(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end()),
3821 GTE = gep_type_end(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end());
3822 for (unsigned i = 0, e = yyvsp[0].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
3823 if (isa<StructType>(*GTI)) // Only change struct indices
3824 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[0].ValueList)[i]))
3825 if (CUI->getType() == Type::UByteTy)
3826 (*yyvsp[0].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
3827
3828 if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, *yyvsp[0].ValueList, true))
3829 ThrowException("Invalid getelementptr indices for type '" +
3830 (*yyvsp[-2].TypeVal)->getDescription()+ "'!");
3831 yyval.InstVal = new GetElementPtrInst(getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal), *yyvsp[0].ValueList);
3832 delete yyvsp[-2].TypeVal; delete yyvsp[0].ValueList;
Nate Begeman14b05292005-11-05 09:21:28 +00003833 ;
3834 break;}
3835}
3836 /* the action file gets copied in in place of this dollarsign */
3837#line 543 "/usr/share/bison.simple"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003838
3839 yyvsp -= yylen;
3840 yyssp -= yylen;
Nate Begeman14b05292005-11-05 09:21:28 +00003841#ifdef YYLSP_NEEDED
3842 yylsp -= yylen;
3843#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00003844
Nate Begeman14b05292005-11-05 09:21:28 +00003845#if YYDEBUG != 0
3846 if (yydebug)
3847 {
3848 short *ssp1 = yyss - 1;
3849 fprintf (stderr, "state stack now");
3850 while (ssp1 != yyssp)
3851 fprintf (stderr, " %d", *++ssp1);
3852 fprintf (stderr, "\n");
3853 }
3854#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00003855
3856 *++yyvsp = yyval;
3857
Nate Begeman14b05292005-11-05 09:21:28 +00003858#ifdef YYLSP_NEEDED
3859 yylsp++;
3860 if (yylen == 0)
3861 {
3862 yylsp->first_line = yylloc.first_line;
3863 yylsp->first_column = yylloc.first_column;
3864 yylsp->last_line = (yylsp-1)->last_line;
3865 yylsp->last_column = (yylsp-1)->last_column;
3866 yylsp->text = 0;
3867 }
3868 else
3869 {
3870 yylsp->last_line = (yylsp+yylen-1)->last_line;
3871 yylsp->last_column = (yylsp+yylen-1)->last_column;
3872 }
3873#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00003874
Nate Begeman14b05292005-11-05 09:21:28 +00003875 /* Now "shift" the result of the reduction.
3876 Determine what state that goes to,
3877 based on the state we popped back to
3878 and the rule number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003879
3880 yyn = yyr1[yyn];
3881
Nate Begeman14b05292005-11-05 09:21:28 +00003882 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
3883 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003884 yystate = yytable[yystate];
3885 else
Nate Begeman14b05292005-11-05 09:21:28 +00003886 yystate = yydefgoto[yyn - YYNTBASE];
Reid Spencer68a24bd2005-08-27 18:50:39 +00003887
3888 goto yynewstate;
3889
Nate Begeman14b05292005-11-05 09:21:28 +00003890yyerrlab: /* here on detecting error */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003891
Nate Begeman14b05292005-11-05 09:21:28 +00003892 if (! yyerrstatus)
3893 /* If not already recovering from an error, report this error. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003894 {
3895 ++yynerrs;
Nate Begeman14b05292005-11-05 09:21:28 +00003896
3897#ifdef YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00003898 yyn = yypact[yystate];
3899
Nate Begeman14b05292005-11-05 09:21:28 +00003900 if (yyn > YYFLAG && yyn < YYLAST)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003901 {
Nate Begeman14b05292005-11-05 09:21:28 +00003902 int size = 0;
3903 char *msg;
3904 int x, count;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003905
Nate Begeman14b05292005-11-05 09:21:28 +00003906 count = 0;
3907 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
3908 for (x = (yyn < 0 ? -yyn : 0);
3909 x < (sizeof(yytname) / sizeof(char *)); x++)
3910 if (yycheck[x + yyn] == x)
3911 size += strlen(yytname[x]) + 15, count++;
3912 msg = (char *) malloc(size + 15);
3913 if (msg != 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003914 {
Nate Begeman14b05292005-11-05 09:21:28 +00003915 strcpy(msg, "parse error");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003916
Nate Begeman14b05292005-11-05 09:21:28 +00003917 if (count < 5)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003918 {
Nate Begeman14b05292005-11-05 09:21:28 +00003919 count = 0;
3920 for (x = (yyn < 0 ? -yyn : 0);
3921 x < (sizeof(yytname) / sizeof(char *)); x++)
3922 if (yycheck[x + yyn] == x)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003923 {
Nate Begeman14b05292005-11-05 09:21:28 +00003924 strcat(msg, count == 0 ? ", expecting `" : " or `");
3925 strcat(msg, yytname[x]);
3926 strcat(msg, "'");
3927 count++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003928 }
3929 }
Nate Begeman14b05292005-11-05 09:21:28 +00003930 yyerror(msg);
3931 free(msg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003932 }
3933 else
Nate Begeman14b05292005-11-05 09:21:28 +00003934 yyerror ("parse error; also virtual memory exceeded");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003935 }
3936 else
3937#endif /* YYERROR_VERBOSE */
Nate Begeman14b05292005-11-05 09:21:28 +00003938 yyerror("parse error");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003939 }
3940
Nate Begeman14b05292005-11-05 09:21:28 +00003941 goto yyerrlab1;
3942yyerrlab1: /* here on error raised explicitly by an action */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003943
3944 if (yyerrstatus == 3)
3945 {
Nate Begeman14b05292005-11-05 09:21:28 +00003946 /* if just tried and failed to reuse lookahead token after an error, discard it. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003947
Nate Begeman14b05292005-11-05 09:21:28 +00003948 /* return failure if at end of input */
3949 if (yychar == YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003950 YYABORT;
3951
Nate Begeman14b05292005-11-05 09:21:28 +00003952#if YYDEBUG != 0
3953 if (yydebug)
3954 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
3955#endif
3956
3957 yychar = YYEMPTY;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003958 }
3959
Nate Begeman14b05292005-11-05 09:21:28 +00003960 /* Else will try to reuse lookahead token
3961 after shifting the error token. */
3962
3963 yyerrstatus = 3; /* Each real token shifted decrements this */
3964
3965 goto yyerrhandle;
3966
3967yyerrdefault: /* current state does not do anything special for the error token. */
3968
3969#if 0
3970 /* This is wrong; only states that explicitly want error tokens
3971 should shift them. */
3972 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
3973 if (yyn) goto yydefault;
3974#endif
3975
3976yyerrpop: /* pop the current state because it cannot handle the error token */
3977
3978 if (yyssp == yyss) YYABORT;
3979 yyvsp--;
3980 yystate = *--yyssp;
3981#ifdef YYLSP_NEEDED
3982 yylsp--;
3983#endif
3984
3985#if YYDEBUG != 0
3986 if (yydebug)
3987 {
3988 short *ssp1 = yyss - 1;
3989 fprintf (stderr, "Error: state stack now");
3990 while (ssp1 != yyssp)
3991 fprintf (stderr, " %d", *++ssp1);
3992 fprintf (stderr, "\n");
3993 }
3994#endif
3995
3996yyerrhandle:
3997
3998 yyn = yypact[yystate];
3999 if (yyn == YYFLAG)
4000 goto yyerrdefault;
4001
4002 yyn += YYTERROR;
4003 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
4004 goto yyerrdefault;
4005
4006 yyn = yytable[yyn];
4007 if (yyn < 0)
4008 {
4009 if (yyn == YYFLAG)
4010 goto yyerrpop;
4011 yyn = -yyn;
4012 goto yyreduce;
4013 }
4014 else if (yyn == 0)
4015 goto yyerrpop;
4016
Reid Spencer68a24bd2005-08-27 18:50:39 +00004017 if (yyn == YYFINAL)
4018 YYACCEPT;
4019
Nate Begeman14b05292005-11-05 09:21:28 +00004020#if YYDEBUG != 0
4021 if (yydebug)
4022 fprintf(stderr, "Shifting error token, ");
4023#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00004024
4025 *++yyvsp = yylval;
Nate Begeman14b05292005-11-05 09:21:28 +00004026#ifdef YYLSP_NEEDED
4027 *++yylsp = yylloc;
4028#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00004029
4030 yystate = yyn;
4031 goto yynewstate;
4032
Nate Begeman14b05292005-11-05 09:21:28 +00004033 yyacceptlab:
4034 /* YYACCEPT comes here. */
4035 if (yyfree_stacks)
4036 {
4037 free (yyss);
4038 free (yyvs);
4039#ifdef YYLSP_NEEDED
4040 free (yyls);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004041#endif
Nate Begeman14b05292005-11-05 09:21:28 +00004042 }
4043 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004044
Nate Begeman14b05292005-11-05 09:21:28 +00004045 yyabortlab:
4046 /* YYABORT comes here. */
4047 if (yyfree_stacks)
4048 {
4049 free (yyss);
4050 free (yyvs);
4051#ifdef YYLSP_NEEDED
4052 free (yyls);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004053#endif
Nate Begeman14b05292005-11-05 09:21:28 +00004054 }
4055 return 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004056}
Chris Lattnerd91c3212005-11-05 21:54:23 +00004057#line 2304 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00004058
4059int yyerror(const char *ErrorMsg) {
4060 std::string where
4061 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
4062 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
4063 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
4064 if (yychar == YYEMPTY || yychar == 0)
4065 errMsg += "end-of-file.";
4066 else
4067 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
4068 ThrowException(errMsg);
4069 return 0;
4070}