blob: 9eee49dfb5d47aa0aba5830df9176795cd76482e [file] [log] [blame]
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001
Chris Lattneredd9b032006-01-23 23:05:42 +00002/* A Bison parser, made from /Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y
3 by GNU Bison version 1.28 */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004
Chris Lattneredd9b032006-01-23 23:05:42 +00005#define YYBISON 1 /* Identify Bison output. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00006
Reid Spencerdfb3fb42005-08-27 18:50:39 +00007#define yyparse llvmAsmparse
Chris Lattneredd9b032006-01-23 23:05:42 +00008#define yylex llvmAsmlex
Reid Spencerdfb3fb42005-08-27 18:50:39 +00009#define yyerror llvmAsmerror
Chris Lattneredd9b032006-01-23 23:05:42 +000010#define yylval llvmAsmlval
11#define yychar llvmAsmchar
Reid Spencerdfb3fb42005-08-27 18:50:39 +000012#define yydebug llvmAsmdebug
13#define yynerrs llvmAsmnerrs
Chris Lattneredd9b032006-01-23 23:05:42 +000014#define ESINT64VAL 257
15#define EUINT64VAL 258
16#define SINTVAL 259
17#define UINTVAL 260
18#define FPVAL 261
19#define VOID 262
20#define BOOL 263
21#define SBYTE 264
22#define UBYTE 265
23#define SHORT 266
24#define USHORT 267
25#define INT 268
26#define UINT 269
27#define LONG 270
28#define ULONG 271
29#define FLOAT 272
30#define DOUBLE 273
31#define TYPE 274
32#define LABEL 275
33#define VAR_ID 276
34#define LABELSTR 277
35#define STRINGCONSTANT 278
36#define IMPLEMENTATION 279
37#define ZEROINITIALIZER 280
38#define TRUETOK 281
39#define FALSETOK 282
40#define BEGINTOK 283
41#define ENDTOK 284
42#define DECLARE 285
43#define GLOBAL 286
44#define CONSTANT 287
45#define SECTION 288
46#define VOLATILE 289
47#define TO 290
48#define DOTDOTDOT 291
49#define NULL_TOK 292
50#define UNDEF 293
51#define CONST 294
52#define INTERNAL 295
53#define LINKONCE 296
54#define WEAK 297
55#define APPENDING 298
56#define OPAQUE 299
57#define NOT 300
58#define EXTERNAL 301
59#define TARGET 302
60#define TRIPLE 303
61#define ENDIAN 304
62#define POINTERSIZE 305
63#define LITTLE 306
64#define BIG 307
65#define ALIGN 308
66#define DEPLIBS 309
67#define CALL 310
68#define TAIL 311
69#define ASM_TOK 312
70#define CC_TOK 313
71#define CCC_TOK 314
72#define FASTCC_TOK 315
73#define COLDCC_TOK 316
74#define RET 317
75#define BR 318
76#define SWITCH 319
77#define INVOKE 320
78#define UNWIND 321
79#define UNREACHABLE 322
80#define ADD 323
81#define SUB 324
82#define MUL 325
83#define DIV 326
84#define REM 327
85#define AND 328
86#define OR 329
87#define XOR 330
88#define SETLE 331
89#define SETGE 332
90#define SETLT 333
91#define SETGT 334
92#define SETEQ 335
93#define SETNE 336
94#define MALLOC 337
95#define ALLOCA 338
96#define FREE 339
97#define LOAD 340
98#define STORE 341
99#define GETELEMENTPTR 342
100#define PHI_TOK 343
101#define CAST 344
102#define SELECT 345
103#define SHL 346
104#define SHR 347
105#define VAARG 348
106#define EXTRACTELEMENT 349
107#define INSERTELEMENT 350
108#define VAARG_old 351
109#define VANEXT_old 352
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000110
Chris Lattneredd9b032006-01-23 23:05:42 +0000111#line 14 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000112
113#include "ParserInternals.h"
114#include "llvm/CallingConv.h"
115#include "llvm/Instructions.h"
116#include "llvm/Module.h"
117#include "llvm/SymbolTable.h"
Reid Spencerb4f9a6f2006-01-16 21:12:35 +0000118#include "llvm/Assembly/AutoUpgrade.h"
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000119#include "llvm/Support/GetElementPtrTypeIterator.h"
120#include "llvm/ADT/STLExtras.h"
Chris Lattner840f7892005-11-06 06:46:53 +0000121#include "llvm/Support/MathExtras.h"
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000122#include <algorithm>
123#include <iostream>
124#include <list>
125#include <utility>
126
127int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
128int yylex(); // declaration" of xxx warnings.
129int yyparse();
130
131namespace llvm {
132 std::string CurFilename;
133}
134using namespace llvm;
135
136static Module *ParserResult;
137
138// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
139// relating to upreferences in the input stream.
140//
141//#define DEBUG_UPREFS 1
142#ifdef DEBUG_UPREFS
143#define UR_OUT(X) std::cerr << X
144#else
145#define UR_OUT(X)
146#endif
147
148#define YYERROR_VERBOSE 1
149
150static bool ObsoleteVarArgs;
151static bool NewVarArgs;
Chris Lattner11ca4d62005-11-12 18:22:38 +0000152static BasicBlock *CurBB;
153static GlobalVariable *CurGV;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000154
155
156// This contains info used when building the body of a function. It is
157// destroyed when the function is completed.
158//
159typedef std::vector<Value *> ValueList; // Numbered defs
160static void
161ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
162 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
163
164static struct PerModuleInfo {
165 Module *CurrentModule;
166 std::map<const Type *, ValueList> Values; // Module level numbered definitions
167 std::map<const Type *,ValueList> LateResolveValues;
168 std::vector<PATypeHolder> Types;
169 std::map<ValID, PATypeHolder> LateResolveTypes;
170
171 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
172 /// how they were referenced and one which line of the input they came from so
173 /// that we can resolve them later and print error messages as appropriate.
174 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
175
176 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
177 // references to global values. Global values may be referenced before they
178 // are defined, and if so, the temporary object that they represent is held
179 // here. This is used for forward references of GlobalValues.
180 //
181 typedef std::map<std::pair<const PointerType *,
182 ValID>, GlobalValue*> GlobalRefsType;
183 GlobalRefsType GlobalRefs;
184
185 void ModuleDone() {
186 // If we could not resolve some functions at function compilation time
187 // (calls to functions before they are defined), resolve them now... Types
188 // are resolved when the constant pool has been completely parsed.
189 //
190 ResolveDefinitions(LateResolveValues);
191
192 // Check to make sure that all global value forward references have been
193 // resolved!
194 //
195 if (!GlobalRefs.empty()) {
196 std::string UndefinedReferences = "Unresolved global references exist:\n";
197
198 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
199 I != E; ++I) {
200 UndefinedReferences += " " + I->first.first->getDescription() + " " +
201 I->first.second.getName() + "\n";
202 }
203 ThrowException(UndefinedReferences);
204 }
205
Reid Spencerc8a9faf2006-01-19 01:21:04 +0000206 // Look for intrinsic functions and CallInst that need to be upgraded
207 for (Module::iterator FI = CurrentModule->begin(),FE = CurrentModule->end();
208 FI != FE; ++FI)
209 UpgradeCallsToIntrinsic(FI);
Reid Spencerb4f9a6f2006-01-16 21:12:35 +0000210
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000211 Values.clear(); // Clear out function local definitions
212 Types.clear();
213 CurrentModule = 0;
214 }
215
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000216 // GetForwardRefForGlobal - Check to see if there is a forward reference
217 // for this global. If so, remove it from the GlobalRefs map and return it.
218 // If not, just return null.
219 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
220 // Check to see if there is a forward reference to this global variable...
221 // if there is, eliminate it and patch the reference to use the new def'n.
222 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
223 GlobalValue *Ret = 0;
224 if (I != GlobalRefs.end()) {
225 Ret = I->second;
226 GlobalRefs.erase(I);
227 }
228 return Ret;
229 }
230} CurModule;
231
232static struct PerFunctionInfo {
233 Function *CurrentFunction; // Pointer to current function being created
234
235 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
236 std::map<const Type*, ValueList> LateResolveValues;
237 bool isDeclare; // Is this function a forward declararation?
238
239 /// BBForwardRefs - When we see forward references to basic blocks, keep
240 /// track of them here.
241 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
242 std::vector<BasicBlock*> NumberedBlocks;
243 unsigned NextBBNum;
244
245 inline PerFunctionInfo() {
246 CurrentFunction = 0;
247 isDeclare = false;
248 }
249
250 inline void FunctionStart(Function *M) {
251 CurrentFunction = M;
252 NextBBNum = 0;
253 }
254
255 void FunctionDone() {
256 NumberedBlocks.clear();
257
258 // Any forward referenced blocks left?
259 if (!BBForwardRefs.empty())
260 ThrowException("Undefined reference to label " +
261 BBForwardRefs.begin()->first->getName());
262
263 // Resolve all forward references now.
264 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
265
266 Values.clear(); // Clear out function local definitions
267 CurrentFunction = 0;
268 isDeclare = false;
269 }
270} CurFun; // Info for the current function...
271
272static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
273
274
275//===----------------------------------------------------------------------===//
276// Code to handle definitions of all the types
277//===----------------------------------------------------------------------===//
278
279static int InsertValue(Value *V,
280 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
281 if (V->hasName()) return -1; // Is this a numbered definition?
282
283 // Yes, insert the value into the value table...
284 ValueList &List = ValueTab[V->getType()];
285 List.push_back(V);
286 return List.size()-1;
287}
288
289static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
290 switch (D.Type) {
291 case ValID::NumberVal: // Is it a numbered definition?
292 // Module constants occupy the lowest numbered slots...
293 if ((unsigned)D.Num < CurModule.Types.size())
294 return CurModule.Types[(unsigned)D.Num];
295 break;
296 case ValID::NameVal: // Is it a named definition?
297 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
298 D.destroy(); // Free old strdup'd memory...
299 return N;
300 }
301 break;
302 default:
303 ThrowException("Internal parser error: Invalid symbol type reference!");
304 }
305
306 // If we reached here, we referenced either a symbol that we don't know about
307 // or an id number that hasn't been read yet. We may be referencing something
308 // forward, so just create an entry to be resolved later and get to it...
309 //
310 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
311
312
313 if (inFunctionScope()) {
314 if (D.Type == ValID::NameVal)
315 ThrowException("Reference to an undefined type: '" + D.getName() + "'");
316 else
317 ThrowException("Reference to an undefined type: #" + itostr(D.Num));
318 }
319
320 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
321 if (I != CurModule.LateResolveTypes.end())
322 return I->second;
323
324 Type *Typ = OpaqueType::get();
325 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
326 return Typ;
327 }
328
329static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
330 SymbolTable &SymTab =
331 inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() :
332 CurModule.CurrentModule->getSymbolTable();
333 return SymTab.lookup(Ty, Name);
334}
335
336// getValNonImprovising - Look up the value specified by the provided type and
337// the provided ValID. If the value exists and has already been defined, return
338// it. Otherwise return null.
339//
340static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
341 if (isa<FunctionType>(Ty))
342 ThrowException("Functions are not values and "
343 "must be referenced as pointers");
344
345 switch (D.Type) {
346 case ValID::NumberVal: { // Is it a numbered definition?
347 unsigned Num = (unsigned)D.Num;
348
349 // Module constants occupy the lowest numbered slots...
350 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
351 if (VI != CurModule.Values.end()) {
352 if (Num < VI->second.size())
353 return VI->second[Num];
354 Num -= VI->second.size();
355 }
356
357 // Make sure that our type is within bounds
358 VI = CurFun.Values.find(Ty);
359 if (VI == CurFun.Values.end()) return 0;
360
361 // Check that the number is within bounds...
362 if (VI->second.size() <= Num) return 0;
363
364 return VI->second[Num];
365 }
366
367 case ValID::NameVal: { // Is it a named definition?
368 Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
369 if (N == 0) return 0;
370
371 D.destroy(); // Free old strdup'd memory...
372 return N;
373 }
374
375 // Check to make sure that "Ty" is an integral type, and that our
376 // value will fit into the specified type...
377 case ValID::ConstSIntVal: // Is it a constant pool reference??
378 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64))
379 ThrowException("Signed integral constant '" +
380 itostr(D.ConstPool64) + "' is invalid for type '" +
381 Ty->getDescription() + "'!");
382 return ConstantSInt::get(Ty, D.ConstPool64);
383
384 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
385 if (!ConstantUInt::isValueValidForType(Ty, D.UConstPool64)) {
386 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) {
387 ThrowException("Integral constant '" + utostr(D.UConstPool64) +
388 "' is invalid or out of range!");
389 } else { // This is really a signed reference. Transmogrify.
390 return ConstantSInt::get(Ty, D.ConstPool64);
391 }
392 } else {
393 return ConstantUInt::get(Ty, D.UConstPool64);
394 }
395
396 case ValID::ConstFPVal: // Is it a floating point const pool reference?
397 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
398 ThrowException("FP constant invalid for type!!");
399 return ConstantFP::get(Ty, D.ConstPoolFP);
400
401 case ValID::ConstNullVal: // Is it a null value?
402 if (!isa<PointerType>(Ty))
403 ThrowException("Cannot create a a non pointer null!");
404 return ConstantPointerNull::get(cast<PointerType>(Ty));
405
406 case ValID::ConstUndefVal: // Is it an undef value?
407 return UndefValue::get(Ty);
408
Chris Lattnera054d122005-12-21 17:53:23 +0000409 case ValID::ConstZeroVal: // Is it a zero value?
410 return Constant::getNullValue(Ty);
411
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000412 case ValID::ConstantVal: // Fully resolved constant?
413 if (D.ConstantValue->getType() != Ty)
414 ThrowException("Constant expression type different from required type!");
415 return D.ConstantValue;
416
417 default:
418 assert(0 && "Unhandled case!");
419 return 0;
420 } // End of switch
421
422 assert(0 && "Unhandled case!");
423 return 0;
424}
425
426// getVal - This function is identical to getValNonImprovising, except that if a
427// value is not already defined, it "improvises" by creating a placeholder var
428// that looks and acts just like the requested variable. When the value is
429// defined later, all uses of the placeholder variable are replaced with the
430// real thing.
431//
432static Value *getVal(const Type *Ty, const ValID &ID) {
433 if (Ty == Type::LabelTy)
434 ThrowException("Cannot use a basic block here");
435
436 // See if the value has already been defined.
437 Value *V = getValNonImprovising(Ty, ID);
438 if (V) return V;
439
440 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
441 ThrowException("Invalid use of a composite type!");
442
443 // If we reached here, we referenced either a symbol that we don't know about
444 // or an id number that hasn't been read yet. We may be referencing something
445 // forward, so just create an entry to be resolved later and get to it...
446 //
447 V = new Argument(Ty);
448
449 // Remember where this forward reference came from. FIXME, shouldn't we try
450 // to recycle these things??
451 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
452 llvmAsmlineno)));
453
454 if (inFunctionScope())
455 InsertValue(V, CurFun.LateResolveValues);
456 else
457 InsertValue(V, CurModule.LateResolveValues);
458 return V;
459}
460
461/// getBBVal - This is used for two purposes:
462/// * If isDefinition is true, a new basic block with the specified ID is being
463/// defined.
464/// * If isDefinition is true, this is a reference to a basic block, which may
465/// or may not be a forward reference.
466///
467static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
468 assert(inFunctionScope() && "Can't get basic block at global scope!");
469
470 std::string Name;
471 BasicBlock *BB = 0;
472 switch (ID.Type) {
473 default: ThrowException("Illegal label reference " + ID.getName());
474 case ValID::NumberVal: // Is it a numbered definition?
475 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
476 CurFun.NumberedBlocks.resize(ID.Num+1);
477 BB = CurFun.NumberedBlocks[ID.Num];
478 break;
479 case ValID::NameVal: // Is it a named definition?
480 Name = ID.Name;
481 if (Value *N = CurFun.CurrentFunction->
482 getSymbolTable().lookup(Type::LabelTy, Name))
483 BB = cast<BasicBlock>(N);
484 break;
485 }
486
487 // See if the block has already been defined.
488 if (BB) {
489 // If this is the definition of the block, make sure the existing value was
490 // just a forward reference. If it was a forward reference, there will be
491 // an entry for it in the PlaceHolderInfo map.
492 if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
493 // The existing value was a definition, not a forward reference.
494 ThrowException("Redefinition of label " + ID.getName());
495
496 ID.destroy(); // Free strdup'd memory.
497 return BB;
498 }
499
500 // Otherwise this block has not been seen before.
501 BB = new BasicBlock("", CurFun.CurrentFunction);
502 if (ID.Type == ValID::NameVal) {
503 BB->setName(ID.Name);
504 } else {
505 CurFun.NumberedBlocks[ID.Num] = BB;
506 }
507
508 // If this is not a definition, keep track of it so we can use it as a forward
509 // reference.
510 if (!isDefinition) {
511 // Remember where this forward reference came from.
512 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
513 } else {
514 // The forward declaration could have been inserted anywhere in the
515 // function: insert it into the correct place now.
516 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
517 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
518 }
519 ID.destroy();
520 return BB;
521}
522
523
524//===----------------------------------------------------------------------===//
525// Code to handle forward references in instructions
526//===----------------------------------------------------------------------===//
527//
528// This code handles the late binding needed with statements that reference
529// values not defined yet... for example, a forward branch, or the PHI node for
530// a loop body.
531//
532// This keeps a table (CurFun.LateResolveValues) of all such forward references
533// and back patchs after we are done.
534//
535
536// ResolveDefinitions - If we could not resolve some defs at parsing
537// time (forward branches, phi functions for loops, etc...) resolve the
538// defs now...
539//
540static void
541ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
542 std::map<const Type*,ValueList> *FutureLateResolvers) {
543 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
544 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
545 E = LateResolvers.end(); LRI != E; ++LRI) {
546 ValueList &List = LRI->second;
547 while (!List.empty()) {
548 Value *V = List.back();
549 List.pop_back();
550
551 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
552 CurModule.PlaceHolderInfo.find(V);
553 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
554
555 ValID &DID = PHI->second.first;
556
557 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
558 if (TheRealValue) {
559 V->replaceAllUsesWith(TheRealValue);
560 delete V;
561 CurModule.PlaceHolderInfo.erase(PHI);
562 } else if (FutureLateResolvers) {
563 // Functions have their unresolved items forwarded to the module late
564 // resolver table
565 InsertValue(V, *FutureLateResolvers);
566 } else {
567 if (DID.Type == ValID::NameVal)
568 ThrowException("Reference to an invalid definition: '" +DID.getName()+
569 "' of type '" + V->getType()->getDescription() + "'",
570 PHI->second.second);
571 else
572 ThrowException("Reference to an invalid definition: #" +
573 itostr(DID.Num) + " of type '" +
574 V->getType()->getDescription() + "'",
575 PHI->second.second);
576 }
577 }
578 }
579
580 LateResolvers.clear();
581}
582
583// ResolveTypeTo - A brand new type was just declared. This means that (if
584// name is not null) things referencing Name can be resolved. Otherwise, things
585// refering to the number can be resolved. Do this now.
586//
587static void ResolveTypeTo(char *Name, const Type *ToTy) {
588 ValID D;
589 if (Name) D = ValID::create(Name);
590 else D = ValID::create((int)CurModule.Types.size());
591
592 std::map<ValID, PATypeHolder>::iterator I =
593 CurModule.LateResolveTypes.find(D);
594 if (I != CurModule.LateResolveTypes.end()) {
595 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
596 CurModule.LateResolveTypes.erase(I);
597 }
598}
599
600// setValueName - Set the specified value to the name given. The name may be
601// null potentially, in which case this is a noop. The string passed in is
602// assumed to be a malloc'd string buffer, and is free'd by this function.
603//
604static void setValueName(Value *V, char *NameStr) {
605 if (NameStr) {
606 std::string Name(NameStr); // Copy string
607 free(NameStr); // Free old string
608
609 if (V->getType() == Type::VoidTy)
610 ThrowException("Can't assign name '" + Name+"' to value with void type!");
611
612 assert(inFunctionScope() && "Must be in function scope!");
613 SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable();
614 if (ST.lookup(V->getType(), Name))
615 ThrowException("Redefinition of value named '" + Name + "' in the '" +
616 V->getType()->getDescription() + "' type plane!");
617
618 // Set the name.
619 V->setName(Name);
620 }
621}
622
623/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
624/// this is a declaration, otherwise it is a definition.
Chris Lattner11ca4d62005-11-12 18:22:38 +0000625static GlobalVariable *
626ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
627 bool isConstantGlobal, const Type *Ty,
628 Constant *Initializer) {
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000629 if (isa<FunctionType>(Ty))
630 ThrowException("Cannot declare global vars of function type!");
631
632 const PointerType *PTy = PointerType::get(Ty);
633
634 std::string Name;
635 if (NameStr) {
636 Name = NameStr; // Copy string
637 free(NameStr); // Free old string
638 }
639
640 // See if this global value was forward referenced. If so, recycle the
641 // object.
642 ValID ID;
643 if (!Name.empty()) {
644 ID = ValID::create((char*)Name.c_str());
645 } else {
646 ID = ValID::create((int)CurModule.Values[PTy].size());
647 }
648
649 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
650 // Move the global to the end of the list, from whereever it was
651 // previously inserted.
652 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
653 CurModule.CurrentModule->getGlobalList().remove(GV);
654 CurModule.CurrentModule->getGlobalList().push_back(GV);
655 GV->setInitializer(Initializer);
656 GV->setLinkage(Linkage);
657 GV->setConstant(isConstantGlobal);
658 InsertValue(GV, CurModule.Values);
Chris Lattner11ca4d62005-11-12 18:22:38 +0000659 return GV;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000660 }
661
662 // If this global has a name, check to see if there is already a definition
663 // of this global in the module. If so, merge as appropriate. Note that
664 // this is really just a hack around problems in the CFE. :(
665 if (!Name.empty()) {
666 // We are a simple redefinition of a value, check to see if it is defined
667 // the same as the old one.
668 if (GlobalVariable *EGV =
669 CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
670 // We are allowed to redefine a global variable in two circumstances:
671 // 1. If at least one of the globals is uninitialized or
672 // 2. If both initializers have the same value.
673 //
674 if (!EGV->hasInitializer() || !Initializer ||
675 EGV->getInitializer() == Initializer) {
676
677 // Make sure the existing global version gets the initializer! Make
678 // sure that it also gets marked const if the new version is.
679 if (Initializer && !EGV->hasInitializer())
680 EGV->setInitializer(Initializer);
681 if (isConstantGlobal)
682 EGV->setConstant(true);
683 EGV->setLinkage(Linkage);
Chris Lattner11ca4d62005-11-12 18:22:38 +0000684 return EGV;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000685 }
686
687 ThrowException("Redefinition of global variable named '" + Name +
688 "' in the '" + Ty->getDescription() + "' type plane!");
689 }
690 }
691
692 // Otherwise there is no existing GV to use, create one now.
693 GlobalVariable *GV =
694 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
695 CurModule.CurrentModule);
696 InsertValue(GV, CurModule.Values);
Chris Lattner11ca4d62005-11-12 18:22:38 +0000697 return GV;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000698}
699
700// setTypeName - Set the specified type to the name given. The name may be
701// null potentially, in which case this is a noop. The string passed in is
702// assumed to be a malloc'd string buffer, and is freed by this function.
703//
704// This function returns true if the type has already been defined, but is
705// allowed to be redefined in the specified context. If the name is a new name
706// for the type plane, it is inserted and false is returned.
707static bool setTypeName(const Type *T, char *NameStr) {
708 assert(!inFunctionScope() && "Can't give types function-local names!");
709 if (NameStr == 0) return false;
710
711 std::string Name(NameStr); // Copy string
712 free(NameStr); // Free old string
713
714 // We don't allow assigning names to void type
715 if (T == Type::VoidTy)
716 ThrowException("Can't assign name '" + Name + "' to the void type!");
717
718 // Set the type name, checking for conflicts as we do so.
719 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
720
721 if (AlreadyExists) { // Inserting a name that is already defined???
722 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
723 assert(Existing && "Conflict but no matching type?");
724
725 // There is only one case where this is allowed: when we are refining an
726 // opaque type. In this case, Existing will be an opaque type.
727 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
728 // We ARE replacing an opaque type!
729 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
730 return true;
731 }
732
733 // Otherwise, this is an attempt to redefine a type. That's okay if
734 // the redefinition is identical to the original. This will be so if
735 // Existing and T point to the same Type object. In this one case we
736 // allow the equivalent redefinition.
737 if (Existing == T) return true; // Yes, it's equal.
738
739 // Any other kind of (non-equivalent) redefinition is an error.
740 ThrowException("Redefinition of type named '" + Name + "' in the '" +
741 T->getDescription() + "' type plane!");
742 }
743
744 return false;
745}
746
747//===----------------------------------------------------------------------===//
748// Code for handling upreferences in type names...
749//
750
751// TypeContains - Returns true if Ty directly contains E in it.
752//
753static bool TypeContains(const Type *Ty, const Type *E) {
754 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
755 E) != Ty->subtype_end();
756}
757
758namespace {
759 struct UpRefRecord {
760 // NestingLevel - The number of nesting levels that need to be popped before
761 // this type is resolved.
762 unsigned NestingLevel;
763
764 // LastContainedTy - This is the type at the current binding level for the
765 // type. Every time we reduce the nesting level, this gets updated.
766 const Type *LastContainedTy;
767
768 // UpRefTy - This is the actual opaque type that the upreference is
769 // represented with.
770 OpaqueType *UpRefTy;
771
772 UpRefRecord(unsigned NL, OpaqueType *URTy)
773 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
774 };
775}
776
777// UpRefs - A list of the outstanding upreferences that need to be resolved.
778static std::vector<UpRefRecord> UpRefs;
779
780/// HandleUpRefs - Every time we finish a new layer of types, this function is
781/// called. It loops through the UpRefs vector, which is a list of the
782/// currently active types. For each type, if the up reference is contained in
783/// the newly completed type, we decrement the level count. When the level
784/// count reaches zero, the upreferenced type is the type that is passed in:
785/// thus we can complete the cycle.
786///
787static PATypeHolder HandleUpRefs(const Type *ty) {
788 if (!ty->isAbstract()) return ty;
789 PATypeHolder Ty(ty);
790 UR_OUT("Type '" << Ty->getDescription() <<
791 "' newly formed. Resolving upreferences.\n" <<
792 UpRefs.size() << " upreferences active!\n");
793
794 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
795 // to zero), we resolve them all together before we resolve them to Ty. At
796 // the end of the loop, if there is anything to resolve to Ty, it will be in
797 // this variable.
798 OpaqueType *TypeToResolve = 0;
799
800 for (unsigned i = 0; i != UpRefs.size(); ++i) {
801 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
802 << UpRefs[i].second->getDescription() << ") = "
803 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
804 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
805 // Decrement level of upreference
806 unsigned Level = --UpRefs[i].NestingLevel;
807 UpRefs[i].LastContainedTy = Ty;
808 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
809 if (Level == 0) { // Upreference should be resolved!
810 if (!TypeToResolve) {
811 TypeToResolve = UpRefs[i].UpRefTy;
812 } else {
813 UR_OUT(" * Resolving upreference for "
814 << UpRefs[i].second->getDescription() << "\n";
815 std::string OldName = UpRefs[i].UpRefTy->getDescription());
816 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
817 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
818 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
819 }
820 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
821 --i; // Do not skip the next element...
822 }
823 }
824 }
825
826 if (TypeToResolve) {
827 UR_OUT(" * Resolving upreference for "
828 << UpRefs[i].second->getDescription() << "\n";
829 std::string OldName = TypeToResolve->getDescription());
830 TypeToResolve->refineAbstractTypeTo(Ty);
831 }
832
833 return Ty;
834}
835
836
837// common code from the two 'RunVMAsmParser' functions
838 static Module * RunParser(Module * M) {
839
840 llvmAsmlineno = 1; // Reset the current line number...
841 ObsoleteVarArgs = false;
842 NewVarArgs = false;
843
844 CurModule.CurrentModule = M;
845 yyparse(); // Parse the file, potentially throwing exception
846
847 Module *Result = ParserResult;
848 ParserResult = 0;
849
850 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
851 {
852 Function* F;
853 if ((F = Result->getNamedFunction("llvm.va_start"))
854 && F->getFunctionType()->getNumParams() == 0)
855 ObsoleteVarArgs = true;
856 if((F = Result->getNamedFunction("llvm.va_copy"))
857 && F->getFunctionType()->getNumParams() == 1)
858 ObsoleteVarArgs = true;
859 }
860
861 if (ObsoleteVarArgs && NewVarArgs)
862 ThrowException("This file is corrupt: it uses both new and old style varargs");
863
864 if(ObsoleteVarArgs) {
865 if(Function* F = Result->getNamedFunction("llvm.va_start")) {
866 if (F->arg_size() != 0)
867 ThrowException("Obsolete va_start takes 0 argument!");
868
869 //foo = va_start()
870 // ->
871 //bar = alloca typeof(foo)
872 //va_start(bar)
873 //foo = load bar
874
875 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
876 const Type* ArgTy = F->getFunctionType()->getReturnType();
877 const Type* ArgTyPtr = PointerType::get(ArgTy);
878 Function* NF = Result->getOrInsertFunction("llvm.va_start",
Jeff Cohen11e26b52005-10-23 04:37:20 +0000879 RetTy, ArgTyPtr, (Type *)0);
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000880
881 while (!F->use_empty()) {
882 CallInst* CI = cast<CallInst>(F->use_back());
883 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
884 new CallInst(NF, bar, "", CI);
885 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
886 CI->replaceAllUsesWith(foo);
887 CI->getParent()->getInstList().erase(CI);
888 }
889 Result->getFunctionList().erase(F);
890 }
891
892 if(Function* F = Result->getNamedFunction("llvm.va_end")) {
893 if(F->arg_size() != 1)
894 ThrowException("Obsolete va_end takes 1 argument!");
895
896 //vaend foo
897 // ->
898 //bar = alloca 1 of typeof(foo)
899 //vaend bar
900 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
901 const Type* ArgTy = F->getFunctionType()->getParamType(0);
902 const Type* ArgTyPtr = PointerType::get(ArgTy);
903 Function* NF = Result->getOrInsertFunction("llvm.va_end",
Jeff Cohen11e26b52005-10-23 04:37:20 +0000904 RetTy, ArgTyPtr, (Type *)0);
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000905
906 while (!F->use_empty()) {
907 CallInst* CI = cast<CallInst>(F->use_back());
908 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
909 new StoreInst(CI->getOperand(1), bar, CI);
910 new CallInst(NF, bar, "", CI);
911 CI->getParent()->getInstList().erase(CI);
912 }
913 Result->getFunctionList().erase(F);
914 }
915
916 if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
917 if(F->arg_size() != 1)
918 ThrowException("Obsolete va_copy takes 1 argument!");
919 //foo = vacopy(bar)
920 // ->
921 //a = alloca 1 of typeof(foo)
922 //b = alloca 1 of typeof(foo)
923 //store bar -> b
924 //vacopy(a, b)
925 //foo = load a
926
927 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
928 const Type* ArgTy = F->getFunctionType()->getReturnType();
929 const Type* ArgTyPtr = PointerType::get(ArgTy);
930 Function* NF = Result->getOrInsertFunction("llvm.va_copy",
Jeff Cohen11e26b52005-10-23 04:37:20 +0000931 RetTy, ArgTyPtr, ArgTyPtr,
932 (Type *)0);
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000933
934 while (!F->use_empty()) {
935 CallInst* CI = cast<CallInst>(F->use_back());
936 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
937 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
938 new StoreInst(CI->getOperand(1), b, CI);
939 new CallInst(NF, a, b, "", CI);
940 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
941 CI->replaceAllUsesWith(foo);
942 CI->getParent()->getInstList().erase(CI);
943 }
944 Result->getFunctionList().erase(F);
945 }
946 }
947
948 return Result;
949
950 }
951
952//===----------------------------------------------------------------------===//
953// RunVMAsmParser - Define an interface to this parser
954//===----------------------------------------------------------------------===//
955//
956Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
957 set_scan_file(F);
958
959 CurFilename = Filename;
960 return RunParser(new Module(CurFilename));
961}
962
963Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
964 set_scan_string(AsmString);
965
966 CurFilename = "from_memory";
967 if (M == NULL) {
968 return RunParser(new Module (CurFilename));
969 } else {
970 return RunParser(M);
971 }
972}
973
974
Chris Lattneredd9b032006-01-23 23:05:42 +0000975#line 878 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
976typedef union {
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000977 llvm::Module *ModuleVal;
978 llvm::Function *FunctionVal;
979 std::pair<llvm::PATypeHolder*, char*> *ArgVal;
980 llvm::BasicBlock *BasicBlockVal;
981 llvm::TerminatorInst *TermInstVal;
982 llvm::Instruction *InstVal;
983 llvm::Constant *ConstVal;
984
985 const llvm::Type *PrimType;
986 llvm::PATypeHolder *TypeVal;
987 llvm::Value *ValueVal;
988
989 std::vector<std::pair<llvm::PATypeHolder*,char*> > *ArgList;
990 std::vector<llvm::Value*> *ValueList;
991 std::list<llvm::PATypeHolder> *TypeList;
992 // Represent the RHS of PHI node
993 std::list<std::pair<llvm::Value*,
994 llvm::BasicBlock*> > *PHIList;
995 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
996 std::vector<llvm::Constant*> *ConstVector;
997
998 llvm::GlobalValue::LinkageTypes Linkage;
999 int64_t SInt64Val;
1000 uint64_t UInt64Val;
1001 int SIntVal;
1002 unsigned UIntVal;
1003 double FPVal;
1004 bool BoolVal;
1005
1006 char *StrVal; // This memory is strdup'd!
1007 llvm::ValID ValIDVal; // strdup'd memory maybe!
1008
1009 llvm::Instruction::BinaryOps BinaryOpVal;
1010 llvm::Instruction::TermOps TermOpVal;
1011 llvm::Instruction::MemoryOps MemOpVal;
1012 llvm::Instruction::OtherOps OtherOpVal;
1013 llvm::Module::Endianness Endianness;
1014} YYSTYPE;
Chris Lattneredd9b032006-01-23 23:05:42 +00001015#include <stdio.h>
1016
1017#ifndef __cplusplus
1018#ifndef __STDC__
1019#define const
1020#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001021#endif
1022
1023
1024
Chris Lattneredd9b032006-01-23 23:05:42 +00001025#define YYFINAL 465
1026#define YYFLAG -32768
1027#define YYNTBASE 113
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001028
Chris Lattneredd9b032006-01-23 23:05:42 +00001029#define YYTRANSLATE(x) ((unsigned)(x) <= 352 ? yytranslate[x] : 183)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001030
Chris Lattneredd9b032006-01-23 23:05:42 +00001031static const char yytranslate[] = { 0,
1032 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1033 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1034 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1035 2, 2, 2, 2, 2, 2, 2, 2, 2, 102,
1036 103, 111, 2, 100, 2, 2, 2, 2, 2, 2,
1037 2, 2, 2, 2, 2, 2, 2, 2, 2, 107,
1038 99, 108, 2, 2, 2, 2, 2, 2, 2, 2,
1039 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1040 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1041 104, 101, 106, 2, 2, 2, 2, 2, 112, 2,
1042 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1043 2, 2, 2, 2, 2, 2, 2, 2, 2, 105,
1044 2, 2, 109, 2, 110, 2, 2, 2, 2, 2,
1045 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1046 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1047 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1048 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1049 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1050 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1051 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1052 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1053 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1054 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1055 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1056 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1057 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
1058 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1059 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1060 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
1061 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
1062 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
1063 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1064 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1065 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1066 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
1067 97, 98
1068};
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001069
Chris Lattneredd9b032006-01-23 23:05:42 +00001070#if YYDEBUG != 0
1071static const short yyprhs[] = { 0,
1072 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
1073 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
1074 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
1075 60, 62, 64, 67, 68, 70, 72, 74, 76, 77,
1076 78, 80, 82, 84, 87, 88, 91, 92, 96, 99,
1077 100, 102, 103, 107, 109, 112, 114, 116, 118, 120,
1078 122, 124, 126, 128, 130, 132, 134, 136, 138, 140,
1079 142, 144, 146, 148, 150, 152, 154, 157, 162, 168,
1080 174, 178, 181, 184, 186, 190, 192, 196, 198, 199,
1081 204, 208, 212, 217, 222, 226, 229, 232, 235, 238,
1082 241, 244, 247, 250, 253, 256, 263, 269, 278, 285,
1083 292, 299, 306, 313, 317, 319, 321, 323, 325, 328,
1084 331, 335, 338, 340, 345, 348, 352, 353, 361, 362,
1085 370, 374, 379, 380, 382, 384, 386, 390, 394, 398,
1086 402, 406, 408, 409, 411, 413, 415, 416, 419, 423,
1087 425, 427, 431, 433, 434, 443, 445, 447, 451, 453,
1088 455, 458, 459, 463, 465, 467, 469, 471, 473, 475,
1089 477, 479, 483, 485, 487, 489, 491, 493, 496, 499,
1090 502, 506, 509, 510, 512, 515, 518, 522, 532, 542,
1091 551, 565, 567, 569, 576, 582, 585, 592, 600, 602,
1092 606, 608, 609, 612, 614, 620, 626, 632, 635, 640,
1093 645, 652, 657, 662, 667, 672, 679, 682, 690, 692,
1094 695, 696, 698, 699, 703, 710, 714, 721, 724, 729,
1095 736
1096};
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001097
Chris Lattneredd9b032006-01-23 23:05:42 +00001098static const short yyrhs[] = { 5,
1099 0, 6, 0, 3, 0, 4, 0, 69, 0, 70,
1100 0, 71, 0, 72, 0, 73, 0, 74, 0, 75,
1101 0, 76, 0, 77, 0, 78, 0, 79, 0, 80,
1102 0, 81, 0, 82, 0, 92, 0, 93, 0, 16,
1103 0, 14, 0, 12, 0, 10, 0, 17, 0, 15,
1104 0, 13, 0, 11, 0, 119, 0, 120, 0, 18,
1105 0, 19, 0, 153, 99, 0, 0, 41, 0, 42,
1106 0, 43, 0, 44, 0, 0, 0, 60, 0, 61,
1107 0, 62, 0, 59, 4, 0, 0, 54, 4, 0,
1108 0, 100, 54, 4, 0, 34, 24, 0, 0, 128,
1109 0, 0, 100, 131, 130, 0, 128, 0, 54, 4,
1110 0, 134, 0, 8, 0, 136, 0, 8, 0, 136,
1111 0, 9, 0, 10, 0, 11, 0, 12, 0, 13,
1112 0, 14, 0, 15, 0, 16, 0, 17, 0, 18,
1113 0, 19, 0, 20, 0, 21, 0, 45, 0, 135,
1114 0, 166, 0, 101, 4, 0, 133, 102, 138, 103,
1115 0, 104, 4, 105, 136, 106, 0, 107, 4, 105,
1116 136, 108, 0, 109, 137, 110, 0, 109, 110, 0,
1117 136, 111, 0, 136, 0, 137, 100, 136, 0, 137,
1118 0, 137, 100, 37, 0, 37, 0, 0, 134, 104,
1119 141, 106, 0, 134, 104, 106, 0, 134, 112, 24,
1120 0, 134, 107, 141, 108, 0, 134, 109, 141, 110,
1121 0, 134, 109, 110, 0, 134, 38, 0, 134, 39,
1122 0, 134, 166, 0, 134, 140, 0, 134, 26, 0,
1123 119, 114, 0, 120, 4, 0, 9, 27, 0, 9,
1124 28, 0, 122, 7, 0, 90, 102, 139, 36, 134,
1125 103, 0, 88, 102, 139, 180, 103, 0, 91, 102,
1126 139, 100, 139, 100, 139, 103, 0, 115, 102, 139,
1127 100, 139, 103, 0, 116, 102, 139, 100, 139, 103,
1128 0, 117, 102, 139, 100, 139, 103, 0, 118, 102,
1129 139, 100, 139, 103, 0, 95, 102, 139, 100, 139,
1130 103, 0, 141, 100, 139, 0, 139, 0, 32, 0,
1131 33, 0, 144, 0, 144, 162, 0, 144, 163, 0,
1132 144, 58, 148, 0, 144, 25, 0, 145, 0, 145,
1133 123, 20, 132, 0, 145, 163, 0, 145, 58, 148,
1134 0, 0, 145, 123, 124, 142, 139, 146, 130, 0,
1135 0, 145, 123, 47, 142, 134, 147, 130, 0, 145,
1136 48, 150, 0, 145, 55, 99, 151, 0, 0, 24,
1137 0, 53, 0, 52, 0, 50, 99, 149, 0, 51,
1138 99, 4, 0, 49, 99, 24, 0, 104, 152, 106,
1139 0, 152, 100, 24, 0, 24, 0, 0, 22, 0,
1140 24, 0, 153, 0, 0, 134, 154, 0, 156, 100,
1141 155, 0, 155, 0, 156, 0, 156, 100, 37, 0,
1142 37, 0, 0, 125, 132, 153, 102, 157, 103, 129,
1143 126, 0, 29, 0, 109, 0, 124, 158, 159, 0,
1144 30, 0, 110, 0, 169, 161, 0, 0, 31, 164,
1145 158, 0, 3, 0, 4, 0, 7, 0, 27, 0,
1146 28, 0, 38, 0, 39, 0, 26, 0, 107, 141,
1147 108, 0, 140, 0, 113, 0, 153, 0, 166, 0,
1148 165, 0, 134, 167, 0, 169, 170, 0, 160, 170,
1149 0, 171, 123, 172, 0, 171, 174, 0, 0, 23,
1150 0, 63, 168, 0, 63, 8, 0, 64, 21, 167,
1151 0, 64, 9, 167, 100, 21, 167, 100, 21, 167,
1152 0, 65, 121, 167, 100, 21, 167, 104, 173, 106,
1153 0, 65, 121, 167, 100, 21, 167, 104, 106, 0,
1154 66, 125, 132, 167, 102, 177, 103, 36, 21, 167,
1155 67, 21, 167, 0, 67, 0, 68, 0, 173, 121,
1156 165, 100, 21, 167, 0, 121, 165, 100, 21, 167,
1157 0, 123, 179, 0, 134, 104, 167, 100, 167, 106,
1158 0, 175, 100, 104, 167, 100, 167, 106, 0, 168,
1159 0, 176, 100, 168, 0, 176, 0, 0, 57, 56,
1160 0, 56, 0, 115, 134, 167, 100, 167, 0, 116,
1161 134, 167, 100, 167, 0, 117, 134, 167, 100, 167,
1162 0, 46, 168, 0, 118, 168, 100, 168, 0, 90,
1163 168, 36, 134, 0, 91, 168, 100, 168, 100, 168,
1164 0, 94, 168, 100, 134, 0, 97, 168, 100, 134,
1165 0, 98, 168, 100, 134, 0, 95, 168, 100, 168,
1166 0, 96, 168, 100, 168, 100, 168, 0, 89, 175,
1167 0, 178, 125, 132, 167, 102, 177, 103, 0, 182,
1168 0, 100, 176, 0, 0, 35, 0, 0, 83, 134,
1169 127, 0, 83, 134, 100, 15, 167, 127, 0, 84,
1170 134, 127, 0, 84, 134, 100, 15, 167, 127, 0,
1171 85, 168, 0, 181, 86, 134, 167, 0, 181, 87,
1172 168, 100, 134, 167, 0, 88, 134, 167, 180, 0
1173};
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001174
1175#endif
1176
Chris Lattneredd9b032006-01-23 23:05:42 +00001177#if YYDEBUG != 0
1178static const short yyrline[] = { 0,
1179 997, 998, 1005, 1006, 1015, 1015, 1015, 1015, 1015, 1016,
1180 1016, 1016, 1017, 1017, 1017, 1017, 1017, 1017, 1019, 1019,
1181 1023, 1023, 1023, 1023, 1024, 1024, 1024, 1024, 1025, 1025,
1182 1026, 1026, 1029, 1032, 1036, 1036, 1037, 1038, 1039, 1042,
1183 1042, 1043, 1044, 1045, 1054, 1054, 1060, 1060, 1068, 1075,
1184 1075, 1081, 1081, 1083, 1087, 1100, 1100, 1101, 1101, 1103,
1185 1112, 1112, 1112, 1112, 1112, 1112, 1112, 1113, 1113, 1113,
1186 1113, 1113, 1113, 1114, 1117, 1120, 1126, 1133, 1145, 1149,
1187 1160, 1169, 1172, 1180, 1184, 1189, 1190, 1193, 1196, 1206,
1188 1231, 1244, 1272, 1297, 1317, 1329, 1338, 1342, 1401, 1407,
1189 1415, 1420, 1425, 1428, 1431, 1438, 1448, 1479, 1486, 1507,
1190 1517, 1522, 1529, 1539, 1542, 1549, 1549, 1559, 1566, 1570,
1191 1573, 1576, 1579, 1592, 1612, 1614, 1616, 1619, 1622, 1626,
1192 1629, 1631, 1633, 1637, 1646, 1647, 1649, 1652, 1660, 1665,
1193 1667, 1671, 1675, 1683, 1683, 1684, 1684, 1686, 1692, 1697,
1194 1703, 1706, 1711, 1715, 1719, 1805, 1805, 1807, 1815, 1815,
1195 1817, 1821, 1821, 1830, 1833, 1836, 1839, 1842, 1845, 1848,
1196 1851, 1854, 1878, 1885, 1888, 1893, 1893, 1899, 1903, 1906,
1197 1914, 1923, 1927, 1937, 1948, 1951, 1954, 1957, 1960, 1974,
1198 1978, 2031, 2034, 2040, 2048, 2058, 2065, 2070, 2077, 2081,
1199 2087, 2087, 2089, 2092, 2098, 2110, 2121, 2131, 2143, 2150,
1200 2157, 2164, 2169, 2188, 2210, 2218, 2230, 2244, 2301, 2307,
1201 2309, 2313, 2316, 2322, 2326, 2330, 2334, 2338, 2345, 2355,
1202 2368
1203};
1204#endif
1205
1206
1207#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
1208
1209static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL",
1210"EUINT64VAL","SINTVAL","UINTVAL","FPVAL","VOID","BOOL","SBYTE","UBYTE","SHORT",
1211"USHORT","INT","UINT","LONG","ULONG","FLOAT","DOUBLE","TYPE","LABEL","VAR_ID",
1212"LABELSTR","STRINGCONSTANT","IMPLEMENTATION","ZEROINITIALIZER","TRUETOK","FALSETOK",
1213"BEGINTOK","ENDTOK","DECLARE","GLOBAL","CONSTANT","SECTION","VOLATILE","TO",
1214"DOTDOTDOT","NULL_TOK","UNDEF","CONST","INTERNAL","LINKONCE","WEAK","APPENDING",
1215"OPAQUE","NOT","EXTERNAL","TARGET","TRIPLE","ENDIAN","POINTERSIZE","LITTLE",
1216"BIG","ALIGN","DEPLIBS","CALL","TAIL","ASM_TOK","CC_TOK","CCC_TOK","FASTCC_TOK",
1217"COLDCC_TOK","RET","BR","SWITCH","INVOKE","UNWIND","UNREACHABLE","ADD","SUB",
1218"MUL","DIV","REM","AND","OR","XOR","SETLE","SETGE","SETLT","SETGT","SETEQ","SETNE",
1219"MALLOC","ALLOCA","FREE","LOAD","STORE","GETELEMENTPTR","PHI_TOK","CAST","SELECT",
1220"SHL","SHR","VAARG","EXTRACTELEMENT","INSERTELEMENT","VAARG_old","VANEXT_old",
1221"'='","','","'\\\\'","'('","')'","'['","'x'","']'","'<'","'>'","'{'","'}'","'*'",
1222"'c'","INTVAL","EINT64VAL","ArithmeticOps","LogicalOps","SetCondOps","ShiftOps",
1223"SIntType","UIntType","IntType","FPType","OptAssign","OptLinkage","OptCallingConv",
1224"OptAlign","OptCAlign","SectionString","OptSection","GlobalVarAttributes","GlobalVarAttribute",
1225"TypesV","UpRTypesV","Types","PrimType","UpRTypes","TypeListI","ArgTypeListI",
1226"ConstVal","ConstExpr","ConstVector","GlobalType","Module","FunctionList","ConstPool",
1227"@1","@2","AsmBlock","BigOrLittle","TargetDefinition","LibrariesDefinition",
1228"LibList","Name","OptName","ArgVal","ArgListH","ArgList","FunctionHeaderH","BEGIN",
1229"FunctionHeader","END","Function","FunctionProto","@3","ConstValueRef","SymbolicValueRef",
1230"ValueRef","ResolvedVal","BasicBlockList","BasicBlock","InstructionList","BBTerminatorInst",
1231"JumpTable","Inst","PHIList","ValueRefList","ValueRefListE","OptTailCall","InstVal",
1232"IndexList","OptVolatile","MemoryInst", NULL
1233};
1234#endif
1235
1236static const short yyr1[] = { 0,
1237 113, 113, 114, 114, 115, 115, 115, 115, 115, 116,
1238 116, 116, 117, 117, 117, 117, 117, 117, 118, 118,
1239 119, 119, 119, 119, 120, 120, 120, 120, 121, 121,
1240 122, 122, 123, 123, 124, 124, 124, 124, 124, 125,
1241 125, 125, 125, 125, 126, 126, 127, 127, 128, 129,
1242 129, 130, 130, 131, 131, 132, 132, 133, 133, 134,
1243 135, 135, 135, 135, 135, 135, 135, 135, 135, 135,
1244 135, 135, 135, 136, 136, 136, 136, 136, 136, 136,
1245 136, 136, 136, 137, 137, 138, 138, 138, 138, 139,
1246 139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
1247 139, 139, 139, 139, 139, 140, 140, 140, 140, 140,
1248 140, 140, 140, 141, 141, 142, 142, 143, 144, 144,
1249 144, 144, 144, 145, 145, 145, 146, 145, 147, 145,
1250 145, 145, 145, 148, 149, 149, 150, 150, 150, 151,
1251 152, 152, 152, 153, 153, 154, 154, 155, 156, 156,
1252 157, 157, 157, 157, 158, 159, 159, 160, 161, 161,
1253 162, 164, 163, 165, 165, 165, 165, 165, 165, 165,
1254 165, 165, 165, 166, 166, 167, 167, 168, 169, 169,
1255 170, 171, 171, 171, 172, 172, 172, 172, 172, 172,
1256 172, 172, 172, 173, 173, 174, 175, 175, 176, 176,
1257 177, 177, 178, 178, 179, 179, 179, 179, 179, 179,
1258 179, 179, 179, 179, 179, 179, 179, 179, 179, 180,
1259 180, 181, 181, 182, 182, 182, 182, 182, 182, 182,
1260 182
1261};
1262
1263static const short yyr2[] = { 0,
1264 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1265 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1266 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1267 1, 1, 2, 0, 1, 1, 1, 1, 0, 0,
1268 1, 1, 1, 2, 0, 2, 0, 3, 2, 0,
1269 1, 0, 3, 1, 2, 1, 1, 1, 1, 1,
1270 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1271 1, 1, 1, 1, 1, 1, 2, 4, 5, 5,
1272 3, 2, 2, 1, 3, 1, 3, 1, 0, 4,
1273 3, 3, 4, 4, 3, 2, 2, 2, 2, 2,
1274 2, 2, 2, 2, 2, 6, 5, 8, 6, 6,
1275 6, 6, 6, 3, 1, 1, 1, 1, 2, 2,
1276 3, 2, 1, 4, 2, 3, 0, 7, 0, 7,
1277 3, 4, 0, 1, 1, 1, 3, 3, 3, 3,
1278 3, 1, 0, 1, 1, 1, 0, 2, 3, 1,
1279 1, 3, 1, 0, 8, 1, 1, 3, 1, 1,
1280 2, 0, 3, 1, 1, 1, 1, 1, 1, 1,
1281 1, 3, 1, 1, 1, 1, 1, 2, 2, 2,
1282 3, 2, 0, 1, 2, 2, 3, 9, 9, 8,
1283 13, 1, 1, 6, 5, 2, 6, 7, 1, 3,
1284 1, 0, 2, 1, 5, 5, 5, 2, 4, 4,
1285 6, 4, 4, 4, 4, 6, 2, 7, 1, 2,
1286 0, 1, 0, 3, 6, 3, 6, 2, 4, 6,
1287 4
1288};
1289
1290static const short yydefact[] = { 133,
1291 39, 123, 122, 162, 35, 36, 37, 38, 0, 40,
1292 183, 119, 120, 183, 144, 145, 0, 0, 0, 39,
1293 0, 125, 40, 134, 121, 0, 41, 42, 43, 0,
1294 0, 184, 180, 34, 159, 160, 161, 179, 0, 0,
1295 0, 131, 0, 126, 0, 0, 0, 33, 163, 44,
1296 1, 2, 57, 61, 62, 63, 64, 65, 66, 67,
1297 68, 69, 70, 71, 72, 73, 74, 0, 0, 0,
1298 0, 174, 0, 0, 56, 75, 60, 175, 76, 156,
1299 157, 158, 223, 182, 0, 0, 0, 143, 132, 124,
1300 116, 117, 0, 0, 77, 0, 0, 59, 82, 84,
1301 0, 0, 89, 83, 222, 0, 204, 0, 0, 0,
1302 0, 40, 192, 193, 5, 6, 7, 8, 9, 10,
1303 11, 12, 13, 14, 15, 16, 17, 18, 0, 0,
1304 0, 0, 0, 0, 0, 19, 20, 0, 0, 0,
1305 0, 0, 0, 0, 0, 0, 181, 40, 196, 0,
1306 219, 139, 136, 135, 137, 138, 142, 0, 129, 61,
1307 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
1308 0, 0, 0, 0, 127, 0, 0, 0, 81, 154,
1309 88, 86, 0, 0, 208, 203, 186, 185, 0, 0,
1310 24, 28, 23, 27, 22, 26, 21, 25, 29, 30,
1311 0, 0, 47, 47, 228, 0, 0, 217, 0, 0,
1312 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1313 0, 0, 0, 140, 52, 103, 104, 3, 4, 101,
1314 102, 105, 100, 96, 97, 0, 0, 0, 0, 0,
1315 0, 0, 0, 0, 0, 0, 0, 99, 98, 52,
1316 58, 58, 85, 153, 147, 150, 151, 0, 0, 78,
1317 164, 165, 166, 171, 167, 168, 169, 170, 0, 173,
1318 177, 176, 178, 0, 187, 0, 0, 0, 224, 0,
1319 226, 221, 0, 0, 0, 0, 0, 0, 0, 0,
1320 0, 0, 0, 0, 0, 0, 0, 0, 141, 0,
1321 130, 0, 0, 0, 0, 91, 115, 0, 0, 95,
1322 0, 92, 0, 0, 0, 0, 128, 79, 80, 146,
1323 148, 0, 50, 87, 0, 0, 0, 0, 0, 0,
1324 0, 0, 231, 0, 0, 210, 0, 212, 215, 0,
1325 213, 214, 0, 0, 0, 209, 0, 229, 0, 0,
1326 0, 54, 52, 221, 0, 0, 0, 0, 90, 93,
1327 94, 0, 0, 0, 0, 152, 149, 51, 45, 172,
1328 0, 0, 202, 47, 48, 47, 199, 220, 0, 0,
1329 0, 0, 205, 206, 207, 202, 0, 49, 55, 53,
1330 0, 0, 0, 0, 114, 0, 0, 0, 0, 0,
1331 155, 0, 0, 201, 0, 0, 225, 227, 0, 0,
1332 0, 211, 216, 0, 230, 107, 0, 0, 0, 0,
1333 0, 0, 0, 46, 0, 0, 0, 200, 197, 0,
1334 218, 106, 0, 113, 109, 110, 111, 112, 0, 190,
1335 0, 0, 0, 198, 0, 188, 0, 189, 0, 0,
1336 108, 0, 0, 0, 0, 0, 0, 195, 0, 0,
1337 194, 191, 0, 0, 0
1338};
1339
1340static const short yydefgoto[] = { 72,
1341 230, 244, 245, 246, 247, 171, 172, 201, 173, 20,
1342 10, 30, 401, 279, 352, 369, 301, 353, 73, 74,
1343 184, 76, 77, 101, 183, 307, 270, 308, 93, 463,
1344 1, 2, 250, 225, 25, 155, 42, 89, 158, 78,
1345 321, 256, 257, 258, 31, 82, 11, 37, 12, 13,
1346 23, 271, 79, 273, 377, 14, 33, 34, 147, 442,
1347 84, 208, 404, 405, 148, 149, 333, 150, 151
1348};
1349
1350static const short yypact[] = {-32768,
1351 164, 551,-32768,-32768,-32768,-32768,-32768,-32768, -12, 47,
1352 6,-32768,-32768, -13,-32768,-32768, 90, -27, -12, 49,
1353 -23,-32768, 47,-32768,-32768, 84,-32768,-32768,-32768, 935,
1354 -20,-32768,-32768, 96,-32768,-32768,-32768,-32768, 2, 18,
1355 25,-32768, 1,-32768, 935, 79, 79,-32768,-32768,-32768,
1356-32768,-32768, 60,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1357-32768,-32768,-32768,-32768,-32768,-32768,-32768, 167, 173, 180,
1358 450,-32768, 96, 94,-32768,-32768, -69,-32768,-32768,-32768,
1359-32768,-32768, 1098,-32768, 174, 114, 193, 175,-32768,-32768,
1360-32768,-32768, 973, 1011,-32768, 95, 97,-32768,-32768, -69,
1361 -66, 99, 745,-32768,-32768, 973,-32768, 147, 1049, 50,
1362 142, 47,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1363-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 973, 973,
1364 973, 973, 973, 973, 973,-32768,-32768, 973, 973, 973,
1365 973, 973, 973, 973, 973, 973,-32768, 47,-32768, 83,
1366-32768,-32768,-32768,-32768,-32768,-32768,-32768, -19,-32768, 115,
1367 170, 205, 172, 213, 178, 214, 184, 215, 216, 221,
1368 190, 217, 222, 56,-32768, 973, 973, 973,-32768, 783,
1369-32768, 131, 129, 563,-32768,-32768, 60,-32768, 563, 563,
1370-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1371 563, 935, 133, 134,-32768, 563, 136, 137, 202, 141,
1372 143, 144, 145, 146, 148, 563, 563, 563, 149, 935,
1373 973, 973, 218,-32768, 150,-32768,-32768,-32768,-32768,-32768,
1374-32768,-32768,-32768,-32768,-32768, 154, 156, 157, 165, 821,
1375 1011, 520, 227, 166, 169, 185, 186,-32768,-32768, 150,
1376 -32, -25, -69,-32768, 96,-32768, 176, 187, 859,-32768,
1377-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 1011,-32768,
1378-32768,-32768,-32768, 177,-32768, 189, 563, 3,-32768, 4,
1379-32768, 191, 563, 192, 973, 973, 973, 973, 973, 973,
1380 973, 194, 195, 197, 973, 563, 563, 198,-32768, 12,
1381-32768, 1011, 1011, 1011, 1011,-32768,-32768, -2, -35,-32768,
1382 -40,-32768, 1011, 1011, 1011, 1011,-32768,-32768,-32768,-32768,
1383-32768, 897, 259,-32768, -33, 278, 279, 199, 563, 298,
1384 563, 973,-32768, 203, 563,-32768, 211,-32768,-32768, 212,
1385-32768,-32768, 563, 563, 563,-32768, 219,-32768, 973, 289,
1386 310,-32768, 150, 191, 282, 220, 224, 1011,-32768,-32768,
1387-32768, 225, 226, 230, 231,-32768,-32768,-32768, 261,-32768,
1388 563, 563, 973, 234,-32768, 234,-32768, 235, 563, 236,
1389 973, 973,-32768,-32768,-32768, 973, 563,-32768,-32768,-32768,
1390 237, 973, 1011, 1011,-32768, 1011, 1011, 1011, 1011, 318,
1391-32768, 238, 223, 235, 242, 283,-32768,-32768, 973, 233,
1392 563,-32768,-32768, 243,-32768,-32768, 245, 249, 247, 248,
1393 250, 251, 252,-32768, 331, 10, 320,-32768,-32768, 253,
1394-32768,-32768, 1011,-32768,-32768,-32768,-32768,-32768, 563,-32768,
1395 645, 39, 336,-32768, 255,-32768, 265,-32768, 645, 563,
1396-32768, 349, 271, 305, 563, 352, 353,-32768, 563, 563,
1397-32768,-32768, 376, 378,-32768
1398};
1399
1400static const short yypgoto[] = {-32768,
1401-32768, 296, 297, 299, 300, -110, -109, -412,-32768, 350,
1402 365, -101,-32768, -196, 63,-32768, -243,-32768, -41,-32768,
1403 -30,-32768, -55, 284,-32768, -89, 228, -201, 341,-32768,
1404-32768,-32768,-32768,-32768, 373,-32768,-32768,-32768,-32768, 11,
1405-32768, 72,-32768,-32768, 374,-32768,-32768,-32768,-32768, 394,
1406-32768, -364, 46, 64, -103,-32768, 384,-32768,-32768,-32768,
1407-32768,-32768, 68, 15,-32768,-32768, 51,-32768,-32768
1408};
1409
1410
1411#define YYLAST 1196
1412
1413
1414static const short yytable[] = { 75,
1415 199, 200, 185, 90, 175, 188, 317, 281, 80, 32,
1416 202, 24, 21, 441, 75, 100, 35, 329, 331, 191,
1417 192, 193, 194, 195, 196, 197, 198, 205, 32, 449,
1418 209, 210, -58, 178, 211, 212, 213, 214, 215, 309,
1419 311, 104, 219, 179, 21, 350, 220, 100, 191, 192,
1420 193, 194, 195, 196, 197, 198, 330, 330, 189, 358,
1421 51, 52, 159, 174, 358, 351, 358, 325, 45, 361,
1422 190, 43, 360, 318, 370, 48, 447, 15, 104, 16,
1423 223, 233, 319, 102, 453, 104, 224, 50, 81, 5,
1424 6, 7, 8, 234, 235, 46, 36, 358, 203, 204,
1425 85, 206, 207, 359, 88, 26, 27, 28, 29, 390,
1426 91, 92, 216, 217, 218, 440, 86, 15, 298, 16,
1427 251, 252, 253, 87, 115, 116, 117, 118, 119, 120,
1428 121, 122, 123, 124, 125, 126, 127, 128, 39, 40,
1429 41, 226, 227, 236, 448, 237, 238, 136, 137, 255,
1430 239, 191, 192, 193, 194, 195, 196, 197, 198, 240,
1431 277, -59, 241, -118, 242, 153, 154, 243, 221, 222,
1432 95, 75, -24, -24, -23, -23, 96, 407, 296, 408,
1433 -22, -22, 337, 97, 339, 340, -21, -21, 3, 75,
1434 297, 346, 228, 229, 4, 103, 156, 152, 157, 176,
1435 180, 177, 186, 253, 5, 6, 7, 8, -28, 174,
1436 174, 174, 354, 355, 356, 357, -27, -26, -25, 249,
1437 231, 9, -31, 362, 363, 364, 365, -32, 232, 272,
1438 259, 260, 278, 280, 272, 272, 284, 285, 174, 283,
1439 286, 299, 287, 288, 289, 290, 272, 291, 295, 300,
1440 312, 272, 274, 275, 336, 302, 338, 303, 304, 341,
1441 342, 272, 272, 272, 276, 320, 305, 313, 395, 282,
1442 314, 174, 174, 174, 174, 322, 326, 412, 413, 292,
1443 293, 294, 174, 174, 174, 174, 315, 316, 327, 323,
1444 332, 255, 350, 343, 344, 335, 345, 349, 371, 372,
1445 373, 375, 379, 418, 419, 428, 420, 421, 422, 423,
1446 381, 382, 388, 389, 400, 199, 200, 392, 387, 393,
1447 386, 424, 272, 394, 396, 397, 426, 174, 272, 398,
1448 399, 199, 200, 406, 409, 411, 330, 425, 429, 416,
1449 328, 272, 272, 445, 427, 431, 334, 432, 433, 434,
1450 435, 439, 436, 437, 438, 443, 450, 451, 444, 347,
1451 348, 417, 174, 174, 452, 174, 174, 174, 174, 455,
1452 456, 457, 459, 460, 272, 464, 272, 465, 143, 144,
1453 272, 145, 146, 83, 47, 368, 182, 94, 272, 272,
1454 272, 44, 374, 367, 376, 22, 49, 38, 380, 378,
1455 414, 248, 174, 0, 391, 0, 383, 384, 385, 0,
1456 0, 0, 0, 0, 0, 0, 272, 272, 0, 0,
1457 0, 0, 0, 0, 272, 0, 0, 0, 0, 0,
1458 0, 0, 272, 0, 402, 403, 0, 0, 0, 0,
1459 0, 0, 410, 0, 0, 0, 0, 0, 0, 0,
1460 415, 0, 0, 0, 51, 52, 272, 98, 54, 55,
1461 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
1462 66, 15, 0, 16, 430, 0, 0, 0, 0, 0,
1463 0, 0, 0, 0, 272, 0, 0, 0, 0, 0,
1464 0, 0, 0, 0, 67, 272, 0, 0, 0, 0,
1465 272, 0, 446, 0, 272, 272, 0, 0, 0, 0,
1466 0, 0, 0, 454, 0, 0, 0, 0, 458, 0,
1467 0, 0, 461, 462, 51, 52, 0, 98, 160, 161,
1468 162, 163, 164, 165, 166, 167, 168, 169, 170, 65,
1469 66, 15, 0, 16, 0, 0, 0, 0, 0, 0,
1470 68, 0, 0, 69, 0, 0, 70, 0, 71, 99,
1471 0, 0, 0, 0, 67, 261, 262, 51, 52, 263,
1472 -34, 0, 15, 0, 16, 0, 0, 0, 0, 0,
1473 0, 4, -34, -34, 15, 0, 16, 0, 264, 265,
1474 266, -34, -34, -34, -34, 0, 0, -34, 17, 0,
1475 267, 268, 0, 0, 0, 18, 0, 0, 19, 0,
1476 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1477 68, 0, 0, 69, 0, 0, 70, 0, 71, 310,
1478 0, 115, 116, 117, 118, 119, 120, 121, 122, 123,
1479 124, 125, 126, 127, 128, 0, 0, 261, 262, 0,
1480 236, 263, 237, 238, 136, 137, 0, 239, 0, 0,
1481 0, 0, 0, 0, 0, 0, 0, 0, 0, 269,
1482 264, 265, 266, 0, 0, 0, 0, 0, 0, 0,
1483 0, 0, 267, 268, 0, 0, 0, 0, 0, 0,
1484 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1485 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1486 0, 0, 0, 115, 116, 117, 118, 119, 120, 121,
1487 122, 123, 124, 125, 126, 127, 128, 0, 0, 0,
1488 0, 0, 236, 0, 237, 238, 136, 137, 0, 239,
1489 0, 0, 0, 0, 0, 0, 0, 0, 0, 51,
1490 52, 269, 98, 54, 55, 56, 57, 58, 59, 60,
1491 61, 62, 63, 64, 65, 66, 15, 0, 16, 0,
1492 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1493 0, 181, 0, 0, 0, 0, 0, 51, 52, 67,
1494 98, 54, 55, 56, 57, 58, 59, 60, 61, 62,
1495 63, 64, 65, 66, 15, 0, 16, 0, 0, 0,
1496 0, 0, 0, 0, 0, 0, 0, 0, 0, 254,
1497 0, 0, 0, 0, 0, 51, 52, 67, 98, 160,
1498 161, 162, 163, 164, 165, 166, 167, 168, 169, 170,
1499 65, 66, 15, 0, 16, 68, 0, 0, 69, 0,
1500 0, 70, 0, 71, 0, 0, 0, 0, 0, 0,
1501 0, 0, 0, 51, 52, 67, 98, 54, 55, 56,
1502 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1503 15, 0, 16, 68, 0, 0, 69, 0, 0, 70,
1504 0, 71, 0, 0, 0, 324, 0, 0, 0, 0,
1505 0, 51, 52, 67, 98, 54, 55, 56, 57, 58,
1506 59, 60, 61, 62, 63, 64, 65, 66, 15, 0,
1507 16, 68, 0, 0, 69, 0, 306, 70, 0, 71,
1508 0, 0, 0, 366, 0, 0, 0, 0, 0, 51,
1509 52, 67, 53, 54, 55, 56, 57, 58, 59, 60,
1510 61, 62, 63, 64, 65, 66, 15, 0, 16, 68,
1511 0, 0, 69, 0, 0, 70, 0, 71, 0, 0,
1512 0, 0, 0, 0, 0, 0, 0, 51, 52, 67,
1513 98, 54, 55, 56, 57, 58, 59, 60, 61, 62,
1514 63, 64, 65, 66, 15, 0, 16, 68, 0, 0,
1515 69, 0, 0, 70, 0, 71, 0, 0, 0, 0,
1516 0, 0, 0, 0, 0, 51, 52, 67, 98, 160,
1517 161, 162, 163, 164, 165, 166, 167, 168, 169, 170,
1518 65, 66, 15, 0, 16, 68, 0, 0, 69, 0,
1519 0, 70, 0, 71, 0, 0, 0, 0, 0, 0,
1520 0, 0, 0, 51, 52, 67, 187, 54, 55, 56,
1521 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1522 15, 0, 16, 68, 0, 0, 69, 0, 0, 70,
1523 0, 71, 0, 0, 0, 0, 0, 0, 0, 0,
1524 0, 0, 0, 67, 0, 0, 0, 0, 0, 0,
1525 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1526 0, 68, 0, 0, 69, 0, 0, 70, 0, 71,
1527 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1528 0, 0, 105, 0, 0, 0, 0, 0, 0, 0,
1529 0, 0, 0, 106, 0, 0, 0, 0, 0, 68,
1530 0, 0, 69, 107, 108, 70, 0, 71, 0, 0,
1531 109, 110, 111, 112, 113, 114, 115, 116, 117, 118,
1532 119, 120, 121, 122, 123, 124, 125, 126, 127, 128,
1533 129, 130, 131, 0, 0, 132, 133, 134, 135, 136,
1534 137, 138, 139, 140, 141, 142
1535};
1536
1537static const short yycheck[] = { 30,
1538 111, 111, 106, 45, 94, 109, 250, 204, 29, 23,
1539 112, 24, 2, 426, 45, 71, 30, 15, 15, 10,
1540 11, 12, 13, 14, 15, 16, 17, 131, 23, 442,
1541 134, 135, 102, 100, 138, 139, 140, 141, 142, 241,
1542 242, 111, 146, 110, 34, 34, 148, 103, 10, 11,
1543 12, 13, 14, 15, 16, 17, 54, 54, 9, 100,
1544 5, 6, 93, 94, 100, 54, 100, 269, 20, 110,
1545 21, 99, 108, 106, 108, 99, 441, 22, 111, 24,
1546 100, 26, 108, 73, 449, 111, 106, 4, 109, 41,
1547 42, 43, 44, 38, 39, 47, 110, 100, 129, 130,
1548 99, 132, 133, 106, 104, 59, 60, 61, 62, 353,
1549 32, 33, 143, 144, 145, 106, 99, 22, 222, 24,
1550 176, 177, 178, 99, 69, 70, 71, 72, 73, 74,
1551 75, 76, 77, 78, 79, 80, 81, 82, 49, 50,
1552 51, 27, 28, 88, 106, 90, 91, 92, 93, 180,
1553 95, 10, 11, 12, 13, 14, 15, 16, 17, 104,
1554 202, 102, 107, 0, 109, 52, 53, 112, 86, 87,
1555 4, 202, 3, 4, 3, 4, 4, 374, 220, 376,
1556 3, 4, 286, 4, 288, 289, 3, 4, 25, 220,
1557 221, 295, 3, 4, 31, 102, 4, 24, 24, 105,
1558 102, 105, 56, 259, 41, 42, 43, 44, 4, 240,
1559 241, 242, 302, 303, 304, 305, 4, 4, 4, 174,
1560 4, 58, 7, 313, 314, 315, 316, 7, 7, 184,
1561 100, 103, 100, 100, 189, 190, 100, 36, 269, 104,
1562 100, 24, 100, 100, 100, 100, 201, 100, 100, 100,
1563 24, 206, 189, 190, 285, 102, 287, 102, 102, 290,
1564 291, 216, 217, 218, 201, 255, 102, 102, 358, 206,
1565 102, 302, 303, 304, 305, 100, 100, 381, 382, 216,
1566 217, 218, 313, 314, 315, 316, 102, 102, 100, 103,
1567 100, 322, 34, 100, 100, 104, 100, 100, 21, 21,
1568 102, 4, 100, 393, 394, 409, 396, 397, 398, 399,
1569 100, 100, 24, 4, 54, 426, 426, 36, 349, 100,
1570 102, 4, 277, 100, 100, 100, 104, 358, 283, 100,
1571 100, 442, 442, 100, 100, 100, 54, 100, 106, 103,
1572 277, 296, 297, 433, 103, 103, 283, 103, 100, 103,
1573 103, 21, 103, 103, 103, 36, 21, 103, 106, 296,
1574 297, 392, 393, 394, 100, 396, 397, 398, 399, 21,
1575 100, 67, 21, 21, 329, 0, 331, 0, 83, 83,
1576 335, 83, 83, 34, 20, 323, 103, 47, 343, 344,
1577 345, 19, 329, 322, 331, 2, 23, 14, 335, 332,
1578 386, 174, 433, -1, 354, -1, 343, 344, 345, -1,
1579 -1, -1, -1, -1, -1, -1, 371, 372, -1, -1,
1580 -1, -1, -1, -1, 379, -1, -1, -1, -1, -1,
1581 -1, -1, 387, -1, 371, 372, -1, -1, -1, -1,
1582 -1, -1, 379, -1, -1, -1, -1, -1, -1, -1,
1583 387, -1, -1, -1, 5, 6, 411, 8, 9, 10,
1584 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
1585 21, 22, -1, 24, 411, -1, -1, -1, -1, -1,
1586 -1, -1, -1, -1, 439, -1, -1, -1, -1, -1,
1587 -1, -1, -1, -1, 45, 450, -1, -1, -1, -1,
1588 455, -1, 439, -1, 459, 460, -1, -1, -1, -1,
1589 -1, -1, -1, 450, -1, -1, -1, -1, 455, -1,
1590 -1, -1, 459, 460, 5, 6, -1, 8, 9, 10,
1591 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
1592 21, 22, -1, 24, -1, -1, -1, -1, -1, -1,
1593 101, -1, -1, 104, -1, -1, 107, -1, 109, 110,
1594 -1, -1, -1, -1, 45, 3, 4, 5, 6, 7,
1595 20, -1, 22, -1, 24, -1, -1, -1, -1, -1,
1596 -1, 31, 32, 33, 22, -1, 24, -1, 26, 27,
1597 28, 41, 42, 43, 44, -1, -1, 47, 48, -1,
1598 38, 39, -1, -1, -1, 55, -1, -1, 58, -1,
1599 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1600 101, -1, -1, 104, -1, -1, 107, -1, 109, 110,
1601 -1, 69, 70, 71, 72, 73, 74, 75, 76, 77,
1602 78, 79, 80, 81, 82, -1, -1, 3, 4, -1,
1603 88, 7, 90, 91, 92, 93, -1, 95, -1, -1,
1604 -1, -1, -1, -1, -1, -1, -1, -1, -1, 107,
1605 26, 27, 28, -1, -1, -1, -1, -1, -1, -1,
1606 -1, -1, 38, 39, -1, -1, -1, -1, -1, -1,
1607 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1608 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1609 -1, -1, -1, 69, 70, 71, 72, 73, 74, 75,
1610 76, 77, 78, 79, 80, 81, 82, -1, -1, -1,
1611 -1, -1, 88, -1, 90, 91, 92, 93, -1, 95,
1612 -1, -1, -1, -1, -1, -1, -1, -1, -1, 5,
1613 6, 107, 8, 9, 10, 11, 12, 13, 14, 15,
1614 16, 17, 18, 19, 20, 21, 22, -1, 24, -1,
1615 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1616 -1, 37, -1, -1, -1, -1, -1, 5, 6, 45,
1617 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
1618 18, 19, 20, 21, 22, -1, 24, -1, -1, -1,
1619 -1, -1, -1, -1, -1, -1, -1, -1, -1, 37,
1620 -1, -1, -1, -1, -1, 5, 6, 45, 8, 9,
1621 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
1622 20, 21, 22, -1, 24, 101, -1, -1, 104, -1,
1623 -1, 107, -1, 109, -1, -1, -1, -1, -1, -1,
1624 -1, -1, -1, 5, 6, 45, 8, 9, 10, 11,
1625 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
1626 22, -1, 24, 101, -1, -1, 104, -1, -1, 107,
1627 -1, 109, -1, -1, -1, 37, -1, -1, -1, -1,
1628 -1, 5, 6, 45, 8, 9, 10, 11, 12, 13,
1629 14, 15, 16, 17, 18, 19, 20, 21, 22, -1,
1630 24, 101, -1, -1, 104, -1, 106, 107, -1, 109,
1631 -1, -1, -1, 37, -1, -1, -1, -1, -1, 5,
1632 6, 45, 8, 9, 10, 11, 12, 13, 14, 15,
1633 16, 17, 18, 19, 20, 21, 22, -1, 24, 101,
1634 -1, -1, 104, -1, -1, 107, -1, 109, -1, -1,
1635 -1, -1, -1, -1, -1, -1, -1, 5, 6, 45,
1636 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
1637 18, 19, 20, 21, 22, -1, 24, 101, -1, -1,
1638 104, -1, -1, 107, -1, 109, -1, -1, -1, -1,
1639 -1, -1, -1, -1, -1, 5, 6, 45, 8, 9,
1640 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
1641 20, 21, 22, -1, 24, 101, -1, -1, 104, -1,
1642 -1, 107, -1, 109, -1, -1, -1, -1, -1, -1,
1643 -1, -1, -1, 5, 6, 45, 8, 9, 10, 11,
1644 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
1645 22, -1, 24, 101, -1, -1, 104, -1, -1, 107,
1646 -1, 109, -1, -1, -1, -1, -1, -1, -1, -1,
1647 -1, -1, -1, 45, -1, -1, -1, -1, -1, -1,
1648 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1649 -1, 101, -1, -1, 104, -1, -1, 107, -1, 109,
1650 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1651 -1, -1, 35, -1, -1, -1, -1, -1, -1, -1,
1652 -1, -1, -1, 46, -1, -1, -1, -1, -1, 101,
1653 -1, -1, 104, 56, 57, 107, -1, 109, -1, -1,
1654 63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
1655 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
1656 83, 84, 85, -1, -1, 88, 89, 90, 91, 92,
1657 93, 94, 95, 96, 97, 98
1658};
1659/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
1660#line 3 "/usr/share/bison.simple"
1661/* This file comes from bison-1.28. */
1662
1663/* Skeleton output parser for bison,
1664 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
1665
1666 This program is free software; you can redistribute it and/or modify
1667 it under the terms of the GNU General Public License as published by
1668 the Free Software Foundation; either version 2, or (at your option)
1669 any later version.
1670
1671 This program is distributed in the hope that it will be useful,
1672 but WITHOUT ANY WARRANTY; without even the implied warranty of
1673 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1674 GNU General Public License for more details.
1675
1676 You should have received a copy of the GNU General Public License
1677 along with this program; if not, write to the Free Software
1678 Foundation, Inc., 59 Temple Place - Suite 330,
1679 Boston, MA 02111-1307, USA. */
1680
1681/* As a special exception, when this file is copied by Bison into a
1682 Bison output file, you may use that output file without restriction.
1683 This special exception was added by the Free Software Foundation
1684 in version 1.24 of Bison. */
1685
1686/* This is the parser code that is written into each bison parser
1687 when the %semantic_parser declaration is not specified in the grammar.
1688 It was written by Richard Stallman by simplifying the hairy parser
1689 used when %semantic_parser is specified. */
1690
1691#ifndef YYSTACK_USE_ALLOCA
1692#ifdef alloca
1693#define YYSTACK_USE_ALLOCA
1694#else /* alloca not defined */
1695#ifdef __GNUC__
1696#define YYSTACK_USE_ALLOCA
1697#define alloca __builtin_alloca
1698#else /* not GNU C. */
1699#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
1700#define YYSTACK_USE_ALLOCA
1701#include <alloca.h>
1702#else /* not sparc */
1703/* We think this test detects Watcom and Microsoft C. */
1704/* This used to test MSDOS, but that is a bad idea
1705 since that symbol is in the user namespace. */
1706#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
1707#if 0 /* No need for malloc.h, which pollutes the namespace;
1708 instead, just don't use alloca. */
1709#include <malloc.h>
1710#endif
1711#else /* not MSDOS, or __TURBOC__ */
1712#if defined(_AIX)
1713/* I don't know what this was needed for, but it pollutes the namespace.
1714 So I turned it off. rms, 2 May 1997. */
1715/* #include <malloc.h> */
1716 #pragma alloca
1717#define YYSTACK_USE_ALLOCA
1718#else /* not MSDOS, or __TURBOC__, or _AIX */
1719#if 0
1720#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
1721 and on HPUX 10. Eventually we can turn this on. */
1722#define YYSTACK_USE_ALLOCA
1723#define alloca __builtin_alloca
1724#endif /* __hpux */
1725#endif
1726#endif /* not _AIX */
1727#endif /* not MSDOS, or __TURBOC__ */
1728#endif /* not sparc */
1729#endif /* not GNU C */
1730#endif /* alloca not defined */
1731#endif /* YYSTACK_USE_ALLOCA not defined */
1732
1733#ifdef YYSTACK_USE_ALLOCA
1734#define YYSTACK_ALLOC alloca
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001735#else
Chris Lattneredd9b032006-01-23 23:05:42 +00001736#define YYSTACK_ALLOC malloc
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001737#endif
1738
Chris Lattneredd9b032006-01-23 23:05:42 +00001739/* Note: there must be only one dollar sign in this file.
1740 It is replaced by the list of actions, each action
1741 as one case of the switch. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001742
1743#define yyerrok (yyerrstatus = 0)
1744#define yyclearin (yychar = YYEMPTY)
Chris Lattneredd9b032006-01-23 23:05:42 +00001745#define YYEMPTY -2
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001746#define YYEOF 0
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001747#define YYACCEPT goto yyacceptlab
Chris Lattneredd9b032006-01-23 23:05:42 +00001748#define YYABORT goto yyabortlab
1749#define YYERROR goto yyerrlab1
1750/* Like YYERROR except do call yyerror.
1751 This remains here temporarily to ease the
1752 transition to the new meaning of YYERROR, for GCC.
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001753 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001754#define YYFAIL goto yyerrlab
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001755#define YYRECOVERING() (!!yyerrstatus)
Chris Lattneredd9b032006-01-23 23:05:42 +00001756#define YYBACKUP(token, value) \
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001757do \
1758 if (yychar == YYEMPTY && yylen == 1) \
Chris Lattneredd9b032006-01-23 23:05:42 +00001759 { yychar = (token), yylval = (value); \
1760 yychar1 = YYTRANSLATE (yychar); \
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001761 YYPOPSTACK; \
1762 goto yybackup; \
1763 } \
1764 else \
Chris Lattneredd9b032006-01-23 23:05:42 +00001765 { yyerror ("syntax error: cannot back up"); YYERROR; } \
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001766while (0)
1767
1768#define YYTERROR 1
1769#define YYERRCODE 256
1770
Chris Lattneredd9b032006-01-23 23:05:42 +00001771#ifndef YYPURE
1772#define YYLEX yylex()
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001773#endif
1774
Chris Lattneredd9b032006-01-23 23:05:42 +00001775#ifdef YYPURE
1776#ifdef YYLSP_NEEDED
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001777#ifdef YYLEX_PARAM
Chris Lattneredd9b032006-01-23 23:05:42 +00001778#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001779#else
Chris Lattneredd9b032006-01-23 23:05:42 +00001780#define YYLEX yylex(&yylval, &yylloc)
1781#endif
1782#else /* not YYLSP_NEEDED */
1783#ifdef YYLEX_PARAM
1784#define YYLEX yylex(&yylval, YYLEX_PARAM)
1785#else
1786#define YYLEX yylex(&yylval)
1787#endif
1788#endif /* not YYLSP_NEEDED */
Robert Bocchinofdf9e412006-01-17 20:06:25 +00001789#endif
Reid Spencerc8a9faf2006-01-19 01:21:04 +00001790
Chris Lattneredd9b032006-01-23 23:05:42 +00001791/* If nonreentrant, generate the variables here */
Reid Spencerc8a9faf2006-01-19 01:21:04 +00001792
Chris Lattneredd9b032006-01-23 23:05:42 +00001793#ifndef YYPURE
Reid Spencerc8a9faf2006-01-19 01:21:04 +00001794
Chris Lattneredd9b032006-01-23 23:05:42 +00001795int yychar; /* the lookahead symbol */
1796YYSTYPE yylval; /* the semantic value of the */
1797 /* lookahead symbol */
Reid Spencerc8a9faf2006-01-19 01:21:04 +00001798
Chris Lattneredd9b032006-01-23 23:05:42 +00001799#ifdef YYLSP_NEEDED
1800YYLTYPE yylloc; /* location data for the lookahead */
1801 /* symbol */
Robert Bocchinofdf9e412006-01-17 20:06:25 +00001802#endif
Reid Spencerc8a9faf2006-01-19 01:21:04 +00001803
Chris Lattneredd9b032006-01-23 23:05:42 +00001804int yynerrs; /* number of parse errors so far */
1805#endif /* not YYPURE */
Reid Spencerc8a9faf2006-01-19 01:21:04 +00001806
Chris Lattneredd9b032006-01-23 23:05:42 +00001807#if YYDEBUG != 0
1808int yydebug; /* nonzero means print parse trace */
1809/* Since this is uninitialized, it does not stop multiple parsers
1810 from coexisting. */
Nate Begeman848622f2005-11-05 09:21:28 +00001811#endif
Reid Spencerb4f9a6f2006-01-16 21:12:35 +00001812
Chris Lattneredd9b032006-01-23 23:05:42 +00001813/* YYINITDEPTH indicates the initial size of the parser's stacks */
Reid Spencerb4f9a6f2006-01-16 21:12:35 +00001814
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001815#ifndef YYINITDEPTH
Chris Lattneredd9b032006-01-23 23:05:42 +00001816#define YYINITDEPTH 200
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001817#endif
1818
Chris Lattneredd9b032006-01-23 23:05:42 +00001819/* YYMAXDEPTH is the maximum size the stacks can grow to
1820 (effective only if the built-in stack extension method is used). */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001821
Chris Lattneredd9b032006-01-23 23:05:42 +00001822#if YYMAXDEPTH == 0
1823#undef YYMAXDEPTH
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001824#endif
1825
1826#ifndef YYMAXDEPTH
Chris Lattneredd9b032006-01-23 23:05:42 +00001827#define YYMAXDEPTH 10000
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001828#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001829
Chris Lattneredd9b032006-01-23 23:05:42 +00001830/* Define __yy_memcpy. Note that the size argument
1831 should be passed with type unsigned int, because that is what the non-GCC
1832 definitions require. With GCC, __builtin_memcpy takes an arg
1833 of type size_t, but it can handle unsigned int. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001834
Chris Lattneredd9b032006-01-23 23:05:42 +00001835#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
1836#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
1837#else /* not GNU C or C++ */
1838#ifndef __cplusplus
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001839
Chris Lattneredd9b032006-01-23 23:05:42 +00001840/* This is the most reliable way to avoid incompatibilities
1841 in available built-in functions on various systems. */
Reid Spencerc8a9faf2006-01-19 01:21:04 +00001842static void
Chris Lattneredd9b032006-01-23 23:05:42 +00001843__yy_memcpy (to, from, count)
1844 char *to;
1845 char *from;
1846 unsigned int count;
1847{
1848 register char *f = from;
1849 register char *t = to;
1850 register int i = count;
1851
1852 while (i-- > 0)
1853 *t++ = *f++;
1854}
1855
1856#else /* __cplusplus */
1857
1858/* This is the most reliable way to avoid incompatibilities
1859 in available built-in functions on various systems. */
Reid Spencerc8a9faf2006-01-19 01:21:04 +00001860static void
Chris Lattneredd9b032006-01-23 23:05:42 +00001861__yy_memcpy (char *to, char *from, unsigned int count)
1862{
1863 register char *t = to;
1864 register char *f = from;
1865 register int i = count;
1866
1867 while (i-- > 0)
1868 *t++ = *f++;
1869}
1870
Reid Spencerb4f9a6f2006-01-16 21:12:35 +00001871#endif
Reid Spencerc8a9faf2006-01-19 01:21:04 +00001872#endif
Reid Spencerc8a9faf2006-01-19 01:21:04 +00001873
Chris Lattneredd9b032006-01-23 23:05:42 +00001874#line 217 "/usr/share/bison.simple"
Reid Spencerc8a9faf2006-01-19 01:21:04 +00001875
Chris Lattneredd9b032006-01-23 23:05:42 +00001876/* The user can define YYPARSE_PARAM as the name of an argument to be passed
1877 into yyparse. The argument should have type void *.
1878 It should actually point to an object.
1879 Grammar actions can access the variable by casting it
1880 to the proper pointer type. */
Reid Spencerc8a9faf2006-01-19 01:21:04 +00001881
1882#ifdef YYPARSE_PARAM
Chris Lattneredd9b032006-01-23 23:05:42 +00001883#ifdef __cplusplus
1884#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
1885#define YYPARSE_PARAM_DECL
1886#else /* not __cplusplus */
1887#define YYPARSE_PARAM_ARG YYPARSE_PARAM
1888#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
1889#endif /* not __cplusplus */
1890#else /* not YYPARSE_PARAM */
1891#define YYPARSE_PARAM_ARG
1892#define YYPARSE_PARAM_DECL
1893#endif /* not YYPARSE_PARAM */
1894
1895/* Prevent warning if -Wstrict-prototypes. */
1896#ifdef __GNUC__
1897#ifdef YYPARSE_PARAM
1898int yyparse (void *);
1899#else
Reid Spencerc8a9faf2006-01-19 01:21:04 +00001900int yyparse (void);
Reid Spencerc8a9faf2006-01-19 01:21:04 +00001901#endif
Chris Lattneredd9b032006-01-23 23:05:42 +00001902#endif
Reid Spencerc8a9faf2006-01-19 01:21:04 +00001903
Reid Spencerc8a9faf2006-01-19 01:21:04 +00001904int
Chris Lattneredd9b032006-01-23 23:05:42 +00001905yyparse(YYPARSE_PARAM_ARG)
1906 YYPARSE_PARAM_DECL
Reid Spencerc8a9faf2006-01-19 01:21:04 +00001907{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001908 register int yystate;
1909 register int yyn;
Nate Begeman848622f2005-11-05 09:21:28 +00001910 register short *yyssp;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001911 register YYSTYPE *yyvsp;
Chris Lattneredd9b032006-01-23 23:05:42 +00001912 int yyerrstatus; /* number of tokens to shift before error messages enabled */
1913 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001914
Chris Lattneredd9b032006-01-23 23:05:42 +00001915 short yyssa[YYINITDEPTH]; /* the state stack */
1916 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001917
Chris Lattneredd9b032006-01-23 23:05:42 +00001918 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
1919 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001920
Chris Lattneredd9b032006-01-23 23:05:42 +00001921#ifdef YYLSP_NEEDED
1922 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
1923 YYLTYPE *yyls = yylsa;
1924 YYLTYPE *yylsp;
1925
1926#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
1927#else
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001928#define YYPOPSTACK (yyvsp--, yyssp--)
Chris Lattneredd9b032006-01-23 23:05:42 +00001929#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001930
Chris Lattneredd9b032006-01-23 23:05:42 +00001931 int yystacksize = YYINITDEPTH;
1932 int yyfree_stacks = 0;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001933
Chris Lattneredd9b032006-01-23 23:05:42 +00001934#ifdef YYPURE
1935 int yychar;
1936 YYSTYPE yylval;
1937 int yynerrs;
1938#ifdef YYLSP_NEEDED
1939 YYLTYPE yylloc;
1940#endif
1941#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001942
Chris Lattneredd9b032006-01-23 23:05:42 +00001943 YYSTYPE yyval; /* the variable used to return */
1944 /* semantic values from the action */
1945 /* routines */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001946
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001947 int yylen;
1948
Chris Lattneredd9b032006-01-23 23:05:42 +00001949#if YYDEBUG != 0
1950 if (yydebug)
1951 fprintf(stderr, "Starting parse\n");
1952#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001953
1954 yystate = 0;
1955 yyerrstatus = 0;
1956 yynerrs = 0;
1957 yychar = YYEMPTY; /* Cause a token to be read. */
1958
1959 /* Initialize stack pointers.
1960 Waste one element of value and location stack
1961 so that they stay on the same level as the state stack.
1962 The wasted elements are never initialized. */
1963
Chris Lattneredd9b032006-01-23 23:05:42 +00001964 yyssp = yyss - 1;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001965 yyvsp = yyvs;
Chris Lattneredd9b032006-01-23 23:05:42 +00001966#ifdef YYLSP_NEEDED
1967 yylsp = yyls;
1968#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001969
Chris Lattneredd9b032006-01-23 23:05:42 +00001970/* Push a new state, which is found in yystate . */
1971/* In all cases, when you get here, the value and location stacks
1972 have just been pushed. so pushing a state here evens the stacks. */
1973yynewstate:
Jeff Cohen11e26b52005-10-23 04:37:20 +00001974
Chris Lattneredd9b032006-01-23 23:05:42 +00001975 *++yyssp = yystate;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001976
Chris Lattneredd9b032006-01-23 23:05:42 +00001977 if (yyssp >= yyss + yystacksize - 1)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001978 {
Chris Lattneredd9b032006-01-23 23:05:42 +00001979 /* Give user a chance to reallocate the stack */
1980 /* Use copies of these so that the &'s don't force the real ones into memory. */
1981 YYSTYPE *yyvs1 = yyvs;
1982 short *yyss1 = yyss;
1983#ifdef YYLSP_NEEDED
1984 YYLTYPE *yyls1 = yyls;
1985#endif
1986
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001987 /* Get the current used size of the three stacks, in elements. */
Chris Lattneredd9b032006-01-23 23:05:42 +00001988 int size = yyssp - yyss + 1;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001989
1990#ifdef yyoverflow
Chris Lattneredd9b032006-01-23 23:05:42 +00001991 /* Each stack pointer address is followed by the size of
1992 the data in use in that stack, in bytes. */
1993#ifdef YYLSP_NEEDED
1994 /* This used to be a conditional around just the two extra args,
1995 but that might be undefined if yyoverflow is a macro. */
1996 yyoverflow("parser stack overflow",
1997 &yyss1, size * sizeof (*yyssp),
1998 &yyvs1, size * sizeof (*yyvsp),
1999 &yyls1, size * sizeof (*yylsp),
2000 &yystacksize);
2001#else
2002 yyoverflow("parser stack overflow",
2003 &yyss1, size * sizeof (*yyssp),
2004 &yyvs1, size * sizeof (*yyvsp),
2005 &yystacksize);
2006#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002007
Chris Lattneredd9b032006-01-23 23:05:42 +00002008 yyss = yyss1; yyvs = yyvs1;
2009#ifdef YYLSP_NEEDED
2010 yyls = yyls1;
2011#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002012#else /* no yyoverflow */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002013 /* Extend the stack our own way. */
Chris Lattneredd9b032006-01-23 23:05:42 +00002014 if (yystacksize >= YYMAXDEPTH)
2015 {
2016 yyerror("parser stack overflow");
2017 if (yyfree_stacks)
2018 {
2019 free (yyss);
2020 free (yyvs);
2021#ifdef YYLSP_NEEDED
2022 free (yyls);
2023#endif
2024 }
2025 return 2;
2026 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002027 yystacksize *= 2;
Chris Lattneredd9b032006-01-23 23:05:42 +00002028 if (yystacksize > YYMAXDEPTH)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002029 yystacksize = YYMAXDEPTH;
Chris Lattneredd9b032006-01-23 23:05:42 +00002030#ifndef YYSTACK_USE_ALLOCA
2031 yyfree_stacks = 1;
2032#endif
2033 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
2034 __yy_memcpy ((char *)yyss, (char *)yyss1,
2035 size * (unsigned int) sizeof (*yyssp));
2036 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
2037 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
2038 size * (unsigned int) sizeof (*yyvsp));
2039#ifdef YYLSP_NEEDED
2040 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
2041 __yy_memcpy ((char *)yyls, (char *)yyls1,
2042 size * (unsigned int) sizeof (*yylsp));
2043#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002044#endif /* no yyoverflow */
2045
Chris Lattneredd9b032006-01-23 23:05:42 +00002046 yyssp = yyss + size - 1;
2047 yyvsp = yyvs + size - 1;
2048#ifdef YYLSP_NEEDED
2049 yylsp = yyls + size - 1;
2050#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002051
Chris Lattneredd9b032006-01-23 23:05:42 +00002052#if YYDEBUG != 0
2053 if (yydebug)
2054 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2055#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002056
Chris Lattneredd9b032006-01-23 23:05:42 +00002057 if (yyssp >= yyss + yystacksize - 1)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002058 YYABORT;
2059 }
2060
Chris Lattneredd9b032006-01-23 23:05:42 +00002061#if YYDEBUG != 0
2062 if (yydebug)
2063 fprintf(stderr, "Entering state %d\n", yystate);
2064#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002065
2066 goto yybackup;
Chris Lattneredd9b032006-01-23 23:05:42 +00002067 yybackup:
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002068
2069/* Do appropriate processing given the current state. */
2070/* Read a lookahead token if we need one and don't already have one. */
2071/* yyresume: */
2072
2073 /* First try to decide what to do without reference to lookahead token. */
2074
2075 yyn = yypact[yystate];
Chris Lattneredd9b032006-01-23 23:05:42 +00002076 if (yyn == YYFLAG)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002077 goto yydefault;
2078
2079 /* Not known => get a lookahead token if don't already have one. */
2080
Chris Lattneredd9b032006-01-23 23:05:42 +00002081 /* yychar is either YYEMPTY or YYEOF
2082 or a valid token in external form. */
2083
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002084 if (yychar == YYEMPTY)
2085 {
Chris Lattneredd9b032006-01-23 23:05:42 +00002086#if YYDEBUG != 0
2087 if (yydebug)
2088 fprintf(stderr, "Reading a token: ");
2089#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002090 yychar = YYLEX;
2091 }
2092
Chris Lattneredd9b032006-01-23 23:05:42 +00002093 /* Convert token to internal form (in yychar1) for indexing tables with */
2094
2095 if (yychar <= 0) /* This means end of input. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002096 {
Chris Lattneredd9b032006-01-23 23:05:42 +00002097 yychar1 = 0;
2098 yychar = YYEOF; /* Don't call YYLEX any more */
2099
2100#if YYDEBUG != 0
2101 if (yydebug)
2102 fprintf(stderr, "Now at end of input.\n");
2103#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002104 }
2105 else
2106 {
Chris Lattneredd9b032006-01-23 23:05:42 +00002107 yychar1 = YYTRANSLATE(yychar);
2108
2109#if YYDEBUG != 0
2110 if (yydebug)
2111 {
2112 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2113 /* Give the individual parser a way to print the precise meaning
2114 of a token, for further debugging info. */
2115#ifdef YYPRINT
2116 YYPRINT (stderr, yychar, yylval);
2117#endif
2118 fprintf (stderr, ")\n");
2119 }
2120#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002121 }
2122
Chris Lattneredd9b032006-01-23 23:05:42 +00002123 yyn += yychar1;
2124 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002125 goto yydefault;
Chris Lattneredd9b032006-01-23 23:05:42 +00002126
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002127 yyn = yytable[yyn];
Chris Lattneredd9b032006-01-23 23:05:42 +00002128
2129 /* yyn is what to do for this token type in this state.
2130 Negative => reduce, -yyn is rule number.
2131 Positive => shift, yyn is new state.
2132 New state is final state => don't bother to shift,
2133 just return success.
2134 0, or most negative number => error. */
2135
2136 if (yyn < 0)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002137 {
Chris Lattneredd9b032006-01-23 23:05:42 +00002138 if (yyn == YYFLAG)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002139 goto yyerrlab;
2140 yyn = -yyn;
2141 goto yyreduce;
2142 }
Chris Lattneredd9b032006-01-23 23:05:42 +00002143 else if (yyn == 0)
2144 goto yyerrlab;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002145
2146 if (yyn == YYFINAL)
2147 YYACCEPT;
2148
2149 /* Shift the lookahead token. */
Chris Lattneredd9b032006-01-23 23:05:42 +00002150
2151#if YYDEBUG != 0
2152 if (yydebug)
2153 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2154#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002155
2156 /* Discard the token being shifted unless it is eof. */
2157 if (yychar != YYEOF)
2158 yychar = YYEMPTY;
2159
2160 *++yyvsp = yylval;
Chris Lattneredd9b032006-01-23 23:05:42 +00002161#ifdef YYLSP_NEEDED
2162 *++yylsp = yylloc;
2163#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002164
Chris Lattneredd9b032006-01-23 23:05:42 +00002165 /* count tokens shifted since error; after three, turn off error status. */
2166 if (yyerrstatus) yyerrstatus--;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002167
2168 yystate = yyn;
2169 goto yynewstate;
2170
Chris Lattneredd9b032006-01-23 23:05:42 +00002171/* Do the default action for the current state. */
Reid Spencerc8a9faf2006-01-19 01:21:04 +00002172yydefault:
Chris Lattneredd9b032006-01-23 23:05:42 +00002173
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002174 yyn = yydefact[yystate];
2175 if (yyn == 0)
2176 goto yyerrlab;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002177
Chris Lattneredd9b032006-01-23 23:05:42 +00002178/* Do a reduction. yyn is the number of a rule to reduce with. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002179yyreduce:
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002180 yylen = yyr2[yyn];
Chris Lattneredd9b032006-01-23 23:05:42 +00002181 if (yylen > 0)
2182 yyval = yyvsp[1-yylen]; /* implement default value of the action */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002183
Chris Lattneredd9b032006-01-23 23:05:42 +00002184#if YYDEBUG != 0
2185 if (yydebug)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002186 {
Chris Lattneredd9b032006-01-23 23:05:42 +00002187 int i;
2188
2189 fprintf (stderr, "Reducing via rule %d (line %d), ",
2190 yyn, yyrline[yyn]);
2191
2192 /* Print the symbols being reduced, and their result. */
2193 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2194 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2195 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2196 }
2197#endif
2198
2199
2200 switch (yyn) {
2201
2202case 2:
2203#line 998 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2204{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002205 if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX) // Outside of my range!
2206 ThrowException("Value too large for type!");
2207 yyval.SIntVal = (int32_t)yyvsp[0].UIntVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002208;
2209 break;}
2210case 4:
2211#line 1006 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2212{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002213 if (yyvsp[0].UInt64Val > (uint64_t)INT64_MAX) // Outside of my range!
2214 ThrowException("Value too large for type!");
2215 yyval.SInt64Val = (int64_t)yyvsp[0].UInt64Val;
Chris Lattneredd9b032006-01-23 23:05:42 +00002216;
2217 break;}
2218case 33:
2219#line 1029 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2220{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002221 yyval.StrVal = yyvsp[-1].StrVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002222 ;
2223 break;}
2224case 34:
2225#line 1032 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2226{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002227 yyval.StrVal = 0;
Chris Lattneredd9b032006-01-23 23:05:42 +00002228 ;
2229 break;}
2230case 35:
2231#line 1036 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2232{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2233 break;}
2234case 36:
2235#line 1037 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2236{ yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2237 break;}
2238case 37:
2239#line 1038 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2240{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2241 break;}
2242case 38:
2243#line 1039 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2244{ yyval.Linkage = GlobalValue::AppendingLinkage; ;
2245 break;}
2246case 39:
2247#line 1040 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2248{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2249 break;}
2250case 40:
2251#line 1042 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2252{ yyval.UIntVal = CallingConv::C; ;
2253 break;}
2254case 41:
2255#line 1043 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2256{ yyval.UIntVal = CallingConv::C; ;
2257 break;}
2258case 42:
2259#line 1044 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2260{ yyval.UIntVal = CallingConv::Fast; ;
2261 break;}
2262case 43:
2263#line 1045 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2264{ yyval.UIntVal = CallingConv::Cold; ;
2265 break;}
2266case 44:
2267#line 1046 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2268{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002269 if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
2270 ThrowException("Calling conv too large!");
2271 yyval.UIntVal = yyvsp[0].UInt64Val;
Chris Lattneredd9b032006-01-23 23:05:42 +00002272 ;
2273 break;}
2274case 45:
2275#line 1054 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2276{ yyval.UIntVal = 0; ;
2277 break;}
2278case 46:
2279#line 1055 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2280{
Chris Lattner11ca4d62005-11-12 18:22:38 +00002281 yyval.UIntVal = yyvsp[0].UInt64Val;
2282 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
2283 ThrowException("Alignment must be a power of two!");
Chris Lattneredd9b032006-01-23 23:05:42 +00002284;
2285 break;}
2286case 47:
2287#line 1060 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2288{ yyval.UIntVal = 0; ;
2289 break;}
2290case 48:
2291#line 1061 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2292{
Chris Lattner11ca4d62005-11-12 18:22:38 +00002293 yyval.UIntVal = yyvsp[0].UInt64Val;
2294 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
2295 ThrowException("Alignment must be a power of two!");
Chris Lattneredd9b032006-01-23 23:05:42 +00002296;
2297 break;}
2298case 49:
2299#line 1068 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2300{
Chris Lattnera0c20b42005-11-12 00:11:49 +00002301 for (unsigned i = 0, e = strlen(yyvsp[0].StrVal); i != e; ++i)
2302 if (yyvsp[0].StrVal[i] == '"' || yyvsp[0].StrVal[i] == '\\')
2303 ThrowException("Invalid character in section name!");
2304 yyval.StrVal = yyvsp[0].StrVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002305;
2306 break;}
2307case 50:
2308#line 1075 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2309{ yyval.StrVal = 0; ;
2310 break;}
2311case 51:
2312#line 1076 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2313{ yyval.StrVal = yyvsp[0].StrVal; ;
2314 break;}
2315case 52:
2316#line 1081 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2317{;
2318 break;}
2319case 53:
2320#line 1082 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2321{;
2322 break;}
2323case 54:
2324#line 1083 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2325{
Chris Lattner11ca4d62005-11-12 18:22:38 +00002326 CurGV->setSection(yyvsp[0].StrVal);
2327 free(yyvsp[0].StrVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00002328 ;
2329 break;}
2330case 55:
2331#line 1087 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2332{
Chris Lattnera054d122005-12-21 17:53:23 +00002333 if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val))
2334 ThrowException("Alignment must be a power of two!");
Chris Lattner11ca4d62005-11-12 18:22:38 +00002335 CurGV->setAlignment(yyvsp[0].UInt64Val);
Chris Lattneredd9b032006-01-23 23:05:42 +00002336 ;
2337 break;}
2338case 57:
2339#line 1100 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2340{ yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2341 break;}
2342case 59:
2343#line 1101 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2344{ yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2345 break;}
2346case 60:
2347#line 1103 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2348{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002349 if (!UpRefs.empty())
2350 ThrowException("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
2351 yyval.TypeVal = yyvsp[0].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002352 ;
2353 break;}
2354case 74:
2355#line 1114 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2356{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002357 yyval.TypeVal = new PATypeHolder(OpaqueType::get());
Chris Lattneredd9b032006-01-23 23:05:42 +00002358 ;
2359 break;}
2360case 75:
2361#line 1117 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2362{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002363 yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
Chris Lattneredd9b032006-01-23 23:05:42 +00002364 ;
2365 break;}
2366case 76:
2367#line 1120 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2368{ // Named types are also simple types...
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002369 yyval.TypeVal = new PATypeHolder(getTypeVal(yyvsp[0].ValIDVal));
Chris Lattneredd9b032006-01-23 23:05:42 +00002370;
2371 break;}
2372case 77:
2373#line 1126 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2374{ // Type UpReference
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002375 if (yyvsp[0].UInt64Val > (uint64_t)~0U) ThrowException("Value out of range!");
2376 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
2377 UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector...
2378 yyval.TypeVal = new PATypeHolder(OT);
2379 UR_OUT("New Upreference!\n");
Chris Lattneredd9b032006-01-23 23:05:42 +00002380 ;
2381 break;}
2382case 78:
2383#line 1133 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2384{ // Function derived type?
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002385 std::vector<const Type*> Params;
2386 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2387 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2388 Params.push_back(*I);
2389 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
2390 if (isVarArg) Params.pop_back();
2391
2392 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FunctionType::get(*yyvsp[-3].TypeVal,Params,isVarArg)));
2393 delete yyvsp[-1].TypeList; // Delete the argument list
2394 delete yyvsp[-3].TypeVal; // Delete the return type handle
Chris Lattneredd9b032006-01-23 23:05:42 +00002395 ;
2396 break;}
2397case 79:
2398#line 1145 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2399{ // Sized array type?
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002400 yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2401 delete yyvsp[-1].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002402 ;
2403 break;}
2404case 80:
2405#line 1149 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2406{ // Packed array type?
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002407 const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
Chris Lattner625b9c82005-11-10 01:42:43 +00002408 if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002409 ThrowException("Unsigned result not equal to signed result");
Chris Lattner625b9c82005-11-10 01:42:43 +00002410 if (!ElemTy->isPrimitiveType())
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002411 ThrowException("Elemental type of a PackedType must be primitive");
Chris Lattner625b9c82005-11-10 01:42:43 +00002412 if (!isPowerOf2_32(yyvsp[-3].UInt64Val))
2413 ThrowException("Vector length should be a power of 2!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002414 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PackedType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2415 delete yyvsp[-1].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002416 ;
2417 break;}
2418case 81:
2419#line 1160 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2420{ // Structure type?
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002421 std::vector<const Type*> Elements;
2422 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2423 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2424 Elements.push_back(*I);
2425
2426 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
2427 delete yyvsp[-1].TypeList;
Chris Lattneredd9b032006-01-23 23:05:42 +00002428 ;
2429 break;}
2430case 82:
2431#line 1169 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2432{ // Empty structure type?
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002433 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Chris Lattneredd9b032006-01-23 23:05:42 +00002434 ;
2435 break;}
2436case 83:
2437#line 1172 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2438{ // Pointer type?
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002439 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal)));
2440 delete yyvsp[-1].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002441 ;
2442 break;}
2443case 84:
2444#line 1180 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2445{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002446 yyval.TypeList = new std::list<PATypeHolder>();
2447 yyval.TypeList->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002448 ;
2449 break;}
2450case 85:
2451#line 1184 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2452{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002453 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002454 ;
2455 break;}
2456case 87:
2457#line 1190 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2458{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002459 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(Type::VoidTy);
Chris Lattneredd9b032006-01-23 23:05:42 +00002460 ;
2461 break;}
2462case 88:
2463#line 1193 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2464{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002465 (yyval.TypeList = new std::list<PATypeHolder>())->push_back(Type::VoidTy);
Chris Lattneredd9b032006-01-23 23:05:42 +00002466 ;
2467 break;}
2468case 89:
2469#line 1196 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2470{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002471 yyval.TypeList = new std::list<PATypeHolder>();
Chris Lattneredd9b032006-01-23 23:05:42 +00002472 ;
2473 break;}
2474case 90:
2475#line 1206 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2476{ // Nonempty unsized arr
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002477 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
2478 if (ATy == 0)
2479 ThrowException("Cannot make array constant with type: '" +
2480 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2481 const Type *ETy = ATy->getElementType();
2482 int NumElements = ATy->getNumElements();
2483
2484 // Verify that we have the correct size...
2485 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2486 ThrowException("Type mismatch: constant sized array initialized with " +
2487 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
2488 itostr(NumElements) + "!");
2489
2490 // Verify all elements are correct type!
2491 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2492 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2493 ThrowException("Element #" + utostr(i) + " is not of type '" +
2494 ETy->getDescription() +"' as required!\nIt is of type '"+
2495 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2496 }
2497
2498 yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
2499 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Chris Lattneredd9b032006-01-23 23:05:42 +00002500 ;
2501 break;}
2502case 91:
2503#line 1231 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2504{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002505 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2506 if (ATy == 0)
2507 ThrowException("Cannot make array constant with type: '" +
2508 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2509
2510 int NumElements = ATy->getNumElements();
2511 if (NumElements != -1 && NumElements != 0)
2512 ThrowException("Type mismatch: constant sized array initialized with 0"
2513 " arguments, but has size of " + itostr(NumElements) +"!");
2514 yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
2515 delete yyvsp[-2].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002516 ;
2517 break;}
2518case 92:
2519#line 1244 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2520{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002521 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2522 if (ATy == 0)
2523 ThrowException("Cannot make array constant with type: '" +
2524 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2525
2526 int NumElements = ATy->getNumElements();
2527 const Type *ETy = ATy->getElementType();
2528 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
2529 if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal))
2530 ThrowException("Can't build string constant of size " +
2531 itostr((int)(EndStr-yyvsp[0].StrVal)) +
2532 " when array has size " + itostr(NumElements) + "!");
2533 std::vector<Constant*> Vals;
2534 if (ETy == Type::SByteTy) {
2535 for (char *C = yyvsp[0].StrVal; C != EndStr; ++C)
2536 Vals.push_back(ConstantSInt::get(ETy, *C));
2537 } else if (ETy == Type::UByteTy) {
2538 for (char *C = yyvsp[0].StrVal; C != EndStr; ++C)
2539 Vals.push_back(ConstantUInt::get(ETy, (unsigned char)*C));
2540 } else {
2541 free(yyvsp[0].StrVal);
2542 ThrowException("Cannot build string arrays of non byte sized elements!");
2543 }
2544 free(yyvsp[0].StrVal);
2545 yyval.ConstVal = ConstantArray::get(ATy, Vals);
2546 delete yyvsp[-2].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002547 ;
2548 break;}
2549case 93:
2550#line 1272 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2551{ // Nonempty unsized arr
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002552 const PackedType *PTy = dyn_cast<PackedType>(yyvsp[-3].TypeVal->get());
2553 if (PTy == 0)
2554 ThrowException("Cannot make packed constant with type: '" +
2555 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2556 const Type *ETy = PTy->getElementType();
2557 int NumElements = PTy->getNumElements();
2558
2559 // Verify that we have the correct size...
2560 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2561 ThrowException("Type mismatch: constant sized packed initialized with " +
2562 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
2563 itostr(NumElements) + "!");
2564
2565 // Verify all elements are correct type!
2566 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2567 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2568 ThrowException("Element #" + utostr(i) + " is not of type '" +
2569 ETy->getDescription() +"' as required!\nIt is of type '"+
2570 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2571 }
2572
2573 yyval.ConstVal = ConstantPacked::get(PTy, *yyvsp[-1].ConstVector);
2574 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Chris Lattneredd9b032006-01-23 23:05:42 +00002575 ;
2576 break;}
2577case 94:
2578#line 1297 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2579{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002580 const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
2581 if (STy == 0)
2582 ThrowException("Cannot make struct constant with type: '" +
2583 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2584
2585 if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
2586 ThrowException("Illegal number of initializers for structure type!");
2587
2588 // Check to ensure that constants are compatible with the type initializer!
2589 for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
2590 if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
2591 ThrowException("Expected type '" +
2592 STy->getElementType(i)->getDescription() +
2593 "' for element #" + utostr(i) +
2594 " of structure initializer!");
2595
2596 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
2597 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Chris Lattneredd9b032006-01-23 23:05:42 +00002598 ;
2599 break;}
2600case 95:
2601#line 1317 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2602{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002603 const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
2604 if (STy == 0)
2605 ThrowException("Cannot make struct constant with type: '" +
2606 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2607
2608 if (STy->getNumContainedTypes() != 0)
2609 ThrowException("Illegal number of initializers for structure type!");
2610
2611 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
2612 delete yyvsp[-2].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002613 ;
2614 break;}
2615case 96:
2616#line 1329 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2617{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002618 const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
2619 if (PTy == 0)
2620 ThrowException("Cannot make null pointer constant with type: '" +
2621 (*yyvsp[-1].TypeVal)->getDescription() + "'!");
2622
2623 yyval.ConstVal = ConstantPointerNull::get(PTy);
2624 delete yyvsp[-1].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002625 ;
2626 break;}
2627case 97:
2628#line 1338 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2629{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002630 yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
2631 delete yyvsp[-1].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002632 ;
2633 break;}
2634case 98:
2635#line 1342 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2636{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002637 const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
2638 if (Ty == 0)
2639 ThrowException("Global const reference must be a pointer type!");
2640
2641 // ConstExprs can exist in the body of a function, thus creating
2642 // GlobalValues whenever they refer to a variable. Because we are in
2643 // the context of a function, getValNonImprovising will search the functions
2644 // symbol table instead of the module symbol table for the global symbol,
2645 // which throws things all off. To get around this, we just tell
2646 // getValNonImprovising that we are at global scope here.
2647 //
2648 Function *SavedCurFn = CurFun.CurrentFunction;
2649 CurFun.CurrentFunction = 0;
2650
2651 Value *V = getValNonImprovising(Ty, yyvsp[0].ValIDVal);
2652
2653 CurFun.CurrentFunction = SavedCurFn;
2654
2655 // If this is an initializer for a constant pointer, which is referencing a
2656 // (currently) undefined variable, create a stub now that shall be replaced
2657 // in the future with the right type of variable.
2658 //
2659 if (V == 0) {
2660 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
2661 const PointerType *PT = cast<PointerType>(Ty);
2662
2663 // First check to see if the forward references value is already created!
2664 PerModuleInfo::GlobalRefsType::iterator I =
2665 CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
2666
2667 if (I != CurModule.GlobalRefs.end()) {
2668 V = I->second; // Placeholder already exists, use it...
2669 yyvsp[0].ValIDVal.destroy();
2670 } else {
2671 std::string Name;
2672 if (yyvsp[0].ValIDVal.Type == ValID::NameVal) Name = yyvsp[0].ValIDVal.Name;
2673
2674 // Create the forward referenced global.
2675 GlobalValue *GV;
2676 if (const FunctionType *FTy =
2677 dyn_cast<FunctionType>(PT->getElementType())) {
2678 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
2679 CurModule.CurrentModule);
2680 } else {
2681 GV = new GlobalVariable(PT->getElementType(), false,
2682 GlobalValue::ExternalLinkage, 0,
2683 Name, CurModule.CurrentModule);
2684 }
2685
2686 // Keep track of the fact that we have a forward ref to recycle it
2687 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
2688 V = GV;
2689 }
2690 }
2691
2692 yyval.ConstVal = cast<GlobalValue>(V);
2693 delete yyvsp[-1].TypeVal; // Free the type handle
Chris Lattneredd9b032006-01-23 23:05:42 +00002694 ;
2695 break;}
2696case 99:
2697#line 1401 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2698{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002699 if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
2700 ThrowException("Mismatched types for constant expression!");
2701 yyval.ConstVal = yyvsp[0].ConstVal;
2702 delete yyvsp[-1].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002703 ;
2704 break;}
2705case 100:
2706#line 1407 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2707{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002708 const Type *Ty = yyvsp[-1].TypeVal->get();
2709 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
2710 ThrowException("Cannot create a null initialized value of this type!");
2711 yyval.ConstVal = Constant::getNullValue(Ty);
2712 delete yyvsp[-1].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002713 ;
2714 break;}
2715case 101:
2716#line 1415 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2717{ // integral constants
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002718 if (!ConstantSInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
2719 ThrowException("Constant value doesn't fit in type!");
2720 yyval.ConstVal = ConstantSInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val);
Chris Lattneredd9b032006-01-23 23:05:42 +00002721 ;
2722 break;}
2723case 102:
2724#line 1420 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2725{ // integral constants
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002726 if (!ConstantUInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
2727 ThrowException("Constant value doesn't fit in type!");
2728 yyval.ConstVal = ConstantUInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val);
Chris Lattneredd9b032006-01-23 23:05:42 +00002729 ;
2730 break;}
2731case 103:
2732#line 1425 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2733{ // Boolean constants
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002734 yyval.ConstVal = ConstantBool::True;
Chris Lattneredd9b032006-01-23 23:05:42 +00002735 ;
2736 break;}
2737case 104:
2738#line 1428 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2739{ // Boolean constants
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002740 yyval.ConstVal = ConstantBool::False;
Chris Lattneredd9b032006-01-23 23:05:42 +00002741 ;
2742 break;}
2743case 105:
2744#line 1431 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2745{ // Float & Double constants
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002746 if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal))
2747 ThrowException("Floating point constant invalid for type!!");
2748 yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00002749 ;
2750 break;}
2751case 106:
2752#line 1438 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2753{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002754 if (!yyvsp[-3].ConstVal->getType()->isFirstClassType())
2755 ThrowException("cast constant expression from a non-primitive type: '" +
2756 yyvsp[-3].ConstVal->getType()->getDescription() + "'!");
2757 if (!yyvsp[-1].TypeVal->get()->isFirstClassType())
2758 ThrowException("cast constant expression to a non-primitive type: '" +
2759 yyvsp[-1].TypeVal->get()->getDescription() + "'!");
2760 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-3].ConstVal, yyvsp[-1].TypeVal->get());
2761 delete yyvsp[-1].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002762 ;
2763 break;}
2764case 107:
2765#line 1448 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2766{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002767 if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
2768 ThrowException("GetElementPtr requires a pointer operand!");
2769
2770 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
2771 // indices to uint struct indices for compatibility.
2772 generic_gep_type_iterator<std::vector<Value*>::iterator>
2773 GTI = gep_type_begin(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end()),
2774 GTE = gep_type_end(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end());
2775 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
2776 if (isa<StructType>(*GTI)) // Only change struct indices
2777 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[-1].ValueList)[i]))
2778 if (CUI->getType() == Type::UByteTy)
2779 (*yyvsp[-1].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
2780
2781 const Type *IdxTy =
2782 GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), *yyvsp[-1].ValueList, true);
2783 if (!IdxTy)
2784 ThrowException("Index list invalid for constant getelementptr!");
2785
2786 std::vector<Constant*> IdxVec;
2787 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
2788 if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
2789 IdxVec.push_back(C);
2790 else
2791 ThrowException("Indices to constant getelementptr must be constants!");
2792
2793 delete yyvsp[-1].ValueList;
2794
2795 yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, IdxVec);
Chris Lattneredd9b032006-01-23 23:05:42 +00002796 ;
2797 break;}
2798case 108:
2799#line 1479 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2800{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002801 if (yyvsp[-5].ConstVal->getType() != Type::BoolTy)
2802 ThrowException("Select condition must be of boolean type!");
2803 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2804 ThrowException("Select operand types must match!");
2805 yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00002806 ;
2807 break;}
2808case 109:
2809#line 1486 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2810{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002811 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2812 ThrowException("Binary operator types must match!");
2813 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
2814 // To retain backward compatibility with these early compilers, we emit a
2815 // cast to the appropriate integer type automatically if we are in the
2816 // broken case. See PR424 for more information.
2817 if (!isa<PointerType>(yyvsp[-3].ConstVal->getType())) {
2818 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2819 } else {
2820 const Type *IntPtrTy = 0;
2821 switch (CurModule.CurrentModule->getPointerSize()) {
2822 case Module::Pointer32: IntPtrTy = Type::IntTy; break;
2823 case Module::Pointer64: IntPtrTy = Type::LongTy; break;
2824 default: ThrowException("invalid pointer binary constant expr!");
2825 }
2826 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, ConstantExpr::getCast(yyvsp[-3].ConstVal, IntPtrTy),
2827 ConstantExpr::getCast(yyvsp[-1].ConstVal, IntPtrTy));
2828 yyval.ConstVal = ConstantExpr::getCast(yyval.ConstVal, yyvsp[-3].ConstVal->getType());
2829 }
Chris Lattneredd9b032006-01-23 23:05:42 +00002830 ;
2831 break;}
2832case 110:
2833#line 1507 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2834{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002835 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2836 ThrowException("Logical operator types must match!");
Chris Lattner15f5a182005-12-21 18:31:50 +00002837 if (!yyvsp[-3].ConstVal->getType()->isIntegral()) {
2838 if (!isa<PackedType>(yyvsp[-3].ConstVal->getType()) ||
2839 !cast<PackedType>(yyvsp[-3].ConstVal->getType())->getElementType()->isIntegral())
2840 ThrowException("Logical operator requires integral operands!");
2841 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002842 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00002843 ;
2844 break;}
2845case 111:
2846#line 1517 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2847{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002848 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2849 ThrowException("setcc operand types must match!");
2850 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00002851 ;
2852 break;}
2853case 112:
2854#line 1522 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2855{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002856 if (yyvsp[-1].ConstVal->getType() != Type::UByteTy)
2857 ThrowException("Shift count for shift constant must be unsigned byte!");
2858 if (!yyvsp[-3].ConstVal->getType()->isInteger())
2859 ThrowException("Shift constant expression requires integer operand!");
2860 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].OtherOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00002861 ;
2862 break;}
2863case 113:
2864#line 1529 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2865{
Robert Bocchinoaa1cf542006-01-10 19:04:32 +00002866 if (!isa<PackedType>(yyvsp[-3].ConstVal->getType()))
2867 ThrowException("First operand of extractelement must be "
2868 "packed type!");
2869 if (yyvsp[-1].ConstVal->getType() != Type::UIntTy)
2870 ThrowException("Second operand of extractelement must be uint!");
2871 yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00002872 ;
2873 break;}
2874case 114:
2875#line 1539 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2876{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002877 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00002878 ;
2879 break;}
2880case 115:
2881#line 1542 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2882{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002883 yyval.ConstVector = new std::vector<Constant*>();
2884 yyval.ConstVector->push_back(yyvsp[0].ConstVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00002885 ;
2886 break;}
2887case 116:
2888#line 1549 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2889{ yyval.BoolVal = false; ;
2890 break;}
2891case 117:
2892#line 1549 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2893{ yyval.BoolVal = true; ;
2894 break;}
2895case 118:
2896#line 1559 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2897{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002898 yyval.ModuleVal = ParserResult = yyvsp[0].ModuleVal;
2899 CurModule.ModuleDone();
Chris Lattneredd9b032006-01-23 23:05:42 +00002900;
2901 break;}
2902case 119:
2903#line 1566 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2904{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002905 yyval.ModuleVal = yyvsp[-1].ModuleVal;
2906 CurFun.FunctionDone();
Chris Lattneredd9b032006-01-23 23:05:42 +00002907 ;
2908 break;}
2909case 120:
2910#line 1570 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2911{
Chris Lattner15f5a182005-12-21 18:31:50 +00002912 yyval.ModuleVal = yyvsp[-1].ModuleVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002913 ;
2914 break;}
2915case 121:
2916#line 1573 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2917{
2918 yyval.ModuleVal = yyvsp[-2].ModuleVal;
2919 ;
2920 break;}
2921case 122:
2922#line 1576 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2923{
Robert Bocchinoaa1cf542006-01-10 19:04:32 +00002924 yyval.ModuleVal = yyvsp[-1].ModuleVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002925 ;
2926 break;}
2927case 123:
2928#line 1579 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2929{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002930 yyval.ModuleVal = CurModule.CurrentModule;
2931 // Emit an error if there are any unresolved types left.
2932 if (!CurModule.LateResolveTypes.empty()) {
2933 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
2934 if (DID.Type == ValID::NameVal)
2935 ThrowException("Reference to an undefined type: '"+DID.getName() + "'");
2936 else
2937 ThrowException("Reference to an undefined type: #" + itostr(DID.Num));
2938 }
Chris Lattneredd9b032006-01-23 23:05:42 +00002939 ;
2940 break;}
2941case 124:
2942#line 1592 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2943{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002944 // Eagerly resolve types. This is not an optimization, this is a
2945 // requirement that is due to the fact that we could have this:
2946 //
2947 // %list = type { %list * }
2948 // %list = type { %list * } ; repeated type decl
2949 //
2950 // If types are not resolved eagerly, then the two types will not be
2951 // determined to be the same type!
2952 //
2953 ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
2954
2955 if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
2956 // If this is a named type that is not a redefinition, add it to the slot
2957 // table.
2958 CurModule.Types.push_back(*yyvsp[0].TypeVal);
2959 }
2960
2961 delete yyvsp[0].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002962 ;
2963 break;}
2964case 125:
2965#line 1612 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2966{ // Function prototypes can be in const pool
2967 ;
2968 break;}
2969case 126:
2970#line 1614 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2971{ // Asm blocks can be in the const pool
2972 ;
2973 break;}
2974case 127:
2975#line 1616 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2976{
Chris Lattner11ca4d62005-11-12 18:22:38 +00002977 if (yyvsp[0].ConstVal == 0) ThrowException("Global value initializer is not a constant!");
2978 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, yyvsp[-2].Linkage, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00002979 ;
2980 break;}
2981case 128:
2982#line 1619 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2983{
Chris Lattner11ca4d62005-11-12 18:22:38 +00002984 CurGV = 0;
Chris Lattneredd9b032006-01-23 23:05:42 +00002985 ;
2986 break;}
2987case 129:
2988#line 1622 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2989{
Chris Lattner11ca4d62005-11-12 18:22:38 +00002990 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalLinkage,
2991 yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0);
2992 delete yyvsp[0].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00002993 ;
2994 break;}
2995case 130:
2996#line 1626 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2997{
Chris Lattner11ca4d62005-11-12 18:22:38 +00002998 CurGV = 0;
Chris Lattneredd9b032006-01-23 23:05:42 +00002999 ;
3000 break;}
3001case 131:
3002#line 1629 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3003{
3004 ;
3005 break;}
3006case 132:
3007#line 1631 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3008{
3009 ;
3010 break;}
3011case 133:
3012#line 1633 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3013{
3014 ;
3015 break;}
3016case 134:
3017#line 1637 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3018{
3019 const std::string &AsmSoFar = CurModule.CurrentModule->getInlineAsm();
3020 if (AsmSoFar.empty())
3021 CurModule.CurrentModule->setInlineAsm(yyvsp[0].StrVal);
3022 else
3023 CurModule.CurrentModule->setInlineAsm(AsmSoFar+"\n"+yyvsp[0].StrVal);
3024 free(yyvsp[0].StrVal);
3025;
3026 break;}
3027case 135:
3028#line 1646 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3029{ yyval.Endianness = Module::BigEndian; ;
3030 break;}
3031case 136:
3032#line 1647 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3033{ yyval.Endianness = Module::LittleEndian; ;
3034 break;}
3035case 137:
3036#line 1649 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3037{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003038 CurModule.CurrentModule->setEndianness(yyvsp[0].Endianness);
Chris Lattneredd9b032006-01-23 23:05:42 +00003039 ;
3040 break;}
3041case 138:
3042#line 1652 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3043{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003044 if (yyvsp[0].UInt64Val == 32)
3045 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
3046 else if (yyvsp[0].UInt64Val == 64)
3047 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
3048 else
3049 ThrowException("Invalid pointer size: '" + utostr(yyvsp[0].UInt64Val) + "'!");
Chris Lattneredd9b032006-01-23 23:05:42 +00003050 ;
3051 break;}
3052case 139:
3053#line 1660 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3054{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003055 CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal);
3056 free(yyvsp[0].StrVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003057 ;
3058 break;}
3059case 141:
3060#line 1667 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3061{
Chris Lattnera0c20b42005-11-12 00:11:49 +00003062 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3063 free(yyvsp[0].StrVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003064 ;
3065 break;}
3066case 142:
3067#line 1671 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3068{
Robert Bocchinoaa1cf542006-01-10 19:04:32 +00003069 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3070 free(yyvsp[0].StrVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003071 ;
3072 break;}
3073case 143:
3074#line 1675 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3075{
3076 ;
3077 break;}
3078case 147:
3079#line 1684 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3080{ yyval.StrVal = 0; ;
3081 break;}
3082case 148:
3083#line 1686 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3084{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003085 if (*yyvsp[-1].TypeVal == Type::VoidTy)
3086 ThrowException("void typed arguments are invalid!");
3087 yyval.ArgVal = new std::pair<PATypeHolder*, char*>(yyvsp[-1].TypeVal, yyvsp[0].StrVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003088;
3089 break;}
3090case 149:
3091#line 1692 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3092{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003093 yyval.ArgList = yyvsp[-2].ArgList;
3094 yyvsp[-2].ArgList->push_back(*yyvsp[0].ArgVal);
3095 delete yyvsp[0].ArgVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003096 ;
3097 break;}
3098case 150:
3099#line 1697 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3100{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003101 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
3102 yyval.ArgList->push_back(*yyvsp[0].ArgVal);
3103 delete yyvsp[0].ArgVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003104 ;
3105 break;}
3106case 151:
3107#line 1703 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3108{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003109 yyval.ArgList = yyvsp[0].ArgList;
Chris Lattneredd9b032006-01-23 23:05:42 +00003110 ;
3111 break;}
3112case 152:
3113#line 1706 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3114{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003115 yyval.ArgList = yyvsp[-2].ArgList;
3116 yyval.ArgList->push_back(std::pair<PATypeHolder*,
3117 char*>(new PATypeHolder(Type::VoidTy), 0));
Chris Lattneredd9b032006-01-23 23:05:42 +00003118 ;
3119 break;}
3120case 153:
3121#line 1711 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3122{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003123 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
3124 yyval.ArgList->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0));
Chris Lattneredd9b032006-01-23 23:05:42 +00003125 ;
3126 break;}
3127case 154:
3128#line 1715 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3129{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003130 yyval.ArgList = 0;
Chris Lattneredd9b032006-01-23 23:05:42 +00003131 ;
3132 break;}
3133case 155:
3134#line 1720 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3135{
Chris Lattnera0c20b42005-11-12 00:11:49 +00003136 UnEscapeLexed(yyvsp[-5].StrVal);
3137 std::string FunctionName(yyvsp[-5].StrVal);
3138 free(yyvsp[-5].StrVal); // Free strdup'd memory!
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003139
Chris Lattnera0c20b42005-11-12 00:11:49 +00003140 if (!(*yyvsp[-6].TypeVal)->isFirstClassType() && *yyvsp[-6].TypeVal != Type::VoidTy)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003141 ThrowException("LLVM functions cannot return aggregate types!");
3142
3143 std::vector<const Type*> ParamTypeList;
Chris Lattnera0c20b42005-11-12 00:11:49 +00003144 if (yyvsp[-3].ArgList) { // If there are arguments...
3145 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-3].ArgList->begin();
3146 I != yyvsp[-3].ArgList->end(); ++I)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003147 ParamTypeList.push_back(I->first->get());
3148 }
3149
3150 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
3151 if (isVarArg) ParamTypeList.pop_back();
3152
Chris Lattnera0c20b42005-11-12 00:11:49 +00003153 const FunctionType *FT = FunctionType::get(*yyvsp[-6].TypeVal, ParamTypeList, isVarArg);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003154 const PointerType *PFT = PointerType::get(FT);
Chris Lattnera0c20b42005-11-12 00:11:49 +00003155 delete yyvsp[-6].TypeVal;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003156
3157 ValID ID;
3158 if (!FunctionName.empty()) {
3159 ID = ValID::create((char*)FunctionName.c_str());
3160 } else {
3161 ID = ValID::create((int)CurModule.Values[PFT].size());
3162 }
3163
3164 Function *Fn = 0;
3165 // See if this function was forward referenced. If so, recycle the object.
3166 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
3167 // Move the function to the end of the list, from whereever it was
3168 // previously inserted.
3169 Fn = cast<Function>(FWRef);
3170 CurModule.CurrentModule->getFunctionList().remove(Fn);
3171 CurModule.CurrentModule->getFunctionList().push_back(Fn);
3172 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
3173 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
3174 // If this is the case, either we need to be a forward decl, or it needs
3175 // to be.
3176 if (!CurFun.isDeclare && !Fn->isExternal())
3177 ThrowException("Redefinition of function '" + FunctionName + "'!");
3178
3179 // Make sure to strip off any argument names so we can't get conflicts.
3180 if (Fn->isExternal())
3181 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
3182 AI != AE; ++AI)
3183 AI->setName("");
3184
3185 } else { // Not already defined?
3186 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
3187 CurModule.CurrentModule);
3188 InsertValue(Fn, CurModule.Values);
3189 }
3190
3191 CurFun.FunctionStart(Fn);
Chris Lattnera0c20b42005-11-12 00:11:49 +00003192 Fn->setCallingConv(yyvsp[-7].UIntVal);
Chris Lattner840f7892005-11-06 06:46:53 +00003193 Fn->setAlignment(yyvsp[0].UIntVal);
Chris Lattnera0c20b42005-11-12 00:11:49 +00003194 if (yyvsp[-1].StrVal) {
3195 Fn->setSection(yyvsp[-1].StrVal);
3196 free(yyvsp[-1].StrVal);
3197 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003198
3199 // Add all of the arguments we parsed to the function...
Chris Lattnera0c20b42005-11-12 00:11:49 +00003200 if (yyvsp[-3].ArgList) { // Is null if empty...
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003201 if (isVarArg) { // Nuke the last entry
Chris Lattnera0c20b42005-11-12 00:11:49 +00003202 assert(yyvsp[-3].ArgList->back().first->get() == Type::VoidTy && yyvsp[-3].ArgList->back().second == 0&&
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003203 "Not a varargs marker!");
Chris Lattnera0c20b42005-11-12 00:11:49 +00003204 delete yyvsp[-3].ArgList->back().first;
3205 yyvsp[-3].ArgList->pop_back(); // Delete the last entry
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003206 }
3207 Function::arg_iterator ArgIt = Fn->arg_begin();
Chris Lattnera0c20b42005-11-12 00:11:49 +00003208 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-3].ArgList->begin();
3209 I != yyvsp[-3].ArgList->end(); ++I, ++ArgIt) {
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003210 delete I->first; // Delete the typeholder...
3211
3212 setValueName(ArgIt, I->second); // Insert arg into symtab...
3213 InsertValue(ArgIt);
3214 }
3215
Chris Lattnera0c20b42005-11-12 00:11:49 +00003216 delete yyvsp[-3].ArgList; // We're now done with the argument list
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003217 }
Chris Lattneredd9b032006-01-23 23:05:42 +00003218;
3219 break;}
3220case 158:
3221#line 1807 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3222{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003223 yyval.FunctionVal = CurFun.CurrentFunction;
3224
3225 // Make sure that we keep track of the linkage type even if there was a
3226 // previous "declare".
3227 yyval.FunctionVal->setLinkage(yyvsp[-2].Linkage);
Chris Lattneredd9b032006-01-23 23:05:42 +00003228;
3229 break;}
3230case 161:
3231#line 1817 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3232{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003233 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003234;
3235 break;}
3236case 162:
3237#line 1821 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3238{ CurFun.isDeclare = true; ;
3239 break;}
3240case 163:
3241#line 1821 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3242{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003243 yyval.FunctionVal = CurFun.CurrentFunction;
3244 CurFun.FunctionDone();
Chris Lattneredd9b032006-01-23 23:05:42 +00003245;
3246 break;}
3247case 164:
3248#line 1830 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3249{ // A reference to a direct constant
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003250 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
Chris Lattneredd9b032006-01-23 23:05:42 +00003251 ;
3252 break;}
3253case 165:
3254#line 1833 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3255{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003256 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
Chris Lattneredd9b032006-01-23 23:05:42 +00003257 ;
3258 break;}
3259case 166:
3260#line 1836 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3261{ // Perhaps it's an FP constant?
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003262 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003263 ;
3264 break;}
3265case 167:
3266#line 1839 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3267{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003268 yyval.ValIDVal = ValID::create(ConstantBool::True);
Chris Lattneredd9b032006-01-23 23:05:42 +00003269 ;
3270 break;}
3271case 168:
3272#line 1842 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3273{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003274 yyval.ValIDVal = ValID::create(ConstantBool::False);
Chris Lattneredd9b032006-01-23 23:05:42 +00003275 ;
3276 break;}
3277case 169:
3278#line 1845 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3279{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003280 yyval.ValIDVal = ValID::createNull();
Chris Lattneredd9b032006-01-23 23:05:42 +00003281 ;
3282 break;}
3283case 170:
3284#line 1848 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3285{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003286 yyval.ValIDVal = ValID::createUndef();
Chris Lattneredd9b032006-01-23 23:05:42 +00003287 ;
3288 break;}
3289case 171:
3290#line 1851 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3291{ // A vector zero constant.
Chris Lattnera054d122005-12-21 17:53:23 +00003292 yyval.ValIDVal = ValID::createZeroInit();
Chris Lattneredd9b032006-01-23 23:05:42 +00003293 ;
3294 break;}
3295case 172:
3296#line 1854 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3297{ // Nonempty unsized packed vector
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003298 const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
3299 int NumElements = yyvsp[-1].ConstVector->size();
3300
3301 PackedType* pt = PackedType::get(ETy, NumElements);
3302 PATypeHolder* PTy = new PATypeHolder(
3303 HandleUpRefs(
3304 PackedType::get(
3305 ETy,
3306 NumElements)
3307 )
3308 );
3309
3310 // Verify all elements are correct type!
3311 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3312 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
3313 ThrowException("Element #" + utostr(i) + " is not of type '" +
3314 ETy->getDescription() +"' as required!\nIt is of type '" +
3315 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
3316 }
3317
3318 yyval.ValIDVal = ValID::create(ConstantPacked::get(pt, *yyvsp[-1].ConstVector));
3319 delete PTy; delete yyvsp[-1].ConstVector;
Chris Lattneredd9b032006-01-23 23:05:42 +00003320 ;
3321 break;}
3322case 173:
3323#line 1878 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3324{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003325 yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003326 ;
3327 break;}
3328case 174:
3329#line 1885 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3330{ // Is it an integer reference...?
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003331 yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003332 ;
3333 break;}
3334case 175:
3335#line 1888 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3336{ // Is it a named reference...?
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003337 yyval.ValIDVal = ValID::create(yyvsp[0].StrVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003338 ;
3339 break;}
3340case 178:
3341#line 1899 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3342{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003343 yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); delete yyvsp[-1].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003344 ;
3345 break;}
3346case 179:
3347#line 1903 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3348{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003349 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003350 ;
3351 break;}
3352case 180:
3353#line 1906 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3354{ // Do not allow functions with 0 basic blocks
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003355 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003356 ;
3357 break;}
3358case 181:
3359#line 1914 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3360{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003361 setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
3362 InsertValue(yyvsp[0].TermInstVal);
3363
3364 yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
3365 InsertValue(yyvsp[-2].BasicBlockVal);
3366 yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003367 ;
3368 break;}
3369case 182:
3370#line 1923 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3371{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003372 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
3373 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003374 ;
3375 break;}
3376case 183:
3377#line 1927 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3378{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003379 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
3380
3381 // Make sure to move the basic block to the correct location in the
3382 // function, instead of leaving it inserted wherever it was first
3383 // referenced.
3384 Function::BasicBlockListType &BBL =
3385 CurFun.CurrentFunction->getBasicBlockList();
3386 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003387 ;
3388 break;}
3389case 184:
3390#line 1937 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3391{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003392 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create(yyvsp[0].StrVal), true);
3393
3394 // Make sure to move the basic block to the correct location in the
3395 // function, instead of leaving it inserted wherever it was first
3396 // referenced.
3397 Function::BasicBlockListType &BBL =
3398 CurFun.CurrentFunction->getBasicBlockList();
3399 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003400 ;
3401 break;}
3402case 185:
3403#line 1948 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3404{ // Return with a result...
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003405 yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003406 ;
3407 break;}
3408case 186:
3409#line 1951 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3410{ // Return with no result...
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003411 yyval.TermInstVal = new ReturnInst();
Chris Lattneredd9b032006-01-23 23:05:42 +00003412 ;
3413 break;}
3414case 187:
3415#line 1954 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3416{ // Unconditional Branch...
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003417 yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[0].ValIDVal));
Chris Lattneredd9b032006-01-23 23:05:42 +00003418 ;
3419 break;}
3420case 188:
3421#line 1957 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3422{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003423 yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[-3].ValIDVal), getBBVal(yyvsp[0].ValIDVal), getVal(Type::BoolTy, yyvsp[-6].ValIDVal));
Chris Lattneredd9b032006-01-23 23:05:42 +00003424 ;
3425 break;}
3426case 189:
3427#line 1960 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3428{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003429 SwitchInst *S = new SwitchInst(getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal), getBBVal(yyvsp[-3].ValIDVal), yyvsp[-1].JumpTable->size());
3430 yyval.TermInstVal = S;
3431
3432 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
3433 E = yyvsp[-1].JumpTable->end();
3434 for (; I != E; ++I) {
3435 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
3436 S->addCase(CI, I->second);
3437 else
3438 ThrowException("Switch case is constant, but not a simple integer!");
3439 }
3440 delete yyvsp[-1].JumpTable;
Chris Lattneredd9b032006-01-23 23:05:42 +00003441 ;
3442 break;}
3443case 190:
3444#line 1974 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3445{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003446 SwitchInst *S = new SwitchInst(getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal), getBBVal(yyvsp[-2].ValIDVal), 0);
3447 yyval.TermInstVal = S;
Chris Lattneredd9b032006-01-23 23:05:42 +00003448 ;
3449 break;}
3450case 191:
3451#line 1979 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3452{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003453 const PointerType *PFTy;
3454 const FunctionType *Ty;
3455
3456 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-10].TypeVal->get())) ||
3457 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3458 // Pull out the types of all of the arguments...
3459 std::vector<const Type*> ParamTypes;
3460 if (yyvsp[-7].ValueList) {
3461 for (std::vector<Value*>::iterator I = yyvsp[-7].ValueList->begin(), E = yyvsp[-7].ValueList->end();
3462 I != E; ++I)
3463 ParamTypes.push_back((*I)->getType());
3464 }
3465
3466 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3467 if (isVarArg) ParamTypes.pop_back();
3468
3469 Ty = FunctionType::get(yyvsp[-10].TypeVal->get(), ParamTypes, isVarArg);
3470 PFTy = PointerType::get(Ty);
3471 }
3472
3473 Value *V = getVal(PFTy, yyvsp[-9].ValIDVal); // Get the function we're calling...
3474
3475 BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
3476 BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
3477
3478 // Create the call node...
3479 if (!yyvsp[-7].ValueList) { // Has no arguments?
3480 yyval.TermInstVal = new InvokeInst(V, Normal, Except, std::vector<Value*>());
3481 } else { // Has arguments?
3482 // Loop through FunctionType's arguments and ensure they are specified
3483 // correctly!
3484 //
3485 FunctionType::param_iterator I = Ty->param_begin();
3486 FunctionType::param_iterator E = Ty->param_end();
3487 std::vector<Value*>::iterator ArgI = yyvsp[-7].ValueList->begin(), ArgE = yyvsp[-7].ValueList->end();
3488
3489 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3490 if ((*ArgI)->getType() != *I)
3491 ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
3492 (*I)->getDescription() + "'!");
3493
3494 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
3495 ThrowException("Invalid number of parameters detected!");
3496
3497 yyval.TermInstVal = new InvokeInst(V, Normal, Except, *yyvsp[-7].ValueList);
3498 }
3499 cast<InvokeInst>(yyval.TermInstVal)->setCallingConv(yyvsp[-11].UIntVal);
3500
3501 delete yyvsp[-10].TypeVal;
3502 delete yyvsp[-7].ValueList;
Chris Lattneredd9b032006-01-23 23:05:42 +00003503 ;
3504 break;}
3505case 192:
3506#line 2031 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3507{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003508 yyval.TermInstVal = new UnwindInst();
Chris Lattneredd9b032006-01-23 23:05:42 +00003509 ;
3510 break;}
3511case 193:
3512#line 2034 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3513{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003514 yyval.TermInstVal = new UnreachableInst();
Chris Lattneredd9b032006-01-23 23:05:42 +00003515 ;
3516 break;}
3517case 194:
3518#line 2040 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3519{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003520 yyval.JumpTable = yyvsp[-5].JumpTable;
3521 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
3522 if (V == 0)
3523 ThrowException("May only switch on a constant pool value!");
3524
3525 yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
Chris Lattneredd9b032006-01-23 23:05:42 +00003526 ;
3527 break;}
3528case 195:
3529#line 2048 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3530{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003531 yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
3532 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
3533
3534 if (V == 0)
3535 ThrowException("May only switch on a constant pool value!");
3536
3537 yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
Chris Lattneredd9b032006-01-23 23:05:42 +00003538 ;
3539 break;}
3540case 196:
3541#line 2058 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3542{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003543 // Is this definition named?? if so, assign the name...
3544 setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
3545 InsertValue(yyvsp[0].InstVal);
3546 yyval.InstVal = yyvsp[0].InstVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003547;
3548 break;}
3549case 197:
3550#line 2065 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3551{ // Used for PHI nodes
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003552 yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
3553 yyval.PHIList->push_back(std::make_pair(getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal), getBBVal(yyvsp[-1].ValIDVal)));
3554 delete yyvsp[-5].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003555 ;
3556 break;}
3557case 198:
3558#line 2070 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3559{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003560 yyval.PHIList = yyvsp[-6].PHIList;
3561 yyvsp[-6].PHIList->push_back(std::make_pair(getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal),
3562 getBBVal(yyvsp[-1].ValIDVal)));
Chris Lattneredd9b032006-01-23 23:05:42 +00003563 ;
3564 break;}
3565case 199:
3566#line 2077 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3567{ // Used for call statements, and memory insts...
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003568 yyval.ValueList = new std::vector<Value*>();
3569 yyval.ValueList->push_back(yyvsp[0].ValueVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003570 ;
3571 break;}
3572case 200:
3573#line 2081 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3574{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003575 yyval.ValueList = yyvsp[-2].ValueList;
3576 yyvsp[-2].ValueList->push_back(yyvsp[0].ValueVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003577 ;
3578 break;}
3579case 202:
3580#line 2087 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3581{ yyval.ValueList = 0; ;
3582 break;}
3583case 203:
3584#line 2089 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3585{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003586 yyval.BoolVal = true;
Chris Lattneredd9b032006-01-23 23:05:42 +00003587 ;
3588 break;}
3589case 204:
3590#line 2092 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3591{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003592 yyval.BoolVal = false;
Chris Lattneredd9b032006-01-23 23:05:42 +00003593 ;
3594 break;}
3595case 205:
3596#line 2098 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3597{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003598 if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
3599 !isa<PackedType>((*yyvsp[-3].TypeVal).get()))
3600 ThrowException(
3601 "Arithmetic operator requires integer, FP, or packed operands!");
3602 if (isa<PackedType>((*yyvsp[-3].TypeVal).get()) && yyvsp[-4].BinaryOpVal == Instruction::Rem)
3603 ThrowException("Rem not supported on packed types!");
3604 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3605 if (yyval.InstVal == 0)
3606 ThrowException("binary operator returned null!");
3607 delete yyvsp[-3].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003608 ;
3609 break;}
3610case 206:
3611#line 2110 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3612{
Chris Lattner15f5a182005-12-21 18:31:50 +00003613 if (!(*yyvsp[-3].TypeVal)->isIntegral()) {
3614 if (!isa<PackedType>(yyvsp[-3].TypeVal->get()) ||
3615 !cast<PackedType>(yyvsp[-3].TypeVal->get())->getElementType()->isIntegral())
3616 ThrowException("Logical operator requires integral operands!");
3617 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003618 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3619 if (yyval.InstVal == 0)
3620 ThrowException("binary operator returned null!");
3621 delete yyvsp[-3].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003622 ;
3623 break;}
3624case 207:
3625#line 2121 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3626{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003627 if(isa<PackedType>((*yyvsp[-3].TypeVal).get())) {
3628 ThrowException(
3629 "PackedTypes currently not supported in setcc instructions!");
3630 }
3631 yyval.InstVal = new SetCondInst(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3632 if (yyval.InstVal == 0)
3633 ThrowException("binary operator returned null!");
3634 delete yyvsp[-3].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003635 ;
3636 break;}
3637case 208:
3638#line 2131 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3639{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003640 std::cerr << "WARNING: Use of eliminated 'not' instruction:"
3641 << " Replacing with 'xor'.\n";
3642
3643 Value *Ones = ConstantIntegral::getAllOnesValue(yyvsp[0].ValueVal->getType());
3644 if (Ones == 0)
3645 ThrowException("Expected integral type for not instruction!");
3646
3647 yyval.InstVal = BinaryOperator::create(Instruction::Xor, yyvsp[0].ValueVal, Ones);
3648 if (yyval.InstVal == 0)
3649 ThrowException("Could not create a xor instruction!");
Chris Lattneredd9b032006-01-23 23:05:42 +00003650 ;
3651 break;}
3652case 209:
3653#line 2143 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3654{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003655 if (yyvsp[0].ValueVal->getType() != Type::UByteTy)
3656 ThrowException("Shift amount must be ubyte!");
3657 if (!yyvsp[-2].ValueVal->getType()->isInteger())
3658 ThrowException("Shift constant expression requires integer operand!");
3659 yyval.InstVal = new ShiftInst(yyvsp[-3].OtherOpVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003660 ;
3661 break;}
3662case 210:
3663#line 2150 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3664{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003665 if (!yyvsp[0].TypeVal->get()->isFirstClassType())
3666 ThrowException("cast instruction to a non-primitive type: '" +
3667 yyvsp[0].TypeVal->get()->getDescription() + "'!");
3668 yyval.InstVal = new CastInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
3669 delete yyvsp[0].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003670 ;
3671 break;}
3672case 211:
3673#line 2157 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3674{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003675 if (yyvsp[-4].ValueVal->getType() != Type::BoolTy)
3676 ThrowException("select condition must be boolean!");
3677 if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
3678 ThrowException("select value types should match!");
3679 yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003680 ;
3681 break;}
3682case 212:
3683#line 2164 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3684{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003685 NewVarArgs = true;
3686 yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
3687 delete yyvsp[0].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003688 ;
3689 break;}
3690case 213:
3691#line 2169 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3692{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003693 ObsoleteVarArgs = true;
3694 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
3695 Function* NF = CurModule.CurrentModule->
Jeff Cohen11e26b52005-10-23 04:37:20 +00003696 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003697
3698 //b = vaarg a, t ->
3699 //foo = alloca 1 of t
3700 //bar = vacopy a
3701 //store bar -> foo
3702 //b = vaarg foo, t
3703 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
3704 CurBB->getInstList().push_back(foo);
3705 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
3706 CurBB->getInstList().push_back(bar);
3707 CurBB->getInstList().push_back(new StoreInst(bar, foo));
3708 yyval.InstVal = new VAArgInst(foo, *yyvsp[0].TypeVal);
3709 delete yyvsp[0].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003710 ;
3711 break;}
3712case 214:
3713#line 2188 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3714{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003715 ObsoleteVarArgs = true;
3716 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
3717 Function* NF = CurModule.CurrentModule->
Jeff Cohen11e26b52005-10-23 04:37:20 +00003718 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003719
3720 //b = vanext a, t ->
3721 //foo = alloca 1 of t
3722 //bar = vacopy a
3723 //store bar -> foo
3724 //tmp = vaarg foo, t
3725 //b = load foo
3726 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
3727 CurBB->getInstList().push_back(foo);
3728 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
3729 CurBB->getInstList().push_back(bar);
3730 CurBB->getInstList().push_back(new StoreInst(bar, foo));
3731 Instruction* tmp = new VAArgInst(foo, *yyvsp[0].TypeVal);
3732 CurBB->getInstList().push_back(tmp);
3733 yyval.InstVal = new LoadInst(foo);
3734 delete yyvsp[0].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003735 ;
3736 break;}
3737case 215:
3738#line 2210 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3739{
Robert Bocchinoaa1cf542006-01-10 19:04:32 +00003740 if (!isa<PackedType>(yyvsp[-2].ValueVal->getType()))
Robert Bocchinofdf9e412006-01-17 20:06:25 +00003741 ThrowException("First operand of extractelement must be "
3742 "packed type!");
Robert Bocchinoaa1cf542006-01-10 19:04:32 +00003743 if (yyvsp[0].ValueVal->getType() != Type::UIntTy)
Robert Bocchinofdf9e412006-01-17 20:06:25 +00003744 ThrowException("Second operand of extractelement must be uint!");
Robert Bocchinoaa1cf542006-01-10 19:04:32 +00003745 yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003746 ;
3747 break;}
3748case 216:
3749#line 2218 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3750{
Robert Bocchinofdf9e412006-01-17 20:06:25 +00003751 if (!isa<PackedType>(yyvsp[-4].ValueVal->getType()))
3752 ThrowException("First operand of insertelement must be "
3753 "packed type!");
3754 if (yyvsp[-2].ValueVal->getType() !=
3755 cast<PackedType>(yyvsp[-4].ValueVal->getType())->getElementType())
3756 ThrowException("Second operand of insertelement must be "
3757 "packed element type!");
3758 if (yyvsp[0].ValueVal->getType() != Type::UIntTy)
3759 ThrowException("Third operand of insertelement must be uint!");
3760 yyval.InstVal = new InsertElementInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003761 ;
3762 break;}
3763case 217:
3764#line 2230 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3765{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003766 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
3767 if (!Ty->isFirstClassType())
3768 ThrowException("PHI node operands must be of first class type!");
3769 yyval.InstVal = new PHINode(Ty);
3770 ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
3771 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
3772 if (yyvsp[0].PHIList->front().first->getType() != Ty)
3773 ThrowException("All elements of a PHI node must be of the same type!");
3774 cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
3775 yyvsp[0].PHIList->pop_front();
3776 }
3777 delete yyvsp[0].PHIList; // Free the list...
Chris Lattneredd9b032006-01-23 23:05:42 +00003778 ;
3779 break;}
3780case 218:
3781#line 2244 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3782{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003783 const PointerType *PFTy;
3784 const FunctionType *Ty;
3785
3786 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-4].TypeVal->get())) ||
3787 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3788 // Pull out the types of all of the arguments...
3789 std::vector<const Type*> ParamTypes;
3790 if (yyvsp[-1].ValueList) {
3791 for (std::vector<Value*>::iterator I = yyvsp[-1].ValueList->begin(), E = yyvsp[-1].ValueList->end();
3792 I != E; ++I)
3793 ParamTypes.push_back((*I)->getType());
3794 }
3795
3796 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3797 if (isVarArg) ParamTypes.pop_back();
3798
3799 if (!(*yyvsp[-4].TypeVal)->isFirstClassType() && *yyvsp[-4].TypeVal != Type::VoidTy)
3800 ThrowException("LLVM functions cannot return aggregate types!");
3801
3802 Ty = FunctionType::get(yyvsp[-4].TypeVal->get(), ParamTypes, isVarArg);
3803 PFTy = PointerType::get(Ty);
3804 }
3805
3806 Value *V = getVal(PFTy, yyvsp[-3].ValIDVal); // Get the function we're calling...
3807
3808 // Create the call node...
3809 if (!yyvsp[-1].ValueList) { // Has no arguments?
3810 // Make sure no arguments is a good thing!
3811 if (Ty->getNumParams() != 0)
3812 ThrowException("No arguments passed to a function that "
3813 "expects arguments!");
3814
3815 yyval.InstVal = new CallInst(V, std::vector<Value*>());
3816 } else { // Has arguments?
3817 // Loop through FunctionType's arguments and ensure they are specified
3818 // correctly!
3819 //
3820 FunctionType::param_iterator I = Ty->param_begin();
3821 FunctionType::param_iterator E = Ty->param_end();
3822 std::vector<Value*>::iterator ArgI = yyvsp[-1].ValueList->begin(), ArgE = yyvsp[-1].ValueList->end();
3823
3824 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3825 if ((*ArgI)->getType() != *I)
3826 ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
3827 (*I)->getDescription() + "'!");
3828
3829 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
3830 ThrowException("Invalid number of parameters detected!");
3831
3832 yyval.InstVal = new CallInst(V, *yyvsp[-1].ValueList);
3833 }
3834 cast<CallInst>(yyval.InstVal)->setTailCall(yyvsp[-6].BoolVal);
3835 cast<CallInst>(yyval.InstVal)->setCallingConv(yyvsp[-5].UIntVal);
3836 delete yyvsp[-4].TypeVal;
3837 delete yyvsp[-1].ValueList;
Chris Lattneredd9b032006-01-23 23:05:42 +00003838 ;
3839 break;}
3840case 219:
3841#line 2301 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3842{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003843 yyval.InstVal = yyvsp[0].InstVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003844 ;
3845 break;}
3846case 220:
3847#line 2307 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3848{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003849 yyval.ValueList = yyvsp[0].ValueList;
Chris Lattneredd9b032006-01-23 23:05:42 +00003850 ;
3851 break;}
3852case 221:
3853#line 2309 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3854{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003855 yyval.ValueList = new std::vector<Value*>();
Chris Lattneredd9b032006-01-23 23:05:42 +00003856 ;
3857 break;}
3858case 222:
3859#line 2313 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3860{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003861 yyval.BoolVal = true;
Chris Lattneredd9b032006-01-23 23:05:42 +00003862 ;
3863 break;}
3864case 223:
3865#line 2316 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3866{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003867 yyval.BoolVal = false;
Chris Lattneredd9b032006-01-23 23:05:42 +00003868 ;
3869 break;}
3870case 224:
3871#line 2322 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3872{
Chris Lattner86c352b2005-11-06 06:34:34 +00003873 yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
3874 delete yyvsp[-1].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003875 ;
3876 break;}
3877case 225:
3878#line 2326 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3879{
Chris Lattner86c352b2005-11-06 06:34:34 +00003880 yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal);
3881 delete yyvsp[-4].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003882 ;
3883 break;}
3884case 226:
3885#line 2330 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3886{
Chris Lattner86c352b2005-11-06 06:34:34 +00003887 yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
3888 delete yyvsp[-1].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003889 ;
3890 break;}
3891case 227:
3892#line 2334 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3893{
Chris Lattner86c352b2005-11-06 06:34:34 +00003894 yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal);
3895 delete yyvsp[-4].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003896 ;
3897 break;}
3898case 228:
3899#line 2338 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3900{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003901 if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
3902 ThrowException("Trying to free nonpointer type " +
3903 yyvsp[0].ValueVal->getType()->getDescription() + "!");
3904 yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
Chris Lattneredd9b032006-01-23 23:05:42 +00003905 ;
3906 break;}
3907case 229:
3908#line 2345 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3909{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003910 if (!isa<PointerType>(yyvsp[-1].TypeVal->get()))
3911 ThrowException("Can't load from nonpointer type: " +
3912 (*yyvsp[-1].TypeVal)->getDescription());
3913 if (!cast<PointerType>(yyvsp[-1].TypeVal->get())->getElementType()->isFirstClassType())
3914 ThrowException("Can't load from pointer of non-first-class type: " +
3915 (*yyvsp[-1].TypeVal)->getDescription());
3916 yyval.InstVal = new LoadInst(getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), "", yyvsp[-3].BoolVal);
3917 delete yyvsp[-1].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003918 ;
3919 break;}
3920case 230:
3921#line 2355 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3922{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003923 const PointerType *PT = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
3924 if (!PT)
3925 ThrowException("Can't store to a nonpointer type: " +
3926 (*yyvsp[-1].TypeVal)->getDescription());
3927 const Type *ElTy = PT->getElementType();
3928 if (ElTy != yyvsp[-3].ValueVal->getType())
3929 ThrowException("Can't store '" + yyvsp[-3].ValueVal->getType()->getDescription() +
3930 "' into space of type '" + ElTy->getDescription() + "'!");
3931
3932 yyval.InstVal = new StoreInst(yyvsp[-3].ValueVal, getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), yyvsp[-5].BoolVal);
3933 delete yyvsp[-1].TypeVal;
Chris Lattneredd9b032006-01-23 23:05:42 +00003934 ;
3935 break;}
3936case 231:
3937#line 2368 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3938{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003939 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
3940 ThrowException("getelementptr insn requires pointer operand!");
3941
3942 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
3943 // indices to uint struct indices for compatibility.
3944 generic_gep_type_iterator<std::vector<Value*>::iterator>
3945 GTI = gep_type_begin(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end()),
3946 GTE = gep_type_end(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end());
3947 for (unsigned i = 0, e = yyvsp[0].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
3948 if (isa<StructType>(*GTI)) // Only change struct indices
3949 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[0].ValueList)[i]))
3950 if (CUI->getType() == Type::UByteTy)
3951 (*yyvsp[0].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
3952
3953 if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, *yyvsp[0].ValueList, true))
3954 ThrowException("Invalid getelementptr indices for type '" +
3955 (*yyvsp[-2].TypeVal)->getDescription()+ "'!");
3956 yyval.InstVal = new GetElementPtrInst(getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal), *yyvsp[0].ValueList);
3957 delete yyvsp[-2].TypeVal; delete yyvsp[0].ValueList;
Chris Lattneredd9b032006-01-23 23:05:42 +00003958 ;
3959 break;}
3960}
3961 /* the action file gets copied in in place of this dollarsign */
3962#line 543 "/usr/share/bison.simple"
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003963
3964 yyvsp -= yylen;
3965 yyssp -= yylen;
Chris Lattneredd9b032006-01-23 23:05:42 +00003966#ifdef YYLSP_NEEDED
3967 yylsp -= yylen;
3968#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003969
Chris Lattneredd9b032006-01-23 23:05:42 +00003970#if YYDEBUG != 0
3971 if (yydebug)
3972 {
3973 short *ssp1 = yyss - 1;
3974 fprintf (stderr, "state stack now");
3975 while (ssp1 != yyssp)
3976 fprintf (stderr, " %d", *++ssp1);
3977 fprintf (stderr, "\n");
3978 }
3979#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003980
3981 *++yyvsp = yyval;
3982
Chris Lattneredd9b032006-01-23 23:05:42 +00003983#ifdef YYLSP_NEEDED
3984 yylsp++;
3985 if (yylen == 0)
3986 {
3987 yylsp->first_line = yylloc.first_line;
3988 yylsp->first_column = yylloc.first_column;
3989 yylsp->last_line = (yylsp-1)->last_line;
3990 yylsp->last_column = (yylsp-1)->last_column;
3991 yylsp->text = 0;
3992 }
3993 else
3994 {
3995 yylsp->last_line = (yylsp+yylen-1)->last_line;
3996 yylsp->last_column = (yylsp+yylen-1)->last_column;
3997 }
3998#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003999
Chris Lattneredd9b032006-01-23 23:05:42 +00004000 /* Now "shift" the result of the reduction.
4001 Determine what state that goes to,
4002 based on the state we popped back to
4003 and the rule number reduced by. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004004
4005 yyn = yyr1[yyn];
4006
Chris Lattneredd9b032006-01-23 23:05:42 +00004007 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
4008 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004009 yystate = yytable[yystate];
4010 else
Chris Lattneredd9b032006-01-23 23:05:42 +00004011 yystate = yydefgoto[yyn - YYNTBASE];
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004012
4013 goto yynewstate;
4014
Chris Lattneredd9b032006-01-23 23:05:42 +00004015yyerrlab: /* here on detecting error */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004016
Chris Lattneredd9b032006-01-23 23:05:42 +00004017 if (! yyerrstatus)
4018 /* If not already recovering from an error, report this error. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004019 {
4020 ++yynerrs;
Chris Lattneredd9b032006-01-23 23:05:42 +00004021
4022#ifdef YYERROR_VERBOSE
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004023 yyn = yypact[yystate];
4024
Chris Lattneredd9b032006-01-23 23:05:42 +00004025 if (yyn > YYFLAG && yyn < YYLAST)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004026 {
Chris Lattneredd9b032006-01-23 23:05:42 +00004027 int size = 0;
4028 char *msg;
4029 int x, count;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004030
Chris Lattneredd9b032006-01-23 23:05:42 +00004031 count = 0;
4032 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
4033 for (x = (yyn < 0 ? -yyn : 0);
4034 x < (sizeof(yytname) / sizeof(char *)); x++)
4035 if (yycheck[x + yyn] == x)
4036 size += strlen(yytname[x]) + 15, count++;
4037 msg = (char *) malloc(size + 15);
4038 if (msg != 0)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004039 {
Chris Lattneredd9b032006-01-23 23:05:42 +00004040 strcpy(msg, "parse error");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004041
Chris Lattneredd9b032006-01-23 23:05:42 +00004042 if (count < 5)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004043 {
Chris Lattneredd9b032006-01-23 23:05:42 +00004044 count = 0;
4045 for (x = (yyn < 0 ? -yyn : 0);
4046 x < (sizeof(yytname) / sizeof(char *)); x++)
4047 if (yycheck[x + yyn] == x)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004048 {
Chris Lattneredd9b032006-01-23 23:05:42 +00004049 strcat(msg, count == 0 ? ", expecting `" : " or `");
4050 strcat(msg, yytname[x]);
4051 strcat(msg, "'");
4052 count++;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004053 }
4054 }
Chris Lattneredd9b032006-01-23 23:05:42 +00004055 yyerror(msg);
4056 free(msg);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004057 }
4058 else
Chris Lattneredd9b032006-01-23 23:05:42 +00004059 yyerror ("parse error; also virtual memory exceeded");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004060 }
4061 else
4062#endif /* YYERROR_VERBOSE */
Chris Lattneredd9b032006-01-23 23:05:42 +00004063 yyerror("parse error");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004064 }
4065
Chris Lattneredd9b032006-01-23 23:05:42 +00004066 goto yyerrlab1;
4067yyerrlab1: /* here on error raised explicitly by an action */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004068
4069 if (yyerrstatus == 3)
4070 {
Chris Lattneredd9b032006-01-23 23:05:42 +00004071 /* if just tried and failed to reuse lookahead token after an error, discard it. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004072
Chris Lattneredd9b032006-01-23 23:05:42 +00004073 /* return failure if at end of input */
4074 if (yychar == YYEOF)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004075 YYABORT;
4076
Chris Lattneredd9b032006-01-23 23:05:42 +00004077#if YYDEBUG != 0
4078 if (yydebug)
4079 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
4080#endif
4081
4082 yychar = YYEMPTY;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004083 }
4084
Chris Lattneredd9b032006-01-23 23:05:42 +00004085 /* Else will try to reuse lookahead token
4086 after shifting the error token. */
4087
4088 yyerrstatus = 3; /* Each real token shifted decrements this */
4089
4090 goto yyerrhandle;
4091
4092yyerrdefault: /* current state does not do anything special for the error token. */
4093
4094#if 0
4095 /* This is wrong; only states that explicitly want error tokens
4096 should shift them. */
4097 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
4098 if (yyn) goto yydefault;
4099#endif
4100
4101yyerrpop: /* pop the current state because it cannot handle the error token */
4102
4103 if (yyssp == yyss) YYABORT;
4104 yyvsp--;
4105 yystate = *--yyssp;
4106#ifdef YYLSP_NEEDED
4107 yylsp--;
4108#endif
4109
4110#if YYDEBUG != 0
4111 if (yydebug)
4112 {
4113 short *ssp1 = yyss - 1;
4114 fprintf (stderr, "Error: state stack now");
4115 while (ssp1 != yyssp)
4116 fprintf (stderr, " %d", *++ssp1);
4117 fprintf (stderr, "\n");
4118 }
4119#endif
4120
4121yyerrhandle:
4122
4123 yyn = yypact[yystate];
4124 if (yyn == YYFLAG)
4125 goto yyerrdefault;
4126
4127 yyn += YYTERROR;
4128 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
4129 goto yyerrdefault;
4130
4131 yyn = yytable[yyn];
4132 if (yyn < 0)
4133 {
4134 if (yyn == YYFLAG)
4135 goto yyerrpop;
4136 yyn = -yyn;
4137 goto yyreduce;
4138 }
4139 else if (yyn == 0)
4140 goto yyerrpop;
4141
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004142 if (yyn == YYFINAL)
4143 YYACCEPT;
4144
Chris Lattneredd9b032006-01-23 23:05:42 +00004145#if YYDEBUG != 0
4146 if (yydebug)
4147 fprintf(stderr, "Shifting error token, ");
4148#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004149
4150 *++yyvsp = yylval;
Chris Lattneredd9b032006-01-23 23:05:42 +00004151#ifdef YYLSP_NEEDED
4152 *++yylsp = yylloc;
4153#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004154
4155 yystate = yyn;
4156 goto yynewstate;
4157
Chris Lattneredd9b032006-01-23 23:05:42 +00004158 yyacceptlab:
4159 /* YYACCEPT comes here. */
4160 if (yyfree_stacks)
4161 {
4162 free (yyss);
4163 free (yyvs);
4164#ifdef YYLSP_NEEDED
4165 free (yyls);
Reid Spencerb4f9a6f2006-01-16 21:12:35 +00004166#endif
Chris Lattneredd9b032006-01-23 23:05:42 +00004167 }
4168 return 0;
Reid Spencerc8a9faf2006-01-19 01:21:04 +00004169
Chris Lattneredd9b032006-01-23 23:05:42 +00004170 yyabortlab:
4171 /* YYABORT comes here. */
4172 if (yyfree_stacks)
4173 {
4174 free (yyss);
4175 free (yyvs);
4176#ifdef YYLSP_NEEDED
4177 free (yyls);
Reid Spencerc8a9faf2006-01-19 01:21:04 +00004178#endif
Chris Lattneredd9b032006-01-23 23:05:42 +00004179 }
4180 return 1;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004181}
Chris Lattneredd9b032006-01-23 23:05:42 +00004182#line 2391 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004183
4184int yyerror(const char *ErrorMsg) {
4185 std::string where
4186 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
4187 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
4188 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
4189 if (yychar == YYEMPTY || yychar == 0)
4190 errMsg += "end-of-file.";
4191 else
4192 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
4193 ThrowException(errMsg);
4194 return 0;
4195}