blob: 6f814b4cc3475e83cf2dd338250f7c97aead9143 [file] [log] [blame]
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001
Chris Lattneredd9b032006-01-23 23:05:42 +00002/* A Bison parser, made from /Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y
3 by GNU Bison version 1.28 */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004
Chris Lattneredd9b032006-01-23 23:05:42 +00005#define YYBISON 1 /* Identify Bison output. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00006
Reid Spencerdfb3fb42005-08-27 18:50:39 +00007#define yyparse llvmAsmparse
Chris Lattneredd9b032006-01-23 23:05:42 +00008#define yylex llvmAsmlex
Reid Spencerdfb3fb42005-08-27 18:50:39 +00009#define yyerror llvmAsmerror
Chris Lattneredd9b032006-01-23 23:05:42 +000010#define yylval llvmAsmlval
11#define yychar llvmAsmchar
Reid Spencerdfb3fb42005-08-27 18:50:39 +000012#define yydebug llvmAsmdebug
13#define yynerrs llvmAsmnerrs
Chris Lattneredd9b032006-01-23 23:05:42 +000014#define ESINT64VAL 257
15#define EUINT64VAL 258
16#define SINTVAL 259
17#define UINTVAL 260
18#define FPVAL 261
19#define VOID 262
20#define BOOL 263
21#define SBYTE 264
22#define UBYTE 265
23#define SHORT 266
24#define USHORT 267
25#define INT 268
26#define UINT 269
27#define LONG 270
28#define ULONG 271
29#define FLOAT 272
30#define DOUBLE 273
31#define TYPE 274
32#define LABEL 275
33#define VAR_ID 276
34#define LABELSTR 277
35#define STRINGCONSTANT 278
36#define IMPLEMENTATION 279
37#define ZEROINITIALIZER 280
38#define TRUETOK 281
39#define FALSETOK 282
40#define BEGINTOK 283
41#define ENDTOK 284
42#define DECLARE 285
43#define GLOBAL 286
44#define CONSTANT 287
45#define SECTION 288
46#define VOLATILE 289
47#define TO 290
48#define DOTDOTDOT 291
49#define NULL_TOK 292
50#define UNDEF 293
51#define CONST 294
52#define INTERNAL 295
53#define LINKONCE 296
54#define WEAK 297
55#define APPENDING 298
56#define OPAQUE 299
57#define NOT 300
58#define EXTERNAL 301
59#define TARGET 302
60#define TRIPLE 303
61#define ENDIAN 304
62#define POINTERSIZE 305
63#define LITTLE 306
64#define BIG 307
65#define ALIGN 308
66#define DEPLIBS 309
67#define CALL 310
68#define TAIL 311
69#define ASM_TOK 312
Chris Lattner8ebd2162006-01-24 04:14:29 +000070#define MODULE 313
71#define CC_TOK 314
72#define CCC_TOK 315
73#define FASTCC_TOK 316
74#define COLDCC_TOK 317
75#define RET 318
76#define BR 319
77#define SWITCH 320
78#define INVOKE 321
79#define UNWIND 322
80#define UNREACHABLE 323
81#define ADD 324
82#define SUB 325
83#define MUL 326
84#define DIV 327
85#define REM 328
86#define AND 329
87#define OR 330
88#define XOR 331
89#define SETLE 332
90#define SETGE 333
91#define SETLT 334
92#define SETGT 335
93#define SETEQ 336
94#define SETNE 337
95#define MALLOC 338
96#define ALLOCA 339
97#define FREE 340
98#define LOAD 341
99#define STORE 342
100#define GETELEMENTPTR 343
101#define PHI_TOK 344
102#define CAST 345
103#define SELECT 346
104#define SHL 347
105#define SHR 348
106#define VAARG 349
107#define EXTRACTELEMENT 350
108#define INSERTELEMENT 351
109#define VAARG_old 352
110#define VANEXT_old 353
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000111
Chris Lattneredd9b032006-01-23 23:05:42 +0000112#line 14 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000113
114#include "ParserInternals.h"
115#include "llvm/CallingConv.h"
116#include "llvm/Instructions.h"
117#include "llvm/Module.h"
118#include "llvm/SymbolTable.h"
Reid Spencerb4f9a6f2006-01-16 21:12:35 +0000119#include "llvm/Assembly/AutoUpgrade.h"
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000120#include "llvm/Support/GetElementPtrTypeIterator.h"
121#include "llvm/ADT/STLExtras.h"
Chris Lattner840f7892005-11-06 06:46:53 +0000122#include "llvm/Support/MathExtras.h"
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000123#include <algorithm>
124#include <iostream>
125#include <list>
126#include <utility>
127
128int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
129int yylex(); // declaration" of xxx warnings.
130int yyparse();
131
132namespace llvm {
133 std::string CurFilename;
134}
135using namespace llvm;
136
137static Module *ParserResult;
138
139// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
140// relating to upreferences in the input stream.
141//
142//#define DEBUG_UPREFS 1
143#ifdef DEBUG_UPREFS
144#define UR_OUT(X) std::cerr << X
145#else
146#define UR_OUT(X)
147#endif
148
149#define YYERROR_VERBOSE 1
150
151static bool ObsoleteVarArgs;
152static bool NewVarArgs;
Chris Lattner11ca4d62005-11-12 18:22:38 +0000153static BasicBlock *CurBB;
154static GlobalVariable *CurGV;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000155
156
157// This contains info used when building the body of a function. It is
158// destroyed when the function is completed.
159//
160typedef std::vector<Value *> ValueList; // Numbered defs
161static void
162ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
163 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
164
165static struct PerModuleInfo {
166 Module *CurrentModule;
167 std::map<const Type *, ValueList> Values; // Module level numbered definitions
168 std::map<const Type *,ValueList> LateResolveValues;
169 std::vector<PATypeHolder> Types;
170 std::map<ValID, PATypeHolder> LateResolveTypes;
171
172 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
173 /// how they were referenced and one which line of the input they came from so
174 /// that we can resolve them later and print error messages as appropriate.
175 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
176
177 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
178 // references to global values. Global values may be referenced before they
179 // are defined, and if so, the temporary object that they represent is held
180 // here. This is used for forward references of GlobalValues.
181 //
182 typedef std::map<std::pair<const PointerType *,
183 ValID>, GlobalValue*> GlobalRefsType;
184 GlobalRefsType GlobalRefs;
185
186 void ModuleDone() {
187 // If we could not resolve some functions at function compilation time
188 // (calls to functions before they are defined), resolve them now... Types
189 // are resolved when the constant pool has been completely parsed.
190 //
191 ResolveDefinitions(LateResolveValues);
192
193 // Check to make sure that all global value forward references have been
194 // resolved!
195 //
196 if (!GlobalRefs.empty()) {
197 std::string UndefinedReferences = "Unresolved global references exist:\n";
198
199 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
200 I != E; ++I) {
201 UndefinedReferences += " " + I->first.first->getDescription() + " " +
202 I->first.second.getName() + "\n";
203 }
204 ThrowException(UndefinedReferences);
205 }
206
Reid Spencerc8a9faf2006-01-19 01:21:04 +0000207 // Look for intrinsic functions and CallInst that need to be upgraded
208 for (Module::iterator FI = CurrentModule->begin(),FE = CurrentModule->end();
209 FI != FE; ++FI)
210 UpgradeCallsToIntrinsic(FI);
Reid Spencerb4f9a6f2006-01-16 21:12:35 +0000211
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000212 Values.clear(); // Clear out function local definitions
213 Types.clear();
214 CurrentModule = 0;
215 }
216
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000217 // GetForwardRefForGlobal - Check to see if there is a forward reference
218 // for this global. If so, remove it from the GlobalRefs map and return it.
219 // If not, just return null.
220 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
221 // Check to see if there is a forward reference to this global variable...
222 // if there is, eliminate it and patch the reference to use the new def'n.
223 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
224 GlobalValue *Ret = 0;
225 if (I != GlobalRefs.end()) {
226 Ret = I->second;
227 GlobalRefs.erase(I);
228 }
229 return Ret;
230 }
231} CurModule;
232
233static struct PerFunctionInfo {
234 Function *CurrentFunction; // Pointer to current function being created
235
236 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
237 std::map<const Type*, ValueList> LateResolveValues;
238 bool isDeclare; // Is this function a forward declararation?
239
240 /// BBForwardRefs - When we see forward references to basic blocks, keep
241 /// track of them here.
242 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
243 std::vector<BasicBlock*> NumberedBlocks;
244 unsigned NextBBNum;
245
246 inline PerFunctionInfo() {
247 CurrentFunction = 0;
248 isDeclare = false;
249 }
250
251 inline void FunctionStart(Function *M) {
252 CurrentFunction = M;
253 NextBBNum = 0;
254 }
255
256 void FunctionDone() {
257 NumberedBlocks.clear();
258
259 // Any forward referenced blocks left?
260 if (!BBForwardRefs.empty())
261 ThrowException("Undefined reference to label " +
262 BBForwardRefs.begin()->first->getName());
263
264 // Resolve all forward references now.
265 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
266
267 Values.clear(); // Clear out function local definitions
268 CurrentFunction = 0;
269 isDeclare = false;
270 }
271} CurFun; // Info for the current function...
272
273static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
274
275
276//===----------------------------------------------------------------------===//
277// Code to handle definitions of all the types
278//===----------------------------------------------------------------------===//
279
280static int InsertValue(Value *V,
281 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
282 if (V->hasName()) return -1; // Is this a numbered definition?
283
284 // Yes, insert the value into the value table...
285 ValueList &List = ValueTab[V->getType()];
286 List.push_back(V);
287 return List.size()-1;
288}
289
290static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
291 switch (D.Type) {
292 case ValID::NumberVal: // Is it a numbered definition?
293 // Module constants occupy the lowest numbered slots...
294 if ((unsigned)D.Num < CurModule.Types.size())
295 return CurModule.Types[(unsigned)D.Num];
296 break;
297 case ValID::NameVal: // Is it a named definition?
298 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
299 D.destroy(); // Free old strdup'd memory...
300 return N;
301 }
302 break;
303 default:
304 ThrowException("Internal parser error: Invalid symbol type reference!");
305 }
306
307 // If we reached here, we referenced either a symbol that we don't know about
308 // or an id number that hasn't been read yet. We may be referencing something
309 // forward, so just create an entry to be resolved later and get to it...
310 //
311 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
312
313
314 if (inFunctionScope()) {
315 if (D.Type == ValID::NameVal)
316 ThrowException("Reference to an undefined type: '" + D.getName() + "'");
317 else
318 ThrowException("Reference to an undefined type: #" + itostr(D.Num));
319 }
320
321 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
322 if (I != CurModule.LateResolveTypes.end())
323 return I->second;
324
325 Type *Typ = OpaqueType::get();
326 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
327 return Typ;
328 }
329
330static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
331 SymbolTable &SymTab =
332 inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() :
333 CurModule.CurrentModule->getSymbolTable();
334 return SymTab.lookup(Ty, Name);
335}
336
337// getValNonImprovising - Look up the value specified by the provided type and
338// the provided ValID. If the value exists and has already been defined, return
339// it. Otherwise return null.
340//
341static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
342 if (isa<FunctionType>(Ty))
343 ThrowException("Functions are not values and "
344 "must be referenced as pointers");
345
346 switch (D.Type) {
347 case ValID::NumberVal: { // Is it a numbered definition?
348 unsigned Num = (unsigned)D.Num;
349
350 // Module constants occupy the lowest numbered slots...
351 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
352 if (VI != CurModule.Values.end()) {
353 if (Num < VI->second.size())
354 return VI->second[Num];
355 Num -= VI->second.size();
356 }
357
358 // Make sure that our type is within bounds
359 VI = CurFun.Values.find(Ty);
360 if (VI == CurFun.Values.end()) return 0;
361
362 // Check that the number is within bounds...
363 if (VI->second.size() <= Num) return 0;
364
365 return VI->second[Num];
366 }
367
368 case ValID::NameVal: { // Is it a named definition?
369 Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
370 if (N == 0) return 0;
371
372 D.destroy(); // Free old strdup'd memory...
373 return N;
374 }
375
376 // Check to make sure that "Ty" is an integral type, and that our
377 // value will fit into the specified type...
378 case ValID::ConstSIntVal: // Is it a constant pool reference??
379 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64))
380 ThrowException("Signed integral constant '" +
381 itostr(D.ConstPool64) + "' is invalid for type '" +
382 Ty->getDescription() + "'!");
383 return ConstantSInt::get(Ty, D.ConstPool64);
384
385 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
386 if (!ConstantUInt::isValueValidForType(Ty, D.UConstPool64)) {
387 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) {
388 ThrowException("Integral constant '" + utostr(D.UConstPool64) +
389 "' is invalid or out of range!");
390 } else { // This is really a signed reference. Transmogrify.
391 return ConstantSInt::get(Ty, D.ConstPool64);
392 }
393 } else {
394 return ConstantUInt::get(Ty, D.UConstPool64);
395 }
396
397 case ValID::ConstFPVal: // Is it a floating point const pool reference?
398 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
399 ThrowException("FP constant invalid for type!!");
400 return ConstantFP::get(Ty, D.ConstPoolFP);
401
402 case ValID::ConstNullVal: // Is it a null value?
403 if (!isa<PointerType>(Ty))
404 ThrowException("Cannot create a a non pointer null!");
405 return ConstantPointerNull::get(cast<PointerType>(Ty));
406
407 case ValID::ConstUndefVal: // Is it an undef value?
408 return UndefValue::get(Ty);
409
Chris Lattnera054d122005-12-21 17:53:23 +0000410 case ValID::ConstZeroVal: // Is it a zero value?
411 return Constant::getNullValue(Ty);
412
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000413 case ValID::ConstantVal: // Fully resolved constant?
414 if (D.ConstantValue->getType() != Ty)
415 ThrowException("Constant expression type different from required type!");
416 return D.ConstantValue;
417
418 default:
419 assert(0 && "Unhandled case!");
420 return 0;
421 } // End of switch
422
423 assert(0 && "Unhandled case!");
424 return 0;
425}
426
427// getVal - This function is identical to getValNonImprovising, except that if a
428// value is not already defined, it "improvises" by creating a placeholder var
429// that looks and acts just like the requested variable. When the value is
430// defined later, all uses of the placeholder variable are replaced with the
431// real thing.
432//
433static Value *getVal(const Type *Ty, const ValID &ID) {
434 if (Ty == Type::LabelTy)
435 ThrowException("Cannot use a basic block here");
436
437 // See if the value has already been defined.
438 Value *V = getValNonImprovising(Ty, ID);
439 if (V) return V;
440
441 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
442 ThrowException("Invalid use of a composite type!");
443
444 // If we reached here, we referenced either a symbol that we don't know about
445 // or an id number that hasn't been read yet. We may be referencing something
446 // forward, so just create an entry to be resolved later and get to it...
447 //
448 V = new Argument(Ty);
449
450 // Remember where this forward reference came from. FIXME, shouldn't we try
451 // to recycle these things??
452 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
453 llvmAsmlineno)));
454
455 if (inFunctionScope())
456 InsertValue(V, CurFun.LateResolveValues);
457 else
458 InsertValue(V, CurModule.LateResolveValues);
459 return V;
460}
461
462/// getBBVal - This is used for two purposes:
463/// * If isDefinition is true, a new basic block with the specified ID is being
464/// defined.
465/// * If isDefinition is true, this is a reference to a basic block, which may
466/// or may not be a forward reference.
467///
468static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
469 assert(inFunctionScope() && "Can't get basic block at global scope!");
470
471 std::string Name;
472 BasicBlock *BB = 0;
473 switch (ID.Type) {
474 default: ThrowException("Illegal label reference " + ID.getName());
475 case ValID::NumberVal: // Is it a numbered definition?
476 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
477 CurFun.NumberedBlocks.resize(ID.Num+1);
478 BB = CurFun.NumberedBlocks[ID.Num];
479 break;
480 case ValID::NameVal: // Is it a named definition?
481 Name = ID.Name;
482 if (Value *N = CurFun.CurrentFunction->
483 getSymbolTable().lookup(Type::LabelTy, Name))
484 BB = cast<BasicBlock>(N);
485 break;
486 }
487
488 // See if the block has already been defined.
489 if (BB) {
490 // If this is the definition of the block, make sure the existing value was
491 // just a forward reference. If it was a forward reference, there will be
492 // an entry for it in the PlaceHolderInfo map.
493 if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
494 // The existing value was a definition, not a forward reference.
495 ThrowException("Redefinition of label " + ID.getName());
496
497 ID.destroy(); // Free strdup'd memory.
498 return BB;
499 }
500
501 // Otherwise this block has not been seen before.
502 BB = new BasicBlock("", CurFun.CurrentFunction);
503 if (ID.Type == ValID::NameVal) {
504 BB->setName(ID.Name);
505 } else {
506 CurFun.NumberedBlocks[ID.Num] = BB;
507 }
508
509 // If this is not a definition, keep track of it so we can use it as a forward
510 // reference.
511 if (!isDefinition) {
512 // Remember where this forward reference came from.
513 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
514 } else {
515 // The forward declaration could have been inserted anywhere in the
516 // function: insert it into the correct place now.
517 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
518 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
519 }
520 ID.destroy();
521 return BB;
522}
523
524
525//===----------------------------------------------------------------------===//
526// Code to handle forward references in instructions
527//===----------------------------------------------------------------------===//
528//
529// This code handles the late binding needed with statements that reference
530// values not defined yet... for example, a forward branch, or the PHI node for
531// a loop body.
532//
533// This keeps a table (CurFun.LateResolveValues) of all such forward references
534// and back patchs after we are done.
535//
536
537// ResolveDefinitions - If we could not resolve some defs at parsing
538// time (forward branches, phi functions for loops, etc...) resolve the
539// defs now...
540//
541static void
542ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
543 std::map<const Type*,ValueList> *FutureLateResolvers) {
544 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
545 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
546 E = LateResolvers.end(); LRI != E; ++LRI) {
547 ValueList &List = LRI->second;
548 while (!List.empty()) {
549 Value *V = List.back();
550 List.pop_back();
551
552 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
553 CurModule.PlaceHolderInfo.find(V);
554 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
555
556 ValID &DID = PHI->second.first;
557
558 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
559 if (TheRealValue) {
560 V->replaceAllUsesWith(TheRealValue);
561 delete V;
562 CurModule.PlaceHolderInfo.erase(PHI);
563 } else if (FutureLateResolvers) {
564 // Functions have their unresolved items forwarded to the module late
565 // resolver table
566 InsertValue(V, *FutureLateResolvers);
567 } else {
568 if (DID.Type == ValID::NameVal)
569 ThrowException("Reference to an invalid definition: '" +DID.getName()+
570 "' of type '" + V->getType()->getDescription() + "'",
571 PHI->second.second);
572 else
573 ThrowException("Reference to an invalid definition: #" +
574 itostr(DID.Num) + " of type '" +
575 V->getType()->getDescription() + "'",
576 PHI->second.second);
577 }
578 }
579 }
580
581 LateResolvers.clear();
582}
583
584// ResolveTypeTo - A brand new type was just declared. This means that (if
585// name is not null) things referencing Name can be resolved. Otherwise, things
586// refering to the number can be resolved. Do this now.
587//
588static void ResolveTypeTo(char *Name, const Type *ToTy) {
589 ValID D;
590 if (Name) D = ValID::create(Name);
591 else D = ValID::create((int)CurModule.Types.size());
592
593 std::map<ValID, PATypeHolder>::iterator I =
594 CurModule.LateResolveTypes.find(D);
595 if (I != CurModule.LateResolveTypes.end()) {
596 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
597 CurModule.LateResolveTypes.erase(I);
598 }
599}
600
601// setValueName - Set the specified value to the name given. The name may be
602// null potentially, in which case this is a noop. The string passed in is
603// assumed to be a malloc'd string buffer, and is free'd by this function.
604//
605static void setValueName(Value *V, char *NameStr) {
606 if (NameStr) {
607 std::string Name(NameStr); // Copy string
608 free(NameStr); // Free old string
609
610 if (V->getType() == Type::VoidTy)
611 ThrowException("Can't assign name '" + Name+"' to value with void type!");
612
613 assert(inFunctionScope() && "Must be in function scope!");
614 SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable();
615 if (ST.lookup(V->getType(), Name))
616 ThrowException("Redefinition of value named '" + Name + "' in the '" +
617 V->getType()->getDescription() + "' type plane!");
618
619 // Set the name.
620 V->setName(Name);
621 }
622}
623
624/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
625/// this is a declaration, otherwise it is a definition.
Chris Lattner11ca4d62005-11-12 18:22:38 +0000626static GlobalVariable *
627ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
628 bool isConstantGlobal, const Type *Ty,
629 Constant *Initializer) {
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000630 if (isa<FunctionType>(Ty))
631 ThrowException("Cannot declare global vars of function type!");
632
633 const PointerType *PTy = PointerType::get(Ty);
634
635 std::string Name;
636 if (NameStr) {
637 Name = NameStr; // Copy string
638 free(NameStr); // Free old string
639 }
640
641 // See if this global value was forward referenced. If so, recycle the
642 // object.
643 ValID ID;
644 if (!Name.empty()) {
645 ID = ValID::create((char*)Name.c_str());
646 } else {
647 ID = ValID::create((int)CurModule.Values[PTy].size());
648 }
649
650 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
651 // Move the global to the end of the list, from whereever it was
652 // previously inserted.
653 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
654 CurModule.CurrentModule->getGlobalList().remove(GV);
655 CurModule.CurrentModule->getGlobalList().push_back(GV);
656 GV->setInitializer(Initializer);
657 GV->setLinkage(Linkage);
658 GV->setConstant(isConstantGlobal);
659 InsertValue(GV, CurModule.Values);
Chris Lattner11ca4d62005-11-12 18:22:38 +0000660 return GV;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000661 }
662
663 // If this global has a name, check to see if there is already a definition
664 // of this global in the module. If so, merge as appropriate. Note that
665 // this is really just a hack around problems in the CFE. :(
666 if (!Name.empty()) {
667 // We are a simple redefinition of a value, check to see if it is defined
668 // the same as the old one.
669 if (GlobalVariable *EGV =
670 CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
671 // We are allowed to redefine a global variable in two circumstances:
672 // 1. If at least one of the globals is uninitialized or
673 // 2. If both initializers have the same value.
674 //
675 if (!EGV->hasInitializer() || !Initializer ||
676 EGV->getInitializer() == Initializer) {
677
678 // Make sure the existing global version gets the initializer! Make
679 // sure that it also gets marked const if the new version is.
680 if (Initializer && !EGV->hasInitializer())
681 EGV->setInitializer(Initializer);
682 if (isConstantGlobal)
683 EGV->setConstant(true);
684 EGV->setLinkage(Linkage);
Chris Lattner11ca4d62005-11-12 18:22:38 +0000685 return EGV;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000686 }
687
688 ThrowException("Redefinition of global variable named '" + Name +
689 "' in the '" + Ty->getDescription() + "' type plane!");
690 }
691 }
692
693 // Otherwise there is no existing GV to use, create one now.
694 GlobalVariable *GV =
695 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
696 CurModule.CurrentModule);
697 InsertValue(GV, CurModule.Values);
Chris Lattner11ca4d62005-11-12 18:22:38 +0000698 return GV;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000699}
700
701// setTypeName - Set the specified type to the name given. The name may be
702// null potentially, in which case this is a noop. The string passed in is
703// assumed to be a malloc'd string buffer, and is freed by this function.
704//
705// This function returns true if the type has already been defined, but is
706// allowed to be redefined in the specified context. If the name is a new name
707// for the type plane, it is inserted and false is returned.
708static bool setTypeName(const Type *T, char *NameStr) {
709 assert(!inFunctionScope() && "Can't give types function-local names!");
710 if (NameStr == 0) return false;
711
712 std::string Name(NameStr); // Copy string
713 free(NameStr); // Free old string
714
715 // We don't allow assigning names to void type
716 if (T == Type::VoidTy)
717 ThrowException("Can't assign name '" + Name + "' to the void type!");
718
719 // Set the type name, checking for conflicts as we do so.
720 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
721
722 if (AlreadyExists) { // Inserting a name that is already defined???
723 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
724 assert(Existing && "Conflict but no matching type?");
725
726 // There is only one case where this is allowed: when we are refining an
727 // opaque type. In this case, Existing will be an opaque type.
728 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
729 // We ARE replacing an opaque type!
730 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
731 return true;
732 }
733
734 // Otherwise, this is an attempt to redefine a type. That's okay if
735 // the redefinition is identical to the original. This will be so if
736 // Existing and T point to the same Type object. In this one case we
737 // allow the equivalent redefinition.
738 if (Existing == T) return true; // Yes, it's equal.
739
740 // Any other kind of (non-equivalent) redefinition is an error.
741 ThrowException("Redefinition of type named '" + Name + "' in the '" +
742 T->getDescription() + "' type plane!");
743 }
744
745 return false;
746}
747
748//===----------------------------------------------------------------------===//
749// Code for handling upreferences in type names...
750//
751
752// TypeContains - Returns true if Ty directly contains E in it.
753//
754static bool TypeContains(const Type *Ty, const Type *E) {
755 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
756 E) != Ty->subtype_end();
757}
758
759namespace {
760 struct UpRefRecord {
761 // NestingLevel - The number of nesting levels that need to be popped before
762 // this type is resolved.
763 unsigned NestingLevel;
764
765 // LastContainedTy - This is the type at the current binding level for the
766 // type. Every time we reduce the nesting level, this gets updated.
767 const Type *LastContainedTy;
768
769 // UpRefTy - This is the actual opaque type that the upreference is
770 // represented with.
771 OpaqueType *UpRefTy;
772
773 UpRefRecord(unsigned NL, OpaqueType *URTy)
774 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
775 };
776}
777
778// UpRefs - A list of the outstanding upreferences that need to be resolved.
779static std::vector<UpRefRecord> UpRefs;
780
781/// HandleUpRefs - Every time we finish a new layer of types, this function is
782/// called. It loops through the UpRefs vector, which is a list of the
783/// currently active types. For each type, if the up reference is contained in
784/// the newly completed type, we decrement the level count. When the level
785/// count reaches zero, the upreferenced type is the type that is passed in:
786/// thus we can complete the cycle.
787///
788static PATypeHolder HandleUpRefs(const Type *ty) {
789 if (!ty->isAbstract()) return ty;
790 PATypeHolder Ty(ty);
791 UR_OUT("Type '" << Ty->getDescription() <<
792 "' newly formed. Resolving upreferences.\n" <<
793 UpRefs.size() << " upreferences active!\n");
794
795 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
796 // to zero), we resolve them all together before we resolve them to Ty. At
797 // the end of the loop, if there is anything to resolve to Ty, it will be in
798 // this variable.
799 OpaqueType *TypeToResolve = 0;
800
801 for (unsigned i = 0; i != UpRefs.size(); ++i) {
802 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
803 << UpRefs[i].second->getDescription() << ") = "
804 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
805 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
806 // Decrement level of upreference
807 unsigned Level = --UpRefs[i].NestingLevel;
808 UpRefs[i].LastContainedTy = Ty;
809 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
810 if (Level == 0) { // Upreference should be resolved!
811 if (!TypeToResolve) {
812 TypeToResolve = UpRefs[i].UpRefTy;
813 } else {
814 UR_OUT(" * Resolving upreference for "
815 << UpRefs[i].second->getDescription() << "\n";
816 std::string OldName = UpRefs[i].UpRefTy->getDescription());
817 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
818 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
819 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
820 }
821 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
822 --i; // Do not skip the next element...
823 }
824 }
825 }
826
827 if (TypeToResolve) {
828 UR_OUT(" * Resolving upreference for "
829 << UpRefs[i].second->getDescription() << "\n";
830 std::string OldName = TypeToResolve->getDescription());
831 TypeToResolve->refineAbstractTypeTo(Ty);
832 }
833
834 return Ty;
835}
836
837
838// common code from the two 'RunVMAsmParser' functions
839 static Module * RunParser(Module * M) {
840
841 llvmAsmlineno = 1; // Reset the current line number...
842 ObsoleteVarArgs = false;
843 NewVarArgs = false;
844
845 CurModule.CurrentModule = M;
846 yyparse(); // Parse the file, potentially throwing exception
847
848 Module *Result = ParserResult;
849 ParserResult = 0;
850
851 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
852 {
853 Function* F;
854 if ((F = Result->getNamedFunction("llvm.va_start"))
855 && F->getFunctionType()->getNumParams() == 0)
856 ObsoleteVarArgs = true;
857 if((F = Result->getNamedFunction("llvm.va_copy"))
858 && F->getFunctionType()->getNumParams() == 1)
859 ObsoleteVarArgs = true;
860 }
861
862 if (ObsoleteVarArgs && NewVarArgs)
863 ThrowException("This file is corrupt: it uses both new and old style varargs");
864
865 if(ObsoleteVarArgs) {
866 if(Function* F = Result->getNamedFunction("llvm.va_start")) {
867 if (F->arg_size() != 0)
868 ThrowException("Obsolete va_start takes 0 argument!");
869
870 //foo = va_start()
871 // ->
872 //bar = alloca typeof(foo)
873 //va_start(bar)
874 //foo = load bar
875
876 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
877 const Type* ArgTy = F->getFunctionType()->getReturnType();
878 const Type* ArgTyPtr = PointerType::get(ArgTy);
879 Function* NF = Result->getOrInsertFunction("llvm.va_start",
Jeff Cohen11e26b52005-10-23 04:37:20 +0000880 RetTy, ArgTyPtr, (Type *)0);
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000881
882 while (!F->use_empty()) {
883 CallInst* CI = cast<CallInst>(F->use_back());
884 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
885 new CallInst(NF, bar, "", CI);
886 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
887 CI->replaceAllUsesWith(foo);
888 CI->getParent()->getInstList().erase(CI);
889 }
890 Result->getFunctionList().erase(F);
891 }
892
893 if(Function* F = Result->getNamedFunction("llvm.va_end")) {
894 if(F->arg_size() != 1)
895 ThrowException("Obsolete va_end takes 1 argument!");
896
897 //vaend foo
898 // ->
899 //bar = alloca 1 of typeof(foo)
900 //vaend bar
901 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
902 const Type* ArgTy = F->getFunctionType()->getParamType(0);
903 const Type* ArgTyPtr = PointerType::get(ArgTy);
904 Function* NF = Result->getOrInsertFunction("llvm.va_end",
Jeff Cohen11e26b52005-10-23 04:37:20 +0000905 RetTy, ArgTyPtr, (Type *)0);
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000906
907 while (!F->use_empty()) {
908 CallInst* CI = cast<CallInst>(F->use_back());
909 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
910 new StoreInst(CI->getOperand(1), bar, CI);
911 new CallInst(NF, bar, "", CI);
912 CI->getParent()->getInstList().erase(CI);
913 }
914 Result->getFunctionList().erase(F);
915 }
916
917 if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
918 if(F->arg_size() != 1)
919 ThrowException("Obsolete va_copy takes 1 argument!");
920 //foo = vacopy(bar)
921 // ->
922 //a = alloca 1 of typeof(foo)
923 //b = alloca 1 of typeof(foo)
924 //store bar -> b
925 //vacopy(a, b)
926 //foo = load a
927
928 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
929 const Type* ArgTy = F->getFunctionType()->getReturnType();
930 const Type* ArgTyPtr = PointerType::get(ArgTy);
931 Function* NF = Result->getOrInsertFunction("llvm.va_copy",
Jeff Cohen11e26b52005-10-23 04:37:20 +0000932 RetTy, ArgTyPtr, ArgTyPtr,
933 (Type *)0);
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000934
935 while (!F->use_empty()) {
936 CallInst* CI = cast<CallInst>(F->use_back());
937 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
938 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
939 new StoreInst(CI->getOperand(1), b, CI);
940 new CallInst(NF, a, b, "", CI);
941 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
942 CI->replaceAllUsesWith(foo);
943 CI->getParent()->getInstList().erase(CI);
944 }
945 Result->getFunctionList().erase(F);
946 }
947 }
948
949 return Result;
950
951 }
952
953//===----------------------------------------------------------------------===//
954// RunVMAsmParser - Define an interface to this parser
955//===----------------------------------------------------------------------===//
956//
957Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
958 set_scan_file(F);
959
960 CurFilename = Filename;
961 return RunParser(new Module(CurFilename));
962}
963
964Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
965 set_scan_string(AsmString);
966
967 CurFilename = "from_memory";
968 if (M == NULL) {
969 return RunParser(new Module (CurFilename));
970 } else {
971 return RunParser(M);
972 }
973}
974
975
Chris Lattneredd9b032006-01-23 23:05:42 +0000976#line 878 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
977typedef union {
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000978 llvm::Module *ModuleVal;
979 llvm::Function *FunctionVal;
980 std::pair<llvm::PATypeHolder*, char*> *ArgVal;
981 llvm::BasicBlock *BasicBlockVal;
982 llvm::TerminatorInst *TermInstVal;
983 llvm::Instruction *InstVal;
984 llvm::Constant *ConstVal;
985
986 const llvm::Type *PrimType;
987 llvm::PATypeHolder *TypeVal;
988 llvm::Value *ValueVal;
989
990 std::vector<std::pair<llvm::PATypeHolder*,char*> > *ArgList;
991 std::vector<llvm::Value*> *ValueList;
992 std::list<llvm::PATypeHolder> *TypeList;
993 // Represent the RHS of PHI node
994 std::list<std::pair<llvm::Value*,
995 llvm::BasicBlock*> > *PHIList;
996 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
997 std::vector<llvm::Constant*> *ConstVector;
998
999 llvm::GlobalValue::LinkageTypes Linkage;
1000 int64_t SInt64Val;
1001 uint64_t UInt64Val;
1002 int SIntVal;
1003 unsigned UIntVal;
1004 double FPVal;
1005 bool BoolVal;
1006
1007 char *StrVal; // This memory is strdup'd!
1008 llvm::ValID ValIDVal; // strdup'd memory maybe!
1009
1010 llvm::Instruction::BinaryOps BinaryOpVal;
1011 llvm::Instruction::TermOps TermOpVal;
1012 llvm::Instruction::MemoryOps MemOpVal;
1013 llvm::Instruction::OtherOps OtherOpVal;
1014 llvm::Module::Endianness Endianness;
1015} YYSTYPE;
Chris Lattneredd9b032006-01-23 23:05:42 +00001016#include <stdio.h>
1017
1018#ifndef __cplusplus
1019#ifndef __STDC__
1020#define const
1021#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001022#endif
1023
1024
1025
Chris Lattner8ebd2162006-01-24 04:14:29 +00001026#define YYFINAL 467
Chris Lattneredd9b032006-01-23 23:05:42 +00001027#define YYFLAG -32768
Chris Lattner8ebd2162006-01-24 04:14:29 +00001028#define YYNTBASE 114
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001029
Chris Lattner8ebd2162006-01-24 04:14:29 +00001030#define YYTRANSLATE(x) ((unsigned)(x) <= 353 ? yytranslate[x] : 184)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001031
Chris Lattneredd9b032006-01-23 23:05:42 +00001032static const char yytranslate[] = { 0,
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,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001036 2, 2, 2, 2, 2, 2, 2, 2, 2, 103,
1037 104, 112, 2, 101, 2, 2, 2, 2, 2, 2,
1038 2, 2, 2, 2, 2, 2, 2, 2, 2, 108,
1039 100, 109, 2, 2, 2, 2, 2, 2, 2, 2,
Chris Lattneredd9b032006-01-23 23:05:42 +00001040 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1041 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001042 105, 102, 107, 2, 2, 2, 2, 2, 113, 2,
Chris Lattneredd9b032006-01-23 23:05:42 +00001043 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001044 2, 2, 2, 2, 2, 2, 2, 2, 2, 106,
1045 2, 2, 110, 2, 111, 2, 2, 2, 2, 2,
Chris Lattneredd9b032006-01-23 23:05:42 +00001046 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1047 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1048 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1049 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1050 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1051 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1052 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1053 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1054 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1055 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1056 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1057 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1058 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
1059 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1060 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1061 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
1062 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
1063 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
1064 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1065 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1066 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1067 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001068 97, 98, 99
Chris Lattneredd9b032006-01-23 23:05:42 +00001069};
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001070
Chris Lattneredd9b032006-01-23 23:05:42 +00001071#if YYDEBUG != 0
1072static const short yyprhs[] = { 0,
1073 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
1074 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
1075 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
1076 60, 62, 64, 67, 68, 70, 72, 74, 76, 77,
1077 78, 80, 82, 84, 87, 88, 91, 92, 96, 99,
1078 100, 102, 103, 107, 109, 112, 114, 116, 118, 120,
1079 122, 124, 126, 128, 130, 132, 134, 136, 138, 140,
1080 142, 144, 146, 148, 150, 152, 154, 157, 162, 168,
1081 174, 178, 181, 184, 186, 190, 192, 196, 198, 199,
1082 204, 208, 212, 217, 222, 226, 229, 232, 235, 238,
1083 241, 244, 247, 250, 253, 256, 263, 269, 278, 285,
1084 292, 299, 306, 313, 317, 319, 321, 323, 325, 328,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001085 331, 336, 339, 341, 346, 349, 354, 355, 363, 364,
1086 372, 376, 381, 382, 384, 386, 388, 392, 396, 400,
1087 404, 408, 410, 411, 413, 415, 417, 418, 421, 425,
1088 427, 429, 433, 435, 436, 445, 447, 449, 453, 455,
1089 457, 460, 461, 465, 467, 469, 471, 473, 475, 477,
1090 479, 481, 485, 487, 489, 491, 493, 495, 498, 501,
1091 504, 508, 511, 512, 514, 517, 520, 524, 534, 544,
1092 553, 567, 569, 571, 578, 584, 587, 594, 602, 604,
1093 608, 610, 611, 614, 616, 622, 628, 634, 637, 642,
1094 647, 654, 659, 664, 669, 674, 681, 684, 692, 694,
1095 697, 698, 700, 701, 705, 712, 716, 723, 726, 731,
1096 738
Chris Lattneredd9b032006-01-23 23:05:42 +00001097};
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001098
Chris Lattneredd9b032006-01-23 23:05:42 +00001099static const short yyrhs[] = { 5,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001100 0, 6, 0, 3, 0, 4, 0, 70, 0, 71,
1101 0, 72, 0, 73, 0, 74, 0, 75, 0, 76,
1102 0, 77, 0, 78, 0, 79, 0, 80, 0, 81,
1103 0, 82, 0, 83, 0, 93, 0, 94, 0, 16,
Chris Lattneredd9b032006-01-23 23:05:42 +00001104 0, 14, 0, 12, 0, 10, 0, 17, 0, 15,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001105 0, 13, 0, 11, 0, 120, 0, 121, 0, 18,
1106 0, 19, 0, 154, 100, 0, 0, 41, 0, 42,
1107 0, 43, 0, 44, 0, 0, 0, 61, 0, 62,
1108 0, 63, 0, 60, 4, 0, 0, 54, 4, 0,
1109 0, 101, 54, 4, 0, 34, 24, 0, 0, 129,
1110 0, 0, 101, 132, 131, 0, 129, 0, 54, 4,
1111 0, 135, 0, 8, 0, 137, 0, 8, 0, 137,
Chris Lattneredd9b032006-01-23 23:05:42 +00001112 0, 9, 0, 10, 0, 11, 0, 12, 0, 13,
1113 0, 14, 0, 15, 0, 16, 0, 17, 0, 18,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001114 0, 19, 0, 20, 0, 21, 0, 45, 0, 136,
1115 0, 167, 0, 102, 4, 0, 134, 103, 139, 104,
1116 0, 105, 4, 106, 137, 107, 0, 108, 4, 106,
1117 137, 109, 0, 110, 138, 111, 0, 110, 111, 0,
1118 137, 112, 0, 137, 0, 138, 101, 137, 0, 138,
1119 0, 138, 101, 37, 0, 37, 0, 0, 135, 105,
1120 142, 107, 0, 135, 105, 107, 0, 135, 113, 24,
1121 0, 135, 108, 142, 109, 0, 135, 110, 142, 111,
1122 0, 135, 110, 111, 0, 135, 38, 0, 135, 39,
1123 0, 135, 167, 0, 135, 141, 0, 135, 26, 0,
1124 120, 115, 0, 121, 4, 0, 9, 27, 0, 9,
1125 28, 0, 123, 7, 0, 91, 103, 140, 36, 135,
1126 104, 0, 89, 103, 140, 181, 104, 0, 92, 103,
1127 140, 101, 140, 101, 140, 104, 0, 116, 103, 140,
1128 101, 140, 104, 0, 117, 103, 140, 101, 140, 104,
1129 0, 118, 103, 140, 101, 140, 104, 0, 119, 103,
1130 140, 101, 140, 104, 0, 96, 103, 140, 101, 140,
1131 104, 0, 142, 101, 140, 0, 140, 0, 32, 0,
1132 33, 0, 145, 0, 145, 163, 0, 145, 164, 0,
1133 145, 59, 58, 149, 0, 145, 25, 0, 146, 0,
1134 146, 124, 20, 133, 0, 146, 164, 0, 146, 59,
1135 58, 149, 0, 0, 146, 124, 125, 143, 140, 147,
1136 131, 0, 0, 146, 124, 47, 143, 135, 148, 131,
1137 0, 146, 48, 151, 0, 146, 55, 100, 152, 0,
1138 0, 24, 0, 53, 0, 52, 0, 50, 100, 150,
1139 0, 51, 100, 4, 0, 49, 100, 24, 0, 105,
1140 153, 107, 0, 153, 101, 24, 0, 24, 0, 0,
1141 22, 0, 24, 0, 154, 0, 0, 135, 155, 0,
1142 157, 101, 156, 0, 156, 0, 157, 0, 157, 101,
1143 37, 0, 37, 0, 0, 126, 133, 154, 103, 158,
1144 104, 130, 127, 0, 29, 0, 110, 0, 125, 159,
1145 160, 0, 30, 0, 111, 0, 170, 162, 0, 0,
1146 31, 165, 159, 0, 3, 0, 4, 0, 7, 0,
1147 27, 0, 28, 0, 38, 0, 39, 0, 26, 0,
1148 108, 142, 109, 0, 141, 0, 114, 0, 154, 0,
1149 167, 0, 166, 0, 135, 168, 0, 170, 171, 0,
1150 161, 171, 0, 172, 124, 173, 0, 172, 175, 0,
1151 0, 23, 0, 64, 169, 0, 64, 8, 0, 65,
1152 21, 168, 0, 65, 9, 168, 101, 21, 168, 101,
1153 21, 168, 0, 66, 122, 168, 101, 21, 168, 105,
1154 174, 107, 0, 66, 122, 168, 101, 21, 168, 105,
1155 107, 0, 67, 126, 133, 168, 103, 178, 104, 36,
1156 21, 168, 68, 21, 168, 0, 68, 0, 69, 0,
1157 174, 122, 166, 101, 21, 168, 0, 122, 166, 101,
1158 21, 168, 0, 124, 180, 0, 135, 105, 168, 101,
1159 168, 107, 0, 176, 101, 105, 168, 101, 168, 107,
1160 0, 169, 0, 177, 101, 169, 0, 177, 0, 0,
1161 57, 56, 0, 56, 0, 116, 135, 168, 101, 168,
1162 0, 117, 135, 168, 101, 168, 0, 118, 135, 168,
1163 101, 168, 0, 46, 169, 0, 119, 169, 101, 169,
1164 0, 91, 169, 36, 135, 0, 92, 169, 101, 169,
1165 101, 169, 0, 95, 169, 101, 135, 0, 98, 169,
1166 101, 135, 0, 99, 169, 101, 135, 0, 96, 169,
1167 101, 169, 0, 97, 169, 101, 169, 101, 169, 0,
1168 90, 176, 0, 179, 126, 133, 168, 103, 178, 104,
1169 0, 183, 0, 101, 177, 0, 0, 35, 0, 0,
1170 84, 135, 128, 0, 84, 135, 101, 15, 168, 128,
1171 0, 85, 135, 128, 0, 85, 135, 101, 15, 168,
1172 128, 0, 86, 169, 0, 182, 87, 135, 168, 0,
1173 182, 88, 169, 101, 135, 168, 0, 89, 135, 168,
1174 181, 0
Chris Lattneredd9b032006-01-23 23:05:42 +00001175};
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001176
1177#endif
1178
Chris Lattneredd9b032006-01-23 23:05:42 +00001179#if YYDEBUG != 0
1180static const short yyrline[] = { 0,
1181 997, 998, 1005, 1006, 1015, 1015, 1015, 1015, 1015, 1016,
1182 1016, 1016, 1017, 1017, 1017, 1017, 1017, 1017, 1019, 1019,
1183 1023, 1023, 1023, 1023, 1024, 1024, 1024, 1024, 1025, 1025,
1184 1026, 1026, 1029, 1032, 1036, 1036, 1037, 1038, 1039, 1042,
1185 1042, 1043, 1044, 1045, 1054, 1054, 1060, 1060, 1068, 1075,
1186 1075, 1081, 1081, 1083, 1087, 1100, 1100, 1101, 1101, 1103,
1187 1112, 1112, 1112, 1112, 1112, 1112, 1112, 1113, 1113, 1113,
1188 1113, 1113, 1113, 1114, 1117, 1120, 1126, 1133, 1145, 1149,
1189 1160, 1169, 1172, 1180, 1184, 1189, 1190, 1193, 1196, 1206,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001190 1231, 1244, 1273, 1298, 1318, 1330, 1339, 1343, 1402, 1408,
1191 1416, 1421, 1426, 1429, 1432, 1439, 1449, 1480, 1487, 1508,
1192 1518, 1523, 1530, 1540, 1543, 1550, 1550, 1560, 1567, 1571,
1193 1574, 1577, 1580, 1593, 1613, 1615, 1617, 1620, 1623, 1627,
1194 1630, 1632, 1634, 1638, 1650, 1651, 1653, 1656, 1664, 1669,
1195 1671, 1675, 1679, 1687, 1687, 1688, 1688, 1690, 1696, 1701,
1196 1707, 1710, 1715, 1719, 1723, 1809, 1809, 1811, 1819, 1819,
1197 1821, 1825, 1825, 1834, 1837, 1840, 1843, 1846, 1849, 1852,
1198 1855, 1858, 1882, 1889, 1892, 1897, 1897, 1903, 1907, 1910,
1199 1918, 1927, 1931, 1941, 1952, 1955, 1958, 1961, 1964, 1978,
1200 1982, 2035, 2038, 2044, 2052, 2062, 2069, 2074, 2081, 2085,
1201 2091, 2091, 2093, 2096, 2102, 2114, 2125, 2135, 2147, 2154,
1202 2161, 2168, 2173, 2192, 2214, 2222, 2234, 2248, 2305, 2311,
1203 2313, 2317, 2320, 2326, 2330, 2334, 2338, 2342, 2349, 2359,
1204 2372
Chris Lattneredd9b032006-01-23 23:05:42 +00001205};
1206#endif
1207
1208
1209#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
1210
1211static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL",
1212"EUINT64VAL","SINTVAL","UINTVAL","FPVAL","VOID","BOOL","SBYTE","UBYTE","SHORT",
1213"USHORT","INT","UINT","LONG","ULONG","FLOAT","DOUBLE","TYPE","LABEL","VAR_ID",
1214"LABELSTR","STRINGCONSTANT","IMPLEMENTATION","ZEROINITIALIZER","TRUETOK","FALSETOK",
1215"BEGINTOK","ENDTOK","DECLARE","GLOBAL","CONSTANT","SECTION","VOLATILE","TO",
1216"DOTDOTDOT","NULL_TOK","UNDEF","CONST","INTERNAL","LINKONCE","WEAK","APPENDING",
1217"OPAQUE","NOT","EXTERNAL","TARGET","TRIPLE","ENDIAN","POINTERSIZE","LITTLE",
Chris Lattner8ebd2162006-01-24 04:14:29 +00001218"BIG","ALIGN","DEPLIBS","CALL","TAIL","ASM_TOK","MODULE","CC_TOK","CCC_TOK",
1219"FASTCC_TOK","COLDCC_TOK","RET","BR","SWITCH","INVOKE","UNWIND","UNREACHABLE",
1220"ADD","SUB","MUL","DIV","REM","AND","OR","XOR","SETLE","SETGE","SETLT","SETGT",
1221"SETEQ","SETNE","MALLOC","ALLOCA","FREE","LOAD","STORE","GETELEMENTPTR","PHI_TOK",
1222"CAST","SELECT","SHL","SHR","VAARG","EXTRACTELEMENT","INSERTELEMENT","VAARG_old",
1223"VANEXT_old","'='","','","'\\\\'","'('","')'","'['","'x'","']'","'<'","'>'",
1224"'{'","'}'","'*'","'c'","INTVAL","EINT64VAL","ArithmeticOps","LogicalOps","SetCondOps",
1225"ShiftOps","SIntType","UIntType","IntType","FPType","OptAssign","OptLinkage",
1226"OptCallingConv","OptAlign","OptCAlign","SectionString","OptSection","GlobalVarAttributes",
1227"GlobalVarAttribute","TypesV","UpRTypesV","Types","PrimType","UpRTypes","TypeListI",
1228"ArgTypeListI","ConstVal","ConstExpr","ConstVector","GlobalType","Module","FunctionList",
1229"ConstPool","@1","@2","AsmBlock","BigOrLittle","TargetDefinition","LibrariesDefinition",
Chris Lattneredd9b032006-01-23 23:05:42 +00001230"LibList","Name","OptName","ArgVal","ArgListH","ArgList","FunctionHeaderH","BEGIN",
1231"FunctionHeader","END","Function","FunctionProto","@3","ConstValueRef","SymbolicValueRef",
1232"ValueRef","ResolvedVal","BasicBlockList","BasicBlock","InstructionList","BBTerminatorInst",
1233"JumpTable","Inst","PHIList","ValueRefList","ValueRefListE","OptTailCall","InstVal",
1234"IndexList","OptVolatile","MemoryInst", NULL
1235};
1236#endif
1237
1238static const short yyr1[] = { 0,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001239 114, 114, 115, 115, 116, 116, 116, 116, 116, 117,
1240 117, 117, 118, 118, 118, 118, 118, 118, 119, 119,
1241 120, 120, 120, 120, 121, 121, 121, 121, 122, 122,
1242 123, 123, 124, 124, 125, 125, 125, 125, 125, 126,
1243 126, 126, 126, 126, 127, 127, 128, 128, 129, 130,
1244 130, 131, 131, 132, 132, 133, 133, 134, 134, 135,
1245 136, 136, 136, 136, 136, 136, 136, 136, 136, 136,
1246 136, 136, 136, 137, 137, 137, 137, 137, 137, 137,
1247 137, 137, 137, 138, 138, 139, 139, 139, 139, 140,
1248 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
1249 140, 140, 140, 140, 140, 141, 141, 141, 141, 141,
1250 141, 141, 141, 142, 142, 143, 143, 144, 145, 145,
1251 145, 145, 145, 146, 146, 146, 147, 146, 148, 146,
1252 146, 146, 146, 149, 150, 150, 151, 151, 151, 152,
1253 153, 153, 153, 154, 154, 155, 155, 156, 157, 157,
1254 158, 158, 158, 158, 159, 160, 160, 161, 162, 162,
1255 163, 165, 164, 166, 166, 166, 166, 166, 166, 166,
1256 166, 166, 166, 167, 167, 168, 168, 169, 170, 170,
1257 171, 172, 172, 172, 173, 173, 173, 173, 173, 173,
1258 173, 173, 173, 174, 174, 175, 176, 176, 177, 177,
1259 178, 178, 179, 179, 180, 180, 180, 180, 180, 180,
1260 180, 180, 180, 180, 180, 180, 180, 180, 180, 181,
1261 181, 182, 182, 183, 183, 183, 183, 183, 183, 183,
1262 183
Chris Lattneredd9b032006-01-23 23:05:42 +00001263};
1264
1265static const short yyr2[] = { 0,
1266 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1267 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1268 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1269 1, 1, 2, 0, 1, 1, 1, 1, 0, 0,
1270 1, 1, 1, 2, 0, 2, 0, 3, 2, 0,
1271 1, 0, 3, 1, 2, 1, 1, 1, 1, 1,
1272 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1273 1, 1, 1, 1, 1, 1, 2, 4, 5, 5,
1274 3, 2, 2, 1, 3, 1, 3, 1, 0, 4,
1275 3, 3, 4, 4, 3, 2, 2, 2, 2, 2,
1276 2, 2, 2, 2, 2, 6, 5, 8, 6, 6,
1277 6, 6, 6, 3, 1, 1, 1, 1, 2, 2,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001278 4, 2, 1, 4, 2, 4, 0, 7, 0, 7,
Chris Lattneredd9b032006-01-23 23:05:42 +00001279 3, 4, 0, 1, 1, 1, 3, 3, 3, 3,
1280 3, 1, 0, 1, 1, 1, 0, 2, 3, 1,
1281 1, 3, 1, 0, 8, 1, 1, 3, 1, 1,
1282 2, 0, 3, 1, 1, 1, 1, 1, 1, 1,
1283 1, 3, 1, 1, 1, 1, 1, 2, 2, 2,
1284 3, 2, 0, 1, 2, 2, 3, 9, 9, 8,
1285 13, 1, 1, 6, 5, 2, 6, 7, 1, 3,
1286 1, 0, 2, 1, 5, 5, 5, 2, 4, 4,
1287 6, 4, 4, 4, 4, 6, 2, 7, 1, 2,
1288 0, 1, 0, 3, 6, 3, 6, 2, 4, 6,
1289 4
1290};
1291
1292static const short yydefact[] = { 133,
1293 39, 123, 122, 162, 35, 36, 37, 38, 0, 40,
1294 183, 119, 120, 183, 144, 145, 0, 0, 0, 39,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001295 0, 125, 40, 0, 0, 41, 42, 43, 0, 0,
1296 184, 180, 34, 159, 160, 161, 179, 0, 0, 0,
1297 131, 0, 0, 0, 0, 0, 33, 163, 134, 121,
1298 44, 1, 2, 57, 61, 62, 63, 64, 65, 66,
1299 67, 68, 69, 70, 71, 72, 73, 74, 0, 0,
1300 0, 0, 174, 0, 0, 56, 75, 60, 175, 76,
1301 156, 157, 158, 223, 182, 0, 0, 0, 143, 132,
1302 126, 124, 116, 117, 0, 0, 77, 0, 0, 59,
1303 82, 84, 0, 0, 89, 83, 222, 0, 204, 0,
1304 0, 0, 0, 40, 192, 193, 5, 6, 7, 8,
1305 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
1306 0, 0, 0, 0, 0, 0, 0, 19, 20, 0,
1307 0, 0, 0, 0, 0, 0, 0, 0, 181, 40,
1308 196, 0, 219, 139, 136, 135, 137, 138, 142, 0,
1309 129, 61, 62, 63, 64, 65, 66, 67, 68, 69,
1310 70, 71, 0, 0, 0, 0, 127, 0, 0, 0,
1311 81, 154, 88, 86, 0, 0, 208, 203, 186, 185,
1312 0, 0, 24, 28, 23, 27, 22, 26, 21, 25,
1313 29, 30, 0, 0, 47, 47, 228, 0, 0, 217,
Chris Lattneredd9b032006-01-23 23:05:42 +00001314 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001315 0, 0, 0, 0, 0, 140, 52, 103, 104, 3,
1316 4, 101, 102, 105, 100, 96, 97, 0, 0, 0,
1317 0, 0, 0, 0, 0, 0, 0, 0, 0, 99,
1318 98, 52, 58, 58, 85, 153, 147, 150, 151, 0,
1319 0, 78, 164, 165, 166, 171, 167, 168, 169, 170,
1320 0, 173, 177, 176, 178, 0, 187, 0, 0, 0,
1321 224, 0, 226, 221, 0, 0, 0, 0, 0, 0,
1322 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1323 141, 0, 130, 0, 0, 0, 0, 91, 115, 0,
1324 0, 95, 0, 92, 0, 0, 0, 0, 128, 79,
1325 80, 146, 148, 0, 50, 87, 0, 0, 0, 0,
1326 0, 0, 0, 0, 231, 0, 0, 210, 0, 212,
1327 215, 0, 213, 214, 0, 0, 0, 209, 0, 229,
1328 0, 0, 0, 54, 52, 221, 0, 0, 0, 0,
1329 90, 93, 94, 0, 0, 0, 0, 152, 149, 51,
1330 45, 172, 0, 0, 202, 47, 48, 47, 199, 220,
1331 0, 0, 0, 0, 205, 206, 207, 202, 0, 49,
1332 55, 53, 0, 0, 0, 0, 114, 0, 0, 0,
1333 0, 0, 155, 0, 0, 201, 0, 0, 225, 227,
1334 0, 0, 0, 211, 216, 0, 230, 107, 0, 0,
1335 0, 0, 0, 0, 0, 46, 0, 0, 0, 200,
1336 197, 0, 218, 106, 0, 113, 109, 110, 111, 112,
1337 0, 190, 0, 0, 0, 198, 0, 188, 0, 189,
1338 0, 0, 108, 0, 0, 0, 0, 0, 0, 195,
1339 0, 0, 194, 191, 0, 0, 0
Chris Lattneredd9b032006-01-23 23:05:42 +00001340};
1341
Chris Lattner8ebd2162006-01-24 04:14:29 +00001342static const short yydefgoto[] = { 73,
1343 232, 246, 247, 248, 249, 173, 174, 203, 175, 20,
1344 10, 29, 403, 281, 354, 371, 303, 355, 74, 75,
1345 186, 77, 78, 103, 185, 309, 272, 310, 95, 465,
1346 1, 2, 252, 227, 50, 157, 41, 90, 160, 79,
1347 323, 258, 259, 260, 30, 83, 11, 36, 12, 13,
1348 23, 273, 80, 275, 379, 14, 32, 33, 149, 444,
1349 85, 210, 406, 407, 150, 151, 335, 152, 153
Chris Lattneredd9b032006-01-23 23:05:42 +00001350};
1351
1352static const short yypact[] = {-32768,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001353 37, 361,-32768,-32768,-32768,-32768,-32768,-32768, -44, 49,
1354 38,-32768,-32768, 3,-32768,-32768, 70, -2, 42, 50,
1355 4,-32768, 49, 89, 125,-32768,-32768,-32768, 1054, -21,
1356-32768,-32768, 64,-32768,-32768,-32768,-32768, 26, 45, 47,
1357-32768, 69, 89, 1054, 117, 117,-32768,-32768,-32768,-32768,
1358-32768,-32768,-32768, 73,-32768,-32768,-32768,-32768,-32768,-32768,
1359-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 174, 179,
1360 180, 122,-32768, 64, 82,-32768,-32768, -27,-32768,-32768,
1361-32768,-32768,-32768, 1215,-32768, 163, -25, 186, 168,-32768,
1362-32768,-32768,-32768,-32768, 1092, 1130,-32768, 85, 90,-32768,
1363-32768, -27, -38, 94, 864,-32768,-32768, 1092,-32768, 142,
1364 1168, 23, 144, 49,-32768,-32768,-32768,-32768,-32768,-32768,
Chris Lattneredd9b032006-01-23 23:05:42 +00001365-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001366 1092, 1092, 1092, 1092, 1092, 1092, 1092,-32768,-32768, 1092,
1367 1092, 1092, 1092, 1092, 1092, 1092, 1092, 1092,-32768, 49,
1368-32768, 75,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -36,
1369-32768, 124, 162, 195, 165, 196, 167, 197, 169, 198,
1370 200, 201, 177, 199, 209, 531,-32768, 1092, 1092, 1092,
1371-32768, 902,-32768, 103, 101, 680,-32768,-32768, 73,-32768,
1372 680, 680,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1373-32768,-32768, 680, 1054, 116, 118,-32768, 680, 113, 127,
1374 189, 130, 133, 134, 135, 136, 137, 680, 680, 680,
1375 139, 1054, 1092, 1092, 202,-32768, 140,-32768,-32768,-32768,
1376-32768,-32768,-32768,-32768,-32768,-32768,-32768, 143, 145, 146,
1377 147, 940, 1130, 637, 219, 148, 149, 150, 151,-32768,
1378-32768, 140, -35, -64, -27,-32768, 64,-32768, 154, 153,
1379 978,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1380 1130,-32768,-32768,-32768,-32768, 158,-32768, 161, 680, -5,
1381-32768, 15,-32768, 173, 680, 164, 1092, 1092, 1092, 1092,
1382 1092, 1092, 1092, 178, 182, 183, 1092, 680, 680, 184,
1383-32768, -18,-32768, 1130, 1130, 1130, 1130,-32768,-32768, -6,
1384 -26,-32768, -37,-32768, 1130, 1130, 1130, 1130,-32768,-32768,
1385-32768,-32768,-32768, 1016, 213,-32768, -19, 245, 247, 187,
1386 680, 266, 680, 1092,-32768, 190, 680,-32768, 191,-32768,
1387-32768, 192,-32768,-32768, 680, 680, 680,-32768, 193,-32768,
1388 1092, 256, 290,-32768, 140, 173, 261, 206, 207, 1130,
1389-32768,-32768,-32768, 210, 211, 212, 214,-32768,-32768,-32768,
1390 244,-32768, 680, 680, 1092, 215,-32768, 215,-32768, 218,
1391 680, 220, 1092, 1092,-32768,-32768,-32768, 1092, 680,-32768,
1392-32768,-32768, 216, 1092, 1130, 1130,-32768, 1130, 1130, 1130,
1393 1130, 295,-32768, 222, 205, 218, 221, 248,-32768,-32768,
1394 1092, 217, 680,-32768,-32768, 223,-32768,-32768, 224, 225,
1395 231, 232, 233, 235, 238,-32768, 293, 8, 307,-32768,
1396-32768, 237,-32768,-32768, 1130,-32768,-32768,-32768,-32768,-32768,
1397 680,-32768, 763, 41, 324,-32768, 243,-32768, 249,-32768,
1398 763, 680,-32768, 327, 252, 281, 680, 333, 334,-32768,
1399 680, 680,-32768,-32768, 359, 360,-32768
Chris Lattneredd9b032006-01-23 23:05:42 +00001400};
1401
1402static const short yypgoto[] = {-32768,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001403-32768, 277, 278, 279, 280, -111, -110, -415,-32768, 335,
1404 353, -103,-32768, -199, 51,-32768, -247,-32768, -40,-32768,
1405 -29,-32768, -55, 269,-32768, -95, 203, -184, 329,-32768,
1406-32768,-32768,-32768,-32768, 337,-32768,-32768,-32768,-32768, 10,
1407-32768, 54,-32768,-32768, 354,-32768,-32768,-32768,-32768, 380,
1408-32768, -344, 53, 138, -102,-32768, 373,-32768,-32768,-32768,
1409-32768,-32768, 55, 0,-32768,-32768, 35,-32768,-32768
Chris Lattneredd9b032006-01-23 23:05:42 +00001410};
1411
1412
Chris Lattner8ebd2162006-01-24 04:14:29 +00001413#define YYLAST 1314
Chris Lattneredd9b032006-01-23 23:05:42 +00001414
1415
Chris Lattner8ebd2162006-01-24 04:14:29 +00001416static const short yytable[] = { 76,
1417 177, 201, 202, 92, 319, 187, 283, 81, 190, 331,
1418 204, 21, 443, 24, 76, 352, 102, 193, 194, 195,
1419 196, 197, 198, 199, 200, 31, 155, 156, 451, 333,
1420 207, 191, 34, 211, 212, 353, -118, 213, 214, 215,
1421 216, 217, 21, 192, 321, 221, 222, 106, 332, 102,
1422 193, 194, 195, 196, 197, 198, 199, 200, 311, 313,
1423 31, 3, 180, 360, 225, 161, 176, 4, 332, 44,
1424 226, 320, 181, 363, 360, -58, 106, 5, 6, 7,
1425 8, 360, 362, 104, 106, 15, 327, 16, 82, 372,
1426 5, 6, 7, 8, 360, 9, 45, 42, 449, 43,
1427 361, 205, 206, 47, 208, 209, 455, 392, 25, 26,
1428 27, 28, 49, 35, 442, 218, 219, 220, 38, 39,
1429 40, 300, 253, 254, 255, 86, 52, 53, 51, 100,
1430 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1431 65, 66, 67, 15, 87, 16, 88, 450, 93, 94,
1432 228, 229, 257, 193, 194, 195, 196, 197, 198, 199,
1433 200, 223, 224, 279, -24, -24, 68, -23, -23, -22,
1434 -22, -21, -21, 89, 76, -59, 409, 97, 410, 230,
1435 231, 298, 98, 99, 105, 339, 154, 341, 342, 158,
1436 178, 159, 76, 299, 348, 179, 182, 188, -28, -27,
1437 -26, -25, 233, 261, 262, 255, -31, -32, 356, 357,
1438 358, 359, 176, 176, 176, 234, 280, 285, 282, 364,
1439 365, 366, 367, 69, 287, 301, 70, 286, 251, 71,
1440 288, 72, 101, 289, 290, 291, 292, 293, 274, 297,
1441 302, 176, 314, 274, 274, 304, 352, 305, 306, 307,
1442 315, 316, 317, 318, 324, 274, 325, 338, 328, 340,
1443 274, 329, 343, 344, 397, 373, 322, 374, 337, 377,
1444 274, 274, 274, 334, 176, 176, 176, 176, 345, 390,
1445 414, 415, 346, 347, 351, 176, 176, 176, 176, 375,
1446 381, 383, 384, 391, 257, 388, 394, 402, 426, 420,
1447 421, 332, 422, 423, 424, 425, 395, 396, 430, 428,
1448 398, 399, 400, 441, 401, 408, 201, 202, 411, 418,
1449 413, 389, 427, 431, 429, 435, 433, 434, 276, 277,
1450 176, 274, 201, 202, 436, 437, 438, 274, 439, 447,
1451 278, 440, 445, 446, 452, 284, 453, 457, 459, 454,
1452 274, 274, 458, 461, 462, 294, 295, 296, 466, 467,
1453 145, 146, 147, 148, 419, 176, 176, 84, 176, 176,
1454 176, 176, 46, 184, 96, 370, 48, 369, 250, 91,
1455 -34, 22, 15, 274, 16, 274, 37, 416, 380, 274,
1456 393, 4, -34, -34, 0, 0, 0, 274, 274, 274,
1457 0, -34, -34, -34, -34, 176, 0, -34, 17, 0,
1458 0, 0, 0, 0, 0, 18, 330, 0, 0, 19,
1459 0, 0, 336, 0, 0, 274, 274, 0, 0, 0,
1460 0, 0, 0, 274, 0, 349, 350, 0, 0, 0,
1461 0, 274, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattneredd9b032006-01-23 23:05:42 +00001462 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001463 0, 0, 0, 0, 0, 274, 0, 0, 376, 0,
1464 378, 0, 0, 0, 382, 0, 0, 0, 0, 0,
1465 0, 0, 385, 386, 387, 0, 0, 0, 0, 0,
1466 0, 0, 0, 274, 0, 0, 0, 0, 0, 0,
1467 0, 0, 0, 0, 274, 0, 0, 0, 0, 274,
1468 404, 405, 0, 274, 274, 0, 0, 0, 412, 0,
1469 0, 0, 0, 0, 0, 0, 417, 0, 0, 0,
1470 0, 0, 0, 0, 0, 52, 53, 0, 0, 0,
1471 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1472 432, 0, 15, 0, 16, 0, 235, 0, 0, 0,
1473 0, 0, 0, 0, 0, 0, 0, 0, 236, 237,
1474 0, 0, 0, 0, 0, 0, 0, 0, 448, 0,
1475 0, 0, 0, 0, 0, 0, 0, 0, 0, 456,
1476 0, 0, 0, 0, 460, 0, 0, 0, 463, 464,
1477 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
1478 127, 128, 129, 130, 0, 0, 0, 0, 0, 238,
1479 0, 239, 240, 138, 139, 0, 241, 0, 0, 0,
1480 0, 0, 0, 0, 0, 242, 0, 0, 243, 0,
1481 244, 52, 53, 245, 100, 162, 163, 164, 165, 166,
1482 167, 168, 169, 170, 171, 172, 66, 67, 15, 0,
1483 16, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1484 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1485 0, 68, 263, 264, 52, 53, 265, 0, 0, 0,
1486 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1487 0, 15, 0, 16, 0, 266, 267, 268, 0, 0,
1488 0, 0, 0, 0, 0, 0, 0, 269, 270, 0,
1489 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1490 0, 0, 0, 0, 0, 0, 0, 0, 69, 0,
1491 0, 70, 0, 0, 71, 0, 72, 312, 0, 117,
1492 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
1493 128, 129, 130, 0, 0, 263, 264, 0, 238, 265,
1494 239, 240, 138, 139, 0, 241, 0, 0, 0, 0,
1495 0, 0, 0, 0, 0, 0, 0, 271, 266, 267,
1496 268, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1497 269, 270, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattneredd9b032006-01-23 23:05:42 +00001498 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1499 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001500 0, 0, 117, 118, 119, 120, 121, 122, 123, 124,
1501 125, 126, 127, 128, 129, 130, 0, 0, 0, 0,
1502 0, 238, 0, 239, 240, 138, 139, 0, 241, 0,
1503 0, 0, 0, 0, 0, 0, 0, 0, 52, 53,
1504 271, 100, 55, 56, 57, 58, 59, 60, 61, 62,
1505 63, 64, 65, 66, 67, 15, 0, 16, 0, 0,
Chris Lattneredd9b032006-01-23 23:05:42 +00001506 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001507 183, 0, 0, 0, 0, 0, 52, 53, 68, 100,
1508 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1509 65, 66, 67, 15, 0, 16, 0, 0, 0, 0,
1510 0, 0, 0, 0, 0, 0, 0, 0, 256, 0,
1511 0, 0, 0, 0, 52, 53, 68, 100, 162, 163,
1512 164, 165, 166, 167, 168, 169, 170, 171, 172, 66,
1513 67, 15, 0, 16, 0, 69, 0, 0, 70, 0,
1514 0, 71, 0, 72, 0, 0, 0, 0, 0, 0,
1515 0, 0, 52, 53, 68, 100, 55, 56, 57, 58,
1516 59, 60, 61, 62, 63, 64, 65, 66, 67, 15,
1517 0, 16, 0, 69, 0, 0, 70, 0, 0, 71,
1518 0, 72, 0, 0, 326, 0, 0, 0, 0, 0,
1519 52, 53, 68, 100, 55, 56, 57, 58, 59, 60,
1520 61, 62, 63, 64, 65, 66, 67, 15, 0, 16,
1521 0, 69, 0, 0, 70, 0, 308, 71, 0, 72,
1522 0, 0, 368, 0, 0, 0, 0, 0, 52, 53,
1523 68, 54, 55, 56, 57, 58, 59, 60, 61, 62,
1524 63, 64, 65, 66, 67, 15, 0, 16, 0, 69,
1525 0, 0, 70, 0, 0, 71, 0, 72, 0, 0,
1526 0, 0, 0, 0, 0, 0, 52, 53, 68, 100,
1527 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1528 65, 66, 67, 15, 0, 16, 0, 69, 0, 0,
1529 70, 0, 0, 71, 0, 72, 0, 0, 0, 0,
1530 0, 0, 0, 0, 52, 53, 68, 100, 162, 163,
1531 164, 165, 166, 167, 168, 169, 170, 171, 172, 66,
1532 67, 15, 0, 16, 0, 69, 0, 0, 70, 0,
1533 0, 71, 0, 72, 0, 0, 0, 0, 0, 0,
1534 0, 0, 52, 53, 68, 189, 55, 56, 57, 58,
1535 59, 60, 61, 62, 63, 64, 65, 66, 67, 15,
1536 0, 16, 0, 69, 0, 0, 70, 0, 0, 71,
1537 0, 72, 0, 0, 0, 0, 0, 0, 0, 0,
1538 0, 0, 68, 0, 0, 0, 0, 0, 0, 0,
Chris Lattneredd9b032006-01-23 23:05:42 +00001539 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001540 0, 69, 0, 0, 70, 0, 0, 71, 0, 72,
1541 0, 0, 0, 0, 0, 0, 0, 0, 0, 107,
Chris Lattneredd9b032006-01-23 23:05:42 +00001542 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001543 108, 0, 0, 0, 0, 0, 0, 0, 0, 69,
1544 109, 110, 70, 0, 0, 71, 0, 72, 111, 112,
1545 113, 114, 115, 116, 117, 118, 119, 120, 121, 122,
1546 123, 124, 125, 126, 127, 128, 129, 130, 131, 132,
1547 133, 0, 0, 134, 135, 136, 137, 138, 139, 140,
1548 141, 142, 143, 144
Chris Lattneredd9b032006-01-23 23:05:42 +00001549};
1550
Chris Lattner8ebd2162006-01-24 04:14:29 +00001551static const short yycheck[] = { 29,
1552 96, 113, 113, 44, 252, 108, 206, 29, 111, 15,
1553 114, 2, 428, 58, 44, 34, 72, 10, 11, 12,
1554 13, 14, 15, 16, 17, 23, 52, 53, 444, 15,
1555 133, 9, 30, 136, 137, 54, 0, 140, 141, 142,
1556 143, 144, 33, 21, 109, 148, 150, 112, 54, 105,
1557 10, 11, 12, 13, 14, 15, 16, 17, 243, 244,
1558 23, 25, 101, 101, 101, 95, 96, 31, 54, 20,
1559 107, 107, 111, 111, 101, 103, 112, 41, 42, 43,
1560 44, 101, 109, 74, 112, 22, 271, 24, 110, 109,
1561 41, 42, 43, 44, 101, 59, 47, 100, 443, 58,
1562 107, 131, 132, 100, 134, 135, 451, 355, 60, 61,
1563 62, 63, 24, 111, 107, 145, 146, 147, 49, 50,
1564 51, 224, 178, 179, 180, 100, 5, 6, 4, 8,
1565 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
1566 19, 20, 21, 22, 100, 24, 100, 107, 32, 33,
1567 27, 28, 182, 10, 11, 12, 13, 14, 15, 16,
1568 17, 87, 88, 204, 3, 4, 45, 3, 4, 3,
1569 4, 3, 4, 105, 204, 103, 376, 4, 378, 3,
1570 4, 222, 4, 4, 103, 288, 24, 290, 291, 4,
1571 106, 24, 222, 223, 297, 106, 103, 56, 4, 4,
1572 4, 4, 4, 101, 104, 261, 7, 7, 304, 305,
1573 306, 307, 242, 243, 244, 7, 101, 105, 101, 315,
1574 316, 317, 318, 102, 36, 24, 105, 101, 176, 108,
1575 101, 110, 111, 101, 101, 101, 101, 101, 186, 101,
1576 101, 271, 24, 191, 192, 103, 34, 103, 103, 103,
1577 103, 103, 103, 103, 101, 203, 104, 287, 101, 289,
1578 208, 101, 292, 293, 360, 21, 257, 21, 105, 4,
1579 218, 219, 220, 101, 304, 305, 306, 307, 101, 24,
1580 383, 384, 101, 101, 101, 315, 316, 317, 318, 103,
1581 101, 101, 101, 4, 324, 103, 36, 54, 4, 395,
1582 396, 54, 398, 399, 400, 401, 101, 101, 411, 105,
1583 101, 101, 101, 21, 101, 101, 428, 428, 101, 104,
1584 101, 351, 101, 107, 104, 101, 104, 104, 191, 192,
1585 360, 279, 444, 444, 104, 104, 104, 285, 104, 435,
1586 203, 104, 36, 107, 21, 208, 104, 21, 68, 101,
1587 298, 299, 101, 21, 21, 218, 219, 220, 0, 0,
1588 84, 84, 84, 84, 394, 395, 396, 33, 398, 399,
1589 400, 401, 20, 105, 46, 325, 23, 324, 176, 43,
1590 20, 2, 22, 331, 24, 333, 14, 388, 334, 337,
1591 356, 31, 32, 33, -1, -1, -1, 345, 346, 347,
1592 -1, 41, 42, 43, 44, 435, -1, 47, 48, -1,
1593 -1, -1, -1, -1, -1, 55, 279, -1, -1, 59,
1594 -1, -1, 285, -1, -1, 373, 374, -1, -1, -1,
1595 -1, -1, -1, 381, -1, 298, 299, -1, -1, -1,
1596 -1, 389, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattneredd9b032006-01-23 23:05:42 +00001597 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001598 -1, -1, -1, -1, -1, 413, -1, -1, 331, -1,
1599 333, -1, -1, -1, 337, -1, -1, -1, -1, -1,
1600 -1, -1, 345, 346, 347, -1, -1, -1, -1, -1,
1601 -1, -1, -1, 441, -1, -1, -1, -1, -1, -1,
1602 -1, -1, -1, -1, 452, -1, -1, -1, -1, 457,
1603 373, 374, -1, 461, 462, -1, -1, -1, 381, -1,
1604 -1, -1, -1, -1, -1, -1, 389, -1, -1, -1,
1605 -1, -1, -1, -1, -1, 5, 6, -1, -1, -1,
Chris Lattneredd9b032006-01-23 23:05:42 +00001606 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001607 413, -1, 22, -1, 24, -1, 26, -1, -1, -1,
1608 -1, -1, -1, -1, -1, -1, -1, -1, 38, 39,
1609 -1, -1, -1, -1, -1, -1, -1, -1, 441, -1,
1610 -1, -1, -1, -1, -1, -1, -1, -1, -1, 452,
1611 -1, -1, -1, -1, 457, -1, -1, -1, 461, 462,
1612 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
1613 80, 81, 82, 83, -1, -1, -1, -1, -1, 89,
1614 -1, 91, 92, 93, 94, -1, 96, -1, -1, -1,
1615 -1, -1, -1, -1, -1, 105, -1, -1, 108, -1,
1616 110, 5, 6, 113, 8, 9, 10, 11, 12, 13,
Chris Lattneredd9b032006-01-23 23:05:42 +00001617 14, 15, 16, 17, 18, 19, 20, 21, 22, -1,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001618 24, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattneredd9b032006-01-23 23:05:42 +00001619 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001620 -1, 45, 3, 4, 5, 6, 7, -1, -1, -1,
Chris Lattneredd9b032006-01-23 23:05:42 +00001621 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001622 -1, 22, -1, 24, -1, 26, 27, 28, -1, -1,
1623 -1, -1, -1, -1, -1, -1, -1, 38, 39, -1,
1624 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1625 -1, -1, -1, -1, -1, -1, -1, -1, 102, -1,
1626 -1, 105, -1, -1, 108, -1, 110, 111, -1, 70,
1627 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
1628 81, 82, 83, -1, -1, 3, 4, -1, 89, 7,
1629 91, 92, 93, 94, -1, 96, -1, -1, -1, -1,
1630 -1, -1, -1, -1, -1, -1, -1, 108, 26, 27,
1631 28, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1632 38, 39, -1, -1, -1, -1, -1, -1, -1, -1,
1633 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1634 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1635 -1, -1, 70, 71, 72, 73, 74, 75, 76, 77,
1636 78, 79, 80, 81, 82, 83, -1, -1, -1, -1,
1637 -1, 89, -1, 91, 92, 93, 94, -1, 96, -1,
1638 -1, -1, -1, -1, -1, -1, -1, -1, 5, 6,
1639 108, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1640 17, 18, 19, 20, 21, 22, -1, 24, -1, -1,
1641 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1642 37, -1, -1, -1, -1, -1, 5, 6, 45, 8,
1643 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
1644 19, 20, 21, 22, -1, 24, -1, -1, -1, -1,
1645 -1, -1, -1, -1, -1, -1, -1, -1, 37, -1,
1646 -1, -1, -1, -1, 5, 6, 45, 8, 9, 10,
1647 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
1648 21, 22, -1, 24, -1, 102, -1, -1, 105, -1,
1649 -1, 108, -1, 110, -1, -1, -1, -1, -1, -1,
1650 -1, -1, 5, 6, 45, 8, 9, 10, 11, 12,
1651 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
1652 -1, 24, -1, 102, -1, -1, 105, -1, -1, 108,
1653 -1, 110, -1, -1, 37, -1, -1, -1, -1, -1,
1654 5, 6, 45, 8, 9, 10, 11, 12, 13, 14,
1655 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
1656 -1, 102, -1, -1, 105, -1, 107, 108, -1, 110,
1657 -1, -1, 37, -1, -1, -1, -1, -1, 5, 6,
1658 45, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1659 17, 18, 19, 20, 21, 22, -1, 24, -1, 102,
1660 -1, -1, 105, -1, -1, 108, -1, 110, -1, -1,
1661 -1, -1, -1, -1, -1, -1, 5, 6, 45, 8,
1662 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
1663 19, 20, 21, 22, -1, 24, -1, 102, -1, -1,
1664 105, -1, -1, 108, -1, 110, -1, -1, -1, -1,
1665 -1, -1, -1, -1, 5, 6, 45, 8, 9, 10,
1666 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
1667 21, 22, -1, 24, -1, 102, -1, -1, 105, -1,
1668 -1, 108, -1, 110, -1, -1, -1, -1, -1, -1,
1669 -1, -1, 5, 6, 45, 8, 9, 10, 11, 12,
1670 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
1671 -1, 24, -1, 102, -1, -1, 105, -1, -1, 108,
1672 -1, 110, -1, -1, -1, -1, -1, -1, -1, -1,
1673 -1, -1, 45, -1, -1, -1, -1, -1, -1, -1,
1674 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1675 -1, 102, -1, -1, 105, -1, -1, 108, -1, 110,
1676 -1, -1, -1, -1, -1, -1, -1, -1, -1, 35,
1677 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1678 46, -1, -1, -1, -1, -1, -1, -1, -1, 102,
1679 56, 57, 105, -1, -1, 108, -1, 110, 64, 65,
1680 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
1681 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
1682 86, -1, -1, 89, 90, 91, 92, 93, 94, 95,
1683 96, 97, 98, 99
Chris Lattneredd9b032006-01-23 23:05:42 +00001684};
1685/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
1686#line 3 "/usr/share/bison.simple"
1687/* This file comes from bison-1.28. */
1688
1689/* Skeleton output parser for bison,
1690 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
1691
1692 This program is free software; you can redistribute it and/or modify
1693 it under the terms of the GNU General Public License as published by
1694 the Free Software Foundation; either version 2, or (at your option)
1695 any later version.
1696
1697 This program is distributed in the hope that it will be useful,
1698 but WITHOUT ANY WARRANTY; without even the implied warranty of
1699 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1700 GNU General Public License for more details.
1701
1702 You should have received a copy of the GNU General Public License
1703 along with this program; if not, write to the Free Software
1704 Foundation, Inc., 59 Temple Place - Suite 330,
1705 Boston, MA 02111-1307, USA. */
1706
1707/* As a special exception, when this file is copied by Bison into a
1708 Bison output file, you may use that output file without restriction.
1709 This special exception was added by the Free Software Foundation
1710 in version 1.24 of Bison. */
1711
1712/* This is the parser code that is written into each bison parser
1713 when the %semantic_parser declaration is not specified in the grammar.
1714 It was written by Richard Stallman by simplifying the hairy parser
1715 used when %semantic_parser is specified. */
1716
1717#ifndef YYSTACK_USE_ALLOCA
1718#ifdef alloca
1719#define YYSTACK_USE_ALLOCA
1720#else /* alloca not defined */
1721#ifdef __GNUC__
1722#define YYSTACK_USE_ALLOCA
1723#define alloca __builtin_alloca
1724#else /* not GNU C. */
1725#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
1726#define YYSTACK_USE_ALLOCA
1727#include <alloca.h>
1728#else /* not sparc */
1729/* We think this test detects Watcom and Microsoft C. */
1730/* This used to test MSDOS, but that is a bad idea
1731 since that symbol is in the user namespace. */
1732#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
1733#if 0 /* No need for malloc.h, which pollutes the namespace;
1734 instead, just don't use alloca. */
1735#include <malloc.h>
1736#endif
1737#else /* not MSDOS, or __TURBOC__ */
1738#if defined(_AIX)
1739/* I don't know what this was needed for, but it pollutes the namespace.
1740 So I turned it off. rms, 2 May 1997. */
1741/* #include <malloc.h> */
1742 #pragma alloca
1743#define YYSTACK_USE_ALLOCA
1744#else /* not MSDOS, or __TURBOC__, or _AIX */
1745#if 0
1746#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
1747 and on HPUX 10. Eventually we can turn this on. */
1748#define YYSTACK_USE_ALLOCA
1749#define alloca __builtin_alloca
1750#endif /* __hpux */
1751#endif
1752#endif /* not _AIX */
1753#endif /* not MSDOS, or __TURBOC__ */
1754#endif /* not sparc */
1755#endif /* not GNU C */
1756#endif /* alloca not defined */
1757#endif /* YYSTACK_USE_ALLOCA not defined */
1758
1759#ifdef YYSTACK_USE_ALLOCA
1760#define YYSTACK_ALLOC alloca
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001761#else
Chris Lattneredd9b032006-01-23 23:05:42 +00001762#define YYSTACK_ALLOC malloc
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001763#endif
1764
Chris Lattneredd9b032006-01-23 23:05:42 +00001765/* Note: there must be only one dollar sign in this file.
1766 It is replaced by the list of actions, each action
1767 as one case of the switch. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001768
1769#define yyerrok (yyerrstatus = 0)
1770#define yyclearin (yychar = YYEMPTY)
Chris Lattneredd9b032006-01-23 23:05:42 +00001771#define YYEMPTY -2
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001772#define YYEOF 0
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001773#define YYACCEPT goto yyacceptlab
Chris Lattneredd9b032006-01-23 23:05:42 +00001774#define YYABORT goto yyabortlab
1775#define YYERROR goto yyerrlab1
1776/* Like YYERROR except do call yyerror.
1777 This remains here temporarily to ease the
1778 transition to the new meaning of YYERROR, for GCC.
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001779 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001780#define YYFAIL goto yyerrlab
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001781#define YYRECOVERING() (!!yyerrstatus)
Chris Lattneredd9b032006-01-23 23:05:42 +00001782#define YYBACKUP(token, value) \
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001783do \
1784 if (yychar == YYEMPTY && yylen == 1) \
Chris Lattneredd9b032006-01-23 23:05:42 +00001785 { yychar = (token), yylval = (value); \
1786 yychar1 = YYTRANSLATE (yychar); \
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001787 YYPOPSTACK; \
1788 goto yybackup; \
1789 } \
1790 else \
Chris Lattneredd9b032006-01-23 23:05:42 +00001791 { yyerror ("syntax error: cannot back up"); YYERROR; } \
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001792while (0)
1793
1794#define YYTERROR 1
1795#define YYERRCODE 256
1796
Chris Lattneredd9b032006-01-23 23:05:42 +00001797#ifndef YYPURE
1798#define YYLEX yylex()
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001799#endif
1800
Chris Lattneredd9b032006-01-23 23:05:42 +00001801#ifdef YYPURE
1802#ifdef YYLSP_NEEDED
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001803#ifdef YYLEX_PARAM
Chris Lattneredd9b032006-01-23 23:05:42 +00001804#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001805#else
Chris Lattneredd9b032006-01-23 23:05:42 +00001806#define YYLEX yylex(&yylval, &yylloc)
1807#endif
1808#else /* not YYLSP_NEEDED */
1809#ifdef YYLEX_PARAM
1810#define YYLEX yylex(&yylval, YYLEX_PARAM)
1811#else
1812#define YYLEX yylex(&yylval)
1813#endif
1814#endif /* not YYLSP_NEEDED */
Robert Bocchinofdf9e412006-01-17 20:06:25 +00001815#endif
Reid Spencerc8a9faf2006-01-19 01:21:04 +00001816
Chris Lattneredd9b032006-01-23 23:05:42 +00001817/* If nonreentrant, generate the variables here */
Reid Spencerc8a9faf2006-01-19 01:21:04 +00001818
Chris Lattneredd9b032006-01-23 23:05:42 +00001819#ifndef YYPURE
Reid Spencerc8a9faf2006-01-19 01:21:04 +00001820
Chris Lattneredd9b032006-01-23 23:05:42 +00001821int yychar; /* the lookahead symbol */
1822YYSTYPE yylval; /* the semantic value of the */
1823 /* lookahead symbol */
Reid Spencerc8a9faf2006-01-19 01:21:04 +00001824
Chris Lattneredd9b032006-01-23 23:05:42 +00001825#ifdef YYLSP_NEEDED
1826YYLTYPE yylloc; /* location data for the lookahead */
1827 /* symbol */
Robert Bocchinofdf9e412006-01-17 20:06:25 +00001828#endif
Reid Spencerc8a9faf2006-01-19 01:21:04 +00001829
Chris Lattneredd9b032006-01-23 23:05:42 +00001830int yynerrs; /* number of parse errors so far */
1831#endif /* not YYPURE */
Reid Spencerc8a9faf2006-01-19 01:21:04 +00001832
Chris Lattneredd9b032006-01-23 23:05:42 +00001833#if YYDEBUG != 0
1834int yydebug; /* nonzero means print parse trace */
1835/* Since this is uninitialized, it does not stop multiple parsers
1836 from coexisting. */
Nate Begeman848622f2005-11-05 09:21:28 +00001837#endif
Reid Spencerb4f9a6f2006-01-16 21:12:35 +00001838
Chris Lattneredd9b032006-01-23 23:05:42 +00001839/* YYINITDEPTH indicates the initial size of the parser's stacks */
Reid Spencerb4f9a6f2006-01-16 21:12:35 +00001840
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001841#ifndef YYINITDEPTH
Chris Lattneredd9b032006-01-23 23:05:42 +00001842#define YYINITDEPTH 200
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001843#endif
1844
Chris Lattneredd9b032006-01-23 23:05:42 +00001845/* YYMAXDEPTH is the maximum size the stacks can grow to
1846 (effective only if the built-in stack extension method is used). */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001847
Chris Lattneredd9b032006-01-23 23:05:42 +00001848#if YYMAXDEPTH == 0
1849#undef YYMAXDEPTH
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001850#endif
1851
1852#ifndef YYMAXDEPTH
Chris Lattneredd9b032006-01-23 23:05:42 +00001853#define YYMAXDEPTH 10000
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001854#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001855
Chris Lattneredd9b032006-01-23 23:05:42 +00001856/* Define __yy_memcpy. Note that the size argument
1857 should be passed with type unsigned int, because that is what the non-GCC
1858 definitions require. With GCC, __builtin_memcpy takes an arg
1859 of type size_t, but it can handle unsigned int. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001860
Chris Lattneredd9b032006-01-23 23:05:42 +00001861#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
1862#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
1863#else /* not GNU C or C++ */
1864#ifndef __cplusplus
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001865
Chris Lattneredd9b032006-01-23 23:05:42 +00001866/* This is the most reliable way to avoid incompatibilities
1867 in available built-in functions on various systems. */
Reid Spencerc8a9faf2006-01-19 01:21:04 +00001868static void
Chris Lattneredd9b032006-01-23 23:05:42 +00001869__yy_memcpy (to, from, count)
1870 char *to;
1871 char *from;
1872 unsigned int count;
1873{
1874 register char *f = from;
1875 register char *t = to;
1876 register int i = count;
1877
1878 while (i-- > 0)
1879 *t++ = *f++;
1880}
1881
1882#else /* __cplusplus */
1883
1884/* This is the most reliable way to avoid incompatibilities
1885 in available built-in functions on various systems. */
Reid Spencerc8a9faf2006-01-19 01:21:04 +00001886static void
Chris Lattneredd9b032006-01-23 23:05:42 +00001887__yy_memcpy (char *to, char *from, unsigned int count)
1888{
1889 register char *t = to;
1890 register char *f = from;
1891 register int i = count;
1892
1893 while (i-- > 0)
1894 *t++ = *f++;
1895}
1896
Reid Spencerb4f9a6f2006-01-16 21:12:35 +00001897#endif
Reid Spencerc8a9faf2006-01-19 01:21:04 +00001898#endif
Reid Spencerc8a9faf2006-01-19 01:21:04 +00001899
Chris Lattneredd9b032006-01-23 23:05:42 +00001900#line 217 "/usr/share/bison.simple"
Reid Spencerc8a9faf2006-01-19 01:21:04 +00001901
Chris Lattneredd9b032006-01-23 23:05:42 +00001902/* The user can define YYPARSE_PARAM as the name of an argument to be passed
1903 into yyparse. The argument should have type void *.
1904 It should actually point to an object.
1905 Grammar actions can access the variable by casting it
1906 to the proper pointer type. */
Reid Spencerc8a9faf2006-01-19 01:21:04 +00001907
1908#ifdef YYPARSE_PARAM
Chris Lattneredd9b032006-01-23 23:05:42 +00001909#ifdef __cplusplus
1910#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
1911#define YYPARSE_PARAM_DECL
1912#else /* not __cplusplus */
1913#define YYPARSE_PARAM_ARG YYPARSE_PARAM
1914#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
1915#endif /* not __cplusplus */
1916#else /* not YYPARSE_PARAM */
1917#define YYPARSE_PARAM_ARG
1918#define YYPARSE_PARAM_DECL
1919#endif /* not YYPARSE_PARAM */
1920
1921/* Prevent warning if -Wstrict-prototypes. */
1922#ifdef __GNUC__
1923#ifdef YYPARSE_PARAM
1924int yyparse (void *);
1925#else
Reid Spencerc8a9faf2006-01-19 01:21:04 +00001926int yyparse (void);
Reid Spencerc8a9faf2006-01-19 01:21:04 +00001927#endif
Chris Lattneredd9b032006-01-23 23:05:42 +00001928#endif
Reid Spencerc8a9faf2006-01-19 01:21:04 +00001929
Reid Spencerc8a9faf2006-01-19 01:21:04 +00001930int
Chris Lattneredd9b032006-01-23 23:05:42 +00001931yyparse(YYPARSE_PARAM_ARG)
1932 YYPARSE_PARAM_DECL
Reid Spencerc8a9faf2006-01-19 01:21:04 +00001933{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001934 register int yystate;
1935 register int yyn;
Nate Begeman848622f2005-11-05 09:21:28 +00001936 register short *yyssp;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001937 register YYSTYPE *yyvsp;
Chris Lattneredd9b032006-01-23 23:05:42 +00001938 int yyerrstatus; /* number of tokens to shift before error messages enabled */
1939 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001940
Chris Lattneredd9b032006-01-23 23:05:42 +00001941 short yyssa[YYINITDEPTH]; /* the state stack */
1942 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001943
Chris Lattneredd9b032006-01-23 23:05:42 +00001944 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
1945 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001946
Chris Lattneredd9b032006-01-23 23:05:42 +00001947#ifdef YYLSP_NEEDED
1948 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
1949 YYLTYPE *yyls = yylsa;
1950 YYLTYPE *yylsp;
1951
1952#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
1953#else
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001954#define YYPOPSTACK (yyvsp--, yyssp--)
Chris Lattneredd9b032006-01-23 23:05:42 +00001955#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001956
Chris Lattneredd9b032006-01-23 23:05:42 +00001957 int yystacksize = YYINITDEPTH;
1958 int yyfree_stacks = 0;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001959
Chris Lattneredd9b032006-01-23 23:05:42 +00001960#ifdef YYPURE
1961 int yychar;
1962 YYSTYPE yylval;
1963 int yynerrs;
1964#ifdef YYLSP_NEEDED
1965 YYLTYPE yylloc;
1966#endif
1967#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001968
Chris Lattneredd9b032006-01-23 23:05:42 +00001969 YYSTYPE yyval; /* the variable used to return */
1970 /* semantic values from the action */
1971 /* routines */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001972
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001973 int yylen;
1974
Chris Lattneredd9b032006-01-23 23:05:42 +00001975#if YYDEBUG != 0
1976 if (yydebug)
1977 fprintf(stderr, "Starting parse\n");
1978#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001979
1980 yystate = 0;
1981 yyerrstatus = 0;
1982 yynerrs = 0;
1983 yychar = YYEMPTY; /* Cause a token to be read. */
1984
1985 /* Initialize stack pointers.
1986 Waste one element of value and location stack
1987 so that they stay on the same level as the state stack.
1988 The wasted elements are never initialized. */
1989
Chris Lattneredd9b032006-01-23 23:05:42 +00001990 yyssp = yyss - 1;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001991 yyvsp = yyvs;
Chris Lattneredd9b032006-01-23 23:05:42 +00001992#ifdef YYLSP_NEEDED
1993 yylsp = yyls;
1994#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001995
Chris Lattneredd9b032006-01-23 23:05:42 +00001996/* Push a new state, which is found in yystate . */
1997/* In all cases, when you get here, the value and location stacks
1998 have just been pushed. so pushing a state here evens the stacks. */
1999yynewstate:
Jeff Cohen11e26b52005-10-23 04:37:20 +00002000
Chris Lattneredd9b032006-01-23 23:05:42 +00002001 *++yyssp = yystate;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002002
Chris Lattneredd9b032006-01-23 23:05:42 +00002003 if (yyssp >= yyss + yystacksize - 1)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002004 {
Chris Lattneredd9b032006-01-23 23:05:42 +00002005 /* Give user a chance to reallocate the stack */
2006 /* Use copies of these so that the &'s don't force the real ones into memory. */
2007 YYSTYPE *yyvs1 = yyvs;
2008 short *yyss1 = yyss;
2009#ifdef YYLSP_NEEDED
2010 YYLTYPE *yyls1 = yyls;
2011#endif
2012
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002013 /* Get the current used size of the three stacks, in elements. */
Chris Lattneredd9b032006-01-23 23:05:42 +00002014 int size = yyssp - yyss + 1;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002015
2016#ifdef yyoverflow
Chris Lattneredd9b032006-01-23 23:05:42 +00002017 /* Each stack pointer address is followed by the size of
2018 the data in use in that stack, in bytes. */
2019#ifdef YYLSP_NEEDED
2020 /* This used to be a conditional around just the two extra args,
2021 but that might be undefined if yyoverflow is a macro. */
2022 yyoverflow("parser stack overflow",
2023 &yyss1, size * sizeof (*yyssp),
2024 &yyvs1, size * sizeof (*yyvsp),
2025 &yyls1, size * sizeof (*yylsp),
2026 &yystacksize);
2027#else
2028 yyoverflow("parser stack overflow",
2029 &yyss1, size * sizeof (*yyssp),
2030 &yyvs1, size * sizeof (*yyvsp),
2031 &yystacksize);
2032#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002033
Chris Lattneredd9b032006-01-23 23:05:42 +00002034 yyss = yyss1; yyvs = yyvs1;
2035#ifdef YYLSP_NEEDED
2036 yyls = yyls1;
2037#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002038#else /* no yyoverflow */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002039 /* Extend the stack our own way. */
Chris Lattneredd9b032006-01-23 23:05:42 +00002040 if (yystacksize >= YYMAXDEPTH)
2041 {
2042 yyerror("parser stack overflow");
2043 if (yyfree_stacks)
2044 {
2045 free (yyss);
2046 free (yyvs);
2047#ifdef YYLSP_NEEDED
2048 free (yyls);
2049#endif
2050 }
2051 return 2;
2052 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002053 yystacksize *= 2;
Chris Lattneredd9b032006-01-23 23:05:42 +00002054 if (yystacksize > YYMAXDEPTH)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002055 yystacksize = YYMAXDEPTH;
Chris Lattneredd9b032006-01-23 23:05:42 +00002056#ifndef YYSTACK_USE_ALLOCA
2057 yyfree_stacks = 1;
2058#endif
2059 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
2060 __yy_memcpy ((char *)yyss, (char *)yyss1,
2061 size * (unsigned int) sizeof (*yyssp));
2062 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
2063 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
2064 size * (unsigned int) sizeof (*yyvsp));
2065#ifdef YYLSP_NEEDED
2066 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
2067 __yy_memcpy ((char *)yyls, (char *)yyls1,
2068 size * (unsigned int) sizeof (*yylsp));
2069#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002070#endif /* no yyoverflow */
2071
Chris Lattneredd9b032006-01-23 23:05:42 +00002072 yyssp = yyss + size - 1;
2073 yyvsp = yyvs + size - 1;
2074#ifdef YYLSP_NEEDED
2075 yylsp = yyls + size - 1;
2076#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002077
Chris Lattneredd9b032006-01-23 23:05:42 +00002078#if YYDEBUG != 0
2079 if (yydebug)
2080 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2081#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002082
Chris Lattneredd9b032006-01-23 23:05:42 +00002083 if (yyssp >= yyss + yystacksize - 1)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002084 YYABORT;
2085 }
2086
Chris Lattneredd9b032006-01-23 23:05:42 +00002087#if YYDEBUG != 0
2088 if (yydebug)
2089 fprintf(stderr, "Entering state %d\n", yystate);
2090#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002091
2092 goto yybackup;
Chris Lattneredd9b032006-01-23 23:05:42 +00002093 yybackup:
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002094
2095/* Do appropriate processing given the current state. */
2096/* Read a lookahead token if we need one and don't already have one. */
2097/* yyresume: */
2098
2099 /* First try to decide what to do without reference to lookahead token. */
2100
2101 yyn = yypact[yystate];
Chris Lattneredd9b032006-01-23 23:05:42 +00002102 if (yyn == YYFLAG)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002103 goto yydefault;
2104
2105 /* Not known => get a lookahead token if don't already have one. */
2106
Chris Lattneredd9b032006-01-23 23:05:42 +00002107 /* yychar is either YYEMPTY or YYEOF
2108 or a valid token in external form. */
2109
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002110 if (yychar == YYEMPTY)
2111 {
Chris Lattneredd9b032006-01-23 23:05:42 +00002112#if YYDEBUG != 0
2113 if (yydebug)
2114 fprintf(stderr, "Reading a token: ");
2115#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002116 yychar = YYLEX;
2117 }
2118
Chris Lattneredd9b032006-01-23 23:05:42 +00002119 /* Convert token to internal form (in yychar1) for indexing tables with */
2120
2121 if (yychar <= 0) /* This means end of input. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002122 {
Chris Lattneredd9b032006-01-23 23:05:42 +00002123 yychar1 = 0;
2124 yychar = YYEOF; /* Don't call YYLEX any more */
2125
2126#if YYDEBUG != 0
2127 if (yydebug)
2128 fprintf(stderr, "Now at end of input.\n");
2129#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002130 }
2131 else
2132 {
Chris Lattneredd9b032006-01-23 23:05:42 +00002133 yychar1 = YYTRANSLATE(yychar);
2134
2135#if YYDEBUG != 0
2136 if (yydebug)
2137 {
2138 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2139 /* Give the individual parser a way to print the precise meaning
2140 of a token, for further debugging info. */
2141#ifdef YYPRINT
2142 YYPRINT (stderr, yychar, yylval);
2143#endif
2144 fprintf (stderr, ")\n");
2145 }
2146#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002147 }
2148
Chris Lattneredd9b032006-01-23 23:05:42 +00002149 yyn += yychar1;
2150 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002151 goto yydefault;
Chris Lattneredd9b032006-01-23 23:05:42 +00002152
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002153 yyn = yytable[yyn];
Chris Lattneredd9b032006-01-23 23:05:42 +00002154
2155 /* yyn is what to do for this token type in this state.
2156 Negative => reduce, -yyn is rule number.
2157 Positive => shift, yyn is new state.
2158 New state is final state => don't bother to shift,
2159 just return success.
2160 0, or most negative number => error. */
2161
2162 if (yyn < 0)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002163 {
Chris Lattneredd9b032006-01-23 23:05:42 +00002164 if (yyn == YYFLAG)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002165 goto yyerrlab;
2166 yyn = -yyn;
2167 goto yyreduce;
2168 }
Chris Lattneredd9b032006-01-23 23:05:42 +00002169 else if (yyn == 0)
2170 goto yyerrlab;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002171
2172 if (yyn == YYFINAL)
2173 YYACCEPT;
2174
2175 /* Shift the lookahead token. */
Chris Lattneredd9b032006-01-23 23:05:42 +00002176
2177#if YYDEBUG != 0
2178 if (yydebug)
2179 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2180#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002181
2182 /* Discard the token being shifted unless it is eof. */
2183 if (yychar != YYEOF)
2184 yychar = YYEMPTY;
2185
2186 *++yyvsp = yylval;
Chris Lattneredd9b032006-01-23 23:05:42 +00002187#ifdef YYLSP_NEEDED
2188 *++yylsp = yylloc;
2189#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002190
Chris Lattneredd9b032006-01-23 23:05:42 +00002191 /* count tokens shifted since error; after three, turn off error status. */
2192 if (yyerrstatus) yyerrstatus--;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002193
2194 yystate = yyn;
2195 goto yynewstate;
2196
Chris Lattneredd9b032006-01-23 23:05:42 +00002197/* Do the default action for the current state. */
Reid Spencerc8a9faf2006-01-19 01:21:04 +00002198yydefault:
Chris Lattneredd9b032006-01-23 23:05:42 +00002199
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002200 yyn = yydefact[yystate];
2201 if (yyn == 0)
2202 goto yyerrlab;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002203
Chris Lattneredd9b032006-01-23 23:05:42 +00002204/* Do a reduction. yyn is the number of a rule to reduce with. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002205yyreduce:
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002206 yylen = yyr2[yyn];
Chris Lattneredd9b032006-01-23 23:05:42 +00002207 if (yylen > 0)
2208 yyval = yyvsp[1-yylen]; /* implement default value of the action */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002209
Chris Lattneredd9b032006-01-23 23:05:42 +00002210#if YYDEBUG != 0
2211 if (yydebug)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002212 {
Chris Lattneredd9b032006-01-23 23:05:42 +00002213 int i;
2214
2215 fprintf (stderr, "Reducing via rule %d (line %d), ",
2216 yyn, yyrline[yyn]);
2217
2218 /* Print the symbols being reduced, and their result. */
2219 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2220 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2221 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2222 }
2223#endif
2224
2225
2226 switch (yyn) {
2227
2228case 2:
2229#line 998 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2230{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002231 if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX) // Outside of my range!
2232 ThrowException("Value too large for type!");
2233 yyval.SIntVal = (int32_t)yyvsp[0].UIntVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002234;
2235 break;}
2236case 4:
2237#line 1006 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2238{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002239 if (yyvsp[0].UInt64Val > (uint64_t)INT64_MAX) // Outside of my range!
2240 ThrowException("Value too large for type!");
2241 yyval.SInt64Val = (int64_t)yyvsp[0].UInt64Val;
Chris Lattneredd9b032006-01-23 23:05:42 +00002242;
2243 break;}
2244case 33:
2245#line 1029 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2246{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002247 yyval.StrVal = yyvsp[-1].StrVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002248 ;
2249 break;}
2250case 34:
2251#line 1032 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2252{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002253 yyval.StrVal = 0;
Chris Lattneredd9b032006-01-23 23:05:42 +00002254 ;
2255 break;}
2256case 35:
2257#line 1036 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2258{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2259 break;}
2260case 36:
2261#line 1037 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2262{ yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2263 break;}
2264case 37:
2265#line 1038 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2266{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2267 break;}
2268case 38:
2269#line 1039 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2270{ yyval.Linkage = GlobalValue::AppendingLinkage; ;
2271 break;}
2272case 39:
2273#line 1040 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2274{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2275 break;}
2276case 40:
2277#line 1042 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2278{ yyval.UIntVal = CallingConv::C; ;
2279 break;}
2280case 41:
2281#line 1043 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2282{ yyval.UIntVal = CallingConv::C; ;
2283 break;}
2284case 42:
2285#line 1044 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2286{ yyval.UIntVal = CallingConv::Fast; ;
2287 break;}
2288case 43:
2289#line 1045 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2290{ yyval.UIntVal = CallingConv::Cold; ;
2291 break;}
2292case 44:
2293#line 1046 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2294{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002295 if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
2296 ThrowException("Calling conv too large!");
2297 yyval.UIntVal = yyvsp[0].UInt64Val;
Chris Lattneredd9b032006-01-23 23:05:42 +00002298 ;
2299 break;}
2300case 45:
2301#line 1054 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2302{ yyval.UIntVal = 0; ;
2303 break;}
2304case 46:
2305#line 1055 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2306{
Chris Lattner11ca4d62005-11-12 18:22:38 +00002307 yyval.UIntVal = yyvsp[0].UInt64Val;
2308 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
2309 ThrowException("Alignment must be a power of two!");
Chris Lattneredd9b032006-01-23 23:05:42 +00002310;
2311 break;}
2312case 47:
2313#line 1060 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2314{ yyval.UIntVal = 0; ;
2315 break;}
2316case 48:
2317#line 1061 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2318{
Chris Lattner11ca4d62005-11-12 18:22:38 +00002319 yyval.UIntVal = yyvsp[0].UInt64Val;
2320 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
2321 ThrowException("Alignment must be a power of two!");
Chris Lattneredd9b032006-01-23 23:05:42 +00002322;
2323 break;}
2324case 49:
2325#line 1068 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2326{
Chris Lattnera0c20b42005-11-12 00:11:49 +00002327 for (unsigned i = 0, e = strlen(yyvsp[0].StrVal); i != e; ++i)
2328 if (yyvsp[0].StrVal[i] == '"' || yyvsp[0].StrVal[i] == '\\')
2329 ThrowException("Invalid character in section name!");
2330 yyval.StrVal = yyvsp[0].StrVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002331;
2332 break;}
2333case 50:
2334#line 1075 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2335{ yyval.StrVal = 0; ;
2336 break;}
2337case 51:
2338#line 1076 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2339{ yyval.StrVal = yyvsp[0].StrVal; ;
2340 break;}
2341case 52:
2342#line 1081 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2343{;
2344 break;}
2345case 53:
2346#line 1082 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2347{;
2348 break;}
2349case 54:
2350#line 1083 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2351{
Chris Lattner11ca4d62005-11-12 18:22:38 +00002352 CurGV->setSection(yyvsp[0].StrVal);
2353 free(yyvsp[0].StrVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00002354 ;
2355 break;}
2356case 55:
2357#line 1087 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2358{
Chris Lattnera054d122005-12-21 17:53:23 +00002359 if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val))
2360 ThrowException("Alignment must be a power of two!");
Chris Lattner11ca4d62005-11-12 18:22:38 +00002361 CurGV->setAlignment(yyvsp[0].UInt64Val);
Chris Lattneredd9b032006-01-23 23:05:42 +00002362 ;
2363 break;}
2364case 57:
2365#line 1100 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2366{ yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2367 break;}
2368case 59:
2369#line 1101 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2370{ yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2371 break;}
2372case 60:
2373#line 1103 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2374{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002375 if (!UpRefs.empty())
2376 ThrowException("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
2377 yyval.TypeVal = yyvsp[0].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002378 ;
2379 break;}
2380case 74:
2381#line 1114 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2382{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002383 yyval.TypeVal = new PATypeHolder(OpaqueType::get());
Chris Lattneredd9b032006-01-23 23:05:42 +00002384 ;
2385 break;}
2386case 75:
2387#line 1117 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2388{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002389 yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
Chris Lattneredd9b032006-01-23 23:05:42 +00002390 ;
2391 break;}
2392case 76:
2393#line 1120 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2394{ // Named types are also simple types...
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002395 yyval.TypeVal = new PATypeHolder(getTypeVal(yyvsp[0].ValIDVal));
Chris Lattneredd9b032006-01-23 23:05:42 +00002396;
2397 break;}
2398case 77:
2399#line 1126 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2400{ // Type UpReference
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002401 if (yyvsp[0].UInt64Val > (uint64_t)~0U) ThrowException("Value out of range!");
2402 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
2403 UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector...
2404 yyval.TypeVal = new PATypeHolder(OT);
2405 UR_OUT("New Upreference!\n");
Chris Lattneredd9b032006-01-23 23:05:42 +00002406 ;
2407 break;}
2408case 78:
2409#line 1133 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2410{ // Function derived type?
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002411 std::vector<const Type*> Params;
2412 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2413 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2414 Params.push_back(*I);
2415 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
2416 if (isVarArg) Params.pop_back();
2417
2418 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FunctionType::get(*yyvsp[-3].TypeVal,Params,isVarArg)));
2419 delete yyvsp[-1].TypeList; // Delete the argument list
2420 delete yyvsp[-3].TypeVal; // Delete the return type handle
Chris Lattneredd9b032006-01-23 23:05:42 +00002421 ;
2422 break;}
2423case 79:
2424#line 1145 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2425{ // Sized array type?
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002426 yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2427 delete yyvsp[-1].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002428 ;
2429 break;}
2430case 80:
2431#line 1149 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2432{ // Packed array type?
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002433 const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
Chris Lattner625b9c82005-11-10 01:42:43 +00002434 if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002435 ThrowException("Unsigned result not equal to signed result");
Chris Lattner625b9c82005-11-10 01:42:43 +00002436 if (!ElemTy->isPrimitiveType())
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002437 ThrowException("Elemental type of a PackedType must be primitive");
Chris Lattner625b9c82005-11-10 01:42:43 +00002438 if (!isPowerOf2_32(yyvsp[-3].UInt64Val))
2439 ThrowException("Vector length should be a power of 2!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002440 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PackedType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2441 delete yyvsp[-1].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002442 ;
2443 break;}
2444case 81:
2445#line 1160 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2446{ // Structure type?
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002447 std::vector<const Type*> Elements;
2448 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2449 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2450 Elements.push_back(*I);
2451
2452 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
2453 delete yyvsp[-1].TypeList;
Chris Lattneredd9b032006-01-23 23:05:42 +00002454 ;
2455 break;}
2456case 82:
2457#line 1169 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2458{ // Empty structure type?
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002459 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Chris Lattneredd9b032006-01-23 23:05:42 +00002460 ;
2461 break;}
2462case 83:
2463#line 1172 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2464{ // Pointer type?
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002465 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal)));
2466 delete yyvsp[-1].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002467 ;
2468 break;}
2469case 84:
2470#line 1180 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2471{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002472 yyval.TypeList = new std::list<PATypeHolder>();
2473 yyval.TypeList->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002474 ;
2475 break;}
2476case 85:
2477#line 1184 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2478{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002479 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002480 ;
2481 break;}
2482case 87:
2483#line 1190 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2484{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002485 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(Type::VoidTy);
Chris Lattneredd9b032006-01-23 23:05:42 +00002486 ;
2487 break;}
2488case 88:
2489#line 1193 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2490{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002491 (yyval.TypeList = new std::list<PATypeHolder>())->push_back(Type::VoidTy);
Chris Lattneredd9b032006-01-23 23:05:42 +00002492 ;
2493 break;}
2494case 89:
2495#line 1196 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2496{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002497 yyval.TypeList = new std::list<PATypeHolder>();
Chris Lattneredd9b032006-01-23 23:05:42 +00002498 ;
2499 break;}
2500case 90:
2501#line 1206 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2502{ // Nonempty unsized arr
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002503 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
2504 if (ATy == 0)
2505 ThrowException("Cannot make array constant with type: '" +
2506 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2507 const Type *ETy = ATy->getElementType();
2508 int NumElements = ATy->getNumElements();
2509
2510 // Verify that we have the correct size...
2511 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2512 ThrowException("Type mismatch: constant sized array initialized with " +
2513 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
2514 itostr(NumElements) + "!");
2515
2516 // Verify all elements are correct type!
2517 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2518 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2519 ThrowException("Element #" + utostr(i) + " is not of type '" +
2520 ETy->getDescription() +"' as required!\nIt is of type '"+
2521 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2522 }
2523
2524 yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
2525 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Chris Lattneredd9b032006-01-23 23:05:42 +00002526 ;
2527 break;}
2528case 91:
2529#line 1231 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2530{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002531 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2532 if (ATy == 0)
2533 ThrowException("Cannot make array constant with type: '" +
2534 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2535
2536 int NumElements = ATy->getNumElements();
2537 if (NumElements != -1 && NumElements != 0)
2538 ThrowException("Type mismatch: constant sized array initialized with 0"
2539 " arguments, but has size of " + itostr(NumElements) +"!");
2540 yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
2541 delete yyvsp[-2].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002542 ;
2543 break;}
2544case 92:
2545#line 1244 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2546{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002547 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2548 if (ATy == 0)
2549 ThrowException("Cannot make array constant with type: '" +
2550 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2551
2552 int NumElements = ATy->getNumElements();
2553 const Type *ETy = ATy->getElementType();
2554 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
2555 if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal))
2556 ThrowException("Can't build string constant of size " +
2557 itostr((int)(EndStr-yyvsp[0].StrVal)) +
2558 " when array has size " + itostr(NumElements) + "!");
2559 std::vector<Constant*> Vals;
2560 if (ETy == Type::SByteTy) {
Chris Lattner8ebd2162006-01-24 04:14:29 +00002561 for (signed char *C = (signed char *)yyvsp[0].StrVal; C != (signed char *)EndStr; ++C)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002562 Vals.push_back(ConstantSInt::get(ETy, *C));
2563 } else if (ETy == Type::UByteTy) {
Chris Lattner8ebd2162006-01-24 04:14:29 +00002564 for (unsigned char *C = (unsigned char *)yyvsp[0].StrVal;
2565 C != (unsigned char*)EndStr; ++C)
2566 Vals.push_back(ConstantUInt::get(ETy, *C));
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002567 } else {
2568 free(yyvsp[0].StrVal);
2569 ThrowException("Cannot build string arrays of non byte sized elements!");
2570 }
2571 free(yyvsp[0].StrVal);
2572 yyval.ConstVal = ConstantArray::get(ATy, Vals);
2573 delete yyvsp[-2].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002574 ;
2575 break;}
2576case 93:
Chris Lattner8ebd2162006-01-24 04:14:29 +00002577#line 1273 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002578{ // Nonempty unsized arr
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002579 const PackedType *PTy = dyn_cast<PackedType>(yyvsp[-3].TypeVal->get());
2580 if (PTy == 0)
2581 ThrowException("Cannot make packed constant with type: '" +
2582 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2583 const Type *ETy = PTy->getElementType();
2584 int NumElements = PTy->getNumElements();
2585
2586 // Verify that we have the correct size...
2587 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2588 ThrowException("Type mismatch: constant sized packed initialized with " +
2589 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
2590 itostr(NumElements) + "!");
2591
2592 // Verify all elements are correct type!
2593 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2594 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2595 ThrowException("Element #" + utostr(i) + " is not of type '" +
2596 ETy->getDescription() +"' as required!\nIt is of type '"+
2597 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2598 }
2599
2600 yyval.ConstVal = ConstantPacked::get(PTy, *yyvsp[-1].ConstVector);
2601 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Chris Lattneredd9b032006-01-23 23:05:42 +00002602 ;
2603 break;}
2604case 94:
Chris Lattner8ebd2162006-01-24 04:14:29 +00002605#line 1298 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002606{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002607 const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
2608 if (STy == 0)
2609 ThrowException("Cannot make struct constant with type: '" +
2610 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2611
2612 if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
2613 ThrowException("Illegal number of initializers for structure type!");
2614
2615 // Check to ensure that constants are compatible with the type initializer!
2616 for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
2617 if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
2618 ThrowException("Expected type '" +
2619 STy->getElementType(i)->getDescription() +
2620 "' for element #" + utostr(i) +
2621 " of structure initializer!");
2622
2623 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
2624 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Chris Lattneredd9b032006-01-23 23:05:42 +00002625 ;
2626 break;}
2627case 95:
Chris Lattner8ebd2162006-01-24 04:14:29 +00002628#line 1318 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002629{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002630 const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
2631 if (STy == 0)
2632 ThrowException("Cannot make struct constant with type: '" +
2633 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2634
2635 if (STy->getNumContainedTypes() != 0)
2636 ThrowException("Illegal number of initializers for structure type!");
2637
2638 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
2639 delete yyvsp[-2].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002640 ;
2641 break;}
2642case 96:
Chris Lattner8ebd2162006-01-24 04:14:29 +00002643#line 1330 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002644{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002645 const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
2646 if (PTy == 0)
2647 ThrowException("Cannot make null pointer constant with type: '" +
2648 (*yyvsp[-1].TypeVal)->getDescription() + "'!");
2649
2650 yyval.ConstVal = ConstantPointerNull::get(PTy);
2651 delete yyvsp[-1].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002652 ;
2653 break;}
2654case 97:
Chris Lattner8ebd2162006-01-24 04:14:29 +00002655#line 1339 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002656{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002657 yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
2658 delete yyvsp[-1].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002659 ;
2660 break;}
2661case 98:
Chris Lattner8ebd2162006-01-24 04:14:29 +00002662#line 1343 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002663{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002664 const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
2665 if (Ty == 0)
2666 ThrowException("Global const reference must be a pointer type!");
2667
2668 // ConstExprs can exist in the body of a function, thus creating
2669 // GlobalValues whenever they refer to a variable. Because we are in
2670 // the context of a function, getValNonImprovising will search the functions
2671 // symbol table instead of the module symbol table for the global symbol,
2672 // which throws things all off. To get around this, we just tell
2673 // getValNonImprovising that we are at global scope here.
2674 //
2675 Function *SavedCurFn = CurFun.CurrentFunction;
2676 CurFun.CurrentFunction = 0;
2677
2678 Value *V = getValNonImprovising(Ty, yyvsp[0].ValIDVal);
2679
2680 CurFun.CurrentFunction = SavedCurFn;
2681
2682 // If this is an initializer for a constant pointer, which is referencing a
2683 // (currently) undefined variable, create a stub now that shall be replaced
2684 // in the future with the right type of variable.
2685 //
2686 if (V == 0) {
2687 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
2688 const PointerType *PT = cast<PointerType>(Ty);
2689
2690 // First check to see if the forward references value is already created!
2691 PerModuleInfo::GlobalRefsType::iterator I =
2692 CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
2693
2694 if (I != CurModule.GlobalRefs.end()) {
2695 V = I->second; // Placeholder already exists, use it...
2696 yyvsp[0].ValIDVal.destroy();
2697 } else {
2698 std::string Name;
2699 if (yyvsp[0].ValIDVal.Type == ValID::NameVal) Name = yyvsp[0].ValIDVal.Name;
2700
2701 // Create the forward referenced global.
2702 GlobalValue *GV;
2703 if (const FunctionType *FTy =
2704 dyn_cast<FunctionType>(PT->getElementType())) {
2705 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
2706 CurModule.CurrentModule);
2707 } else {
2708 GV = new GlobalVariable(PT->getElementType(), false,
2709 GlobalValue::ExternalLinkage, 0,
2710 Name, CurModule.CurrentModule);
2711 }
2712
2713 // Keep track of the fact that we have a forward ref to recycle it
2714 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
2715 V = GV;
2716 }
2717 }
2718
2719 yyval.ConstVal = cast<GlobalValue>(V);
2720 delete yyvsp[-1].TypeVal; // Free the type handle
Chris Lattneredd9b032006-01-23 23:05:42 +00002721 ;
2722 break;}
2723case 99:
Chris Lattner8ebd2162006-01-24 04:14:29 +00002724#line 1402 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002725{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002726 if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
2727 ThrowException("Mismatched types for constant expression!");
2728 yyval.ConstVal = yyvsp[0].ConstVal;
2729 delete yyvsp[-1].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002730 ;
2731 break;}
2732case 100:
Chris Lattner8ebd2162006-01-24 04:14:29 +00002733#line 1408 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002734{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002735 const Type *Ty = yyvsp[-1].TypeVal->get();
2736 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
2737 ThrowException("Cannot create a null initialized value of this type!");
2738 yyval.ConstVal = Constant::getNullValue(Ty);
2739 delete yyvsp[-1].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002740 ;
2741 break;}
2742case 101:
Chris Lattner8ebd2162006-01-24 04:14:29 +00002743#line 1416 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002744{ // integral constants
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002745 if (!ConstantSInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
2746 ThrowException("Constant value doesn't fit in type!");
2747 yyval.ConstVal = ConstantSInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val);
Chris Lattneredd9b032006-01-23 23:05:42 +00002748 ;
2749 break;}
2750case 102:
Chris Lattner8ebd2162006-01-24 04:14:29 +00002751#line 1421 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002752{ // integral constants
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002753 if (!ConstantUInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
2754 ThrowException("Constant value doesn't fit in type!");
2755 yyval.ConstVal = ConstantUInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val);
Chris Lattneredd9b032006-01-23 23:05:42 +00002756 ;
2757 break;}
2758case 103:
Chris Lattner8ebd2162006-01-24 04:14:29 +00002759#line 1426 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002760{ // Boolean constants
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002761 yyval.ConstVal = ConstantBool::True;
Chris Lattneredd9b032006-01-23 23:05:42 +00002762 ;
2763 break;}
2764case 104:
Chris Lattner8ebd2162006-01-24 04:14:29 +00002765#line 1429 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002766{ // Boolean constants
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002767 yyval.ConstVal = ConstantBool::False;
Chris Lattneredd9b032006-01-23 23:05:42 +00002768 ;
2769 break;}
2770case 105:
Chris Lattner8ebd2162006-01-24 04:14:29 +00002771#line 1432 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002772{ // Float & Double constants
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002773 if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal))
2774 ThrowException("Floating point constant invalid for type!!");
2775 yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00002776 ;
2777 break;}
2778case 106:
Chris Lattner8ebd2162006-01-24 04:14:29 +00002779#line 1439 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002780{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002781 if (!yyvsp[-3].ConstVal->getType()->isFirstClassType())
2782 ThrowException("cast constant expression from a non-primitive type: '" +
2783 yyvsp[-3].ConstVal->getType()->getDescription() + "'!");
2784 if (!yyvsp[-1].TypeVal->get()->isFirstClassType())
2785 ThrowException("cast constant expression to a non-primitive type: '" +
2786 yyvsp[-1].TypeVal->get()->getDescription() + "'!");
2787 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-3].ConstVal, yyvsp[-1].TypeVal->get());
2788 delete yyvsp[-1].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002789 ;
2790 break;}
2791case 107:
Chris Lattner8ebd2162006-01-24 04:14:29 +00002792#line 1449 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002793{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002794 if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
2795 ThrowException("GetElementPtr requires a pointer operand!");
2796
2797 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
2798 // indices to uint struct indices for compatibility.
2799 generic_gep_type_iterator<std::vector<Value*>::iterator>
2800 GTI = gep_type_begin(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end()),
2801 GTE = gep_type_end(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end());
2802 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
2803 if (isa<StructType>(*GTI)) // Only change struct indices
2804 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[-1].ValueList)[i]))
2805 if (CUI->getType() == Type::UByteTy)
2806 (*yyvsp[-1].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
2807
2808 const Type *IdxTy =
2809 GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), *yyvsp[-1].ValueList, true);
2810 if (!IdxTy)
2811 ThrowException("Index list invalid for constant getelementptr!");
2812
2813 std::vector<Constant*> IdxVec;
2814 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
2815 if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
2816 IdxVec.push_back(C);
2817 else
2818 ThrowException("Indices to constant getelementptr must be constants!");
2819
2820 delete yyvsp[-1].ValueList;
2821
2822 yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, IdxVec);
Chris Lattneredd9b032006-01-23 23:05:42 +00002823 ;
2824 break;}
2825case 108:
Chris Lattner8ebd2162006-01-24 04:14:29 +00002826#line 1480 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002827{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002828 if (yyvsp[-5].ConstVal->getType() != Type::BoolTy)
2829 ThrowException("Select condition must be of boolean type!");
2830 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2831 ThrowException("Select operand types must match!");
2832 yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00002833 ;
2834 break;}
2835case 109:
Chris Lattner8ebd2162006-01-24 04:14:29 +00002836#line 1487 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002837{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002838 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2839 ThrowException("Binary operator types must match!");
2840 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
2841 // To retain backward compatibility with these early compilers, we emit a
2842 // cast to the appropriate integer type automatically if we are in the
2843 // broken case. See PR424 for more information.
2844 if (!isa<PointerType>(yyvsp[-3].ConstVal->getType())) {
2845 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2846 } else {
2847 const Type *IntPtrTy = 0;
2848 switch (CurModule.CurrentModule->getPointerSize()) {
2849 case Module::Pointer32: IntPtrTy = Type::IntTy; break;
2850 case Module::Pointer64: IntPtrTy = Type::LongTy; break;
2851 default: ThrowException("invalid pointer binary constant expr!");
2852 }
2853 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, ConstantExpr::getCast(yyvsp[-3].ConstVal, IntPtrTy),
2854 ConstantExpr::getCast(yyvsp[-1].ConstVal, IntPtrTy));
2855 yyval.ConstVal = ConstantExpr::getCast(yyval.ConstVal, yyvsp[-3].ConstVal->getType());
2856 }
Chris Lattneredd9b032006-01-23 23:05:42 +00002857 ;
2858 break;}
2859case 110:
Chris Lattner8ebd2162006-01-24 04:14:29 +00002860#line 1508 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002861{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002862 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2863 ThrowException("Logical operator types must match!");
Chris Lattner15f5a182005-12-21 18:31:50 +00002864 if (!yyvsp[-3].ConstVal->getType()->isIntegral()) {
2865 if (!isa<PackedType>(yyvsp[-3].ConstVal->getType()) ||
2866 !cast<PackedType>(yyvsp[-3].ConstVal->getType())->getElementType()->isIntegral())
2867 ThrowException("Logical operator requires integral operands!");
2868 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002869 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00002870 ;
2871 break;}
2872case 111:
Chris Lattner8ebd2162006-01-24 04:14:29 +00002873#line 1518 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002874{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002875 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2876 ThrowException("setcc operand types must match!");
2877 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00002878 ;
2879 break;}
2880case 112:
Chris Lattner8ebd2162006-01-24 04:14:29 +00002881#line 1523 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002882{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002883 if (yyvsp[-1].ConstVal->getType() != Type::UByteTy)
2884 ThrowException("Shift count for shift constant must be unsigned byte!");
2885 if (!yyvsp[-3].ConstVal->getType()->isInteger())
2886 ThrowException("Shift constant expression requires integer operand!");
2887 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].OtherOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00002888 ;
2889 break;}
2890case 113:
Chris Lattner8ebd2162006-01-24 04:14:29 +00002891#line 1530 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002892{
Robert Bocchinoaa1cf542006-01-10 19:04:32 +00002893 if (!isa<PackedType>(yyvsp[-3].ConstVal->getType()))
2894 ThrowException("First operand of extractelement must be "
2895 "packed type!");
2896 if (yyvsp[-1].ConstVal->getType() != Type::UIntTy)
2897 ThrowException("Second operand of extractelement must be uint!");
2898 yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00002899 ;
2900 break;}
2901case 114:
Chris Lattner8ebd2162006-01-24 04:14:29 +00002902#line 1540 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002903{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002904 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00002905 ;
2906 break;}
2907case 115:
Chris Lattner8ebd2162006-01-24 04:14:29 +00002908#line 1543 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002909{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002910 yyval.ConstVector = new std::vector<Constant*>();
2911 yyval.ConstVector->push_back(yyvsp[0].ConstVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00002912 ;
2913 break;}
2914case 116:
Chris Lattner8ebd2162006-01-24 04:14:29 +00002915#line 1550 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002916{ yyval.BoolVal = false; ;
2917 break;}
2918case 117:
Chris Lattner8ebd2162006-01-24 04:14:29 +00002919#line 1550 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002920{ yyval.BoolVal = true; ;
2921 break;}
2922case 118:
Chris Lattner8ebd2162006-01-24 04:14:29 +00002923#line 1560 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002924{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002925 yyval.ModuleVal = ParserResult = yyvsp[0].ModuleVal;
2926 CurModule.ModuleDone();
Chris Lattneredd9b032006-01-23 23:05:42 +00002927;
2928 break;}
2929case 119:
Chris Lattner8ebd2162006-01-24 04:14:29 +00002930#line 1567 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002931{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002932 yyval.ModuleVal = yyvsp[-1].ModuleVal;
2933 CurFun.FunctionDone();
Chris Lattneredd9b032006-01-23 23:05:42 +00002934 ;
2935 break;}
2936case 120:
Chris Lattner8ebd2162006-01-24 04:14:29 +00002937#line 1571 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002938{
Chris Lattner15f5a182005-12-21 18:31:50 +00002939 yyval.ModuleVal = yyvsp[-1].ModuleVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002940 ;
2941 break;}
2942case 121:
Chris Lattner8ebd2162006-01-24 04:14:29 +00002943#line 1574 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002944{
Chris Lattner8ebd2162006-01-24 04:14:29 +00002945 yyval.ModuleVal = yyvsp[-3].ModuleVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002946 ;
2947 break;}
2948case 122:
Chris Lattner8ebd2162006-01-24 04:14:29 +00002949#line 1577 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002950{
Robert Bocchinoaa1cf542006-01-10 19:04:32 +00002951 yyval.ModuleVal = yyvsp[-1].ModuleVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002952 ;
2953 break;}
2954case 123:
Chris Lattner8ebd2162006-01-24 04:14:29 +00002955#line 1580 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002956{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002957 yyval.ModuleVal = CurModule.CurrentModule;
2958 // Emit an error if there are any unresolved types left.
2959 if (!CurModule.LateResolveTypes.empty()) {
2960 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
2961 if (DID.Type == ValID::NameVal)
2962 ThrowException("Reference to an undefined type: '"+DID.getName() + "'");
2963 else
2964 ThrowException("Reference to an undefined type: #" + itostr(DID.Num));
2965 }
Chris Lattneredd9b032006-01-23 23:05:42 +00002966 ;
2967 break;}
2968case 124:
Chris Lattner8ebd2162006-01-24 04:14:29 +00002969#line 1593 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002970{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002971 // Eagerly resolve types. This is not an optimization, this is a
2972 // requirement that is due to the fact that we could have this:
2973 //
2974 // %list = type { %list * }
2975 // %list = type { %list * } ; repeated type decl
2976 //
2977 // If types are not resolved eagerly, then the two types will not be
2978 // determined to be the same type!
2979 //
2980 ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
2981
2982 if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
2983 // If this is a named type that is not a redefinition, add it to the slot
2984 // table.
2985 CurModule.Types.push_back(*yyvsp[0].TypeVal);
2986 }
2987
2988 delete yyvsp[0].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002989 ;
2990 break;}
2991case 125:
Chris Lattner8ebd2162006-01-24 04:14:29 +00002992#line 1613 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002993{ // Function prototypes can be in const pool
2994 ;
2995 break;}
2996case 126:
Chris Lattner8ebd2162006-01-24 04:14:29 +00002997#line 1615 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2998{ // Asm blocks can be in the const pool
Chris Lattneredd9b032006-01-23 23:05:42 +00002999 ;
3000 break;}
3001case 127:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003002#line 1617 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003003{
Chris Lattner11ca4d62005-11-12 18:22:38 +00003004 if (yyvsp[0].ConstVal == 0) ThrowException("Global value initializer is not a constant!");
3005 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, yyvsp[-2].Linkage, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003006 ;
3007 break;}
3008case 128:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003009#line 1620 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003010{
Chris Lattner11ca4d62005-11-12 18:22:38 +00003011 CurGV = 0;
Chris Lattneredd9b032006-01-23 23:05:42 +00003012 ;
3013 break;}
3014case 129:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003015#line 1623 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003016{
Chris Lattner11ca4d62005-11-12 18:22:38 +00003017 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalLinkage,
3018 yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0);
3019 delete yyvsp[0].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003020 ;
3021 break;}
3022case 130:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003023#line 1627 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003024{
Chris Lattner11ca4d62005-11-12 18:22:38 +00003025 CurGV = 0;
Chris Lattneredd9b032006-01-23 23:05:42 +00003026 ;
3027 break;}
3028case 131:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003029#line 1630 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003030{
3031 ;
3032 break;}
3033case 132:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003034#line 1632 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003035{
3036 ;
3037 break;}
3038case 133:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003039#line 1634 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003040{
3041 ;
3042 break;}
3043case 134:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003044#line 1638 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003045{
Chris Lattner8ebd2162006-01-24 04:14:29 +00003046 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
3047 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
3048 std::string NewAsm(yyvsp[0].StrVal, EndStr);
Chris Lattneredd9b032006-01-23 23:05:42 +00003049 free(yyvsp[0].StrVal);
Chris Lattner8ebd2162006-01-24 04:14:29 +00003050
3051 if (AsmSoFar.empty())
3052 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
3053 else
3054 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Chris Lattneredd9b032006-01-23 23:05:42 +00003055;
3056 break;}
3057case 135:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003058#line 1650 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003059{ yyval.Endianness = Module::BigEndian; ;
3060 break;}
3061case 136:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003062#line 1651 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003063{ yyval.Endianness = Module::LittleEndian; ;
3064 break;}
3065case 137:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003066#line 1653 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003067{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003068 CurModule.CurrentModule->setEndianness(yyvsp[0].Endianness);
Chris Lattneredd9b032006-01-23 23:05:42 +00003069 ;
3070 break;}
3071case 138:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003072#line 1656 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003073{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003074 if (yyvsp[0].UInt64Val == 32)
3075 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
3076 else if (yyvsp[0].UInt64Val == 64)
3077 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
3078 else
3079 ThrowException("Invalid pointer size: '" + utostr(yyvsp[0].UInt64Val) + "'!");
Chris Lattneredd9b032006-01-23 23:05:42 +00003080 ;
3081 break;}
3082case 139:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003083#line 1664 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003084{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003085 CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal);
3086 free(yyvsp[0].StrVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003087 ;
3088 break;}
3089case 141:
Chris Lattneredd9b032006-01-23 23:05:42 +00003090#line 1671 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3091{
Robert Bocchinoaa1cf542006-01-10 19:04:32 +00003092 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3093 free(yyvsp[0].StrVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003094 ;
3095 break;}
Chris Lattner8ebd2162006-01-24 04:14:29 +00003096case 142:
Chris Lattneredd9b032006-01-23 23:05:42 +00003097#line 1675 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3098{
Chris Lattner8ebd2162006-01-24 04:14:29 +00003099 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3100 free(yyvsp[0].StrVal);
3101 ;
3102 break;}
3103case 143:
3104#line 1679 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3105{
Chris Lattneredd9b032006-01-23 23:05:42 +00003106 ;
3107 break;}
3108case 147:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003109#line 1688 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003110{ yyval.StrVal = 0; ;
3111 break;}
3112case 148:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003113#line 1690 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003114{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003115 if (*yyvsp[-1].TypeVal == Type::VoidTy)
3116 ThrowException("void typed arguments are invalid!");
3117 yyval.ArgVal = new std::pair<PATypeHolder*, char*>(yyvsp[-1].TypeVal, yyvsp[0].StrVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003118;
3119 break;}
3120case 149:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003121#line 1696 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003122{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003123 yyval.ArgList = yyvsp[-2].ArgList;
3124 yyvsp[-2].ArgList->push_back(*yyvsp[0].ArgVal);
3125 delete yyvsp[0].ArgVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003126 ;
3127 break;}
3128case 150:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003129#line 1701 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003130{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003131 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
3132 yyval.ArgList->push_back(*yyvsp[0].ArgVal);
3133 delete yyvsp[0].ArgVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003134 ;
3135 break;}
3136case 151:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003137#line 1707 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003138{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003139 yyval.ArgList = yyvsp[0].ArgList;
Chris Lattneredd9b032006-01-23 23:05:42 +00003140 ;
3141 break;}
3142case 152:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003143#line 1710 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003144{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003145 yyval.ArgList = yyvsp[-2].ArgList;
3146 yyval.ArgList->push_back(std::pair<PATypeHolder*,
3147 char*>(new PATypeHolder(Type::VoidTy), 0));
Chris Lattneredd9b032006-01-23 23:05:42 +00003148 ;
3149 break;}
3150case 153:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003151#line 1715 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003152{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003153 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
3154 yyval.ArgList->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0));
Chris Lattneredd9b032006-01-23 23:05:42 +00003155 ;
3156 break;}
3157case 154:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003158#line 1719 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003159{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003160 yyval.ArgList = 0;
Chris Lattneredd9b032006-01-23 23:05:42 +00003161 ;
3162 break;}
3163case 155:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003164#line 1724 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003165{
Chris Lattnera0c20b42005-11-12 00:11:49 +00003166 UnEscapeLexed(yyvsp[-5].StrVal);
3167 std::string FunctionName(yyvsp[-5].StrVal);
3168 free(yyvsp[-5].StrVal); // Free strdup'd memory!
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003169
Chris Lattnera0c20b42005-11-12 00:11:49 +00003170 if (!(*yyvsp[-6].TypeVal)->isFirstClassType() && *yyvsp[-6].TypeVal != Type::VoidTy)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003171 ThrowException("LLVM functions cannot return aggregate types!");
3172
3173 std::vector<const Type*> ParamTypeList;
Chris Lattnera0c20b42005-11-12 00:11:49 +00003174 if (yyvsp[-3].ArgList) { // If there are arguments...
3175 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-3].ArgList->begin();
3176 I != yyvsp[-3].ArgList->end(); ++I)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003177 ParamTypeList.push_back(I->first->get());
3178 }
3179
3180 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
3181 if (isVarArg) ParamTypeList.pop_back();
3182
Chris Lattnera0c20b42005-11-12 00:11:49 +00003183 const FunctionType *FT = FunctionType::get(*yyvsp[-6].TypeVal, ParamTypeList, isVarArg);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003184 const PointerType *PFT = PointerType::get(FT);
Chris Lattnera0c20b42005-11-12 00:11:49 +00003185 delete yyvsp[-6].TypeVal;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003186
3187 ValID ID;
3188 if (!FunctionName.empty()) {
3189 ID = ValID::create((char*)FunctionName.c_str());
3190 } else {
3191 ID = ValID::create((int)CurModule.Values[PFT].size());
3192 }
3193
3194 Function *Fn = 0;
3195 // See if this function was forward referenced. If so, recycle the object.
3196 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
3197 // Move the function to the end of the list, from whereever it was
3198 // previously inserted.
3199 Fn = cast<Function>(FWRef);
3200 CurModule.CurrentModule->getFunctionList().remove(Fn);
3201 CurModule.CurrentModule->getFunctionList().push_back(Fn);
3202 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
3203 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
3204 // If this is the case, either we need to be a forward decl, or it needs
3205 // to be.
3206 if (!CurFun.isDeclare && !Fn->isExternal())
3207 ThrowException("Redefinition of function '" + FunctionName + "'!");
3208
3209 // Make sure to strip off any argument names so we can't get conflicts.
3210 if (Fn->isExternal())
3211 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
3212 AI != AE; ++AI)
3213 AI->setName("");
3214
3215 } else { // Not already defined?
3216 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
3217 CurModule.CurrentModule);
3218 InsertValue(Fn, CurModule.Values);
3219 }
3220
3221 CurFun.FunctionStart(Fn);
Chris Lattnera0c20b42005-11-12 00:11:49 +00003222 Fn->setCallingConv(yyvsp[-7].UIntVal);
Chris Lattner840f7892005-11-06 06:46:53 +00003223 Fn->setAlignment(yyvsp[0].UIntVal);
Chris Lattnera0c20b42005-11-12 00:11:49 +00003224 if (yyvsp[-1].StrVal) {
3225 Fn->setSection(yyvsp[-1].StrVal);
3226 free(yyvsp[-1].StrVal);
3227 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003228
3229 // Add all of the arguments we parsed to the function...
Chris Lattnera0c20b42005-11-12 00:11:49 +00003230 if (yyvsp[-3].ArgList) { // Is null if empty...
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003231 if (isVarArg) { // Nuke the last entry
Chris Lattnera0c20b42005-11-12 00:11:49 +00003232 assert(yyvsp[-3].ArgList->back().first->get() == Type::VoidTy && yyvsp[-3].ArgList->back().second == 0&&
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003233 "Not a varargs marker!");
Chris Lattnera0c20b42005-11-12 00:11:49 +00003234 delete yyvsp[-3].ArgList->back().first;
3235 yyvsp[-3].ArgList->pop_back(); // Delete the last entry
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003236 }
3237 Function::arg_iterator ArgIt = Fn->arg_begin();
Chris Lattnera0c20b42005-11-12 00:11:49 +00003238 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-3].ArgList->begin();
3239 I != yyvsp[-3].ArgList->end(); ++I, ++ArgIt) {
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003240 delete I->first; // Delete the typeholder...
3241
3242 setValueName(ArgIt, I->second); // Insert arg into symtab...
3243 InsertValue(ArgIt);
3244 }
3245
Chris Lattnera0c20b42005-11-12 00:11:49 +00003246 delete yyvsp[-3].ArgList; // We're now done with the argument list
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003247 }
Chris Lattneredd9b032006-01-23 23:05:42 +00003248;
3249 break;}
3250case 158:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003251#line 1811 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003252{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003253 yyval.FunctionVal = CurFun.CurrentFunction;
3254
3255 // Make sure that we keep track of the linkage type even if there was a
3256 // previous "declare".
3257 yyval.FunctionVal->setLinkage(yyvsp[-2].Linkage);
Chris Lattneredd9b032006-01-23 23:05:42 +00003258;
3259 break;}
3260case 161:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003261#line 1821 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003262{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003263 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003264;
3265 break;}
3266case 162:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003267#line 1825 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003268{ CurFun.isDeclare = true; ;
3269 break;}
3270case 163:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003271#line 1825 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003272{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003273 yyval.FunctionVal = CurFun.CurrentFunction;
3274 CurFun.FunctionDone();
Chris Lattneredd9b032006-01-23 23:05:42 +00003275;
3276 break;}
3277case 164:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003278#line 1834 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003279{ // A reference to a direct constant
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003280 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
Chris Lattneredd9b032006-01-23 23:05:42 +00003281 ;
3282 break;}
3283case 165:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003284#line 1837 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003285{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003286 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
Chris Lattneredd9b032006-01-23 23:05:42 +00003287 ;
3288 break;}
3289case 166:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003290#line 1840 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003291{ // Perhaps it's an FP constant?
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003292 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003293 ;
3294 break;}
3295case 167:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003296#line 1843 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003297{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003298 yyval.ValIDVal = ValID::create(ConstantBool::True);
Chris Lattneredd9b032006-01-23 23:05:42 +00003299 ;
3300 break;}
3301case 168:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003302#line 1846 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003303{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003304 yyval.ValIDVal = ValID::create(ConstantBool::False);
Chris Lattneredd9b032006-01-23 23:05:42 +00003305 ;
3306 break;}
3307case 169:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003308#line 1849 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003309{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003310 yyval.ValIDVal = ValID::createNull();
Chris Lattneredd9b032006-01-23 23:05:42 +00003311 ;
3312 break;}
3313case 170:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003314#line 1852 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003315{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003316 yyval.ValIDVal = ValID::createUndef();
Chris Lattneredd9b032006-01-23 23:05:42 +00003317 ;
3318 break;}
3319case 171:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003320#line 1855 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003321{ // A vector zero constant.
Chris Lattnera054d122005-12-21 17:53:23 +00003322 yyval.ValIDVal = ValID::createZeroInit();
Chris Lattneredd9b032006-01-23 23:05:42 +00003323 ;
3324 break;}
3325case 172:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003326#line 1858 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003327{ // Nonempty unsized packed vector
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003328 const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
3329 int NumElements = yyvsp[-1].ConstVector->size();
3330
3331 PackedType* pt = PackedType::get(ETy, NumElements);
3332 PATypeHolder* PTy = new PATypeHolder(
3333 HandleUpRefs(
3334 PackedType::get(
3335 ETy,
3336 NumElements)
3337 )
3338 );
3339
3340 // Verify all elements are correct type!
3341 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3342 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
3343 ThrowException("Element #" + utostr(i) + " is not of type '" +
3344 ETy->getDescription() +"' as required!\nIt is of type '" +
3345 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
3346 }
3347
3348 yyval.ValIDVal = ValID::create(ConstantPacked::get(pt, *yyvsp[-1].ConstVector));
3349 delete PTy; delete yyvsp[-1].ConstVector;
Chris Lattneredd9b032006-01-23 23:05:42 +00003350 ;
3351 break;}
3352case 173:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003353#line 1882 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003354{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003355 yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003356 ;
3357 break;}
3358case 174:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003359#line 1889 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003360{ // Is it an integer reference...?
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003361 yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003362 ;
3363 break;}
3364case 175:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003365#line 1892 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003366{ // Is it a named reference...?
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003367 yyval.ValIDVal = ValID::create(yyvsp[0].StrVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003368 ;
3369 break;}
3370case 178:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003371#line 1903 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003372{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003373 yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); delete yyvsp[-1].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003374 ;
3375 break;}
3376case 179:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003377#line 1907 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003378{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003379 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003380 ;
3381 break;}
3382case 180:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003383#line 1910 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003384{ // Do not allow functions with 0 basic blocks
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003385 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003386 ;
3387 break;}
3388case 181:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003389#line 1918 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003390{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003391 setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
3392 InsertValue(yyvsp[0].TermInstVal);
3393
3394 yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
3395 InsertValue(yyvsp[-2].BasicBlockVal);
3396 yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003397 ;
3398 break;}
3399case 182:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003400#line 1927 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003401{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003402 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
3403 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003404 ;
3405 break;}
3406case 183:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003407#line 1931 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003408{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003409 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
3410
3411 // Make sure to move the basic block to the correct location in the
3412 // function, instead of leaving it inserted wherever it was first
3413 // referenced.
3414 Function::BasicBlockListType &BBL =
3415 CurFun.CurrentFunction->getBasicBlockList();
3416 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003417 ;
3418 break;}
3419case 184:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003420#line 1941 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003421{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003422 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create(yyvsp[0].StrVal), true);
3423
3424 // Make sure to move the basic block to the correct location in the
3425 // function, instead of leaving it inserted wherever it was first
3426 // referenced.
3427 Function::BasicBlockListType &BBL =
3428 CurFun.CurrentFunction->getBasicBlockList();
3429 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003430 ;
3431 break;}
3432case 185:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003433#line 1952 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003434{ // Return with a result...
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003435 yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003436 ;
3437 break;}
3438case 186:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003439#line 1955 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003440{ // Return with no result...
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003441 yyval.TermInstVal = new ReturnInst();
Chris Lattneredd9b032006-01-23 23:05:42 +00003442 ;
3443 break;}
3444case 187:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003445#line 1958 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003446{ // Unconditional Branch...
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003447 yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[0].ValIDVal));
Chris Lattneredd9b032006-01-23 23:05:42 +00003448 ;
3449 break;}
3450case 188:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003451#line 1961 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003452{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003453 yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[-3].ValIDVal), getBBVal(yyvsp[0].ValIDVal), getVal(Type::BoolTy, yyvsp[-6].ValIDVal));
Chris Lattneredd9b032006-01-23 23:05:42 +00003454 ;
3455 break;}
3456case 189:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003457#line 1964 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003458{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003459 SwitchInst *S = new SwitchInst(getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal), getBBVal(yyvsp[-3].ValIDVal), yyvsp[-1].JumpTable->size());
3460 yyval.TermInstVal = S;
3461
3462 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
3463 E = yyvsp[-1].JumpTable->end();
3464 for (; I != E; ++I) {
3465 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
3466 S->addCase(CI, I->second);
3467 else
3468 ThrowException("Switch case is constant, but not a simple integer!");
3469 }
3470 delete yyvsp[-1].JumpTable;
Chris Lattneredd9b032006-01-23 23:05:42 +00003471 ;
3472 break;}
3473case 190:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003474#line 1978 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003475{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003476 SwitchInst *S = new SwitchInst(getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal), getBBVal(yyvsp[-2].ValIDVal), 0);
3477 yyval.TermInstVal = S;
Chris Lattneredd9b032006-01-23 23:05:42 +00003478 ;
3479 break;}
3480case 191:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003481#line 1983 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003482{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003483 const PointerType *PFTy;
3484 const FunctionType *Ty;
3485
3486 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-10].TypeVal->get())) ||
3487 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3488 // Pull out the types of all of the arguments...
3489 std::vector<const Type*> ParamTypes;
3490 if (yyvsp[-7].ValueList) {
3491 for (std::vector<Value*>::iterator I = yyvsp[-7].ValueList->begin(), E = yyvsp[-7].ValueList->end();
3492 I != E; ++I)
3493 ParamTypes.push_back((*I)->getType());
3494 }
3495
3496 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3497 if (isVarArg) ParamTypes.pop_back();
3498
3499 Ty = FunctionType::get(yyvsp[-10].TypeVal->get(), ParamTypes, isVarArg);
3500 PFTy = PointerType::get(Ty);
3501 }
3502
3503 Value *V = getVal(PFTy, yyvsp[-9].ValIDVal); // Get the function we're calling...
3504
3505 BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
3506 BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
3507
3508 // Create the call node...
3509 if (!yyvsp[-7].ValueList) { // Has no arguments?
3510 yyval.TermInstVal = new InvokeInst(V, Normal, Except, std::vector<Value*>());
3511 } else { // Has arguments?
3512 // Loop through FunctionType's arguments and ensure they are specified
3513 // correctly!
3514 //
3515 FunctionType::param_iterator I = Ty->param_begin();
3516 FunctionType::param_iterator E = Ty->param_end();
3517 std::vector<Value*>::iterator ArgI = yyvsp[-7].ValueList->begin(), ArgE = yyvsp[-7].ValueList->end();
3518
3519 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3520 if ((*ArgI)->getType() != *I)
3521 ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
3522 (*I)->getDescription() + "'!");
3523
3524 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
3525 ThrowException("Invalid number of parameters detected!");
3526
3527 yyval.TermInstVal = new InvokeInst(V, Normal, Except, *yyvsp[-7].ValueList);
3528 }
3529 cast<InvokeInst>(yyval.TermInstVal)->setCallingConv(yyvsp[-11].UIntVal);
3530
3531 delete yyvsp[-10].TypeVal;
3532 delete yyvsp[-7].ValueList;
Chris Lattneredd9b032006-01-23 23:05:42 +00003533 ;
3534 break;}
3535case 192:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003536#line 2035 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003537{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003538 yyval.TermInstVal = new UnwindInst();
Chris Lattneredd9b032006-01-23 23:05:42 +00003539 ;
3540 break;}
3541case 193:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003542#line 2038 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003543{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003544 yyval.TermInstVal = new UnreachableInst();
Chris Lattneredd9b032006-01-23 23:05:42 +00003545 ;
3546 break;}
3547case 194:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003548#line 2044 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003549{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003550 yyval.JumpTable = yyvsp[-5].JumpTable;
3551 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
3552 if (V == 0)
3553 ThrowException("May only switch on a constant pool value!");
3554
3555 yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
Chris Lattneredd9b032006-01-23 23:05:42 +00003556 ;
3557 break;}
3558case 195:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003559#line 2052 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003560{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003561 yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
3562 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
3563
3564 if (V == 0)
3565 ThrowException("May only switch on a constant pool value!");
3566
3567 yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
Chris Lattneredd9b032006-01-23 23:05:42 +00003568 ;
3569 break;}
3570case 196:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003571#line 2062 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003572{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003573 // Is this definition named?? if so, assign the name...
3574 setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
3575 InsertValue(yyvsp[0].InstVal);
3576 yyval.InstVal = yyvsp[0].InstVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003577;
3578 break;}
3579case 197:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003580#line 2069 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003581{ // Used for PHI nodes
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003582 yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
3583 yyval.PHIList->push_back(std::make_pair(getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal), getBBVal(yyvsp[-1].ValIDVal)));
3584 delete yyvsp[-5].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003585 ;
3586 break;}
3587case 198:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003588#line 2074 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003589{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003590 yyval.PHIList = yyvsp[-6].PHIList;
3591 yyvsp[-6].PHIList->push_back(std::make_pair(getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal),
3592 getBBVal(yyvsp[-1].ValIDVal)));
Chris Lattneredd9b032006-01-23 23:05:42 +00003593 ;
3594 break;}
3595case 199:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003596#line 2081 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003597{ // Used for call statements, and memory insts...
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003598 yyval.ValueList = new std::vector<Value*>();
3599 yyval.ValueList->push_back(yyvsp[0].ValueVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003600 ;
3601 break;}
3602case 200:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003603#line 2085 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003604{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003605 yyval.ValueList = yyvsp[-2].ValueList;
3606 yyvsp[-2].ValueList->push_back(yyvsp[0].ValueVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003607 ;
3608 break;}
3609case 202:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003610#line 2091 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003611{ yyval.ValueList = 0; ;
3612 break;}
3613case 203:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003614#line 2093 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003615{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003616 yyval.BoolVal = true;
Chris Lattneredd9b032006-01-23 23:05:42 +00003617 ;
3618 break;}
3619case 204:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003620#line 2096 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003621{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003622 yyval.BoolVal = false;
Chris Lattneredd9b032006-01-23 23:05:42 +00003623 ;
3624 break;}
3625case 205:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003626#line 2102 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003627{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003628 if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
3629 !isa<PackedType>((*yyvsp[-3].TypeVal).get()))
3630 ThrowException(
3631 "Arithmetic operator requires integer, FP, or packed operands!");
3632 if (isa<PackedType>((*yyvsp[-3].TypeVal).get()) && yyvsp[-4].BinaryOpVal == Instruction::Rem)
3633 ThrowException("Rem not supported on packed types!");
3634 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3635 if (yyval.InstVal == 0)
3636 ThrowException("binary operator returned null!");
3637 delete yyvsp[-3].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003638 ;
3639 break;}
3640case 206:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003641#line 2114 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003642{
Chris Lattner15f5a182005-12-21 18:31:50 +00003643 if (!(*yyvsp[-3].TypeVal)->isIntegral()) {
3644 if (!isa<PackedType>(yyvsp[-3].TypeVal->get()) ||
3645 !cast<PackedType>(yyvsp[-3].TypeVal->get())->getElementType()->isIntegral())
3646 ThrowException("Logical operator requires integral operands!");
3647 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003648 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3649 if (yyval.InstVal == 0)
3650 ThrowException("binary operator returned null!");
3651 delete yyvsp[-3].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003652 ;
3653 break;}
3654case 207:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003655#line 2125 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003656{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003657 if(isa<PackedType>((*yyvsp[-3].TypeVal).get())) {
3658 ThrowException(
3659 "PackedTypes currently not supported in setcc instructions!");
3660 }
3661 yyval.InstVal = new SetCondInst(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3662 if (yyval.InstVal == 0)
3663 ThrowException("binary operator returned null!");
3664 delete yyvsp[-3].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003665 ;
3666 break;}
3667case 208:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003668#line 2135 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003669{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003670 std::cerr << "WARNING: Use of eliminated 'not' instruction:"
3671 << " Replacing with 'xor'.\n";
3672
3673 Value *Ones = ConstantIntegral::getAllOnesValue(yyvsp[0].ValueVal->getType());
3674 if (Ones == 0)
3675 ThrowException("Expected integral type for not instruction!");
3676
3677 yyval.InstVal = BinaryOperator::create(Instruction::Xor, yyvsp[0].ValueVal, Ones);
3678 if (yyval.InstVal == 0)
3679 ThrowException("Could not create a xor instruction!");
Chris Lattneredd9b032006-01-23 23:05:42 +00003680 ;
3681 break;}
3682case 209:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003683#line 2147 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003684{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003685 if (yyvsp[0].ValueVal->getType() != Type::UByteTy)
3686 ThrowException("Shift amount must be ubyte!");
3687 if (!yyvsp[-2].ValueVal->getType()->isInteger())
3688 ThrowException("Shift constant expression requires integer operand!");
3689 yyval.InstVal = new ShiftInst(yyvsp[-3].OtherOpVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003690 ;
3691 break;}
3692case 210:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003693#line 2154 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003694{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003695 if (!yyvsp[0].TypeVal->get()->isFirstClassType())
3696 ThrowException("cast instruction to a non-primitive type: '" +
3697 yyvsp[0].TypeVal->get()->getDescription() + "'!");
3698 yyval.InstVal = new CastInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
3699 delete yyvsp[0].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003700 ;
3701 break;}
3702case 211:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003703#line 2161 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003704{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003705 if (yyvsp[-4].ValueVal->getType() != Type::BoolTy)
3706 ThrowException("select condition must be boolean!");
3707 if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
3708 ThrowException("select value types should match!");
3709 yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003710 ;
3711 break;}
3712case 212:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003713#line 2168 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003714{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003715 NewVarArgs = true;
3716 yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
3717 delete yyvsp[0].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003718 ;
3719 break;}
3720case 213:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003721#line 2173 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003722{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003723 ObsoleteVarArgs = true;
3724 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
3725 Function* NF = CurModule.CurrentModule->
Jeff Cohen11e26b52005-10-23 04:37:20 +00003726 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003727
3728 //b = vaarg a, t ->
3729 //foo = alloca 1 of t
3730 //bar = vacopy a
3731 //store bar -> foo
3732 //b = vaarg foo, t
3733 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
3734 CurBB->getInstList().push_back(foo);
3735 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
3736 CurBB->getInstList().push_back(bar);
3737 CurBB->getInstList().push_back(new StoreInst(bar, foo));
3738 yyval.InstVal = new VAArgInst(foo, *yyvsp[0].TypeVal);
3739 delete yyvsp[0].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003740 ;
3741 break;}
3742case 214:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003743#line 2192 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003744{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003745 ObsoleteVarArgs = true;
3746 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
3747 Function* NF = CurModule.CurrentModule->
Jeff Cohen11e26b52005-10-23 04:37:20 +00003748 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003749
3750 //b = vanext a, t ->
3751 //foo = alloca 1 of t
3752 //bar = vacopy a
3753 //store bar -> foo
3754 //tmp = vaarg foo, t
3755 //b = load foo
3756 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
3757 CurBB->getInstList().push_back(foo);
3758 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
3759 CurBB->getInstList().push_back(bar);
3760 CurBB->getInstList().push_back(new StoreInst(bar, foo));
3761 Instruction* tmp = new VAArgInst(foo, *yyvsp[0].TypeVal);
3762 CurBB->getInstList().push_back(tmp);
3763 yyval.InstVal = new LoadInst(foo);
3764 delete yyvsp[0].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003765 ;
3766 break;}
3767case 215:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003768#line 2214 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003769{
Robert Bocchinoaa1cf542006-01-10 19:04:32 +00003770 if (!isa<PackedType>(yyvsp[-2].ValueVal->getType()))
Robert Bocchinofdf9e412006-01-17 20:06:25 +00003771 ThrowException("First operand of extractelement must be "
3772 "packed type!");
Robert Bocchinoaa1cf542006-01-10 19:04:32 +00003773 if (yyvsp[0].ValueVal->getType() != Type::UIntTy)
Robert Bocchinofdf9e412006-01-17 20:06:25 +00003774 ThrowException("Second operand of extractelement must be uint!");
Robert Bocchinoaa1cf542006-01-10 19:04:32 +00003775 yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003776 ;
3777 break;}
3778case 216:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003779#line 2222 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003780{
Robert Bocchinofdf9e412006-01-17 20:06:25 +00003781 if (!isa<PackedType>(yyvsp[-4].ValueVal->getType()))
3782 ThrowException("First operand of insertelement must be "
3783 "packed type!");
3784 if (yyvsp[-2].ValueVal->getType() !=
3785 cast<PackedType>(yyvsp[-4].ValueVal->getType())->getElementType())
3786 ThrowException("Second operand of insertelement must be "
3787 "packed element type!");
3788 if (yyvsp[0].ValueVal->getType() != Type::UIntTy)
3789 ThrowException("Third operand of insertelement must be uint!");
3790 yyval.InstVal = new InsertElementInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003791 ;
3792 break;}
3793case 217:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003794#line 2234 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003795{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003796 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
3797 if (!Ty->isFirstClassType())
3798 ThrowException("PHI node operands must be of first class type!");
3799 yyval.InstVal = new PHINode(Ty);
3800 ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
3801 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
3802 if (yyvsp[0].PHIList->front().first->getType() != Ty)
3803 ThrowException("All elements of a PHI node must be of the same type!");
3804 cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
3805 yyvsp[0].PHIList->pop_front();
3806 }
3807 delete yyvsp[0].PHIList; // Free the list...
Chris Lattneredd9b032006-01-23 23:05:42 +00003808 ;
3809 break;}
3810case 218:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003811#line 2248 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003812{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003813 const PointerType *PFTy;
3814 const FunctionType *Ty;
3815
3816 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-4].TypeVal->get())) ||
3817 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3818 // Pull out the types of all of the arguments...
3819 std::vector<const Type*> ParamTypes;
3820 if (yyvsp[-1].ValueList) {
3821 for (std::vector<Value*>::iterator I = yyvsp[-1].ValueList->begin(), E = yyvsp[-1].ValueList->end();
3822 I != E; ++I)
3823 ParamTypes.push_back((*I)->getType());
3824 }
3825
3826 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3827 if (isVarArg) ParamTypes.pop_back();
3828
3829 if (!(*yyvsp[-4].TypeVal)->isFirstClassType() && *yyvsp[-4].TypeVal != Type::VoidTy)
3830 ThrowException("LLVM functions cannot return aggregate types!");
3831
3832 Ty = FunctionType::get(yyvsp[-4].TypeVal->get(), ParamTypes, isVarArg);
3833 PFTy = PointerType::get(Ty);
3834 }
3835
3836 Value *V = getVal(PFTy, yyvsp[-3].ValIDVal); // Get the function we're calling...
3837
3838 // Create the call node...
3839 if (!yyvsp[-1].ValueList) { // Has no arguments?
3840 // Make sure no arguments is a good thing!
3841 if (Ty->getNumParams() != 0)
3842 ThrowException("No arguments passed to a function that "
3843 "expects arguments!");
3844
3845 yyval.InstVal = new CallInst(V, std::vector<Value*>());
3846 } else { // Has arguments?
3847 // Loop through FunctionType's arguments and ensure they are specified
3848 // correctly!
3849 //
3850 FunctionType::param_iterator I = Ty->param_begin();
3851 FunctionType::param_iterator E = Ty->param_end();
3852 std::vector<Value*>::iterator ArgI = yyvsp[-1].ValueList->begin(), ArgE = yyvsp[-1].ValueList->end();
3853
3854 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3855 if ((*ArgI)->getType() != *I)
3856 ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
3857 (*I)->getDescription() + "'!");
3858
3859 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
3860 ThrowException("Invalid number of parameters detected!");
3861
3862 yyval.InstVal = new CallInst(V, *yyvsp[-1].ValueList);
3863 }
3864 cast<CallInst>(yyval.InstVal)->setTailCall(yyvsp[-6].BoolVal);
3865 cast<CallInst>(yyval.InstVal)->setCallingConv(yyvsp[-5].UIntVal);
3866 delete yyvsp[-4].TypeVal;
3867 delete yyvsp[-1].ValueList;
Chris Lattneredd9b032006-01-23 23:05:42 +00003868 ;
3869 break;}
3870case 219:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003871#line 2305 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003872{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003873 yyval.InstVal = yyvsp[0].InstVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003874 ;
3875 break;}
3876case 220:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003877#line 2311 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003878{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003879 yyval.ValueList = yyvsp[0].ValueList;
Chris Lattneredd9b032006-01-23 23:05:42 +00003880 ;
3881 break;}
3882case 221:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003883#line 2313 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003884{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003885 yyval.ValueList = new std::vector<Value*>();
Chris Lattneredd9b032006-01-23 23:05:42 +00003886 ;
3887 break;}
3888case 222:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003889#line 2317 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003890{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003891 yyval.BoolVal = true;
Chris Lattneredd9b032006-01-23 23:05:42 +00003892 ;
3893 break;}
3894case 223:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003895#line 2320 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003896{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003897 yyval.BoolVal = false;
Chris Lattneredd9b032006-01-23 23:05:42 +00003898 ;
3899 break;}
3900case 224:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003901#line 2326 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003902{
Chris Lattner86c352b2005-11-06 06:34:34 +00003903 yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
3904 delete yyvsp[-1].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003905 ;
3906 break;}
3907case 225:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003908#line 2330 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003909{
Chris Lattner86c352b2005-11-06 06:34:34 +00003910 yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal);
3911 delete yyvsp[-4].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003912 ;
3913 break;}
3914case 226:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003915#line 2334 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003916{
Chris Lattner86c352b2005-11-06 06:34:34 +00003917 yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
3918 delete yyvsp[-1].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003919 ;
3920 break;}
3921case 227:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003922#line 2338 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003923{
Chris Lattner86c352b2005-11-06 06:34:34 +00003924 yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal);
3925 delete yyvsp[-4].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003926 ;
3927 break;}
3928case 228:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003929#line 2342 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003930{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003931 if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
3932 ThrowException("Trying to free nonpointer type " +
3933 yyvsp[0].ValueVal->getType()->getDescription() + "!");
3934 yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003935 ;
3936 break;}
3937case 229:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003938#line 2349 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003939{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003940 if (!isa<PointerType>(yyvsp[-1].TypeVal->get()))
3941 ThrowException("Can't load from nonpointer type: " +
3942 (*yyvsp[-1].TypeVal)->getDescription());
3943 if (!cast<PointerType>(yyvsp[-1].TypeVal->get())->getElementType()->isFirstClassType())
3944 ThrowException("Can't load from pointer of non-first-class type: " +
3945 (*yyvsp[-1].TypeVal)->getDescription());
3946 yyval.InstVal = new LoadInst(getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), "", yyvsp[-3].BoolVal);
3947 delete yyvsp[-1].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003948 ;
3949 break;}
3950case 230:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003951#line 2359 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003952{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003953 const PointerType *PT = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
3954 if (!PT)
3955 ThrowException("Can't store to a nonpointer type: " +
3956 (*yyvsp[-1].TypeVal)->getDescription());
3957 const Type *ElTy = PT->getElementType();
3958 if (ElTy != yyvsp[-3].ValueVal->getType())
3959 ThrowException("Can't store '" + yyvsp[-3].ValueVal->getType()->getDescription() +
3960 "' into space of type '" + ElTy->getDescription() + "'!");
3961
3962 yyval.InstVal = new StoreInst(yyvsp[-3].ValueVal, getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), yyvsp[-5].BoolVal);
3963 delete yyvsp[-1].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003964 ;
3965 break;}
3966case 231:
Chris Lattner8ebd2162006-01-24 04:14:29 +00003967#line 2372 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003968{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003969 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
3970 ThrowException("getelementptr insn requires pointer operand!");
3971
3972 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
3973 // indices to uint struct indices for compatibility.
3974 generic_gep_type_iterator<std::vector<Value*>::iterator>
3975 GTI = gep_type_begin(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end()),
3976 GTE = gep_type_end(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end());
3977 for (unsigned i = 0, e = yyvsp[0].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
3978 if (isa<StructType>(*GTI)) // Only change struct indices
3979 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[0].ValueList)[i]))
3980 if (CUI->getType() == Type::UByteTy)
3981 (*yyvsp[0].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
3982
3983 if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, *yyvsp[0].ValueList, true))
3984 ThrowException("Invalid getelementptr indices for type '" +
3985 (*yyvsp[-2].TypeVal)->getDescription()+ "'!");
3986 yyval.InstVal = new GetElementPtrInst(getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal), *yyvsp[0].ValueList);
3987 delete yyvsp[-2].TypeVal; delete yyvsp[0].ValueList;
Chris Lattneredd9b032006-01-23 23:05:42 +00003988 ;
3989 break;}
3990}
3991 /* the action file gets copied in in place of this dollarsign */
3992#line 543 "/usr/share/bison.simple"
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003993
3994 yyvsp -= yylen;
3995 yyssp -= yylen;
Chris Lattneredd9b032006-01-23 23:05:42 +00003996#ifdef YYLSP_NEEDED
3997 yylsp -= yylen;
3998#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003999
Chris Lattneredd9b032006-01-23 23:05:42 +00004000#if YYDEBUG != 0
4001 if (yydebug)
4002 {
4003 short *ssp1 = yyss - 1;
4004 fprintf (stderr, "state stack now");
4005 while (ssp1 != yyssp)
4006 fprintf (stderr, " %d", *++ssp1);
4007 fprintf (stderr, "\n");
4008 }
4009#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004010
4011 *++yyvsp = yyval;
4012
Chris Lattneredd9b032006-01-23 23:05:42 +00004013#ifdef YYLSP_NEEDED
4014 yylsp++;
4015 if (yylen == 0)
4016 {
4017 yylsp->first_line = yylloc.first_line;
4018 yylsp->first_column = yylloc.first_column;
4019 yylsp->last_line = (yylsp-1)->last_line;
4020 yylsp->last_column = (yylsp-1)->last_column;
4021 yylsp->text = 0;
4022 }
4023 else
4024 {
4025 yylsp->last_line = (yylsp+yylen-1)->last_line;
4026 yylsp->last_column = (yylsp+yylen-1)->last_column;
4027 }
4028#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004029
Chris Lattneredd9b032006-01-23 23:05:42 +00004030 /* Now "shift" the result of the reduction.
4031 Determine what state that goes to,
4032 based on the state we popped back to
4033 and the rule number reduced by. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004034
4035 yyn = yyr1[yyn];
4036
Chris Lattneredd9b032006-01-23 23:05:42 +00004037 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
4038 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004039 yystate = yytable[yystate];
4040 else
Chris Lattneredd9b032006-01-23 23:05:42 +00004041 yystate = yydefgoto[yyn - YYNTBASE];
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004042
4043 goto yynewstate;
4044
Chris Lattneredd9b032006-01-23 23:05:42 +00004045yyerrlab: /* here on detecting error */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004046
Chris Lattneredd9b032006-01-23 23:05:42 +00004047 if (! yyerrstatus)
4048 /* If not already recovering from an error, report this error. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004049 {
4050 ++yynerrs;
Chris Lattneredd9b032006-01-23 23:05:42 +00004051
4052#ifdef YYERROR_VERBOSE
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004053 yyn = yypact[yystate];
4054
Chris Lattneredd9b032006-01-23 23:05:42 +00004055 if (yyn > YYFLAG && yyn < YYLAST)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004056 {
Chris Lattneredd9b032006-01-23 23:05:42 +00004057 int size = 0;
4058 char *msg;
4059 int x, count;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004060
Chris Lattneredd9b032006-01-23 23:05:42 +00004061 count = 0;
4062 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
4063 for (x = (yyn < 0 ? -yyn : 0);
4064 x < (sizeof(yytname) / sizeof(char *)); x++)
4065 if (yycheck[x + yyn] == x)
4066 size += strlen(yytname[x]) + 15, count++;
4067 msg = (char *) malloc(size + 15);
4068 if (msg != 0)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004069 {
Chris Lattneredd9b032006-01-23 23:05:42 +00004070 strcpy(msg, "parse error");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004071
Chris Lattneredd9b032006-01-23 23:05:42 +00004072 if (count < 5)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004073 {
Chris Lattneredd9b032006-01-23 23:05:42 +00004074 count = 0;
4075 for (x = (yyn < 0 ? -yyn : 0);
4076 x < (sizeof(yytname) / sizeof(char *)); x++)
4077 if (yycheck[x + yyn] == x)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004078 {
Chris Lattneredd9b032006-01-23 23:05:42 +00004079 strcat(msg, count == 0 ? ", expecting `" : " or `");
4080 strcat(msg, yytname[x]);
4081 strcat(msg, "'");
4082 count++;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004083 }
4084 }
Chris Lattneredd9b032006-01-23 23:05:42 +00004085 yyerror(msg);
4086 free(msg);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004087 }
4088 else
Chris Lattneredd9b032006-01-23 23:05:42 +00004089 yyerror ("parse error; also virtual memory exceeded");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004090 }
4091 else
4092#endif /* YYERROR_VERBOSE */
Chris Lattneredd9b032006-01-23 23:05:42 +00004093 yyerror("parse error");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004094 }
4095
Chris Lattneredd9b032006-01-23 23:05:42 +00004096 goto yyerrlab1;
4097yyerrlab1: /* here on error raised explicitly by an action */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004098
4099 if (yyerrstatus == 3)
4100 {
Chris Lattneredd9b032006-01-23 23:05:42 +00004101 /* if just tried and failed to reuse lookahead token after an error, discard it. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004102
Chris Lattneredd9b032006-01-23 23:05:42 +00004103 /* return failure if at end of input */
4104 if (yychar == YYEOF)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004105 YYABORT;
4106
Chris Lattneredd9b032006-01-23 23:05:42 +00004107#if YYDEBUG != 0
4108 if (yydebug)
4109 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
4110#endif
4111
4112 yychar = YYEMPTY;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004113 }
4114
Chris Lattneredd9b032006-01-23 23:05:42 +00004115 /* Else will try to reuse lookahead token
4116 after shifting the error token. */
4117
4118 yyerrstatus = 3; /* Each real token shifted decrements this */
4119
4120 goto yyerrhandle;
4121
4122yyerrdefault: /* current state does not do anything special for the error token. */
4123
4124#if 0
4125 /* This is wrong; only states that explicitly want error tokens
4126 should shift them. */
4127 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
4128 if (yyn) goto yydefault;
4129#endif
4130
4131yyerrpop: /* pop the current state because it cannot handle the error token */
4132
4133 if (yyssp == yyss) YYABORT;
4134 yyvsp--;
4135 yystate = *--yyssp;
4136#ifdef YYLSP_NEEDED
4137 yylsp--;
4138#endif
4139
4140#if YYDEBUG != 0
4141 if (yydebug)
4142 {
4143 short *ssp1 = yyss - 1;
4144 fprintf (stderr, "Error: state stack now");
4145 while (ssp1 != yyssp)
4146 fprintf (stderr, " %d", *++ssp1);
4147 fprintf (stderr, "\n");
4148 }
4149#endif
4150
4151yyerrhandle:
4152
4153 yyn = yypact[yystate];
4154 if (yyn == YYFLAG)
4155 goto yyerrdefault;
4156
4157 yyn += YYTERROR;
4158 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
4159 goto yyerrdefault;
4160
4161 yyn = yytable[yyn];
4162 if (yyn < 0)
4163 {
4164 if (yyn == YYFLAG)
4165 goto yyerrpop;
4166 yyn = -yyn;
4167 goto yyreduce;
4168 }
4169 else if (yyn == 0)
4170 goto yyerrpop;
4171
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004172 if (yyn == YYFINAL)
4173 YYACCEPT;
4174
Chris Lattneredd9b032006-01-23 23:05:42 +00004175#if YYDEBUG != 0
4176 if (yydebug)
4177 fprintf(stderr, "Shifting error token, ");
4178#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004179
4180 *++yyvsp = yylval;
Chris Lattneredd9b032006-01-23 23:05:42 +00004181#ifdef YYLSP_NEEDED
4182 *++yylsp = yylloc;
4183#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004184
4185 yystate = yyn;
4186 goto yynewstate;
4187
Chris Lattneredd9b032006-01-23 23:05:42 +00004188 yyacceptlab:
4189 /* YYACCEPT comes here. */
4190 if (yyfree_stacks)
4191 {
4192 free (yyss);
4193 free (yyvs);
4194#ifdef YYLSP_NEEDED
4195 free (yyls);
Reid Spencerb4f9a6f2006-01-16 21:12:35 +00004196#endif
Chris Lattneredd9b032006-01-23 23:05:42 +00004197 }
4198 return 0;
Reid Spencerc8a9faf2006-01-19 01:21:04 +00004199
Chris Lattneredd9b032006-01-23 23:05:42 +00004200 yyabortlab:
4201 /* YYABORT comes here. */
4202 if (yyfree_stacks)
4203 {
4204 free (yyss);
4205 free (yyvs);
4206#ifdef YYLSP_NEEDED
4207 free (yyls);
Reid Spencerc8a9faf2006-01-19 01:21:04 +00004208#endif
Chris Lattneredd9b032006-01-23 23:05:42 +00004209 }
4210 return 1;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004211}
Chris Lattner8ebd2162006-01-24 04:14:29 +00004212#line 2395 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004213
4214int yyerror(const char *ErrorMsg) {
4215 std::string where
4216 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
4217 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
4218 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
4219 if (yychar == YYEMPTY || yychar == 0)
4220 errMsg += "end-of-file.";
4221 else
4222 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
4223 ThrowException(errMsg);
4224 return 0;
4225}