blob: 1b5b51be7ef622d846f01a583cee188416eaea92 [file] [log] [blame]
Reid Spencer68a24bd2005-08-27 18:50:39 +00001
Chris Lattnerd25db202006-04-08 03:55:17 +00002/* A Bison parser, made from /Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y
Chris Lattner8335e842006-01-23 23:05:42 +00003 by GNU Bison version 1.28 */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004
Chris Lattner8335e842006-01-23 23:05:42 +00005#define YYBISON 1 /* Identify Bison output. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00006
Reid Spencer68a24bd2005-08-27 18:50:39 +00007#define yyparse llvmAsmparse
Chris Lattner8335e842006-01-23 23:05:42 +00008#define yylex llvmAsmlex
Reid Spencer68a24bd2005-08-27 18:50:39 +00009#define yyerror llvmAsmerror
Chris Lattner8335e842006-01-23 23:05:42 +000010#define yylval llvmAsmlval
11#define yychar llvmAsmchar
Reid Spencer68a24bd2005-08-27 18:50:39 +000012#define yydebug llvmAsmdebug
13#define yynerrs llvmAsmnerrs
Chris Lattner8335e842006-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 Lattner66316012006-01-24 04:14:29 +000070#define MODULE 313
Chris Lattner0e9c3762006-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
Chris Lattnerd5efe842006-04-08 01:18:56 +0000110#define SHUFFLEVECTOR 353
111#define VAARG_old 354
112#define VANEXT_old 355
Reid Spencer68a24bd2005-08-27 18:50:39 +0000113
Chris Lattnerd25db202006-04-08 03:55:17 +0000114#line 14 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000115
116#include "ParserInternals.h"
117#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000118#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000119#include "llvm/Instructions.h"
120#include "llvm/Module.h"
121#include "llvm/SymbolTable.h"
Reid Spencer0b118202006-01-16 21:12:35 +0000122#include "llvm/Assembly/AutoUpgrade.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000123#include "llvm/Support/GetElementPtrTypeIterator.h"
124#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000125#include "llvm/Support/MathExtras.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000126#include <algorithm>
127#include <iostream>
128#include <list>
129#include <utility>
130
131int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
132int yylex(); // declaration" of xxx warnings.
133int yyparse();
134
135namespace llvm {
136 std::string CurFilename;
137}
138using namespace llvm;
139
140static Module *ParserResult;
141
142// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
143// relating to upreferences in the input stream.
144//
145//#define DEBUG_UPREFS 1
146#ifdef DEBUG_UPREFS
147#define UR_OUT(X) std::cerr << X
148#else
149#define UR_OUT(X)
150#endif
151
152#define YYERROR_VERBOSE 1
153
154static bool ObsoleteVarArgs;
155static bool NewVarArgs;
Chris Lattnerb475c422005-11-12 18:22:38 +0000156static BasicBlock *CurBB;
157static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000158
159
160// This contains info used when building the body of a function. It is
161// destroyed when the function is completed.
162//
163typedef std::vector<Value *> ValueList; // Numbered defs
164static void
165ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
166 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
167
168static struct PerModuleInfo {
169 Module *CurrentModule;
170 std::map<const Type *, ValueList> Values; // Module level numbered definitions
171 std::map<const Type *,ValueList> LateResolveValues;
172 std::vector<PATypeHolder> Types;
173 std::map<ValID, PATypeHolder> LateResolveTypes;
174
175 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
176 /// how they were referenced and one which line of the input they came from so
177 /// that we can resolve them later and print error messages as appropriate.
178 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
179
180 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
181 // references to global values. Global values may be referenced before they
182 // are defined, and if so, the temporary object that they represent is held
183 // here. This is used for forward references of GlobalValues.
184 //
185 typedef std::map<std::pair<const PointerType *,
186 ValID>, GlobalValue*> GlobalRefsType;
187 GlobalRefsType GlobalRefs;
188
189 void ModuleDone() {
190 // If we could not resolve some functions at function compilation time
191 // (calls to functions before they are defined), resolve them now... Types
192 // are resolved when the constant pool has been completely parsed.
193 //
194 ResolveDefinitions(LateResolveValues);
195
196 // Check to make sure that all global value forward references have been
197 // resolved!
198 //
199 if (!GlobalRefs.empty()) {
200 std::string UndefinedReferences = "Unresolved global references exist:\n";
201
202 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
203 I != E; ++I) {
204 UndefinedReferences += " " + I->first.first->getDescription() + " " +
205 I->first.second.getName() + "\n";
206 }
207 ThrowException(UndefinedReferences);
208 }
209
Reid Spencere812fb22006-01-19 01:21:04 +0000210 // Look for intrinsic functions and CallInst that need to be upgraded
Chris Lattnerd5efe842006-04-08 01:18:56 +0000211 for (Module::iterator FI = CurrentModule->begin(),
212 FE = CurrentModule->end(); FI != FE; )
Chris Lattnerc2c60382006-03-04 07:53:41 +0000213 UpgradeCallsToIntrinsic(FI++);
Reid Spencer0b118202006-01-16 21:12:35 +0000214
Reid Spencer68a24bd2005-08-27 18:50:39 +0000215 Values.clear(); // Clear out function local definitions
216 Types.clear();
217 CurrentModule = 0;
218 }
219
Reid Spencer68a24bd2005-08-27 18:50:39 +0000220 // GetForwardRefForGlobal - Check to see if there is a forward reference
221 // for this global. If so, remove it from the GlobalRefs map and return it.
222 // If not, just return null.
223 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
224 // Check to see if there is a forward reference to this global variable...
225 // if there is, eliminate it and patch the reference to use the new def'n.
226 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
227 GlobalValue *Ret = 0;
228 if (I != GlobalRefs.end()) {
229 Ret = I->second;
230 GlobalRefs.erase(I);
231 }
232 return Ret;
233 }
234} CurModule;
235
236static struct PerFunctionInfo {
237 Function *CurrentFunction; // Pointer to current function being created
238
239 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
240 std::map<const Type*, ValueList> LateResolveValues;
241 bool isDeclare; // Is this function a forward declararation?
242
243 /// BBForwardRefs - When we see forward references to basic blocks, keep
244 /// track of them here.
245 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
246 std::vector<BasicBlock*> NumberedBlocks;
247 unsigned NextBBNum;
248
249 inline PerFunctionInfo() {
250 CurrentFunction = 0;
251 isDeclare = false;
252 }
253
254 inline void FunctionStart(Function *M) {
255 CurrentFunction = M;
256 NextBBNum = 0;
257 }
258
259 void FunctionDone() {
260 NumberedBlocks.clear();
261
262 // Any forward referenced blocks left?
263 if (!BBForwardRefs.empty())
264 ThrowException("Undefined reference to label " +
265 BBForwardRefs.begin()->first->getName());
266
267 // Resolve all forward references now.
268 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
269
270 Values.clear(); // Clear out function local definitions
271 CurrentFunction = 0;
272 isDeclare = false;
273 }
274} CurFun; // Info for the current function...
275
276static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
277
278
279//===----------------------------------------------------------------------===//
280// Code to handle definitions of all the types
281//===----------------------------------------------------------------------===//
282
283static int InsertValue(Value *V,
284 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
285 if (V->hasName()) return -1; // Is this a numbered definition?
286
287 // Yes, insert the value into the value table...
288 ValueList &List = ValueTab[V->getType()];
289 List.push_back(V);
290 return List.size()-1;
291}
292
293static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
294 switch (D.Type) {
295 case ValID::NumberVal: // Is it a numbered definition?
296 // Module constants occupy the lowest numbered slots...
297 if ((unsigned)D.Num < CurModule.Types.size())
298 return CurModule.Types[(unsigned)D.Num];
299 break;
300 case ValID::NameVal: // Is it a named definition?
301 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
302 D.destroy(); // Free old strdup'd memory...
303 return N;
304 }
305 break;
306 default:
307 ThrowException("Internal parser error: Invalid symbol type reference!");
308 }
309
310 // If we reached here, we referenced either a symbol that we don't know about
311 // or an id number that hasn't been read yet. We may be referencing something
312 // forward, so just create an entry to be resolved later and get to it...
313 //
314 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
315
316
317 if (inFunctionScope()) {
318 if (D.Type == ValID::NameVal)
319 ThrowException("Reference to an undefined type: '" + D.getName() + "'");
320 else
321 ThrowException("Reference to an undefined type: #" + itostr(D.Num));
322 }
323
324 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
325 if (I != CurModule.LateResolveTypes.end())
326 return I->second;
327
328 Type *Typ = OpaqueType::get();
329 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
330 return Typ;
331 }
332
333static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
334 SymbolTable &SymTab =
335 inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() :
336 CurModule.CurrentModule->getSymbolTable();
337 return SymTab.lookup(Ty, Name);
338}
339
340// getValNonImprovising - Look up the value specified by the provided type and
341// the provided ValID. If the value exists and has already been defined, return
342// it. Otherwise return null.
343//
344static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
345 if (isa<FunctionType>(Ty))
346 ThrowException("Functions are not values and "
347 "must be referenced as pointers");
348
349 switch (D.Type) {
350 case ValID::NumberVal: { // Is it a numbered definition?
351 unsigned Num = (unsigned)D.Num;
352
353 // Module constants occupy the lowest numbered slots...
354 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
355 if (VI != CurModule.Values.end()) {
356 if (Num < VI->second.size())
357 return VI->second[Num];
358 Num -= VI->second.size();
359 }
360
361 // Make sure that our type is within bounds
362 VI = CurFun.Values.find(Ty);
363 if (VI == CurFun.Values.end()) return 0;
364
365 // Check that the number is within bounds...
366 if (VI->second.size() <= Num) return 0;
367
368 return VI->second[Num];
369 }
370
371 case ValID::NameVal: { // Is it a named definition?
372 Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
373 if (N == 0) return 0;
374
375 D.destroy(); // Free old strdup'd memory...
376 return N;
377 }
378
379 // Check to make sure that "Ty" is an integral type, and that our
380 // value will fit into the specified type...
381 case ValID::ConstSIntVal: // Is it a constant pool reference??
382 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64))
383 ThrowException("Signed integral constant '" +
384 itostr(D.ConstPool64) + "' is invalid for type '" +
385 Ty->getDescription() + "'!");
386 return ConstantSInt::get(Ty, D.ConstPool64);
387
388 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
389 if (!ConstantUInt::isValueValidForType(Ty, D.UConstPool64)) {
390 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) {
391 ThrowException("Integral constant '" + utostr(D.UConstPool64) +
392 "' is invalid or out of range!");
393 } else { // This is really a signed reference. Transmogrify.
394 return ConstantSInt::get(Ty, D.ConstPool64);
395 }
396 } else {
397 return ConstantUInt::get(Ty, D.UConstPool64);
398 }
399
400 case ValID::ConstFPVal: // Is it a floating point const pool reference?
401 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
402 ThrowException("FP constant invalid for type!!");
403 return ConstantFP::get(Ty, D.ConstPoolFP);
404
405 case ValID::ConstNullVal: // Is it a null value?
406 if (!isa<PointerType>(Ty))
407 ThrowException("Cannot create a a non pointer null!");
408 return ConstantPointerNull::get(cast<PointerType>(Ty));
409
410 case ValID::ConstUndefVal: // Is it an undef value?
411 return UndefValue::get(Ty);
412
Chris Lattner7aa61892005-12-21 17:53:23 +0000413 case ValID::ConstZeroVal: // Is it a zero value?
414 return Constant::getNullValue(Ty);
415
Reid Spencer68a24bd2005-08-27 18:50:39 +0000416 case ValID::ConstantVal: // Fully resolved constant?
417 if (D.ConstantValue->getType() != Ty)
418 ThrowException("Constant expression type different from required type!");
419 return D.ConstantValue;
420
Chris Lattner0e9c3762006-01-25 22:27:16 +0000421 case ValID::InlineAsmVal: { // Inline asm expression
422 const PointerType *PTy = dyn_cast<PointerType>(Ty);
423 const FunctionType *FTy =
424 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
425 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints))
426 ThrowException("Invalid type for asm constraint string!");
427 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
428 D.IAD->HasSideEffects);
429 D.destroy(); // Free InlineAsmDescriptor.
430 return IA;
431 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000432 default:
433 assert(0 && "Unhandled case!");
434 return 0;
435 } // End of switch
436
437 assert(0 && "Unhandled case!");
438 return 0;
439}
440
441// getVal - This function is identical to getValNonImprovising, except that if a
442// value is not already defined, it "improvises" by creating a placeholder var
443// that looks and acts just like the requested variable. When the value is
444// defined later, all uses of the placeholder variable are replaced with the
445// real thing.
446//
447static Value *getVal(const Type *Ty, const ValID &ID) {
448 if (Ty == Type::LabelTy)
449 ThrowException("Cannot use a basic block here");
450
451 // See if the value has already been defined.
452 Value *V = getValNonImprovising(Ty, ID);
453 if (V) return V;
454
455 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
456 ThrowException("Invalid use of a composite type!");
457
458 // If we reached here, we referenced either a symbol that we don't know about
459 // or an id number that hasn't been read yet. We may be referencing something
460 // forward, so just create an entry to be resolved later and get to it...
461 //
462 V = new Argument(Ty);
463
464 // Remember where this forward reference came from. FIXME, shouldn't we try
465 // to recycle these things??
466 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
467 llvmAsmlineno)));
468
469 if (inFunctionScope())
470 InsertValue(V, CurFun.LateResolveValues);
471 else
472 InsertValue(V, CurModule.LateResolveValues);
473 return V;
474}
475
476/// getBBVal - This is used for two purposes:
477/// * If isDefinition is true, a new basic block with the specified ID is being
478/// defined.
479/// * If isDefinition is true, this is a reference to a basic block, which may
480/// or may not be a forward reference.
481///
482static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
483 assert(inFunctionScope() && "Can't get basic block at global scope!");
484
485 std::string Name;
486 BasicBlock *BB = 0;
487 switch (ID.Type) {
488 default: ThrowException("Illegal label reference " + ID.getName());
489 case ValID::NumberVal: // Is it a numbered definition?
490 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
491 CurFun.NumberedBlocks.resize(ID.Num+1);
492 BB = CurFun.NumberedBlocks[ID.Num];
493 break;
494 case ValID::NameVal: // Is it a named definition?
495 Name = ID.Name;
496 if (Value *N = CurFun.CurrentFunction->
497 getSymbolTable().lookup(Type::LabelTy, Name))
498 BB = cast<BasicBlock>(N);
499 break;
500 }
501
502 // See if the block has already been defined.
503 if (BB) {
504 // If this is the definition of the block, make sure the existing value was
505 // just a forward reference. If it was a forward reference, there will be
506 // an entry for it in the PlaceHolderInfo map.
507 if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
508 // The existing value was a definition, not a forward reference.
509 ThrowException("Redefinition of label " + ID.getName());
510
511 ID.destroy(); // Free strdup'd memory.
512 return BB;
513 }
514
515 // Otherwise this block has not been seen before.
516 BB = new BasicBlock("", CurFun.CurrentFunction);
517 if (ID.Type == ValID::NameVal) {
518 BB->setName(ID.Name);
519 } else {
520 CurFun.NumberedBlocks[ID.Num] = BB;
521 }
522
523 // If this is not a definition, keep track of it so we can use it as a forward
524 // reference.
525 if (!isDefinition) {
526 // Remember where this forward reference came from.
527 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
528 } else {
529 // The forward declaration could have been inserted anywhere in the
530 // function: insert it into the correct place now.
531 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
532 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
533 }
534 ID.destroy();
535 return BB;
536}
537
538
539//===----------------------------------------------------------------------===//
540// Code to handle forward references in instructions
541//===----------------------------------------------------------------------===//
542//
543// This code handles the late binding needed with statements that reference
544// values not defined yet... for example, a forward branch, or the PHI node for
545// a loop body.
546//
547// This keeps a table (CurFun.LateResolveValues) of all such forward references
548// and back patchs after we are done.
549//
550
551// ResolveDefinitions - If we could not resolve some defs at parsing
552// time (forward branches, phi functions for loops, etc...) resolve the
553// defs now...
554//
555static void
556ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
557 std::map<const Type*,ValueList> *FutureLateResolvers) {
558 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
559 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
560 E = LateResolvers.end(); LRI != E; ++LRI) {
561 ValueList &List = LRI->second;
562 while (!List.empty()) {
563 Value *V = List.back();
564 List.pop_back();
565
566 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
567 CurModule.PlaceHolderInfo.find(V);
568 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
569
570 ValID &DID = PHI->second.first;
571
572 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
573 if (TheRealValue) {
574 V->replaceAllUsesWith(TheRealValue);
575 delete V;
576 CurModule.PlaceHolderInfo.erase(PHI);
577 } else if (FutureLateResolvers) {
578 // Functions have their unresolved items forwarded to the module late
579 // resolver table
580 InsertValue(V, *FutureLateResolvers);
581 } else {
582 if (DID.Type == ValID::NameVal)
583 ThrowException("Reference to an invalid definition: '" +DID.getName()+
584 "' of type '" + V->getType()->getDescription() + "'",
585 PHI->second.second);
586 else
587 ThrowException("Reference to an invalid definition: #" +
588 itostr(DID.Num) + " of type '" +
589 V->getType()->getDescription() + "'",
590 PHI->second.second);
591 }
592 }
593 }
594
595 LateResolvers.clear();
596}
597
598// ResolveTypeTo - A brand new type was just declared. This means that (if
599// name is not null) things referencing Name can be resolved. Otherwise, things
600// refering to the number can be resolved. Do this now.
601//
602static void ResolveTypeTo(char *Name, const Type *ToTy) {
603 ValID D;
604 if (Name) D = ValID::create(Name);
605 else D = ValID::create((int)CurModule.Types.size());
606
607 std::map<ValID, PATypeHolder>::iterator I =
608 CurModule.LateResolveTypes.find(D);
609 if (I != CurModule.LateResolveTypes.end()) {
610 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
611 CurModule.LateResolveTypes.erase(I);
612 }
613}
614
615// setValueName - Set the specified value to the name given. The name may be
616// null potentially, in which case this is a noop. The string passed in is
617// assumed to be a malloc'd string buffer, and is free'd by this function.
618//
619static void setValueName(Value *V, char *NameStr) {
620 if (NameStr) {
621 std::string Name(NameStr); // Copy string
622 free(NameStr); // Free old string
623
624 if (V->getType() == Type::VoidTy)
625 ThrowException("Can't assign name '" + Name+"' to value with void type!");
626
627 assert(inFunctionScope() && "Must be in function scope!");
628 SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable();
629 if (ST.lookup(V->getType(), Name))
630 ThrowException("Redefinition of value named '" + Name + "' in the '" +
631 V->getType()->getDescription() + "' type plane!");
632
633 // Set the name.
634 V->setName(Name);
635 }
636}
637
638/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
639/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +0000640static GlobalVariable *
641ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
642 bool isConstantGlobal, const Type *Ty,
643 Constant *Initializer) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000644 if (isa<FunctionType>(Ty))
645 ThrowException("Cannot declare global vars of function type!");
646
647 const PointerType *PTy = PointerType::get(Ty);
648
649 std::string Name;
650 if (NameStr) {
651 Name = NameStr; // Copy string
652 free(NameStr); // Free old string
653 }
654
655 // See if this global value was forward referenced. If so, recycle the
656 // object.
657 ValID ID;
658 if (!Name.empty()) {
659 ID = ValID::create((char*)Name.c_str());
660 } else {
661 ID = ValID::create((int)CurModule.Values[PTy].size());
662 }
663
664 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
665 // Move the global to the end of the list, from whereever it was
666 // previously inserted.
667 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
668 CurModule.CurrentModule->getGlobalList().remove(GV);
669 CurModule.CurrentModule->getGlobalList().push_back(GV);
670 GV->setInitializer(Initializer);
671 GV->setLinkage(Linkage);
672 GV->setConstant(isConstantGlobal);
673 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000674 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000675 }
676
677 // If this global has a name, check to see if there is already a definition
678 // of this global in the module. If so, merge as appropriate. Note that
679 // this is really just a hack around problems in the CFE. :(
680 if (!Name.empty()) {
681 // We are a simple redefinition of a value, check to see if it is defined
682 // the same as the old one.
683 if (GlobalVariable *EGV =
684 CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
685 // We are allowed to redefine a global variable in two circumstances:
686 // 1. If at least one of the globals is uninitialized or
687 // 2. If both initializers have the same value.
688 //
689 if (!EGV->hasInitializer() || !Initializer ||
690 EGV->getInitializer() == Initializer) {
691
692 // Make sure the existing global version gets the initializer! Make
693 // sure that it also gets marked const if the new version is.
694 if (Initializer && !EGV->hasInitializer())
695 EGV->setInitializer(Initializer);
696 if (isConstantGlobal)
697 EGV->setConstant(true);
698 EGV->setLinkage(Linkage);
Chris Lattnerb475c422005-11-12 18:22:38 +0000699 return EGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000700 }
701
702 ThrowException("Redefinition of global variable named '" + Name +
703 "' in the '" + Ty->getDescription() + "' type plane!");
704 }
705 }
706
707 // Otherwise there is no existing GV to use, create one now.
708 GlobalVariable *GV =
709 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
710 CurModule.CurrentModule);
711 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000712 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000713}
714
715// setTypeName - Set the specified type to the name given. The name may be
716// null potentially, in which case this is a noop. The string passed in is
717// assumed to be a malloc'd string buffer, and is freed by this function.
718//
719// This function returns true if the type has already been defined, but is
720// allowed to be redefined in the specified context. If the name is a new name
721// for the type plane, it is inserted and false is returned.
722static bool setTypeName(const Type *T, char *NameStr) {
723 assert(!inFunctionScope() && "Can't give types function-local names!");
724 if (NameStr == 0) return false;
725
726 std::string Name(NameStr); // Copy string
727 free(NameStr); // Free old string
728
729 // We don't allow assigning names to void type
730 if (T == Type::VoidTy)
731 ThrowException("Can't assign name '" + Name + "' to the void type!");
732
733 // Set the type name, checking for conflicts as we do so.
734 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
735
736 if (AlreadyExists) { // Inserting a name that is already defined???
737 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
738 assert(Existing && "Conflict but no matching type?");
739
740 // There is only one case where this is allowed: when we are refining an
741 // opaque type. In this case, Existing will be an opaque type.
742 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
743 // We ARE replacing an opaque type!
744 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
745 return true;
746 }
747
748 // Otherwise, this is an attempt to redefine a type. That's okay if
749 // the redefinition is identical to the original. This will be so if
750 // Existing and T point to the same Type object. In this one case we
751 // allow the equivalent redefinition.
752 if (Existing == T) return true; // Yes, it's equal.
753
754 // Any other kind of (non-equivalent) redefinition is an error.
755 ThrowException("Redefinition of type named '" + Name + "' in the '" +
756 T->getDescription() + "' type plane!");
757 }
758
759 return false;
760}
761
762//===----------------------------------------------------------------------===//
763// Code for handling upreferences in type names...
764//
765
766// TypeContains - Returns true if Ty directly contains E in it.
767//
768static bool TypeContains(const Type *Ty, const Type *E) {
769 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
770 E) != Ty->subtype_end();
771}
772
773namespace {
774 struct UpRefRecord {
775 // NestingLevel - The number of nesting levels that need to be popped before
776 // this type is resolved.
777 unsigned NestingLevel;
778
779 // LastContainedTy - This is the type at the current binding level for the
780 // type. Every time we reduce the nesting level, this gets updated.
781 const Type *LastContainedTy;
782
783 // UpRefTy - This is the actual opaque type that the upreference is
784 // represented with.
785 OpaqueType *UpRefTy;
786
787 UpRefRecord(unsigned NL, OpaqueType *URTy)
788 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
789 };
790}
791
792// UpRefs - A list of the outstanding upreferences that need to be resolved.
793static std::vector<UpRefRecord> UpRefs;
794
795/// HandleUpRefs - Every time we finish a new layer of types, this function is
796/// called. It loops through the UpRefs vector, which is a list of the
797/// currently active types. For each type, if the up reference is contained in
798/// the newly completed type, we decrement the level count. When the level
799/// count reaches zero, the upreferenced type is the type that is passed in:
800/// thus we can complete the cycle.
801///
802static PATypeHolder HandleUpRefs(const Type *ty) {
803 if (!ty->isAbstract()) return ty;
804 PATypeHolder Ty(ty);
805 UR_OUT("Type '" << Ty->getDescription() <<
806 "' newly formed. Resolving upreferences.\n" <<
807 UpRefs.size() << " upreferences active!\n");
808
809 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
810 // to zero), we resolve them all together before we resolve them to Ty. At
811 // the end of the loop, if there is anything to resolve to Ty, it will be in
812 // this variable.
813 OpaqueType *TypeToResolve = 0;
814
815 for (unsigned i = 0; i != UpRefs.size(); ++i) {
816 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
817 << UpRefs[i].second->getDescription() << ") = "
818 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
819 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
820 // Decrement level of upreference
821 unsigned Level = --UpRefs[i].NestingLevel;
822 UpRefs[i].LastContainedTy = Ty;
823 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
824 if (Level == 0) { // Upreference should be resolved!
825 if (!TypeToResolve) {
826 TypeToResolve = UpRefs[i].UpRefTy;
827 } else {
828 UR_OUT(" * Resolving upreference for "
829 << UpRefs[i].second->getDescription() << "\n";
830 std::string OldName = UpRefs[i].UpRefTy->getDescription());
831 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
832 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
833 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
834 }
835 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
836 --i; // Do not skip the next element...
837 }
838 }
839 }
840
841 if (TypeToResolve) {
842 UR_OUT(" * Resolving upreference for "
843 << UpRefs[i].second->getDescription() << "\n";
844 std::string OldName = TypeToResolve->getDescription());
845 TypeToResolve->refineAbstractTypeTo(Ty);
846 }
847
848 return Ty;
849}
850
851
852// common code from the two 'RunVMAsmParser' functions
853 static Module * RunParser(Module * M) {
854
855 llvmAsmlineno = 1; // Reset the current line number...
856 ObsoleteVarArgs = false;
857 NewVarArgs = false;
858
859 CurModule.CurrentModule = M;
860 yyparse(); // Parse the file, potentially throwing exception
861
862 Module *Result = ParserResult;
863 ParserResult = 0;
864
865 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
866 {
867 Function* F;
868 if ((F = Result->getNamedFunction("llvm.va_start"))
869 && F->getFunctionType()->getNumParams() == 0)
870 ObsoleteVarArgs = true;
871 if((F = Result->getNamedFunction("llvm.va_copy"))
872 && F->getFunctionType()->getNumParams() == 1)
873 ObsoleteVarArgs = true;
874 }
875
876 if (ObsoleteVarArgs && NewVarArgs)
877 ThrowException("This file is corrupt: it uses both new and old style varargs");
878
879 if(ObsoleteVarArgs) {
880 if(Function* F = Result->getNamedFunction("llvm.va_start")) {
881 if (F->arg_size() != 0)
882 ThrowException("Obsolete va_start takes 0 argument!");
883
884 //foo = va_start()
885 // ->
886 //bar = alloca typeof(foo)
887 //va_start(bar)
888 //foo = load bar
889
890 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
891 const Type* ArgTy = F->getFunctionType()->getReturnType();
892 const Type* ArgTyPtr = PointerType::get(ArgTy);
893 Function* NF = Result->getOrInsertFunction("llvm.va_start",
Jeff Cohen66c5fd62005-10-23 04:37:20 +0000894 RetTy, ArgTyPtr, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000895
896 while (!F->use_empty()) {
897 CallInst* CI = cast<CallInst>(F->use_back());
898 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
899 new CallInst(NF, bar, "", CI);
900 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
901 CI->replaceAllUsesWith(foo);
902 CI->getParent()->getInstList().erase(CI);
903 }
904 Result->getFunctionList().erase(F);
905 }
906
907 if(Function* F = Result->getNamedFunction("llvm.va_end")) {
908 if(F->arg_size() != 1)
909 ThrowException("Obsolete va_end takes 1 argument!");
910
911 //vaend foo
912 // ->
913 //bar = alloca 1 of typeof(foo)
914 //vaend bar
915 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
916 const Type* ArgTy = F->getFunctionType()->getParamType(0);
917 const Type* ArgTyPtr = PointerType::get(ArgTy);
918 Function* NF = Result->getOrInsertFunction("llvm.va_end",
Jeff Cohen66c5fd62005-10-23 04:37:20 +0000919 RetTy, ArgTyPtr, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000920
921 while (!F->use_empty()) {
922 CallInst* CI = cast<CallInst>(F->use_back());
923 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
924 new StoreInst(CI->getOperand(1), bar, CI);
925 new CallInst(NF, bar, "", CI);
926 CI->getParent()->getInstList().erase(CI);
927 }
928 Result->getFunctionList().erase(F);
929 }
930
931 if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
932 if(F->arg_size() != 1)
933 ThrowException("Obsolete va_copy takes 1 argument!");
934 //foo = vacopy(bar)
935 // ->
936 //a = alloca 1 of typeof(foo)
937 //b = alloca 1 of typeof(foo)
938 //store bar -> b
939 //vacopy(a, b)
940 //foo = load a
941
942 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
943 const Type* ArgTy = F->getFunctionType()->getReturnType();
944 const Type* ArgTyPtr = PointerType::get(ArgTy);
945 Function* NF = Result->getOrInsertFunction("llvm.va_copy",
Jeff Cohen66c5fd62005-10-23 04:37:20 +0000946 RetTy, ArgTyPtr, ArgTyPtr,
947 (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000948
949 while (!F->use_empty()) {
950 CallInst* CI = cast<CallInst>(F->use_back());
951 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
952 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
953 new StoreInst(CI->getOperand(1), b, CI);
954 new CallInst(NF, a, b, "", CI);
955 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
956 CI->replaceAllUsesWith(foo);
957 CI->getParent()->getInstList().erase(CI);
958 }
959 Result->getFunctionList().erase(F);
960 }
961 }
962
963 return Result;
964
965 }
966
967//===----------------------------------------------------------------------===//
968// RunVMAsmParser - Define an interface to this parser
969//===----------------------------------------------------------------------===//
970//
971Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
972 set_scan_file(F);
973
974 CurFilename = Filename;
975 return RunParser(new Module(CurFilename));
976}
977
978Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
979 set_scan_string(AsmString);
980
981 CurFilename = "from_memory";
982 if (M == NULL) {
983 return RunParser(new Module (CurFilename));
984 } else {
985 return RunParser(M);
986 }
987}
988
989
Chris Lattnerd25db202006-04-08 03:55:17 +0000990#line 890 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +0000991typedef union {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000992 llvm::Module *ModuleVal;
993 llvm::Function *FunctionVal;
994 std::pair<llvm::PATypeHolder*, char*> *ArgVal;
995 llvm::BasicBlock *BasicBlockVal;
996 llvm::TerminatorInst *TermInstVal;
997 llvm::Instruction *InstVal;
998 llvm::Constant *ConstVal;
999
1000 const llvm::Type *PrimType;
1001 llvm::PATypeHolder *TypeVal;
1002 llvm::Value *ValueVal;
1003
1004 std::vector<std::pair<llvm::PATypeHolder*,char*> > *ArgList;
1005 std::vector<llvm::Value*> *ValueList;
1006 std::list<llvm::PATypeHolder> *TypeList;
1007 // Represent the RHS of PHI node
1008 std::list<std::pair<llvm::Value*,
1009 llvm::BasicBlock*> > *PHIList;
1010 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1011 std::vector<llvm::Constant*> *ConstVector;
1012
1013 llvm::GlobalValue::LinkageTypes Linkage;
1014 int64_t SInt64Val;
1015 uint64_t UInt64Val;
1016 int SIntVal;
1017 unsigned UIntVal;
1018 double FPVal;
1019 bool BoolVal;
1020
1021 char *StrVal; // This memory is strdup'd!
1022 llvm::ValID ValIDVal; // strdup'd memory maybe!
1023
1024 llvm::Instruction::BinaryOps BinaryOpVal;
1025 llvm::Instruction::TermOps TermOpVal;
1026 llvm::Instruction::MemoryOps MemOpVal;
1027 llvm::Instruction::OtherOps OtherOpVal;
1028 llvm::Module::Endianness Endianness;
1029} YYSTYPE;
Chris Lattner8335e842006-01-23 23:05:42 +00001030#include <stdio.h>
1031
1032#ifndef __cplusplus
1033#ifndef __STDC__
1034#define const
1035#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001036#endif
1037
1038
1039
Chris Lattnerd25db202006-04-08 03:55:17 +00001040#define YYFINAL 495
Chris Lattner8335e842006-01-23 23:05:42 +00001041#define YYFLAG -32768
Chris Lattnerd5efe842006-04-08 01:18:56 +00001042#define YYNTBASE 116
Reid Spencer68a24bd2005-08-27 18:50:39 +00001043
Chris Lattnerd5efe842006-04-08 01:18:56 +00001044#define YYTRANSLATE(x) ((unsigned)(x) <= 355 ? yytranslate[x] : 187)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001045
Chris Lattner8335e842006-01-23 23:05:42 +00001046static const char yytranslate[] = { 0,
1047 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1048 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1049 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001050 2, 2, 2, 2, 2, 2, 2, 2, 2, 105,
1051 106, 114, 2, 103, 2, 2, 2, 2, 2, 2,
1052 2, 2, 2, 2, 2, 2, 2, 2, 2, 110,
1053 102, 111, 2, 2, 2, 2, 2, 2, 2, 2,
Chris Lattner8335e842006-01-23 23:05:42 +00001054 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1055 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001056 107, 104, 109, 2, 2, 2, 2, 2, 115, 2,
Chris Lattner8335e842006-01-23 23:05:42 +00001057 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001058 2, 2, 2, 2, 2, 2, 2, 2, 2, 108,
1059 2, 2, 112, 2, 113, 2, 2, 2, 2, 2,
Chris Lattner8335e842006-01-23 23:05:42 +00001060 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, 2, 2, 2, 2, 2,
1072 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
1073 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1074 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1075 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
1076 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
1077 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
1078 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1079 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1080 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1081 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001082 97, 98, 99, 100, 101
Chris Lattner8335e842006-01-23 23:05:42 +00001083};
Reid Spencer68a24bd2005-08-27 18:50:39 +00001084
Chris Lattner8335e842006-01-23 23:05:42 +00001085#if YYDEBUG != 0
1086static const short yyprhs[] = { 0,
1087 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
1088 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
1089 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
1090 60, 62, 64, 67, 68, 70, 72, 74, 76, 77,
1091 78, 80, 82, 84, 87, 88, 91, 92, 96, 99,
1092 100, 102, 103, 107, 109, 112, 114, 116, 118, 120,
1093 122, 124, 126, 128, 130, 132, 134, 136, 138, 140,
1094 142, 144, 146, 148, 150, 152, 154, 157, 162, 168,
1095 174, 178, 181, 184, 186, 190, 192, 196, 198, 199,
1096 204, 208, 212, 217, 222, 226, 229, 232, 235, 238,
1097 241, 244, 247, 250, 253, 256, 263, 269, 278, 285,
Chris Lattnerd25db202006-04-08 03:55:17 +00001098 292, 299, 306, 313, 322, 331, 335, 337, 339, 341,
1099 343, 346, 349, 354, 357, 359, 364, 367, 372, 373,
1100 381, 382, 390, 394, 399, 400, 402, 404, 406, 410,
1101 414, 418, 422, 426, 428, 429, 431, 433, 435, 436,
1102 439, 443, 445, 447, 451, 453, 454, 463, 465, 467,
1103 471, 473, 475, 478, 479, 483, 484, 486, 488, 490,
1104 492, 494, 496, 498, 500, 502, 506, 508, 514, 516,
1105 518, 520, 522, 525, 528, 531, 535, 538, 539, 541,
1106 544, 547, 551, 561, 571, 580, 594, 596, 598, 605,
1107 611, 614, 621, 629, 631, 635, 637, 638, 641, 643,
1108 649, 655, 661, 664, 669, 674, 681, 686, 691, 696,
1109 701, 708, 715, 718, 726, 728, 731, 732, 734, 735,
1110 739, 746, 750, 757, 760, 765, 772
Chris Lattner8335e842006-01-23 23:05:42 +00001111};
Reid Spencer68a24bd2005-08-27 18:50:39 +00001112
Chris Lattner8335e842006-01-23 23:05:42 +00001113static const short yyrhs[] = { 5,
Chris Lattner0e9c3762006-01-25 22:27:16 +00001114 0, 6, 0, 3, 0, 4, 0, 71, 0, 72,
1115 0, 73, 0, 74, 0, 75, 0, 76, 0, 77,
1116 0, 78, 0, 79, 0, 80, 0, 81, 0, 82,
1117 0, 83, 0, 84, 0, 94, 0, 95, 0, 16,
Chris Lattner8335e842006-01-23 23:05:42 +00001118 0, 14, 0, 12, 0, 10, 0, 17, 0, 15,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001119 0, 13, 0, 11, 0, 122, 0, 123, 0, 18,
1120 0, 19, 0, 156, 102, 0, 0, 41, 0, 42,
Chris Lattner0e9c3762006-01-25 22:27:16 +00001121 0, 43, 0, 44, 0, 0, 0, 62, 0, 63,
1122 0, 64, 0, 61, 4, 0, 0, 54, 4, 0,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001123 0, 103, 54, 4, 0, 34, 24, 0, 0, 131,
1124 0, 0, 103, 134, 133, 0, 131, 0, 54, 4,
1125 0, 137, 0, 8, 0, 139, 0, 8, 0, 139,
Chris Lattner8335e842006-01-23 23:05:42 +00001126 0, 9, 0, 10, 0, 11, 0, 12, 0, 13,
1127 0, 14, 0, 15, 0, 16, 0, 17, 0, 18,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001128 0, 19, 0, 20, 0, 21, 0, 45, 0, 138,
1129 0, 170, 0, 104, 4, 0, 136, 105, 141, 106,
1130 0, 107, 4, 108, 139, 109, 0, 110, 4, 108,
1131 139, 111, 0, 112, 140, 113, 0, 112, 113, 0,
1132 139, 114, 0, 139, 0, 140, 103, 139, 0, 140,
1133 0, 140, 103, 37, 0, 37, 0, 0, 137, 107,
1134 144, 109, 0, 137, 107, 109, 0, 137, 115, 24,
1135 0, 137, 110, 144, 111, 0, 137, 112, 144, 113,
1136 0, 137, 112, 113, 0, 137, 38, 0, 137, 39,
1137 0, 137, 170, 0, 137, 143, 0, 137, 26, 0,
1138 122, 117, 0, 123, 4, 0, 9, 27, 0, 9,
1139 28, 0, 125, 7, 0, 92, 105, 142, 36, 137,
1140 106, 0, 90, 105, 142, 184, 106, 0, 93, 105,
1141 142, 103, 142, 103, 142, 106, 0, 118, 105, 142,
1142 103, 142, 106, 0, 119, 105, 142, 103, 142, 106,
1143 0, 120, 105, 142, 103, 142, 106, 0, 121, 105,
1144 142, 103, 142, 106, 0, 97, 105, 142, 103, 142,
Chris Lattnerd25db202006-04-08 03:55:17 +00001145 106, 0, 98, 105, 142, 103, 142, 103, 142, 106,
1146 0, 99, 105, 142, 103, 142, 103, 142, 106, 0,
1147 144, 103, 142, 0, 142, 0, 32, 0, 33, 0,
1148 147, 0, 147, 165, 0, 147, 166, 0, 147, 59,
1149 58, 151, 0, 147, 25, 0, 148, 0, 148, 126,
1150 20, 135, 0, 148, 166, 0, 148, 59, 58, 151,
1151 0, 0, 148, 126, 127, 145, 142, 149, 133, 0,
1152 0, 148, 126, 47, 145, 137, 150, 133, 0, 148,
1153 48, 153, 0, 148, 55, 102, 154, 0, 0, 24,
1154 0, 53, 0, 52, 0, 50, 102, 152, 0, 51,
1155 102, 4, 0, 49, 102, 24, 0, 107, 155, 109,
1156 0, 155, 103, 24, 0, 24, 0, 0, 22, 0,
1157 24, 0, 156, 0, 0, 137, 157, 0, 159, 103,
1158 158, 0, 158, 0, 159, 0, 159, 103, 37, 0,
1159 37, 0, 0, 128, 135, 156, 105, 160, 106, 132,
1160 129, 0, 29, 0, 112, 0, 127, 161, 162, 0,
1161 30, 0, 113, 0, 173, 164, 0, 0, 31, 167,
1162 161, 0, 0, 60, 0, 3, 0, 4, 0, 7,
1163 0, 27, 0, 28, 0, 38, 0, 39, 0, 26,
1164 0, 110, 144, 111, 0, 143, 0, 58, 168, 24,
1165 103, 24, 0, 116, 0, 156, 0, 170, 0, 169,
1166 0, 137, 171, 0, 173, 174, 0, 163, 174, 0,
1167 175, 126, 176, 0, 175, 178, 0, 0, 23, 0,
1168 65, 172, 0, 65, 8, 0, 66, 21, 171, 0,
1169 66, 9, 171, 103, 21, 171, 103, 21, 171, 0,
1170 67, 124, 171, 103, 21, 171, 107, 177, 109, 0,
1171 67, 124, 171, 103, 21, 171, 107, 109, 0, 68,
1172 128, 135, 171, 105, 181, 106, 36, 21, 171, 69,
1173 21, 171, 0, 69, 0, 70, 0, 177, 124, 169,
1174 103, 21, 171, 0, 124, 169, 103, 21, 171, 0,
1175 126, 183, 0, 137, 107, 171, 103, 171, 109, 0,
1176 179, 103, 107, 171, 103, 171, 109, 0, 172, 0,
1177 180, 103, 172, 0, 180, 0, 0, 57, 56, 0,
1178 56, 0, 118, 137, 171, 103, 171, 0, 119, 137,
1179 171, 103, 171, 0, 120, 137, 171, 103, 171, 0,
1180 46, 172, 0, 121, 172, 103, 172, 0, 92, 172,
1181 36, 137, 0, 93, 172, 103, 172, 103, 172, 0,
1182 96, 172, 103, 137, 0, 100, 172, 103, 137, 0,
1183 101, 172, 103, 137, 0, 97, 172, 103, 172, 0,
1184 98, 172, 103, 172, 103, 172, 0, 99, 172, 103,
1185 172, 103, 172, 0, 91, 179, 0, 182, 128, 135,
1186 171, 105, 181, 106, 0, 186, 0, 103, 180, 0,
1187 0, 35, 0, 0, 85, 137, 130, 0, 85, 137,
1188 103, 15, 171, 130, 0, 86, 137, 130, 0, 86,
1189 137, 103, 15, 171, 130, 0, 87, 172, 0, 185,
1190 88, 137, 171, 0, 185, 89, 172, 103, 137, 171,
1191 0, 90, 137, 171, 184, 0
Chris Lattner8335e842006-01-23 23:05:42 +00001192};
Reid Spencer68a24bd2005-08-27 18:50:39 +00001193
1194#endif
1195
Chris Lattner8335e842006-01-23 23:05:42 +00001196#if YYDEBUG != 0
1197static const short yyrline[] = { 0,
Chris Lattner0e9c3762006-01-25 22:27:16 +00001198 1010, 1011, 1018, 1019, 1028, 1028, 1028, 1028, 1028, 1029,
1199 1029, 1029, 1030, 1030, 1030, 1030, 1030, 1030, 1032, 1032,
1200 1036, 1036, 1036, 1036, 1037, 1037, 1037, 1037, 1038, 1038,
1201 1039, 1039, 1042, 1045, 1049, 1049, 1050, 1051, 1052, 1055,
1202 1055, 1056, 1057, 1058, 1067, 1067, 1073, 1073, 1081, 1088,
1203 1088, 1094, 1094, 1096, 1100, 1113, 1113, 1114, 1114, 1116,
1204 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1126, 1126, 1126,
1205 1126, 1126, 1126, 1127, 1130, 1133, 1139, 1146, 1158, 1162,
1206 1173, 1182, 1185, 1193, 1197, 1202, 1203, 1206, 1209, 1219,
1207 1244, 1257, 1286, 1311, 1331, 1343, 1352, 1356, 1415, 1421,
1208 1429, 1434, 1439, 1442, 1445, 1452, 1462, 1493, 1500, 1521,
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00001209 1531, 1536, 1543, 1548, 1553, 1561, 1564, 1571, 1571, 1581,
1210 1588, 1592, 1595, 1598, 1601, 1614, 1634, 1636, 1638, 1641,
1211 1644, 1648, 1651, 1653, 1655, 1659, 1671, 1672, 1674, 1677,
1212 1685, 1690, 1692, 1696, 1700, 1708, 1708, 1709, 1709, 1711,
1213 1717, 1722, 1728, 1731, 1736, 1740, 1744, 1830, 1830, 1832,
1214 1840, 1840, 1842, 1846, 1846, 1855, 1858, 1862, 1865, 1868,
1215 1871, 1874, 1877, 1880, 1883, 1886, 1910, 1913, 1926, 1929,
1216 1934, 1934, 1940, 1944, 1947, 1955, 1964, 1968, 1978, 1989,
1217 1992, 1995, 1998, 2001, 2015, 2019, 2072, 2075, 2081, 2089,
1218 2099, 2106, 2111, 2118, 2122, 2128, 2128, 2130, 2133, 2139,
1219 2151, 2162, 2172, 2184, 2191, 2198, 2205, 2210, 2229, 2251,
1220 2256, 2261, 2266, 2280, 2337, 2343, 2345, 2349, 2352, 2358,
1221 2362, 2366, 2370, 2374, 2381, 2391, 2404
Chris Lattner8335e842006-01-23 23:05:42 +00001222};
1223#endif
1224
1225
1226#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
1227
1228static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL",
1229"EUINT64VAL","SINTVAL","UINTVAL","FPVAL","VOID","BOOL","SBYTE","UBYTE","SHORT",
1230"USHORT","INT","UINT","LONG","ULONG","FLOAT","DOUBLE","TYPE","LABEL","VAR_ID",
1231"LABELSTR","STRINGCONSTANT","IMPLEMENTATION","ZEROINITIALIZER","TRUETOK","FALSETOK",
1232"BEGINTOK","ENDTOK","DECLARE","GLOBAL","CONSTANT","SECTION","VOLATILE","TO",
1233"DOTDOTDOT","NULL_TOK","UNDEF","CONST","INTERNAL","LINKONCE","WEAK","APPENDING",
1234"OPAQUE","NOT","EXTERNAL","TARGET","TRIPLE","ENDIAN","POINTERSIZE","LITTLE",
Chris Lattner0e9c3762006-01-25 22:27:16 +00001235"BIG","ALIGN","DEPLIBS","CALL","TAIL","ASM_TOK","MODULE","SIDEEFFECT","CC_TOK",
1236"CCC_TOK","FASTCC_TOK","COLDCC_TOK","RET","BR","SWITCH","INVOKE","UNWIND","UNREACHABLE",
Chris Lattner66316012006-01-24 04:14:29 +00001237"ADD","SUB","MUL","DIV","REM","AND","OR","XOR","SETLE","SETGE","SETLT","SETGT",
1238"SETEQ","SETNE","MALLOC","ALLOCA","FREE","LOAD","STORE","GETELEMENTPTR","PHI_TOK",
Chris Lattnerd5efe842006-04-08 01:18:56 +00001239"CAST","SELECT","SHL","SHR","VAARG","EXTRACTELEMENT","INSERTELEMENT","SHUFFLEVECTOR",
1240"VAARG_old","VANEXT_old","'='","','","'\\\\'","'('","')'","'['","'x'","']'",
1241"'<'","'>'","'{'","'}'","'*'","'c'","INTVAL","EINT64VAL","ArithmeticOps","LogicalOps",
1242"SetCondOps","ShiftOps","SIntType","UIntType","IntType","FPType","OptAssign",
1243"OptLinkage","OptCallingConv","OptAlign","OptCAlign","SectionString","OptSection",
1244"GlobalVarAttributes","GlobalVarAttribute","TypesV","UpRTypesV","Types","PrimType",
1245"UpRTypes","TypeListI","ArgTypeListI","ConstVal","ConstExpr","ConstVector","GlobalType",
1246"Module","FunctionList","ConstPool","@1","@2","AsmBlock","BigOrLittle","TargetDefinition",
1247"LibrariesDefinition","LibList","Name","OptName","ArgVal","ArgListH","ArgList",
1248"FunctionHeaderH","BEGIN","FunctionHeader","END","Function","FunctionProto",
1249"@3","OptSideEffect","ConstValueRef","SymbolicValueRef","ValueRef","ResolvedVal",
1250"BasicBlockList","BasicBlock","InstructionList","BBTerminatorInst","JumpTable",
1251"Inst","PHIList","ValueRefList","ValueRefListE","OptTailCall","InstVal","IndexList",
1252"OptVolatile","MemoryInst", NULL
Chris Lattner8335e842006-01-23 23:05:42 +00001253};
1254#endif
1255
1256static const short yyr1[] = { 0,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001257 116, 116, 117, 117, 118, 118, 118, 118, 118, 119,
1258 119, 119, 120, 120, 120, 120, 120, 120, 121, 121,
1259 122, 122, 122, 122, 123, 123, 123, 123, 124, 124,
1260 125, 125, 126, 126, 127, 127, 127, 127, 127, 128,
1261 128, 128, 128, 128, 129, 129, 130, 130, 131, 132,
1262 132, 133, 133, 134, 134, 135, 135, 136, 136, 137,
1263 138, 138, 138, 138, 138, 138, 138, 138, 138, 138,
1264 138, 138, 138, 139, 139, 139, 139, 139, 139, 139,
1265 139, 139, 139, 140, 140, 141, 141, 141, 141, 142,
1266 142, 142, 142, 142, 142, 142, 142, 142, 142, 142,
1267 142, 142, 142, 142, 142, 143, 143, 143, 143, 143,
Chris Lattnerd25db202006-04-08 03:55:17 +00001268 143, 143, 143, 143, 143, 144, 144, 145, 145, 146,
1269 147, 147, 147, 147, 147, 148, 148, 148, 149, 148,
1270 150, 148, 148, 148, 148, 151, 152, 152, 153, 153,
1271 153, 154, 155, 155, 155, 156, 156, 157, 157, 158,
1272 159, 159, 160, 160, 160, 160, 161, 162, 162, 163,
1273 164, 164, 165, 167, 166, 168, 168, 169, 169, 169,
1274 169, 169, 169, 169, 169, 169, 169, 169, 170, 170,
1275 171, 171, 172, 173, 173, 174, 175, 175, 175, 176,
1276 176, 176, 176, 176, 176, 176, 176, 176, 177, 177,
1277 178, 179, 179, 180, 180, 181, 181, 182, 182, 183,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001278 183, 183, 183, 183, 183, 183, 183, 183, 183, 183,
Chris Lattnerd25db202006-04-08 03:55:17 +00001279 183, 183, 183, 183, 183, 184, 184, 185, 185, 186,
1280 186, 186, 186, 186, 186, 186, 186
Chris Lattner8335e842006-01-23 23:05:42 +00001281};
1282
1283static const short yyr2[] = { 0,
1284 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1285 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1286 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1287 1, 1, 2, 0, 1, 1, 1, 1, 0, 0,
1288 1, 1, 1, 2, 0, 2, 0, 3, 2, 0,
1289 1, 0, 3, 1, 2, 1, 1, 1, 1, 1,
1290 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1291 1, 1, 1, 1, 1, 1, 2, 4, 5, 5,
1292 3, 2, 2, 1, 3, 1, 3, 1, 0, 4,
1293 3, 3, 4, 4, 3, 2, 2, 2, 2, 2,
1294 2, 2, 2, 2, 2, 6, 5, 8, 6, 6,
Chris Lattnerd25db202006-04-08 03:55:17 +00001295 6, 6, 6, 8, 8, 3, 1, 1, 1, 1,
1296 2, 2, 4, 2, 1, 4, 2, 4, 0, 7,
1297 0, 7, 3, 4, 0, 1, 1, 1, 3, 3,
1298 3, 3, 3, 1, 0, 1, 1, 1, 0, 2,
1299 3, 1, 1, 3, 1, 0, 8, 1, 1, 3,
1300 1, 1, 2, 0, 3, 0, 1, 1, 1, 1,
1301 1, 1, 1, 1, 1, 3, 1, 5, 1, 1,
1302 1, 1, 2, 2, 2, 3, 2, 0, 1, 2,
1303 2, 3, 9, 9, 8, 13, 1, 1, 6, 5,
1304 2, 6, 7, 1, 3, 1, 0, 2, 1, 5,
1305 5, 5, 2, 4, 4, 6, 4, 4, 4, 4,
1306 6, 6, 2, 7, 1, 2, 0, 1, 0, 3,
1307 6, 3, 6, 2, 4, 6, 4
Chris Lattner8335e842006-01-23 23:05:42 +00001308};
1309
Chris Lattnerd25db202006-04-08 03:55:17 +00001310static const short yydefact[] = { 135,
1311 39, 125, 124, 164, 35, 36, 37, 38, 0, 40,
1312 188, 121, 122, 188, 146, 147, 0, 0, 0, 39,
1313 0, 127, 40, 0, 0, 41, 42, 43, 0, 0,
1314 189, 185, 34, 161, 162, 163, 184, 0, 0, 0,
1315 133, 0, 0, 0, 0, 0, 33, 165, 136, 123,
Chris Lattner66316012006-01-24 04:14:29 +00001316 44, 1, 2, 57, 61, 62, 63, 64, 65, 66,
1317 67, 68, 69, 70, 71, 72, 73, 74, 0, 0,
Chris Lattnerd25db202006-04-08 03:55:17 +00001318 0, 0, 179, 0, 0, 56, 75, 60, 180, 76,
1319 158, 159, 160, 229, 187, 0, 0, 0, 145, 134,
1320 128, 126, 118, 119, 0, 0, 77, 0, 0, 59,
1321 82, 84, 0, 0, 89, 83, 228, 0, 209, 0,
1322 0, 0, 0, 40, 197, 198, 5, 6, 7, 8,
Chris Lattner66316012006-01-24 04:14:29 +00001323 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
1324 0, 0, 0, 0, 0, 0, 0, 19, 20, 0,
Chris Lattnerd25db202006-04-08 03:55:17 +00001325 0, 0, 0, 0, 0, 0, 0, 0, 0, 186,
1326 40, 201, 0, 225, 141, 138, 137, 139, 140, 144,
1327 0, 131, 61, 62, 63, 64, 65, 66, 67, 68,
1328 69, 70, 71, 0, 0, 0, 0, 129, 0, 0,
1329 0, 81, 156, 88, 86, 0, 0, 213, 208, 191,
1330 190, 0, 0, 24, 28, 23, 27, 22, 26, 21,
1331 25, 29, 30, 0, 0, 47, 47, 234, 0, 0,
1332 223, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1333 0, 0, 0, 0, 0, 0, 0, 142, 52, 103,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001334 104, 3, 4, 101, 102, 105, 100, 96, 97, 0,
Chris Lattner8335e842006-01-23 23:05:42 +00001335 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattnerd25db202006-04-08 03:55:17 +00001336 0, 0, 0, 99, 98, 52, 58, 58, 85, 155,
1337 149, 152, 153, 0, 0, 78, 168, 169, 170, 175,
1338 171, 172, 173, 174, 166, 0, 177, 182, 181, 183,
1339 0, 192, 0, 0, 0, 230, 0, 232, 227, 0,
Chris Lattner66316012006-01-24 04:14:29 +00001340 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattnerd25db202006-04-08 03:55:17 +00001341 0, 0, 0, 0, 0, 0, 143, 0, 132, 0,
1342 0, 0, 0, 0, 0, 91, 117, 0, 0, 95,
1343 0, 92, 0, 0, 0, 0, 130, 79, 80, 148,
1344 150, 0, 50, 87, 167, 0, 0, 0, 0, 0,
1345 0, 0, 0, 0, 237, 0, 0, 215, 0, 217,
1346 220, 0, 0, 218, 219, 0, 0, 0, 214, 0,
1347 235, 0, 0, 0, 54, 52, 227, 0, 0, 0,
1348 0, 0, 0, 90, 93, 94, 0, 0, 0, 0,
1349 154, 151, 51, 45, 0, 176, 0, 0, 207, 47,
1350 48, 47, 204, 226, 0, 0, 0, 0, 0, 210,
1351 211, 212, 207, 0, 49, 55, 53, 0, 0, 0,
1352 0, 0, 0, 116, 0, 0, 0, 0, 0, 157,
1353 0, 0, 0, 206, 0, 0, 231, 233, 0, 0,
1354 0, 216, 221, 222, 0, 236, 107, 0, 0, 0,
1355 0, 0, 0, 0, 0, 0, 46, 178, 0, 0,
1356 0, 205, 202, 0, 224, 106, 0, 113, 0, 0,
1357 109, 110, 111, 112, 0, 195, 0, 0, 0, 203,
1358 0, 0, 0, 193, 0, 194, 0, 0, 108, 114,
1359 115, 0, 0, 0, 0, 0, 0, 200, 0, 0,
1360 199, 196, 0, 0, 0
Chris Lattner8335e842006-01-23 23:05:42 +00001361};
1362
Chris Lattner66316012006-01-24 04:14:29 +00001363static const short yydefgoto[] = { 73,
Chris Lattnerd25db202006-04-08 03:55:17 +00001364 234, 250, 251, 252, 253, 174, 175, 204, 176, 20,
1365 10, 29, 420, 286, 365, 384, 309, 366, 74, 75,
1366 177, 77, 78, 103, 186, 317, 277, 318, 95, 493,
1367 1, 2, 256, 229, 50, 158, 41, 90, 161, 79,
1368 331, 262, 263, 264, 30, 83, 11, 36, 12, 13,
1369 23, 336, 278, 80, 280, 393, 14, 32, 33, 150,
1370 468, 85, 211, 424, 425, 151, 152, 345, 153, 154
Chris Lattner8335e842006-01-23 23:05:42 +00001371};
1372
1373static const short yypact[] = {-32768,
Chris Lattnerd25db202006-04-08 03:55:17 +00001374 181, 364,-32768,-32768,-32768,-32768,-32768,-32768, 6, -1,
1375 60,-32768,-32768, -14,-32768,-32768, 47, -22, 72, 45,
1376 33,-32768, -1, 125, 157,-32768,-32768,-32768, 1050, -21,
1377-32768,-32768, 22,-32768,-32768,-32768,-32768, 61, 67, 68,
1378-32768, 55, 125, 1050, -6, -6,-32768,-32768,-32768,-32768,
1379-32768,-32768,-32768, 66,-32768,-32768,-32768,-32768,-32768,-32768,
1380-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 168, 170,
1381 171, 566,-32768, 22, 73,-32768,-32768, -24,-32768,-32768,
1382-32768,-32768,-32768, 1213,-32768, 149, 57, 173, 155,-32768,
1383-32768,-32768,-32768,-32768, 1088, 1126,-32768, 74, 75,-32768,
1384-32768, -24, -82, 79, 860,-32768,-32768, 1088,-32768, 124,
1385 1164, 14, 128, -1,-32768,-32768,-32768,-32768,-32768,-32768,
Chris Lattner8335e842006-01-23 23:05:42 +00001386-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
Chris Lattnerd25db202006-04-08 03:55:17 +00001387 1088, 1088, 1088, 1088, 1088, 1088, 1088,-32768,-32768, 1088,
1388 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088,-32768,
1389 -1,-32768, 40,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1390 -9,-32768, 106, 143, 183, 148, 190, 152, 194, 154,
1391 196, 178, 195, 156, 197, 198, 425,-32768, 1088, 1088,
1392 1088,-32768, 898,-32768, 100, 98, 660,-32768,-32768, 66,
1393-32768, 660, 660,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1394-32768,-32768,-32768, 660, 1050, 104, 105,-32768, 660, 102,
1395 108, 177, 111, 112, 123, 130, 132, 133, 134, 660,
1396 660, 660, 135, 1050, 1088, 1088, 203,-32768, 136,-32768,
1397-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 137,
1398 138, 139, 140, 141, 142, 936, 1126, 604, 217, 145,
1399 146, 147, 150,-32768,-32768, 136, 18, -86, -24,-32768,
1400 22,-32768, 151, 153, 974,-32768,-32768,-32768,-32768,-32768,
1401-32768,-32768,-32768,-32768, 193, 1126,-32768,-32768,-32768,-32768,
1402 158,-32768, 159, 660, -5,-32768, 5,-32768, 172, 660,
1403 165, 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088, 174,
1404 175, 179, 1088, 660, 660, 180,-32768, -20,-32768, 1126,
1405 1126, 1126, 1126, 1126, 1126,-32768,-32768, -8, -81,-32768,
1406 -36,-32768, 1126, 1126, 1126, 1126,-32768,-32768,-32768,-32768,
1407-32768, 1012, 222,-32768,-32768, 233, -18, 237, 239, 176,
1408 660, 269, 660, 1088,-32768, 185, 660,-32768, 186,-32768,
1409-32768, 187, 189,-32768,-32768, 660, 660, 660,-32768, 191,
1410-32768, 1088, 252, 276,-32768, 136, 172, 248, 201, 202,
1411 204, 205, 1126,-32768,-32768,-32768, 206, 207, 208, 209,
1412-32768,-32768,-32768, 232, 210,-32768, 660, 660, 1088, 211,
1413-32768, 211,-32768, 223, 660, 224, 1088, 1088, 1088,-32768,
1414-32768,-32768, 1088, 660,-32768,-32768,-32768, 192, 1088, 1126,
1415 1126, 1126, 1126,-32768, 1126, 1126, 1126, 1126, 293,-32768,
1416 275, 225, 199, 223, 214, 280,-32768,-32768, 1088, 220,
1417 660,-32768,-32768,-32768, 229,-32768,-32768, 230, 227, 231,
1418 238, 240, 236, 241, 243, 244,-32768,-32768, 323, 41,
1419 309,-32768,-32768, 242,-32768,-32768, 1126,-32768, 1126, 1126,
1420-32768,-32768,-32768,-32768, 660,-32768, 757, 59, 325,-32768,
1421 246, 247, 249,-32768, 251,-32768, 757, 660,-32768,-32768,
1422-32768, 336, 256, 295, 660, 346, 350,-32768, 660, 660,
1423-32768,-32768, 372, 376,-32768
Chris Lattner8335e842006-01-23 23:05:42 +00001424};
1425
1426static const short yypgoto[] = {-32768,
Chris Lattnerd25db202006-04-08 03:55:17 +00001427-32768, 297, 298, 299, 301, -112, -110, -426,-32768, 344,
1428 359, -103,-32768, -202, 54,-32768, -243,-32768, -38,-32768,
1429 -29,-32768, -55, 287,-32768, -94, 216, -229, 348,-32768,
1430-32768,-32768,-32768,-32768, 355,-32768,-32768,-32768,-32768, 10,
1431-32768, 69,-32768,-32768, 379,-32768,-32768,-32768,-32768, 397,
1432-32768,-32768, -399, -56, 169, -104,-32768, 389,-32768,-32768,
1433-32768,-32768,-32768, 70, 1,-32768,-32768, 43,-32768,-32768
Chris Lattner8335e842006-01-23 23:05:42 +00001434};
1435
1436
Chris Lattnerd25db202006-04-08 03:55:17 +00001437#define YYLAST 1314
Chris Lattner8335e842006-01-23 23:05:42 +00001438
1439
Chris Lattner66316012006-01-24 04:14:29 +00001440static const short yytable[] = { 76,
Chris Lattnerd25db202006-04-08 03:55:17 +00001441 202, 178, 203, 188, 288, 92, 191, 81, 31, 341,
1442 205, 21, 327, 363, 76, 34, 102, 319, 321, 343,
1443 181, 373, 192, 467, 329, 93, 94, 106, 208, 375,
1444 182, 212, 213, 364, 193, 214, 215, 216, 217, 218,
1445 219, 477, 21, 15, 223, 16, 337, 224, 342, 102,
1446 194, 195, 196, 197, 198, 199, 200, 201, 342, 25,
1447 26, 27, 28, 24, 44, 162, 373, 475, 194, 195,
1448 196, 197, 198, 199, 200, 201, 376, 483, 187, 42,
1449 -58, 187, 31, 104, 373, 5, 6, 7, 8, 106,
1450 82, 45, 386, 227, 373, 38, 39, 40, 35, 228,
1451 374, 206, 207, 187, 209, 210, 187, 187, 156, 157,
1452 187, 187, 187, 187, 187, 187, 220, 221, 222, 187,
1453 255, 306, 407, 257, 258, 259, 328, 225, 226, 43,
1454 279, 106, 230, 231, 47, 279, 279, 194, 195, 196,
1455 197, 198, 199, 200, 201, -24, -24, 279, 49, 466,
1456 -23, -23, 279, 261, -22, -22, -21, -21, 232, 233,
1457 51, 89, 86, 279, 279, 279, 284, 476, 87, 88,
1458 -59, 97, 155, 98, 99, 76, 159, 105, 160, 189,
1459 -120, 179, 180, 183, -31, 304, -28, 427, 349, 428,
1460 351, 352, 353, -27, 76, 305, 187, -26, 359, -25,
1461 235, -32, 265, 266, 236, 3, 285, 287, 290, 259,
1462 291, 4, 292, 293, 294, 367, 368, 369, 370, 371,
1463 372, 5, 6, 7, 8, 295, 307, 279, 377, 378,
1464 379, 380, 296, 279, 297, 298, 299, 303, 308, 9,
1465 322, 310, 311, 312, 313, 314, 315, 279, 279, 323,
1466 324, 325, 335, 332, 326, 363, 385, 387, 333, 388,
1467 338, 339, 348, 187, 350, 187, 187, 187, 354, 355,
1468 330, 347, 391, 187, 344, 405, 356, 357, 414, 406,
1469 389, 358, 362, 409, 279, 419, 279, 395, 397, 398,
1470 279, 399, 432, 433, 434, 403, 447, 437, 448, 279,
1471 279, 279, 261, 410, 411, 450, 412, 413, 415, 416,
1472 417, 418, 421, 426, 187, 439, 440, 441, 442, 451,
1473 443, 444, 445, 446, 452, 429, 431, 449, 453, 457,
1474 279, 279, 404, 342, 455, 456, 458, 202, 279, 203,
1475 459, 461, 460, 465, 469, 478, 462, 279, 463, 464,
1476 470, 479, 480, 482, 481, 202, 485, 203, 486, 187,
1477 281, 282, 471, 487, 472, 473, 489, 187, 187, 187,
1478 490, 494, 283, 187, 279, 495, 84, 289, 46, 438,
1479 146, 147, 148, -34, 149, 15, 383, 16, 300, 301,
1480 302, 185, 254, 96, 4, -34, -34, 91, 22, 187,
1481 382, 48, 37, 435, -34, -34, -34, -34, 279, 408,
1482 -34, 17, 0, 394, 0, 0, 0, 0, 18, 0,
1483 0, 279, 19, 0, 0, 0, 0, 0, 279, 52,
1484 53, 0, 279, 279, 0, 0, 0, 0, 0, 0,
1485 0, 0, 0, 0, 0, 0, 15, 0, 16, 0,
1486 237, 0, 340, 0, 0, 0, 0, 0, 346, 0,
1487 0, 0, 238, 239, 0, 0, 0, 0, 0, 0,
1488 0, 0, 360, 361, 0, 0, 0, 0, 0, 0,
1489 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001490 0, 0, 0, 0, 0, 117, 118, 119, 120, 121,
Chris Lattnerd25db202006-04-08 03:55:17 +00001491 122, 123, 124, 125, 126, 127, 128, 129, 130, 390,
1492 0, 392, 0, 0, 240, 396, 241, 242, 138, 139,
1493 0, 243, 244, 245, 400, 401, 402, 0, 0, 0,
1494 0, 246, 0, 0, 247, 0, 248, 0, 0, 249,
Chris Lattner8335e842006-01-23 23:05:42 +00001495 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattnerd25db202006-04-08 03:55:17 +00001496 0, 0, 0, 0, 0, 422, 423, 0, 0, 0,
1497 0, 0, 0, 430, 0, 0, 0, 0, 0, 0,
1498 52, 53, 436, 100, 55, 56, 57, 58, 59, 60,
1499 61, 62, 63, 64, 65, 66, 67, 15, 0, 16,
1500 0, 0, 0, 0, 0, 0, 0, 0, 0, 454,
1501 0, 0, 0, 0, 0, 0, 0, 0, 52, 53,
1502 68, 100, 163, 164, 165, 166, 167, 168, 169, 170,
1503 171, 172, 173, 66, 67, 15, 0, 16, 0, 0,
1504 0, 0, 0, 474, 0, 0, 0, 0, 0, 0,
1505 0, 0, 0, 0, 0, 0, 484, 0, 68, 0,
1506 0, 0, 0, 488, 0, 0, 0, 491, 492, 0,
1507 0, 0, 267, 268, 52, 53, 269, 0, 0, 69,
1508 0, 0, 70, 0, 0, 71, 0, 72, 101, 0,
1509 0, 15, 0, 16, 0, 270, 271, 272, 0, 0,
1510 0, 0, 0, 0, 0, 0, 0, 273, 274, 0,
1511 0, 0, 0, 0, 0, 0, 0, 69, 0, 0,
1512 70, 0, 0, 71, 0, 72, 320, 275, 0, 0,
Chris Lattner66316012006-01-24 04:14:29 +00001513 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001514 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
Chris Lattnerd25db202006-04-08 03:55:17 +00001515 127, 128, 129, 130, 0, 0, 0, 0, 0, 240,
1516 0, 241, 242, 138, 139, 0, 243, 244, 245, 267,
1517 268, 0, 0, 269, 0, 0, 0, 0, 0, 276,
1518 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1519 0, 0, 270, 271, 272, 0, 0, 0, 0, 0,
1520 0, 0, 0, 0, 273, 274, 0, 0, 0, 0,
1521 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1522 0, 0, 0, 0, 275, 0, 0, 0, 0, 0,
1523 0, 0, 0, 0, 0, 0, 0, 117, 118, 119,
1524 120, 121, 122, 123, 124, 125, 126, 127, 128, 129,
1525 130, 0, 0, 0, 0, 0, 240, 0, 241, 242,
1526 138, 139, 0, 243, 244, 245, 0, 0, 0, 0,
1527 0, 0, 0, 0, 52, 53, 276, 100, 55, 56,
1528 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1529 67, 15, 0, 16, 0, 0, 0, 0, 0, 0,
1530 0, 0, 0, 0, 0, 0, 184, 0, 0, 0,
1531 0, 0, 52, 53, 68, 100, 55, 56, 57, 58,
1532 59, 60, 61, 62, 63, 64, 65, 66, 67, 15,
1533 0, 16, 0, 0, 0, 0, 0, 0, 0, 0,
1534 0, 0, 0, 0, 260, 0, 0, 0, 0, 0,
1535 52, 53, 68, 100, 163, 164, 165, 166, 167, 168,
1536 169, 170, 171, 172, 173, 66, 67, 15, 0, 16,
1537 0, 0, 0, 69, 0, 0, 70, 0, 0, 71,
1538 0, 72, 0, 0, 0, 0, 0, 0, 52, 53,
1539 68, 100, 55, 56, 57, 58, 59, 60, 61, 62,
1540 63, 64, 65, 66, 67, 15, 0, 16, 0, 0,
1541 0, 69, 0, 0, 70, 0, 0, 71, 0, 72,
1542 334, 0, 0, 0, 0, 0, 52, 53, 68, 100,
1543 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1544 65, 66, 67, 15, 0, 16, 0, 0, 0, 69,
1545 0, 0, 70, 0, 316, 71, 0, 72, 381, 0,
1546 0, 0, 0, 0, 52, 53, 68, 54, 55, 56,
1547 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1548 67, 15, 0, 16, 0, 0, 0, 69, 0, 0,
1549 70, 0, 0, 71, 0, 72, 0, 0, 0, 0,
1550 0, 0, 52, 53, 68, 100, 55, 56, 57, 58,
1551 59, 60, 61, 62, 63, 64, 65, 66, 67, 15,
1552 0, 16, 0, 0, 0, 69, 0, 0, 70, 0,
1553 0, 71, 0, 72, 0, 0, 0, 0, 0, 0,
1554 52, 53, 68, 100, 163, 164, 165, 166, 167, 168,
1555 169, 170, 171, 172, 173, 66, 67, 15, 0, 16,
1556 0, 0, 0, 69, 0, 0, 70, 0, 0, 71,
1557 0, 72, 0, 0, 0, 0, 0, 0, 52, 53,
1558 68, 190, 55, 56, 57, 58, 59, 60, 61, 62,
1559 63, 64, 65, 66, 67, 15, 0, 16, 0, 0,
1560 0, 69, 0, 0, 70, 0, 0, 71, 0, 72,
1561 0, 0, 0, 0, 0, 0, 0, 0, 68, 0,
1562 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1563 0, 0, 0, 0, 0, 0, 0, 0, 0, 69,
1564 0, 0, 70, 0, 0, 71, 0, 72, 0, 0,
1565 0, 0, 0, 0, 0, 0, 0, 107, 0, 0,
1566 0, 0, 0, 0, 0, 0, 0, 0, 108, 0,
1567 0, 0, 0, 0, 0, 0, 0, 69, 109, 110,
1568 70, 0, 0, 71, 0, 72, 0, 111, 112, 113,
1569 114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
1570 124, 125, 126, 127, 128, 129, 130, 131, 132, 133,
1571 0, 0, 134, 135, 136, 137, 138, 139, 140, 141,
1572 142, 143, 144, 145
Chris Lattner8335e842006-01-23 23:05:42 +00001573};
1574
Chris Lattner66316012006-01-24 04:14:29 +00001575static const short yycheck[] = { 29,
Chris Lattnerd25db202006-04-08 03:55:17 +00001576 113, 96, 113, 108, 207, 44, 111, 29, 23, 15,
1577 114, 2, 256, 34, 44, 30, 72, 247, 248, 15,
1578 103, 103, 9, 450, 111, 32, 33, 114, 133, 111,
1579 113, 136, 137, 54, 21, 140, 141, 142, 143, 144,
1580 145, 468, 33, 22, 149, 24, 276, 151, 54, 105,
1581 10, 11, 12, 13, 14, 15, 16, 17, 54, 61,
1582 62, 63, 64, 58, 20, 95, 103, 467, 10, 11,
1583 12, 13, 14, 15, 16, 17, 113, 477, 108, 102,
1584 105, 111, 23, 74, 103, 41, 42, 43, 44, 114,
1585 112, 47, 111, 103, 103, 49, 50, 51, 113, 109,
1586 109, 131, 132, 133, 134, 135, 136, 137, 52, 53,
1587 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
1588 177, 226, 366, 179, 180, 181, 109, 88, 89, 58,
1589 187, 114, 27, 28, 102, 192, 193, 10, 11, 12,
1590 13, 14, 15, 16, 17, 3, 4, 204, 24, 109,
1591 3, 4, 209, 183, 3, 4, 3, 4, 3, 4,
1592 4, 107, 102, 220, 221, 222, 205, 109, 102, 102,
1593 105, 4, 24, 4, 4, 205, 4, 105, 24, 56,
1594 0, 108, 108, 105, 7, 224, 4, 390, 293, 392,
1595 295, 296, 297, 4, 224, 225, 226, 4, 303, 4,
1596 4, 7, 103, 106, 7, 25, 103, 103, 107, 265,
1597 103, 31, 36, 103, 103, 310, 311, 312, 313, 314,
1598 315, 41, 42, 43, 44, 103, 24, 284, 323, 324,
1599 325, 326, 103, 290, 103, 103, 103, 103, 103, 59,
1600 24, 105, 105, 105, 105, 105, 105, 304, 305, 105,
1601 105, 105, 60, 103, 105, 34, 24, 21, 106, 21,
1602 103, 103, 292, 293, 294, 295, 296, 297, 298, 299,
1603 261, 107, 4, 303, 103, 24, 103, 103, 373, 4,
1604 105, 103, 103, 36, 341, 54, 343, 103, 103, 103,
1605 347, 103, 397, 398, 399, 105, 4, 106, 24, 356,
1606 357, 358, 332, 103, 103, 107, 103, 103, 103, 103,
1607 103, 103, 103, 103, 344, 410, 411, 412, 413, 106,
1608 415, 416, 417, 418, 429, 103, 103, 103, 109, 103,
1609 387, 388, 362, 54, 106, 106, 106, 450, 395, 450,
1610 103, 106, 103, 21, 36, 21, 106, 404, 106, 106,
1611 109, 106, 106, 103, 106, 468, 21, 468, 103, 389,
1612 192, 193, 457, 69, 459, 460, 21, 397, 398, 399,
1613 21, 0, 204, 403, 431, 0, 33, 209, 20, 409,
1614 84, 84, 84, 20, 84, 22, 333, 24, 220, 221,
1615 222, 105, 177, 46, 31, 32, 33, 43, 2, 429,
1616 332, 23, 14, 403, 41, 42, 43, 44, 465, 367,
1617 47, 48, -1, 344, -1, -1, -1, -1, 55, -1,
1618 -1, 478, 59, -1, -1, -1, -1, -1, 485, 5,
1619 6, -1, 489, 490, -1, -1, -1, -1, -1, -1,
1620 -1, -1, -1, -1, -1, -1, 22, -1, 24, -1,
1621 26, -1, 284, -1, -1, -1, -1, -1, 290, -1,
1622 -1, -1, 38, 39, -1, -1, -1, -1, -1, -1,
1623 -1, -1, 304, 305, -1, -1, -1, -1, -1, -1,
1624 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001625 -1, -1, -1, -1, -1, 71, 72, 73, 74, 75,
Chris Lattnerd25db202006-04-08 03:55:17 +00001626 76, 77, 78, 79, 80, 81, 82, 83, 84, 341,
1627 -1, 343, -1, -1, 90, 347, 92, 93, 94, 95,
1628 -1, 97, 98, 99, 356, 357, 358, -1, -1, -1,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001629 -1, 107, -1, -1, 110, -1, 112, -1, -1, 115,
1630 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattnerd25db202006-04-08 03:55:17 +00001631 -1, -1, -1, -1, -1, 387, 388, -1, -1, -1,
1632 -1, -1, -1, 395, -1, -1, -1, -1, -1, -1,
1633 5, 6, 404, 8, 9, 10, 11, 12, 13, 14,
1634 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
1635 -1, -1, -1, -1, -1, -1, -1, -1, -1, 431,
1636 -1, -1, -1, -1, -1, -1, -1, -1, 5, 6,
1637 45, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1638 17, 18, 19, 20, 21, 22, -1, 24, -1, -1,
1639 -1, -1, -1, 465, -1, -1, -1, -1, -1, -1,
1640 -1, -1, -1, -1, -1, -1, 478, -1, 45, -1,
1641 -1, -1, -1, 485, -1, -1, -1, 489, 490, -1,
1642 -1, -1, 3, 4, 5, 6, 7, -1, -1, 104,
1643 -1, -1, 107, -1, -1, 110, -1, 112, 113, -1,
1644 -1, 22, -1, 24, -1, 26, 27, 28, -1, -1,
1645 -1, -1, -1, -1, -1, -1, -1, 38, 39, -1,
1646 -1, -1, -1, -1, -1, -1, -1, 104, -1, -1,
1647 107, -1, -1, 110, -1, 112, 113, 58, -1, -1,
1648 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1649 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
1650 81, 82, 83, 84, -1, -1, -1, -1, -1, 90,
1651 -1, 92, 93, 94, 95, -1, 97, 98, 99, 3,
1652 4, -1, -1, 7, -1, -1, -1, -1, -1, 110,
1653 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1654 -1, -1, 26, 27, 28, -1, -1, -1, -1, -1,
1655 -1, -1, -1, -1, 38, 39, -1, -1, -1, -1,
1656 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1657 -1, -1, -1, -1, 58, -1, -1, -1, -1, -1,
1658 -1, -1, -1, -1, -1, -1, -1, 71, 72, 73,
1659 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
1660 84, -1, -1, -1, -1, -1, 90, -1, 92, 93,
1661 94, 95, -1, 97, 98, 99, -1, -1, -1, -1,
1662 -1, -1, -1, -1, 5, 6, 110, 8, 9, 10,
1663 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
1664 21, 22, -1, 24, -1, -1, -1, -1, -1, -1,
1665 -1, -1, -1, -1, -1, -1, 37, -1, -1, -1,
1666 -1, -1, 5, 6, 45, 8, 9, 10, 11, 12,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001667 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
1668 -1, 24, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattnerd25db202006-04-08 03:55:17 +00001669 -1, -1, -1, -1, 37, -1, -1, -1, -1, -1,
1670 5, 6, 45, 8, 9, 10, 11, 12, 13, 14,
1671 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
1672 -1, -1, -1, 104, -1, -1, 107, -1, -1, 110,
1673 -1, 112, -1, -1, -1, -1, -1, -1, 5, 6,
1674 45, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1675 17, 18, 19, 20, 21, 22, -1, 24, -1, -1,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001676 -1, 104, -1, -1, 107, -1, -1, 110, -1, 112,
Chris Lattnerd25db202006-04-08 03:55:17 +00001677 37, -1, -1, -1, -1, -1, 5, 6, 45, 8,
1678 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
1679 19, 20, 21, 22, -1, 24, -1, -1, -1, 104,
1680 -1, -1, 107, -1, 109, 110, -1, 112, 37, -1,
1681 -1, -1, -1, -1, 5, 6, 45, 8, 9, 10,
1682 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
1683 21, 22, -1, 24, -1, -1, -1, 104, -1, -1,
1684 107, -1, -1, 110, -1, 112, -1, -1, -1, -1,
1685 -1, -1, 5, 6, 45, 8, 9, 10, 11, 12,
1686 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
1687 -1, 24, -1, -1, -1, 104, -1, -1, 107, -1,
1688 -1, 110, -1, 112, -1, -1, -1, -1, -1, -1,
1689 5, 6, 45, 8, 9, 10, 11, 12, 13, 14,
1690 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
1691 -1, -1, -1, 104, -1, -1, 107, -1, -1, 110,
1692 -1, 112, -1, -1, -1, -1, -1, -1, 5, 6,
1693 45, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1694 17, 18, 19, 20, 21, 22, -1, 24, -1, -1,
1695 -1, 104, -1, -1, 107, -1, -1, 110, -1, 112,
1696 -1, -1, -1, -1, -1, -1, -1, -1, 45, -1,
Chris Lattnerd5efe842006-04-08 01:18:56 +00001697 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattnerd25db202006-04-08 03:55:17 +00001698 -1, -1, -1, -1, -1, -1, -1, -1, -1, 104,
1699 -1, -1, 107, -1, -1, 110, -1, 112, -1, -1,
1700 -1, -1, -1, -1, -1, -1, -1, 35, -1, -1,
1701 -1, -1, -1, -1, -1, -1, -1, -1, 46, -1,
1702 -1, -1, -1, -1, -1, -1, -1, 104, 56, 57,
1703 107, -1, -1, 110, -1, 112, -1, 65, 66, 67,
1704 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
1705 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
1706 -1, -1, 90, 91, 92, 93, 94, 95, 96, 97,
1707 98, 99, 100, 101
Chris Lattner8335e842006-01-23 23:05:42 +00001708};
1709/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
1710#line 3 "/usr/share/bison.simple"
1711/* This file comes from bison-1.28. */
1712
1713/* Skeleton output parser for bison,
1714 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
1715
1716 This program is free software; you can redistribute it and/or modify
1717 it under the terms of the GNU General Public License as published by
1718 the Free Software Foundation; either version 2, or (at your option)
1719 any later version.
1720
1721 This program is distributed in the hope that it will be useful,
1722 but WITHOUT ANY WARRANTY; without even the implied warranty of
1723 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1724 GNU General Public License for more details.
1725
1726 You should have received a copy of the GNU General Public License
1727 along with this program; if not, write to the Free Software
1728 Foundation, Inc., 59 Temple Place - Suite 330,
1729 Boston, MA 02111-1307, USA. */
1730
1731/* As a special exception, when this file is copied by Bison into a
1732 Bison output file, you may use that output file without restriction.
1733 This special exception was added by the Free Software Foundation
1734 in version 1.24 of Bison. */
1735
1736/* This is the parser code that is written into each bison parser
1737 when the %semantic_parser declaration is not specified in the grammar.
1738 It was written by Richard Stallman by simplifying the hairy parser
1739 used when %semantic_parser is specified. */
1740
1741#ifndef YYSTACK_USE_ALLOCA
1742#ifdef alloca
1743#define YYSTACK_USE_ALLOCA
1744#else /* alloca not defined */
1745#ifdef __GNUC__
1746#define YYSTACK_USE_ALLOCA
1747#define alloca __builtin_alloca
1748#else /* not GNU C. */
1749#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
1750#define YYSTACK_USE_ALLOCA
1751#include <alloca.h>
1752#else /* not sparc */
1753/* We think this test detects Watcom and Microsoft C. */
1754/* This used to test MSDOS, but that is a bad idea
1755 since that symbol is in the user namespace. */
1756#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
1757#if 0 /* No need for malloc.h, which pollutes the namespace;
1758 instead, just don't use alloca. */
1759#include <malloc.h>
1760#endif
1761#else /* not MSDOS, or __TURBOC__ */
1762#if defined(_AIX)
1763/* I don't know what this was needed for, but it pollutes the namespace.
1764 So I turned it off. rms, 2 May 1997. */
1765/* #include <malloc.h> */
1766 #pragma alloca
1767#define YYSTACK_USE_ALLOCA
1768#else /* not MSDOS, or __TURBOC__, or _AIX */
1769#if 0
1770#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
1771 and on HPUX 10. Eventually we can turn this on. */
1772#define YYSTACK_USE_ALLOCA
1773#define alloca __builtin_alloca
1774#endif /* __hpux */
1775#endif
1776#endif /* not _AIX */
1777#endif /* not MSDOS, or __TURBOC__ */
1778#endif /* not sparc */
1779#endif /* not GNU C */
1780#endif /* alloca not defined */
1781#endif /* YYSTACK_USE_ALLOCA not defined */
1782
1783#ifdef YYSTACK_USE_ALLOCA
1784#define YYSTACK_ALLOC alloca
Reid Spencer68a24bd2005-08-27 18:50:39 +00001785#else
Chris Lattner8335e842006-01-23 23:05:42 +00001786#define YYSTACK_ALLOC malloc
Reid Spencer68a24bd2005-08-27 18:50:39 +00001787#endif
1788
Chris Lattner8335e842006-01-23 23:05:42 +00001789/* Note: there must be only one dollar sign in this file.
1790 It is replaced by the list of actions, each action
1791 as one case of the switch. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001792
1793#define yyerrok (yyerrstatus = 0)
1794#define yyclearin (yychar = YYEMPTY)
Chris Lattner8335e842006-01-23 23:05:42 +00001795#define YYEMPTY -2
Reid Spencer68a24bd2005-08-27 18:50:39 +00001796#define YYEOF 0
Reid Spencer68a24bd2005-08-27 18:50:39 +00001797#define YYACCEPT goto yyacceptlab
Chris Lattner8335e842006-01-23 23:05:42 +00001798#define YYABORT goto yyabortlab
1799#define YYERROR goto yyerrlab1
1800/* Like YYERROR except do call yyerror.
1801 This remains here temporarily to ease the
1802 transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00001803 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001804#define YYFAIL goto yyerrlab
Reid Spencer68a24bd2005-08-27 18:50:39 +00001805#define YYRECOVERING() (!!yyerrstatus)
Chris Lattner8335e842006-01-23 23:05:42 +00001806#define YYBACKUP(token, value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00001807do \
1808 if (yychar == YYEMPTY && yylen == 1) \
Chris Lattner8335e842006-01-23 23:05:42 +00001809 { yychar = (token), yylval = (value); \
1810 yychar1 = YYTRANSLATE (yychar); \
Reid Spencer68a24bd2005-08-27 18:50:39 +00001811 YYPOPSTACK; \
1812 goto yybackup; \
1813 } \
1814 else \
Chris Lattner8335e842006-01-23 23:05:42 +00001815 { yyerror ("syntax error: cannot back up"); YYERROR; } \
Reid Spencer68a24bd2005-08-27 18:50:39 +00001816while (0)
1817
1818#define YYTERROR 1
1819#define YYERRCODE 256
1820
Chris Lattner8335e842006-01-23 23:05:42 +00001821#ifndef YYPURE
1822#define YYLEX yylex()
Reid Spencer68a24bd2005-08-27 18:50:39 +00001823#endif
1824
Chris Lattner8335e842006-01-23 23:05:42 +00001825#ifdef YYPURE
1826#ifdef YYLSP_NEEDED
Reid Spencer68a24bd2005-08-27 18:50:39 +00001827#ifdef YYLEX_PARAM
Chris Lattner8335e842006-01-23 23:05:42 +00001828#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001829#else
Chris Lattner8335e842006-01-23 23:05:42 +00001830#define YYLEX yylex(&yylval, &yylloc)
1831#endif
1832#else /* not YYLSP_NEEDED */
1833#ifdef YYLEX_PARAM
1834#define YYLEX yylex(&yylval, YYLEX_PARAM)
1835#else
1836#define YYLEX yylex(&yylval)
1837#endif
1838#endif /* not YYLSP_NEEDED */
Robert Bocchino2def1b32006-01-17 20:06:25 +00001839#endif
Reid Spencere812fb22006-01-19 01:21:04 +00001840
Chris Lattner8335e842006-01-23 23:05:42 +00001841/* If nonreentrant, generate the variables here */
Reid Spencere812fb22006-01-19 01:21:04 +00001842
Chris Lattner8335e842006-01-23 23:05:42 +00001843#ifndef YYPURE
Reid Spencere812fb22006-01-19 01:21:04 +00001844
Chris Lattner8335e842006-01-23 23:05:42 +00001845int yychar; /* the lookahead symbol */
1846YYSTYPE yylval; /* the semantic value of the */
1847 /* lookahead symbol */
Reid Spencere812fb22006-01-19 01:21:04 +00001848
Chris Lattner8335e842006-01-23 23:05:42 +00001849#ifdef YYLSP_NEEDED
1850YYLTYPE yylloc; /* location data for the lookahead */
1851 /* symbol */
Robert Bocchino2def1b32006-01-17 20:06:25 +00001852#endif
Reid Spencere812fb22006-01-19 01:21:04 +00001853
Chris Lattner8335e842006-01-23 23:05:42 +00001854int yynerrs; /* number of parse errors so far */
1855#endif /* not YYPURE */
Reid Spencere812fb22006-01-19 01:21:04 +00001856
Chris Lattner8335e842006-01-23 23:05:42 +00001857#if YYDEBUG != 0
1858int yydebug; /* nonzero means print parse trace */
1859/* Since this is uninitialized, it does not stop multiple parsers
1860 from coexisting. */
Nate Begeman14b05292005-11-05 09:21:28 +00001861#endif
Reid Spencer0b118202006-01-16 21:12:35 +00001862
Chris Lattner8335e842006-01-23 23:05:42 +00001863/* YYINITDEPTH indicates the initial size of the parser's stacks */
Reid Spencer0b118202006-01-16 21:12:35 +00001864
Reid Spencer68a24bd2005-08-27 18:50:39 +00001865#ifndef YYINITDEPTH
Chris Lattner8335e842006-01-23 23:05:42 +00001866#define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00001867#endif
1868
Chris Lattner8335e842006-01-23 23:05:42 +00001869/* YYMAXDEPTH is the maximum size the stacks can grow to
1870 (effective only if the built-in stack extension method is used). */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001871
Chris Lattner8335e842006-01-23 23:05:42 +00001872#if YYMAXDEPTH == 0
1873#undef YYMAXDEPTH
Reid Spencer68a24bd2005-08-27 18:50:39 +00001874#endif
1875
1876#ifndef YYMAXDEPTH
Chris Lattner8335e842006-01-23 23:05:42 +00001877#define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00001878#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001879
Chris Lattner8335e842006-01-23 23:05:42 +00001880/* Define __yy_memcpy. Note that the size argument
1881 should be passed with type unsigned int, because that is what the non-GCC
1882 definitions require. With GCC, __builtin_memcpy takes an arg
1883 of type size_t, but it can handle unsigned int. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001884
Chris Lattner8335e842006-01-23 23:05:42 +00001885#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
1886#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
1887#else /* not GNU C or C++ */
1888#ifndef __cplusplus
Reid Spencer68a24bd2005-08-27 18:50:39 +00001889
Chris Lattner8335e842006-01-23 23:05:42 +00001890/* This is the most reliable way to avoid incompatibilities
1891 in available built-in functions on various systems. */
Reid Spencere812fb22006-01-19 01:21:04 +00001892static void
Chris Lattner8335e842006-01-23 23:05:42 +00001893__yy_memcpy (to, from, count)
1894 char *to;
1895 char *from;
1896 unsigned int count;
1897{
1898 register char *f = from;
1899 register char *t = to;
1900 register int i = count;
1901
1902 while (i-- > 0)
1903 *t++ = *f++;
1904}
1905
1906#else /* __cplusplus */
1907
1908/* This is the most reliable way to avoid incompatibilities
1909 in available built-in functions on various systems. */
Reid Spencere812fb22006-01-19 01:21:04 +00001910static void
Chris Lattner8335e842006-01-23 23:05:42 +00001911__yy_memcpy (char *to, char *from, unsigned int count)
1912{
1913 register char *t = to;
1914 register char *f = from;
1915 register int i = count;
1916
1917 while (i-- > 0)
1918 *t++ = *f++;
1919}
1920
Reid Spencer0b118202006-01-16 21:12:35 +00001921#endif
Reid Spencere812fb22006-01-19 01:21:04 +00001922#endif
Reid Spencere812fb22006-01-19 01:21:04 +00001923
Chris Lattner8335e842006-01-23 23:05:42 +00001924#line 217 "/usr/share/bison.simple"
Reid Spencere812fb22006-01-19 01:21:04 +00001925
Chris Lattner8335e842006-01-23 23:05:42 +00001926/* The user can define YYPARSE_PARAM as the name of an argument to be passed
1927 into yyparse. The argument should have type void *.
1928 It should actually point to an object.
1929 Grammar actions can access the variable by casting it
1930 to the proper pointer type. */
Reid Spencere812fb22006-01-19 01:21:04 +00001931
1932#ifdef YYPARSE_PARAM
Chris Lattner8335e842006-01-23 23:05:42 +00001933#ifdef __cplusplus
1934#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
1935#define YYPARSE_PARAM_DECL
1936#else /* not __cplusplus */
1937#define YYPARSE_PARAM_ARG YYPARSE_PARAM
1938#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
1939#endif /* not __cplusplus */
1940#else /* not YYPARSE_PARAM */
1941#define YYPARSE_PARAM_ARG
1942#define YYPARSE_PARAM_DECL
1943#endif /* not YYPARSE_PARAM */
1944
1945/* Prevent warning if -Wstrict-prototypes. */
1946#ifdef __GNUC__
1947#ifdef YYPARSE_PARAM
1948int yyparse (void *);
1949#else
Reid Spencere812fb22006-01-19 01:21:04 +00001950int yyparse (void);
Reid Spencere812fb22006-01-19 01:21:04 +00001951#endif
Chris Lattner8335e842006-01-23 23:05:42 +00001952#endif
Reid Spencere812fb22006-01-19 01:21:04 +00001953
Reid Spencere812fb22006-01-19 01:21:04 +00001954int
Chris Lattner8335e842006-01-23 23:05:42 +00001955yyparse(YYPARSE_PARAM_ARG)
1956 YYPARSE_PARAM_DECL
Reid Spencere812fb22006-01-19 01:21:04 +00001957{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001958 register int yystate;
1959 register int yyn;
Nate Begeman14b05292005-11-05 09:21:28 +00001960 register short *yyssp;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001961 register YYSTYPE *yyvsp;
Chris Lattner8335e842006-01-23 23:05:42 +00001962 int yyerrstatus; /* number of tokens to shift before error messages enabled */
1963 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001964
Chris Lattner8335e842006-01-23 23:05:42 +00001965 short yyssa[YYINITDEPTH]; /* the state stack */
1966 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001967
Chris Lattner8335e842006-01-23 23:05:42 +00001968 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
1969 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001970
Chris Lattner8335e842006-01-23 23:05:42 +00001971#ifdef YYLSP_NEEDED
1972 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
1973 YYLTYPE *yyls = yylsa;
1974 YYLTYPE *yylsp;
1975
1976#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
1977#else
Reid Spencer68a24bd2005-08-27 18:50:39 +00001978#define YYPOPSTACK (yyvsp--, yyssp--)
Chris Lattner8335e842006-01-23 23:05:42 +00001979#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001980
Chris Lattner8335e842006-01-23 23:05:42 +00001981 int yystacksize = YYINITDEPTH;
1982 int yyfree_stacks = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001983
Chris Lattner8335e842006-01-23 23:05:42 +00001984#ifdef YYPURE
1985 int yychar;
1986 YYSTYPE yylval;
1987 int yynerrs;
1988#ifdef YYLSP_NEEDED
1989 YYLTYPE yylloc;
1990#endif
1991#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001992
Chris Lattner8335e842006-01-23 23:05:42 +00001993 YYSTYPE yyval; /* the variable used to return */
1994 /* semantic values from the action */
1995 /* routines */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001996
Reid Spencer68a24bd2005-08-27 18:50:39 +00001997 int yylen;
1998
Chris Lattner8335e842006-01-23 23:05:42 +00001999#if YYDEBUG != 0
2000 if (yydebug)
2001 fprintf(stderr, "Starting parse\n");
2002#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002003
2004 yystate = 0;
2005 yyerrstatus = 0;
2006 yynerrs = 0;
2007 yychar = YYEMPTY; /* Cause a token to be read. */
2008
2009 /* Initialize stack pointers.
2010 Waste one element of value and location stack
2011 so that they stay on the same level as the state stack.
2012 The wasted elements are never initialized. */
2013
Chris Lattner8335e842006-01-23 23:05:42 +00002014 yyssp = yyss - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002015 yyvsp = yyvs;
Chris Lattner8335e842006-01-23 23:05:42 +00002016#ifdef YYLSP_NEEDED
2017 yylsp = yyls;
2018#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002019
Chris Lattner8335e842006-01-23 23:05:42 +00002020/* Push a new state, which is found in yystate . */
2021/* In all cases, when you get here, the value and location stacks
2022 have just been pushed. so pushing a state here evens the stacks. */
2023yynewstate:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002024
Chris Lattner8335e842006-01-23 23:05:42 +00002025 *++yyssp = yystate;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002026
Chris Lattner8335e842006-01-23 23:05:42 +00002027 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002028 {
Chris Lattner8335e842006-01-23 23:05:42 +00002029 /* Give user a chance to reallocate the stack */
2030 /* Use copies of these so that the &'s don't force the real ones into memory. */
2031 YYSTYPE *yyvs1 = yyvs;
2032 short *yyss1 = yyss;
2033#ifdef YYLSP_NEEDED
2034 YYLTYPE *yyls1 = yyls;
2035#endif
2036
Reid Spencer68a24bd2005-08-27 18:50:39 +00002037 /* Get the current used size of the three stacks, in elements. */
Chris Lattner8335e842006-01-23 23:05:42 +00002038 int size = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002039
2040#ifdef yyoverflow
Chris Lattner8335e842006-01-23 23:05:42 +00002041 /* Each stack pointer address is followed by the size of
2042 the data in use in that stack, in bytes. */
2043#ifdef YYLSP_NEEDED
2044 /* This used to be a conditional around just the two extra args,
2045 but that might be undefined if yyoverflow is a macro. */
2046 yyoverflow("parser stack overflow",
2047 &yyss1, size * sizeof (*yyssp),
2048 &yyvs1, size * sizeof (*yyvsp),
2049 &yyls1, size * sizeof (*yylsp),
2050 &yystacksize);
2051#else
2052 yyoverflow("parser stack overflow",
2053 &yyss1, size * sizeof (*yyssp),
2054 &yyvs1, size * sizeof (*yyvsp),
2055 &yystacksize);
2056#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002057
Chris Lattner8335e842006-01-23 23:05:42 +00002058 yyss = yyss1; yyvs = yyvs1;
2059#ifdef YYLSP_NEEDED
2060 yyls = yyls1;
2061#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002062#else /* no yyoverflow */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002063 /* Extend the stack our own way. */
Chris Lattner8335e842006-01-23 23:05:42 +00002064 if (yystacksize >= YYMAXDEPTH)
2065 {
2066 yyerror("parser stack overflow");
2067 if (yyfree_stacks)
2068 {
2069 free (yyss);
2070 free (yyvs);
2071#ifdef YYLSP_NEEDED
2072 free (yyls);
2073#endif
2074 }
2075 return 2;
2076 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002077 yystacksize *= 2;
Chris Lattner8335e842006-01-23 23:05:42 +00002078 if (yystacksize > YYMAXDEPTH)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002079 yystacksize = YYMAXDEPTH;
Chris Lattner8335e842006-01-23 23:05:42 +00002080#ifndef YYSTACK_USE_ALLOCA
2081 yyfree_stacks = 1;
2082#endif
2083 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
2084 __yy_memcpy ((char *)yyss, (char *)yyss1,
2085 size * (unsigned int) sizeof (*yyssp));
2086 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
2087 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
2088 size * (unsigned int) sizeof (*yyvsp));
2089#ifdef YYLSP_NEEDED
2090 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
2091 __yy_memcpy ((char *)yyls, (char *)yyls1,
2092 size * (unsigned int) sizeof (*yylsp));
2093#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002094#endif /* no yyoverflow */
2095
Chris Lattner8335e842006-01-23 23:05:42 +00002096 yyssp = yyss + size - 1;
2097 yyvsp = yyvs + size - 1;
2098#ifdef YYLSP_NEEDED
2099 yylsp = yyls + size - 1;
2100#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002101
Chris Lattner8335e842006-01-23 23:05:42 +00002102#if YYDEBUG != 0
2103 if (yydebug)
2104 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2105#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002106
Chris Lattner8335e842006-01-23 23:05:42 +00002107 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002108 YYABORT;
2109 }
2110
Chris Lattner8335e842006-01-23 23:05:42 +00002111#if YYDEBUG != 0
2112 if (yydebug)
2113 fprintf(stderr, "Entering state %d\n", yystate);
2114#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002115
2116 goto yybackup;
Chris Lattner8335e842006-01-23 23:05:42 +00002117 yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002118
2119/* Do appropriate processing given the current state. */
2120/* Read a lookahead token if we need one and don't already have one. */
2121/* yyresume: */
2122
2123 /* First try to decide what to do without reference to lookahead token. */
2124
2125 yyn = yypact[yystate];
Chris Lattner8335e842006-01-23 23:05:42 +00002126 if (yyn == YYFLAG)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002127 goto yydefault;
2128
2129 /* Not known => get a lookahead token if don't already have one. */
2130
Chris Lattner8335e842006-01-23 23:05:42 +00002131 /* yychar is either YYEMPTY or YYEOF
2132 or a valid token in external form. */
2133
Reid Spencer68a24bd2005-08-27 18:50:39 +00002134 if (yychar == YYEMPTY)
2135 {
Chris Lattner8335e842006-01-23 23:05:42 +00002136#if YYDEBUG != 0
2137 if (yydebug)
2138 fprintf(stderr, "Reading a token: ");
2139#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002140 yychar = YYLEX;
2141 }
2142
Chris Lattner8335e842006-01-23 23:05:42 +00002143 /* Convert token to internal form (in yychar1) for indexing tables with */
2144
2145 if (yychar <= 0) /* This means end of input. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002146 {
Chris Lattner8335e842006-01-23 23:05:42 +00002147 yychar1 = 0;
2148 yychar = YYEOF; /* Don't call YYLEX any more */
2149
2150#if YYDEBUG != 0
2151 if (yydebug)
2152 fprintf(stderr, "Now at end of input.\n");
2153#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002154 }
2155 else
2156 {
Chris Lattner8335e842006-01-23 23:05:42 +00002157 yychar1 = YYTRANSLATE(yychar);
2158
2159#if YYDEBUG != 0
2160 if (yydebug)
2161 {
2162 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2163 /* Give the individual parser a way to print the precise meaning
2164 of a token, for further debugging info. */
2165#ifdef YYPRINT
2166 YYPRINT (stderr, yychar, yylval);
2167#endif
2168 fprintf (stderr, ")\n");
2169 }
2170#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002171 }
2172
Chris Lattner8335e842006-01-23 23:05:42 +00002173 yyn += yychar1;
2174 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002175 goto yydefault;
Chris Lattner8335e842006-01-23 23:05:42 +00002176
Reid Spencer68a24bd2005-08-27 18:50:39 +00002177 yyn = yytable[yyn];
Chris Lattner8335e842006-01-23 23:05:42 +00002178
2179 /* yyn is what to do for this token type in this state.
2180 Negative => reduce, -yyn is rule number.
2181 Positive => shift, yyn is new state.
2182 New state is final state => don't bother to shift,
2183 just return success.
2184 0, or most negative number => error. */
2185
2186 if (yyn < 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002187 {
Chris Lattner8335e842006-01-23 23:05:42 +00002188 if (yyn == YYFLAG)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002189 goto yyerrlab;
2190 yyn = -yyn;
2191 goto yyreduce;
2192 }
Chris Lattner8335e842006-01-23 23:05:42 +00002193 else if (yyn == 0)
2194 goto yyerrlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002195
2196 if (yyn == YYFINAL)
2197 YYACCEPT;
2198
2199 /* Shift the lookahead token. */
Chris Lattner8335e842006-01-23 23:05:42 +00002200
2201#if YYDEBUG != 0
2202 if (yydebug)
2203 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2204#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002205
2206 /* Discard the token being shifted unless it is eof. */
2207 if (yychar != YYEOF)
2208 yychar = YYEMPTY;
2209
2210 *++yyvsp = yylval;
Chris Lattner8335e842006-01-23 23:05:42 +00002211#ifdef YYLSP_NEEDED
2212 *++yylsp = yylloc;
2213#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002214
Chris Lattner8335e842006-01-23 23:05:42 +00002215 /* count tokens shifted since error; after three, turn off error status. */
2216 if (yyerrstatus) yyerrstatus--;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002217
2218 yystate = yyn;
2219 goto yynewstate;
2220
Chris Lattner8335e842006-01-23 23:05:42 +00002221/* Do the default action for the current state. */
Reid Spencere812fb22006-01-19 01:21:04 +00002222yydefault:
Chris Lattner8335e842006-01-23 23:05:42 +00002223
Reid Spencer68a24bd2005-08-27 18:50:39 +00002224 yyn = yydefact[yystate];
2225 if (yyn == 0)
2226 goto yyerrlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002227
Chris Lattner8335e842006-01-23 23:05:42 +00002228/* Do a reduction. yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002229yyreduce:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002230 yylen = yyr2[yyn];
Chris Lattner8335e842006-01-23 23:05:42 +00002231 if (yylen > 0)
2232 yyval = yyvsp[1-yylen]; /* implement default value of the action */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002233
Chris Lattner8335e842006-01-23 23:05:42 +00002234#if YYDEBUG != 0
2235 if (yydebug)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002236 {
Chris Lattner8335e842006-01-23 23:05:42 +00002237 int i;
2238
2239 fprintf (stderr, "Reducing via rule %d (line %d), ",
2240 yyn, yyrline[yyn]);
2241
2242 /* Print the symbols being reduced, and their result. */
2243 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2244 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2245 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2246 }
2247#endif
2248
2249
2250 switch (yyn) {
2251
2252case 2:
Chris Lattnerd25db202006-04-08 03:55:17 +00002253#line 1011 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002254{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002255 if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX) // Outside of my range!
2256 ThrowException("Value too large for type!");
2257 yyval.SIntVal = (int32_t)yyvsp[0].UIntVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002258;
2259 break;}
2260case 4:
Chris Lattnerd25db202006-04-08 03:55:17 +00002261#line 1019 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002262{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002263 if (yyvsp[0].UInt64Val > (uint64_t)INT64_MAX) // Outside of my range!
2264 ThrowException("Value too large for type!");
2265 yyval.SInt64Val = (int64_t)yyvsp[0].UInt64Val;
Chris Lattner8335e842006-01-23 23:05:42 +00002266;
2267 break;}
2268case 33:
Chris Lattnerd25db202006-04-08 03:55:17 +00002269#line 1042 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002270{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002271 yyval.StrVal = yyvsp[-1].StrVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002272 ;
2273 break;}
2274case 34:
Chris Lattnerd25db202006-04-08 03:55:17 +00002275#line 1045 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002276{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002277 yyval.StrVal = 0;
Chris Lattner8335e842006-01-23 23:05:42 +00002278 ;
2279 break;}
2280case 35:
Chris Lattnerd25db202006-04-08 03:55:17 +00002281#line 1049 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002282{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2283 break;}
2284case 36:
Chris Lattnerd25db202006-04-08 03:55:17 +00002285#line 1050 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002286{ yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2287 break;}
2288case 37:
Chris Lattnerd25db202006-04-08 03:55:17 +00002289#line 1051 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002290{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2291 break;}
2292case 38:
Chris Lattnerd25db202006-04-08 03:55:17 +00002293#line 1052 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002294{ yyval.Linkage = GlobalValue::AppendingLinkage; ;
2295 break;}
2296case 39:
Chris Lattnerd25db202006-04-08 03:55:17 +00002297#line 1053 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002298{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2299 break;}
2300case 40:
Chris Lattnerd25db202006-04-08 03:55:17 +00002301#line 1055 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002302{ yyval.UIntVal = CallingConv::C; ;
2303 break;}
2304case 41:
Chris Lattnerd25db202006-04-08 03:55:17 +00002305#line 1056 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002306{ yyval.UIntVal = CallingConv::C; ;
2307 break;}
2308case 42:
Chris Lattnerd25db202006-04-08 03:55:17 +00002309#line 1057 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002310{ yyval.UIntVal = CallingConv::Fast; ;
2311 break;}
2312case 43:
Chris Lattnerd25db202006-04-08 03:55:17 +00002313#line 1058 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002314{ yyval.UIntVal = CallingConv::Cold; ;
2315 break;}
2316case 44:
Chris Lattnerd25db202006-04-08 03:55:17 +00002317#line 1059 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002318{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002319 if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
2320 ThrowException("Calling conv too large!");
2321 yyval.UIntVal = yyvsp[0].UInt64Val;
Chris Lattner8335e842006-01-23 23:05:42 +00002322 ;
2323 break;}
2324case 45:
Chris Lattnerd25db202006-04-08 03:55:17 +00002325#line 1067 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002326{ yyval.UIntVal = 0; ;
2327 break;}
2328case 46:
Chris Lattnerd25db202006-04-08 03:55:17 +00002329#line 1068 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002330{
Chris Lattnerb475c422005-11-12 18:22:38 +00002331 yyval.UIntVal = yyvsp[0].UInt64Val;
2332 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
2333 ThrowException("Alignment must be a power of two!");
Chris Lattner8335e842006-01-23 23:05:42 +00002334;
2335 break;}
2336case 47:
Chris Lattnerd25db202006-04-08 03:55:17 +00002337#line 1073 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002338{ yyval.UIntVal = 0; ;
2339 break;}
2340case 48:
Chris Lattnerd25db202006-04-08 03:55:17 +00002341#line 1074 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002342{
Chris Lattnerb475c422005-11-12 18:22:38 +00002343 yyval.UIntVal = yyvsp[0].UInt64Val;
2344 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
2345 ThrowException("Alignment must be a power of two!");
Chris Lattner8335e842006-01-23 23:05:42 +00002346;
2347 break;}
2348case 49:
Chris Lattnerd25db202006-04-08 03:55:17 +00002349#line 1081 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002350{
Chris Lattnere869eef2005-11-12 00:11:49 +00002351 for (unsigned i = 0, e = strlen(yyvsp[0].StrVal); i != e; ++i)
2352 if (yyvsp[0].StrVal[i] == '"' || yyvsp[0].StrVal[i] == '\\')
2353 ThrowException("Invalid character in section name!");
2354 yyval.StrVal = yyvsp[0].StrVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002355;
2356 break;}
2357case 50:
Chris Lattnerd25db202006-04-08 03:55:17 +00002358#line 1088 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002359{ yyval.StrVal = 0; ;
2360 break;}
2361case 51:
Chris Lattnerd25db202006-04-08 03:55:17 +00002362#line 1089 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002363{ yyval.StrVal = yyvsp[0].StrVal; ;
2364 break;}
2365case 52:
Chris Lattnerd25db202006-04-08 03:55:17 +00002366#line 1094 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002367{;
2368 break;}
2369case 53:
Chris Lattnerd25db202006-04-08 03:55:17 +00002370#line 1095 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002371{;
2372 break;}
2373case 54:
Chris Lattnerd25db202006-04-08 03:55:17 +00002374#line 1096 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002375{
Chris Lattnerb475c422005-11-12 18:22:38 +00002376 CurGV->setSection(yyvsp[0].StrVal);
2377 free(yyvsp[0].StrVal);
Chris Lattner8335e842006-01-23 23:05:42 +00002378 ;
2379 break;}
2380case 55:
Chris Lattnerd25db202006-04-08 03:55:17 +00002381#line 1100 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002382{
Chris Lattner7aa61892005-12-21 17:53:23 +00002383 if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val))
2384 ThrowException("Alignment must be a power of two!");
Chris Lattnerb475c422005-11-12 18:22:38 +00002385 CurGV->setAlignment(yyvsp[0].UInt64Val);
Chris Lattner8335e842006-01-23 23:05:42 +00002386 ;
2387 break;}
2388case 57:
Chris Lattnerd25db202006-04-08 03:55:17 +00002389#line 1113 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002390{ yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2391 break;}
2392case 59:
Chris Lattnerd25db202006-04-08 03:55:17 +00002393#line 1114 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002394{ yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2395 break;}
2396case 60:
Chris Lattnerd25db202006-04-08 03:55:17 +00002397#line 1116 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002398{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002399 if (!UpRefs.empty())
2400 ThrowException("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
2401 yyval.TypeVal = yyvsp[0].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002402 ;
2403 break;}
2404case 74:
Chris Lattnerd25db202006-04-08 03:55:17 +00002405#line 1127 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002406{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002407 yyval.TypeVal = new PATypeHolder(OpaqueType::get());
Chris Lattner8335e842006-01-23 23:05:42 +00002408 ;
2409 break;}
2410case 75:
Chris Lattnerd25db202006-04-08 03:55:17 +00002411#line 1130 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002412{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002413 yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
Chris Lattner8335e842006-01-23 23:05:42 +00002414 ;
2415 break;}
2416case 76:
Chris Lattnerd25db202006-04-08 03:55:17 +00002417#line 1133 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002418{ // Named types are also simple types...
Reid Spencer68a24bd2005-08-27 18:50:39 +00002419 yyval.TypeVal = new PATypeHolder(getTypeVal(yyvsp[0].ValIDVal));
Chris Lattner8335e842006-01-23 23:05:42 +00002420;
2421 break;}
2422case 77:
Chris Lattnerd25db202006-04-08 03:55:17 +00002423#line 1139 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002424{ // Type UpReference
Reid Spencer68a24bd2005-08-27 18:50:39 +00002425 if (yyvsp[0].UInt64Val > (uint64_t)~0U) ThrowException("Value out of range!");
2426 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
2427 UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector...
2428 yyval.TypeVal = new PATypeHolder(OT);
2429 UR_OUT("New Upreference!\n");
Chris Lattner8335e842006-01-23 23:05:42 +00002430 ;
2431 break;}
2432case 78:
Chris Lattnerd25db202006-04-08 03:55:17 +00002433#line 1146 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002434{ // Function derived type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002435 std::vector<const Type*> Params;
2436 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2437 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2438 Params.push_back(*I);
2439 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
2440 if (isVarArg) Params.pop_back();
2441
2442 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FunctionType::get(*yyvsp[-3].TypeVal,Params,isVarArg)));
2443 delete yyvsp[-1].TypeList; // Delete the argument list
2444 delete yyvsp[-3].TypeVal; // Delete the return type handle
Chris Lattner8335e842006-01-23 23:05:42 +00002445 ;
2446 break;}
2447case 79:
Chris Lattnerd25db202006-04-08 03:55:17 +00002448#line 1158 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002449{ // Sized array type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002450 yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2451 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002452 ;
2453 break;}
2454case 80:
Chris Lattnerd25db202006-04-08 03:55:17 +00002455#line 1162 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002456{ // Packed array type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002457 const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
Chris Lattner9547d7f2005-11-10 01:42:43 +00002458 if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002459 ThrowException("Unsigned result not equal to signed result");
Chris Lattner9547d7f2005-11-10 01:42:43 +00002460 if (!ElemTy->isPrimitiveType())
Reid Spencer68a24bd2005-08-27 18:50:39 +00002461 ThrowException("Elemental type of a PackedType must be primitive");
Chris Lattner9547d7f2005-11-10 01:42:43 +00002462 if (!isPowerOf2_32(yyvsp[-3].UInt64Val))
2463 ThrowException("Vector length should be a power of 2!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00002464 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PackedType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2465 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002466 ;
2467 break;}
2468case 81:
Chris Lattnerd25db202006-04-08 03:55:17 +00002469#line 1173 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002470{ // Structure type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002471 std::vector<const Type*> Elements;
2472 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2473 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2474 Elements.push_back(*I);
2475
2476 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
2477 delete yyvsp[-1].TypeList;
Chris Lattner8335e842006-01-23 23:05:42 +00002478 ;
2479 break;}
2480case 82:
Chris Lattnerd25db202006-04-08 03:55:17 +00002481#line 1182 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002482{ // Empty structure type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002483 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Chris Lattner8335e842006-01-23 23:05:42 +00002484 ;
2485 break;}
2486case 83:
Chris Lattnerd25db202006-04-08 03:55:17 +00002487#line 1185 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002488{ // Pointer type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002489 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal)));
2490 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002491 ;
2492 break;}
2493case 84:
Chris Lattnerd25db202006-04-08 03:55:17 +00002494#line 1193 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002495{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002496 yyval.TypeList = new std::list<PATypeHolder>();
2497 yyval.TypeList->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002498 ;
2499 break;}
2500case 85:
Chris Lattnerd25db202006-04-08 03:55:17 +00002501#line 1197 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002502{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002503 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002504 ;
2505 break;}
2506case 87:
Chris Lattnerd25db202006-04-08 03:55:17 +00002507#line 1203 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002508{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002509 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(Type::VoidTy);
Chris Lattner8335e842006-01-23 23:05:42 +00002510 ;
2511 break;}
2512case 88:
Chris Lattnerd25db202006-04-08 03:55:17 +00002513#line 1206 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002514{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002515 (yyval.TypeList = new std::list<PATypeHolder>())->push_back(Type::VoidTy);
Chris Lattner8335e842006-01-23 23:05:42 +00002516 ;
2517 break;}
2518case 89:
Chris Lattnerd25db202006-04-08 03:55:17 +00002519#line 1209 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002520{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002521 yyval.TypeList = new std::list<PATypeHolder>();
Chris Lattner8335e842006-01-23 23:05:42 +00002522 ;
2523 break;}
2524case 90:
Chris Lattnerd25db202006-04-08 03:55:17 +00002525#line 1219 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002526{ // Nonempty unsized arr
Reid Spencer68a24bd2005-08-27 18:50:39 +00002527 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
2528 if (ATy == 0)
2529 ThrowException("Cannot make array constant with type: '" +
2530 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2531 const Type *ETy = ATy->getElementType();
2532 int NumElements = ATy->getNumElements();
2533
2534 // Verify that we have the correct size...
2535 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2536 ThrowException("Type mismatch: constant sized array initialized with " +
2537 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
2538 itostr(NumElements) + "!");
2539
2540 // Verify all elements are correct type!
2541 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2542 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2543 ThrowException("Element #" + utostr(i) + " is not of type '" +
2544 ETy->getDescription() +"' as required!\nIt is of type '"+
2545 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2546 }
2547
2548 yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
2549 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Chris Lattner8335e842006-01-23 23:05:42 +00002550 ;
2551 break;}
2552case 91:
Chris Lattnerd25db202006-04-08 03:55:17 +00002553#line 1244 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002554{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002555 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2556 if (ATy == 0)
2557 ThrowException("Cannot make array constant with type: '" +
2558 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2559
2560 int NumElements = ATy->getNumElements();
2561 if (NumElements != -1 && NumElements != 0)
2562 ThrowException("Type mismatch: constant sized array initialized with 0"
2563 " arguments, but has size of " + itostr(NumElements) +"!");
2564 yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
2565 delete yyvsp[-2].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002566 ;
2567 break;}
2568case 92:
Chris Lattnerd25db202006-04-08 03:55:17 +00002569#line 1257 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002570{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002571 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2572 if (ATy == 0)
2573 ThrowException("Cannot make array constant with type: '" +
2574 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2575
2576 int NumElements = ATy->getNumElements();
2577 const Type *ETy = ATy->getElementType();
2578 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
2579 if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal))
2580 ThrowException("Can't build string constant of size " +
2581 itostr((int)(EndStr-yyvsp[0].StrVal)) +
2582 " when array has size " + itostr(NumElements) + "!");
2583 std::vector<Constant*> Vals;
2584 if (ETy == Type::SByteTy) {
Chris Lattner66316012006-01-24 04:14:29 +00002585 for (signed char *C = (signed char *)yyvsp[0].StrVal; C != (signed char *)EndStr; ++C)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002586 Vals.push_back(ConstantSInt::get(ETy, *C));
2587 } else if (ETy == Type::UByteTy) {
Chris Lattner66316012006-01-24 04:14:29 +00002588 for (unsigned char *C = (unsigned char *)yyvsp[0].StrVal;
2589 C != (unsigned char*)EndStr; ++C)
2590 Vals.push_back(ConstantUInt::get(ETy, *C));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002591 } else {
2592 free(yyvsp[0].StrVal);
2593 ThrowException("Cannot build string arrays of non byte sized elements!");
2594 }
2595 free(yyvsp[0].StrVal);
2596 yyval.ConstVal = ConstantArray::get(ATy, Vals);
2597 delete yyvsp[-2].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002598 ;
2599 break;}
2600case 93:
Chris Lattnerd25db202006-04-08 03:55:17 +00002601#line 1286 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002602{ // Nonempty unsized arr
Reid Spencer68a24bd2005-08-27 18:50:39 +00002603 const PackedType *PTy = dyn_cast<PackedType>(yyvsp[-3].TypeVal->get());
2604 if (PTy == 0)
2605 ThrowException("Cannot make packed constant with type: '" +
2606 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2607 const Type *ETy = PTy->getElementType();
2608 int NumElements = PTy->getNumElements();
2609
2610 // Verify that we have the correct size...
2611 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2612 ThrowException("Type mismatch: constant sized packed initialized with " +
2613 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
2614 itostr(NumElements) + "!");
2615
2616 // Verify all elements are correct type!
2617 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2618 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2619 ThrowException("Element #" + utostr(i) + " is not of type '" +
2620 ETy->getDescription() +"' as required!\nIt is of type '"+
2621 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2622 }
2623
2624 yyval.ConstVal = ConstantPacked::get(PTy, *yyvsp[-1].ConstVector);
2625 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Chris Lattner8335e842006-01-23 23:05:42 +00002626 ;
2627 break;}
2628case 94:
Chris Lattnerd25db202006-04-08 03:55:17 +00002629#line 1311 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002630{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002631 const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
2632 if (STy == 0)
2633 ThrowException("Cannot make struct constant with type: '" +
2634 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2635
2636 if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
2637 ThrowException("Illegal number of initializers for structure type!");
2638
2639 // Check to ensure that constants are compatible with the type initializer!
2640 for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
2641 if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
2642 ThrowException("Expected type '" +
2643 STy->getElementType(i)->getDescription() +
2644 "' for element #" + utostr(i) +
2645 " of structure initializer!");
2646
2647 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
2648 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Chris Lattner8335e842006-01-23 23:05:42 +00002649 ;
2650 break;}
2651case 95:
Chris Lattnerd25db202006-04-08 03:55:17 +00002652#line 1331 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002653{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002654 const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
2655 if (STy == 0)
2656 ThrowException("Cannot make struct constant with type: '" +
2657 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2658
2659 if (STy->getNumContainedTypes() != 0)
2660 ThrowException("Illegal number of initializers for structure type!");
2661
2662 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
2663 delete yyvsp[-2].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002664 ;
2665 break;}
2666case 96:
Chris Lattnerd25db202006-04-08 03:55:17 +00002667#line 1343 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002668{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002669 const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
2670 if (PTy == 0)
2671 ThrowException("Cannot make null pointer constant with type: '" +
2672 (*yyvsp[-1].TypeVal)->getDescription() + "'!");
2673
2674 yyval.ConstVal = ConstantPointerNull::get(PTy);
2675 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002676 ;
2677 break;}
2678case 97:
Chris Lattnerd25db202006-04-08 03:55:17 +00002679#line 1352 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002680{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002681 yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
2682 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002683 ;
2684 break;}
2685case 98:
Chris Lattnerd25db202006-04-08 03:55:17 +00002686#line 1356 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002687{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002688 const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
2689 if (Ty == 0)
2690 ThrowException("Global const reference must be a pointer type!");
2691
2692 // ConstExprs can exist in the body of a function, thus creating
2693 // GlobalValues whenever they refer to a variable. Because we are in
2694 // the context of a function, getValNonImprovising will search the functions
2695 // symbol table instead of the module symbol table for the global symbol,
2696 // which throws things all off. To get around this, we just tell
2697 // getValNonImprovising that we are at global scope here.
2698 //
2699 Function *SavedCurFn = CurFun.CurrentFunction;
2700 CurFun.CurrentFunction = 0;
2701
2702 Value *V = getValNonImprovising(Ty, yyvsp[0].ValIDVal);
2703
2704 CurFun.CurrentFunction = SavedCurFn;
2705
2706 // If this is an initializer for a constant pointer, which is referencing a
2707 // (currently) undefined variable, create a stub now that shall be replaced
2708 // in the future with the right type of variable.
2709 //
2710 if (V == 0) {
2711 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
2712 const PointerType *PT = cast<PointerType>(Ty);
2713
2714 // First check to see if the forward references value is already created!
2715 PerModuleInfo::GlobalRefsType::iterator I =
2716 CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
2717
2718 if (I != CurModule.GlobalRefs.end()) {
2719 V = I->second; // Placeholder already exists, use it...
2720 yyvsp[0].ValIDVal.destroy();
2721 } else {
2722 std::string Name;
2723 if (yyvsp[0].ValIDVal.Type == ValID::NameVal) Name = yyvsp[0].ValIDVal.Name;
2724
2725 // Create the forward referenced global.
2726 GlobalValue *GV;
2727 if (const FunctionType *FTy =
2728 dyn_cast<FunctionType>(PT->getElementType())) {
2729 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
2730 CurModule.CurrentModule);
2731 } else {
2732 GV = new GlobalVariable(PT->getElementType(), false,
2733 GlobalValue::ExternalLinkage, 0,
2734 Name, CurModule.CurrentModule);
2735 }
2736
2737 // Keep track of the fact that we have a forward ref to recycle it
2738 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
2739 V = GV;
2740 }
2741 }
2742
2743 yyval.ConstVal = cast<GlobalValue>(V);
2744 delete yyvsp[-1].TypeVal; // Free the type handle
Chris Lattner8335e842006-01-23 23:05:42 +00002745 ;
2746 break;}
2747case 99:
Chris Lattnerd25db202006-04-08 03:55:17 +00002748#line 1415 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002749{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002750 if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
2751 ThrowException("Mismatched types for constant expression!");
2752 yyval.ConstVal = yyvsp[0].ConstVal;
2753 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002754 ;
2755 break;}
2756case 100:
Chris Lattnerd25db202006-04-08 03:55:17 +00002757#line 1421 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002758{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002759 const Type *Ty = yyvsp[-1].TypeVal->get();
2760 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
2761 ThrowException("Cannot create a null initialized value of this type!");
2762 yyval.ConstVal = Constant::getNullValue(Ty);
2763 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002764 ;
2765 break;}
2766case 101:
Chris Lattnerd25db202006-04-08 03:55:17 +00002767#line 1429 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002768{ // integral constants
Reid Spencer68a24bd2005-08-27 18:50:39 +00002769 if (!ConstantSInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
2770 ThrowException("Constant value doesn't fit in type!");
2771 yyval.ConstVal = ConstantSInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val);
Chris Lattner8335e842006-01-23 23:05:42 +00002772 ;
2773 break;}
2774case 102:
Chris Lattnerd25db202006-04-08 03:55:17 +00002775#line 1434 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002776{ // integral constants
Reid Spencer68a24bd2005-08-27 18:50:39 +00002777 if (!ConstantUInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
2778 ThrowException("Constant value doesn't fit in type!");
2779 yyval.ConstVal = ConstantUInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val);
Chris Lattner8335e842006-01-23 23:05:42 +00002780 ;
2781 break;}
2782case 103:
Chris Lattnerd25db202006-04-08 03:55:17 +00002783#line 1439 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002784{ // Boolean constants
Reid Spencer68a24bd2005-08-27 18:50:39 +00002785 yyval.ConstVal = ConstantBool::True;
Chris Lattner8335e842006-01-23 23:05:42 +00002786 ;
2787 break;}
2788case 104:
Chris Lattnerd25db202006-04-08 03:55:17 +00002789#line 1442 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002790{ // Boolean constants
Reid Spencer68a24bd2005-08-27 18:50:39 +00002791 yyval.ConstVal = ConstantBool::False;
Chris Lattner8335e842006-01-23 23:05:42 +00002792 ;
2793 break;}
2794case 105:
Chris Lattnerd25db202006-04-08 03:55:17 +00002795#line 1445 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002796{ // Float & Double constants
Reid Spencer68a24bd2005-08-27 18:50:39 +00002797 if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal))
2798 ThrowException("Floating point constant invalid for type!!");
2799 yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal);
Chris Lattner8335e842006-01-23 23:05:42 +00002800 ;
2801 break;}
2802case 106:
Chris Lattnerd25db202006-04-08 03:55:17 +00002803#line 1452 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002804{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002805 if (!yyvsp[-3].ConstVal->getType()->isFirstClassType())
2806 ThrowException("cast constant expression from a non-primitive type: '" +
2807 yyvsp[-3].ConstVal->getType()->getDescription() + "'!");
2808 if (!yyvsp[-1].TypeVal->get()->isFirstClassType())
2809 ThrowException("cast constant expression to a non-primitive type: '" +
2810 yyvsp[-1].TypeVal->get()->getDescription() + "'!");
2811 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-3].ConstVal, yyvsp[-1].TypeVal->get());
2812 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002813 ;
2814 break;}
2815case 107:
Chris Lattnerd25db202006-04-08 03:55:17 +00002816#line 1462 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002817{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002818 if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
2819 ThrowException("GetElementPtr requires a pointer operand!");
2820
2821 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
2822 // indices to uint struct indices for compatibility.
2823 generic_gep_type_iterator<std::vector<Value*>::iterator>
2824 GTI = gep_type_begin(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end()),
2825 GTE = gep_type_end(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end());
2826 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
2827 if (isa<StructType>(*GTI)) // Only change struct indices
2828 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[-1].ValueList)[i]))
2829 if (CUI->getType() == Type::UByteTy)
2830 (*yyvsp[-1].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
2831
2832 const Type *IdxTy =
2833 GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), *yyvsp[-1].ValueList, true);
2834 if (!IdxTy)
2835 ThrowException("Index list invalid for constant getelementptr!");
2836
2837 std::vector<Constant*> IdxVec;
2838 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
2839 if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
2840 IdxVec.push_back(C);
2841 else
2842 ThrowException("Indices to constant getelementptr must be constants!");
2843
2844 delete yyvsp[-1].ValueList;
2845
2846 yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, IdxVec);
Chris Lattner8335e842006-01-23 23:05:42 +00002847 ;
2848 break;}
2849case 108:
Chris Lattnerd25db202006-04-08 03:55:17 +00002850#line 1493 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002851{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002852 if (yyvsp[-5].ConstVal->getType() != Type::BoolTy)
2853 ThrowException("Select condition must be of boolean type!");
2854 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2855 ThrowException("Select operand types must match!");
2856 yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Chris Lattner8335e842006-01-23 23:05:42 +00002857 ;
2858 break;}
2859case 109:
Chris Lattnerd25db202006-04-08 03:55:17 +00002860#line 1500 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002861{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002862 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2863 ThrowException("Binary operator types must match!");
2864 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
2865 // To retain backward compatibility with these early compilers, we emit a
2866 // cast to the appropriate integer type automatically if we are in the
2867 // broken case. See PR424 for more information.
2868 if (!isa<PointerType>(yyvsp[-3].ConstVal->getType())) {
2869 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2870 } else {
2871 const Type *IntPtrTy = 0;
2872 switch (CurModule.CurrentModule->getPointerSize()) {
2873 case Module::Pointer32: IntPtrTy = Type::IntTy; break;
2874 case Module::Pointer64: IntPtrTy = Type::LongTy; break;
2875 default: ThrowException("invalid pointer binary constant expr!");
2876 }
2877 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, ConstantExpr::getCast(yyvsp[-3].ConstVal, IntPtrTy),
2878 ConstantExpr::getCast(yyvsp[-1].ConstVal, IntPtrTy));
2879 yyval.ConstVal = ConstantExpr::getCast(yyval.ConstVal, yyvsp[-3].ConstVal->getType());
2880 }
Chris Lattner8335e842006-01-23 23:05:42 +00002881 ;
2882 break;}
2883case 110:
Chris Lattnerd25db202006-04-08 03:55:17 +00002884#line 1521 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002885{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002886 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2887 ThrowException("Logical operator types must match!");
Chris Lattner524a1312005-12-21 18:31:50 +00002888 if (!yyvsp[-3].ConstVal->getType()->isIntegral()) {
2889 if (!isa<PackedType>(yyvsp[-3].ConstVal->getType()) ||
2890 !cast<PackedType>(yyvsp[-3].ConstVal->getType())->getElementType()->isIntegral())
2891 ThrowException("Logical operator requires integral operands!");
2892 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002893 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Chris Lattner8335e842006-01-23 23:05:42 +00002894 ;
2895 break;}
2896case 111:
Chris Lattnerd25db202006-04-08 03:55:17 +00002897#line 1531 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002898{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002899 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2900 ThrowException("setcc operand types must match!");
2901 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Chris Lattner8335e842006-01-23 23:05:42 +00002902 ;
2903 break;}
2904case 112:
Chris Lattnerd25db202006-04-08 03:55:17 +00002905#line 1536 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002906{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002907 if (yyvsp[-1].ConstVal->getType() != Type::UByteTy)
2908 ThrowException("Shift count for shift constant must be unsigned byte!");
2909 if (!yyvsp[-3].ConstVal->getType()->isInteger())
2910 ThrowException("Shift constant expression requires integer operand!");
2911 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].OtherOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Chris Lattner8335e842006-01-23 23:05:42 +00002912 ;
2913 break;}
2914case 113:
Chris Lattnerd25db202006-04-08 03:55:17 +00002915#line 1543 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002916{
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00002917 if (!ExtractElementInst::isValidOperands(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
2918 ThrowException("Invalid extractelement operands!");
Robert Bocchino9c62b562006-01-10 19:04:32 +00002919 yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Chris Lattner8335e842006-01-23 23:05:42 +00002920 ;
2921 break;}
2922case 114:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00002923#line 1548 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerd25db202006-04-08 03:55:17 +00002924{
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00002925 if (!InsertElementInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
2926 ThrowException("Invalid insertelement operands!");
Chris Lattnerd25db202006-04-08 03:55:17 +00002927 yyval.ConstVal = ConstantExpr::getInsertElement(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2928 ;
2929 break;}
2930case 115:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00002931#line 1553 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerd25db202006-04-08 03:55:17 +00002932{
2933 if (!ShuffleVectorInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
2934 ThrowException("Invalid shufflevector operands!");
2935 yyval.ConstVal = ConstantExpr::getShuffleVector(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2936 ;
2937 break;}
2938case 116:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00002939#line 1561 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002940{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002941 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
Chris Lattner8335e842006-01-23 23:05:42 +00002942 ;
2943 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00002944case 117:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00002945#line 1564 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002946{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002947 yyval.ConstVector = new std::vector<Constant*>();
2948 yyval.ConstVector->push_back(yyvsp[0].ConstVal);
Chris Lattner8335e842006-01-23 23:05:42 +00002949 ;
2950 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00002951case 118:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00002952#line 1571 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002953{ yyval.BoolVal = false; ;
2954 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00002955case 119:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00002956#line 1571 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002957{ yyval.BoolVal = true; ;
2958 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00002959case 120:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00002960#line 1581 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002961{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002962 yyval.ModuleVal = ParserResult = yyvsp[0].ModuleVal;
2963 CurModule.ModuleDone();
Chris Lattner8335e842006-01-23 23:05:42 +00002964;
2965 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00002966case 121:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00002967#line 1588 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002968{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002969 yyval.ModuleVal = yyvsp[-1].ModuleVal;
2970 CurFun.FunctionDone();
Chris Lattner8335e842006-01-23 23:05:42 +00002971 ;
2972 break;}
Chris Lattner8335e842006-01-23 23:05:42 +00002973case 122:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00002974#line 1592 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002975{
Robert Bocchino9c62b562006-01-10 19:04:32 +00002976 yyval.ModuleVal = yyvsp[-1].ModuleVal;
Chris Lattner8335e842006-01-23 23:05:42 +00002977 ;
2978 break;}
2979case 123:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00002980#line 1595 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerd25db202006-04-08 03:55:17 +00002981{
2982 yyval.ModuleVal = yyvsp[-3].ModuleVal;
2983 ;
2984 break;}
2985case 124:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00002986#line 1598 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerd25db202006-04-08 03:55:17 +00002987{
2988 yyval.ModuleVal = yyvsp[-1].ModuleVal;
2989 ;
2990 break;}
2991case 125:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00002992#line 1601 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00002993{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002994 yyval.ModuleVal = CurModule.CurrentModule;
2995 // Emit an error if there are any unresolved types left.
2996 if (!CurModule.LateResolveTypes.empty()) {
2997 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
2998 if (DID.Type == ValID::NameVal)
2999 ThrowException("Reference to an undefined type: '"+DID.getName() + "'");
3000 else
3001 ThrowException("Reference to an undefined type: #" + itostr(DID.Num));
3002 }
Chris Lattner8335e842006-01-23 23:05:42 +00003003 ;
3004 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003005case 126:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003006#line 1614 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003007{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003008 // Eagerly resolve types. This is not an optimization, this is a
3009 // requirement that is due to the fact that we could have this:
3010 //
3011 // %list = type { %list * }
3012 // %list = type { %list * } ; repeated type decl
3013 //
3014 // If types are not resolved eagerly, then the two types will not be
3015 // determined to be the same type!
3016 //
3017 ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
3018
3019 if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
3020 // If this is a named type that is not a redefinition, add it to the slot
3021 // table.
3022 CurModule.Types.push_back(*yyvsp[0].TypeVal);
3023 }
3024
3025 delete yyvsp[0].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003026 ;
3027 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003028case 127:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003029#line 1634 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003030{ // Function prototypes can be in const pool
3031 ;
3032 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003033case 128:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003034#line 1636 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner66316012006-01-24 04:14:29 +00003035{ // Asm blocks can be in the const pool
Chris Lattner8335e842006-01-23 23:05:42 +00003036 ;
3037 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003038case 129:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003039#line 1638 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003040{
Chris Lattnerb475c422005-11-12 18:22:38 +00003041 if (yyvsp[0].ConstVal == 0) ThrowException("Global value initializer is not a constant!");
3042 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, yyvsp[-2].Linkage, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003043 ;
3044 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003045case 130:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003046#line 1641 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003047{
Chris Lattnerb475c422005-11-12 18:22:38 +00003048 CurGV = 0;
Chris Lattner8335e842006-01-23 23:05:42 +00003049 ;
3050 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003051case 131:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003052#line 1644 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003053{
Chris Lattnerb475c422005-11-12 18:22:38 +00003054 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalLinkage,
3055 yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0);
3056 delete yyvsp[0].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003057 ;
3058 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003059case 132:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003060#line 1648 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003061{
Chris Lattnerb475c422005-11-12 18:22:38 +00003062 CurGV = 0;
Chris Lattner8335e842006-01-23 23:05:42 +00003063 ;
3064 break;}
Chris Lattner8335e842006-01-23 23:05:42 +00003065case 133:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003066#line 1651 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003067{
3068 ;
3069 break;}
3070case 134:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003071#line 1653 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerd25db202006-04-08 03:55:17 +00003072{
3073 ;
3074 break;}
3075case 135:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003076#line 1655 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerd25db202006-04-08 03:55:17 +00003077{
3078 ;
3079 break;}
3080case 136:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003081#line 1659 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003082{
Chris Lattner66316012006-01-24 04:14:29 +00003083 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
3084 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
3085 std::string NewAsm(yyvsp[0].StrVal, EndStr);
Chris Lattner8335e842006-01-23 23:05:42 +00003086 free(yyvsp[0].StrVal);
Chris Lattner66316012006-01-24 04:14:29 +00003087
3088 if (AsmSoFar.empty())
3089 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
3090 else
3091 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Chris Lattner8335e842006-01-23 23:05:42 +00003092;
3093 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003094case 137:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003095#line 1671 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003096{ yyval.Endianness = Module::BigEndian; ;
3097 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003098case 138:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003099#line 1672 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003100{ yyval.Endianness = Module::LittleEndian; ;
3101 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003102case 139:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003103#line 1674 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003104{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003105 CurModule.CurrentModule->setEndianness(yyvsp[0].Endianness);
Chris Lattner8335e842006-01-23 23:05:42 +00003106 ;
3107 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003108case 140:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003109#line 1677 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003110{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003111 if (yyvsp[0].UInt64Val == 32)
3112 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
3113 else if (yyvsp[0].UInt64Val == 64)
3114 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
3115 else
3116 ThrowException("Invalid pointer size: '" + utostr(yyvsp[0].UInt64Val) + "'!");
Chris Lattner8335e842006-01-23 23:05:42 +00003117 ;
3118 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003119case 141:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003120#line 1685 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003121{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003122 CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal);
3123 free(yyvsp[0].StrVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003124 ;
3125 break;}
Chris Lattner66316012006-01-24 04:14:29 +00003126case 143:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003127#line 1692 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerd25db202006-04-08 03:55:17 +00003128{
3129 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3130 free(yyvsp[0].StrVal);
3131 ;
3132 break;}
3133case 144:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003134#line 1696 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerd25db202006-04-08 03:55:17 +00003135{
3136 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3137 free(yyvsp[0].StrVal);
3138 ;
3139 break;}
3140case 145:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003141#line 1700 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner66316012006-01-24 04:14:29 +00003142{
Chris Lattner8335e842006-01-23 23:05:42 +00003143 ;
3144 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003145case 149:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003146#line 1709 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003147{ yyval.StrVal = 0; ;
3148 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003149case 150:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003150#line 1711 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003151{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003152 if (*yyvsp[-1].TypeVal == Type::VoidTy)
3153 ThrowException("void typed arguments are invalid!");
3154 yyval.ArgVal = new std::pair<PATypeHolder*, char*>(yyvsp[-1].TypeVal, yyvsp[0].StrVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003155;
3156 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003157case 151:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003158#line 1717 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003159{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003160 yyval.ArgList = yyvsp[-2].ArgList;
3161 yyvsp[-2].ArgList->push_back(*yyvsp[0].ArgVal);
3162 delete yyvsp[0].ArgVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003163 ;
3164 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003165case 152:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003166#line 1722 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003167{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003168 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
3169 yyval.ArgList->push_back(*yyvsp[0].ArgVal);
3170 delete yyvsp[0].ArgVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003171 ;
3172 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003173case 153:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003174#line 1728 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003175{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003176 yyval.ArgList = yyvsp[0].ArgList;
Chris Lattner8335e842006-01-23 23:05:42 +00003177 ;
3178 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003179case 154:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003180#line 1731 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003181{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003182 yyval.ArgList = yyvsp[-2].ArgList;
3183 yyval.ArgList->push_back(std::pair<PATypeHolder*,
3184 char*>(new PATypeHolder(Type::VoidTy), 0));
Chris Lattner8335e842006-01-23 23:05:42 +00003185 ;
3186 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003187case 155:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003188#line 1736 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003189{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003190 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
3191 yyval.ArgList->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0));
Chris Lattner8335e842006-01-23 23:05:42 +00003192 ;
3193 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003194case 156:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003195#line 1740 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003196{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003197 yyval.ArgList = 0;
Chris Lattner8335e842006-01-23 23:05:42 +00003198 ;
3199 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003200case 157:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003201#line 1745 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003202{
Chris Lattnere869eef2005-11-12 00:11:49 +00003203 UnEscapeLexed(yyvsp[-5].StrVal);
3204 std::string FunctionName(yyvsp[-5].StrVal);
3205 free(yyvsp[-5].StrVal); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00003206
Chris Lattnere869eef2005-11-12 00:11:49 +00003207 if (!(*yyvsp[-6].TypeVal)->isFirstClassType() && *yyvsp[-6].TypeVal != Type::VoidTy)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003208 ThrowException("LLVM functions cannot return aggregate types!");
3209
3210 std::vector<const Type*> ParamTypeList;
Chris Lattnere869eef2005-11-12 00:11:49 +00003211 if (yyvsp[-3].ArgList) { // If there are arguments...
3212 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-3].ArgList->begin();
3213 I != yyvsp[-3].ArgList->end(); ++I)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003214 ParamTypeList.push_back(I->first->get());
3215 }
3216
3217 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
3218 if (isVarArg) ParamTypeList.pop_back();
3219
Chris Lattnere869eef2005-11-12 00:11:49 +00003220 const FunctionType *FT = FunctionType::get(*yyvsp[-6].TypeVal, ParamTypeList, isVarArg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003221 const PointerType *PFT = PointerType::get(FT);
Chris Lattnere869eef2005-11-12 00:11:49 +00003222 delete yyvsp[-6].TypeVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003223
3224 ValID ID;
3225 if (!FunctionName.empty()) {
3226 ID = ValID::create((char*)FunctionName.c_str());
3227 } else {
3228 ID = ValID::create((int)CurModule.Values[PFT].size());
3229 }
3230
3231 Function *Fn = 0;
3232 // See if this function was forward referenced. If so, recycle the object.
3233 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
3234 // Move the function to the end of the list, from whereever it was
3235 // previously inserted.
3236 Fn = cast<Function>(FWRef);
3237 CurModule.CurrentModule->getFunctionList().remove(Fn);
3238 CurModule.CurrentModule->getFunctionList().push_back(Fn);
3239 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
3240 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
3241 // If this is the case, either we need to be a forward decl, or it needs
3242 // to be.
3243 if (!CurFun.isDeclare && !Fn->isExternal())
3244 ThrowException("Redefinition of function '" + FunctionName + "'!");
3245
3246 // Make sure to strip off any argument names so we can't get conflicts.
3247 if (Fn->isExternal())
3248 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
3249 AI != AE; ++AI)
3250 AI->setName("");
3251
3252 } else { // Not already defined?
3253 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
3254 CurModule.CurrentModule);
3255 InsertValue(Fn, CurModule.Values);
3256 }
3257
3258 CurFun.FunctionStart(Fn);
Chris Lattnere869eef2005-11-12 00:11:49 +00003259 Fn->setCallingConv(yyvsp[-7].UIntVal);
Chris Lattner0019bbe2005-11-06 06:46:53 +00003260 Fn->setAlignment(yyvsp[0].UIntVal);
Chris Lattnere869eef2005-11-12 00:11:49 +00003261 if (yyvsp[-1].StrVal) {
3262 Fn->setSection(yyvsp[-1].StrVal);
3263 free(yyvsp[-1].StrVal);
3264 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00003265
3266 // Add all of the arguments we parsed to the function...
Chris Lattnere869eef2005-11-12 00:11:49 +00003267 if (yyvsp[-3].ArgList) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00003268 if (isVarArg) { // Nuke the last entry
Chris Lattnere869eef2005-11-12 00:11:49 +00003269 assert(yyvsp[-3].ArgList->back().first->get() == Type::VoidTy && yyvsp[-3].ArgList->back().second == 0&&
Reid Spencer68a24bd2005-08-27 18:50:39 +00003270 "Not a varargs marker!");
Chris Lattnere869eef2005-11-12 00:11:49 +00003271 delete yyvsp[-3].ArgList->back().first;
3272 yyvsp[-3].ArgList->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00003273 }
3274 Function::arg_iterator ArgIt = Fn->arg_begin();
Chris Lattnere869eef2005-11-12 00:11:49 +00003275 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-3].ArgList->begin();
3276 I != yyvsp[-3].ArgList->end(); ++I, ++ArgIt) {
Reid Spencer68a24bd2005-08-27 18:50:39 +00003277 delete I->first; // Delete the typeholder...
3278
3279 setValueName(ArgIt, I->second); // Insert arg into symtab...
3280 InsertValue(ArgIt);
3281 }
3282
Chris Lattnere869eef2005-11-12 00:11:49 +00003283 delete yyvsp[-3].ArgList; // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00003284 }
Chris Lattner8335e842006-01-23 23:05:42 +00003285;
3286 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003287case 160:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003288#line 1832 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003289{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003290 yyval.FunctionVal = CurFun.CurrentFunction;
3291
3292 // Make sure that we keep track of the linkage type even if there was a
3293 // previous "declare".
3294 yyval.FunctionVal->setLinkage(yyvsp[-2].Linkage);
Chris Lattner8335e842006-01-23 23:05:42 +00003295;
3296 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003297case 163:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003298#line 1842 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003299{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003300 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003301;
3302 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003303case 164:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003304#line 1846 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003305{ CurFun.isDeclare = true; ;
3306 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003307case 165:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003308#line 1846 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003309{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003310 yyval.FunctionVal = CurFun.CurrentFunction;
3311 CurFun.FunctionDone();
Chris Lattner8335e842006-01-23 23:05:42 +00003312;
3313 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003314case 166:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003315#line 1855 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner0e9c3762006-01-25 22:27:16 +00003316{
3317 yyval.BoolVal = false;
3318 ;
3319 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003320case 167:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003321#line 1858 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner0e9c3762006-01-25 22:27:16 +00003322{
3323 yyval.BoolVal = true;
3324 ;
3325 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003326case 168:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003327#line 1862 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003328{ // A reference to a direct constant
Reid Spencer68a24bd2005-08-27 18:50:39 +00003329 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
Chris Lattner8335e842006-01-23 23:05:42 +00003330 ;
3331 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003332case 169:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003333#line 1865 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003334{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003335 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
Chris Lattner8335e842006-01-23 23:05:42 +00003336 ;
3337 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003338case 170:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003339#line 1868 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003340{ // Perhaps it's an FP constant?
Reid Spencer68a24bd2005-08-27 18:50:39 +00003341 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003342 ;
3343 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003344case 171:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003345#line 1871 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003346{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003347 yyval.ValIDVal = ValID::create(ConstantBool::True);
Chris Lattner8335e842006-01-23 23:05:42 +00003348 ;
3349 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003350case 172:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003351#line 1874 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003352{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003353 yyval.ValIDVal = ValID::create(ConstantBool::False);
Chris Lattner8335e842006-01-23 23:05:42 +00003354 ;
3355 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003356case 173:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003357#line 1877 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003358{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003359 yyval.ValIDVal = ValID::createNull();
Chris Lattner8335e842006-01-23 23:05:42 +00003360 ;
3361 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003362case 174:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003363#line 1880 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003364{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003365 yyval.ValIDVal = ValID::createUndef();
Chris Lattner8335e842006-01-23 23:05:42 +00003366 ;
3367 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003368case 175:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003369#line 1883 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003370{ // A vector zero constant.
Chris Lattner7aa61892005-12-21 17:53:23 +00003371 yyval.ValIDVal = ValID::createZeroInit();
Chris Lattner8335e842006-01-23 23:05:42 +00003372 ;
3373 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003374case 176:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003375#line 1886 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003376{ // Nonempty unsized packed vector
Reid Spencer68a24bd2005-08-27 18:50:39 +00003377 const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
3378 int NumElements = yyvsp[-1].ConstVector->size();
3379
3380 PackedType* pt = PackedType::get(ETy, NumElements);
3381 PATypeHolder* PTy = new PATypeHolder(
3382 HandleUpRefs(
3383 PackedType::get(
3384 ETy,
3385 NumElements)
3386 )
3387 );
3388
3389 // Verify all elements are correct type!
3390 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3391 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
3392 ThrowException("Element #" + utostr(i) + " is not of type '" +
3393 ETy->getDescription() +"' as required!\nIt is of type '" +
3394 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
3395 }
3396
3397 yyval.ValIDVal = ValID::create(ConstantPacked::get(pt, *yyvsp[-1].ConstVector));
3398 delete PTy; delete yyvsp[-1].ConstVector;
Chris Lattner8335e842006-01-23 23:05:42 +00003399 ;
3400 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003401case 177:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003402#line 1910 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003403{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003404 yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003405 ;
3406 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003407case 178:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003408#line 1913 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner0e9c3762006-01-25 22:27:16 +00003409{
3410 char *End = UnEscapeLexed(yyvsp[-2].StrVal, true);
3411 std::string AsmStr = std::string(yyvsp[-2].StrVal, End);
3412 End = UnEscapeLexed(yyvsp[0].StrVal, true);
3413 std::string Constraints = std::string(yyvsp[0].StrVal, End);
3414 yyval.ValIDVal = ValID::createInlineAsm(AsmStr, Constraints, yyvsp[-3].BoolVal);
3415 free(yyvsp[-2].StrVal);
3416 free(yyvsp[0].StrVal);
3417 ;
3418 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003419case 179:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003420#line 1926 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003421{ // Is it an integer reference...?
Reid Spencer68a24bd2005-08-27 18:50:39 +00003422 yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003423 ;
3424 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003425case 180:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003426#line 1929 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003427{ // Is it a named reference...?
Reid Spencer68a24bd2005-08-27 18:50:39 +00003428 yyval.ValIDVal = ValID::create(yyvsp[0].StrVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003429 ;
3430 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003431case 183:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003432#line 1940 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003433{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003434 yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003435 ;
3436 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003437case 184:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003438#line 1944 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003439{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003440 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003441 ;
3442 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003443case 185:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003444#line 1947 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003445{ // Do not allow functions with 0 basic blocks
Reid Spencer68a24bd2005-08-27 18:50:39 +00003446 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003447 ;
3448 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003449case 186:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003450#line 1955 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003451{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003452 setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
3453 InsertValue(yyvsp[0].TermInstVal);
3454
3455 yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
3456 InsertValue(yyvsp[-2].BasicBlockVal);
3457 yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003458 ;
3459 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003460case 187:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003461#line 1964 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003462{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003463 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
3464 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003465 ;
3466 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003467case 188:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003468#line 1968 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003469{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003470 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
3471
3472 // Make sure to move the basic block to the correct location in the
3473 // function, instead of leaving it inserted wherever it was first
3474 // referenced.
3475 Function::BasicBlockListType &BBL =
3476 CurFun.CurrentFunction->getBasicBlockList();
3477 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003478 ;
3479 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003480case 189:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003481#line 1978 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003482{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003483 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create(yyvsp[0].StrVal), true);
3484
3485 // Make sure to move the basic block to the correct location in the
3486 // function, instead of leaving it inserted wherever it was first
3487 // referenced.
3488 Function::BasicBlockListType &BBL =
3489 CurFun.CurrentFunction->getBasicBlockList();
3490 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003491 ;
3492 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003493case 190:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003494#line 1989 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003495{ // Return with a result...
Reid Spencer68a24bd2005-08-27 18:50:39 +00003496 yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003497 ;
3498 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003499case 191:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003500#line 1992 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003501{ // Return with no result...
Reid Spencer68a24bd2005-08-27 18:50:39 +00003502 yyval.TermInstVal = new ReturnInst();
Chris Lattner8335e842006-01-23 23:05:42 +00003503 ;
3504 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003505case 192:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003506#line 1995 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003507{ // Unconditional Branch...
Reid Spencer68a24bd2005-08-27 18:50:39 +00003508 yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[0].ValIDVal));
Chris Lattner8335e842006-01-23 23:05:42 +00003509 ;
3510 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003511case 193:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003512#line 1998 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003513{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003514 yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[-3].ValIDVal), getBBVal(yyvsp[0].ValIDVal), getVal(Type::BoolTy, yyvsp[-6].ValIDVal));
Chris Lattner8335e842006-01-23 23:05:42 +00003515 ;
3516 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003517case 194:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003518#line 2001 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003519{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003520 SwitchInst *S = new SwitchInst(getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal), getBBVal(yyvsp[-3].ValIDVal), yyvsp[-1].JumpTable->size());
3521 yyval.TermInstVal = S;
3522
3523 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
3524 E = yyvsp[-1].JumpTable->end();
3525 for (; I != E; ++I) {
3526 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
3527 S->addCase(CI, I->second);
3528 else
3529 ThrowException("Switch case is constant, but not a simple integer!");
3530 }
3531 delete yyvsp[-1].JumpTable;
Chris Lattner8335e842006-01-23 23:05:42 +00003532 ;
3533 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003534case 195:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003535#line 2015 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003536{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003537 SwitchInst *S = new SwitchInst(getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal), getBBVal(yyvsp[-2].ValIDVal), 0);
3538 yyval.TermInstVal = S;
Chris Lattner8335e842006-01-23 23:05:42 +00003539 ;
3540 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003541case 196:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003542#line 2020 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003543{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003544 const PointerType *PFTy;
3545 const FunctionType *Ty;
3546
3547 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-10].TypeVal->get())) ||
3548 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3549 // Pull out the types of all of the arguments...
3550 std::vector<const Type*> ParamTypes;
3551 if (yyvsp[-7].ValueList) {
3552 for (std::vector<Value*>::iterator I = yyvsp[-7].ValueList->begin(), E = yyvsp[-7].ValueList->end();
3553 I != E; ++I)
3554 ParamTypes.push_back((*I)->getType());
3555 }
3556
3557 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3558 if (isVarArg) ParamTypes.pop_back();
3559
3560 Ty = FunctionType::get(yyvsp[-10].TypeVal->get(), ParamTypes, isVarArg);
3561 PFTy = PointerType::get(Ty);
3562 }
3563
3564 Value *V = getVal(PFTy, yyvsp[-9].ValIDVal); // Get the function we're calling...
3565
3566 BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
3567 BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
3568
3569 // Create the call node...
3570 if (!yyvsp[-7].ValueList) { // Has no arguments?
3571 yyval.TermInstVal = new InvokeInst(V, Normal, Except, std::vector<Value*>());
3572 } else { // Has arguments?
3573 // Loop through FunctionType's arguments and ensure they are specified
3574 // correctly!
3575 //
3576 FunctionType::param_iterator I = Ty->param_begin();
3577 FunctionType::param_iterator E = Ty->param_end();
3578 std::vector<Value*>::iterator ArgI = yyvsp[-7].ValueList->begin(), ArgE = yyvsp[-7].ValueList->end();
3579
3580 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3581 if ((*ArgI)->getType() != *I)
3582 ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
3583 (*I)->getDescription() + "'!");
3584
3585 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
3586 ThrowException("Invalid number of parameters detected!");
3587
3588 yyval.TermInstVal = new InvokeInst(V, Normal, Except, *yyvsp[-7].ValueList);
3589 }
3590 cast<InvokeInst>(yyval.TermInstVal)->setCallingConv(yyvsp[-11].UIntVal);
3591
3592 delete yyvsp[-10].TypeVal;
3593 delete yyvsp[-7].ValueList;
Chris Lattner8335e842006-01-23 23:05:42 +00003594 ;
3595 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003596case 197:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003597#line 2072 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003598{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003599 yyval.TermInstVal = new UnwindInst();
Chris Lattner8335e842006-01-23 23:05:42 +00003600 ;
3601 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003602case 198:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003603#line 2075 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003604{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003605 yyval.TermInstVal = new UnreachableInst();
Chris Lattner8335e842006-01-23 23:05:42 +00003606 ;
3607 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003608case 199:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003609#line 2081 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003610{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003611 yyval.JumpTable = yyvsp[-5].JumpTable;
3612 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
3613 if (V == 0)
3614 ThrowException("May only switch on a constant pool value!");
3615
3616 yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
Chris Lattner8335e842006-01-23 23:05:42 +00003617 ;
3618 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003619case 200:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003620#line 2089 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003621{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003622 yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
3623 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
3624
3625 if (V == 0)
3626 ThrowException("May only switch on a constant pool value!");
3627
3628 yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
Chris Lattner8335e842006-01-23 23:05:42 +00003629 ;
3630 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003631case 201:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003632#line 2099 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003633{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003634 // Is this definition named?? if so, assign the name...
3635 setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
3636 InsertValue(yyvsp[0].InstVal);
3637 yyval.InstVal = yyvsp[0].InstVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003638;
3639 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003640case 202:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003641#line 2106 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003642{ // Used for PHI nodes
Reid Spencer68a24bd2005-08-27 18:50:39 +00003643 yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
3644 yyval.PHIList->push_back(std::make_pair(getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal), getBBVal(yyvsp[-1].ValIDVal)));
3645 delete yyvsp[-5].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003646 ;
3647 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003648case 203:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003649#line 2111 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003650{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003651 yyval.PHIList = yyvsp[-6].PHIList;
3652 yyvsp[-6].PHIList->push_back(std::make_pair(getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal),
3653 getBBVal(yyvsp[-1].ValIDVal)));
Chris Lattner8335e842006-01-23 23:05:42 +00003654 ;
3655 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003656case 204:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003657#line 2118 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003658{ // Used for call statements, and memory insts...
Reid Spencer68a24bd2005-08-27 18:50:39 +00003659 yyval.ValueList = new std::vector<Value*>();
3660 yyval.ValueList->push_back(yyvsp[0].ValueVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003661 ;
3662 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003663case 205:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003664#line 2122 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003665{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003666 yyval.ValueList = yyvsp[-2].ValueList;
3667 yyvsp[-2].ValueList->push_back(yyvsp[0].ValueVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003668 ;
3669 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003670case 207:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003671#line 2128 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003672{ yyval.ValueList = 0; ;
3673 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003674case 208:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003675#line 2130 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003676{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003677 yyval.BoolVal = true;
Chris Lattner8335e842006-01-23 23:05:42 +00003678 ;
3679 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003680case 209:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003681#line 2133 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003682{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003683 yyval.BoolVal = false;
Chris Lattner8335e842006-01-23 23:05:42 +00003684 ;
3685 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003686case 210:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003687#line 2139 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003688{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003689 if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
3690 !isa<PackedType>((*yyvsp[-3].TypeVal).get()))
3691 ThrowException(
3692 "Arithmetic operator requires integer, FP, or packed operands!");
3693 if (isa<PackedType>((*yyvsp[-3].TypeVal).get()) && yyvsp[-4].BinaryOpVal == Instruction::Rem)
3694 ThrowException("Rem not supported on packed types!");
3695 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3696 if (yyval.InstVal == 0)
3697 ThrowException("binary operator returned null!");
3698 delete yyvsp[-3].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003699 ;
3700 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003701case 211:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003702#line 2151 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003703{
Chris Lattner524a1312005-12-21 18:31:50 +00003704 if (!(*yyvsp[-3].TypeVal)->isIntegral()) {
3705 if (!isa<PackedType>(yyvsp[-3].TypeVal->get()) ||
3706 !cast<PackedType>(yyvsp[-3].TypeVal->get())->getElementType()->isIntegral())
3707 ThrowException("Logical operator requires integral operands!");
3708 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00003709 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3710 if (yyval.InstVal == 0)
3711 ThrowException("binary operator returned null!");
3712 delete yyvsp[-3].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003713 ;
3714 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003715case 212:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003716#line 2162 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003717{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003718 if(isa<PackedType>((*yyvsp[-3].TypeVal).get())) {
3719 ThrowException(
3720 "PackedTypes currently not supported in setcc instructions!");
3721 }
3722 yyval.InstVal = new SetCondInst(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3723 if (yyval.InstVal == 0)
3724 ThrowException("binary operator returned null!");
3725 delete yyvsp[-3].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003726 ;
3727 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003728case 213:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003729#line 2172 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003730{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003731 std::cerr << "WARNING: Use of eliminated 'not' instruction:"
3732 << " Replacing with 'xor'.\n";
3733
3734 Value *Ones = ConstantIntegral::getAllOnesValue(yyvsp[0].ValueVal->getType());
3735 if (Ones == 0)
3736 ThrowException("Expected integral type for not instruction!");
3737
3738 yyval.InstVal = BinaryOperator::create(Instruction::Xor, yyvsp[0].ValueVal, Ones);
3739 if (yyval.InstVal == 0)
3740 ThrowException("Could not create a xor instruction!");
Chris Lattner8335e842006-01-23 23:05:42 +00003741 ;
3742 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003743case 214:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003744#line 2184 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003745{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003746 if (yyvsp[0].ValueVal->getType() != Type::UByteTy)
3747 ThrowException("Shift amount must be ubyte!");
3748 if (!yyvsp[-2].ValueVal->getType()->isInteger())
3749 ThrowException("Shift constant expression requires integer operand!");
3750 yyval.InstVal = new ShiftInst(yyvsp[-3].OtherOpVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003751 ;
3752 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003753case 215:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003754#line 2191 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003755{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003756 if (!yyvsp[0].TypeVal->get()->isFirstClassType())
3757 ThrowException("cast instruction to a non-primitive type: '" +
3758 yyvsp[0].TypeVal->get()->getDescription() + "'!");
3759 yyval.InstVal = new CastInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
3760 delete yyvsp[0].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003761 ;
3762 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003763case 216:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003764#line 2198 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003765{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003766 if (yyvsp[-4].ValueVal->getType() != Type::BoolTy)
3767 ThrowException("select condition must be boolean!");
3768 if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
3769 ThrowException("select value types should match!");
3770 yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003771 ;
3772 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003773case 217:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003774#line 2205 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003775{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003776 NewVarArgs = true;
3777 yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
3778 delete yyvsp[0].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003779 ;
3780 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003781case 218:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003782#line 2210 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003783{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003784 ObsoleteVarArgs = true;
3785 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
3786 Function* NF = CurModule.CurrentModule->
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003787 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003788
3789 //b = vaarg a, t ->
3790 //foo = alloca 1 of t
3791 //bar = vacopy a
3792 //store bar -> foo
3793 //b = vaarg foo, t
3794 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
3795 CurBB->getInstList().push_back(foo);
3796 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
3797 CurBB->getInstList().push_back(bar);
3798 CurBB->getInstList().push_back(new StoreInst(bar, foo));
3799 yyval.InstVal = new VAArgInst(foo, *yyvsp[0].TypeVal);
3800 delete yyvsp[0].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003801 ;
3802 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003803case 219:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003804#line 2229 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003805{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003806 ObsoleteVarArgs = true;
3807 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
3808 Function* NF = CurModule.CurrentModule->
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003809 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003810
3811 //b = vanext a, t ->
3812 //foo = alloca 1 of t
3813 //bar = vacopy a
3814 //store bar -> foo
3815 //tmp = vaarg foo, t
3816 //b = load foo
3817 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
3818 CurBB->getInstList().push_back(foo);
3819 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
3820 CurBB->getInstList().push_back(bar);
3821 CurBB->getInstList().push_back(new StoreInst(bar, foo));
3822 Instruction* tmp = new VAArgInst(foo, *yyvsp[0].TypeVal);
3823 CurBB->getInstList().push_back(tmp);
3824 yyval.InstVal = new LoadInst(foo);
3825 delete yyvsp[0].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003826 ;
3827 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003828case 220:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003829#line 2251 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003830{
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003831 if (!ExtractElementInst::isValidOperands(yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
3832 ThrowException("Invalid extractelement operands!");
Robert Bocchino9c62b562006-01-10 19:04:32 +00003833 yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003834 ;
3835 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003836case 221:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003837#line 2256 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003838{
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003839 if (!InsertElementInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
3840 ThrowException("Invalid insertelement operands!");
Robert Bocchino2def1b32006-01-17 20:06:25 +00003841 yyval.InstVal = new InsertElementInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003842 ;
3843 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003844case 222:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003845#line 2261 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerd5efe842006-04-08 01:18:56 +00003846{
Chris Lattnerd25db202006-04-08 03:55:17 +00003847 if (!ShuffleVectorInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
3848 ThrowException("Invalid shufflevector operands!");
Chris Lattnerd5efe842006-04-08 01:18:56 +00003849 yyval.InstVal = new ShuffleVectorInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
3850 ;
3851 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003852case 223:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003853#line 2266 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003854{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003855 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
3856 if (!Ty->isFirstClassType())
3857 ThrowException("PHI node operands must be of first class type!");
3858 yyval.InstVal = new PHINode(Ty);
3859 ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
3860 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
3861 if (yyvsp[0].PHIList->front().first->getType() != Ty)
3862 ThrowException("All elements of a PHI node must be of the same type!");
3863 cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
3864 yyvsp[0].PHIList->pop_front();
3865 }
3866 delete yyvsp[0].PHIList; // Free the list...
Chris Lattner8335e842006-01-23 23:05:42 +00003867 ;
3868 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003869case 224:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003870#line 2280 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003871{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003872 const PointerType *PFTy;
3873 const FunctionType *Ty;
3874
3875 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-4].TypeVal->get())) ||
3876 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3877 // Pull out the types of all of the arguments...
3878 std::vector<const Type*> ParamTypes;
3879 if (yyvsp[-1].ValueList) {
3880 for (std::vector<Value*>::iterator I = yyvsp[-1].ValueList->begin(), E = yyvsp[-1].ValueList->end();
3881 I != E; ++I)
3882 ParamTypes.push_back((*I)->getType());
3883 }
3884
3885 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3886 if (isVarArg) ParamTypes.pop_back();
3887
3888 if (!(*yyvsp[-4].TypeVal)->isFirstClassType() && *yyvsp[-4].TypeVal != Type::VoidTy)
3889 ThrowException("LLVM functions cannot return aggregate types!");
3890
3891 Ty = FunctionType::get(yyvsp[-4].TypeVal->get(), ParamTypes, isVarArg);
3892 PFTy = PointerType::get(Ty);
3893 }
3894
3895 Value *V = getVal(PFTy, yyvsp[-3].ValIDVal); // Get the function we're calling...
3896
3897 // Create the call node...
3898 if (!yyvsp[-1].ValueList) { // Has no arguments?
3899 // Make sure no arguments is a good thing!
3900 if (Ty->getNumParams() != 0)
3901 ThrowException("No arguments passed to a function that "
3902 "expects arguments!");
3903
3904 yyval.InstVal = new CallInst(V, std::vector<Value*>());
3905 } else { // Has arguments?
3906 // Loop through FunctionType's arguments and ensure they are specified
3907 // correctly!
3908 //
3909 FunctionType::param_iterator I = Ty->param_begin();
3910 FunctionType::param_iterator E = Ty->param_end();
3911 std::vector<Value*>::iterator ArgI = yyvsp[-1].ValueList->begin(), ArgE = yyvsp[-1].ValueList->end();
3912
3913 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3914 if ((*ArgI)->getType() != *I)
3915 ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
3916 (*I)->getDescription() + "'!");
3917
3918 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
3919 ThrowException("Invalid number of parameters detected!");
3920
3921 yyval.InstVal = new CallInst(V, *yyvsp[-1].ValueList);
3922 }
3923 cast<CallInst>(yyval.InstVal)->setTailCall(yyvsp[-6].BoolVal);
3924 cast<CallInst>(yyval.InstVal)->setCallingConv(yyvsp[-5].UIntVal);
3925 delete yyvsp[-4].TypeVal;
3926 delete yyvsp[-1].ValueList;
Chris Lattner8335e842006-01-23 23:05:42 +00003927 ;
3928 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003929case 225:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003930#line 2337 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003931{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003932 yyval.InstVal = yyvsp[0].InstVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003933 ;
3934 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003935case 226:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003936#line 2343 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003937{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003938 yyval.ValueList = yyvsp[0].ValueList;
Chris Lattner8335e842006-01-23 23:05:42 +00003939 ;
3940 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003941case 227:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003942#line 2345 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003943{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003944 yyval.ValueList = new std::vector<Value*>();
Chris Lattner8335e842006-01-23 23:05:42 +00003945 ;
3946 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003947case 228:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003948#line 2349 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003949{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003950 yyval.BoolVal = true;
Chris Lattner8335e842006-01-23 23:05:42 +00003951 ;
3952 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003953case 229:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003954#line 2352 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003955{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003956 yyval.BoolVal = false;
Chris Lattner8335e842006-01-23 23:05:42 +00003957 ;
3958 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003959case 230:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003960#line 2358 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003961{
Chris Lattner7d09ab62005-11-06 06:34:34 +00003962 yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
3963 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003964 ;
3965 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003966case 231:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003967#line 2362 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003968{
Chris Lattner7d09ab62005-11-06 06:34:34 +00003969 yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal);
3970 delete yyvsp[-4].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003971 ;
3972 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003973case 232:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003974#line 2366 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003975{
Chris Lattner7d09ab62005-11-06 06:34:34 +00003976 yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
3977 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003978 ;
3979 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003980case 233:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003981#line 2370 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003982{
Chris Lattner7d09ab62005-11-06 06:34:34 +00003983 yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal);
3984 delete yyvsp[-4].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00003985 ;
3986 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003987case 234:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003988#line 2374 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003989{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003990 if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
3991 ThrowException("Trying to free nonpointer type " +
3992 yyvsp[0].ValueVal->getType()->getDescription() + "!");
3993 yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
Chris Lattner8335e842006-01-23 23:05:42 +00003994 ;
3995 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00003996case 235:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00003997#line 2381 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00003998{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003999 if (!isa<PointerType>(yyvsp[-1].TypeVal->get()))
4000 ThrowException("Can't load from nonpointer type: " +
4001 (*yyvsp[-1].TypeVal)->getDescription());
4002 if (!cast<PointerType>(yyvsp[-1].TypeVal->get())->getElementType()->isFirstClassType())
4003 ThrowException("Can't load from pointer of non-first-class type: " +
4004 (*yyvsp[-1].TypeVal)->getDescription());
4005 yyval.InstVal = new LoadInst(getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), "", yyvsp[-3].BoolVal);
4006 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00004007 ;
4008 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00004009case 236:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00004010#line 2391 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00004011{
Reid Spencer68a24bd2005-08-27 18:50:39 +00004012 const PointerType *PT = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
4013 if (!PT)
4014 ThrowException("Can't store to a nonpointer type: " +
4015 (*yyvsp[-1].TypeVal)->getDescription());
4016 const Type *ElTy = PT->getElementType();
4017 if (ElTy != yyvsp[-3].ValueVal->getType())
4018 ThrowException("Can't store '" + yyvsp[-3].ValueVal->getType()->getDescription() +
4019 "' into space of type '" + ElTy->getDescription() + "'!");
4020
4021 yyval.InstVal = new StoreInst(yyvsp[-3].ValueVal, getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), yyvsp[-5].BoolVal);
4022 delete yyvsp[-1].TypeVal;
Chris Lattner8335e842006-01-23 23:05:42 +00004023 ;
4024 break;}
Chris Lattnerd25db202006-04-08 03:55:17 +00004025case 237:
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00004026#line 2404 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Chris Lattner8335e842006-01-23 23:05:42 +00004027{
Reid Spencer68a24bd2005-08-27 18:50:39 +00004028 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
4029 ThrowException("getelementptr insn requires pointer operand!");
4030
4031 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
4032 // indices to uint struct indices for compatibility.
4033 generic_gep_type_iterator<std::vector<Value*>::iterator>
4034 GTI = gep_type_begin(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end()),
4035 GTE = gep_type_end(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end());
4036 for (unsigned i = 0, e = yyvsp[0].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
4037 if (isa<StructType>(*GTI)) // Only change struct indices
4038 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[0].ValueList)[i]))
4039 if (CUI->getType() == Type::UByteTy)
4040 (*yyvsp[0].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
4041
4042 if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, *yyvsp[0].ValueList, true))
4043 ThrowException("Invalid getelementptr indices for type '" +
4044 (*yyvsp[-2].TypeVal)->getDescription()+ "'!");
4045 yyval.InstVal = new GetElementPtrInst(getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal), *yyvsp[0].ValueList);
4046 delete yyvsp[-2].TypeVal; delete yyvsp[0].ValueList;
Chris Lattner8335e842006-01-23 23:05:42 +00004047 ;
4048 break;}
4049}
4050 /* the action file gets copied in in place of this dollarsign */
4051#line 543 "/usr/share/bison.simple"
Reid Spencer68a24bd2005-08-27 18:50:39 +00004052
4053 yyvsp -= yylen;
4054 yyssp -= yylen;
Chris Lattner8335e842006-01-23 23:05:42 +00004055#ifdef YYLSP_NEEDED
4056 yylsp -= yylen;
4057#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00004058
Chris Lattner8335e842006-01-23 23:05:42 +00004059#if YYDEBUG != 0
4060 if (yydebug)
4061 {
4062 short *ssp1 = yyss - 1;
4063 fprintf (stderr, "state stack now");
4064 while (ssp1 != yyssp)
4065 fprintf (stderr, " %d", *++ssp1);
4066 fprintf (stderr, "\n");
4067 }
4068#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00004069
4070 *++yyvsp = yyval;
4071
Chris Lattner8335e842006-01-23 23:05:42 +00004072#ifdef YYLSP_NEEDED
4073 yylsp++;
4074 if (yylen == 0)
4075 {
4076 yylsp->first_line = yylloc.first_line;
4077 yylsp->first_column = yylloc.first_column;
4078 yylsp->last_line = (yylsp-1)->last_line;
4079 yylsp->last_column = (yylsp-1)->last_column;
4080 yylsp->text = 0;
4081 }
4082 else
4083 {
4084 yylsp->last_line = (yylsp+yylen-1)->last_line;
4085 yylsp->last_column = (yylsp+yylen-1)->last_column;
4086 }
4087#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00004088
Chris Lattner8335e842006-01-23 23:05:42 +00004089 /* Now "shift" the result of the reduction.
4090 Determine what state that goes to,
4091 based on the state we popped back to
4092 and the rule number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004093
4094 yyn = yyr1[yyn];
4095
Chris Lattner8335e842006-01-23 23:05:42 +00004096 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
4097 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004098 yystate = yytable[yystate];
4099 else
Chris Lattner8335e842006-01-23 23:05:42 +00004100 yystate = yydefgoto[yyn - YYNTBASE];
Reid Spencer68a24bd2005-08-27 18:50:39 +00004101
4102 goto yynewstate;
4103
Chris Lattner8335e842006-01-23 23:05:42 +00004104yyerrlab: /* here on detecting error */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004105
Chris Lattner8335e842006-01-23 23:05:42 +00004106 if (! yyerrstatus)
4107 /* If not already recovering from an error, report this error. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004108 {
4109 ++yynerrs;
Chris Lattner8335e842006-01-23 23:05:42 +00004110
4111#ifdef YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00004112 yyn = yypact[yystate];
4113
Chris Lattner8335e842006-01-23 23:05:42 +00004114 if (yyn > YYFLAG && yyn < YYLAST)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004115 {
Chris Lattner8335e842006-01-23 23:05:42 +00004116 int size = 0;
4117 char *msg;
4118 int x, count;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004119
Chris Lattner8335e842006-01-23 23:05:42 +00004120 count = 0;
4121 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
4122 for (x = (yyn < 0 ? -yyn : 0);
4123 x < (sizeof(yytname) / sizeof(char *)); x++)
4124 if (yycheck[x + yyn] == x)
4125 size += strlen(yytname[x]) + 15, count++;
4126 msg = (char *) malloc(size + 15);
4127 if (msg != 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004128 {
Chris Lattner8335e842006-01-23 23:05:42 +00004129 strcpy(msg, "parse error");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004130
Chris Lattner8335e842006-01-23 23:05:42 +00004131 if (count < 5)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004132 {
Chris Lattner8335e842006-01-23 23:05:42 +00004133 count = 0;
4134 for (x = (yyn < 0 ? -yyn : 0);
4135 x < (sizeof(yytname) / sizeof(char *)); x++)
4136 if (yycheck[x + yyn] == x)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004137 {
Chris Lattner8335e842006-01-23 23:05:42 +00004138 strcat(msg, count == 0 ? ", expecting `" : " or `");
4139 strcat(msg, yytname[x]);
4140 strcat(msg, "'");
4141 count++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004142 }
4143 }
Chris Lattner8335e842006-01-23 23:05:42 +00004144 yyerror(msg);
4145 free(msg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004146 }
4147 else
Chris Lattner8335e842006-01-23 23:05:42 +00004148 yyerror ("parse error; also virtual memory exceeded");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004149 }
4150 else
4151#endif /* YYERROR_VERBOSE */
Chris Lattner8335e842006-01-23 23:05:42 +00004152 yyerror("parse error");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004153 }
4154
Chris Lattner8335e842006-01-23 23:05:42 +00004155 goto yyerrlab1;
4156yyerrlab1: /* here on error raised explicitly by an action */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004157
4158 if (yyerrstatus == 3)
4159 {
Chris Lattner8335e842006-01-23 23:05:42 +00004160 /* if just tried and failed to reuse lookahead token after an error, discard it. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004161
Chris Lattner8335e842006-01-23 23:05:42 +00004162 /* return failure if at end of input */
4163 if (yychar == YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004164 YYABORT;
4165
Chris Lattner8335e842006-01-23 23:05:42 +00004166#if YYDEBUG != 0
4167 if (yydebug)
4168 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
4169#endif
4170
4171 yychar = YYEMPTY;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004172 }
4173
Chris Lattner8335e842006-01-23 23:05:42 +00004174 /* Else will try to reuse lookahead token
4175 after shifting the error token. */
4176
4177 yyerrstatus = 3; /* Each real token shifted decrements this */
4178
4179 goto yyerrhandle;
4180
4181yyerrdefault: /* current state does not do anything special for the error token. */
4182
4183#if 0
4184 /* This is wrong; only states that explicitly want error tokens
4185 should shift them. */
4186 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
4187 if (yyn) goto yydefault;
4188#endif
4189
4190yyerrpop: /* pop the current state because it cannot handle the error token */
4191
4192 if (yyssp == yyss) YYABORT;
4193 yyvsp--;
4194 yystate = *--yyssp;
4195#ifdef YYLSP_NEEDED
4196 yylsp--;
4197#endif
4198
4199#if YYDEBUG != 0
4200 if (yydebug)
4201 {
4202 short *ssp1 = yyss - 1;
4203 fprintf (stderr, "Error: state stack now");
4204 while (ssp1 != yyssp)
4205 fprintf (stderr, " %d", *++ssp1);
4206 fprintf (stderr, "\n");
4207 }
4208#endif
4209
4210yyerrhandle:
4211
4212 yyn = yypact[yystate];
4213 if (yyn == YYFLAG)
4214 goto yyerrdefault;
4215
4216 yyn += YYTERROR;
4217 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
4218 goto yyerrdefault;
4219
4220 yyn = yytable[yyn];
4221 if (yyn < 0)
4222 {
4223 if (yyn == YYFLAG)
4224 goto yyerrpop;
4225 yyn = -yyn;
4226 goto yyreduce;
4227 }
4228 else if (yyn == 0)
4229 goto yyerrpop;
4230
Reid Spencer68a24bd2005-08-27 18:50:39 +00004231 if (yyn == YYFINAL)
4232 YYACCEPT;
4233
Chris Lattner8335e842006-01-23 23:05:42 +00004234#if YYDEBUG != 0
4235 if (yydebug)
4236 fprintf(stderr, "Shifting error token, ");
4237#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00004238
4239 *++yyvsp = yylval;
Chris Lattner8335e842006-01-23 23:05:42 +00004240#ifdef YYLSP_NEEDED
4241 *++yylsp = yylloc;
4242#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00004243
4244 yystate = yyn;
4245 goto yynewstate;
4246
Chris Lattner8335e842006-01-23 23:05:42 +00004247 yyacceptlab:
4248 /* YYACCEPT comes here. */
4249 if (yyfree_stacks)
4250 {
4251 free (yyss);
4252 free (yyvs);
4253#ifdef YYLSP_NEEDED
4254 free (yyls);
Reid Spencer0b118202006-01-16 21:12:35 +00004255#endif
Chris Lattner8335e842006-01-23 23:05:42 +00004256 }
4257 return 0;
Reid Spencere812fb22006-01-19 01:21:04 +00004258
Chris Lattner8335e842006-01-23 23:05:42 +00004259 yyabortlab:
4260 /* YYABORT comes here. */
4261 if (yyfree_stacks)
4262 {
4263 free (yyss);
4264 free (yyvs);
4265#ifdef YYLSP_NEEDED
4266 free (yyls);
Reid Spencere812fb22006-01-19 01:21:04 +00004267#endif
Chris Lattner8335e842006-01-23 23:05:42 +00004268 }
4269 return 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004270}
Chris Lattnerf4bd7d82006-04-08 04:09:02 +00004271#line 2427 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00004272
4273int yyerror(const char *ErrorMsg) {
4274 std::string where
4275 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
4276 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
4277 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
4278 if (yychar == YYEMPTY || yychar == 0)
4279 errMsg += "end-of-file.";
4280 else
4281 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
4282 ThrowException(errMsg);
4283 return 0;
4284}