blob: f7e57fe87886969f456bc171ad22f6c7d50c4de9 [file] [log] [blame]
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002/* A Bison parser, made from /Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y
Chris Lattneredd9b032006-01-23 23:05:42 +00003 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
Chris Lattnere0a4ee92006-01-25 22:27:16 +000071#define SIDEEFFECT 314
72#define CC_TOK 315
73#define CCC_TOK 316
74#define FASTCC_TOK 317
75#define COLDCC_TOK 318
76#define RET 319
77#define BR 320
78#define SWITCH 321
79#define INVOKE 322
80#define UNWIND 323
81#define UNREACHABLE 324
82#define ADD 325
83#define SUB 326
84#define MUL 327
85#define DIV 328
86#define REM 329
87#define AND 330
88#define OR 331
89#define XOR 332
90#define SETLE 333
91#define SETGE 334
92#define SETLT 335
93#define SETGT 336
94#define SETEQ 337
95#define SETNE 338
96#define MALLOC 339
97#define ALLOCA 340
98#define FREE 341
99#define LOAD 342
100#define STORE 343
101#define GETELEMENTPTR 344
102#define PHI_TOK 345
103#define CAST 346
104#define SELECT 347
105#define SHL 348
106#define SHR 349
107#define VAARG 350
108#define EXTRACTELEMENT 351
109#define INSERTELEMENT 352
110#define VAARG_old 353
111#define VANEXT_old 354
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000112
Chris Lattnere0a4ee92006-01-25 22:27:16 +0000113#line 14 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000114
115#include "ParserInternals.h"
116#include "llvm/CallingConv.h"
Chris Lattnere0a4ee92006-01-25 22:27:16 +0000117#include "llvm/InlineAsm.h"
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000118#include "llvm/Instructions.h"
119#include "llvm/Module.h"
120#include "llvm/SymbolTable.h"
Reid Spencerb4f9a6f2006-01-16 21:12:35 +0000121#include "llvm/Assembly/AutoUpgrade.h"
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000122#include "llvm/Support/GetElementPtrTypeIterator.h"
123#include "llvm/ADT/STLExtras.h"
Chris Lattner840f7892005-11-06 06:46:53 +0000124#include "llvm/Support/MathExtras.h"
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000125#include <algorithm>
126#include <iostream>
127#include <list>
128#include <utility>
129
130int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
131int yylex(); // declaration" of xxx warnings.
132int yyparse();
133
134namespace llvm {
135 std::string CurFilename;
136}
137using namespace llvm;
138
139static Module *ParserResult;
140
141// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
142// relating to upreferences in the input stream.
143//
144//#define DEBUG_UPREFS 1
145#ifdef DEBUG_UPREFS
146#define UR_OUT(X) std::cerr << X
147#else
148#define UR_OUT(X)
149#endif
150
151#define YYERROR_VERBOSE 1
152
153static bool ObsoleteVarArgs;
154static bool NewVarArgs;
Chris Lattner11ca4d62005-11-12 18:22:38 +0000155static BasicBlock *CurBB;
156static GlobalVariable *CurGV;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000157
158
159// This contains info used when building the body of a function. It is
160// destroyed when the function is completed.
161//
162typedef std::vector<Value *> ValueList; // Numbered defs
163static void
164ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
165 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
166
167static struct PerModuleInfo {
168 Module *CurrentModule;
169 std::map<const Type *, ValueList> Values; // Module level numbered definitions
170 std::map<const Type *,ValueList> LateResolveValues;
171 std::vector<PATypeHolder> Types;
172 std::map<ValID, PATypeHolder> LateResolveTypes;
173
174 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
175 /// how they were referenced and one which line of the input they came from so
176 /// that we can resolve them later and print error messages as appropriate.
177 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
178
179 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
180 // references to global values. Global values may be referenced before they
181 // are defined, and if so, the temporary object that they represent is held
182 // here. This is used for forward references of GlobalValues.
183 //
184 typedef std::map<std::pair<const PointerType *,
185 ValID>, GlobalValue*> GlobalRefsType;
186 GlobalRefsType GlobalRefs;
187
188 void ModuleDone() {
189 // If we could not resolve some functions at function compilation time
190 // (calls to functions before they are defined), resolve them now... Types
191 // are resolved when the constant pool has been completely parsed.
192 //
193 ResolveDefinitions(LateResolveValues);
194
195 // Check to make sure that all global value forward references have been
196 // resolved!
197 //
198 if (!GlobalRefs.empty()) {
199 std::string UndefinedReferences = "Unresolved global references exist:\n";
200
201 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
202 I != E; ++I) {
203 UndefinedReferences += " " + I->first.first->getDescription() + " " +
204 I->first.second.getName() + "\n";
205 }
206 ThrowException(UndefinedReferences);
207 }
208
Reid Spencerc8a9faf2006-01-19 01:21:04 +0000209 // Look for intrinsic functions and CallInst that need to be upgraded
210 for (Module::iterator FI = CurrentModule->begin(),FE = CurrentModule->end();
211 FI != FE; ++FI)
212 UpgradeCallsToIntrinsic(FI);
Reid Spencerb4f9a6f2006-01-16 21:12:35 +0000213
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000214 Values.clear(); // Clear out function local definitions
215 Types.clear();
216 CurrentModule = 0;
217 }
218
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000219 // GetForwardRefForGlobal - Check to see if there is a forward reference
220 // for this global. If so, remove it from the GlobalRefs map and return it.
221 // If not, just return null.
222 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
223 // Check to see if there is a forward reference to this global variable...
224 // if there is, eliminate it and patch the reference to use the new def'n.
225 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
226 GlobalValue *Ret = 0;
227 if (I != GlobalRefs.end()) {
228 Ret = I->second;
229 GlobalRefs.erase(I);
230 }
231 return Ret;
232 }
233} CurModule;
234
235static struct PerFunctionInfo {
236 Function *CurrentFunction; // Pointer to current function being created
237
238 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
239 std::map<const Type*, ValueList> LateResolveValues;
240 bool isDeclare; // Is this function a forward declararation?
241
242 /// BBForwardRefs - When we see forward references to basic blocks, keep
243 /// track of them here.
244 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
245 std::vector<BasicBlock*> NumberedBlocks;
246 unsigned NextBBNum;
247
248 inline PerFunctionInfo() {
249 CurrentFunction = 0;
250 isDeclare = false;
251 }
252
253 inline void FunctionStart(Function *M) {
254 CurrentFunction = M;
255 NextBBNum = 0;
256 }
257
258 void FunctionDone() {
259 NumberedBlocks.clear();
260
261 // Any forward referenced blocks left?
262 if (!BBForwardRefs.empty())
263 ThrowException("Undefined reference to label " +
264 BBForwardRefs.begin()->first->getName());
265
266 // Resolve all forward references now.
267 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
268
269 Values.clear(); // Clear out function local definitions
270 CurrentFunction = 0;
271 isDeclare = false;
272 }
273} CurFun; // Info for the current function...
274
275static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
276
277
278//===----------------------------------------------------------------------===//
279// Code to handle definitions of all the types
280//===----------------------------------------------------------------------===//
281
282static int InsertValue(Value *V,
283 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
284 if (V->hasName()) return -1; // Is this a numbered definition?
285
286 // Yes, insert the value into the value table...
287 ValueList &List = ValueTab[V->getType()];
288 List.push_back(V);
289 return List.size()-1;
290}
291
292static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
293 switch (D.Type) {
294 case ValID::NumberVal: // Is it a numbered definition?
295 // Module constants occupy the lowest numbered slots...
296 if ((unsigned)D.Num < CurModule.Types.size())
297 return CurModule.Types[(unsigned)D.Num];
298 break;
299 case ValID::NameVal: // Is it a named definition?
300 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
301 D.destroy(); // Free old strdup'd memory...
302 return N;
303 }
304 break;
305 default:
306 ThrowException("Internal parser error: Invalid symbol type reference!");
307 }
308
309 // If we reached here, we referenced either a symbol that we don't know about
310 // or an id number that hasn't been read yet. We may be referencing something
311 // forward, so just create an entry to be resolved later and get to it...
312 //
313 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
314
315
316 if (inFunctionScope()) {
317 if (D.Type == ValID::NameVal)
318 ThrowException("Reference to an undefined type: '" + D.getName() + "'");
319 else
320 ThrowException("Reference to an undefined type: #" + itostr(D.Num));
321 }
322
323 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
324 if (I != CurModule.LateResolveTypes.end())
325 return I->second;
326
327 Type *Typ = OpaqueType::get();
328 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
329 return Typ;
330 }
331
332static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
333 SymbolTable &SymTab =
334 inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() :
335 CurModule.CurrentModule->getSymbolTable();
336 return SymTab.lookup(Ty, Name);
337}
338
339// getValNonImprovising - Look up the value specified by the provided type and
340// the provided ValID. If the value exists and has already been defined, return
341// it. Otherwise return null.
342//
343static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
344 if (isa<FunctionType>(Ty))
345 ThrowException("Functions are not values and "
346 "must be referenced as pointers");
347
348 switch (D.Type) {
349 case ValID::NumberVal: { // Is it a numbered definition?
350 unsigned Num = (unsigned)D.Num;
351
352 // Module constants occupy the lowest numbered slots...
353 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
354 if (VI != CurModule.Values.end()) {
355 if (Num < VI->second.size())
356 return VI->second[Num];
357 Num -= VI->second.size();
358 }
359
360 // Make sure that our type is within bounds
361 VI = CurFun.Values.find(Ty);
362 if (VI == CurFun.Values.end()) return 0;
363
364 // Check that the number is within bounds...
365 if (VI->second.size() <= Num) return 0;
366
367 return VI->second[Num];
368 }
369
370 case ValID::NameVal: { // Is it a named definition?
371 Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
372 if (N == 0) return 0;
373
374 D.destroy(); // Free old strdup'd memory...
375 return N;
376 }
377
378 // Check to make sure that "Ty" is an integral type, and that our
379 // value will fit into the specified type...
380 case ValID::ConstSIntVal: // Is it a constant pool reference??
381 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64))
382 ThrowException("Signed integral constant '" +
383 itostr(D.ConstPool64) + "' is invalid for type '" +
384 Ty->getDescription() + "'!");
385 return ConstantSInt::get(Ty, D.ConstPool64);
386
387 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
388 if (!ConstantUInt::isValueValidForType(Ty, D.UConstPool64)) {
389 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) {
390 ThrowException("Integral constant '" + utostr(D.UConstPool64) +
391 "' is invalid or out of range!");
392 } else { // This is really a signed reference. Transmogrify.
393 return ConstantSInt::get(Ty, D.ConstPool64);
394 }
395 } else {
396 return ConstantUInt::get(Ty, D.UConstPool64);
397 }
398
399 case ValID::ConstFPVal: // Is it a floating point const pool reference?
400 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
401 ThrowException("FP constant invalid for type!!");
402 return ConstantFP::get(Ty, D.ConstPoolFP);
403
404 case ValID::ConstNullVal: // Is it a null value?
405 if (!isa<PointerType>(Ty))
406 ThrowException("Cannot create a a non pointer null!");
407 return ConstantPointerNull::get(cast<PointerType>(Ty));
408
409 case ValID::ConstUndefVal: // Is it an undef value?
410 return UndefValue::get(Ty);
411
Chris Lattnera054d122005-12-21 17:53:23 +0000412 case ValID::ConstZeroVal: // Is it a zero value?
413 return Constant::getNullValue(Ty);
414
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000415 case ValID::ConstantVal: // Fully resolved constant?
416 if (D.ConstantValue->getType() != Ty)
417 ThrowException("Constant expression type different from required type!");
418 return D.ConstantValue;
419
Chris Lattnere0a4ee92006-01-25 22:27:16 +0000420 case ValID::InlineAsmVal: { // Inline asm expression
421 const PointerType *PTy = dyn_cast<PointerType>(Ty);
422 const FunctionType *FTy =
423 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
424 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints))
425 ThrowException("Invalid type for asm constraint string!");
426 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
427 D.IAD->HasSideEffects);
428 D.destroy(); // Free InlineAsmDescriptor.
429 return IA;
430 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000431 default:
432 assert(0 && "Unhandled case!");
433 return 0;
434 } // End of switch
435
436 assert(0 && "Unhandled case!");
437 return 0;
438}
439
440// getVal - This function is identical to getValNonImprovising, except that if a
441// value is not already defined, it "improvises" by creating a placeholder var
442// that looks and acts just like the requested variable. When the value is
443// defined later, all uses of the placeholder variable are replaced with the
444// real thing.
445//
446static Value *getVal(const Type *Ty, const ValID &ID) {
447 if (Ty == Type::LabelTy)
448 ThrowException("Cannot use a basic block here");
449
450 // See if the value has already been defined.
451 Value *V = getValNonImprovising(Ty, ID);
452 if (V) return V;
453
454 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
455 ThrowException("Invalid use of a composite type!");
456
457 // If we reached here, we referenced either a symbol that we don't know about
458 // or an id number that hasn't been read yet. We may be referencing something
459 // forward, so just create an entry to be resolved later and get to it...
460 //
461 V = new Argument(Ty);
462
463 // Remember where this forward reference came from. FIXME, shouldn't we try
464 // to recycle these things??
465 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
466 llvmAsmlineno)));
467
468 if (inFunctionScope())
469 InsertValue(V, CurFun.LateResolveValues);
470 else
471 InsertValue(V, CurModule.LateResolveValues);
472 return V;
473}
474
475/// getBBVal - This is used for two purposes:
476/// * If isDefinition is true, a new basic block with the specified ID is being
477/// defined.
478/// * If isDefinition is true, this is a reference to a basic block, which may
479/// or may not be a forward reference.
480///
481static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
482 assert(inFunctionScope() && "Can't get basic block at global scope!");
483
484 std::string Name;
485 BasicBlock *BB = 0;
486 switch (ID.Type) {
487 default: ThrowException("Illegal label reference " + ID.getName());
488 case ValID::NumberVal: // Is it a numbered definition?
489 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
490 CurFun.NumberedBlocks.resize(ID.Num+1);
491 BB = CurFun.NumberedBlocks[ID.Num];
492 break;
493 case ValID::NameVal: // Is it a named definition?
494 Name = ID.Name;
495 if (Value *N = CurFun.CurrentFunction->
496 getSymbolTable().lookup(Type::LabelTy, Name))
497 BB = cast<BasicBlock>(N);
498 break;
499 }
500
501 // See if the block has already been defined.
502 if (BB) {
503 // If this is the definition of the block, make sure the existing value was
504 // just a forward reference. If it was a forward reference, there will be
505 // an entry for it in the PlaceHolderInfo map.
506 if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
507 // The existing value was a definition, not a forward reference.
508 ThrowException("Redefinition of label " + ID.getName());
509
510 ID.destroy(); // Free strdup'd memory.
511 return BB;
512 }
513
514 // Otherwise this block has not been seen before.
515 BB = new BasicBlock("", CurFun.CurrentFunction);
516 if (ID.Type == ValID::NameVal) {
517 BB->setName(ID.Name);
518 } else {
519 CurFun.NumberedBlocks[ID.Num] = BB;
520 }
521
522 // If this is not a definition, keep track of it so we can use it as a forward
523 // reference.
524 if (!isDefinition) {
525 // Remember where this forward reference came from.
526 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
527 } else {
528 // The forward declaration could have been inserted anywhere in the
529 // function: insert it into the correct place now.
530 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
531 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
532 }
533 ID.destroy();
534 return BB;
535}
536
537
538//===----------------------------------------------------------------------===//
539// Code to handle forward references in instructions
540//===----------------------------------------------------------------------===//
541//
542// This code handles the late binding needed with statements that reference
543// values not defined yet... for example, a forward branch, or the PHI node for
544// a loop body.
545//
546// This keeps a table (CurFun.LateResolveValues) of all such forward references
547// and back patchs after we are done.
548//
549
550// ResolveDefinitions - If we could not resolve some defs at parsing
551// time (forward branches, phi functions for loops, etc...) resolve the
552// defs now...
553//
554static void
555ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
556 std::map<const Type*,ValueList> *FutureLateResolvers) {
557 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
558 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
559 E = LateResolvers.end(); LRI != E; ++LRI) {
560 ValueList &List = LRI->second;
561 while (!List.empty()) {
562 Value *V = List.back();
563 List.pop_back();
564
565 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
566 CurModule.PlaceHolderInfo.find(V);
567 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
568
569 ValID &DID = PHI->second.first;
570
571 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
572 if (TheRealValue) {
573 V->replaceAllUsesWith(TheRealValue);
574 delete V;
575 CurModule.PlaceHolderInfo.erase(PHI);
576 } else if (FutureLateResolvers) {
577 // Functions have their unresolved items forwarded to the module late
578 // resolver table
579 InsertValue(V, *FutureLateResolvers);
580 } else {
581 if (DID.Type == ValID::NameVal)
582 ThrowException("Reference to an invalid definition: '" +DID.getName()+
583 "' of type '" + V->getType()->getDescription() + "'",
584 PHI->second.second);
585 else
586 ThrowException("Reference to an invalid definition: #" +
587 itostr(DID.Num) + " of type '" +
588 V->getType()->getDescription() + "'",
589 PHI->second.second);
590 }
591 }
592 }
593
594 LateResolvers.clear();
595}
596
597// ResolveTypeTo - A brand new type was just declared. This means that (if
598// name is not null) things referencing Name can be resolved. Otherwise, things
599// refering to the number can be resolved. Do this now.
600//
601static void ResolveTypeTo(char *Name, const Type *ToTy) {
602 ValID D;
603 if (Name) D = ValID::create(Name);
604 else D = ValID::create((int)CurModule.Types.size());
605
606 std::map<ValID, PATypeHolder>::iterator I =
607 CurModule.LateResolveTypes.find(D);
608 if (I != CurModule.LateResolveTypes.end()) {
609 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
610 CurModule.LateResolveTypes.erase(I);
611 }
612}
613
614// setValueName - Set the specified value to the name given. The name may be
615// null potentially, in which case this is a noop. The string passed in is
616// assumed to be a malloc'd string buffer, and is free'd by this function.
617//
618static void setValueName(Value *V, char *NameStr) {
619 if (NameStr) {
620 std::string Name(NameStr); // Copy string
621 free(NameStr); // Free old string
622
623 if (V->getType() == Type::VoidTy)
624 ThrowException("Can't assign name '" + Name+"' to value with void type!");
625
626 assert(inFunctionScope() && "Must be in function scope!");
627 SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable();
628 if (ST.lookup(V->getType(), Name))
629 ThrowException("Redefinition of value named '" + Name + "' in the '" +
630 V->getType()->getDescription() + "' type plane!");
631
632 // Set the name.
633 V->setName(Name);
634 }
635}
636
637/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
638/// this is a declaration, otherwise it is a definition.
Chris Lattner11ca4d62005-11-12 18:22:38 +0000639static GlobalVariable *
640ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
641 bool isConstantGlobal, const Type *Ty,
642 Constant *Initializer) {
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000643 if (isa<FunctionType>(Ty))
644 ThrowException("Cannot declare global vars of function type!");
645
646 const PointerType *PTy = PointerType::get(Ty);
647
648 std::string Name;
649 if (NameStr) {
650 Name = NameStr; // Copy string
651 free(NameStr); // Free old string
652 }
653
654 // See if this global value was forward referenced. If so, recycle the
655 // object.
656 ValID ID;
657 if (!Name.empty()) {
658 ID = ValID::create((char*)Name.c_str());
659 } else {
660 ID = ValID::create((int)CurModule.Values[PTy].size());
661 }
662
663 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
664 // Move the global to the end of the list, from whereever it was
665 // previously inserted.
666 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
667 CurModule.CurrentModule->getGlobalList().remove(GV);
668 CurModule.CurrentModule->getGlobalList().push_back(GV);
669 GV->setInitializer(Initializer);
670 GV->setLinkage(Linkage);
671 GV->setConstant(isConstantGlobal);
672 InsertValue(GV, CurModule.Values);
Chris Lattner11ca4d62005-11-12 18:22:38 +0000673 return GV;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000674 }
675
676 // If this global has a name, check to see if there is already a definition
677 // of this global in the module. If so, merge as appropriate. Note that
678 // this is really just a hack around problems in the CFE. :(
679 if (!Name.empty()) {
680 // We are a simple redefinition of a value, check to see if it is defined
681 // the same as the old one.
682 if (GlobalVariable *EGV =
683 CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
684 // We are allowed to redefine a global variable in two circumstances:
685 // 1. If at least one of the globals is uninitialized or
686 // 2. If both initializers have the same value.
687 //
688 if (!EGV->hasInitializer() || !Initializer ||
689 EGV->getInitializer() == Initializer) {
690
691 // Make sure the existing global version gets the initializer! Make
692 // sure that it also gets marked const if the new version is.
693 if (Initializer && !EGV->hasInitializer())
694 EGV->setInitializer(Initializer);
695 if (isConstantGlobal)
696 EGV->setConstant(true);
697 EGV->setLinkage(Linkage);
Chris Lattner11ca4d62005-11-12 18:22:38 +0000698 return EGV;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000699 }
700
701 ThrowException("Redefinition of global variable named '" + Name +
702 "' in the '" + Ty->getDescription() + "' type plane!");
703 }
704 }
705
706 // Otherwise there is no existing GV to use, create one now.
707 GlobalVariable *GV =
708 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
709 CurModule.CurrentModule);
710 InsertValue(GV, CurModule.Values);
Chris Lattner11ca4d62005-11-12 18:22:38 +0000711 return GV;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000712}
713
714// setTypeName - Set the specified type to the name given. The name may be
715// null potentially, in which case this is a noop. The string passed in is
716// assumed to be a malloc'd string buffer, and is freed by this function.
717//
718// This function returns true if the type has already been defined, but is
719// allowed to be redefined in the specified context. If the name is a new name
720// for the type plane, it is inserted and false is returned.
721static bool setTypeName(const Type *T, char *NameStr) {
722 assert(!inFunctionScope() && "Can't give types function-local names!");
723 if (NameStr == 0) return false;
724
725 std::string Name(NameStr); // Copy string
726 free(NameStr); // Free old string
727
728 // We don't allow assigning names to void type
729 if (T == Type::VoidTy)
730 ThrowException("Can't assign name '" + Name + "' to the void type!");
731
732 // Set the type name, checking for conflicts as we do so.
733 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
734
735 if (AlreadyExists) { // Inserting a name that is already defined???
736 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
737 assert(Existing && "Conflict but no matching type?");
738
739 // There is only one case where this is allowed: when we are refining an
740 // opaque type. In this case, Existing will be an opaque type.
741 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
742 // We ARE replacing an opaque type!
743 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
744 return true;
745 }
746
747 // Otherwise, this is an attempt to redefine a type. That's okay if
748 // the redefinition is identical to the original. This will be so if
749 // Existing and T point to the same Type object. In this one case we
750 // allow the equivalent redefinition.
751 if (Existing == T) return true; // Yes, it's equal.
752
753 // Any other kind of (non-equivalent) redefinition is an error.
754 ThrowException("Redefinition of type named '" + Name + "' in the '" +
755 T->getDescription() + "' type plane!");
756 }
757
758 return false;
759}
760
761//===----------------------------------------------------------------------===//
762// Code for handling upreferences in type names...
763//
764
765// TypeContains - Returns true if Ty directly contains E in it.
766//
767static bool TypeContains(const Type *Ty, const Type *E) {
768 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
769 E) != Ty->subtype_end();
770}
771
772namespace {
773 struct UpRefRecord {
774 // NestingLevel - The number of nesting levels that need to be popped before
775 // this type is resolved.
776 unsigned NestingLevel;
777
778 // LastContainedTy - This is the type at the current binding level for the
779 // type. Every time we reduce the nesting level, this gets updated.
780 const Type *LastContainedTy;
781
782 // UpRefTy - This is the actual opaque type that the upreference is
783 // represented with.
784 OpaqueType *UpRefTy;
785
786 UpRefRecord(unsigned NL, OpaqueType *URTy)
787 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
788 };
789}
790
791// UpRefs - A list of the outstanding upreferences that need to be resolved.
792static std::vector<UpRefRecord> UpRefs;
793
794/// HandleUpRefs - Every time we finish a new layer of types, this function is
795/// called. It loops through the UpRefs vector, which is a list of the
796/// currently active types. For each type, if the up reference is contained in
797/// the newly completed type, we decrement the level count. When the level
798/// count reaches zero, the upreferenced type is the type that is passed in:
799/// thus we can complete the cycle.
800///
801static PATypeHolder HandleUpRefs(const Type *ty) {
802 if (!ty->isAbstract()) return ty;
803 PATypeHolder Ty(ty);
804 UR_OUT("Type '" << Ty->getDescription() <<
805 "' newly formed. Resolving upreferences.\n" <<
806 UpRefs.size() << " upreferences active!\n");
807
808 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
809 // to zero), we resolve them all together before we resolve them to Ty. At
810 // the end of the loop, if there is anything to resolve to Ty, it will be in
811 // this variable.
812 OpaqueType *TypeToResolve = 0;
813
814 for (unsigned i = 0; i != UpRefs.size(); ++i) {
815 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
816 << UpRefs[i].second->getDescription() << ") = "
817 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
818 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
819 // Decrement level of upreference
820 unsigned Level = --UpRefs[i].NestingLevel;
821 UpRefs[i].LastContainedTy = Ty;
822 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
823 if (Level == 0) { // Upreference should be resolved!
824 if (!TypeToResolve) {
825 TypeToResolve = UpRefs[i].UpRefTy;
826 } else {
827 UR_OUT(" * Resolving upreference for "
828 << UpRefs[i].second->getDescription() << "\n";
829 std::string OldName = UpRefs[i].UpRefTy->getDescription());
830 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
831 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
832 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
833 }
834 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
835 --i; // Do not skip the next element...
836 }
837 }
838 }
839
840 if (TypeToResolve) {
841 UR_OUT(" * Resolving upreference for "
842 << UpRefs[i].second->getDescription() << "\n";
843 std::string OldName = TypeToResolve->getDescription());
844 TypeToResolve->refineAbstractTypeTo(Ty);
845 }
846
847 return Ty;
848}
849
850
851// common code from the two 'RunVMAsmParser' functions
852 static Module * RunParser(Module * M) {
853
854 llvmAsmlineno = 1; // Reset the current line number...
855 ObsoleteVarArgs = false;
856 NewVarArgs = false;
857
858 CurModule.CurrentModule = M;
859 yyparse(); // Parse the file, potentially throwing exception
860
861 Module *Result = ParserResult;
862 ParserResult = 0;
863
864 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
865 {
866 Function* F;
867 if ((F = Result->getNamedFunction("llvm.va_start"))
868 && F->getFunctionType()->getNumParams() == 0)
869 ObsoleteVarArgs = true;
870 if((F = Result->getNamedFunction("llvm.va_copy"))
871 && F->getFunctionType()->getNumParams() == 1)
872 ObsoleteVarArgs = true;
873 }
874
875 if (ObsoleteVarArgs && NewVarArgs)
876 ThrowException("This file is corrupt: it uses both new and old style varargs");
877
878 if(ObsoleteVarArgs) {
879 if(Function* F = Result->getNamedFunction("llvm.va_start")) {
880 if (F->arg_size() != 0)
881 ThrowException("Obsolete va_start takes 0 argument!");
882
883 //foo = va_start()
884 // ->
885 //bar = alloca typeof(foo)
886 //va_start(bar)
887 //foo = load bar
888
889 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
890 const Type* ArgTy = F->getFunctionType()->getReturnType();
891 const Type* ArgTyPtr = PointerType::get(ArgTy);
892 Function* NF = Result->getOrInsertFunction("llvm.va_start",
Jeff Cohen11e26b52005-10-23 04:37:20 +0000893 RetTy, ArgTyPtr, (Type *)0);
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000894
895 while (!F->use_empty()) {
896 CallInst* CI = cast<CallInst>(F->use_back());
897 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
898 new CallInst(NF, bar, "", CI);
899 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
900 CI->replaceAllUsesWith(foo);
901 CI->getParent()->getInstList().erase(CI);
902 }
903 Result->getFunctionList().erase(F);
904 }
905
906 if(Function* F = Result->getNamedFunction("llvm.va_end")) {
907 if(F->arg_size() != 1)
908 ThrowException("Obsolete va_end takes 1 argument!");
909
910 //vaend foo
911 // ->
912 //bar = alloca 1 of typeof(foo)
913 //vaend bar
914 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
915 const Type* ArgTy = F->getFunctionType()->getParamType(0);
916 const Type* ArgTyPtr = PointerType::get(ArgTy);
917 Function* NF = Result->getOrInsertFunction("llvm.va_end",
Jeff Cohen11e26b52005-10-23 04:37:20 +0000918 RetTy, ArgTyPtr, (Type *)0);
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000919
920 while (!F->use_empty()) {
921 CallInst* CI = cast<CallInst>(F->use_back());
922 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
923 new StoreInst(CI->getOperand(1), bar, CI);
924 new CallInst(NF, bar, "", CI);
925 CI->getParent()->getInstList().erase(CI);
926 }
927 Result->getFunctionList().erase(F);
928 }
929
930 if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
931 if(F->arg_size() != 1)
932 ThrowException("Obsolete va_copy takes 1 argument!");
933 //foo = vacopy(bar)
934 // ->
935 //a = alloca 1 of typeof(foo)
936 //b = alloca 1 of typeof(foo)
937 //store bar -> b
938 //vacopy(a, b)
939 //foo = load a
940
941 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
942 const Type* ArgTy = F->getFunctionType()->getReturnType();
943 const Type* ArgTyPtr = PointerType::get(ArgTy);
944 Function* NF = Result->getOrInsertFunction("llvm.va_copy",
Jeff Cohen11e26b52005-10-23 04:37:20 +0000945 RetTy, ArgTyPtr, ArgTyPtr,
946 (Type *)0);
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000947
948 while (!F->use_empty()) {
949 CallInst* CI = cast<CallInst>(F->use_back());
950 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
951 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
952 new StoreInst(CI->getOperand(1), b, CI);
953 new CallInst(NF, a, b, "", CI);
954 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
955 CI->replaceAllUsesWith(foo);
956 CI->getParent()->getInstList().erase(CI);
957 }
958 Result->getFunctionList().erase(F);
959 }
960 }
961
962 return Result;
963
964 }
965
966//===----------------------------------------------------------------------===//
967// RunVMAsmParser - Define an interface to this parser
968//===----------------------------------------------------------------------===//
969//
970Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
971 set_scan_file(F);
972
973 CurFilename = Filename;
974 return RunParser(new Module(CurFilename));
975}
976
977Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
978 set_scan_string(AsmString);
979
980 CurFilename = "from_memory";
981 if (M == NULL) {
982 return RunParser(new Module (CurFilename));
983 } else {
984 return RunParser(M);
985 }
986}
987
988
Chris Lattnere0a4ee92006-01-25 22:27:16 +0000989#line 890 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +0000990typedef union {
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000991 llvm::Module *ModuleVal;
992 llvm::Function *FunctionVal;
993 std::pair<llvm::PATypeHolder*, char*> *ArgVal;
994 llvm::BasicBlock *BasicBlockVal;
995 llvm::TerminatorInst *TermInstVal;
996 llvm::Instruction *InstVal;
997 llvm::Constant *ConstVal;
998
999 const llvm::Type *PrimType;
1000 llvm::PATypeHolder *TypeVal;
1001 llvm::Value *ValueVal;
1002
1003 std::vector<std::pair<llvm::PATypeHolder*,char*> > *ArgList;
1004 std::vector<llvm::Value*> *ValueList;
1005 std::list<llvm::PATypeHolder> *TypeList;
1006 // Represent the RHS of PHI node
1007 std::list<std::pair<llvm::Value*,
1008 llvm::BasicBlock*> > *PHIList;
1009 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1010 std::vector<llvm::Constant*> *ConstVector;
1011
1012 llvm::GlobalValue::LinkageTypes Linkage;
1013 int64_t SInt64Val;
1014 uint64_t UInt64Val;
1015 int SIntVal;
1016 unsigned UIntVal;
1017 double FPVal;
1018 bool BoolVal;
1019
1020 char *StrVal; // This memory is strdup'd!
1021 llvm::ValID ValIDVal; // strdup'd memory maybe!
1022
1023 llvm::Instruction::BinaryOps BinaryOpVal;
1024 llvm::Instruction::TermOps TermOpVal;
1025 llvm::Instruction::MemoryOps MemOpVal;
1026 llvm::Instruction::OtherOps OtherOpVal;
1027 llvm::Module::Endianness Endianness;
1028} YYSTYPE;
Chris Lattneredd9b032006-01-23 23:05:42 +00001029#include <stdio.h>
1030
1031#ifndef __cplusplus
1032#ifndef __STDC__
1033#define const
1034#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001035#endif
1036
1037
1038
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001039#define YYFINAL 473
Chris Lattneredd9b032006-01-23 23:05:42 +00001040#define YYFLAG -32768
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001041#define YYNTBASE 115
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001042
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001043#define YYTRANSLATE(x) ((unsigned)(x) <= 354 ? yytranslate[x] : 186)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001044
Chris Lattneredd9b032006-01-23 23:05:42 +00001045static const char yytranslate[] = { 0,
1046 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1047 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1048 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001049 2, 2, 2, 2, 2, 2, 2, 2, 2, 104,
1050 105, 113, 2, 102, 2, 2, 2, 2, 2, 2,
1051 2, 2, 2, 2, 2, 2, 2, 2, 2, 109,
1052 101, 110, 2, 2, 2, 2, 2, 2, 2, 2,
Chris Lattneredd9b032006-01-23 23:05:42 +00001053 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1054 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001055 106, 103, 108, 2, 2, 2, 2, 2, 114, 2,
Chris Lattneredd9b032006-01-23 23:05:42 +00001056 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001057 2, 2, 2, 2, 2, 2, 2, 2, 2, 107,
1058 2, 2, 111, 2, 112, 2, 2, 2, 2, 2,
Chris Lattneredd9b032006-01-23 23:05:42 +00001059 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1060 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1061 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1062 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1063 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1064 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1065 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1066 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1067 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1068 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1069 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1070 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1071 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
1072 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1073 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1074 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
1075 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
1076 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
1077 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1078 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1079 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1080 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001081 97, 98, 99, 100
Chris Lattneredd9b032006-01-23 23:05:42 +00001082};
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001083
Chris Lattneredd9b032006-01-23 23:05:42 +00001084#if YYDEBUG != 0
1085static const short yyprhs[] = { 0,
1086 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
1087 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
1088 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
1089 60, 62, 64, 67, 68, 70, 72, 74, 76, 77,
1090 78, 80, 82, 84, 87, 88, 91, 92, 96, 99,
1091 100, 102, 103, 107, 109, 112, 114, 116, 118, 120,
1092 122, 124, 126, 128, 130, 132, 134, 136, 138, 140,
1093 142, 144, 146, 148, 150, 152, 154, 157, 162, 168,
1094 174, 178, 181, 184, 186, 190, 192, 196, 198, 199,
1095 204, 208, 212, 217, 222, 226, 229, 232, 235, 238,
1096 241, 244, 247, 250, 253, 256, 263, 269, 278, 285,
1097 292, 299, 306, 313, 317, 319, 321, 323, 325, 328,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001098 331, 336, 339, 341, 346, 349, 354, 355, 363, 364,
1099 372, 376, 381, 382, 384, 386, 388, 392, 396, 400,
1100 404, 408, 410, 411, 413, 415, 417, 418, 421, 425,
1101 427, 429, 433, 435, 436, 445, 447, 449, 453, 455,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001102 457, 460, 461, 465, 466, 468, 470, 472, 474, 476,
1103 478, 480, 482, 484, 488, 490, 496, 498, 500, 502,
1104 504, 507, 510, 513, 517, 520, 521, 523, 526, 529,
1105 533, 543, 553, 562, 576, 578, 580, 587, 593, 596,
1106 603, 611, 613, 617, 619, 620, 623, 625, 631, 637,
1107 643, 646, 651, 656, 663, 668, 673, 678, 683, 690,
1108 693, 701, 703, 706, 707, 709, 710, 714, 721, 725,
1109 732, 735, 740, 747
Chris Lattneredd9b032006-01-23 23:05:42 +00001110};
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001111
Chris Lattneredd9b032006-01-23 23:05:42 +00001112static const short yyrhs[] = { 5,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001113 0, 6, 0, 3, 0, 4, 0, 71, 0, 72,
1114 0, 73, 0, 74, 0, 75, 0, 76, 0, 77,
1115 0, 78, 0, 79, 0, 80, 0, 81, 0, 82,
1116 0, 83, 0, 84, 0, 94, 0, 95, 0, 16,
Chris Lattneredd9b032006-01-23 23:05:42 +00001117 0, 14, 0, 12, 0, 10, 0, 17, 0, 15,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001118 0, 13, 0, 11, 0, 121, 0, 122, 0, 18,
1119 0, 19, 0, 155, 101, 0, 0, 41, 0, 42,
1120 0, 43, 0, 44, 0, 0, 0, 62, 0, 63,
1121 0, 64, 0, 61, 4, 0, 0, 54, 4, 0,
1122 0, 102, 54, 4, 0, 34, 24, 0, 0, 130,
1123 0, 0, 102, 133, 132, 0, 130, 0, 54, 4,
1124 0, 136, 0, 8, 0, 138, 0, 8, 0, 138,
Chris Lattneredd9b032006-01-23 23:05:42 +00001125 0, 9, 0, 10, 0, 11, 0, 12, 0, 13,
1126 0, 14, 0, 15, 0, 16, 0, 17, 0, 18,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001127 0, 19, 0, 20, 0, 21, 0, 45, 0, 137,
1128 0, 169, 0, 103, 4, 0, 135, 104, 140, 105,
1129 0, 106, 4, 107, 138, 108, 0, 109, 4, 107,
1130 138, 110, 0, 111, 139, 112, 0, 111, 112, 0,
1131 138, 113, 0, 138, 0, 139, 102, 138, 0, 139,
1132 0, 139, 102, 37, 0, 37, 0, 0, 136, 106,
1133 143, 108, 0, 136, 106, 108, 0, 136, 114, 24,
1134 0, 136, 109, 143, 110, 0, 136, 111, 143, 112,
1135 0, 136, 111, 112, 0, 136, 38, 0, 136, 39,
1136 0, 136, 169, 0, 136, 142, 0, 136, 26, 0,
1137 121, 116, 0, 122, 4, 0, 9, 27, 0, 9,
1138 28, 0, 124, 7, 0, 92, 104, 141, 36, 136,
1139 105, 0, 90, 104, 141, 183, 105, 0, 93, 104,
1140 141, 102, 141, 102, 141, 105, 0, 117, 104, 141,
1141 102, 141, 105, 0, 118, 104, 141, 102, 141, 105,
1142 0, 119, 104, 141, 102, 141, 105, 0, 120, 104,
1143 141, 102, 141, 105, 0, 97, 104, 141, 102, 141,
1144 105, 0, 143, 102, 141, 0, 141, 0, 32, 0,
1145 33, 0, 146, 0, 146, 164, 0, 146, 165, 0,
1146 146, 59, 58, 150, 0, 146, 25, 0, 147, 0,
1147 147, 125, 20, 134, 0, 147, 165, 0, 147, 59,
1148 58, 150, 0, 0, 147, 125, 126, 144, 141, 148,
1149 132, 0, 0, 147, 125, 47, 144, 136, 149, 132,
1150 0, 147, 48, 152, 0, 147, 55, 101, 153, 0,
1151 0, 24, 0, 53, 0, 52, 0, 50, 101, 151,
1152 0, 51, 101, 4, 0, 49, 101, 24, 0, 106,
1153 154, 108, 0, 154, 102, 24, 0, 24, 0, 0,
1154 22, 0, 24, 0, 155, 0, 0, 136, 156, 0,
1155 158, 102, 157, 0, 157, 0, 158, 0, 158, 102,
1156 37, 0, 37, 0, 0, 127, 134, 155, 104, 159,
1157 105, 131, 128, 0, 29, 0, 111, 0, 126, 160,
1158 161, 0, 30, 0, 112, 0, 172, 163, 0, 0,
1159 31, 166, 160, 0, 0, 60, 0, 3, 0, 4,
1160 0, 7, 0, 27, 0, 28, 0, 38, 0, 39,
1161 0, 26, 0, 109, 143, 110, 0, 142, 0, 58,
1162 167, 24, 102, 24, 0, 115, 0, 155, 0, 169,
1163 0, 168, 0, 136, 170, 0, 172, 173, 0, 162,
1164 173, 0, 174, 125, 175, 0, 174, 177, 0, 0,
1165 23, 0, 65, 171, 0, 65, 8, 0, 66, 21,
1166 170, 0, 66, 9, 170, 102, 21, 170, 102, 21,
1167 170, 0, 67, 123, 170, 102, 21, 170, 106, 176,
1168 108, 0, 67, 123, 170, 102, 21, 170, 106, 108,
1169 0, 68, 127, 134, 170, 104, 180, 105, 36, 21,
1170 170, 69, 21, 170, 0, 69, 0, 70, 0, 176,
1171 123, 168, 102, 21, 170, 0, 123, 168, 102, 21,
1172 170, 0, 125, 182, 0, 136, 106, 170, 102, 170,
1173 108, 0, 178, 102, 106, 170, 102, 170, 108, 0,
1174 171, 0, 179, 102, 171, 0, 179, 0, 0, 57,
1175 56, 0, 56, 0, 117, 136, 170, 102, 170, 0,
1176 118, 136, 170, 102, 170, 0, 119, 136, 170, 102,
1177 170, 0, 46, 171, 0, 120, 171, 102, 171, 0,
1178 92, 171, 36, 136, 0, 93, 171, 102, 171, 102,
1179 171, 0, 96, 171, 102, 136, 0, 99, 171, 102,
1180 136, 0, 100, 171, 102, 136, 0, 97, 171, 102,
1181 171, 0, 98, 171, 102, 171, 102, 171, 0, 91,
1182 178, 0, 181, 127, 134, 170, 104, 180, 105, 0,
1183 185, 0, 102, 179, 0, 0, 35, 0, 0, 85,
1184 136, 129, 0, 85, 136, 102, 15, 170, 129, 0,
1185 86, 136, 129, 0, 86, 136, 102, 15, 170, 129,
1186 0, 87, 171, 0, 184, 88, 136, 170, 0, 184,
1187 89, 171, 102, 136, 170, 0, 90, 136, 170, 183,
1188 0
Chris Lattneredd9b032006-01-23 23:05:42 +00001189};
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001190
1191#endif
1192
Chris Lattneredd9b032006-01-23 23:05:42 +00001193#if YYDEBUG != 0
1194static const short yyrline[] = { 0,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001195 1010, 1011, 1018, 1019, 1028, 1028, 1028, 1028, 1028, 1029,
1196 1029, 1029, 1030, 1030, 1030, 1030, 1030, 1030, 1032, 1032,
1197 1036, 1036, 1036, 1036, 1037, 1037, 1037, 1037, 1038, 1038,
1198 1039, 1039, 1042, 1045, 1049, 1049, 1050, 1051, 1052, 1055,
1199 1055, 1056, 1057, 1058, 1067, 1067, 1073, 1073, 1081, 1088,
1200 1088, 1094, 1094, 1096, 1100, 1113, 1113, 1114, 1114, 1116,
1201 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1126, 1126, 1126,
1202 1126, 1126, 1126, 1127, 1130, 1133, 1139, 1146, 1158, 1162,
1203 1173, 1182, 1185, 1193, 1197, 1202, 1203, 1206, 1209, 1219,
1204 1244, 1257, 1286, 1311, 1331, 1343, 1352, 1356, 1415, 1421,
1205 1429, 1434, 1439, 1442, 1445, 1452, 1462, 1493, 1500, 1521,
1206 1531, 1536, 1543, 1553, 1556, 1563, 1563, 1573, 1580, 1584,
1207 1587, 1590, 1593, 1606, 1626, 1628, 1630, 1633, 1636, 1640,
1208 1643, 1645, 1647, 1651, 1663, 1664, 1666, 1669, 1677, 1682,
1209 1684, 1688, 1692, 1700, 1700, 1701, 1701, 1703, 1709, 1714,
1210 1720, 1723, 1728, 1732, 1736, 1822, 1822, 1824, 1832, 1832,
1211 1834, 1838, 1838, 1847, 1850, 1854, 1857, 1860, 1863, 1866,
1212 1869, 1872, 1875, 1878, 1902, 1905, 1918, 1921, 1926, 1926,
1213 1932, 1936, 1939, 1947, 1956, 1960, 1970, 1981, 1984, 1987,
1214 1990, 1993, 2007, 2011, 2064, 2067, 2073, 2081, 2091, 2098,
1215 2103, 2110, 2114, 2120, 2120, 2122, 2125, 2131, 2143, 2154,
1216 2164, 2176, 2183, 2190, 2197, 2202, 2221, 2243, 2251, 2263,
1217 2277, 2334, 2340, 2342, 2346, 2349, 2355, 2359, 2363, 2367,
1218 2371, 2378, 2388, 2401
Chris Lattneredd9b032006-01-23 23:05:42 +00001219};
1220#endif
1221
1222
1223#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
1224
1225static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL",
1226"EUINT64VAL","SINTVAL","UINTVAL","FPVAL","VOID","BOOL","SBYTE","UBYTE","SHORT",
1227"USHORT","INT","UINT","LONG","ULONG","FLOAT","DOUBLE","TYPE","LABEL","VAR_ID",
1228"LABELSTR","STRINGCONSTANT","IMPLEMENTATION","ZEROINITIALIZER","TRUETOK","FALSETOK",
1229"BEGINTOK","ENDTOK","DECLARE","GLOBAL","CONSTANT","SECTION","VOLATILE","TO",
1230"DOTDOTDOT","NULL_TOK","UNDEF","CONST","INTERNAL","LINKONCE","WEAK","APPENDING",
1231"OPAQUE","NOT","EXTERNAL","TARGET","TRIPLE","ENDIAN","POINTERSIZE","LITTLE",
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001232"BIG","ALIGN","DEPLIBS","CALL","TAIL","ASM_TOK","MODULE","SIDEEFFECT","CC_TOK",
1233"CCC_TOK","FASTCC_TOK","COLDCC_TOK","RET","BR","SWITCH","INVOKE","UNWIND","UNREACHABLE",
Chris Lattner8ebd2162006-01-24 04:14:29 +00001234"ADD","SUB","MUL","DIV","REM","AND","OR","XOR","SETLE","SETGE","SETLT","SETGT",
1235"SETEQ","SETNE","MALLOC","ALLOCA","FREE","LOAD","STORE","GETELEMENTPTR","PHI_TOK",
1236"CAST","SELECT","SHL","SHR","VAARG","EXTRACTELEMENT","INSERTELEMENT","VAARG_old",
1237"VANEXT_old","'='","','","'\\\\'","'('","')'","'['","'x'","']'","'<'","'>'",
1238"'{'","'}'","'*'","'c'","INTVAL","EINT64VAL","ArithmeticOps","LogicalOps","SetCondOps",
1239"ShiftOps","SIntType","UIntType","IntType","FPType","OptAssign","OptLinkage",
1240"OptCallingConv","OptAlign","OptCAlign","SectionString","OptSection","GlobalVarAttributes",
1241"GlobalVarAttribute","TypesV","UpRTypesV","Types","PrimType","UpRTypes","TypeListI",
1242"ArgTypeListI","ConstVal","ConstExpr","ConstVector","GlobalType","Module","FunctionList",
1243"ConstPool","@1","@2","AsmBlock","BigOrLittle","TargetDefinition","LibrariesDefinition",
Chris Lattneredd9b032006-01-23 23:05:42 +00001244"LibList","Name","OptName","ArgVal","ArgListH","ArgList","FunctionHeaderH","BEGIN",
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001245"FunctionHeader","END","Function","FunctionProto","@3","OptSideEffect","ConstValueRef",
1246"SymbolicValueRef","ValueRef","ResolvedVal","BasicBlockList","BasicBlock","InstructionList",
1247"BBTerminatorInst","JumpTable","Inst","PHIList","ValueRefList","ValueRefListE",
1248"OptTailCall","InstVal","IndexList","OptVolatile","MemoryInst", NULL
Chris Lattneredd9b032006-01-23 23:05:42 +00001249};
1250#endif
1251
1252static const short yyr1[] = { 0,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001253 115, 115, 116, 116, 117, 117, 117, 117, 117, 118,
1254 118, 118, 119, 119, 119, 119, 119, 119, 120, 120,
1255 121, 121, 121, 121, 122, 122, 122, 122, 123, 123,
1256 124, 124, 125, 125, 126, 126, 126, 126, 126, 127,
1257 127, 127, 127, 127, 128, 128, 129, 129, 130, 131,
1258 131, 132, 132, 133, 133, 134, 134, 135, 135, 136,
1259 137, 137, 137, 137, 137, 137, 137, 137, 137, 137,
1260 137, 137, 137, 138, 138, 138, 138, 138, 138, 138,
1261 138, 138, 138, 139, 139, 140, 140, 140, 140, 141,
1262 141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
1263 141, 141, 141, 141, 141, 142, 142, 142, 142, 142,
1264 142, 142, 142, 143, 143, 144, 144, 145, 146, 146,
1265 146, 146, 146, 147, 147, 147, 148, 147, 149, 147,
1266 147, 147, 147, 150, 151, 151, 152, 152, 152, 153,
1267 154, 154, 154, 155, 155, 156, 156, 157, 158, 158,
1268 159, 159, 159, 159, 160, 161, 161, 162, 163, 163,
1269 164, 166, 165, 167, 167, 168, 168, 168, 168, 168,
1270 168, 168, 168, 168, 168, 168, 169, 169, 170, 170,
1271 171, 172, 172, 173, 174, 174, 174, 175, 175, 175,
1272 175, 175, 175, 175, 175, 175, 176, 176, 177, 178,
1273 178, 179, 179, 180, 180, 181, 181, 182, 182, 182,
1274 182, 182, 182, 182, 182, 182, 182, 182, 182, 182,
1275 182, 182, 183, 183, 184, 184, 185, 185, 185, 185,
1276 185, 185, 185, 185
Chris Lattneredd9b032006-01-23 23:05:42 +00001277};
1278
1279static const short yyr2[] = { 0,
1280 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1281 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1282 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1283 1, 1, 2, 0, 1, 1, 1, 1, 0, 0,
1284 1, 1, 1, 2, 0, 2, 0, 3, 2, 0,
1285 1, 0, 3, 1, 2, 1, 1, 1, 1, 1,
1286 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1287 1, 1, 1, 1, 1, 1, 2, 4, 5, 5,
1288 3, 2, 2, 1, 3, 1, 3, 1, 0, 4,
1289 3, 3, 4, 4, 3, 2, 2, 2, 2, 2,
1290 2, 2, 2, 2, 2, 6, 5, 8, 6, 6,
1291 6, 6, 6, 3, 1, 1, 1, 1, 2, 2,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001292 4, 2, 1, 4, 2, 4, 0, 7, 0, 7,
Chris Lattneredd9b032006-01-23 23:05:42 +00001293 3, 4, 0, 1, 1, 1, 3, 3, 3, 3,
1294 3, 1, 0, 1, 1, 1, 0, 2, 3, 1,
1295 1, 3, 1, 0, 8, 1, 1, 3, 1, 1,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001296 2, 0, 3, 0, 1, 1, 1, 1, 1, 1,
1297 1, 1, 1, 3, 1, 5, 1, 1, 1, 1,
1298 2, 2, 2, 3, 2, 0, 1, 2, 2, 3,
1299 9, 9, 8, 13, 1, 1, 6, 5, 2, 6,
1300 7, 1, 3, 1, 0, 2, 1, 5, 5, 5,
1301 2, 4, 4, 6, 4, 4, 4, 4, 6, 2,
1302 7, 1, 2, 0, 1, 0, 3, 6, 3, 6,
1303 2, 4, 6, 4
Chris Lattneredd9b032006-01-23 23:05:42 +00001304};
1305
1306static const short yydefact[] = { 133,
1307 39, 123, 122, 162, 35, 36, 37, 38, 0, 40,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001308 186, 119, 120, 186, 144, 145, 0, 0, 0, 39,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001309 0, 125, 40, 0, 0, 41, 42, 43, 0, 0,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001310 187, 183, 34, 159, 160, 161, 182, 0, 0, 0,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001311 131, 0, 0, 0, 0, 0, 33, 163, 134, 121,
1312 44, 1, 2, 57, 61, 62, 63, 64, 65, 66,
1313 67, 68, 69, 70, 71, 72, 73, 74, 0, 0,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001314 0, 0, 177, 0, 0, 56, 75, 60, 178, 76,
1315 156, 157, 158, 226, 185, 0, 0, 0, 143, 132,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001316 126, 124, 116, 117, 0, 0, 77, 0, 0, 59,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001317 82, 84, 0, 0, 89, 83, 225, 0, 207, 0,
1318 0, 0, 0, 40, 195, 196, 5, 6, 7, 8,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001319 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
1320 0, 0, 0, 0, 0, 0, 0, 19, 20, 0,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001321 0, 0, 0, 0, 0, 0, 0, 0, 184, 40,
1322 199, 0, 222, 139, 136, 135, 137, 138, 142, 0,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001323 129, 61, 62, 63, 64, 65, 66, 67, 68, 69,
1324 70, 71, 0, 0, 0, 0, 127, 0, 0, 0,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001325 81, 154, 88, 86, 0, 0, 211, 206, 189, 188,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001326 0, 0, 24, 28, 23, 27, 22, 26, 21, 25,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001327 29, 30, 0, 0, 47, 47, 231, 0, 0, 220,
Chris Lattneredd9b032006-01-23 23:05:42 +00001328 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001329 0, 0, 0, 0, 0, 140, 52, 103, 104, 3,
1330 4, 101, 102, 105, 100, 96, 97, 0, 0, 0,
1331 0, 0, 0, 0, 0, 0, 0, 0, 0, 99,
1332 98, 52, 58, 58, 85, 153, 147, 150, 151, 0,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001333 0, 78, 166, 167, 168, 173, 169, 170, 171, 172,
1334 164, 0, 175, 180, 179, 181, 0, 190, 0, 0,
1335 0, 227, 0, 229, 224, 0, 0, 0, 0, 0,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001336 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001337 0, 141, 0, 130, 0, 0, 0, 0, 91, 115,
1338 0, 0, 95, 0, 92, 0, 0, 0, 0, 128,
1339 79, 80, 146, 148, 0, 50, 87, 165, 0, 0,
1340 0, 0, 0, 0, 0, 0, 0, 234, 0, 0,
1341 213, 0, 215, 218, 0, 216, 217, 0, 0, 0,
1342 212, 0, 232, 0, 0, 0, 54, 52, 224, 0,
1343 0, 0, 0, 90, 93, 94, 0, 0, 0, 0,
1344 152, 149, 51, 45, 0, 174, 0, 0, 205, 47,
1345 48, 47, 202, 223, 0, 0, 0, 0, 208, 209,
1346 210, 205, 0, 49, 55, 53, 0, 0, 0, 0,
1347 114, 0, 0, 0, 0, 0, 155, 0, 0, 0,
1348 204, 0, 0, 228, 230, 0, 0, 0, 214, 219,
1349 0, 233, 107, 0, 0, 0, 0, 0, 0, 0,
1350 46, 176, 0, 0, 0, 203, 200, 0, 221, 106,
1351 0, 113, 109, 110, 111, 112, 0, 193, 0, 0,
1352 0, 201, 0, 191, 0, 192, 0, 0, 108, 0,
1353 0, 0, 0, 0, 0, 198, 0, 0, 197, 194,
1354 0, 0, 0
Chris Lattneredd9b032006-01-23 23:05:42 +00001355};
1356
Chris Lattner8ebd2162006-01-24 04:14:29 +00001357static const short yydefgoto[] = { 73,
1358 232, 246, 247, 248, 249, 173, 174, 203, 175, 20,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001359 10, 29, 407, 282, 357, 374, 304, 358, 74, 75,
1360 186, 77, 78, 103, 185, 310, 273, 311, 95, 471,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001361 1, 2, 252, 227, 50, 157, 41, 90, 160, 79,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001362 324, 258, 259, 260, 30, 83, 11, 36, 12, 13,
1363 23, 329, 274, 80, 276, 383, 14, 32, 33, 149,
1364 450, 85, 210, 411, 412, 150, 151, 338, 152, 153
Chris Lattneredd9b032006-01-23 23:05:42 +00001365};
1366
1367static const short yypact[] = {-32768,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001368 30, 99,-32768,-32768,-32768,-32768,-32768,-32768, -47, 46,
1369 33,-32768,-32768, -13,-32768,-32768, 75, -32, 26, 21,
1370 -3,-32768, 46, 63, 100,-32768,-32768,-32768, 974, -21,
1371-32768,-32768, 105,-32768,-32768,-32768,-32768, 10, 27, 32,
1372-32768, 38, 63, 974, 103, 103,-32768,-32768,-32768,-32768,
1373-32768,-32768,-32768, 18,-32768,-32768,-32768,-32768,-32768,-32768,
1374-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 135, 148,
1375 155, 490,-32768, 105, 67,-32768,-32768, -64,-32768,-32768,
1376-32768,-32768,-32768, 1136,-32768, 149, 85, 172, 154,-32768,
1377-32768,-32768,-32768,-32768, 1012, 1050,-32768, 73, 76,-32768,
1378-32768, -64, -17, 80, 784,-32768,-32768, 1012,-32768, 129,
1379 1088, 23, 221, 46,-32768,-32768,-32768,-32768,-32768,-32768,
Chris Lattneredd9b032006-01-23 23:05:42 +00001380-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001381 1012, 1012, 1012, 1012, 1012, 1012, 1012,-32768,-32768, 1012,
1382 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012,-32768, 46,
1383-32768, 60,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -14,
1384-32768, 123, 153, 182, 159, 186, 162, 187, 164, 188,
1385 189, 190, 166, 194, 193, 372,-32768, 1012, 1012, 1012,
1386-32768, 822,-32768, 101, 102, 622,-32768,-32768, 18,-32768,
1387 622, 622,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1388-32768,-32768, 622, 974, 104, 107,-32768, 622, 98, 108,
1389 169, 109, 110, 118, 119, 120, 121, 622, 622, 622,
1390 122, 974, 1012, 1012, 201,-32768, 124,-32768,-32768,-32768,
1391-32768,-32768,-32768,-32768,-32768,-32768,-32768, 136, 137, 138,
1392 141, 860, 1050, 531, 215, 142, 143, 144, 146,-32768,
1393-32768, 124, -75, -53, -64,-32768, 105,-32768, 150, 139,
1394 898,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1395 191, 1050,-32768,-32768,-32768,-32768, 151,-32768, 152, 622,
1396 5,-32768, 16,-32768, 158, 622, 156, 1012, 1012, 1012,
1397 1012, 1012, 1012, 1012, 161, 165, 168, 1012, 622, 622,
1398 170,-32768, -18,-32768, 1050, 1050, 1050, 1050,-32768,-32768,
1399 -11, -65,-32768, -16,-32768, 1050, 1050, 1050, 1050,-32768,
1400-32768,-32768,-32768,-32768, 936, 222,-32768,-32768, 233, -10,
1401 245, 250, 171, 622, 269, 622, 1012,-32768, 178, 622,
1402-32768, 179,-32768,-32768, 180,-32768,-32768, 622, 622, 622,
1403-32768, 181,-32768, 1012, 259, 280,-32768, 124, 158, 255,
1404 184, 192, 1050,-32768,-32768,-32768, 197, 198, 199, 200,
1405-32768,-32768,-32768, 238, 202,-32768, 622, 622, 1012, 204,
1406-32768, 204,-32768, 205, 622, 206, 1012, 1012,-32768,-32768,
1407-32768, 1012, 622,-32768,-32768,-32768, 207, 1012, 1050, 1050,
1408-32768, 1050, 1050, 1050, 1050, 289,-32768, 271, 218, 223,
1409 205, 216, 270,-32768,-32768, 1012, 219, 622,-32768,-32768,
1410 225,-32768,-32768, 228, 226, 230, 231, 232, 235, 236,
1411-32768,-32768, 321, 12, 308,-32768,-32768, 237,-32768,-32768,
1412 1050,-32768,-32768,-32768,-32768,-32768, 622,-32768, 682, 66,
1413 328,-32768, 246,-32768, 248,-32768, 682, 622,-32768, 332,
1414 253, 287, 622, 336, 340,-32768, 622, 622,-32768,-32768,
1415 363, 364,-32768
Chris Lattneredd9b032006-01-23 23:05:42 +00001416};
1417
1418static const short yypgoto[] = {-32768,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001419-32768, 281, 282, 283, 284, -112, -111, -415,-32768, 339,
1420 359, -102,-32768, -201, 54,-32768, -243,-32768, -40,-32768,
1421 -29,-32768, -66, 276,-32768, -89, 208, -230, 337,-32768,
1422-32768,-32768,-32768,-32768, 342,-32768,-32768,-32768,-32768, 1,
1423-32768, 57,-32768,-32768, 365,-32768,-32768,-32768,-32768, 384,
1424-32768,-32768, -356, -31, 140, -90,-32768, 375,-32768,-32768,
1425-32768,-32768,-32768, 53, -1,-32768,-32768, 34,-32768,-32768
Chris Lattneredd9b032006-01-23 23:05:42 +00001426};
1427
1428
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001429#define YYLAST 1236
Chris Lattneredd9b032006-01-23 23:05:42 +00001430
1431
Chris Lattner8ebd2162006-01-24 04:14:29 +00001432static const short yytable[] = { 76,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001433 201, 202, 21, 92, 284, 102, 177, 81, 320, 31,
1434 24, 204, 312, 314, 76, 355, 34, 187, 449, 334,
1435 190, 193, 194, 195, 196, 197, 198, 199, 200, -118,
1436 336, 191, 321, 21, 457, 356, 363, 106, 102, -58,
1437 44, 330, 207, 192, 365, 211, 212, 222, 106, 213,
1438 214, 215, 216, 217, 3, 31, 322, 221, 335, 106,
1439 4, 5, 6, 7, 8, 161, 176, 45, 42, 335,
1440 5, 6, 7, 8, 104, 193, 194, 195, 196, 197,
1441 198, 199, 200, 43, 180, 363, 49, 225, 9, 82,
1442 363, 363, 455, 226, 181, 366, 364, 47, 35, 376,
1443 461, 205, 206, 51, 208, 209, 25, 26, 27, 28,
1444 86, 253, 254, 255, 396, 218, 219, 220, -34, 448,
1445 15, -59, 16, 38, 39, 40, 15, 87, 16, 4,
1446 -34, -34, 88, 301, 93, 94, 155, 156, 97, -34,
1447 -34, -34, -34, 89, 251, -34, 17, 223, 224, 228,
1448 229, 98, 257, 18, 275, -24, -24, 19, 99, 275,
1449 275, -23, -23, 280, -22, -22, -21, -21, 230, 231,
1450 105, 275, 154, 456, 76, 158, 275, 159, 414, 178,
1451 415, 299, 179, 182, 188, -28, 275, 275, 275, -27,
1452 -26, -25, 76, 300, 255, -31, -32, 233, 342, 234,
1453 344, 345, 261, 286, 288, 281, 262, 351, 283, 287,
1454 289, 290, 176, 176, 176, 359, 360, 361, 362, 291,
1455 292, 293, 294, 298, 302, 303, 367, 368, 369, 370,
1456 193, 194, 195, 196, 197, 198, 199, 200, 315, 305,
1457 306, 307, 176, 326, 308, 316, 317, 318, 275, 319,
1458 328, 325, 331, 332, 275, 355, 375, 323, 341, 337,
1459 343, 340, 348, 346, 347, 377, 349, 275, 275, 350,
1460 378, 354, 381, 401, 379, 176, 176, 176, 176, 385,
1461 387, 388, 394, 395, 392, 399, 176, 176, 176, 176,
1462 398, 406, 431, 400, 432, 257, 419, 420, 402, 403,
1463 404, 405, 275, 408, 275, 413, 416, 418, 275, 425,
1464 426, 423, 427, 428, 429, 430, 275, 275, 275, 433,
1465 435, 201, 202, 335, 393, 436, 437, 441, 434, 439,
1466 277, 278, 440, 176, 442, 443, 444, 201, 202, 445,
1467 446, 447, 279, 451, 452, 275, 275, 285, 458, 460,
1468 459, 453, 463, 275, 464, 465, 467, 295, 296, 297,
1469 468, 275, 472, 473, 145, 146, 147, 148, 424, 176,
1470 176, 84, 176, 176, 176, 176, 52, 53, 46, 373,
1471 184, 372, 96, 250, 91, 22, 275, 48, 37, 384,
1472 421, 0, 397, 15, 0, 16, 0, 235, 0, 0,
1473 0, 0, 0, 0, 0, 0, 0, 0, 0, 236,
1474 237, 176, 0, 0, 0, 275, 0, 0, 0, 333,
1475 0, 0, 0, 0, 0, 339, 275, 0, 0, 0,
1476 0, 275, 0, 0, 0, 275, 275, 0, 352, 353,
1477 0, 0, 117, 118, 119, 120, 121, 122, 123, 124,
1478 125, 126, 127, 128, 129, 130, 0, 0, 0, 0,
1479 0, 238, 0, 239, 240, 138, 139, 0, 241, 0,
1480 0, 0, 0, 380, 0, 382, 0, 242, 0, 386,
1481 243, 0, 244, 0, 0, 245, 0, 389, 390, 391,
1482 0, 0, 0, 0, 52, 53, 0, 100, 55, 56,
1483 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1484 67, 15, 0, 16, 0, 0, 409, 410, 0, 0,
1485 0, 0, 0, 0, 417, 0, 0, 0, 0, 0,
1486 0, 0, 422, 0, 68, 52, 53, 0, 100, 162,
1487 163, 164, 165, 166, 167, 168, 169, 170, 171, 172,
1488 66, 67, 15, 0, 16, 0, 0, 438, 0, 0,
Chris Lattneredd9b032006-01-23 23:05:42 +00001489 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001490 0, 0, 0, 0, 0, 68, 0, 0, 0, 0,
1491 0, 0, 0, 0, 0, 0, 454, 0, 0, 0,
1492 0, 0, 69, 0, 0, 70, 0, 462, 71, 0,
1493 72, 101, 466, 0, 0, 0, 469, 470, 0, 0,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001494 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001495 0, 0, 0, 0, 263, 264, 52, 53, 265, 0,
1496 0, 0, 0, 69, 0, 0, 70, 0, 0, 71,
1497 0, 72, 313, 15, 0, 16, 0, 266, 267, 268,
1498 0, 0, 0, 0, 0, 0, 0, 0, 0, 269,
1499 270, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1500 0, 0, 0, 0, 0, 0, 0, 0, 0, 271,
1501 0, 0, 0, 0, 263, 264, 0, 0, 265, 0,
1502 0, 0, 117, 118, 119, 120, 121, 122, 123, 124,
1503 125, 126, 127, 128, 129, 130, 0, 266, 267, 268,
1504 0, 238, 0, 239, 240, 138, 139, 0, 241, 269,
1505 270, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1506 272, 0, 0, 0, 0, 0, 0, 0, 0, 271,
Chris Lattneredd9b032006-01-23 23:05:42 +00001507 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001508 0, 0, 117, 118, 119, 120, 121, 122, 123, 124,
1509 125, 126, 127, 128, 129, 130, 0, 0, 0, 0,
1510 0, 238, 0, 239, 240, 138, 139, 0, 241, 0,
1511 0, 0, 0, 0, 0, 0, 0, 0, 52, 53,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001512 272, 100, 55, 56, 57, 58, 59, 60, 61, 62,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001513 63, 64, 65, 66, 67, 15, 0, 16, 0, 0,
Chris Lattneredd9b032006-01-23 23:05:42 +00001514 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001515 183, 0, 0, 0, 0, 0, 52, 53, 68, 100,
1516 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1517 65, 66, 67, 15, 0, 16, 0, 0, 0, 0,
1518 0, 0, 0, 0, 0, 0, 0, 0, 256, 0,
1519 0, 0, 0, 0, 52, 53, 68, 100, 162, 163,
1520 164, 165, 166, 167, 168, 169, 170, 171, 172, 66,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001521 67, 15, 0, 16, 0, 0, 69, 0, 0, 70,
1522 0, 0, 71, 0, 72, 0, 0, 0, 0, 0,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001523 0, 0, 52, 53, 68, 100, 55, 56, 57, 58,
1524 59, 60, 61, 62, 63, 64, 65, 66, 67, 15,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001525 0, 16, 0, 0, 69, 0, 0, 70, 0, 0,
1526 71, 0, 72, 0, 327, 0, 0, 0, 0, 0,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001527 52, 53, 68, 100, 55, 56, 57, 58, 59, 60,
1528 61, 62, 63, 64, 65, 66, 67, 15, 0, 16,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001529 0, 0, 69, 0, 0, 70, 0, 309, 71, 0,
1530 72, 0, 371, 0, 0, 0, 0, 0, 52, 53,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001531 68, 54, 55, 56, 57, 58, 59, 60, 61, 62,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001532 63, 64, 65, 66, 67, 15, 0, 16, 0, 0,
1533 69, 0, 0, 70, 0, 0, 71, 0, 72, 0,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001534 0, 0, 0, 0, 0, 0, 52, 53, 68, 100,
1535 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001536 65, 66, 67, 15, 0, 16, 0, 0, 69, 0,
1537 0, 70, 0, 0, 71, 0, 72, 0, 0, 0,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001538 0, 0, 0, 0, 52, 53, 68, 100, 162, 163,
1539 164, 165, 166, 167, 168, 169, 170, 171, 172, 66,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001540 67, 15, 0, 16, 0, 0, 69, 0, 0, 70,
1541 0, 0, 71, 0, 72, 0, 0, 0, 0, 0,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001542 0, 0, 52, 53, 68, 189, 55, 56, 57, 58,
1543 59, 60, 61, 62, 63, 64, 65, 66, 67, 15,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001544 0, 16, 0, 0, 69, 0, 0, 70, 0, 0,
1545 71, 0, 72, 0, 0, 0, 0, 0, 0, 0,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001546 0, 0, 68, 0, 0, 0, 0, 0, 0, 0,
Chris Lattneredd9b032006-01-23 23:05:42 +00001547 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001548 0, 0, 69, 0, 0, 70, 0, 0, 71, 0,
1549 72, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1550 107, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1551 0, 108, 0, 0, 0, 0, 0, 0, 0, 0,
1552 69, 109, 110, 70, 0, 0, 71, 0, 72, 0,
1553 111, 112, 113, 114, 115, 116, 117, 118, 119, 120,
1554 121, 122, 123, 124, 125, 126, 127, 128, 129, 130,
1555 131, 132, 133, 0, 0, 134, 135, 136, 137, 138,
1556 139, 140, 141, 142, 143, 144
Chris Lattneredd9b032006-01-23 23:05:42 +00001557};
1558
Chris Lattner8ebd2162006-01-24 04:14:29 +00001559static const short yycheck[] = { 29,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001560 113, 113, 2, 44, 206, 72, 96, 29, 252, 23,
1561 58, 114, 243, 244, 44, 34, 30, 108, 434, 15,
1562 111, 10, 11, 12, 13, 14, 15, 16, 17, 0,
1563 15, 9, 108, 33, 450, 54, 102, 113, 105, 104,
1564 20, 272, 133, 21, 110, 136, 137, 150, 113, 140,
1565 141, 142, 143, 144, 25, 23, 110, 148, 54, 113,
1566 31, 41, 42, 43, 44, 95, 96, 47, 101, 54,
1567 41, 42, 43, 44, 74, 10, 11, 12, 13, 14,
1568 15, 16, 17, 58, 102, 102, 24, 102, 59, 111,
1569 102, 102, 449, 108, 112, 112, 108, 101, 112, 110,
1570 457, 131, 132, 4, 134, 135, 61, 62, 63, 64,
1571 101, 178, 179, 180, 358, 145, 146, 147, 20, 108,
1572 22, 104, 24, 49, 50, 51, 22, 101, 24, 31,
1573 32, 33, 101, 224, 32, 33, 52, 53, 4, 41,
1574 42, 43, 44, 106, 176, 47, 48, 88, 89, 27,
1575 28, 4, 182, 55, 186, 3, 4, 59, 4, 191,
1576 192, 3, 4, 204, 3, 4, 3, 4, 3, 4,
1577 104, 203, 24, 108, 204, 4, 208, 24, 380, 107,
1578 382, 222, 107, 104, 56, 4, 218, 219, 220, 4,
1579 4, 4, 222, 223, 261, 7, 7, 4, 289, 7,
1580 291, 292, 102, 106, 36, 102, 105, 298, 102, 102,
1581 102, 102, 242, 243, 244, 305, 306, 307, 308, 102,
1582 102, 102, 102, 102, 24, 102, 316, 317, 318, 319,
1583 10, 11, 12, 13, 14, 15, 16, 17, 24, 104,
1584 104, 104, 272, 105, 104, 104, 104, 104, 280, 104,
1585 60, 102, 102, 102, 286, 34, 24, 257, 288, 102,
1586 290, 106, 102, 293, 294, 21, 102, 299, 300, 102,
1587 21, 102, 4, 363, 104, 305, 306, 307, 308, 102,
1588 102, 102, 24, 4, 104, 102, 316, 317, 318, 319,
1589 36, 54, 4, 102, 24, 325, 387, 388, 102, 102,
1590 102, 102, 334, 102, 336, 102, 102, 102, 340, 399,
1591 400, 105, 402, 403, 404, 405, 348, 349, 350, 102,
1592 105, 434, 434, 54, 354, 416, 108, 102, 106, 105,
1593 191, 192, 105, 363, 105, 105, 105, 450, 450, 105,
1594 105, 21, 203, 36, 108, 377, 378, 208, 21, 102,
1595 105, 441, 21, 385, 102, 69, 21, 218, 219, 220,
1596 21, 393, 0, 0, 84, 84, 84, 84, 398, 399,
1597 400, 33, 402, 403, 404, 405, 5, 6, 20, 326,
1598 105, 325, 46, 176, 43, 2, 418, 23, 14, 337,
1599 392, -1, 359, 22, -1, 24, -1, 26, -1, -1,
1600 -1, -1, -1, -1, -1, -1, -1, -1, -1, 38,
1601 39, 441, -1, -1, -1, 447, -1, -1, -1, 280,
1602 -1, -1, -1, -1, -1, 286, 458, -1, -1, -1,
1603 -1, 463, -1, -1, -1, 467, 468, -1, 299, 300,
1604 -1, -1, 71, 72, 73, 74, 75, 76, 77, 78,
1605 79, 80, 81, 82, 83, 84, -1, -1, -1, -1,
1606 -1, 90, -1, 92, 93, 94, 95, -1, 97, -1,
1607 -1, -1, -1, 334, -1, 336, -1, 106, -1, 340,
1608 109, -1, 111, -1, -1, 114, -1, 348, 349, 350,
1609 -1, -1, -1, -1, 5, 6, -1, 8, 9, 10,
1610 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
1611 21, 22, -1, 24, -1, -1, 377, 378, -1, -1,
1612 -1, -1, -1, -1, 385, -1, -1, -1, -1, -1,
1613 -1, -1, 393, -1, 45, 5, 6, -1, 8, 9,
1614 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
1615 20, 21, 22, -1, 24, -1, -1, 418, -1, -1,
Chris Lattneredd9b032006-01-23 23:05:42 +00001616 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001617 -1, -1, -1, -1, -1, 45, -1, -1, -1, -1,
1618 -1, -1, -1, -1, -1, -1, 447, -1, -1, -1,
1619 -1, -1, 103, -1, -1, 106, -1, 458, 109, -1,
1620 111, 112, 463, -1, -1, -1, 467, 468, -1, -1,
Chris Lattneredd9b032006-01-23 23:05:42 +00001621 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001622 -1, -1, -1, -1, 3, 4, 5, 6, 7, -1,
1623 -1, -1, -1, 103, -1, -1, 106, -1, -1, 109,
1624 -1, 111, 112, 22, -1, 24, -1, 26, 27, 28,
1625 -1, -1, -1, -1, -1, -1, -1, -1, -1, 38,
1626 39, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1627 -1, -1, -1, -1, -1, -1, -1, -1, -1, 58,
1628 -1, -1, -1, -1, 3, 4, -1, -1, 7, -1,
1629 -1, -1, 71, 72, 73, 74, 75, 76, 77, 78,
1630 79, 80, 81, 82, 83, 84, -1, 26, 27, 28,
1631 -1, 90, -1, 92, 93, 94, 95, -1, 97, 38,
1632 39, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1633 109, -1, -1, -1, -1, -1, -1, -1, -1, 58,
Chris Lattneredd9b032006-01-23 23:05:42 +00001634 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001635 -1, -1, 71, 72, 73, 74, 75, 76, 77, 78,
1636 79, 80, 81, 82, 83, 84, -1, -1, -1, -1,
1637 -1, 90, -1, 92, 93, 94, 95, -1, 97, -1,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001638 -1, -1, -1, -1, -1, -1, -1, -1, 5, 6,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001639 109, 8, 9, 10, 11, 12, 13, 14, 15, 16,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001640 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,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001648 21, 22, -1, 24, -1, -1, 103, -1, -1, 106,
1649 -1, -1, 109, -1, 111, -1, -1, -1, -1, -1,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001650 -1, -1, 5, 6, 45, 8, 9, 10, 11, 12,
1651 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001652 -1, 24, -1, -1, 103, -1, -1, 106, -1, -1,
1653 109, -1, 111, -1, 37, -1, -1, -1, -1, -1,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001654 5, 6, 45, 8, 9, 10, 11, 12, 13, 14,
1655 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001656 -1, -1, 103, -1, -1, 106, -1, 108, 109, -1,
1657 111, -1, 37, -1, -1, -1, -1, -1, 5, 6,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001658 45, 8, 9, 10, 11, 12, 13, 14, 15, 16,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001659 17, 18, 19, 20, 21, 22, -1, 24, -1, -1,
1660 103, -1, -1, 106, -1, -1, 109, -1, 111, -1,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001661 -1, -1, -1, -1, -1, -1, 5, 6, 45, 8,
1662 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001663 19, 20, 21, 22, -1, 24, -1, -1, 103, -1,
1664 -1, 106, -1, -1, 109, -1, 111, -1, -1, -1,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001665 -1, -1, -1, -1, 5, 6, 45, 8, 9, 10,
1666 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001667 21, 22, -1, 24, -1, -1, 103, -1, -1, 106,
1668 -1, -1, 109, -1, 111, -1, -1, -1, -1, -1,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001669 -1, -1, 5, 6, 45, 8, 9, 10, 11, 12,
1670 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001671 -1, 24, -1, -1, 103, -1, -1, 106, -1, -1,
1672 109, -1, 111, -1, -1, -1, -1, -1, -1, -1,
Chris Lattner8ebd2162006-01-24 04:14:29 +00001673 -1, -1, 45, -1, -1, -1, -1, -1, -1, -1,
1674 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattnere0a4ee92006-01-25 22:27:16 +00001675 -1, -1, 103, -1, -1, 106, -1, -1, 109, -1,
1676 111, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1677 35, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1678 -1, 46, -1, -1, -1, -1, -1, -1, -1, -1,
1679 103, 56, 57, 106, -1, -1, 109, -1, 111, -1,
1680 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1681 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1682 85, 86, 87, -1, -1, 90, 91, 92, 93, 94,
1683 95, 96, 97, 98, 99, 100
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:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002229#line 1011 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002230{
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:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002237#line 1019 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002238{
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:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002245#line 1042 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002246{
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:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002251#line 1045 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002252{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002253 yyval.StrVal = 0;
Chris Lattneredd9b032006-01-23 23:05:42 +00002254 ;
2255 break;}
2256case 35:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002257#line 1049 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002258{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2259 break;}
2260case 36:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002261#line 1050 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002262{ yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2263 break;}
2264case 37:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002265#line 1051 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002266{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2267 break;}
2268case 38:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002269#line 1052 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002270{ yyval.Linkage = GlobalValue::AppendingLinkage; ;
2271 break;}
2272case 39:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002273#line 1053 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002274{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2275 break;}
2276case 40:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002277#line 1055 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002278{ yyval.UIntVal = CallingConv::C; ;
2279 break;}
2280case 41:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002281#line 1056 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002282{ yyval.UIntVal = CallingConv::C; ;
2283 break;}
2284case 42:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002285#line 1057 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002286{ yyval.UIntVal = CallingConv::Fast; ;
2287 break;}
2288case 43:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002289#line 1058 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002290{ yyval.UIntVal = CallingConv::Cold; ;
2291 break;}
2292case 44:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002293#line 1059 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002294{
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:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002301#line 1067 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002302{ yyval.UIntVal = 0; ;
2303 break;}
2304case 46:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002305#line 1068 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002306{
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:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002313#line 1073 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002314{ yyval.UIntVal = 0; ;
2315 break;}
2316case 48:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002317#line 1074 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002318{
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:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002325#line 1081 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002326{
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:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002334#line 1088 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002335{ yyval.StrVal = 0; ;
2336 break;}
2337case 51:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002338#line 1089 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002339{ yyval.StrVal = yyvsp[0].StrVal; ;
2340 break;}
2341case 52:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002342#line 1094 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002343{;
2344 break;}
2345case 53:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002346#line 1095 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002347{;
2348 break;}
2349case 54:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002350#line 1096 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002351{
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:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002357#line 1100 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002358{
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:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002365#line 1113 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002366{ yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2367 break;}
2368case 59:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002369#line 1114 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002370{ yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2371 break;}
2372case 60:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002373#line 1116 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002374{
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:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002381#line 1127 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002382{
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:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002387#line 1130 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002388{
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:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002393#line 1133 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002394{ // 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:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002399#line 1139 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002400{ // 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:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002409#line 1146 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002410{ // 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:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002424#line 1158 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002425{ // 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:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002431#line 1162 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002432{ // 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:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002445#line 1173 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002446{ // 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:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002457#line 1182 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002458{ // 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:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002463#line 1185 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002464{ // 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:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002470#line 1193 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002471{
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:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002477#line 1197 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002478{
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:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002483#line 1203 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002484{
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:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002489#line 1206 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002490{
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:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002495#line 1209 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002496{
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:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002501#line 1219 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002502{ // 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:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002529#line 1244 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002530{
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:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002545#line 1257 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002546{
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 Lattnere0a4ee92006-01-25 22:27:16 +00002577#line 1286 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00002605#line 1311 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00002628#line 1331 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00002643#line 1343 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00002655#line 1352 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00002662#line 1356 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00002724#line 1415 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00002733#line 1421 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00002743#line 1429 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00002751#line 1434 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00002759#line 1439 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00002765#line 1442 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00002771#line 1445 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00002779#line 1452 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00002792#line 1462 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00002826#line 1493 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00002836#line 1500 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00002860#line 1521 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00002873#line 1531 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00002881#line 1536 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00002891#line 1543 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00002902#line 1553 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00002908#line 1556 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00002915#line 1563 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002916{ yyval.BoolVal = false; ;
2917 break;}
2918case 117:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002919#line 1563 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00002920{ yyval.BoolVal = true; ;
2921 break;}
2922case 118:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00002923#line 1573 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00002930#line 1580 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00002937#line 1584 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00002943#line 1587 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00002949#line 1590 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00002955#line 1593 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00002969#line 1606 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00002992#line 1626 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00002997#line 1628 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8ebd2162006-01-24 04:14:29 +00002998{ // Asm blocks can be in the const pool
Chris Lattneredd9b032006-01-23 23:05:42 +00002999 ;
3000 break;}
3001case 127:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003002#line 1630 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00003009#line 1633 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00003015#line 1636 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00003023#line 1640 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00003029#line 1643 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003030{
3031 ;
3032 break;}
3033case 132:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003034#line 1645 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003035{
3036 ;
3037 break;}
3038case 133:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003039#line 1647 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003040{
3041 ;
3042 break;}
3043case 134:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003044#line 1651 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00003058#line 1663 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003059{ yyval.Endianness = Module::BigEndian; ;
3060 break;}
3061case 136:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003062#line 1664 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003063{ yyval.Endianness = Module::LittleEndian; ;
3064 break;}
3065case 137:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003066#line 1666 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00003072#line 1669 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00003083#line 1677 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00003090#line 1684 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003091{
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 Lattnere0a4ee92006-01-25 22:27:16 +00003097#line 1688 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003098{
Chris Lattner8ebd2162006-01-24 04:14:29 +00003099 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3100 free(yyvsp[0].StrVal);
3101 ;
3102 break;}
3103case 143:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003104#line 1692 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8ebd2162006-01-24 04:14:29 +00003105{
Chris Lattneredd9b032006-01-23 23:05:42 +00003106 ;
3107 break;}
3108case 147:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003109#line 1701 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003110{ yyval.StrVal = 0; ;
3111 break;}
3112case 148:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003113#line 1703 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00003121#line 1709 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00003129#line 1714 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00003137#line 1720 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00003143#line 1723 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00003151#line 1728 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00003158#line 1732 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00003164#line 1737 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00003251#line 1824 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00003261#line 1834 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00003267#line 1838 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003268{ CurFun.isDeclare = true; ;
3269 break;}
3270case 163:
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003271#line 1838 "/Volumes/ProjectsDisk/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 Lattnere0a4ee92006-01-25 22:27:16 +00003278#line 1847 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3279{
3280 yyval.BoolVal = false;
3281 ;
3282 break;}
3283case 165:
3284#line 1850 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3285{
3286 yyval.BoolVal = true;
3287 ;
3288 break;}
3289case 166:
3290#line 1854 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003291{ // A reference to a direct constant
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003292 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
Chris Lattneredd9b032006-01-23 23:05:42 +00003293 ;
3294 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003295case 167:
3296#line 1857 "/Volumes/ProjectsDisk/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(yyvsp[0].UInt64Val);
Chris Lattneredd9b032006-01-23 23:05:42 +00003299 ;
3300 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003301case 168:
3302#line 1860 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003303{ // Perhaps it's an FP constant?
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003304 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003305 ;
3306 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003307case 169:
3308#line 1863 "/Volumes/ProjectsDisk/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::create(ConstantBool::True);
Chris Lattneredd9b032006-01-23 23:05:42 +00003311 ;
3312 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003313case 170:
3314#line 1866 "/Volumes/ProjectsDisk/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::create(ConstantBool::False);
Chris Lattneredd9b032006-01-23 23:05:42 +00003317 ;
3318 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003319case 171:
3320#line 1869 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003321{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003322 yyval.ValIDVal = ValID::createNull();
Chris Lattneredd9b032006-01-23 23:05:42 +00003323 ;
3324 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003325case 172:
3326#line 1872 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003327{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003328 yyval.ValIDVal = ValID::createUndef();
Chris Lattneredd9b032006-01-23 23:05:42 +00003329 ;
3330 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003331case 173:
3332#line 1875 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003333{ // A vector zero constant.
Chris Lattnera054d122005-12-21 17:53:23 +00003334 yyval.ValIDVal = ValID::createZeroInit();
Chris Lattneredd9b032006-01-23 23:05:42 +00003335 ;
3336 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003337case 174:
3338#line 1878 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003339{ // Nonempty unsized packed vector
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003340 const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
3341 int NumElements = yyvsp[-1].ConstVector->size();
3342
3343 PackedType* pt = PackedType::get(ETy, NumElements);
3344 PATypeHolder* PTy = new PATypeHolder(
3345 HandleUpRefs(
3346 PackedType::get(
3347 ETy,
3348 NumElements)
3349 )
3350 );
3351
3352 // Verify all elements are correct type!
3353 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3354 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
3355 ThrowException("Element #" + utostr(i) + " is not of type '" +
3356 ETy->getDescription() +"' as required!\nIt is of type '" +
3357 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
3358 }
3359
3360 yyval.ValIDVal = ValID::create(ConstantPacked::get(pt, *yyvsp[-1].ConstVector));
3361 delete PTy; delete yyvsp[-1].ConstVector;
Chris Lattneredd9b032006-01-23 23:05:42 +00003362 ;
3363 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003364case 175:
3365#line 1902 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003366{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003367 yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003368 ;
3369 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003370case 176:
3371#line 1905 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3372{
3373 char *End = UnEscapeLexed(yyvsp[-2].StrVal, true);
3374 std::string AsmStr = std::string(yyvsp[-2].StrVal, End);
3375 End = UnEscapeLexed(yyvsp[0].StrVal, true);
3376 std::string Constraints = std::string(yyvsp[0].StrVal, End);
3377 yyval.ValIDVal = ValID::createInlineAsm(AsmStr, Constraints, yyvsp[-3].BoolVal);
3378 free(yyvsp[-2].StrVal);
3379 free(yyvsp[0].StrVal);
3380 ;
3381 break;}
3382case 177:
3383#line 1918 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003384{ // Is it an integer reference...?
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003385 yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003386 ;
3387 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003388case 178:
3389#line 1921 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003390{ // Is it a named reference...?
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003391 yyval.ValIDVal = ValID::create(yyvsp[0].StrVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003392 ;
3393 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003394case 181:
3395#line 1932 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003396{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003397 yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); delete yyvsp[-1].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003398 ;
3399 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003400case 182:
3401#line 1936 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003402{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003403 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003404 ;
3405 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003406case 183:
3407#line 1939 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003408{ // Do not allow functions with 0 basic blocks
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003409 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003410 ;
3411 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003412case 184:
3413#line 1947 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003414{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003415 setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
3416 InsertValue(yyvsp[0].TermInstVal);
3417
3418 yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
3419 InsertValue(yyvsp[-2].BasicBlockVal);
3420 yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003421 ;
3422 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003423case 185:
3424#line 1956 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003425{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003426 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
3427 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003428 ;
3429 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003430case 186:
3431#line 1960 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003432{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003433 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
3434
3435 // Make sure to move the basic block to the correct location in the
3436 // function, instead of leaving it inserted wherever it was first
3437 // referenced.
3438 Function::BasicBlockListType &BBL =
3439 CurFun.CurrentFunction->getBasicBlockList();
3440 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003441 ;
3442 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003443case 187:
3444#line 1970 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003445{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003446 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create(yyvsp[0].StrVal), true);
3447
3448 // Make sure to move the basic block to the correct location in the
3449 // function, instead of leaving it inserted wherever it was first
3450 // referenced.
3451 Function::BasicBlockListType &BBL =
3452 CurFun.CurrentFunction->getBasicBlockList();
3453 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003454 ;
3455 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003456case 188:
3457#line 1981 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003458{ // Return with a result...
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003459 yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003460 ;
3461 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003462case 189:
3463#line 1984 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003464{ // Return with no result...
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003465 yyval.TermInstVal = new ReturnInst();
Chris Lattneredd9b032006-01-23 23:05:42 +00003466 ;
3467 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003468case 190:
3469#line 1987 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003470{ // Unconditional Branch...
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003471 yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[0].ValIDVal));
Chris Lattneredd9b032006-01-23 23:05:42 +00003472 ;
3473 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003474case 191:
3475#line 1990 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003476{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003477 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 +00003478 ;
3479 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003480case 192:
3481#line 1993 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003482{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003483 SwitchInst *S = new SwitchInst(getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal), getBBVal(yyvsp[-3].ValIDVal), yyvsp[-1].JumpTable->size());
3484 yyval.TermInstVal = S;
3485
3486 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
3487 E = yyvsp[-1].JumpTable->end();
3488 for (; I != E; ++I) {
3489 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
3490 S->addCase(CI, I->second);
3491 else
3492 ThrowException("Switch case is constant, but not a simple integer!");
3493 }
3494 delete yyvsp[-1].JumpTable;
Chris Lattneredd9b032006-01-23 23:05:42 +00003495 ;
3496 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003497case 193:
3498#line 2007 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003499{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003500 SwitchInst *S = new SwitchInst(getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal), getBBVal(yyvsp[-2].ValIDVal), 0);
3501 yyval.TermInstVal = S;
Chris Lattneredd9b032006-01-23 23:05:42 +00003502 ;
3503 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003504case 194:
3505#line 2012 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003506{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003507 const PointerType *PFTy;
3508 const FunctionType *Ty;
3509
3510 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-10].TypeVal->get())) ||
3511 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3512 // Pull out the types of all of the arguments...
3513 std::vector<const Type*> ParamTypes;
3514 if (yyvsp[-7].ValueList) {
3515 for (std::vector<Value*>::iterator I = yyvsp[-7].ValueList->begin(), E = yyvsp[-7].ValueList->end();
3516 I != E; ++I)
3517 ParamTypes.push_back((*I)->getType());
3518 }
3519
3520 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3521 if (isVarArg) ParamTypes.pop_back();
3522
3523 Ty = FunctionType::get(yyvsp[-10].TypeVal->get(), ParamTypes, isVarArg);
3524 PFTy = PointerType::get(Ty);
3525 }
3526
3527 Value *V = getVal(PFTy, yyvsp[-9].ValIDVal); // Get the function we're calling...
3528
3529 BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
3530 BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
3531
3532 // Create the call node...
3533 if (!yyvsp[-7].ValueList) { // Has no arguments?
3534 yyval.TermInstVal = new InvokeInst(V, Normal, Except, std::vector<Value*>());
3535 } else { // Has arguments?
3536 // Loop through FunctionType's arguments and ensure they are specified
3537 // correctly!
3538 //
3539 FunctionType::param_iterator I = Ty->param_begin();
3540 FunctionType::param_iterator E = Ty->param_end();
3541 std::vector<Value*>::iterator ArgI = yyvsp[-7].ValueList->begin(), ArgE = yyvsp[-7].ValueList->end();
3542
3543 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3544 if ((*ArgI)->getType() != *I)
3545 ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
3546 (*I)->getDescription() + "'!");
3547
3548 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
3549 ThrowException("Invalid number of parameters detected!");
3550
3551 yyval.TermInstVal = new InvokeInst(V, Normal, Except, *yyvsp[-7].ValueList);
3552 }
3553 cast<InvokeInst>(yyval.TermInstVal)->setCallingConv(yyvsp[-11].UIntVal);
3554
3555 delete yyvsp[-10].TypeVal;
3556 delete yyvsp[-7].ValueList;
Chris Lattneredd9b032006-01-23 23:05:42 +00003557 ;
3558 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003559case 195:
3560#line 2064 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003561{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003562 yyval.TermInstVal = new UnwindInst();
Chris Lattneredd9b032006-01-23 23:05:42 +00003563 ;
3564 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003565case 196:
3566#line 2067 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003567{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003568 yyval.TermInstVal = new UnreachableInst();
Chris Lattneredd9b032006-01-23 23:05:42 +00003569 ;
3570 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003571case 197:
3572#line 2073 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003573{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003574 yyval.JumpTable = yyvsp[-5].JumpTable;
3575 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
3576 if (V == 0)
3577 ThrowException("May only switch on a constant pool value!");
3578
3579 yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
Chris Lattneredd9b032006-01-23 23:05:42 +00003580 ;
3581 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003582case 198:
3583#line 2081 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003584{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003585 yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
3586 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
3587
3588 if (V == 0)
3589 ThrowException("May only switch on a constant pool value!");
3590
3591 yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
Chris Lattneredd9b032006-01-23 23:05:42 +00003592 ;
3593 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003594case 199:
3595#line 2091 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003596{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003597 // Is this definition named?? if so, assign the name...
3598 setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
3599 InsertValue(yyvsp[0].InstVal);
3600 yyval.InstVal = yyvsp[0].InstVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003601;
3602 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003603case 200:
3604#line 2098 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003605{ // Used for PHI nodes
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003606 yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
3607 yyval.PHIList->push_back(std::make_pair(getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal), getBBVal(yyvsp[-1].ValIDVal)));
3608 delete yyvsp[-5].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003609 ;
3610 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003611case 201:
3612#line 2103 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003613{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003614 yyval.PHIList = yyvsp[-6].PHIList;
3615 yyvsp[-6].PHIList->push_back(std::make_pair(getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal),
3616 getBBVal(yyvsp[-1].ValIDVal)));
Chris Lattneredd9b032006-01-23 23:05:42 +00003617 ;
3618 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003619case 202:
3620#line 2110 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003621{ // Used for call statements, and memory insts...
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003622 yyval.ValueList = new std::vector<Value*>();
3623 yyval.ValueList->push_back(yyvsp[0].ValueVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003624 ;
3625 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003626case 203:
3627#line 2114 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003628{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003629 yyval.ValueList = yyvsp[-2].ValueList;
3630 yyvsp[-2].ValueList->push_back(yyvsp[0].ValueVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003631 ;
3632 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003633case 205:
3634#line 2120 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003635{ yyval.ValueList = 0; ;
3636 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003637case 206:
3638#line 2122 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003639{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003640 yyval.BoolVal = true;
Chris Lattneredd9b032006-01-23 23:05:42 +00003641 ;
3642 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003643case 207:
3644#line 2125 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003645{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003646 yyval.BoolVal = false;
Chris Lattneredd9b032006-01-23 23:05:42 +00003647 ;
3648 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003649case 208:
3650#line 2131 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003651{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003652 if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
3653 !isa<PackedType>((*yyvsp[-3].TypeVal).get()))
3654 ThrowException(
3655 "Arithmetic operator requires integer, FP, or packed operands!");
3656 if (isa<PackedType>((*yyvsp[-3].TypeVal).get()) && yyvsp[-4].BinaryOpVal == Instruction::Rem)
3657 ThrowException("Rem not supported on packed types!");
3658 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3659 if (yyval.InstVal == 0)
3660 ThrowException("binary operator returned null!");
3661 delete yyvsp[-3].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003662 ;
3663 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003664case 209:
3665#line 2143 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003666{
Chris Lattner15f5a182005-12-21 18:31:50 +00003667 if (!(*yyvsp[-3].TypeVal)->isIntegral()) {
3668 if (!isa<PackedType>(yyvsp[-3].TypeVal->get()) ||
3669 !cast<PackedType>(yyvsp[-3].TypeVal->get())->getElementType()->isIntegral())
3670 ThrowException("Logical operator requires integral operands!");
3671 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003672 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3673 if (yyval.InstVal == 0)
3674 ThrowException("binary operator returned null!");
3675 delete yyvsp[-3].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003676 ;
3677 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003678case 210:
3679#line 2154 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003680{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003681 if(isa<PackedType>((*yyvsp[-3].TypeVal).get())) {
3682 ThrowException(
3683 "PackedTypes currently not supported in setcc instructions!");
3684 }
3685 yyval.InstVal = new SetCondInst(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3686 if (yyval.InstVal == 0)
3687 ThrowException("binary operator returned null!");
3688 delete yyvsp[-3].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003689 ;
3690 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003691case 211:
3692#line 2164 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003693{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003694 std::cerr << "WARNING: Use of eliminated 'not' instruction:"
3695 << " Replacing with 'xor'.\n";
3696
3697 Value *Ones = ConstantIntegral::getAllOnesValue(yyvsp[0].ValueVal->getType());
3698 if (Ones == 0)
3699 ThrowException("Expected integral type for not instruction!");
3700
3701 yyval.InstVal = BinaryOperator::create(Instruction::Xor, yyvsp[0].ValueVal, Ones);
3702 if (yyval.InstVal == 0)
3703 ThrowException("Could not create a xor instruction!");
Chris Lattneredd9b032006-01-23 23:05:42 +00003704 ;
3705 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003706case 212:
3707#line 2176 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003708{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003709 if (yyvsp[0].ValueVal->getType() != Type::UByteTy)
3710 ThrowException("Shift amount must be ubyte!");
3711 if (!yyvsp[-2].ValueVal->getType()->isInteger())
3712 ThrowException("Shift constant expression requires integer operand!");
3713 yyval.InstVal = new ShiftInst(yyvsp[-3].OtherOpVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003714 ;
3715 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003716case 213:
3717#line 2183 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003718{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003719 if (!yyvsp[0].TypeVal->get()->isFirstClassType())
3720 ThrowException("cast instruction to a non-primitive type: '" +
3721 yyvsp[0].TypeVal->get()->getDescription() + "'!");
3722 yyval.InstVal = new CastInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
3723 delete yyvsp[0].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003724 ;
3725 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003726case 214:
3727#line 2190 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003728{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003729 if (yyvsp[-4].ValueVal->getType() != Type::BoolTy)
3730 ThrowException("select condition must be boolean!");
3731 if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
3732 ThrowException("select value types should match!");
3733 yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003734 ;
3735 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003736case 215:
3737#line 2197 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003738{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003739 NewVarArgs = true;
3740 yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
3741 delete yyvsp[0].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003742 ;
3743 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003744case 216:
3745#line 2202 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003746{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003747 ObsoleteVarArgs = true;
3748 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
3749 Function* NF = CurModule.CurrentModule->
Jeff Cohen11e26b52005-10-23 04:37:20 +00003750 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003751
3752 //b = vaarg a, t ->
3753 //foo = alloca 1 of t
3754 //bar = vacopy a
3755 //store bar -> foo
3756 //b = vaarg foo, t
3757 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
3758 CurBB->getInstList().push_back(foo);
3759 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
3760 CurBB->getInstList().push_back(bar);
3761 CurBB->getInstList().push_back(new StoreInst(bar, foo));
3762 yyval.InstVal = new VAArgInst(foo, *yyvsp[0].TypeVal);
3763 delete yyvsp[0].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003764 ;
3765 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003766case 217:
3767#line 2221 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003768{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003769 ObsoleteVarArgs = true;
3770 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
3771 Function* NF = CurModule.CurrentModule->
Jeff Cohen11e26b52005-10-23 04:37:20 +00003772 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003773
3774 //b = vanext a, t ->
3775 //foo = alloca 1 of t
3776 //bar = vacopy a
3777 //store bar -> foo
3778 //tmp = vaarg foo, t
3779 //b = load foo
3780 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
3781 CurBB->getInstList().push_back(foo);
3782 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
3783 CurBB->getInstList().push_back(bar);
3784 CurBB->getInstList().push_back(new StoreInst(bar, foo));
3785 Instruction* tmp = new VAArgInst(foo, *yyvsp[0].TypeVal);
3786 CurBB->getInstList().push_back(tmp);
3787 yyval.InstVal = new LoadInst(foo);
3788 delete yyvsp[0].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003789 ;
3790 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003791case 218:
3792#line 2243 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003793{
Robert Bocchinoaa1cf542006-01-10 19:04:32 +00003794 if (!isa<PackedType>(yyvsp[-2].ValueVal->getType()))
Robert Bocchinofdf9e412006-01-17 20:06:25 +00003795 ThrowException("First operand of extractelement must be "
3796 "packed type!");
Robert Bocchinoaa1cf542006-01-10 19:04:32 +00003797 if (yyvsp[0].ValueVal->getType() != Type::UIntTy)
Robert Bocchinofdf9e412006-01-17 20:06:25 +00003798 ThrowException("Second operand of extractelement must be uint!");
Robert Bocchinoaa1cf542006-01-10 19:04:32 +00003799 yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003800 ;
3801 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003802case 219:
3803#line 2251 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003804{
Robert Bocchinofdf9e412006-01-17 20:06:25 +00003805 if (!isa<PackedType>(yyvsp[-4].ValueVal->getType()))
3806 ThrowException("First operand of insertelement must be "
3807 "packed type!");
3808 if (yyvsp[-2].ValueVal->getType() !=
3809 cast<PackedType>(yyvsp[-4].ValueVal->getType())->getElementType())
3810 ThrowException("Second operand of insertelement must be "
3811 "packed element type!");
3812 if (yyvsp[0].ValueVal->getType() != Type::UIntTy)
3813 ThrowException("Third operand of insertelement must be uint!");
3814 yyval.InstVal = new InsertElementInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003815 ;
3816 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003817case 220:
3818#line 2263 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003819{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003820 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
3821 if (!Ty->isFirstClassType())
3822 ThrowException("PHI node operands must be of first class type!");
3823 yyval.InstVal = new PHINode(Ty);
3824 ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
3825 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
3826 if (yyvsp[0].PHIList->front().first->getType() != Ty)
3827 ThrowException("All elements of a PHI node must be of the same type!");
3828 cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
3829 yyvsp[0].PHIList->pop_front();
3830 }
3831 delete yyvsp[0].PHIList; // Free the list...
Chris Lattneredd9b032006-01-23 23:05:42 +00003832 ;
3833 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003834case 221:
3835#line 2277 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003836{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003837 const PointerType *PFTy;
3838 const FunctionType *Ty;
3839
3840 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-4].TypeVal->get())) ||
3841 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3842 // Pull out the types of all of the arguments...
3843 std::vector<const Type*> ParamTypes;
3844 if (yyvsp[-1].ValueList) {
3845 for (std::vector<Value*>::iterator I = yyvsp[-1].ValueList->begin(), E = yyvsp[-1].ValueList->end();
3846 I != E; ++I)
3847 ParamTypes.push_back((*I)->getType());
3848 }
3849
3850 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3851 if (isVarArg) ParamTypes.pop_back();
3852
3853 if (!(*yyvsp[-4].TypeVal)->isFirstClassType() && *yyvsp[-4].TypeVal != Type::VoidTy)
3854 ThrowException("LLVM functions cannot return aggregate types!");
3855
3856 Ty = FunctionType::get(yyvsp[-4].TypeVal->get(), ParamTypes, isVarArg);
3857 PFTy = PointerType::get(Ty);
3858 }
3859
3860 Value *V = getVal(PFTy, yyvsp[-3].ValIDVal); // Get the function we're calling...
3861
3862 // Create the call node...
3863 if (!yyvsp[-1].ValueList) { // Has no arguments?
3864 // Make sure no arguments is a good thing!
3865 if (Ty->getNumParams() != 0)
3866 ThrowException("No arguments passed to a function that "
3867 "expects arguments!");
3868
3869 yyval.InstVal = new CallInst(V, std::vector<Value*>());
3870 } else { // Has arguments?
3871 // Loop through FunctionType's arguments and ensure they are specified
3872 // correctly!
3873 //
3874 FunctionType::param_iterator I = Ty->param_begin();
3875 FunctionType::param_iterator E = Ty->param_end();
3876 std::vector<Value*>::iterator ArgI = yyvsp[-1].ValueList->begin(), ArgE = yyvsp[-1].ValueList->end();
3877
3878 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3879 if ((*ArgI)->getType() != *I)
3880 ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
3881 (*I)->getDescription() + "'!");
3882
3883 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
3884 ThrowException("Invalid number of parameters detected!");
3885
3886 yyval.InstVal = new CallInst(V, *yyvsp[-1].ValueList);
3887 }
3888 cast<CallInst>(yyval.InstVal)->setTailCall(yyvsp[-6].BoolVal);
3889 cast<CallInst>(yyval.InstVal)->setCallingConv(yyvsp[-5].UIntVal);
3890 delete yyvsp[-4].TypeVal;
3891 delete yyvsp[-1].ValueList;
Chris Lattneredd9b032006-01-23 23:05:42 +00003892 ;
3893 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003894case 222:
3895#line 2334 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003896{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003897 yyval.InstVal = yyvsp[0].InstVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003898 ;
3899 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003900case 223:
3901#line 2340 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003902{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003903 yyval.ValueList = yyvsp[0].ValueList;
Chris Lattneredd9b032006-01-23 23:05:42 +00003904 ;
3905 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003906case 224:
3907#line 2342 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003908{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003909 yyval.ValueList = new std::vector<Value*>();
Chris Lattneredd9b032006-01-23 23:05:42 +00003910 ;
3911 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003912case 225:
3913#line 2346 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003914{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003915 yyval.BoolVal = true;
Chris Lattneredd9b032006-01-23 23:05:42 +00003916 ;
3917 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003918case 226:
3919#line 2349 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003920{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003921 yyval.BoolVal = false;
Chris Lattneredd9b032006-01-23 23:05:42 +00003922 ;
3923 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003924case 227:
3925#line 2355 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003926{
Chris Lattner86c352b2005-11-06 06:34:34 +00003927 yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
3928 delete yyvsp[-1].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003929 ;
3930 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003931case 228:
3932#line 2359 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003933{
Chris Lattner86c352b2005-11-06 06:34:34 +00003934 yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal);
3935 delete yyvsp[-4].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003936 ;
3937 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003938case 229:
3939#line 2363 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003940{
Chris Lattner86c352b2005-11-06 06:34:34 +00003941 yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
3942 delete yyvsp[-1].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003943 ;
3944 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003945case 230:
3946#line 2367 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003947{
Chris Lattner86c352b2005-11-06 06:34:34 +00003948 yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal);
3949 delete yyvsp[-4].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003950 ;
3951 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003952case 231:
3953#line 2371 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003954{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003955 if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
3956 ThrowException("Trying to free nonpointer type " +
3957 yyvsp[0].ValueVal->getType()->getDescription() + "!");
3958 yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003959 ;
3960 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003961case 232:
3962#line 2378 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003963{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003964 if (!isa<PointerType>(yyvsp[-1].TypeVal->get()))
3965 ThrowException("Can't load from nonpointer type: " +
3966 (*yyvsp[-1].TypeVal)->getDescription());
3967 if (!cast<PointerType>(yyvsp[-1].TypeVal->get())->getElementType()->isFirstClassType())
3968 ThrowException("Can't load from pointer of non-first-class type: " +
3969 (*yyvsp[-1].TypeVal)->getDescription());
3970 yyval.InstVal = new LoadInst(getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), "", yyvsp[-3].BoolVal);
3971 delete yyvsp[-1].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003972 ;
3973 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003974case 233:
3975#line 2388 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003976{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003977 const PointerType *PT = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
3978 if (!PT)
3979 ThrowException("Can't store to a nonpointer type: " +
3980 (*yyvsp[-1].TypeVal)->getDescription());
3981 const Type *ElTy = PT->getElementType();
3982 if (ElTy != yyvsp[-3].ValueVal->getType())
3983 ThrowException("Can't store '" + yyvsp[-3].ValueVal->getType()->getDescription() +
3984 "' into space of type '" + ElTy->getDescription() + "'!");
3985
3986 yyval.InstVal = new StoreInst(yyvsp[-3].ValueVal, getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), yyvsp[-5].BoolVal);
3987 delete yyvsp[-1].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003988 ;
3989 break;}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00003990case 234:
3991#line 2401 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattneredd9b032006-01-23 23:05:42 +00003992{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003993 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
3994 ThrowException("getelementptr insn requires pointer operand!");
3995
3996 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
3997 // indices to uint struct indices for compatibility.
3998 generic_gep_type_iterator<std::vector<Value*>::iterator>
3999 GTI = gep_type_begin(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end()),
4000 GTE = gep_type_end(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end());
4001 for (unsigned i = 0, e = yyvsp[0].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
4002 if (isa<StructType>(*GTI)) // Only change struct indices
4003 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[0].ValueList)[i]))
4004 if (CUI->getType() == Type::UByteTy)
4005 (*yyvsp[0].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
4006
4007 if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, *yyvsp[0].ValueList, true))
4008 ThrowException("Invalid getelementptr indices for type '" +
4009 (*yyvsp[-2].TypeVal)->getDescription()+ "'!");
4010 yyval.InstVal = new GetElementPtrInst(getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal), *yyvsp[0].ValueList);
4011 delete yyvsp[-2].TypeVal; delete yyvsp[0].ValueList;
Chris Lattneredd9b032006-01-23 23:05:42 +00004012 ;
4013 break;}
4014}
4015 /* the action file gets copied in in place of this dollarsign */
4016#line 543 "/usr/share/bison.simple"
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004017
4018 yyvsp -= yylen;
4019 yyssp -= yylen;
Chris Lattneredd9b032006-01-23 23:05:42 +00004020#ifdef YYLSP_NEEDED
4021 yylsp -= yylen;
4022#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004023
Chris Lattneredd9b032006-01-23 23:05:42 +00004024#if YYDEBUG != 0
4025 if (yydebug)
4026 {
4027 short *ssp1 = yyss - 1;
4028 fprintf (stderr, "state stack now");
4029 while (ssp1 != yyssp)
4030 fprintf (stderr, " %d", *++ssp1);
4031 fprintf (stderr, "\n");
4032 }
4033#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004034
4035 *++yyvsp = yyval;
4036
Chris Lattneredd9b032006-01-23 23:05:42 +00004037#ifdef YYLSP_NEEDED
4038 yylsp++;
4039 if (yylen == 0)
4040 {
4041 yylsp->first_line = yylloc.first_line;
4042 yylsp->first_column = yylloc.first_column;
4043 yylsp->last_line = (yylsp-1)->last_line;
4044 yylsp->last_column = (yylsp-1)->last_column;
4045 yylsp->text = 0;
4046 }
4047 else
4048 {
4049 yylsp->last_line = (yylsp+yylen-1)->last_line;
4050 yylsp->last_column = (yylsp+yylen-1)->last_column;
4051 }
4052#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004053
Chris Lattneredd9b032006-01-23 23:05:42 +00004054 /* Now "shift" the result of the reduction.
4055 Determine what state that goes to,
4056 based on the state we popped back to
4057 and the rule number reduced by. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004058
4059 yyn = yyr1[yyn];
4060
Chris Lattneredd9b032006-01-23 23:05:42 +00004061 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
4062 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004063 yystate = yytable[yystate];
4064 else
Chris Lattneredd9b032006-01-23 23:05:42 +00004065 yystate = yydefgoto[yyn - YYNTBASE];
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004066
4067 goto yynewstate;
4068
Chris Lattneredd9b032006-01-23 23:05:42 +00004069yyerrlab: /* here on detecting error */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004070
Chris Lattneredd9b032006-01-23 23:05:42 +00004071 if (! yyerrstatus)
4072 /* If not already recovering from an error, report this error. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004073 {
4074 ++yynerrs;
Chris Lattneredd9b032006-01-23 23:05:42 +00004075
4076#ifdef YYERROR_VERBOSE
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004077 yyn = yypact[yystate];
4078
Chris Lattneredd9b032006-01-23 23:05:42 +00004079 if (yyn > YYFLAG && yyn < YYLAST)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004080 {
Chris Lattneredd9b032006-01-23 23:05:42 +00004081 int size = 0;
4082 char *msg;
4083 int x, count;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004084
Chris Lattneredd9b032006-01-23 23:05:42 +00004085 count = 0;
4086 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
4087 for (x = (yyn < 0 ? -yyn : 0);
4088 x < (sizeof(yytname) / sizeof(char *)); x++)
4089 if (yycheck[x + yyn] == x)
4090 size += strlen(yytname[x]) + 15, count++;
4091 msg = (char *) malloc(size + 15);
4092 if (msg != 0)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004093 {
Chris Lattneredd9b032006-01-23 23:05:42 +00004094 strcpy(msg, "parse error");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004095
Chris Lattneredd9b032006-01-23 23:05:42 +00004096 if (count < 5)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004097 {
Chris Lattneredd9b032006-01-23 23:05:42 +00004098 count = 0;
4099 for (x = (yyn < 0 ? -yyn : 0);
4100 x < (sizeof(yytname) / sizeof(char *)); x++)
4101 if (yycheck[x + yyn] == x)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004102 {
Chris Lattneredd9b032006-01-23 23:05:42 +00004103 strcat(msg, count == 0 ? ", expecting `" : " or `");
4104 strcat(msg, yytname[x]);
4105 strcat(msg, "'");
4106 count++;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004107 }
4108 }
Chris Lattneredd9b032006-01-23 23:05:42 +00004109 yyerror(msg);
4110 free(msg);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004111 }
4112 else
Chris Lattneredd9b032006-01-23 23:05:42 +00004113 yyerror ("parse error; also virtual memory exceeded");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004114 }
4115 else
4116#endif /* YYERROR_VERBOSE */
Chris Lattneredd9b032006-01-23 23:05:42 +00004117 yyerror("parse error");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004118 }
4119
Chris Lattneredd9b032006-01-23 23:05:42 +00004120 goto yyerrlab1;
4121yyerrlab1: /* here on error raised explicitly by an action */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004122
4123 if (yyerrstatus == 3)
4124 {
Chris Lattneredd9b032006-01-23 23:05:42 +00004125 /* if just tried and failed to reuse lookahead token after an error, discard it. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004126
Chris Lattneredd9b032006-01-23 23:05:42 +00004127 /* return failure if at end of input */
4128 if (yychar == YYEOF)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004129 YYABORT;
4130
Chris Lattneredd9b032006-01-23 23:05:42 +00004131#if YYDEBUG != 0
4132 if (yydebug)
4133 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
4134#endif
4135
4136 yychar = YYEMPTY;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004137 }
4138
Chris Lattneredd9b032006-01-23 23:05:42 +00004139 /* Else will try to reuse lookahead token
4140 after shifting the error token. */
4141
4142 yyerrstatus = 3; /* Each real token shifted decrements this */
4143
4144 goto yyerrhandle;
4145
4146yyerrdefault: /* current state does not do anything special for the error token. */
4147
4148#if 0
4149 /* This is wrong; only states that explicitly want error tokens
4150 should shift them. */
4151 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
4152 if (yyn) goto yydefault;
4153#endif
4154
4155yyerrpop: /* pop the current state because it cannot handle the error token */
4156
4157 if (yyssp == yyss) YYABORT;
4158 yyvsp--;
4159 yystate = *--yyssp;
4160#ifdef YYLSP_NEEDED
4161 yylsp--;
4162#endif
4163
4164#if YYDEBUG != 0
4165 if (yydebug)
4166 {
4167 short *ssp1 = yyss - 1;
4168 fprintf (stderr, "Error: state stack now");
4169 while (ssp1 != yyssp)
4170 fprintf (stderr, " %d", *++ssp1);
4171 fprintf (stderr, "\n");
4172 }
4173#endif
4174
4175yyerrhandle:
4176
4177 yyn = yypact[yystate];
4178 if (yyn == YYFLAG)
4179 goto yyerrdefault;
4180
4181 yyn += YYTERROR;
4182 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
4183 goto yyerrdefault;
4184
4185 yyn = yytable[yyn];
4186 if (yyn < 0)
4187 {
4188 if (yyn == YYFLAG)
4189 goto yyerrpop;
4190 yyn = -yyn;
4191 goto yyreduce;
4192 }
4193 else if (yyn == 0)
4194 goto yyerrpop;
4195
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004196 if (yyn == YYFINAL)
4197 YYACCEPT;
4198
Chris Lattneredd9b032006-01-23 23:05:42 +00004199#if YYDEBUG != 0
4200 if (yydebug)
4201 fprintf(stderr, "Shifting error token, ");
4202#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004203
4204 *++yyvsp = yylval;
Chris Lattneredd9b032006-01-23 23:05:42 +00004205#ifdef YYLSP_NEEDED
4206 *++yylsp = yylloc;
4207#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004208
4209 yystate = yyn;
4210 goto yynewstate;
4211
Chris Lattneredd9b032006-01-23 23:05:42 +00004212 yyacceptlab:
4213 /* YYACCEPT comes here. */
4214 if (yyfree_stacks)
4215 {
4216 free (yyss);
4217 free (yyvs);
4218#ifdef YYLSP_NEEDED
4219 free (yyls);
Reid Spencerb4f9a6f2006-01-16 21:12:35 +00004220#endif
Chris Lattneredd9b032006-01-23 23:05:42 +00004221 }
4222 return 0;
Reid Spencerc8a9faf2006-01-19 01:21:04 +00004223
Chris Lattneredd9b032006-01-23 23:05:42 +00004224 yyabortlab:
4225 /* YYABORT comes here. */
4226 if (yyfree_stacks)
4227 {
4228 free (yyss);
4229 free (yyvs);
4230#ifdef YYLSP_NEEDED
4231 free (yyls);
Reid Spencerc8a9faf2006-01-19 01:21:04 +00004232#endif
Chris Lattneredd9b032006-01-23 23:05:42 +00004233 }
4234 return 1;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004235}
Chris Lattnere0a4ee92006-01-25 22:27:16 +00004236#line 2424 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004237
4238int yyerror(const char *ErrorMsg) {
4239 std::string where
4240 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
4241 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
4242 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
4243 if (yychar == YYEMPTY || yychar == 0)
4244 errMsg += "end-of-file.";
4245 else
4246 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
4247 ThrowException(errMsg);
4248 return 0;
4249}