blob: 5922298b975274df5db4760932182a0ddb1b7128 [file] [log] [blame]
Reid Spencer68a24bd2005-08-27 18:50:39 +00001
Robert Bocchino9c62b562006-01-10 19:04:32 +00002/* A Bison parser, made from /Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y
Nate Begeman14b05292005-11-05 09:21:28 +00003 by GNU Bison version 1.28 */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004
Nate Begeman14b05292005-11-05 09:21:28 +00005#define YYBISON 1 /* Identify Bison output. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00006
Reid Spencer68a24bd2005-08-27 18:50:39 +00007#define yyparse llvmAsmparse
Nate Begeman14b05292005-11-05 09:21:28 +00008#define yylex llvmAsmlex
Reid Spencer68a24bd2005-08-27 18:50:39 +00009#define yyerror llvmAsmerror
Nate Begeman14b05292005-11-05 09:21:28 +000010#define yylval llvmAsmlval
11#define yychar llvmAsmchar
Reid Spencer68a24bd2005-08-27 18:50:39 +000012#define yydebug llvmAsmdebug
13#define yynerrs llvmAsmnerrs
Nate Begeman14b05292005-11-05 09:21:28 +000014#define ESINT64VAL 257
15#define EUINT64VAL 258
16#define SINTVAL 259
17#define UINTVAL 260
18#define FPVAL 261
19#define VOID 262
20#define BOOL 263
21#define SBYTE 264
22#define UBYTE 265
23#define SHORT 266
24#define USHORT 267
25#define INT 268
26#define UINT 269
27#define LONG 270
28#define ULONG 271
29#define FLOAT 272
30#define DOUBLE 273
31#define TYPE 274
32#define LABEL 275
33#define VAR_ID 276
34#define LABELSTR 277
35#define STRINGCONSTANT 278
36#define IMPLEMENTATION 279
37#define ZEROINITIALIZER 280
38#define TRUETOK 281
39#define FALSETOK 282
40#define BEGINTOK 283
41#define ENDTOK 284
42#define DECLARE 285
43#define GLOBAL 286
44#define CONSTANT 287
Chris Lattnere869eef2005-11-12 00:11:49 +000045#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 CC_TOK 312
70#define CCC_TOK 313
71#define FASTCC_TOK 314
72#define COLDCC_TOK 315
73#define RET 316
74#define BR 317
75#define SWITCH 318
76#define INVOKE 319
77#define UNWIND 320
78#define UNREACHABLE 321
79#define ADD 322
80#define SUB 323
81#define MUL 324
82#define DIV 325
83#define REM 326
84#define AND 327
85#define OR 328
86#define XOR 329
87#define SETLE 330
88#define SETGE 331
89#define SETLT 332
90#define SETGT 333
91#define SETEQ 334
92#define SETNE 335
93#define MALLOC 336
94#define ALLOCA 337
95#define FREE 338
96#define LOAD 339
97#define STORE 340
98#define GETELEMENTPTR 341
99#define PHI_TOK 342
100#define CAST 343
101#define SELECT 344
102#define SHL 345
103#define SHR 346
104#define VAARG 347
Robert Bocchino9c62b562006-01-10 19:04:32 +0000105#define EXTRACTELEMENT 348
106#define VAARG_old 349
107#define VANEXT_old 350
Reid Spencer68a24bd2005-08-27 18:50:39 +0000108
Robert Bocchino9c62b562006-01-10 19:04:32 +0000109#line 14 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000110
111#include "ParserInternals.h"
112#include "llvm/CallingConv.h"
113#include "llvm/Instructions.h"
114#include "llvm/Module.h"
115#include "llvm/SymbolTable.h"
116#include "llvm/Support/GetElementPtrTypeIterator.h"
117#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000118#include "llvm/Support/MathExtras.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000119#include <algorithm>
120#include <iostream>
121#include <list>
122#include <utility>
123
124int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
125int yylex(); // declaration" of xxx warnings.
126int yyparse();
127
128namespace llvm {
129 std::string CurFilename;
130}
131using namespace llvm;
132
133static Module *ParserResult;
134
135// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
136// relating to upreferences in the input stream.
137//
138//#define DEBUG_UPREFS 1
139#ifdef DEBUG_UPREFS
140#define UR_OUT(X) std::cerr << X
141#else
142#define UR_OUT(X)
143#endif
144
145#define YYERROR_VERBOSE 1
146
147static bool ObsoleteVarArgs;
148static bool NewVarArgs;
Chris Lattnerb475c422005-11-12 18:22:38 +0000149static BasicBlock *CurBB;
150static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000151
152
153// This contains info used when building the body of a function. It is
154// destroyed when the function is completed.
155//
156typedef std::vector<Value *> ValueList; // Numbered defs
157static void
158ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
159 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
160
161static struct PerModuleInfo {
162 Module *CurrentModule;
163 std::map<const Type *, ValueList> Values; // Module level numbered definitions
164 std::map<const Type *,ValueList> LateResolveValues;
165 std::vector<PATypeHolder> Types;
166 std::map<ValID, PATypeHolder> LateResolveTypes;
167
168 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
169 /// how they were referenced and one which line of the input they came from so
170 /// that we can resolve them later and print error messages as appropriate.
171 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
172
173 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
174 // references to global values. Global values may be referenced before they
175 // are defined, and if so, the temporary object that they represent is held
176 // here. This is used for forward references of GlobalValues.
177 //
178 typedef std::map<std::pair<const PointerType *,
179 ValID>, GlobalValue*> GlobalRefsType;
180 GlobalRefsType GlobalRefs;
181
182 void ModuleDone() {
183 // If we could not resolve some functions at function compilation time
184 // (calls to functions before they are defined), resolve them now... Types
185 // are resolved when the constant pool has been completely parsed.
186 //
187 ResolveDefinitions(LateResolveValues);
188
189 // Check to make sure that all global value forward references have been
190 // resolved!
191 //
192 if (!GlobalRefs.empty()) {
193 std::string UndefinedReferences = "Unresolved global references exist:\n";
194
195 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
196 I != E; ++I) {
197 UndefinedReferences += " " + I->first.first->getDescription() + " " +
198 I->first.second.getName() + "\n";
199 }
200 ThrowException(UndefinedReferences);
201 }
202
203 Values.clear(); // Clear out function local definitions
204 Types.clear();
205 CurrentModule = 0;
206 }
207
208
209 // GetForwardRefForGlobal - Check to see if there is a forward reference
210 // for this global. If so, remove it from the GlobalRefs map and return it.
211 // If not, just return null.
212 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
213 // Check to see if there is a forward reference to this global variable...
214 // if there is, eliminate it and patch the reference to use the new def'n.
215 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
216 GlobalValue *Ret = 0;
217 if (I != GlobalRefs.end()) {
218 Ret = I->second;
219 GlobalRefs.erase(I);
220 }
221 return Ret;
222 }
223} CurModule;
224
225static struct PerFunctionInfo {
226 Function *CurrentFunction; // Pointer to current function being created
227
228 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
229 std::map<const Type*, ValueList> LateResolveValues;
230 bool isDeclare; // Is this function a forward declararation?
231
232 /// BBForwardRefs - When we see forward references to basic blocks, keep
233 /// track of them here.
234 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
235 std::vector<BasicBlock*> NumberedBlocks;
236 unsigned NextBBNum;
237
238 inline PerFunctionInfo() {
239 CurrentFunction = 0;
240 isDeclare = false;
241 }
242
243 inline void FunctionStart(Function *M) {
244 CurrentFunction = M;
245 NextBBNum = 0;
246 }
247
248 void FunctionDone() {
249 NumberedBlocks.clear();
250
251 // Any forward referenced blocks left?
252 if (!BBForwardRefs.empty())
253 ThrowException("Undefined reference to label " +
254 BBForwardRefs.begin()->first->getName());
255
256 // Resolve all forward references now.
257 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
258
259 Values.clear(); // Clear out function local definitions
260 CurrentFunction = 0;
261 isDeclare = false;
262 }
263} CurFun; // Info for the current function...
264
265static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
266
267
268//===----------------------------------------------------------------------===//
269// Code to handle definitions of all the types
270//===----------------------------------------------------------------------===//
271
272static int InsertValue(Value *V,
273 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
274 if (V->hasName()) return -1; // Is this a numbered definition?
275
276 // Yes, insert the value into the value table...
277 ValueList &List = ValueTab[V->getType()];
278 List.push_back(V);
279 return List.size()-1;
280}
281
282static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
283 switch (D.Type) {
284 case ValID::NumberVal: // Is it a numbered definition?
285 // Module constants occupy the lowest numbered slots...
286 if ((unsigned)D.Num < CurModule.Types.size())
287 return CurModule.Types[(unsigned)D.Num];
288 break;
289 case ValID::NameVal: // Is it a named definition?
290 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
291 D.destroy(); // Free old strdup'd memory...
292 return N;
293 }
294 break;
295 default:
296 ThrowException("Internal parser error: Invalid symbol type reference!");
297 }
298
299 // If we reached here, we referenced either a symbol that we don't know about
300 // or an id number that hasn't been read yet. We may be referencing something
301 // forward, so just create an entry to be resolved later and get to it...
302 //
303 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
304
305
306 if (inFunctionScope()) {
307 if (D.Type == ValID::NameVal)
308 ThrowException("Reference to an undefined type: '" + D.getName() + "'");
309 else
310 ThrowException("Reference to an undefined type: #" + itostr(D.Num));
311 }
312
313 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
314 if (I != CurModule.LateResolveTypes.end())
315 return I->second;
316
317 Type *Typ = OpaqueType::get();
318 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
319 return Typ;
320 }
321
322static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
323 SymbolTable &SymTab =
324 inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() :
325 CurModule.CurrentModule->getSymbolTable();
326 return SymTab.lookup(Ty, Name);
327}
328
329// getValNonImprovising - Look up the value specified by the provided type and
330// the provided ValID. If the value exists and has already been defined, return
331// it. Otherwise return null.
332//
333static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
334 if (isa<FunctionType>(Ty))
335 ThrowException("Functions are not values and "
336 "must be referenced as pointers");
337
338 switch (D.Type) {
339 case ValID::NumberVal: { // Is it a numbered definition?
340 unsigned Num = (unsigned)D.Num;
341
342 // Module constants occupy the lowest numbered slots...
343 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
344 if (VI != CurModule.Values.end()) {
345 if (Num < VI->second.size())
346 return VI->second[Num];
347 Num -= VI->second.size();
348 }
349
350 // Make sure that our type is within bounds
351 VI = CurFun.Values.find(Ty);
352 if (VI == CurFun.Values.end()) return 0;
353
354 // Check that the number is within bounds...
355 if (VI->second.size() <= Num) return 0;
356
357 return VI->second[Num];
358 }
359
360 case ValID::NameVal: { // Is it a named definition?
361 Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
362 if (N == 0) return 0;
363
364 D.destroy(); // Free old strdup'd memory...
365 return N;
366 }
367
368 // Check to make sure that "Ty" is an integral type, and that our
369 // value will fit into the specified type...
370 case ValID::ConstSIntVal: // Is it a constant pool reference??
371 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64))
372 ThrowException("Signed integral constant '" +
373 itostr(D.ConstPool64) + "' is invalid for type '" +
374 Ty->getDescription() + "'!");
375 return ConstantSInt::get(Ty, D.ConstPool64);
376
377 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
378 if (!ConstantUInt::isValueValidForType(Ty, D.UConstPool64)) {
379 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) {
380 ThrowException("Integral constant '" + utostr(D.UConstPool64) +
381 "' is invalid or out of range!");
382 } else { // This is really a signed reference. Transmogrify.
383 return ConstantSInt::get(Ty, D.ConstPool64);
384 }
385 } else {
386 return ConstantUInt::get(Ty, D.UConstPool64);
387 }
388
389 case ValID::ConstFPVal: // Is it a floating point const pool reference?
390 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
391 ThrowException("FP constant invalid for type!!");
392 return ConstantFP::get(Ty, D.ConstPoolFP);
393
394 case ValID::ConstNullVal: // Is it a null value?
395 if (!isa<PointerType>(Ty))
396 ThrowException("Cannot create a a non pointer null!");
397 return ConstantPointerNull::get(cast<PointerType>(Ty));
398
399 case ValID::ConstUndefVal: // Is it an undef value?
400 return UndefValue::get(Ty);
401
Chris Lattner7aa61892005-12-21 17:53:23 +0000402 case ValID::ConstZeroVal: // Is it a zero value?
403 return Constant::getNullValue(Ty);
404
Reid Spencer68a24bd2005-08-27 18:50:39 +0000405 case ValID::ConstantVal: // Fully resolved constant?
406 if (D.ConstantValue->getType() != Ty)
407 ThrowException("Constant expression type different from required type!");
408 return D.ConstantValue;
409
410 default:
411 assert(0 && "Unhandled case!");
412 return 0;
413 } // End of switch
414
415 assert(0 && "Unhandled case!");
416 return 0;
417}
418
419// getVal - This function is identical to getValNonImprovising, except that if a
420// value is not already defined, it "improvises" by creating a placeholder var
421// that looks and acts just like the requested variable. When the value is
422// defined later, all uses of the placeholder variable are replaced with the
423// real thing.
424//
425static Value *getVal(const Type *Ty, const ValID &ID) {
426 if (Ty == Type::LabelTy)
427 ThrowException("Cannot use a basic block here");
428
429 // See if the value has already been defined.
430 Value *V = getValNonImprovising(Ty, ID);
431 if (V) return V;
432
433 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
434 ThrowException("Invalid use of a composite type!");
435
436 // If we reached here, we referenced either a symbol that we don't know about
437 // or an id number that hasn't been read yet. We may be referencing something
438 // forward, so just create an entry to be resolved later and get to it...
439 //
440 V = new Argument(Ty);
441
442 // Remember where this forward reference came from. FIXME, shouldn't we try
443 // to recycle these things??
444 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
445 llvmAsmlineno)));
446
447 if (inFunctionScope())
448 InsertValue(V, CurFun.LateResolveValues);
449 else
450 InsertValue(V, CurModule.LateResolveValues);
451 return V;
452}
453
454/// getBBVal - This is used for two purposes:
455/// * If isDefinition is true, a new basic block with the specified ID is being
456/// defined.
457/// * If isDefinition is true, this is a reference to a basic block, which may
458/// or may not be a forward reference.
459///
460static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
461 assert(inFunctionScope() && "Can't get basic block at global scope!");
462
463 std::string Name;
464 BasicBlock *BB = 0;
465 switch (ID.Type) {
466 default: ThrowException("Illegal label reference " + ID.getName());
467 case ValID::NumberVal: // Is it a numbered definition?
468 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
469 CurFun.NumberedBlocks.resize(ID.Num+1);
470 BB = CurFun.NumberedBlocks[ID.Num];
471 break;
472 case ValID::NameVal: // Is it a named definition?
473 Name = ID.Name;
474 if (Value *N = CurFun.CurrentFunction->
475 getSymbolTable().lookup(Type::LabelTy, Name))
476 BB = cast<BasicBlock>(N);
477 break;
478 }
479
480 // See if the block has already been defined.
481 if (BB) {
482 // If this is the definition of the block, make sure the existing value was
483 // just a forward reference. If it was a forward reference, there will be
484 // an entry for it in the PlaceHolderInfo map.
485 if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
486 // The existing value was a definition, not a forward reference.
487 ThrowException("Redefinition of label " + ID.getName());
488
489 ID.destroy(); // Free strdup'd memory.
490 return BB;
491 }
492
493 // Otherwise this block has not been seen before.
494 BB = new BasicBlock("", CurFun.CurrentFunction);
495 if (ID.Type == ValID::NameVal) {
496 BB->setName(ID.Name);
497 } else {
498 CurFun.NumberedBlocks[ID.Num] = BB;
499 }
500
501 // If this is not a definition, keep track of it so we can use it as a forward
502 // reference.
503 if (!isDefinition) {
504 // Remember where this forward reference came from.
505 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
506 } else {
507 // The forward declaration could have been inserted anywhere in the
508 // function: insert it into the correct place now.
509 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
510 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
511 }
512 ID.destroy();
513 return BB;
514}
515
516
517//===----------------------------------------------------------------------===//
518// Code to handle forward references in instructions
519//===----------------------------------------------------------------------===//
520//
521// This code handles the late binding needed with statements that reference
522// values not defined yet... for example, a forward branch, or the PHI node for
523// a loop body.
524//
525// This keeps a table (CurFun.LateResolveValues) of all such forward references
526// and back patchs after we are done.
527//
528
529// ResolveDefinitions - If we could not resolve some defs at parsing
530// time (forward branches, phi functions for loops, etc...) resolve the
531// defs now...
532//
533static void
534ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
535 std::map<const Type*,ValueList> *FutureLateResolvers) {
536 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
537 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
538 E = LateResolvers.end(); LRI != E; ++LRI) {
539 ValueList &List = LRI->second;
540 while (!List.empty()) {
541 Value *V = List.back();
542 List.pop_back();
543
544 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
545 CurModule.PlaceHolderInfo.find(V);
546 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
547
548 ValID &DID = PHI->second.first;
549
550 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
551 if (TheRealValue) {
552 V->replaceAllUsesWith(TheRealValue);
553 delete V;
554 CurModule.PlaceHolderInfo.erase(PHI);
555 } else if (FutureLateResolvers) {
556 // Functions have their unresolved items forwarded to the module late
557 // resolver table
558 InsertValue(V, *FutureLateResolvers);
559 } else {
560 if (DID.Type == ValID::NameVal)
561 ThrowException("Reference to an invalid definition: '" +DID.getName()+
562 "' of type '" + V->getType()->getDescription() + "'",
563 PHI->second.second);
564 else
565 ThrowException("Reference to an invalid definition: #" +
566 itostr(DID.Num) + " of type '" +
567 V->getType()->getDescription() + "'",
568 PHI->second.second);
569 }
570 }
571 }
572
573 LateResolvers.clear();
574}
575
576// ResolveTypeTo - A brand new type was just declared. This means that (if
577// name is not null) things referencing Name can be resolved. Otherwise, things
578// refering to the number can be resolved. Do this now.
579//
580static void ResolveTypeTo(char *Name, const Type *ToTy) {
581 ValID D;
582 if (Name) D = ValID::create(Name);
583 else D = ValID::create((int)CurModule.Types.size());
584
585 std::map<ValID, PATypeHolder>::iterator I =
586 CurModule.LateResolveTypes.find(D);
587 if (I != CurModule.LateResolveTypes.end()) {
588 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
589 CurModule.LateResolveTypes.erase(I);
590 }
591}
592
593// setValueName - Set the specified value to the name given. The name may be
594// null potentially, in which case this is a noop. The string passed in is
595// assumed to be a malloc'd string buffer, and is free'd by this function.
596//
597static void setValueName(Value *V, char *NameStr) {
598 if (NameStr) {
599 std::string Name(NameStr); // Copy string
600 free(NameStr); // Free old string
601
602 if (V->getType() == Type::VoidTy)
603 ThrowException("Can't assign name '" + Name+"' to value with void type!");
604
605 assert(inFunctionScope() && "Must be in function scope!");
606 SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable();
607 if (ST.lookup(V->getType(), Name))
608 ThrowException("Redefinition of value named '" + Name + "' in the '" +
609 V->getType()->getDescription() + "' type plane!");
610
611 // Set the name.
612 V->setName(Name);
613 }
614}
615
616/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
617/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +0000618static GlobalVariable *
619ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
620 bool isConstantGlobal, const Type *Ty,
621 Constant *Initializer) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000622 if (isa<FunctionType>(Ty))
623 ThrowException("Cannot declare global vars of function type!");
624
625 const PointerType *PTy = PointerType::get(Ty);
626
627 std::string Name;
628 if (NameStr) {
629 Name = NameStr; // Copy string
630 free(NameStr); // Free old string
631 }
632
633 // See if this global value was forward referenced. If so, recycle the
634 // object.
635 ValID ID;
636 if (!Name.empty()) {
637 ID = ValID::create((char*)Name.c_str());
638 } else {
639 ID = ValID::create((int)CurModule.Values[PTy].size());
640 }
641
642 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
643 // Move the global to the end of the list, from whereever it was
644 // previously inserted.
645 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
646 CurModule.CurrentModule->getGlobalList().remove(GV);
647 CurModule.CurrentModule->getGlobalList().push_back(GV);
648 GV->setInitializer(Initializer);
649 GV->setLinkage(Linkage);
650 GV->setConstant(isConstantGlobal);
651 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000652 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000653 }
654
655 // If this global has a name, check to see if there is already a definition
656 // of this global in the module. If so, merge as appropriate. Note that
657 // this is really just a hack around problems in the CFE. :(
658 if (!Name.empty()) {
659 // We are a simple redefinition of a value, check to see if it is defined
660 // the same as the old one.
661 if (GlobalVariable *EGV =
662 CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
663 // We are allowed to redefine a global variable in two circumstances:
664 // 1. If at least one of the globals is uninitialized or
665 // 2. If both initializers have the same value.
666 //
667 if (!EGV->hasInitializer() || !Initializer ||
668 EGV->getInitializer() == Initializer) {
669
670 // Make sure the existing global version gets the initializer! Make
671 // sure that it also gets marked const if the new version is.
672 if (Initializer && !EGV->hasInitializer())
673 EGV->setInitializer(Initializer);
674 if (isConstantGlobal)
675 EGV->setConstant(true);
676 EGV->setLinkage(Linkage);
Chris Lattnerb475c422005-11-12 18:22:38 +0000677 return EGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000678 }
679
680 ThrowException("Redefinition of global variable named '" + Name +
681 "' in the '" + Ty->getDescription() + "' type plane!");
682 }
683 }
684
685 // Otherwise there is no existing GV to use, create one now.
686 GlobalVariable *GV =
687 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
688 CurModule.CurrentModule);
689 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000690 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000691}
692
693// setTypeName - Set the specified type to the name given. The name may be
694// null potentially, in which case this is a noop. The string passed in is
695// assumed to be a malloc'd string buffer, and is freed by this function.
696//
697// This function returns true if the type has already been defined, but is
698// allowed to be redefined in the specified context. If the name is a new name
699// for the type plane, it is inserted and false is returned.
700static bool setTypeName(const Type *T, char *NameStr) {
701 assert(!inFunctionScope() && "Can't give types function-local names!");
702 if (NameStr == 0) return false;
703
704 std::string Name(NameStr); // Copy string
705 free(NameStr); // Free old string
706
707 // We don't allow assigning names to void type
708 if (T == Type::VoidTy)
709 ThrowException("Can't assign name '" + Name + "' to the void type!");
710
711 // Set the type name, checking for conflicts as we do so.
712 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
713
714 if (AlreadyExists) { // Inserting a name that is already defined???
715 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
716 assert(Existing && "Conflict but no matching type?");
717
718 // There is only one case where this is allowed: when we are refining an
719 // opaque type. In this case, Existing will be an opaque type.
720 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
721 // We ARE replacing an opaque type!
722 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
723 return true;
724 }
725
726 // Otherwise, this is an attempt to redefine a type. That's okay if
727 // the redefinition is identical to the original. This will be so if
728 // Existing and T point to the same Type object. In this one case we
729 // allow the equivalent redefinition.
730 if (Existing == T) return true; // Yes, it's equal.
731
732 // Any other kind of (non-equivalent) redefinition is an error.
733 ThrowException("Redefinition of type named '" + Name + "' in the '" +
734 T->getDescription() + "' type plane!");
735 }
736
737 return false;
738}
739
740//===----------------------------------------------------------------------===//
741// Code for handling upreferences in type names...
742//
743
744// TypeContains - Returns true if Ty directly contains E in it.
745//
746static bool TypeContains(const Type *Ty, const Type *E) {
747 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
748 E) != Ty->subtype_end();
749}
750
751namespace {
752 struct UpRefRecord {
753 // NestingLevel - The number of nesting levels that need to be popped before
754 // this type is resolved.
755 unsigned NestingLevel;
756
757 // LastContainedTy - This is the type at the current binding level for the
758 // type. Every time we reduce the nesting level, this gets updated.
759 const Type *LastContainedTy;
760
761 // UpRefTy - This is the actual opaque type that the upreference is
762 // represented with.
763 OpaqueType *UpRefTy;
764
765 UpRefRecord(unsigned NL, OpaqueType *URTy)
766 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
767 };
768}
769
770// UpRefs - A list of the outstanding upreferences that need to be resolved.
771static std::vector<UpRefRecord> UpRefs;
772
773/// HandleUpRefs - Every time we finish a new layer of types, this function is
774/// called. It loops through the UpRefs vector, which is a list of the
775/// currently active types. For each type, if the up reference is contained in
776/// the newly completed type, we decrement the level count. When the level
777/// count reaches zero, the upreferenced type is the type that is passed in:
778/// thus we can complete the cycle.
779///
780static PATypeHolder HandleUpRefs(const Type *ty) {
781 if (!ty->isAbstract()) return ty;
782 PATypeHolder Ty(ty);
783 UR_OUT("Type '" << Ty->getDescription() <<
784 "' newly formed. Resolving upreferences.\n" <<
785 UpRefs.size() << " upreferences active!\n");
786
787 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
788 // to zero), we resolve them all together before we resolve them to Ty. At
789 // the end of the loop, if there is anything to resolve to Ty, it will be in
790 // this variable.
791 OpaqueType *TypeToResolve = 0;
792
793 for (unsigned i = 0; i != UpRefs.size(); ++i) {
794 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
795 << UpRefs[i].second->getDescription() << ") = "
796 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
797 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
798 // Decrement level of upreference
799 unsigned Level = --UpRefs[i].NestingLevel;
800 UpRefs[i].LastContainedTy = Ty;
801 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
802 if (Level == 0) { // Upreference should be resolved!
803 if (!TypeToResolve) {
804 TypeToResolve = UpRefs[i].UpRefTy;
805 } else {
806 UR_OUT(" * Resolving upreference for "
807 << UpRefs[i].second->getDescription() << "\n";
808 std::string OldName = UpRefs[i].UpRefTy->getDescription());
809 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
810 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
811 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
812 }
813 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
814 --i; // Do not skip the next element...
815 }
816 }
817 }
818
819 if (TypeToResolve) {
820 UR_OUT(" * Resolving upreference for "
821 << UpRefs[i].second->getDescription() << "\n";
822 std::string OldName = TypeToResolve->getDescription());
823 TypeToResolve->refineAbstractTypeTo(Ty);
824 }
825
826 return Ty;
827}
828
829
830// common code from the two 'RunVMAsmParser' functions
831 static Module * RunParser(Module * M) {
832
833 llvmAsmlineno = 1; // Reset the current line number...
834 ObsoleteVarArgs = false;
835 NewVarArgs = false;
836
837 CurModule.CurrentModule = M;
838 yyparse(); // Parse the file, potentially throwing exception
839
840 Module *Result = ParserResult;
841 ParserResult = 0;
842
843 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
844 {
845 Function* F;
846 if ((F = Result->getNamedFunction("llvm.va_start"))
847 && F->getFunctionType()->getNumParams() == 0)
848 ObsoleteVarArgs = true;
849 if((F = Result->getNamedFunction("llvm.va_copy"))
850 && F->getFunctionType()->getNumParams() == 1)
851 ObsoleteVarArgs = true;
852 }
853
854 if (ObsoleteVarArgs && NewVarArgs)
855 ThrowException("This file is corrupt: it uses both new and old style varargs");
856
857 if(ObsoleteVarArgs) {
858 if(Function* F = Result->getNamedFunction("llvm.va_start")) {
859 if (F->arg_size() != 0)
860 ThrowException("Obsolete va_start takes 0 argument!");
861
862 //foo = va_start()
863 // ->
864 //bar = alloca typeof(foo)
865 //va_start(bar)
866 //foo = load bar
867
868 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
869 const Type* ArgTy = F->getFunctionType()->getReturnType();
870 const Type* ArgTyPtr = PointerType::get(ArgTy);
871 Function* NF = Result->getOrInsertFunction("llvm.va_start",
Jeff Cohen66c5fd62005-10-23 04:37:20 +0000872 RetTy, ArgTyPtr, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000873
874 while (!F->use_empty()) {
875 CallInst* CI = cast<CallInst>(F->use_back());
876 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
877 new CallInst(NF, bar, "", CI);
878 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
879 CI->replaceAllUsesWith(foo);
880 CI->getParent()->getInstList().erase(CI);
881 }
882 Result->getFunctionList().erase(F);
883 }
884
885 if(Function* F = Result->getNamedFunction("llvm.va_end")) {
886 if(F->arg_size() != 1)
887 ThrowException("Obsolete va_end takes 1 argument!");
888
889 //vaend foo
890 // ->
891 //bar = alloca 1 of typeof(foo)
892 //vaend bar
893 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
894 const Type* ArgTy = F->getFunctionType()->getParamType(0);
895 const Type* ArgTyPtr = PointerType::get(ArgTy);
896 Function* NF = Result->getOrInsertFunction("llvm.va_end",
Jeff Cohen66c5fd62005-10-23 04:37:20 +0000897 RetTy, ArgTyPtr, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000898
899 while (!F->use_empty()) {
900 CallInst* CI = cast<CallInst>(F->use_back());
901 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
902 new StoreInst(CI->getOperand(1), bar, CI);
903 new CallInst(NF, bar, "", CI);
904 CI->getParent()->getInstList().erase(CI);
905 }
906 Result->getFunctionList().erase(F);
907 }
908
909 if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
910 if(F->arg_size() != 1)
911 ThrowException("Obsolete va_copy takes 1 argument!");
912 //foo = vacopy(bar)
913 // ->
914 //a = alloca 1 of typeof(foo)
915 //b = alloca 1 of typeof(foo)
916 //store bar -> b
917 //vacopy(a, b)
918 //foo = load a
919
920 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
921 const Type* ArgTy = F->getFunctionType()->getReturnType();
922 const Type* ArgTyPtr = PointerType::get(ArgTy);
923 Function* NF = Result->getOrInsertFunction("llvm.va_copy",
Jeff Cohen66c5fd62005-10-23 04:37:20 +0000924 RetTy, ArgTyPtr, ArgTyPtr,
925 (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000926
927 while (!F->use_empty()) {
928 CallInst* CI = cast<CallInst>(F->use_back());
929 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
930 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
931 new StoreInst(CI->getOperand(1), b, CI);
932 new CallInst(NF, a, b, "", CI);
933 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
934 CI->replaceAllUsesWith(foo);
935 CI->getParent()->getInstList().erase(CI);
936 }
937 Result->getFunctionList().erase(F);
938 }
939 }
940
941 return Result;
942
943 }
944
945//===----------------------------------------------------------------------===//
946// RunVMAsmParser - Define an interface to this parser
947//===----------------------------------------------------------------------===//
948//
949Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
950 set_scan_file(F);
951
952 CurFilename = Filename;
953 return RunParser(new Module(CurFilename));
954}
955
956Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
957 set_scan_string(AsmString);
958
959 CurFilename = "from_memory";
960 if (M == NULL) {
961 return RunParser(new Module (CurFilename));
962 } else {
963 return RunParser(M);
964 }
965}
966
967
Robert Bocchino9c62b562006-01-10 19:04:32 +0000968#line 873 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +0000969typedef union {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000970 llvm::Module *ModuleVal;
971 llvm::Function *FunctionVal;
972 std::pair<llvm::PATypeHolder*, char*> *ArgVal;
973 llvm::BasicBlock *BasicBlockVal;
974 llvm::TerminatorInst *TermInstVal;
975 llvm::Instruction *InstVal;
976 llvm::Constant *ConstVal;
977
978 const llvm::Type *PrimType;
979 llvm::PATypeHolder *TypeVal;
980 llvm::Value *ValueVal;
981
982 std::vector<std::pair<llvm::PATypeHolder*,char*> > *ArgList;
983 std::vector<llvm::Value*> *ValueList;
984 std::list<llvm::PATypeHolder> *TypeList;
985 // Represent the RHS of PHI node
986 std::list<std::pair<llvm::Value*,
987 llvm::BasicBlock*> > *PHIList;
988 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
989 std::vector<llvm::Constant*> *ConstVector;
990
991 llvm::GlobalValue::LinkageTypes Linkage;
992 int64_t SInt64Val;
993 uint64_t UInt64Val;
994 int SIntVal;
995 unsigned UIntVal;
996 double FPVal;
997 bool BoolVal;
998
999 char *StrVal; // This memory is strdup'd!
1000 llvm::ValID ValIDVal; // strdup'd memory maybe!
1001
1002 llvm::Instruction::BinaryOps BinaryOpVal;
1003 llvm::Instruction::TermOps TermOpVal;
1004 llvm::Instruction::MemoryOps MemOpVal;
1005 llvm::Instruction::OtherOps OtherOpVal;
1006 llvm::Module::Endianness Endianness;
1007} YYSTYPE;
Nate Begeman14b05292005-11-05 09:21:28 +00001008#include <stdio.h>
1009
1010#ifndef __cplusplus
1011#ifndef __STDC__
1012#define const
1013#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001014#endif
1015
1016
1017
Robert Bocchino9c62b562006-01-10 19:04:32 +00001018#define YYFINAL 454
Nate Begeman14b05292005-11-05 09:21:28 +00001019#define YYFLAG -32768
Robert Bocchino9c62b562006-01-10 19:04:32 +00001020#define YYNTBASE 111
Reid Spencer68a24bd2005-08-27 18:50:39 +00001021
Robert Bocchino9c62b562006-01-10 19:04:32 +00001022#define YYTRANSLATE(x) ((unsigned)(x) <= 350 ? yytranslate[x] : 180)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001023
Nate Begeman14b05292005-11-05 09:21:28 +00001024static const char yytranslate[] = { 0,
1025 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1026 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1027 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Robert Bocchino9c62b562006-01-10 19:04:32 +00001028 2, 2, 2, 2, 2, 2, 2, 2, 2, 100,
1029 101, 109, 2, 98, 2, 2, 2, 2, 2, 2,
1030 2, 2, 2, 2, 2, 2, 2, 2, 2, 105,
1031 97, 106, 2, 2, 2, 2, 2, 2, 2, 2,
Nate Begeman14b05292005-11-05 09:21:28 +00001032 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1033 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Robert Bocchino9c62b562006-01-10 19:04:32 +00001034 102, 99, 104, 2, 2, 2, 2, 2, 110, 2,
Nate Begeman14b05292005-11-05 09:21:28 +00001035 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Robert Bocchino9c62b562006-01-10 19:04:32 +00001036 2, 2, 2, 2, 2, 2, 2, 2, 2, 103,
1037 2, 2, 107, 2, 108, 2, 2, 2, 2, 2,
Nate Begeman14b05292005-11-05 09:21:28 +00001038 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1039 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1040 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1041 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1042 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1043 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1044 2, 2, 2, 2, 2, 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, 1, 3, 4, 5, 6,
1051 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1052 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1053 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
1054 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
1055 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
1056 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1057 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1058 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
Robert Bocchino9c62b562006-01-10 19:04:32 +00001059 87, 88, 89, 90, 91, 92, 93, 94, 95, 96
Nate Begeman14b05292005-11-05 09:21:28 +00001060};
Reid Spencer68a24bd2005-08-27 18:50:39 +00001061
Nate Begeman14b05292005-11-05 09:21:28 +00001062#if YYDEBUG != 0
1063static const short yyprhs[] = { 0,
1064 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
1065 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
1066 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
1067 60, 62, 64, 67, 68, 70, 72, 74, 76, 77,
Chris Lattnere869eef2005-11-12 00:11:49 +00001068 78, 80, 82, 84, 87, 88, 91, 92, 96, 99,
Chris Lattnerb475c422005-11-12 18:22:38 +00001069 100, 102, 103, 107, 109, 112, 114, 116, 118, 120,
1070 122, 124, 126, 128, 130, 132, 134, 136, 138, 140,
1071 142, 144, 146, 148, 150, 152, 154, 157, 162, 168,
1072 174, 178, 181, 184, 186, 190, 192, 196, 198, 199,
1073 204, 208, 212, 217, 222, 226, 229, 232, 235, 238,
1074 241, 244, 247, 250, 253, 256, 263, 269, 278, 285,
Robert Bocchino9c62b562006-01-10 19:04:32 +00001075 292, 299, 306, 313, 317, 319, 321, 323, 325, 328,
1076 331, 334, 336, 341, 344, 345, 353, 354, 362, 366,
1077 371, 372, 374, 376, 380, 384, 388, 392, 396, 398,
1078 399, 401, 403, 405, 406, 409, 413, 415, 417, 421,
1079 423, 424, 433, 435, 437, 441, 443, 445, 448, 449,
1080 453, 455, 457, 459, 461, 463, 465, 467, 469, 473,
1081 475, 477, 479, 481, 483, 486, 489, 492, 496, 499,
1082 500, 502, 505, 508, 512, 522, 532, 541, 555, 557,
1083 559, 566, 572, 575, 582, 590, 592, 596, 598, 599,
1084 602, 604, 610, 616, 622, 625, 630, 635, 642, 647,
1085 652, 657, 662, 665, 673, 675, 678, 679, 681, 682,
1086 686, 693, 697, 704, 707, 712, 719
Nate Begeman14b05292005-11-05 09:21:28 +00001087};
Reid Spencer68a24bd2005-08-27 18:50:39 +00001088
Nate Begeman14b05292005-11-05 09:21:28 +00001089static const short yyrhs[] = { 5,
Chris Lattnere869eef2005-11-12 00:11:49 +00001090 0, 6, 0, 3, 0, 4, 0, 68, 0, 69,
1091 0, 70, 0, 71, 0, 72, 0, 73, 0, 74,
1092 0, 75, 0, 76, 0, 77, 0, 78, 0, 79,
1093 0, 80, 0, 81, 0, 91, 0, 92, 0, 16,
Nate Begeman14b05292005-11-05 09:21:28 +00001094 0, 14, 0, 12, 0, 10, 0, 17, 0, 15,
Robert Bocchino9c62b562006-01-10 19:04:32 +00001095 0, 13, 0, 11, 0, 117, 0, 118, 0, 18,
1096 0, 19, 0, 150, 97, 0, 0, 41, 0, 42,
Chris Lattnere869eef2005-11-12 00:11:49 +00001097 0, 43, 0, 44, 0, 0, 0, 59, 0, 60,
1098 0, 61, 0, 58, 4, 0, 0, 54, 4, 0,
Robert Bocchino9c62b562006-01-10 19:04:32 +00001099 0, 98, 54, 4, 0, 34, 24, 0, 0, 126,
1100 0, 0, 98, 129, 128, 0, 126, 0, 54, 4,
1101 0, 132, 0, 8, 0, 134, 0, 8, 0, 134,
Chris Lattnerb475c422005-11-12 18:22:38 +00001102 0, 9, 0, 10, 0, 11, 0, 12, 0, 13,
1103 0, 14, 0, 15, 0, 16, 0, 17, 0, 18,
Robert Bocchino9c62b562006-01-10 19:04:32 +00001104 0, 19, 0, 20, 0, 21, 0, 45, 0, 133,
1105 0, 163, 0, 99, 4, 0, 131, 100, 136, 101,
1106 0, 102, 4, 103, 134, 104, 0, 105, 4, 103,
1107 134, 106, 0, 107, 135, 108, 0, 107, 108, 0,
1108 134, 109, 0, 134, 0, 135, 98, 134, 0, 135,
1109 0, 135, 98, 37, 0, 37, 0, 0, 132, 102,
1110 139, 104, 0, 132, 102, 104, 0, 132, 110, 24,
1111 0, 132, 105, 139, 106, 0, 132, 107, 139, 108,
1112 0, 132, 107, 108, 0, 132, 38, 0, 132, 39,
1113 0, 132, 163, 0, 132, 138, 0, 132, 26, 0,
1114 117, 112, 0, 118, 4, 0, 9, 27, 0, 9,
1115 28, 0, 120, 7, 0, 89, 100, 137, 36, 132,
1116 101, 0, 87, 100, 137, 177, 101, 0, 90, 100,
1117 137, 98, 137, 98, 137, 101, 0, 113, 100, 137,
1118 98, 137, 101, 0, 114, 100, 137, 98, 137, 101,
1119 0, 115, 100, 137, 98, 137, 101, 0, 116, 100,
1120 137, 98, 137, 101, 0, 94, 100, 137, 98, 137,
1121 101, 0, 139, 98, 137, 0, 137, 0, 32, 0,
1122 33, 0, 142, 0, 142, 159, 0, 142, 160, 0,
1123 142, 25, 0, 143, 0, 143, 121, 20, 130, 0,
1124 143, 160, 0, 0, 143, 121, 122, 140, 137, 144,
1125 128, 0, 0, 143, 121, 47, 140, 132, 145, 128,
1126 0, 143, 48, 147, 0, 143, 55, 97, 148, 0,
1127 0, 53, 0, 52, 0, 50, 97, 146, 0, 51,
1128 97, 4, 0, 49, 97, 24, 0, 102, 149, 104,
1129 0, 149, 98, 24, 0, 24, 0, 0, 22, 0,
1130 24, 0, 150, 0, 0, 132, 151, 0, 153, 98,
1131 152, 0, 152, 0, 153, 0, 153, 98, 37, 0,
1132 37, 0, 0, 123, 130, 150, 100, 154, 101, 127,
1133 124, 0, 29, 0, 107, 0, 122, 155, 156, 0,
1134 30, 0, 108, 0, 166, 158, 0, 0, 31, 161,
1135 155, 0, 3, 0, 4, 0, 7, 0, 27, 0,
1136 28, 0, 38, 0, 39, 0, 26, 0, 105, 139,
1137 106, 0, 138, 0, 111, 0, 150, 0, 163, 0,
1138 162, 0, 132, 164, 0, 166, 167, 0, 157, 167,
1139 0, 168, 121, 169, 0, 168, 171, 0, 0, 23,
1140 0, 62, 165, 0, 62, 8, 0, 63, 21, 164,
1141 0, 63, 9, 164, 98, 21, 164, 98, 21, 164,
1142 0, 64, 119, 164, 98, 21, 164, 102, 170, 104,
1143 0, 64, 119, 164, 98, 21, 164, 102, 104, 0,
1144 65, 123, 130, 164, 100, 174, 101, 36, 21, 164,
1145 66, 21, 164, 0, 66, 0, 67, 0, 170, 119,
1146 162, 98, 21, 164, 0, 119, 162, 98, 21, 164,
1147 0, 121, 176, 0, 132, 102, 164, 98, 164, 104,
1148 0, 172, 98, 102, 164, 98, 164, 104, 0, 165,
1149 0, 173, 98, 165, 0, 173, 0, 0, 57, 56,
1150 0, 56, 0, 113, 132, 164, 98, 164, 0, 114,
1151 132, 164, 98, 164, 0, 115, 132, 164, 98, 164,
1152 0, 46, 165, 0, 116, 165, 98, 165, 0, 89,
1153 165, 36, 132, 0, 90, 165, 98, 165, 98, 165,
1154 0, 93, 165, 98, 132, 0, 95, 165, 98, 132,
1155 0, 96, 165, 98, 132, 0, 94, 165, 98, 165,
1156 0, 88, 172, 0, 175, 123, 130, 164, 100, 174,
1157 101, 0, 179, 0, 98, 173, 0, 0, 35, 0,
1158 0, 82, 132, 125, 0, 82, 132, 98, 15, 164,
1159 125, 0, 83, 132, 125, 0, 83, 132, 98, 15,
1160 164, 125, 0, 84, 165, 0, 178, 85, 132, 164,
1161 0, 178, 86, 165, 98, 132, 164, 0, 87, 132,
1162 164, 177, 0
Nate Begeman14b05292005-11-05 09:21:28 +00001163};
Reid Spencer68a24bd2005-08-27 18:50:39 +00001164
1165#endif
1166
Nate Begeman14b05292005-11-05 09:21:28 +00001167#if YYDEBUG != 0
1168static const short yyrline[] = { 0,
Chris Lattner7aa61892005-12-21 17:53:23 +00001169 991, 992, 999, 1000, 1009, 1009, 1009, 1009, 1009, 1010,
1170 1010, 1010, 1011, 1011, 1011, 1011, 1011, 1011, 1013, 1013,
1171 1017, 1017, 1017, 1017, 1018, 1018, 1018, 1018, 1019, 1019,
1172 1020, 1020, 1023, 1026, 1030, 1030, 1031, 1032, 1033, 1036,
1173 1036, 1037, 1038, 1039, 1048, 1048, 1054, 1054, 1062, 1069,
1174 1069, 1075, 1075, 1077, 1081, 1094, 1094, 1095, 1095, 1097,
1175 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1107, 1107, 1107,
1176 1107, 1107, 1107, 1108, 1111, 1114, 1120, 1127, 1139, 1143,
1177 1154, 1163, 1166, 1174, 1178, 1183, 1184, 1187, 1190, 1200,
1178 1225, 1238, 1266, 1291, 1311, 1323, 1332, 1336, 1395, 1401,
1179 1409, 1414, 1419, 1422, 1425, 1432, 1442, 1473, 1480, 1501,
Robert Bocchino9c62b562006-01-10 19:04:32 +00001180 1511, 1516, 1523, 1533, 1536, 1543, 1543, 1553, 1560, 1564,
1181 1567, 1570, 1583, 1603, 1605, 1608, 1611, 1615, 1618, 1620,
1182 1622, 1627, 1628, 1630, 1633, 1641, 1646, 1648, 1652, 1656,
1183 1664, 1664, 1665, 1665, 1667, 1673, 1678, 1684, 1687, 1692,
1184 1696, 1700, 1786, 1786, 1788, 1796, 1796, 1798, 1802, 1802,
1185 1811, 1814, 1817, 1820, 1823, 1826, 1829, 1832, 1835, 1859,
1186 1866, 1869, 1874, 1874, 1880, 1884, 1887, 1895, 1904, 1908,
1187 1918, 1929, 1932, 1935, 1938, 1941, 1955, 1959, 2012, 2015,
1188 2021, 2029, 2039, 2046, 2051, 2058, 2062, 2068, 2068, 2070,
1189 2073, 2079, 2091, 2102, 2112, 2124, 2131, 2138, 2145, 2150,
1190 2169, 2191, 2199, 2213, 2270, 2276, 2278, 2282, 2285, 2291,
1191 2295, 2299, 2303, 2307, 2314, 2324, 2337
Nate Begeman14b05292005-11-05 09:21:28 +00001192};
1193#endif
1194
1195
1196#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
1197
1198static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL",
1199"EUINT64VAL","SINTVAL","UINTVAL","FPVAL","VOID","BOOL","SBYTE","UBYTE","SHORT",
1200"USHORT","INT","UINT","LONG","ULONG","FLOAT","DOUBLE","TYPE","LABEL","VAR_ID",
1201"LABELSTR","STRINGCONSTANT","IMPLEMENTATION","ZEROINITIALIZER","TRUETOK","FALSETOK",
Chris Lattnere869eef2005-11-12 00:11:49 +00001202"BEGINTOK","ENDTOK","DECLARE","GLOBAL","CONSTANT","SECTION","VOLATILE","TO",
1203"DOTDOTDOT","NULL_TOK","UNDEF","CONST","INTERNAL","LINKONCE","WEAK","APPENDING",
1204"OPAQUE","NOT","EXTERNAL","TARGET","TRIPLE","ENDIAN","POINTERSIZE","LITTLE",
1205"BIG","ALIGN","DEPLIBS","CALL","TAIL","CC_TOK","CCC_TOK","FASTCC_TOK","COLDCC_TOK",
1206"RET","BR","SWITCH","INVOKE","UNWIND","UNREACHABLE","ADD","SUB","MUL","DIV",
1207"REM","AND","OR","XOR","SETLE","SETGE","SETLT","SETGT","SETEQ","SETNE","MALLOC",
1208"ALLOCA","FREE","LOAD","STORE","GETELEMENTPTR","PHI_TOK","CAST","SELECT","SHL",
Robert Bocchino9c62b562006-01-10 19:04:32 +00001209"SHR","VAARG","EXTRACTELEMENT","VAARG_old","VANEXT_old","'='","','","'\\\\'",
1210"'('","')'","'['","'x'","']'","'<'","'>'","'{'","'}'","'*'","'c'","INTVAL","EINT64VAL",
1211"ArithmeticOps","LogicalOps","SetCondOps","ShiftOps","SIntType","UIntType","IntType",
1212"FPType","OptAssign","OptLinkage","OptCallingConv","OptAlign","OptCAlign","SectionString",
Chris Lattnerb475c422005-11-12 18:22:38 +00001213"OptSection","GlobalVarAttributes","GlobalVarAttribute","TypesV","UpRTypesV",
1214"Types","PrimType","UpRTypes","TypeListI","ArgTypeListI","ConstVal","ConstExpr",
1215"ConstVector","GlobalType","Module","FunctionList","ConstPool","@1","@2","BigOrLittle",
1216"TargetDefinition","LibrariesDefinition","LibList","Name","OptName","ArgVal",
1217"ArgListH","ArgList","FunctionHeaderH","BEGIN","FunctionHeader","END","Function",
1218"FunctionProto","@3","ConstValueRef","SymbolicValueRef","ValueRef","ResolvedVal",
1219"BasicBlockList","BasicBlock","InstructionList","BBTerminatorInst","JumpTable",
1220"Inst","PHIList","ValueRefList","ValueRefListE","OptTailCall","InstVal","IndexList",
1221"OptVolatile","MemoryInst", NULL
Nate Begeman14b05292005-11-05 09:21:28 +00001222};
1223#endif
1224
1225static const short yyr1[] = { 0,
Robert Bocchino9c62b562006-01-10 19:04:32 +00001226 111, 111, 112, 112, 113, 113, 113, 113, 113, 114,
1227 114, 114, 115, 115, 115, 115, 115, 115, 116, 116,
1228 117, 117, 117, 117, 118, 118, 118, 118, 119, 119,
1229 120, 120, 121, 121, 122, 122, 122, 122, 122, 123,
1230 123, 123, 123, 123, 124, 124, 125, 125, 126, 127,
1231 127, 128, 128, 129, 129, 130, 130, 131, 131, 132,
1232 133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
1233 133, 133, 133, 134, 134, 134, 134, 134, 134, 134,
1234 134, 134, 134, 135, 135, 136, 136, 136, 136, 137,
1235 137, 137, 137, 137, 137, 137, 137, 137, 137, 137,
1236 137, 137, 137, 137, 137, 138, 138, 138, 138, 138,
1237 138, 138, 138, 139, 139, 140, 140, 141, 142, 142,
1238 142, 142, 143, 143, 144, 143, 145, 143, 143, 143,
1239 143, 146, 146, 147, 147, 147, 148, 149, 149, 149,
1240 150, 150, 151, 151, 152, 153, 153, 154, 154, 154,
1241 154, 155, 156, 156, 157, 158, 158, 159, 161, 160,
1242 162, 162, 162, 162, 162, 162, 162, 162, 162, 162,
1243 163, 163, 164, 164, 165, 166, 166, 167, 168, 168,
1244 168, 169, 169, 169, 169, 169, 169, 169, 169, 169,
1245 170, 170, 171, 172, 172, 173, 173, 174, 174, 175,
1246 175, 176, 176, 176, 176, 176, 176, 176, 176, 176,
1247 176, 176, 176, 176, 176, 177, 177, 178, 178, 179,
1248 179, 179, 179, 179, 179, 179, 179
Nate Begeman14b05292005-11-05 09:21:28 +00001249};
1250
1251static const short yyr2[] = { 0,
1252 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1253 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1254 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1255 1, 1, 2, 0, 1, 1, 1, 1, 0, 0,
Chris Lattnere869eef2005-11-12 00:11:49 +00001256 1, 1, 1, 2, 0, 2, 0, 3, 2, 0,
Chris Lattnerb475c422005-11-12 18:22:38 +00001257 1, 0, 3, 1, 2, 1, 1, 1, 1, 1,
Nate Begeman14b05292005-11-05 09:21:28 +00001258 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Chris Lattnerb475c422005-11-12 18:22:38 +00001259 1, 1, 1, 1, 1, 1, 2, 4, 5, 5,
1260 3, 2, 2, 1, 3, 1, 3, 1, 0, 4,
1261 3, 3, 4, 4, 3, 2, 2, 2, 2, 2,
1262 2, 2, 2, 2, 2, 6, 5, 8, 6, 6,
Robert Bocchino9c62b562006-01-10 19:04:32 +00001263 6, 6, 6, 3, 1, 1, 1, 1, 2, 2,
1264 2, 1, 4, 2, 0, 7, 0, 7, 3, 4,
1265 0, 1, 1, 3, 3, 3, 3, 3, 1, 0,
1266 1, 1, 1, 0, 2, 3, 1, 1, 3, 1,
1267 0, 8, 1, 1, 3, 1, 1, 2, 0, 3,
1268 1, 1, 1, 1, 1, 1, 1, 1, 3, 1,
1269 1, 1, 1, 1, 2, 2, 2, 3, 2, 0,
1270 1, 2, 2, 3, 9, 9, 8, 13, 1, 1,
1271 6, 5, 2, 6, 7, 1, 3, 1, 0, 2,
1272 1, 5, 5, 5, 2, 4, 4, 6, 4, 4,
1273 4, 4, 2, 7, 1, 2, 0, 1, 0, 3,
1274 6, 3, 6, 2, 4, 6, 4
Nate Begeman14b05292005-11-05 09:21:28 +00001275};
1276
Robert Bocchino9c62b562006-01-10 19:04:32 +00001277static const short yydefact[] = { 131,
1278 39, 122, 121, 159, 35, 36, 37, 38, 40, 180,
1279 119, 120, 180, 141, 142, 0, 0, 39, 0, 124,
1280 40, 0, 41, 42, 43, 0, 0, 181, 177, 34,
1281 156, 157, 158, 176, 0, 0, 0, 129, 0, 0,
1282 0, 0, 33, 160, 44, 1, 2, 57, 61, 62,
Chris Lattnerb475c422005-11-12 18:22:38 +00001283 63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
Robert Bocchino9c62b562006-01-10 19:04:32 +00001284 73, 74, 0, 0, 0, 0, 171, 0, 0, 56,
1285 75, 60, 172, 76, 153, 154, 155, 219, 179, 0,
1286 0, 0, 140, 130, 123, 116, 117, 0, 0, 77,
1287 0, 0, 59, 82, 84, 0, 0, 89, 83, 218,
1288 0, 201, 0, 0, 0, 0, 40, 189, 190, 5,
Nate Begeman14b05292005-11-05 09:21:28 +00001289 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
1290 16, 17, 18, 0, 0, 0, 0, 0, 0, 0,
Robert Bocchino9c62b562006-01-10 19:04:32 +00001291 19, 20, 0, 0, 0, 0, 0, 0, 0, 0,
1292 178, 40, 193, 0, 215, 136, 133, 132, 134, 135,
1293 139, 0, 127, 61, 62, 63, 64, 65, 66, 67,
1294 68, 69, 70, 71, 0, 0, 0, 0, 125, 0,
1295 0, 0, 81, 151, 88, 86, 0, 0, 205, 200,
1296 183, 182, 0, 0, 24, 28, 23, 27, 22, 26,
1297 21, 25, 29, 30, 0, 0, 47, 47, 224, 0,
1298 0, 213, 0, 0, 0, 0, 0, 0, 0, 0,
1299 0, 0, 0, 0, 0, 0, 137, 52, 103, 104,
1300 3, 4, 101, 102, 105, 100, 96, 97, 0, 0,
1301 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1302 99, 98, 52, 58, 58, 85, 150, 144, 147, 148,
1303 0, 0, 78, 161, 162, 163, 168, 164, 165, 166,
1304 167, 0, 170, 174, 173, 175, 0, 184, 0, 0,
1305 0, 220, 0, 222, 217, 0, 0, 0, 0, 0,
1306 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1307 138, 0, 128, 0, 0, 0, 0, 91, 115, 0,
1308 0, 95, 0, 92, 0, 0, 0, 0, 126, 79,
1309 80, 143, 145, 0, 50, 87, 0, 0, 0, 0,
1310 0, 0, 0, 0, 227, 0, 0, 207, 0, 209,
1311 212, 210, 211, 0, 0, 0, 206, 0, 225, 0,
1312 0, 0, 54, 52, 217, 0, 0, 0, 0, 90,
1313 93, 94, 0, 0, 0, 0, 149, 146, 51, 45,
1314 169, 0, 0, 199, 47, 48, 47, 196, 216, 0,
1315 0, 0, 202, 203, 204, 199, 0, 49, 55, 53,
1316 0, 0, 0, 0, 114, 0, 0, 0, 0, 0,
1317 152, 0, 0, 198, 0, 0, 221, 223, 0, 0,
1318 0, 208, 0, 226, 107, 0, 0, 0, 0, 0,
1319 0, 0, 46, 0, 0, 0, 197, 194, 0, 214,
1320 106, 0, 113, 109, 110, 111, 112, 0, 187, 0,
1321 0, 0, 195, 0, 185, 0, 186, 0, 0, 108,
1322 0, 0, 0, 0, 0, 0, 192, 0, 0, 191,
1323 188, 0, 0, 0
Nate Begeman14b05292005-11-05 09:21:28 +00001324};
1325
1326static const short yydefgoto[] = { 67,
Robert Bocchino9c62b562006-01-10 19:04:32 +00001327 223, 237, 238, 239, 240, 165, 166, 195, 167, 18,
1328 9, 26, 391, 272, 343, 360, 293, 344, 68, 69,
1329 168, 71, 72, 96, 177, 299, 263, 300, 88, 452,
1330 1, 2, 243, 218, 149, 38, 84, 152, 73, 313,
1331 249, 250, 251, 27, 77, 10, 33, 11, 12, 21,
1332 264, 74, 266, 368, 13, 29, 30, 141, 431, 79,
1333 202, 394, 395, 142, 143, 325, 144, 145
Nate Begeman14b05292005-11-05 09:21:28 +00001334};
1335
1336static const short yypact[] = {-32768,
Robert Bocchino9c62b562006-01-10 19:04:32 +00001337 41, 181,-32768,-32768,-32768,-32768,-32768,-32768, 62, 12,
1338-32768,-32768, -14,-32768,-32768, 100, -8, 49, 0,-32768,
1339 62, 38,-32768,-32768,-32768, 979, -19,-32768,-32768, 112,
1340-32768,-32768,-32768,-32768, 8, 27, 68,-32768, 36, 979,
1341 -13, -13,-32768,-32768,-32768,-32768,-32768, 69,-32768,-32768,
Nate Begeman14b05292005-11-05 09:21:28 +00001342-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
Robert Bocchino9c62b562006-01-10 19:04:32 +00001343-32768,-32768, 169, 171, 173, 491,-32768, 112, 78,-32768,
1344-32768, -82,-32768,-32768,-32768,-32768,-32768, 1140,-32768, 156,
1345 24, 177, 158,-32768,-32768,-32768,-32768, 1017, 1055,-32768,
1346 81, 83,-32768,-32768, -82, -77, 90, 789,-32768,-32768,
1347 1017,-32768, 136, 1093, 4, 116, 62,-32768,-32768,-32768,
Nate Begeman14b05292005-11-05 09:21:28 +00001348-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
Robert Bocchino9c62b562006-01-10 19:04:32 +00001349-32768,-32768,-32768, 1017, 1017, 1017, 1017, 1017, 1017, 1017,
1350-32768,-32768, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017,
1351-32768, 62,-32768, 59,-32768,-32768,-32768,-32768,-32768,-32768,
1352-32768, -24,-32768, 126, 152, 189, 155, 190, 157, 191,
1353 160, 192, 193, 195, 168, 194, 197, 360,-32768, 1017,
1354 1017, 1017,-32768, 827,-32768, 101, 105, 610,-32768,-32768,
1355 69,-32768, 610, 610,-32768,-32768,-32768,-32768,-32768,-32768,
1356-32768,-32768,-32768,-32768, 610, 979, 113, 117,-32768, 610,
1357 114, 119, 196, 128, 132, 133, 137, 139, 610, 610,
1358 610, 140, 979, 1017, 1017, 210,-32768, 141,-32768,-32768,
1359-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 142, 143,
1360 144, 147, 865, 1055, 567, 216, 148, 149, 151, 159,
1361-32768,-32768, 141, 33, 37, -82,-32768, 112,-32768, 162,
1362 163, 903,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1363-32768, 1055,-32768,-32768,-32768,-32768, 165,-32768, 167, 610,
1364 7,-32768, 9,-32768, 170, 610, 164, 1017, 1017, 1017,
1365 1017, 1017, 1017, 172, 174, 175, 1017, 610, 610, 176,
1366-32768, 52,-32768, 1055, 1055, 1055, 1055,-32768,-32768, -17,
1367 -83,-32768, -72,-32768, 1055, 1055, 1055, 1055,-32768,-32768,
1368-32768,-32768,-32768, 941, 207,-32768, -33, 237, 246, 179,
1369 610, 265, 610, 1017,-32768, 183, 610,-32768, 184,-32768,
1370-32768,-32768,-32768, 610, 610, 610,-32768, 185,-32768, 1017,
1371 247, 271,-32768, 141, 170, 241, 188, 208, 1055,-32768,
1372-32768,-32768, 209, 211, 213, 215,-32768,-32768,-32768, 229,
1373-32768, 610, 610, 1017, 217,-32768, 217,-32768, 219, 610,
1374 220, 1017,-32768,-32768,-32768, 1017, 610,-32768,-32768,-32768,
1375 186, 1017, 1055, 1055,-32768, 1055, 1055, 1055, 1055, 285,
1376-32768, 224, 206, 219, 222, 236,-32768,-32768, 1017, 221,
1377 610,-32768, 223,-32768,-32768, 228, 235, 238, 239, 240,
1378 242, 243,-32768, 273, 35, 259,-32768,-32768, 232,-32768,
1379-32768, 1055,-32768,-32768,-32768,-32768,-32768, 610,-32768, 691,
1380 43, 316,-32768, 244,-32768, 249,-32768, 691, 610,-32768,
1381 321, 250, 283, 610, 330, 331,-32768, 610, 610,-32768,
1382-32768, 353, 354,-32768
Nate Begeman14b05292005-11-05 09:21:28 +00001383};
1384
Chris Lattner0019bbe2005-11-06 06:46:53 +00001385static const short yypgoto[] = {-32768,
Robert Bocchino9c62b562006-01-10 19:04:32 +00001386-32768, 277, 279, 281, 282, -105, -103, -403,-32768, 332,
1387 343, -78,-32768, -191, 48,-32768, -226,-32768, -34,-32768,
1388 -26,-32768, -55, 266,-32768, -87, 199, -167, 326,-32768,
1389-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 2,-32768,
1390 55,-32768,-32768, 349,-32768,-32768,-32768,-32768, 369,-32768,
1391 -359, -43, 121, -96,-32768, 359,-32768,-32768,-32768,-32768,
1392-32768, 50, -1,-32768,-32768, 31,-32768,-32768
Chris Lattner0019bbe2005-11-06 06:46:53 +00001393};
Nate Begeman14b05292005-11-05 09:21:28 +00001394
Chris Lattner0019bbe2005-11-06 06:46:53 +00001395
Robert Bocchino9c62b562006-01-10 19:04:32 +00001396#define YYLAST 1236
Nate Begeman14b05292005-11-05 09:21:28 +00001397
1398
1399static const short yytable[] = { 70,
Robert Bocchino9c62b562006-01-10 19:04:32 +00001400 193, 169, 194, 19, 179, 85, 274, 182, 28, 75,
1401 95, 430, 183, 70, 349, 31, 309, -58, 86, 87,
1402 172, 321, 351, 323, 184, 349, 99, 438, 196, 199,
1403 173, 19, 203, 204, 28, 352, 205, 206, 207, 208,
1404 -118, 45, 95, 212, 185, 186, 187, 188, 189, 190,
1405 191, 192, 185, 186, 187, 188, 189, 190, 191, 192,
1406 322, 153, 322, 213, 349, 3, 301, 303, 40, 97,
1407 436, 4, 361, 216, 178, 147, 148, 178, 442, 217,
1408 349, 5, 6, 7, 8, 341, 350, 76, 39, 5,
1409 6, 7, 8, 32, 317, 41, 43, 197, 198, 178,
1410 200, 201, 178, 178, 80, 342, 178, 178, 178, 178,
1411 209, 210, 211, 178, 244, 245, 246, 380, 290, 22,
1412 23, 24, 25, 81, 242, 185, 186, 187, 188, 189,
1413 190, 191, 192, 14, 265, 15, 310, 83, 429, 265,
1414 265, 99, 311, 214, 215, 99, 437, 248, 35, 36,
1415 37, 265, 219, 220, -24, -24, 265, -23, -23, -22,
1416 -22, 270, -21, -21, 82, 265, 265, 265, -59, 70,
1417 221, 222, 90, 397, 91, 398, 92, 98, 288, 146,
1418 150, 151, 329, 170, 331, 171, 70, 289, 178, 174,
1419 337, 180, -28, -27, -26, -25, 246, 224, 252, -31,
1420 -34, -32, 14, 225, 15, 253, 345, 346, 347, 348,
1421 271, 4, -34, -34, 273, 276, 277, 353, 354, 355,
1422 356, -34, -34, -34, -34, 279, 265, -34, 16, 280,
1423 281, 278, 265, 291, 282, 17, 283, 287, 292, 304,
1424 341, 294, 295, 296, 265, 265, 297, 305, 306, 312,
1425 307, 328, 178, 330, 178, 332, 333, 362, 308, 314,
1426 178, 385, 318, 315, 319, 327, 363, 324, 366, 334,
1427 378, 335, 336, 340, 379, 402, 382, 265, 364, 265,
1428 370, 372, 390, 265, 376, 383, 405, 248, 413, 322,
1429 265, 265, 265, 428, 432, 407, 408, 178, 409, 410,
1430 411, 412, 417, 267, 268, 384, 386, 415, 387, 193,
1431 388, 194, 389, 377, 396, 269, 399, 401, 265, 265,
1432 275, 414, 416, 420, 418, 193, 265, 194, 421, 284,
1433 285, 286, 422, 265, 434, 433, 439, 178, 423, 424,
1434 425, 444, 426, 427, 440, 178, 441, 445, 446, 178,
1435 448, 449, 453, 454, 137, 406, 138, 265, 139, 140,
1436 42, 78, 359, 176, 46, 47, 241, 89, 358, 44,
1437 20, 34, 178, 369, 403, 381, 0, 0, 0, 0,
1438 0, 14, 0, 15, 265, 226, 0, 0, 0, 0,
1439 320, 0, 0, 0, 0, 265, 326, 227, 228, 0,
1440 265, 0, 0, 0, 265, 265, 0, 0, 338, 339,
Nate Begeman14b05292005-11-05 09:21:28 +00001441 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Robert Bocchino9c62b562006-01-10 19:04:32 +00001442 0, 0, 0, 0, 0, 0, 0, 110, 111, 112,
Chris Lattner7aa61892005-12-21 17:53:23 +00001443 113, 114, 115, 116, 117, 118, 119, 120, 121, 122,
Robert Bocchino9c62b562006-01-10 19:04:32 +00001444 123, 365, 0, 367, 0, 0, 229, 371, 230, 231,
1445 131, 132, 0, 232, 373, 374, 375, 0, 0, 0,
1446 0, 233, 0, 0, 234, 0, 235, 0, 0, 236,
Chris Lattner7aa61892005-12-21 17:53:23 +00001447 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Robert Bocchino9c62b562006-01-10 19:04:32 +00001448 0, 0, 392, 393, 0, 0, 0, 0, 0, 0,
1449 400, 0, 0, 0, 0, 46, 47, 404, 93, 49,
1450 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
1451 60, 61, 14, 0, 15, 0, 0, 0, 0, 0,
1452 0, 419, 0, 0, 0, 0, 0, 0, 0, 0,
1453 0, 0, 0, 0, 0, 62, 0, 0, 0, 0,
1454 0, 0, 0, 0, 0, 0, 0, 0, 435, 0,
1455 0, 0, 0, 0, 0, 0, 0, 0, 0, 443,
1456 0, 0, 0, 0, 447, 0, 0, 0, 450, 451,
1457 0, 46, 47, 0, 93, 154, 155, 156, 157, 158,
1458 159, 160, 161, 162, 163, 164, 60, 61, 14, 63,
1459 15, 0, 64, 0, 0, 65, 0, 66, 94, 0,
1460 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1461 0, 62, 254, 255, 46, 47, 256, 0, 0, 0,
1462 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1463 0, 14, 0, 15, 0, 257, 258, 259, 0, 0,
1464 0, 0, 0, 0, 0, 0, 0, 260, 261, 0,
1465 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1466 0, 0, 0, 0, 0, 63, 0, 0, 64, 0,
1467 0, 65, 0, 66, 302, 0, 0, 110, 111, 112,
1468 113, 114, 115, 116, 117, 118, 119, 120, 121, 122,
1469 123, 0, 0, 254, 255, 0, 229, 256, 230, 231,
1470 131, 132, 0, 232, 0, 0, 0, 0, 0, 0,
1471 0, 0, 0, 0, 262, 0, 257, 258, 259, 0,
1472 0, 0, 0, 0, 0, 0, 0, 0, 260, 261,
Chris Lattner7aa61892005-12-21 17:53:23 +00001473 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1474 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Robert Bocchino9c62b562006-01-10 19:04:32 +00001475 0, 0, 0, 0, 0, 0, 0, 0, 110, 111,
1476 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
1477 122, 123, 0, 0, 0, 0, 0, 229, 0, 230,
1478 231, 131, 132, 0, 232, 0, 0, 0, 0, 0,
1479 0, 0, 0, 46, 47, 262, 93, 49, 50, 51,
1480 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
Chris Lattnere869eef2005-11-12 00:11:49 +00001481 14, 0, 15, 0, 0, 0, 0, 0, 0, 0,
Robert Bocchino9c62b562006-01-10 19:04:32 +00001482 0, 0, 0, 0, 0, 175, 0, 0, 0, 0,
1483 0, 46, 47, 62, 93, 49, 50, 51, 52, 53,
Chris Lattner7aa61892005-12-21 17:53:23 +00001484 54, 55, 56, 57, 58, 59, 60, 61, 14, 0,
Robert Bocchino9c62b562006-01-10 19:04:32 +00001485 15, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1486 0, 0, 0, 247, 0, 0, 0, 0, 0, 46,
1487 47, 62, 93, 154, 155, 156, 157, 158, 159, 160,
1488 161, 162, 163, 164, 60, 61, 14, 63, 15, 0,
1489 64, 0, 0, 65, 0, 66, 0, 0, 0, 0,
1490 0, 0, 0, 0, 0, 0, 0, 46, 47, 62,
1491 93, 49, 50, 51, 52, 53, 54, 55, 56, 57,
1492 58, 59, 60, 61, 14, 63, 15, 0, 64, 0,
1493 0, 65, 0, 66, 0, 0, 0, 0, 0, 316,
1494 0, 0, 0, 0, 0, 46, 47, 62, 93, 49,
1495 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
1496 60, 61, 14, 63, 15, 0, 64, 0, 298, 65,
1497 0, 66, 0, 0, 0, 0, 0, 357, 0, 0,
1498 0, 0, 0, 46, 47, 62, 48, 49, 50, 51,
1499 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
1500 14, 63, 15, 0, 64, 0, 0, 65, 0, 66,
1501 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1502 0, 46, 47, 62, 93, 49, 50, 51, 52, 53,
1503 54, 55, 56, 57, 58, 59, 60, 61, 14, 63,
1504 15, 0, 64, 0, 0, 65, 0, 66, 0, 0,
1505 0, 0, 0, 0, 0, 0, 0, 0, 0, 46,
1506 47, 62, 93, 154, 155, 156, 157, 158, 159, 160,
1507 161, 162, 163, 164, 60, 61, 14, 63, 15, 0,
1508 64, 0, 0, 65, 0, 66, 0, 0, 0, 0,
1509 0, 0, 0, 0, 0, 0, 0, 46, 47, 62,
1510 181, 49, 50, 51, 52, 53, 54, 55, 56, 57,
1511 58, 59, 60, 61, 14, 63, 15, 0, 64, 0,
1512 0, 65, 0, 66, 0, 0, 0, 0, 0, 0,
1513 0, 0, 0, 0, 0, 0, 0, 62, 0, 0,
1514 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1515 0, 0, 0, 63, 0, 0, 64, 0, 0, 65,
1516 0, 66, 0, 0, 0, 0, 0, 0, 0, 0,
1517 0, 0, 0, 0, 100, 0, 0, 0, 0, 0,
1518 0, 0, 0, 0, 0, 101, 0, 0, 0, 0,
1519 0, 63, 0, 0, 64, 102, 103, 65, 0, 66,
Chris Lattner7aa61892005-12-21 17:53:23 +00001520 0, 104, 105, 106, 107, 108, 109, 110, 111, 112,
1521 113, 114, 115, 116, 117, 118, 119, 120, 121, 122,
1522 123, 124, 125, 126, 0, 0, 127, 128, 129, 130,
Robert Bocchino9c62b562006-01-10 19:04:32 +00001523 131, 132, 133, 134, 135, 136
Nate Begeman14b05292005-11-05 09:21:28 +00001524};
1525
1526static const short yycheck[] = { 26,
Robert Bocchino9c62b562006-01-10 19:04:32 +00001527 106, 89, 106, 2, 101, 40, 198, 104, 23, 29,
1528 66, 415, 9, 40, 98, 30, 243, 100, 32, 33,
1529 98, 15, 106, 15, 21, 98, 109, 431, 107, 126,
1530 108, 30, 129, 130, 23, 108, 133, 134, 135, 136,
1531 0, 4, 98, 140, 10, 11, 12, 13, 14, 15,
1532 16, 17, 10, 11, 12, 13, 14, 15, 16, 17,
1533 54, 88, 54, 142, 98, 25, 234, 235, 20, 68,
1534 430, 31, 106, 98, 101, 52, 53, 104, 438, 104,
1535 98, 41, 42, 43, 44, 34, 104, 107, 97, 41,
1536 42, 43, 44, 108, 262, 47, 97, 124, 125, 126,
1537 127, 128, 129, 130, 97, 54, 133, 134, 135, 136,
1538 137, 138, 139, 140, 170, 171, 172, 344, 215, 58,
1539 59, 60, 61, 97, 168, 10, 11, 12, 13, 14,
1540 15, 16, 17, 22, 178, 24, 104, 102, 104, 183,
1541 184, 109, 106, 85, 86, 109, 104, 174, 49, 50,
1542 51, 195, 27, 28, 3, 4, 200, 3, 4, 3,
1543 4, 196, 3, 4, 97, 209, 210, 211, 100, 196,
1544 3, 4, 4, 365, 4, 367, 4, 100, 213, 24,
1545 4, 24, 279, 103, 281, 103, 213, 214, 215, 100,
1546 287, 56, 4, 4, 4, 4, 252, 4, 98, 7,
1547 20, 7, 22, 7, 24, 101, 294, 295, 296, 297,
1548 98, 31, 32, 33, 98, 102, 98, 305, 306, 307,
1549 308, 41, 42, 43, 44, 98, 270, 47, 48, 98,
1550 98, 36, 276, 24, 98, 55, 98, 98, 98, 24,
1551 34, 100, 100, 100, 288, 289, 100, 100, 100, 248,
1552 100, 278, 279, 280, 281, 282, 283, 21, 100, 98,
1553 287, 349, 98, 101, 98, 102, 21, 98, 4, 98,
1554 24, 98, 98, 98, 4, 372, 36, 321, 100, 323,
1555 98, 98, 54, 327, 100, 98, 101, 314, 4, 54,
1556 334, 335, 336, 21, 36, 383, 384, 324, 386, 387,
1557 388, 389, 399, 183, 184, 98, 98, 102, 98, 415,
1558 98, 415, 98, 340, 98, 195, 98, 98, 362, 363,
1559 200, 98, 101, 101, 104, 431, 370, 431, 101, 209,
1560 210, 211, 98, 377, 422, 104, 21, 364, 101, 101,
1561 101, 21, 101, 101, 101, 372, 98, 98, 66, 376,
1562 21, 21, 0, 0, 78, 382, 78, 401, 78, 78,
1563 18, 30, 315, 98, 5, 6, 168, 42, 314, 21,
1564 2, 13, 399, 324, 376, 345, -1, -1, -1, -1,
1565 -1, 22, -1, 24, 428, 26, -1, -1, -1, -1,
1566 270, -1, -1, -1, -1, 439, 276, 38, 39, -1,
1567 444, -1, -1, -1, 448, 449, -1, -1, 288, 289,
Chris Lattnerb475c422005-11-12 18:22:38 +00001568 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Robert Bocchino9c62b562006-01-10 19:04:32 +00001569 -1, -1, -1, -1, -1, -1, -1, 68, 69, 70,
Chris Lattner7aa61892005-12-21 17:53:23 +00001570 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
Robert Bocchino9c62b562006-01-10 19:04:32 +00001571 81, 321, -1, 323, -1, -1, 87, 327, 89, 90,
1572 91, 92, -1, 94, 334, 335, 336, -1, -1, -1,
1573 -1, 102, -1, -1, 105, -1, 107, -1, -1, 110,
Chris Lattner7aa61892005-12-21 17:53:23 +00001574 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Robert Bocchino9c62b562006-01-10 19:04:32 +00001575 -1, -1, 362, 363, -1, -1, -1, -1, -1, -1,
1576 370, -1, -1, -1, -1, 5, 6, 377, 8, 9,
1577 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
1578 20, 21, 22, -1, 24, -1, -1, -1, -1, -1,
1579 -1, 401, -1, -1, -1, -1, -1, -1, -1, -1,
1580 -1, -1, -1, -1, -1, 45, -1, -1, -1, -1,
1581 -1, -1, -1, -1, -1, -1, -1, -1, 428, -1,
1582 -1, -1, -1, -1, -1, -1, -1, -1, -1, 439,
1583 -1, -1, -1, -1, 444, -1, -1, -1, 448, 449,
Chris Lattner7aa61892005-12-21 17:53:23 +00001584 -1, 5, 6, -1, 8, 9, 10, 11, 12, 13,
Robert Bocchino9c62b562006-01-10 19:04:32 +00001585 14, 15, 16, 17, 18, 19, 20, 21, 22, 99,
1586 24, -1, 102, -1, -1, 105, -1, 107, 108, -1,
Chris Lattnerb475c422005-11-12 18:22:38 +00001587 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Robert Bocchino9c62b562006-01-10 19:04:32 +00001588 -1, 45, 3, 4, 5, 6, 7, -1, -1, -1,
1589 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1590 -1, 22, -1, 24, -1, 26, 27, 28, -1, -1,
1591 -1, -1, -1, -1, -1, -1, -1, 38, 39, -1,
1592 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1593 -1, -1, -1, -1, -1, 99, -1, -1, 102, -1,
1594 -1, 105, -1, 107, 108, -1, -1, 68, 69, 70,
1595 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
1596 81, -1, -1, 3, 4, -1, 87, 7, 89, 90,
1597 91, 92, -1, 94, -1, -1, -1, -1, -1, -1,
1598 -1, -1, -1, -1, 105, -1, 26, 27, 28, -1,
1599 -1, -1, -1, -1, -1, -1, -1, -1, 38, 39,
1600 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1601 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1602 -1, -1, -1, -1, -1, -1, -1, -1, 68, 69,
1603 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
1604 80, 81, -1, -1, -1, -1, -1, 87, -1, 89,
1605 90, 91, 92, -1, 94, -1, -1, -1, -1, -1,
1606 -1, -1, -1, 5, 6, 105, 8, 9, 10, 11,
Chris Lattnerb475c422005-11-12 18:22:38 +00001607 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
1608 22, -1, 24, -1, -1, -1, -1, -1, -1, -1,
Robert Bocchino9c62b562006-01-10 19:04:32 +00001609 -1, -1, -1, -1, -1, 37, -1, -1, -1, -1,
1610 -1, 5, 6, 45, 8, 9, 10, 11, 12, 13,
Chris Lattner7aa61892005-12-21 17:53:23 +00001611 14, 15, 16, 17, 18, 19, 20, 21, 22, -1,
Robert Bocchino9c62b562006-01-10 19:04:32 +00001612 24, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1613 -1, -1, -1, 37, -1, -1, -1, -1, -1, 5,
1614 6, 45, 8, 9, 10, 11, 12, 13, 14, 15,
1615 16, 17, 18, 19, 20, 21, 22, 99, 24, -1,
1616 102, -1, -1, 105, -1, 107, -1, -1, -1, -1,
1617 -1, -1, -1, -1, -1, -1, -1, 5, 6, 45,
1618 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
1619 18, 19, 20, 21, 22, 99, 24, -1, 102, -1,
1620 -1, 105, -1, 107, -1, -1, -1, -1, -1, 37,
1621 -1, -1, -1, -1, -1, 5, 6, 45, 8, 9,
1622 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
1623 20, 21, 22, 99, 24, -1, 102, -1, 104, 105,
1624 -1, 107, -1, -1, -1, -1, -1, 37, -1, -1,
1625 -1, -1, -1, 5, 6, 45, 8, 9, 10, 11,
1626 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
1627 22, 99, 24, -1, 102, -1, -1, 105, -1, 107,
1628 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1629 -1, 5, 6, 45, 8, 9, 10, 11, 12, 13,
1630 14, 15, 16, 17, 18, 19, 20, 21, 22, 99,
1631 24, -1, 102, -1, -1, 105, -1, 107, -1, -1,
1632 -1, -1, -1, -1, -1, -1, -1, -1, -1, 5,
1633 6, 45, 8, 9, 10, 11, 12, 13, 14, 15,
1634 16, 17, 18, 19, 20, 21, 22, 99, 24, -1,
1635 102, -1, -1, 105, -1, 107, -1, -1, -1, -1,
1636 -1, -1, -1, -1, -1, -1, -1, 5, 6, 45,
1637 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
1638 18, 19, 20, 21, 22, 99, 24, -1, 102, -1,
1639 -1, 105, -1, 107, -1, -1, -1, -1, -1, -1,
1640 -1, -1, -1, -1, -1, -1, -1, 45, -1, -1,
1641 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1642 -1, -1, -1, 99, -1, -1, 102, -1, -1, 105,
1643 -1, 107, -1, -1, -1, -1, -1, -1, -1, -1,
1644 -1, -1, -1, -1, 35, -1, -1, -1, -1, -1,
1645 -1, -1, -1, -1, -1, 46, -1, -1, -1, -1,
1646 -1, 99, -1, -1, 102, 56, 57, 105, -1, 107,
Chris Lattner7aa61892005-12-21 17:53:23 +00001647 -1, 62, 63, 64, 65, 66, 67, 68, 69, 70,
1648 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
1649 81, 82, 83, 84, -1, -1, 87, 88, 89, 90,
Robert Bocchino9c62b562006-01-10 19:04:32 +00001650 91, 92, 93, 94, 95, 96
Nate Begeman14b05292005-11-05 09:21:28 +00001651};
1652/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
1653#line 3 "/usr/share/bison.simple"
1654/* This file comes from bison-1.28. */
1655
1656/* Skeleton output parser for bison,
1657 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
1658
1659 This program is free software; you can redistribute it and/or modify
1660 it under the terms of the GNU General Public License as published by
1661 the Free Software Foundation; either version 2, or (at your option)
1662 any later version.
1663
1664 This program is distributed in the hope that it will be useful,
1665 but WITHOUT ANY WARRANTY; without even the implied warranty of
1666 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1667 GNU General Public License for more details.
1668
1669 You should have received a copy of the GNU General Public License
1670 along with this program; if not, write to the Free Software
1671 Foundation, Inc., 59 Temple Place - Suite 330,
1672 Boston, MA 02111-1307, USA. */
1673
1674/* As a special exception, when this file is copied by Bison into a
1675 Bison output file, you may use that output file without restriction.
1676 This special exception was added by the Free Software Foundation
1677 in version 1.24 of Bison. */
1678
1679/* This is the parser code that is written into each bison parser
1680 when the %semantic_parser declaration is not specified in the grammar.
1681 It was written by Richard Stallman by simplifying the hairy parser
1682 used when %semantic_parser is specified. */
1683
1684#ifndef YYSTACK_USE_ALLOCA
1685#ifdef alloca
1686#define YYSTACK_USE_ALLOCA
1687#else /* alloca not defined */
1688#ifdef __GNUC__
1689#define YYSTACK_USE_ALLOCA
1690#define alloca __builtin_alloca
1691#else /* not GNU C. */
1692#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
1693#define YYSTACK_USE_ALLOCA
1694#include <alloca.h>
1695#else /* not sparc */
1696/* We think this test detects Watcom and Microsoft C. */
1697/* This used to test MSDOS, but that is a bad idea
1698 since that symbol is in the user namespace. */
1699#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
1700#if 0 /* No need for malloc.h, which pollutes the namespace;
1701 instead, just don't use alloca. */
1702#include <malloc.h>
1703#endif
1704#else /* not MSDOS, or __TURBOC__ */
1705#if defined(_AIX)
1706/* I don't know what this was needed for, but it pollutes the namespace.
1707 So I turned it off. rms, 2 May 1997. */
1708/* #include <malloc.h> */
1709 #pragma alloca
1710#define YYSTACK_USE_ALLOCA
1711#else /* not MSDOS, or __TURBOC__, or _AIX */
1712#if 0
1713#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
1714 and on HPUX 10. Eventually we can turn this on. */
1715#define YYSTACK_USE_ALLOCA
1716#define alloca __builtin_alloca
1717#endif /* __hpux */
1718#endif
1719#endif /* not _AIX */
1720#endif /* not MSDOS, or __TURBOC__ */
1721#endif /* not sparc */
1722#endif /* not GNU C */
1723#endif /* alloca not defined */
1724#endif /* YYSTACK_USE_ALLOCA not defined */
1725
1726#ifdef YYSTACK_USE_ALLOCA
1727#define YYSTACK_ALLOC alloca
Reid Spencer68a24bd2005-08-27 18:50:39 +00001728#else
Nate Begeman14b05292005-11-05 09:21:28 +00001729#define YYSTACK_ALLOC malloc
Reid Spencer68a24bd2005-08-27 18:50:39 +00001730#endif
1731
Nate Begeman14b05292005-11-05 09:21:28 +00001732/* Note: there must be only one dollar sign in this file.
1733 It is replaced by the list of actions, each action
1734 as one case of the switch. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001735
1736#define yyerrok (yyerrstatus = 0)
1737#define yyclearin (yychar = YYEMPTY)
Nate Begeman14b05292005-11-05 09:21:28 +00001738#define YYEMPTY -2
Reid Spencer68a24bd2005-08-27 18:50:39 +00001739#define YYEOF 0
Reid Spencer68a24bd2005-08-27 18:50:39 +00001740#define YYACCEPT goto yyacceptlab
Nate Begeman14b05292005-11-05 09:21:28 +00001741#define YYABORT goto yyabortlab
1742#define YYERROR goto yyerrlab1
1743/* Like YYERROR except do call yyerror.
1744 This remains here temporarily to ease the
1745 transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00001746 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001747#define YYFAIL goto yyerrlab
Reid Spencer68a24bd2005-08-27 18:50:39 +00001748#define YYRECOVERING() (!!yyerrstatus)
Nate Begeman14b05292005-11-05 09:21:28 +00001749#define YYBACKUP(token, value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00001750do \
1751 if (yychar == YYEMPTY && yylen == 1) \
Nate Begeman14b05292005-11-05 09:21:28 +00001752 { yychar = (token), yylval = (value); \
1753 yychar1 = YYTRANSLATE (yychar); \
Reid Spencer68a24bd2005-08-27 18:50:39 +00001754 YYPOPSTACK; \
1755 goto yybackup; \
1756 } \
1757 else \
Nate Begeman14b05292005-11-05 09:21:28 +00001758 { yyerror ("syntax error: cannot back up"); YYERROR; } \
Reid Spencer68a24bd2005-08-27 18:50:39 +00001759while (0)
1760
1761#define YYTERROR 1
1762#define YYERRCODE 256
1763
Nate Begeman14b05292005-11-05 09:21:28 +00001764#ifndef YYPURE
1765#define YYLEX yylex()
Reid Spencer68a24bd2005-08-27 18:50:39 +00001766#endif
1767
Nate Begeman14b05292005-11-05 09:21:28 +00001768#ifdef YYPURE
1769#ifdef YYLSP_NEEDED
Reid Spencer68a24bd2005-08-27 18:50:39 +00001770#ifdef YYLEX_PARAM
Nate Begeman14b05292005-11-05 09:21:28 +00001771#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001772#else
Nate Begeman14b05292005-11-05 09:21:28 +00001773#define YYLEX yylex(&yylval, &yylloc)
1774#endif
1775#else /* not YYLSP_NEEDED */
1776#ifdef YYLEX_PARAM
1777#define YYLEX yylex(&yylval, YYLEX_PARAM)
1778#else
1779#define YYLEX yylex(&yylval)
1780#endif
1781#endif /* not YYLSP_NEEDED */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001782#endif
1783
Nate Begeman14b05292005-11-05 09:21:28 +00001784/* If nonreentrant, generate the variables here */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001785
Nate Begeman14b05292005-11-05 09:21:28 +00001786#ifndef YYPURE
Reid Spencer68a24bd2005-08-27 18:50:39 +00001787
Nate Begeman14b05292005-11-05 09:21:28 +00001788int yychar; /* the lookahead symbol */
1789YYSTYPE yylval; /* the semantic value of the */
1790 /* lookahead symbol */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001791
Nate Begeman14b05292005-11-05 09:21:28 +00001792#ifdef YYLSP_NEEDED
1793YYLTYPE yylloc; /* location data for the lookahead */
1794 /* symbol */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001795#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001796
Nate Begeman14b05292005-11-05 09:21:28 +00001797int yynerrs; /* number of parse errors so far */
1798#endif /* not YYPURE */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001799
Nate Begeman14b05292005-11-05 09:21:28 +00001800#if YYDEBUG != 0
1801int yydebug; /* nonzero means print parse trace */
1802/* Since this is uninitialized, it does not stop multiple parsers
1803 from coexisting. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001804#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001805
Nate Begeman14b05292005-11-05 09:21:28 +00001806/* YYINITDEPTH indicates the initial size of the parser's stacks */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001807
Reid Spencer68a24bd2005-08-27 18:50:39 +00001808#ifndef YYINITDEPTH
Nate Begeman14b05292005-11-05 09:21:28 +00001809#define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00001810#endif
1811
Nate Begeman14b05292005-11-05 09:21:28 +00001812/* YYMAXDEPTH is the maximum size the stacks can grow to
1813 (effective only if the built-in stack extension method is used). */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001814
Nate Begeman14b05292005-11-05 09:21:28 +00001815#if YYMAXDEPTH == 0
1816#undef YYMAXDEPTH
Reid Spencer68a24bd2005-08-27 18:50:39 +00001817#endif
1818
1819#ifndef YYMAXDEPTH
Nate Begeman14b05292005-11-05 09:21:28 +00001820#define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00001821#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001822
Nate Begeman14b05292005-11-05 09:21:28 +00001823/* Define __yy_memcpy. Note that the size argument
1824 should be passed with type unsigned int, because that is what the non-GCC
1825 definitions require. With GCC, __builtin_memcpy takes an arg
1826 of type size_t, but it can handle unsigned int. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001827
Nate Begeman14b05292005-11-05 09:21:28 +00001828#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
1829#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
1830#else /* not GNU C or C++ */
1831#ifndef __cplusplus
Reid Spencer68a24bd2005-08-27 18:50:39 +00001832
Nate Begeman14b05292005-11-05 09:21:28 +00001833/* This is the most reliable way to avoid incompatibilities
1834 in available built-in functions on various systems. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001835static void
Nate Begeman14b05292005-11-05 09:21:28 +00001836__yy_memcpy (to, from, count)
1837 char *to;
1838 char *from;
1839 unsigned int count;
1840{
1841 register char *f = from;
1842 register char *t = to;
1843 register int i = count;
1844
1845 while (i-- > 0)
1846 *t++ = *f++;
1847}
1848
1849#else /* __cplusplus */
1850
1851/* This is the most reliable way to avoid incompatibilities
1852 in available built-in functions on various systems. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001853static void
Nate Begeman14b05292005-11-05 09:21:28 +00001854__yy_memcpy (char *to, char *from, unsigned int count)
1855{
1856 register char *t = to;
1857 register char *f = from;
1858 register int i = count;
1859
1860 while (i-- > 0)
1861 *t++ = *f++;
1862}
1863
Reid Spencer68a24bd2005-08-27 18:50:39 +00001864#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001865#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001866
Nate Begeman14b05292005-11-05 09:21:28 +00001867#line 217 "/usr/share/bison.simple"
Reid Spencer68a24bd2005-08-27 18:50:39 +00001868
Nate Begeman14b05292005-11-05 09:21:28 +00001869/* The user can define YYPARSE_PARAM as the name of an argument to be passed
1870 into yyparse. The argument should have type void *.
1871 It should actually point to an object.
1872 Grammar actions can access the variable by casting it
1873 to the proper pointer type. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001874
1875#ifdef YYPARSE_PARAM
Nate Begeman14b05292005-11-05 09:21:28 +00001876#ifdef __cplusplus
1877#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
1878#define YYPARSE_PARAM_DECL
1879#else /* not __cplusplus */
1880#define YYPARSE_PARAM_ARG YYPARSE_PARAM
1881#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
1882#endif /* not __cplusplus */
1883#else /* not YYPARSE_PARAM */
1884#define YYPARSE_PARAM_ARG
1885#define YYPARSE_PARAM_DECL
1886#endif /* not YYPARSE_PARAM */
1887
1888/* Prevent warning if -Wstrict-prototypes. */
1889#ifdef __GNUC__
1890#ifdef YYPARSE_PARAM
1891int yyparse (void *);
1892#else
Reid Spencer68a24bd2005-08-27 18:50:39 +00001893int yyparse (void);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001894#endif
Nate Begeman14b05292005-11-05 09:21:28 +00001895#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001896
Reid Spencer68a24bd2005-08-27 18:50:39 +00001897int
Nate Begeman14b05292005-11-05 09:21:28 +00001898yyparse(YYPARSE_PARAM_ARG)
1899 YYPARSE_PARAM_DECL
Reid Spencer68a24bd2005-08-27 18:50:39 +00001900{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001901 register int yystate;
1902 register int yyn;
Nate Begeman14b05292005-11-05 09:21:28 +00001903 register short *yyssp;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001904 register YYSTYPE *yyvsp;
Nate Begeman14b05292005-11-05 09:21:28 +00001905 int yyerrstatus; /* number of tokens to shift before error messages enabled */
1906 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001907
Nate Begeman14b05292005-11-05 09:21:28 +00001908 short yyssa[YYINITDEPTH]; /* the state stack */
1909 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001910
Nate Begeman14b05292005-11-05 09:21:28 +00001911 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
1912 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001913
Nate Begeman14b05292005-11-05 09:21:28 +00001914#ifdef YYLSP_NEEDED
1915 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
1916 YYLTYPE *yyls = yylsa;
1917 YYLTYPE *yylsp;
1918
1919#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
1920#else
Reid Spencer68a24bd2005-08-27 18:50:39 +00001921#define YYPOPSTACK (yyvsp--, yyssp--)
Nate Begeman14b05292005-11-05 09:21:28 +00001922#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001923
Nate Begeman14b05292005-11-05 09:21:28 +00001924 int yystacksize = YYINITDEPTH;
1925 int yyfree_stacks = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001926
Nate Begeman14b05292005-11-05 09:21:28 +00001927#ifdef YYPURE
1928 int yychar;
1929 YYSTYPE yylval;
1930 int yynerrs;
1931#ifdef YYLSP_NEEDED
1932 YYLTYPE yylloc;
1933#endif
1934#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001935
Nate Begeman14b05292005-11-05 09:21:28 +00001936 YYSTYPE yyval; /* the variable used to return */
1937 /* semantic values from the action */
1938 /* routines */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001939
Reid Spencer68a24bd2005-08-27 18:50:39 +00001940 int yylen;
1941
Nate Begeman14b05292005-11-05 09:21:28 +00001942#if YYDEBUG != 0
1943 if (yydebug)
1944 fprintf(stderr, "Starting parse\n");
1945#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001946
1947 yystate = 0;
1948 yyerrstatus = 0;
1949 yynerrs = 0;
1950 yychar = YYEMPTY; /* Cause a token to be read. */
1951
1952 /* Initialize stack pointers.
1953 Waste one element of value and location stack
1954 so that they stay on the same level as the state stack.
1955 The wasted elements are never initialized. */
1956
Nate Begeman14b05292005-11-05 09:21:28 +00001957 yyssp = yyss - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001958 yyvsp = yyvs;
Nate Begeman14b05292005-11-05 09:21:28 +00001959#ifdef YYLSP_NEEDED
1960 yylsp = yyls;
1961#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001962
Nate Begeman14b05292005-11-05 09:21:28 +00001963/* Push a new state, which is found in yystate . */
1964/* In all cases, when you get here, the value and location stacks
1965 have just been pushed. so pushing a state here evens the stacks. */
1966yynewstate:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001967
Nate Begeman14b05292005-11-05 09:21:28 +00001968 *++yyssp = yystate;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001969
Nate Begeman14b05292005-11-05 09:21:28 +00001970 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001971 {
Nate Begeman14b05292005-11-05 09:21:28 +00001972 /* Give user a chance to reallocate the stack */
1973 /* Use copies of these so that the &'s don't force the real ones into memory. */
1974 YYSTYPE *yyvs1 = yyvs;
1975 short *yyss1 = yyss;
1976#ifdef YYLSP_NEEDED
1977 YYLTYPE *yyls1 = yyls;
1978#endif
1979
Reid Spencer68a24bd2005-08-27 18:50:39 +00001980 /* Get the current used size of the three stacks, in elements. */
Nate Begeman14b05292005-11-05 09:21:28 +00001981 int size = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001982
1983#ifdef yyoverflow
Nate Begeman14b05292005-11-05 09:21:28 +00001984 /* Each stack pointer address is followed by the size of
1985 the data in use in that stack, in bytes. */
1986#ifdef YYLSP_NEEDED
1987 /* This used to be a conditional around just the two extra args,
1988 but that might be undefined if yyoverflow is a macro. */
1989 yyoverflow("parser stack overflow",
1990 &yyss1, size * sizeof (*yyssp),
1991 &yyvs1, size * sizeof (*yyvsp),
1992 &yyls1, size * sizeof (*yylsp),
1993 &yystacksize);
1994#else
1995 yyoverflow("parser stack overflow",
1996 &yyss1, size * sizeof (*yyssp),
1997 &yyvs1, size * sizeof (*yyvsp),
1998 &yystacksize);
1999#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002000
Nate Begeman14b05292005-11-05 09:21:28 +00002001 yyss = yyss1; yyvs = yyvs1;
2002#ifdef YYLSP_NEEDED
2003 yyls = yyls1;
2004#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002005#else /* no yyoverflow */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002006 /* Extend the stack our own way. */
Nate Begeman14b05292005-11-05 09:21:28 +00002007 if (yystacksize >= YYMAXDEPTH)
2008 {
2009 yyerror("parser stack overflow");
2010 if (yyfree_stacks)
2011 {
2012 free (yyss);
2013 free (yyvs);
2014#ifdef YYLSP_NEEDED
2015 free (yyls);
2016#endif
2017 }
2018 return 2;
2019 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002020 yystacksize *= 2;
Nate Begeman14b05292005-11-05 09:21:28 +00002021 if (yystacksize > YYMAXDEPTH)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002022 yystacksize = YYMAXDEPTH;
Nate Begeman14b05292005-11-05 09:21:28 +00002023#ifndef YYSTACK_USE_ALLOCA
2024 yyfree_stacks = 1;
2025#endif
2026 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
2027 __yy_memcpy ((char *)yyss, (char *)yyss1,
2028 size * (unsigned int) sizeof (*yyssp));
2029 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
2030 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
2031 size * (unsigned int) sizeof (*yyvsp));
2032#ifdef YYLSP_NEEDED
2033 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
2034 __yy_memcpy ((char *)yyls, (char *)yyls1,
2035 size * (unsigned int) sizeof (*yylsp));
2036#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002037#endif /* no yyoverflow */
2038
Nate Begeman14b05292005-11-05 09:21:28 +00002039 yyssp = yyss + size - 1;
2040 yyvsp = yyvs + size - 1;
2041#ifdef YYLSP_NEEDED
2042 yylsp = yyls + size - 1;
2043#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002044
Nate Begeman14b05292005-11-05 09:21:28 +00002045#if YYDEBUG != 0
2046 if (yydebug)
2047 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2048#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002049
Nate Begeman14b05292005-11-05 09:21:28 +00002050 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002051 YYABORT;
2052 }
2053
Nate Begeman14b05292005-11-05 09:21:28 +00002054#if YYDEBUG != 0
2055 if (yydebug)
2056 fprintf(stderr, "Entering state %d\n", yystate);
2057#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002058
2059 goto yybackup;
Nate Begeman14b05292005-11-05 09:21:28 +00002060 yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002061
2062/* Do appropriate processing given the current state. */
2063/* Read a lookahead token if we need one and don't already have one. */
2064/* yyresume: */
2065
2066 /* First try to decide what to do without reference to lookahead token. */
2067
2068 yyn = yypact[yystate];
Nate Begeman14b05292005-11-05 09:21:28 +00002069 if (yyn == YYFLAG)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002070 goto yydefault;
2071
2072 /* Not known => get a lookahead token if don't already have one. */
2073
Nate Begeman14b05292005-11-05 09:21:28 +00002074 /* yychar is either YYEMPTY or YYEOF
2075 or a valid token in external form. */
2076
Reid Spencer68a24bd2005-08-27 18:50:39 +00002077 if (yychar == YYEMPTY)
2078 {
Nate Begeman14b05292005-11-05 09:21:28 +00002079#if YYDEBUG != 0
2080 if (yydebug)
2081 fprintf(stderr, "Reading a token: ");
2082#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002083 yychar = YYLEX;
2084 }
2085
Nate Begeman14b05292005-11-05 09:21:28 +00002086 /* Convert token to internal form (in yychar1) for indexing tables with */
2087
2088 if (yychar <= 0) /* This means end of input. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002089 {
Nate Begeman14b05292005-11-05 09:21:28 +00002090 yychar1 = 0;
2091 yychar = YYEOF; /* Don't call YYLEX any more */
2092
2093#if YYDEBUG != 0
2094 if (yydebug)
2095 fprintf(stderr, "Now at end of input.\n");
2096#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002097 }
2098 else
2099 {
Nate Begeman14b05292005-11-05 09:21:28 +00002100 yychar1 = YYTRANSLATE(yychar);
2101
2102#if YYDEBUG != 0
2103 if (yydebug)
2104 {
2105 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2106 /* Give the individual parser a way to print the precise meaning
2107 of a token, for further debugging info. */
2108#ifdef YYPRINT
2109 YYPRINT (stderr, yychar, yylval);
2110#endif
2111 fprintf (stderr, ")\n");
2112 }
2113#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002114 }
2115
Nate Begeman14b05292005-11-05 09:21:28 +00002116 yyn += yychar1;
2117 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002118 goto yydefault;
Nate Begeman14b05292005-11-05 09:21:28 +00002119
Reid Spencer68a24bd2005-08-27 18:50:39 +00002120 yyn = yytable[yyn];
Nate Begeman14b05292005-11-05 09:21:28 +00002121
2122 /* yyn is what to do for this token type in this state.
2123 Negative => reduce, -yyn is rule number.
2124 Positive => shift, yyn is new state.
2125 New state is final state => don't bother to shift,
2126 just return success.
2127 0, or most negative number => error. */
2128
2129 if (yyn < 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002130 {
Nate Begeman14b05292005-11-05 09:21:28 +00002131 if (yyn == YYFLAG)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002132 goto yyerrlab;
2133 yyn = -yyn;
2134 goto yyreduce;
2135 }
Nate Begeman14b05292005-11-05 09:21:28 +00002136 else if (yyn == 0)
2137 goto yyerrlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002138
2139 if (yyn == YYFINAL)
2140 YYACCEPT;
2141
2142 /* Shift the lookahead token. */
Nate Begeman14b05292005-11-05 09:21:28 +00002143
2144#if YYDEBUG != 0
2145 if (yydebug)
2146 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2147#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002148
2149 /* Discard the token being shifted unless it is eof. */
2150 if (yychar != YYEOF)
2151 yychar = YYEMPTY;
2152
2153 *++yyvsp = yylval;
Nate Begeman14b05292005-11-05 09:21:28 +00002154#ifdef YYLSP_NEEDED
2155 *++yylsp = yylloc;
2156#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002157
Nate Begeman14b05292005-11-05 09:21:28 +00002158 /* count tokens shifted since error; after three, turn off error status. */
2159 if (yyerrstatus) yyerrstatus--;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002160
2161 yystate = yyn;
2162 goto yynewstate;
2163
Nate Begeman14b05292005-11-05 09:21:28 +00002164/* Do the default action for the current state. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002165yydefault:
Nate Begeman14b05292005-11-05 09:21:28 +00002166
Reid Spencer68a24bd2005-08-27 18:50:39 +00002167 yyn = yydefact[yystate];
2168 if (yyn == 0)
2169 goto yyerrlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002170
Nate Begeman14b05292005-11-05 09:21:28 +00002171/* Do a reduction. yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002172yyreduce:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002173 yylen = yyr2[yyn];
Nate Begeman14b05292005-11-05 09:21:28 +00002174 if (yylen > 0)
2175 yyval = yyvsp[1-yylen]; /* implement default value of the action */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002176
Nate Begeman14b05292005-11-05 09:21:28 +00002177#if YYDEBUG != 0
2178 if (yydebug)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002179 {
Nate Begeman14b05292005-11-05 09:21:28 +00002180 int i;
2181
2182 fprintf (stderr, "Reducing via rule %d (line %d), ",
2183 yyn, yyrline[yyn]);
2184
2185 /* Print the symbols being reduced, and their result. */
2186 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2187 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2188 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2189 }
2190#endif
2191
2192
2193 switch (yyn) {
2194
2195case 2:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002196#line 992 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002197{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002198 if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX) // Outside of my range!
2199 ThrowException("Value too large for type!");
2200 yyval.SIntVal = (int32_t)yyvsp[0].UIntVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002201;
2202 break;}
2203case 4:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002204#line 1000 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002205{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002206 if (yyvsp[0].UInt64Val > (uint64_t)INT64_MAX) // Outside of my range!
2207 ThrowException("Value too large for type!");
2208 yyval.SInt64Val = (int64_t)yyvsp[0].UInt64Val;
Nate Begeman14b05292005-11-05 09:21:28 +00002209;
2210 break;}
2211case 33:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002212#line 1023 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002213{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002214 yyval.StrVal = yyvsp[-1].StrVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002215 ;
2216 break;}
2217case 34:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002218#line 1026 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002219{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002220 yyval.StrVal = 0;
Nate Begeman14b05292005-11-05 09:21:28 +00002221 ;
2222 break;}
2223case 35:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002224#line 1030 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002225{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2226 break;}
2227case 36:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002228#line 1031 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002229{ yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2230 break;}
2231case 37:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002232#line 1032 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002233{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2234 break;}
2235case 38:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002236#line 1033 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002237{ yyval.Linkage = GlobalValue::AppendingLinkage; ;
2238 break;}
2239case 39:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002240#line 1034 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002241{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2242 break;}
2243case 40:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002244#line 1036 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002245{ yyval.UIntVal = CallingConv::C; ;
2246 break;}
2247case 41:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002248#line 1037 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002249{ yyval.UIntVal = CallingConv::C; ;
2250 break;}
2251case 42:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002252#line 1038 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002253{ yyval.UIntVal = CallingConv::Fast; ;
2254 break;}
2255case 43:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002256#line 1039 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002257{ yyval.UIntVal = CallingConv::Cold; ;
2258 break;}
2259case 44:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002260#line 1040 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002261{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002262 if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
2263 ThrowException("Calling conv too large!");
2264 yyval.UIntVal = yyvsp[0].UInt64Val;
Nate Begeman14b05292005-11-05 09:21:28 +00002265 ;
2266 break;}
Chris Lattner7d09ab62005-11-06 06:34:34 +00002267case 45:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002268#line 1048 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Chris Lattner7d09ab62005-11-06 06:34:34 +00002269{ yyval.UIntVal = 0; ;
2270 break;}
Nate Begeman14b05292005-11-05 09:21:28 +00002271case 46:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002272#line 1049 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerb475c422005-11-12 18:22:38 +00002273{
2274 yyval.UIntVal = yyvsp[0].UInt64Val;
2275 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
2276 ThrowException("Alignment must be a power of two!");
2277;
Nate Begeman14b05292005-11-05 09:21:28 +00002278 break;}
Chris Lattner0019bbe2005-11-06 06:46:53 +00002279case 47:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002280#line 1054 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Chris Lattner0019bbe2005-11-06 06:46:53 +00002281{ yyval.UIntVal = 0; ;
2282 break;}
Nate Begeman14b05292005-11-05 09:21:28 +00002283case 48:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002284#line 1055 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerb475c422005-11-12 18:22:38 +00002285{
2286 yyval.UIntVal = yyvsp[0].UInt64Val;
2287 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
2288 ThrowException("Alignment must be a power of two!");
2289;
Nate Begeman14b05292005-11-05 09:21:28 +00002290 break;}
Chris Lattnere869eef2005-11-12 00:11:49 +00002291case 49:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002292#line 1062 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Chris Lattnere869eef2005-11-12 00:11:49 +00002293{
2294 for (unsigned i = 0, e = strlen(yyvsp[0].StrVal); i != e; ++i)
2295 if (yyvsp[0].StrVal[i] == '"' || yyvsp[0].StrVal[i] == '\\')
2296 ThrowException("Invalid character in section name!");
2297 yyval.StrVal = yyvsp[0].StrVal;
2298;
2299 break;}
Chris Lattner7d09ab62005-11-06 06:34:34 +00002300case 50:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002301#line 1069 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Chris Lattnere869eef2005-11-12 00:11:49 +00002302{ yyval.StrVal = 0; ;
2303 break;}
2304case 51:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002305#line 1070 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Chris Lattnere869eef2005-11-12 00:11:49 +00002306{ yyval.StrVal = yyvsp[0].StrVal; ;
Chris Lattner7d09ab62005-11-06 06:34:34 +00002307 break;}
Chris Lattner0019bbe2005-11-06 06:46:53 +00002308case 52:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002309#line 1075 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerb475c422005-11-12 18:22:38 +00002310{;
Chris Lattner0019bbe2005-11-06 06:46:53 +00002311 break;}
2312case 53:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002313#line 1076 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerb475c422005-11-12 18:22:38 +00002314{;
2315 break;}
2316case 54:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002317#line 1077 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerb475c422005-11-12 18:22:38 +00002318{
2319 CurGV->setSection(yyvsp[0].StrVal);
2320 free(yyvsp[0].StrVal);
2321 ;
Chris Lattnere869eef2005-11-12 00:11:49 +00002322 break;}
2323case 55:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002324#line 1081 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerb475c422005-11-12 18:22:38 +00002325{
Chris Lattner7aa61892005-12-21 17:53:23 +00002326 if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val))
2327 ThrowException("Alignment must be a power of two!");
Chris Lattnerb475c422005-11-12 18:22:38 +00002328 CurGV->setAlignment(yyvsp[0].UInt64Val);
2329 ;
Chris Lattnere869eef2005-11-12 00:11:49 +00002330 break;}
2331case 57:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002332#line 1094 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Chris Lattnere869eef2005-11-12 00:11:49 +00002333{ yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2334 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002335case 59:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002336#line 1095 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerb475c422005-11-12 18:22:38 +00002337{ yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2338 break;}
2339case 60:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002340#line 1097 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002341{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002342 if (!UpRefs.empty())
2343 ThrowException("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
2344 yyval.TypeVal = yyvsp[0].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002345 ;
2346 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002347case 74:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002348#line 1108 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002349{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002350 yyval.TypeVal = new PATypeHolder(OpaqueType::get());
Nate Begeman14b05292005-11-05 09:21:28 +00002351 ;
2352 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002353case 75:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002354#line 1111 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002355{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002356 yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
Nate Begeman14b05292005-11-05 09:21:28 +00002357 ;
2358 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002359case 76:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002360#line 1114 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002361{ // Named types are also simple types...
Reid Spencer68a24bd2005-08-27 18:50:39 +00002362 yyval.TypeVal = new PATypeHolder(getTypeVal(yyvsp[0].ValIDVal));
Nate Begeman14b05292005-11-05 09:21:28 +00002363;
2364 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002365case 77:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002366#line 1120 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002367{ // Type UpReference
Reid Spencer68a24bd2005-08-27 18:50:39 +00002368 if (yyvsp[0].UInt64Val > (uint64_t)~0U) ThrowException("Value out of range!");
2369 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
2370 UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector...
2371 yyval.TypeVal = new PATypeHolder(OT);
2372 UR_OUT("New Upreference!\n");
Nate Begeman14b05292005-11-05 09:21:28 +00002373 ;
2374 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002375case 78:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002376#line 1127 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002377{ // Function derived type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002378 std::vector<const Type*> Params;
2379 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2380 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2381 Params.push_back(*I);
2382 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
2383 if (isVarArg) Params.pop_back();
2384
2385 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FunctionType::get(*yyvsp[-3].TypeVal,Params,isVarArg)));
2386 delete yyvsp[-1].TypeList; // Delete the argument list
2387 delete yyvsp[-3].TypeVal; // Delete the return type handle
Nate Begeman14b05292005-11-05 09:21:28 +00002388 ;
2389 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002390case 79:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002391#line 1139 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002392{ // Sized array type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002393 yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2394 delete yyvsp[-1].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002395 ;
2396 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002397case 80:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002398#line 1143 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002399{ // Packed array type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002400 const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
Chris Lattner9547d7f2005-11-10 01:42:43 +00002401 if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002402 ThrowException("Unsigned result not equal to signed result");
Chris Lattner9547d7f2005-11-10 01:42:43 +00002403 if (!ElemTy->isPrimitiveType())
Reid Spencer68a24bd2005-08-27 18:50:39 +00002404 ThrowException("Elemental type of a PackedType must be primitive");
Chris Lattner9547d7f2005-11-10 01:42:43 +00002405 if (!isPowerOf2_32(yyvsp[-3].UInt64Val))
2406 ThrowException("Vector length should be a power of 2!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00002407 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PackedType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2408 delete yyvsp[-1].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002409 ;
2410 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002411case 81:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002412#line 1154 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002413{ // Structure type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002414 std::vector<const Type*> Elements;
2415 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2416 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2417 Elements.push_back(*I);
2418
2419 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
2420 delete yyvsp[-1].TypeList;
Nate Begeman14b05292005-11-05 09:21:28 +00002421 ;
2422 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002423case 82:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002424#line 1163 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002425{ // Empty structure type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002426 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Nate Begeman14b05292005-11-05 09:21:28 +00002427 ;
2428 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002429case 83:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002430#line 1166 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002431{ // Pointer type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002432 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal)));
2433 delete yyvsp[-1].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002434 ;
2435 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002436case 84:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002437#line 1174 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002438{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002439 yyval.TypeList = new std::list<PATypeHolder>();
2440 yyval.TypeList->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002441 ;
2442 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002443case 85:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002444#line 1178 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002445{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002446 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002447 ;
2448 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002449case 87:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002450#line 1184 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002451{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002452 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(Type::VoidTy);
Nate Begeman14b05292005-11-05 09:21:28 +00002453 ;
2454 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002455case 88:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002456#line 1187 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002457{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002458 (yyval.TypeList = new std::list<PATypeHolder>())->push_back(Type::VoidTy);
Nate Begeman14b05292005-11-05 09:21:28 +00002459 ;
2460 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002461case 89:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002462#line 1190 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002463{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002464 yyval.TypeList = new std::list<PATypeHolder>();
Nate Begeman14b05292005-11-05 09:21:28 +00002465 ;
2466 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002467case 90:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002468#line 1200 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002469{ // Nonempty unsized arr
Reid Spencer68a24bd2005-08-27 18:50:39 +00002470 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
2471 if (ATy == 0)
2472 ThrowException("Cannot make array constant with type: '" +
2473 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2474 const Type *ETy = ATy->getElementType();
2475 int NumElements = ATy->getNumElements();
2476
2477 // Verify that we have the correct size...
2478 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2479 ThrowException("Type mismatch: constant sized array initialized with " +
2480 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
2481 itostr(NumElements) + "!");
2482
2483 // Verify all elements are correct type!
2484 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2485 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2486 ThrowException("Element #" + utostr(i) + " is not of type '" +
2487 ETy->getDescription() +"' as required!\nIt is of type '"+
2488 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2489 }
2490
2491 yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
2492 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Nate Begeman14b05292005-11-05 09:21:28 +00002493 ;
2494 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002495case 91:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002496#line 1225 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002497{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002498 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2499 if (ATy == 0)
2500 ThrowException("Cannot make array constant with type: '" +
2501 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2502
2503 int NumElements = ATy->getNumElements();
2504 if (NumElements != -1 && NumElements != 0)
2505 ThrowException("Type mismatch: constant sized array initialized with 0"
2506 " arguments, but has size of " + itostr(NumElements) +"!");
2507 yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
2508 delete yyvsp[-2].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002509 ;
2510 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002511case 92:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002512#line 1238 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002513{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002514 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2515 if (ATy == 0)
2516 ThrowException("Cannot make array constant with type: '" +
2517 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2518
2519 int NumElements = ATy->getNumElements();
2520 const Type *ETy = ATy->getElementType();
2521 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
2522 if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal))
2523 ThrowException("Can't build string constant of size " +
2524 itostr((int)(EndStr-yyvsp[0].StrVal)) +
2525 " when array has size " + itostr(NumElements) + "!");
2526 std::vector<Constant*> Vals;
2527 if (ETy == Type::SByteTy) {
2528 for (char *C = yyvsp[0].StrVal; C != EndStr; ++C)
2529 Vals.push_back(ConstantSInt::get(ETy, *C));
2530 } else if (ETy == Type::UByteTy) {
2531 for (char *C = yyvsp[0].StrVal; C != EndStr; ++C)
2532 Vals.push_back(ConstantUInt::get(ETy, (unsigned char)*C));
2533 } else {
2534 free(yyvsp[0].StrVal);
2535 ThrowException("Cannot build string arrays of non byte sized elements!");
2536 }
2537 free(yyvsp[0].StrVal);
2538 yyval.ConstVal = ConstantArray::get(ATy, Vals);
2539 delete yyvsp[-2].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002540 ;
2541 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002542case 93:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002543#line 1266 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002544{ // Nonempty unsized arr
Reid Spencer68a24bd2005-08-27 18:50:39 +00002545 const PackedType *PTy = dyn_cast<PackedType>(yyvsp[-3].TypeVal->get());
2546 if (PTy == 0)
2547 ThrowException("Cannot make packed constant with type: '" +
2548 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2549 const Type *ETy = PTy->getElementType();
2550 int NumElements = PTy->getNumElements();
2551
2552 // Verify that we have the correct size...
2553 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2554 ThrowException("Type mismatch: constant sized packed initialized with " +
2555 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
2556 itostr(NumElements) + "!");
2557
2558 // Verify all elements are correct type!
2559 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2560 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2561 ThrowException("Element #" + utostr(i) + " is not of type '" +
2562 ETy->getDescription() +"' as required!\nIt is of type '"+
2563 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2564 }
2565
2566 yyval.ConstVal = ConstantPacked::get(PTy, *yyvsp[-1].ConstVector);
2567 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Nate Begeman14b05292005-11-05 09:21:28 +00002568 ;
2569 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002570case 94:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002571#line 1291 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002572{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002573 const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
2574 if (STy == 0)
2575 ThrowException("Cannot make struct constant with type: '" +
2576 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2577
2578 if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
2579 ThrowException("Illegal number of initializers for structure type!");
2580
2581 // Check to ensure that constants are compatible with the type initializer!
2582 for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
2583 if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
2584 ThrowException("Expected type '" +
2585 STy->getElementType(i)->getDescription() +
2586 "' for element #" + utostr(i) +
2587 " of structure initializer!");
2588
2589 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
2590 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Nate Begeman14b05292005-11-05 09:21:28 +00002591 ;
2592 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002593case 95:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002594#line 1311 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002595{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002596 const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
2597 if (STy == 0)
2598 ThrowException("Cannot make struct constant with type: '" +
2599 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2600
2601 if (STy->getNumContainedTypes() != 0)
2602 ThrowException("Illegal number of initializers for structure type!");
2603
2604 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
2605 delete yyvsp[-2].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002606 ;
2607 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002608case 96:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002609#line 1323 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002610{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002611 const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
2612 if (PTy == 0)
2613 ThrowException("Cannot make null pointer constant with type: '" +
2614 (*yyvsp[-1].TypeVal)->getDescription() + "'!");
2615
2616 yyval.ConstVal = ConstantPointerNull::get(PTy);
2617 delete yyvsp[-1].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002618 ;
2619 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002620case 97:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002621#line 1332 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002622{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002623 yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
2624 delete yyvsp[-1].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002625 ;
2626 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002627case 98:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002628#line 1336 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002629{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002630 const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
2631 if (Ty == 0)
2632 ThrowException("Global const reference must be a pointer type!");
2633
2634 // ConstExprs can exist in the body of a function, thus creating
2635 // GlobalValues whenever they refer to a variable. Because we are in
2636 // the context of a function, getValNonImprovising will search the functions
2637 // symbol table instead of the module symbol table for the global symbol,
2638 // which throws things all off. To get around this, we just tell
2639 // getValNonImprovising that we are at global scope here.
2640 //
2641 Function *SavedCurFn = CurFun.CurrentFunction;
2642 CurFun.CurrentFunction = 0;
2643
2644 Value *V = getValNonImprovising(Ty, yyvsp[0].ValIDVal);
2645
2646 CurFun.CurrentFunction = SavedCurFn;
2647
2648 // If this is an initializer for a constant pointer, which is referencing a
2649 // (currently) undefined variable, create a stub now that shall be replaced
2650 // in the future with the right type of variable.
2651 //
2652 if (V == 0) {
2653 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
2654 const PointerType *PT = cast<PointerType>(Ty);
2655
2656 // First check to see if the forward references value is already created!
2657 PerModuleInfo::GlobalRefsType::iterator I =
2658 CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
2659
2660 if (I != CurModule.GlobalRefs.end()) {
2661 V = I->second; // Placeholder already exists, use it...
2662 yyvsp[0].ValIDVal.destroy();
2663 } else {
2664 std::string Name;
2665 if (yyvsp[0].ValIDVal.Type == ValID::NameVal) Name = yyvsp[0].ValIDVal.Name;
2666
2667 // Create the forward referenced global.
2668 GlobalValue *GV;
2669 if (const FunctionType *FTy =
2670 dyn_cast<FunctionType>(PT->getElementType())) {
2671 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
2672 CurModule.CurrentModule);
2673 } else {
2674 GV = new GlobalVariable(PT->getElementType(), false,
2675 GlobalValue::ExternalLinkage, 0,
2676 Name, CurModule.CurrentModule);
2677 }
2678
2679 // Keep track of the fact that we have a forward ref to recycle it
2680 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
2681 V = GV;
2682 }
2683 }
2684
2685 yyval.ConstVal = cast<GlobalValue>(V);
2686 delete yyvsp[-1].TypeVal; // Free the type handle
Nate Begeman14b05292005-11-05 09:21:28 +00002687 ;
2688 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002689case 99:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002690#line 1395 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002691{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002692 if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
2693 ThrowException("Mismatched types for constant expression!");
2694 yyval.ConstVal = yyvsp[0].ConstVal;
2695 delete yyvsp[-1].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002696 ;
2697 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002698case 100:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002699#line 1401 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002700{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002701 const Type *Ty = yyvsp[-1].TypeVal->get();
2702 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
2703 ThrowException("Cannot create a null initialized value of this type!");
2704 yyval.ConstVal = Constant::getNullValue(Ty);
2705 delete yyvsp[-1].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002706 ;
2707 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002708case 101:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002709#line 1409 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002710{ // integral constants
Reid Spencer68a24bd2005-08-27 18:50:39 +00002711 if (!ConstantSInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
2712 ThrowException("Constant value doesn't fit in type!");
2713 yyval.ConstVal = ConstantSInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val);
Nate Begeman14b05292005-11-05 09:21:28 +00002714 ;
2715 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002716case 102:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002717#line 1414 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002718{ // integral constants
Reid Spencer68a24bd2005-08-27 18:50:39 +00002719 if (!ConstantUInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
2720 ThrowException("Constant value doesn't fit in type!");
2721 yyval.ConstVal = ConstantUInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val);
Nate Begeman14b05292005-11-05 09:21:28 +00002722 ;
2723 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002724case 103:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002725#line 1419 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002726{ // Boolean constants
Reid Spencer68a24bd2005-08-27 18:50:39 +00002727 yyval.ConstVal = ConstantBool::True;
Nate Begeman14b05292005-11-05 09:21:28 +00002728 ;
2729 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002730case 104:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002731#line 1422 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002732{ // Boolean constants
Reid Spencer68a24bd2005-08-27 18:50:39 +00002733 yyval.ConstVal = ConstantBool::False;
Nate Begeman14b05292005-11-05 09:21:28 +00002734 ;
2735 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002736case 105:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002737#line 1425 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002738{ // Float & Double constants
Reid Spencer68a24bd2005-08-27 18:50:39 +00002739 if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal))
2740 ThrowException("Floating point constant invalid for type!!");
2741 yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal);
Nate Begeman14b05292005-11-05 09:21:28 +00002742 ;
2743 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002744case 106:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002745#line 1432 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002746{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002747 if (!yyvsp[-3].ConstVal->getType()->isFirstClassType())
2748 ThrowException("cast constant expression from a non-primitive type: '" +
2749 yyvsp[-3].ConstVal->getType()->getDescription() + "'!");
2750 if (!yyvsp[-1].TypeVal->get()->isFirstClassType())
2751 ThrowException("cast constant expression to a non-primitive type: '" +
2752 yyvsp[-1].TypeVal->get()->getDescription() + "'!");
2753 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-3].ConstVal, yyvsp[-1].TypeVal->get());
2754 delete yyvsp[-1].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002755 ;
2756 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002757case 107:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002758#line 1442 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002759{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002760 if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
2761 ThrowException("GetElementPtr requires a pointer operand!");
2762
2763 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
2764 // indices to uint struct indices for compatibility.
2765 generic_gep_type_iterator<std::vector<Value*>::iterator>
2766 GTI = gep_type_begin(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end()),
2767 GTE = gep_type_end(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end());
2768 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
2769 if (isa<StructType>(*GTI)) // Only change struct indices
2770 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[-1].ValueList)[i]))
2771 if (CUI->getType() == Type::UByteTy)
2772 (*yyvsp[-1].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
2773
2774 const Type *IdxTy =
2775 GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), *yyvsp[-1].ValueList, true);
2776 if (!IdxTy)
2777 ThrowException("Index list invalid for constant getelementptr!");
2778
2779 std::vector<Constant*> IdxVec;
2780 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
2781 if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
2782 IdxVec.push_back(C);
2783 else
2784 ThrowException("Indices to constant getelementptr must be constants!");
2785
2786 delete yyvsp[-1].ValueList;
2787
2788 yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, IdxVec);
Nate Begeman14b05292005-11-05 09:21:28 +00002789 ;
2790 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002791case 108:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002792#line 1473 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002793{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002794 if (yyvsp[-5].ConstVal->getType() != Type::BoolTy)
2795 ThrowException("Select condition must be of boolean type!");
2796 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2797 ThrowException("Select operand types must match!");
2798 yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Nate Begeman14b05292005-11-05 09:21:28 +00002799 ;
2800 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002801case 109:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002802#line 1480 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002803{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002804 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2805 ThrowException("Binary operator types must match!");
2806 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
2807 // To retain backward compatibility with these early compilers, we emit a
2808 // cast to the appropriate integer type automatically if we are in the
2809 // broken case. See PR424 for more information.
2810 if (!isa<PointerType>(yyvsp[-3].ConstVal->getType())) {
2811 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2812 } else {
2813 const Type *IntPtrTy = 0;
2814 switch (CurModule.CurrentModule->getPointerSize()) {
2815 case Module::Pointer32: IntPtrTy = Type::IntTy; break;
2816 case Module::Pointer64: IntPtrTy = Type::LongTy; break;
2817 default: ThrowException("invalid pointer binary constant expr!");
2818 }
2819 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, ConstantExpr::getCast(yyvsp[-3].ConstVal, IntPtrTy),
2820 ConstantExpr::getCast(yyvsp[-1].ConstVal, IntPtrTy));
2821 yyval.ConstVal = ConstantExpr::getCast(yyval.ConstVal, yyvsp[-3].ConstVal->getType());
2822 }
Nate Begeman14b05292005-11-05 09:21:28 +00002823 ;
2824 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002825case 110:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002826#line 1501 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002827{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002828 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2829 ThrowException("Logical operator types must match!");
Chris Lattner524a1312005-12-21 18:31:50 +00002830 if (!yyvsp[-3].ConstVal->getType()->isIntegral()) {
2831 if (!isa<PackedType>(yyvsp[-3].ConstVal->getType()) ||
2832 !cast<PackedType>(yyvsp[-3].ConstVal->getType())->getElementType()->isIntegral())
2833 ThrowException("Logical operator requires integral operands!");
2834 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002835 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Nate Begeman14b05292005-11-05 09:21:28 +00002836 ;
2837 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002838case 111:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002839#line 1511 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002840{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002841 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2842 ThrowException("setcc operand types must match!");
2843 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Nate Begeman14b05292005-11-05 09:21:28 +00002844 ;
2845 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002846case 112:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002847#line 1516 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002848{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002849 if (yyvsp[-1].ConstVal->getType() != Type::UByteTy)
2850 ThrowException("Shift count for shift constant must be unsigned byte!");
2851 if (!yyvsp[-3].ConstVal->getType()->isInteger())
2852 ThrowException("Shift constant expression requires integer operand!");
2853 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].OtherOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Nate Begeman14b05292005-11-05 09:21:28 +00002854 ;
2855 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002856case 113:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002857#line 1523 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
2858{
2859 if (!isa<PackedType>(yyvsp[-3].ConstVal->getType()))
2860 ThrowException("First operand of extractelement must be "
2861 "packed type!");
2862 if (yyvsp[-1].ConstVal->getType() != Type::UIntTy)
2863 ThrowException("Second operand of extractelement must be uint!");
2864 yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2865 ;
2866 break;}
2867case 114:
2868#line 1533 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002869{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002870 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
Nate Begeman14b05292005-11-05 09:21:28 +00002871 ;
2872 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00002873case 115:
2874#line 1536 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002875{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002876 yyval.ConstVector = new std::vector<Constant*>();
2877 yyval.ConstVector->push_back(yyvsp[0].ConstVal);
Nate Begeman14b05292005-11-05 09:21:28 +00002878 ;
2879 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00002880case 116:
2881#line 1543 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002882{ yyval.BoolVal = false; ;
2883 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00002884case 117:
2885#line 1543 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002886{ yyval.BoolVal = true; ;
2887 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00002888case 118:
2889#line 1553 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002890{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002891 yyval.ModuleVal = ParserResult = yyvsp[0].ModuleVal;
2892 CurModule.ModuleDone();
Nate Begeman14b05292005-11-05 09:21:28 +00002893;
2894 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00002895case 119:
2896#line 1560 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002897{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002898 yyval.ModuleVal = yyvsp[-1].ModuleVal;
2899 CurFun.FunctionDone();
Nate Begeman14b05292005-11-05 09:21:28 +00002900 ;
2901 break;}
Chris Lattner524a1312005-12-21 18:31:50 +00002902case 120:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002903#line 1564 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002904{
Chris Lattner524a1312005-12-21 18:31:50 +00002905 yyval.ModuleVal = yyvsp[-1].ModuleVal;
2906 ;
2907 break;}
2908case 121:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002909#line 1567 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
2910{
2911 yyval.ModuleVal = yyvsp[-1].ModuleVal;
2912 ;
2913 break;}
2914case 122:
2915#line 1570 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Chris Lattner524a1312005-12-21 18:31:50 +00002916{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002917 yyval.ModuleVal = CurModule.CurrentModule;
2918 // Emit an error if there are any unresolved types left.
2919 if (!CurModule.LateResolveTypes.empty()) {
2920 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
2921 if (DID.Type == ValID::NameVal)
2922 ThrowException("Reference to an undefined type: '"+DID.getName() + "'");
2923 else
2924 ThrowException("Reference to an undefined type: #" + itostr(DID.Num));
2925 }
Nate Begeman14b05292005-11-05 09:21:28 +00002926 ;
2927 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00002928case 123:
2929#line 1583 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002930{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002931 // Eagerly resolve types. This is not an optimization, this is a
2932 // requirement that is due to the fact that we could have this:
2933 //
2934 // %list = type { %list * }
2935 // %list = type { %list * } ; repeated type decl
2936 //
2937 // If types are not resolved eagerly, then the two types will not be
2938 // determined to be the same type!
2939 //
2940 ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
2941
2942 if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
2943 // If this is a named type that is not a redefinition, add it to the slot
2944 // table.
2945 CurModule.Types.push_back(*yyvsp[0].TypeVal);
2946 }
2947
2948 delete yyvsp[0].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00002949 ;
2950 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00002951case 124:
2952#line 1603 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00002953{ // Function prototypes can be in const pool
2954 ;
2955 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00002956case 125:
2957#line 1605 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerb475c422005-11-12 18:22:38 +00002958{
2959 if (yyvsp[0].ConstVal == 0) ThrowException("Global value initializer is not a constant!");
2960 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, yyvsp[-2].Linkage, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal);
2961 ;
Chris Lattnere869eef2005-11-12 00:11:49 +00002962 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00002963case 126:
2964#line 1608 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Chris Lattnere869eef2005-11-12 00:11:49 +00002965{
Chris Lattnerb475c422005-11-12 18:22:38 +00002966 CurGV = 0;
Chris Lattnere869eef2005-11-12 00:11:49 +00002967 ;
2968 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00002969case 127:
2970#line 1611 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerb475c422005-11-12 18:22:38 +00002971{
2972 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalLinkage,
2973 yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0);
2974 delete yyvsp[0].TypeVal;
2975 ;
2976 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00002977case 128:
2978#line 1615 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerb475c422005-11-12 18:22:38 +00002979{
2980 CurGV = 0;
2981 ;
2982 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002983case 129:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002984#line 1618 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
2985{
Chris Lattnerb475c422005-11-12 18:22:38 +00002986 ;
2987 break;}
2988case 130:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002989#line 1620 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
2990{
Chris Lattnerb475c422005-11-12 18:22:38 +00002991 ;
2992 break;}
2993case 131:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002994#line 1622 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
2995{
2996 ;
Chris Lattnere869eef2005-11-12 00:11:49 +00002997 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00002998case 132:
Robert Bocchino9c62b562006-01-10 19:04:32 +00002999#line 1627 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
3000{ yyval.Endianness = Module::BigEndian; ;
Chris Lattnere869eef2005-11-12 00:11:49 +00003001 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00003002case 133:
Robert Bocchino9c62b562006-01-10 19:04:32 +00003003#line 1628 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
3004{ yyval.Endianness = Module::LittleEndian; ;
3005 break;}
3006case 134:
3007#line 1630 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003008{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003009 CurModule.CurrentModule->setEndianness(yyvsp[0].Endianness);
Nate Begeman14b05292005-11-05 09:21:28 +00003010 ;
3011 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003012case 135:
3013#line 1633 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003014{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003015 if (yyvsp[0].UInt64Val == 32)
3016 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
3017 else if (yyvsp[0].UInt64Val == 64)
3018 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
3019 else
3020 ThrowException("Invalid pointer size: '" + utostr(yyvsp[0].UInt64Val) + "'!");
Nate Begeman14b05292005-11-05 09:21:28 +00003021 ;
3022 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003023case 136:
3024#line 1641 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003025{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003026 CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal);
3027 free(yyvsp[0].StrVal);
Nate Begeman14b05292005-11-05 09:21:28 +00003028 ;
3029 break;}
Chris Lattnerb475c422005-11-12 18:22:38 +00003030case 138:
Robert Bocchino9c62b562006-01-10 19:04:32 +00003031#line 1648 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Chris Lattnere869eef2005-11-12 00:11:49 +00003032{
3033 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3034 free(yyvsp[0].StrVal);
3035 ;
Nate Begeman14b05292005-11-05 09:21:28 +00003036 break;}
Chris Lattnere869eef2005-11-12 00:11:49 +00003037case 139:
Robert Bocchino9c62b562006-01-10 19:04:32 +00003038#line 1652 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
3039{
3040 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3041 free(yyvsp[0].StrVal);
3042 ;
3043 break;}
3044case 140:
3045#line 1656 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Chris Lattnerb475c422005-11-12 18:22:38 +00003046{
3047 ;
3048 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003049case 144:
3050#line 1665 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Chris Lattnere869eef2005-11-12 00:11:49 +00003051{ yyval.StrVal = 0; ;
3052 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003053case 145:
3054#line 1667 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003055{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003056 if (*yyvsp[-1].TypeVal == Type::VoidTy)
3057 ThrowException("void typed arguments are invalid!");
3058 yyval.ArgVal = new std::pair<PATypeHolder*, char*>(yyvsp[-1].TypeVal, yyvsp[0].StrVal);
Nate Begeman14b05292005-11-05 09:21:28 +00003059;
3060 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003061case 146:
3062#line 1673 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003063{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003064 yyval.ArgList = yyvsp[-2].ArgList;
3065 yyvsp[-2].ArgList->push_back(*yyvsp[0].ArgVal);
3066 delete yyvsp[0].ArgVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003067 ;
3068 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003069case 147:
3070#line 1678 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003071{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003072 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
3073 yyval.ArgList->push_back(*yyvsp[0].ArgVal);
3074 delete yyvsp[0].ArgVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003075 ;
3076 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003077case 148:
3078#line 1684 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003079{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003080 yyval.ArgList = yyvsp[0].ArgList;
Nate Begeman14b05292005-11-05 09:21:28 +00003081 ;
3082 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003083case 149:
3084#line 1687 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003085{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003086 yyval.ArgList = yyvsp[-2].ArgList;
3087 yyval.ArgList->push_back(std::pair<PATypeHolder*,
3088 char*>(new PATypeHolder(Type::VoidTy), 0));
Nate Begeman14b05292005-11-05 09:21:28 +00003089 ;
3090 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003091case 150:
3092#line 1692 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003093{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003094 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
3095 yyval.ArgList->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0));
Nate Begeman14b05292005-11-05 09:21:28 +00003096 ;
3097 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003098case 151:
3099#line 1696 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003100{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003101 yyval.ArgList = 0;
Nate Begeman14b05292005-11-05 09:21:28 +00003102 ;
3103 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003104case 152:
3105#line 1701 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003106{
Chris Lattnere869eef2005-11-12 00:11:49 +00003107 UnEscapeLexed(yyvsp[-5].StrVal);
3108 std::string FunctionName(yyvsp[-5].StrVal);
3109 free(yyvsp[-5].StrVal); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00003110
Chris Lattnere869eef2005-11-12 00:11:49 +00003111 if (!(*yyvsp[-6].TypeVal)->isFirstClassType() && *yyvsp[-6].TypeVal != Type::VoidTy)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003112 ThrowException("LLVM functions cannot return aggregate types!");
3113
3114 std::vector<const Type*> ParamTypeList;
Chris Lattnere869eef2005-11-12 00:11:49 +00003115 if (yyvsp[-3].ArgList) { // If there are arguments...
3116 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-3].ArgList->begin();
3117 I != yyvsp[-3].ArgList->end(); ++I)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003118 ParamTypeList.push_back(I->first->get());
3119 }
3120
3121 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
3122 if (isVarArg) ParamTypeList.pop_back();
3123
Chris Lattnere869eef2005-11-12 00:11:49 +00003124 const FunctionType *FT = FunctionType::get(*yyvsp[-6].TypeVal, ParamTypeList, isVarArg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003125 const PointerType *PFT = PointerType::get(FT);
Chris Lattnere869eef2005-11-12 00:11:49 +00003126 delete yyvsp[-6].TypeVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003127
3128 ValID ID;
3129 if (!FunctionName.empty()) {
3130 ID = ValID::create((char*)FunctionName.c_str());
3131 } else {
3132 ID = ValID::create((int)CurModule.Values[PFT].size());
3133 }
3134
3135 Function *Fn = 0;
3136 // See if this function was forward referenced. If so, recycle the object.
3137 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
3138 // Move the function to the end of the list, from whereever it was
3139 // previously inserted.
3140 Fn = cast<Function>(FWRef);
3141 CurModule.CurrentModule->getFunctionList().remove(Fn);
3142 CurModule.CurrentModule->getFunctionList().push_back(Fn);
3143 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
3144 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
3145 // If this is the case, either we need to be a forward decl, or it needs
3146 // to be.
3147 if (!CurFun.isDeclare && !Fn->isExternal())
3148 ThrowException("Redefinition of function '" + FunctionName + "'!");
3149
3150 // Make sure to strip off any argument names so we can't get conflicts.
3151 if (Fn->isExternal())
3152 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
3153 AI != AE; ++AI)
3154 AI->setName("");
3155
3156 } else { // Not already defined?
3157 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
3158 CurModule.CurrentModule);
3159 InsertValue(Fn, CurModule.Values);
3160 }
3161
3162 CurFun.FunctionStart(Fn);
Chris Lattnere869eef2005-11-12 00:11:49 +00003163 Fn->setCallingConv(yyvsp[-7].UIntVal);
Chris Lattner0019bbe2005-11-06 06:46:53 +00003164 Fn->setAlignment(yyvsp[0].UIntVal);
Chris Lattnere869eef2005-11-12 00:11:49 +00003165 if (yyvsp[-1].StrVal) {
3166 Fn->setSection(yyvsp[-1].StrVal);
3167 free(yyvsp[-1].StrVal);
3168 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00003169
3170 // Add all of the arguments we parsed to the function...
Chris Lattnere869eef2005-11-12 00:11:49 +00003171 if (yyvsp[-3].ArgList) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00003172 if (isVarArg) { // Nuke the last entry
Chris Lattnere869eef2005-11-12 00:11:49 +00003173 assert(yyvsp[-3].ArgList->back().first->get() == Type::VoidTy && yyvsp[-3].ArgList->back().second == 0&&
Reid Spencer68a24bd2005-08-27 18:50:39 +00003174 "Not a varargs marker!");
Chris Lattnere869eef2005-11-12 00:11:49 +00003175 delete yyvsp[-3].ArgList->back().first;
3176 yyvsp[-3].ArgList->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00003177 }
3178 Function::arg_iterator ArgIt = Fn->arg_begin();
Chris Lattnere869eef2005-11-12 00:11:49 +00003179 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-3].ArgList->begin();
3180 I != yyvsp[-3].ArgList->end(); ++I, ++ArgIt) {
Reid Spencer68a24bd2005-08-27 18:50:39 +00003181 delete I->first; // Delete the typeholder...
3182
3183 setValueName(ArgIt, I->second); // Insert arg into symtab...
3184 InsertValue(ArgIt);
3185 }
3186
Chris Lattnere869eef2005-11-12 00:11:49 +00003187 delete yyvsp[-3].ArgList; // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00003188 }
Nate Begeman14b05292005-11-05 09:21:28 +00003189;
3190 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003191case 155:
3192#line 1788 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003193{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003194 yyval.FunctionVal = CurFun.CurrentFunction;
3195
3196 // Make sure that we keep track of the linkage type even if there was a
3197 // previous "declare".
3198 yyval.FunctionVal->setLinkage(yyvsp[-2].Linkage);
Nate Begeman14b05292005-11-05 09:21:28 +00003199;
3200 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003201case 158:
3202#line 1798 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003203{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003204 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003205;
3206 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003207case 159:
3208#line 1802 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003209{ CurFun.isDeclare = true; ;
3210 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003211case 160:
3212#line 1802 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003213{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003214 yyval.FunctionVal = CurFun.CurrentFunction;
3215 CurFun.FunctionDone();
Nate Begeman14b05292005-11-05 09:21:28 +00003216;
3217 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003218case 161:
3219#line 1811 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003220{ // A reference to a direct constant
Reid Spencer68a24bd2005-08-27 18:50:39 +00003221 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
Nate Begeman14b05292005-11-05 09:21:28 +00003222 ;
3223 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003224case 162:
3225#line 1814 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003226{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003227 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
Nate Begeman14b05292005-11-05 09:21:28 +00003228 ;
3229 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003230case 163:
3231#line 1817 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003232{ // Perhaps it's an FP constant?
Reid Spencer68a24bd2005-08-27 18:50:39 +00003233 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
Nate Begeman14b05292005-11-05 09:21:28 +00003234 ;
3235 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003236case 164:
3237#line 1820 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003238{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003239 yyval.ValIDVal = ValID::create(ConstantBool::True);
Nate Begeman14b05292005-11-05 09:21:28 +00003240 ;
3241 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003242case 165:
3243#line 1823 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003244{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003245 yyval.ValIDVal = ValID::create(ConstantBool::False);
Nate Begeman14b05292005-11-05 09:21:28 +00003246 ;
3247 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003248case 166:
3249#line 1826 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003250{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003251 yyval.ValIDVal = ValID::createNull();
Nate Begeman14b05292005-11-05 09:21:28 +00003252 ;
3253 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003254case 167:
3255#line 1829 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003256{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003257 yyval.ValIDVal = ValID::createUndef();
Nate Begeman14b05292005-11-05 09:21:28 +00003258 ;
3259 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003260case 168:
3261#line 1832 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Chris Lattner7aa61892005-12-21 17:53:23 +00003262{ // A vector zero constant.
3263 yyval.ValIDVal = ValID::createZeroInit();
3264 ;
3265 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003266case 169:
3267#line 1835 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003268{ // Nonempty unsized packed vector
Reid Spencer68a24bd2005-08-27 18:50:39 +00003269 const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
3270 int NumElements = yyvsp[-1].ConstVector->size();
3271
3272 PackedType* pt = PackedType::get(ETy, NumElements);
3273 PATypeHolder* PTy = new PATypeHolder(
3274 HandleUpRefs(
3275 PackedType::get(
3276 ETy,
3277 NumElements)
3278 )
3279 );
3280
3281 // Verify all elements are correct type!
3282 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3283 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
3284 ThrowException("Element #" + utostr(i) + " is not of type '" +
3285 ETy->getDescription() +"' as required!\nIt is of type '" +
3286 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
3287 }
3288
3289 yyval.ValIDVal = ValID::create(ConstantPacked::get(pt, *yyvsp[-1].ConstVector));
3290 delete PTy; delete yyvsp[-1].ConstVector;
Nate Begeman14b05292005-11-05 09:21:28 +00003291 ;
3292 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003293case 170:
3294#line 1859 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003295{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003296 yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
Nate Begeman14b05292005-11-05 09:21:28 +00003297 ;
3298 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003299case 171:
3300#line 1866 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003301{ // Is it an integer reference...?
Reid Spencer68a24bd2005-08-27 18:50:39 +00003302 yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal);
Nate Begeman14b05292005-11-05 09:21:28 +00003303 ;
3304 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003305case 172:
3306#line 1869 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003307{ // Is it a named reference...?
Reid Spencer68a24bd2005-08-27 18:50:39 +00003308 yyval.ValIDVal = ValID::create(yyvsp[0].StrVal);
Nate Begeman14b05292005-11-05 09:21:28 +00003309 ;
3310 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003311case 175:
3312#line 1880 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003313{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003314 yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); delete yyvsp[-1].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003315 ;
3316 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003317case 176:
3318#line 1884 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003319{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003320 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003321 ;
3322 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003323case 177:
3324#line 1887 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003325{ // Do not allow functions with 0 basic blocks
Reid Spencer68a24bd2005-08-27 18:50:39 +00003326 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003327 ;
3328 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003329case 178:
3330#line 1895 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003331{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003332 setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
3333 InsertValue(yyvsp[0].TermInstVal);
3334
3335 yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
3336 InsertValue(yyvsp[-2].BasicBlockVal);
3337 yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003338 ;
3339 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003340case 179:
3341#line 1904 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003342{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003343 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
3344 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003345 ;
3346 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003347case 180:
3348#line 1908 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003349{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003350 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
3351
3352 // Make sure to move the basic block to the correct location in the
3353 // function, instead of leaving it inserted wherever it was first
3354 // referenced.
3355 Function::BasicBlockListType &BBL =
3356 CurFun.CurrentFunction->getBasicBlockList();
3357 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
Nate Begeman14b05292005-11-05 09:21:28 +00003358 ;
3359 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003360case 181:
3361#line 1918 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003362{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003363 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create(yyvsp[0].StrVal), true);
3364
3365 // Make sure to move the basic block to the correct location in the
3366 // function, instead of leaving it inserted wherever it was first
3367 // referenced.
3368 Function::BasicBlockListType &BBL =
3369 CurFun.CurrentFunction->getBasicBlockList();
3370 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
Nate Begeman14b05292005-11-05 09:21:28 +00003371 ;
3372 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003373case 182:
3374#line 1929 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003375{ // Return with a result...
Reid Spencer68a24bd2005-08-27 18:50:39 +00003376 yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
Nate Begeman14b05292005-11-05 09:21:28 +00003377 ;
3378 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003379case 183:
3380#line 1932 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003381{ // Return with no result...
Reid Spencer68a24bd2005-08-27 18:50:39 +00003382 yyval.TermInstVal = new ReturnInst();
Nate Begeman14b05292005-11-05 09:21:28 +00003383 ;
3384 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003385case 184:
3386#line 1935 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003387{ // Unconditional Branch...
Reid Spencer68a24bd2005-08-27 18:50:39 +00003388 yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[0].ValIDVal));
Nate Begeman14b05292005-11-05 09:21:28 +00003389 ;
3390 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003391case 185:
3392#line 1938 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003393{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003394 yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[-3].ValIDVal), getBBVal(yyvsp[0].ValIDVal), getVal(Type::BoolTy, yyvsp[-6].ValIDVal));
Nate Begeman14b05292005-11-05 09:21:28 +00003395 ;
3396 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003397case 186:
3398#line 1941 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003399{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003400 SwitchInst *S = new SwitchInst(getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal), getBBVal(yyvsp[-3].ValIDVal), yyvsp[-1].JumpTable->size());
3401 yyval.TermInstVal = S;
3402
3403 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
3404 E = yyvsp[-1].JumpTable->end();
3405 for (; I != E; ++I) {
3406 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
3407 S->addCase(CI, I->second);
3408 else
3409 ThrowException("Switch case is constant, but not a simple integer!");
3410 }
3411 delete yyvsp[-1].JumpTable;
Nate Begeman14b05292005-11-05 09:21:28 +00003412 ;
3413 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003414case 187:
3415#line 1955 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003416{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003417 SwitchInst *S = new SwitchInst(getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal), getBBVal(yyvsp[-2].ValIDVal), 0);
3418 yyval.TermInstVal = S;
Nate Begeman14b05292005-11-05 09:21:28 +00003419 ;
3420 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003421case 188:
3422#line 1960 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003423{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003424 const PointerType *PFTy;
3425 const FunctionType *Ty;
3426
3427 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-10].TypeVal->get())) ||
3428 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3429 // Pull out the types of all of the arguments...
3430 std::vector<const Type*> ParamTypes;
3431 if (yyvsp[-7].ValueList) {
3432 for (std::vector<Value*>::iterator I = yyvsp[-7].ValueList->begin(), E = yyvsp[-7].ValueList->end();
3433 I != E; ++I)
3434 ParamTypes.push_back((*I)->getType());
3435 }
3436
3437 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3438 if (isVarArg) ParamTypes.pop_back();
3439
3440 Ty = FunctionType::get(yyvsp[-10].TypeVal->get(), ParamTypes, isVarArg);
3441 PFTy = PointerType::get(Ty);
3442 }
3443
3444 Value *V = getVal(PFTy, yyvsp[-9].ValIDVal); // Get the function we're calling...
3445
3446 BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
3447 BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
3448
3449 // Create the call node...
3450 if (!yyvsp[-7].ValueList) { // Has no arguments?
3451 yyval.TermInstVal = new InvokeInst(V, Normal, Except, std::vector<Value*>());
3452 } else { // Has arguments?
3453 // Loop through FunctionType's arguments and ensure they are specified
3454 // correctly!
3455 //
3456 FunctionType::param_iterator I = Ty->param_begin();
3457 FunctionType::param_iterator E = Ty->param_end();
3458 std::vector<Value*>::iterator ArgI = yyvsp[-7].ValueList->begin(), ArgE = yyvsp[-7].ValueList->end();
3459
3460 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3461 if ((*ArgI)->getType() != *I)
3462 ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
3463 (*I)->getDescription() + "'!");
3464
3465 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
3466 ThrowException("Invalid number of parameters detected!");
3467
3468 yyval.TermInstVal = new InvokeInst(V, Normal, Except, *yyvsp[-7].ValueList);
3469 }
3470 cast<InvokeInst>(yyval.TermInstVal)->setCallingConv(yyvsp[-11].UIntVal);
3471
3472 delete yyvsp[-10].TypeVal;
3473 delete yyvsp[-7].ValueList;
Nate Begeman14b05292005-11-05 09:21:28 +00003474 ;
3475 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003476case 189:
3477#line 2012 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003478{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003479 yyval.TermInstVal = new UnwindInst();
Nate Begeman14b05292005-11-05 09:21:28 +00003480 ;
3481 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003482case 190:
3483#line 2015 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003484{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003485 yyval.TermInstVal = new UnreachableInst();
Nate Begeman14b05292005-11-05 09:21:28 +00003486 ;
3487 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003488case 191:
3489#line 2021 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003490{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003491 yyval.JumpTable = yyvsp[-5].JumpTable;
3492 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
3493 if (V == 0)
3494 ThrowException("May only switch on a constant pool value!");
3495
3496 yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
Nate Begeman14b05292005-11-05 09:21:28 +00003497 ;
3498 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003499case 192:
3500#line 2029 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003501{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003502 yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
3503 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
3504
3505 if (V == 0)
3506 ThrowException("May only switch on a constant pool value!");
3507
3508 yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
Nate Begeman14b05292005-11-05 09:21:28 +00003509 ;
3510 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003511case 193:
3512#line 2039 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003513{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003514 // Is this definition named?? if so, assign the name...
3515 setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
3516 InsertValue(yyvsp[0].InstVal);
3517 yyval.InstVal = yyvsp[0].InstVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003518;
3519 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003520case 194:
3521#line 2046 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003522{ // Used for PHI nodes
Reid Spencer68a24bd2005-08-27 18:50:39 +00003523 yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
3524 yyval.PHIList->push_back(std::make_pair(getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal), getBBVal(yyvsp[-1].ValIDVal)));
3525 delete yyvsp[-5].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003526 ;
3527 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003528case 195:
3529#line 2051 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003530{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003531 yyval.PHIList = yyvsp[-6].PHIList;
3532 yyvsp[-6].PHIList->push_back(std::make_pair(getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal),
3533 getBBVal(yyvsp[-1].ValIDVal)));
Nate Begeman14b05292005-11-05 09:21:28 +00003534 ;
3535 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003536case 196:
3537#line 2058 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003538{ // Used for call statements, and memory insts...
Reid Spencer68a24bd2005-08-27 18:50:39 +00003539 yyval.ValueList = new std::vector<Value*>();
3540 yyval.ValueList->push_back(yyvsp[0].ValueVal);
Nate Begeman14b05292005-11-05 09:21:28 +00003541 ;
3542 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003543case 197:
3544#line 2062 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003545{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003546 yyval.ValueList = yyvsp[-2].ValueList;
3547 yyvsp[-2].ValueList->push_back(yyvsp[0].ValueVal);
Nate Begeman14b05292005-11-05 09:21:28 +00003548 ;
3549 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003550case 199:
3551#line 2068 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003552{ yyval.ValueList = 0; ;
3553 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003554case 200:
3555#line 2070 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003556{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003557 yyval.BoolVal = true;
Nate Begeman14b05292005-11-05 09:21:28 +00003558 ;
3559 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003560case 201:
3561#line 2073 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003562{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003563 yyval.BoolVal = false;
Nate Begeman14b05292005-11-05 09:21:28 +00003564 ;
3565 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003566case 202:
3567#line 2079 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003568{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003569 if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
3570 !isa<PackedType>((*yyvsp[-3].TypeVal).get()))
3571 ThrowException(
3572 "Arithmetic operator requires integer, FP, or packed operands!");
3573 if (isa<PackedType>((*yyvsp[-3].TypeVal).get()) && yyvsp[-4].BinaryOpVal == Instruction::Rem)
3574 ThrowException("Rem not supported on packed types!");
3575 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3576 if (yyval.InstVal == 0)
3577 ThrowException("binary operator returned null!");
3578 delete yyvsp[-3].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003579 ;
3580 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003581case 203:
3582#line 2091 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003583{
Chris Lattner524a1312005-12-21 18:31:50 +00003584 if (!(*yyvsp[-3].TypeVal)->isIntegral()) {
3585 if (!isa<PackedType>(yyvsp[-3].TypeVal->get()) ||
3586 !cast<PackedType>(yyvsp[-3].TypeVal->get())->getElementType()->isIntegral())
3587 ThrowException("Logical operator requires integral operands!");
3588 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00003589 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3590 if (yyval.InstVal == 0)
3591 ThrowException("binary operator returned null!");
3592 delete yyvsp[-3].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003593 ;
3594 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003595case 204:
3596#line 2102 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003597{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003598 if(isa<PackedType>((*yyvsp[-3].TypeVal).get())) {
3599 ThrowException(
3600 "PackedTypes currently not supported in setcc instructions!");
3601 }
3602 yyval.InstVal = new SetCondInst(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3603 if (yyval.InstVal == 0)
3604 ThrowException("binary operator returned null!");
3605 delete yyvsp[-3].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003606 ;
3607 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003608case 205:
3609#line 2112 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003610{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003611 std::cerr << "WARNING: Use of eliminated 'not' instruction:"
3612 << " Replacing with 'xor'.\n";
3613
3614 Value *Ones = ConstantIntegral::getAllOnesValue(yyvsp[0].ValueVal->getType());
3615 if (Ones == 0)
3616 ThrowException("Expected integral type for not instruction!");
3617
3618 yyval.InstVal = BinaryOperator::create(Instruction::Xor, yyvsp[0].ValueVal, Ones);
3619 if (yyval.InstVal == 0)
3620 ThrowException("Could not create a xor instruction!");
Nate Begeman14b05292005-11-05 09:21:28 +00003621 ;
3622 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003623case 206:
3624#line 2124 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003625{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003626 if (yyvsp[0].ValueVal->getType() != Type::UByteTy)
3627 ThrowException("Shift amount must be ubyte!");
3628 if (!yyvsp[-2].ValueVal->getType()->isInteger())
3629 ThrowException("Shift constant expression requires integer operand!");
3630 yyval.InstVal = new ShiftInst(yyvsp[-3].OtherOpVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Nate Begeman14b05292005-11-05 09:21:28 +00003631 ;
3632 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003633case 207:
3634#line 2131 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003635{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003636 if (!yyvsp[0].TypeVal->get()->isFirstClassType())
3637 ThrowException("cast instruction to a non-primitive type: '" +
3638 yyvsp[0].TypeVal->get()->getDescription() + "'!");
3639 yyval.InstVal = new CastInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
3640 delete yyvsp[0].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003641 ;
3642 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003643case 208:
3644#line 2138 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003645{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003646 if (yyvsp[-4].ValueVal->getType() != Type::BoolTy)
3647 ThrowException("select condition must be boolean!");
3648 if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
3649 ThrowException("select value types should match!");
3650 yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Nate Begeman14b05292005-11-05 09:21:28 +00003651 ;
3652 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003653case 209:
3654#line 2145 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003655{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003656 NewVarArgs = true;
3657 yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
3658 delete yyvsp[0].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003659 ;
3660 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003661case 210:
3662#line 2150 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003663{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003664 ObsoleteVarArgs = true;
3665 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
3666 Function* NF = CurModule.CurrentModule->
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003667 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003668
3669 //b = vaarg a, t ->
3670 //foo = alloca 1 of t
3671 //bar = vacopy a
3672 //store bar -> foo
3673 //b = vaarg foo, t
3674 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
3675 CurBB->getInstList().push_back(foo);
3676 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
3677 CurBB->getInstList().push_back(bar);
3678 CurBB->getInstList().push_back(new StoreInst(bar, foo));
3679 yyval.InstVal = new VAArgInst(foo, *yyvsp[0].TypeVal);
3680 delete yyvsp[0].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003681 ;
3682 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003683case 211:
3684#line 2169 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003685{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003686 ObsoleteVarArgs = true;
3687 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
3688 Function* NF = CurModule.CurrentModule->
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003689 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003690
3691 //b = vanext a, t ->
3692 //foo = alloca 1 of t
3693 //bar = vacopy a
3694 //store bar -> foo
3695 //tmp = vaarg foo, t
3696 //b = load foo
3697 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
3698 CurBB->getInstList().push_back(foo);
3699 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
3700 CurBB->getInstList().push_back(bar);
3701 CurBB->getInstList().push_back(new StoreInst(bar, foo));
3702 Instruction* tmp = new VAArgInst(foo, *yyvsp[0].TypeVal);
3703 CurBB->getInstList().push_back(tmp);
3704 yyval.InstVal = new LoadInst(foo);
3705 delete yyvsp[0].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003706 ;
3707 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003708case 212:
3709#line 2191 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
3710{
3711 if (!isa<PackedType>(yyvsp[-2].ValueVal->getType()))
3712 ThrowException("First operand of extractelement must be a "
3713 "packed type val!");
3714 if (yyvsp[0].ValueVal->getType() != Type::UIntTy)
3715 ThrowException("Second operand of extractelement must be a uint!");
3716 yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
3717 ;
3718 break;}
3719case 213:
3720#line 2199 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003721{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003722 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
3723 if (!Ty->isFirstClassType())
3724 ThrowException("PHI node operands must be of first class type!");
3725 yyval.InstVal = new PHINode(Ty);
3726 ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
3727 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
3728 if (yyvsp[0].PHIList->front().first->getType() != Ty)
3729 ThrowException("All elements of a PHI node must be of the same type!");
3730 cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
3731 yyvsp[0].PHIList->pop_front();
3732 }
3733 delete yyvsp[0].PHIList; // Free the list...
Nate Begeman14b05292005-11-05 09:21:28 +00003734 ;
3735 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003736case 214:
3737#line 2213 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003738{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003739 const PointerType *PFTy;
3740 const FunctionType *Ty;
3741
3742 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-4].TypeVal->get())) ||
3743 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3744 // Pull out the types of all of the arguments...
3745 std::vector<const Type*> ParamTypes;
3746 if (yyvsp[-1].ValueList) {
3747 for (std::vector<Value*>::iterator I = yyvsp[-1].ValueList->begin(), E = yyvsp[-1].ValueList->end();
3748 I != E; ++I)
3749 ParamTypes.push_back((*I)->getType());
3750 }
3751
3752 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3753 if (isVarArg) ParamTypes.pop_back();
3754
3755 if (!(*yyvsp[-4].TypeVal)->isFirstClassType() && *yyvsp[-4].TypeVal != Type::VoidTy)
3756 ThrowException("LLVM functions cannot return aggregate types!");
3757
3758 Ty = FunctionType::get(yyvsp[-4].TypeVal->get(), ParamTypes, isVarArg);
3759 PFTy = PointerType::get(Ty);
3760 }
3761
3762 Value *V = getVal(PFTy, yyvsp[-3].ValIDVal); // Get the function we're calling...
3763
3764 // Create the call node...
3765 if (!yyvsp[-1].ValueList) { // Has no arguments?
3766 // Make sure no arguments is a good thing!
3767 if (Ty->getNumParams() != 0)
3768 ThrowException("No arguments passed to a function that "
3769 "expects arguments!");
3770
3771 yyval.InstVal = new CallInst(V, std::vector<Value*>());
3772 } else { // Has arguments?
3773 // Loop through FunctionType's arguments and ensure they are specified
3774 // correctly!
3775 //
3776 FunctionType::param_iterator I = Ty->param_begin();
3777 FunctionType::param_iterator E = Ty->param_end();
3778 std::vector<Value*>::iterator ArgI = yyvsp[-1].ValueList->begin(), ArgE = yyvsp[-1].ValueList->end();
3779
3780 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3781 if ((*ArgI)->getType() != *I)
3782 ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
3783 (*I)->getDescription() + "'!");
3784
3785 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
3786 ThrowException("Invalid number of parameters detected!");
3787
3788 yyval.InstVal = new CallInst(V, *yyvsp[-1].ValueList);
3789 }
3790 cast<CallInst>(yyval.InstVal)->setTailCall(yyvsp[-6].BoolVal);
3791 cast<CallInst>(yyval.InstVal)->setCallingConv(yyvsp[-5].UIntVal);
3792 delete yyvsp[-4].TypeVal;
3793 delete yyvsp[-1].ValueList;
Nate Begeman14b05292005-11-05 09:21:28 +00003794 ;
3795 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003796case 215:
3797#line 2270 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003798{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003799 yyval.InstVal = yyvsp[0].InstVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003800 ;
3801 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003802case 216:
3803#line 2276 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003804{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003805 yyval.ValueList = yyvsp[0].ValueList;
Nate Begeman14b05292005-11-05 09:21:28 +00003806 ;
3807 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003808case 217:
3809#line 2278 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003810{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003811 yyval.ValueList = new std::vector<Value*>();
Nate Begeman14b05292005-11-05 09:21:28 +00003812 ;
3813 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003814case 218:
3815#line 2282 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003816{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003817 yyval.BoolVal = true;
Nate Begeman14b05292005-11-05 09:21:28 +00003818 ;
3819 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003820case 219:
3821#line 2285 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003822{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003823 yyval.BoolVal = false;
Nate Begeman14b05292005-11-05 09:21:28 +00003824 ;
3825 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003826case 220:
3827#line 2291 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003828{
Chris Lattner7d09ab62005-11-06 06:34:34 +00003829 yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
3830 delete yyvsp[-1].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003831 ;
3832 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003833case 221:
3834#line 2295 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003835{
Chris Lattner7d09ab62005-11-06 06:34:34 +00003836 yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal);
3837 delete yyvsp[-4].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003838 ;
3839 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003840case 222:
3841#line 2299 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003842{
Chris Lattner7d09ab62005-11-06 06:34:34 +00003843 yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
3844 delete yyvsp[-1].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003845 ;
3846 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003847case 223:
3848#line 2303 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003849{
Chris Lattner7d09ab62005-11-06 06:34:34 +00003850 yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal);
3851 delete yyvsp[-4].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003852 ;
3853 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003854case 224:
3855#line 2307 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003856{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003857 if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
3858 ThrowException("Trying to free nonpointer type " +
3859 yyvsp[0].ValueVal->getType()->getDescription() + "!");
3860 yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
Nate Begeman14b05292005-11-05 09:21:28 +00003861 ;
3862 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003863case 225:
3864#line 2314 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003865{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003866 if (!isa<PointerType>(yyvsp[-1].TypeVal->get()))
3867 ThrowException("Can't load from nonpointer type: " +
3868 (*yyvsp[-1].TypeVal)->getDescription());
3869 if (!cast<PointerType>(yyvsp[-1].TypeVal->get())->getElementType()->isFirstClassType())
3870 ThrowException("Can't load from pointer of non-first-class type: " +
3871 (*yyvsp[-1].TypeVal)->getDescription());
3872 yyval.InstVal = new LoadInst(getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), "", yyvsp[-3].BoolVal);
3873 delete yyvsp[-1].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003874 ;
3875 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003876case 226:
3877#line 2324 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003878{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003879 const PointerType *PT = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
3880 if (!PT)
3881 ThrowException("Can't store to a nonpointer type: " +
3882 (*yyvsp[-1].TypeVal)->getDescription());
3883 const Type *ElTy = PT->getElementType();
3884 if (ElTy != yyvsp[-3].ValueVal->getType())
3885 ThrowException("Can't store '" + yyvsp[-3].ValueVal->getType()->getDescription() +
3886 "' into space of type '" + ElTy->getDescription() + "'!");
3887
3888 yyval.InstVal = new StoreInst(yyvsp[-3].ValueVal, getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), yyvsp[-5].BoolVal);
3889 delete yyvsp[-1].TypeVal;
Nate Begeman14b05292005-11-05 09:21:28 +00003890 ;
3891 break;}
Robert Bocchino9c62b562006-01-10 19:04:32 +00003892case 227:
3893#line 2337 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Nate Begeman14b05292005-11-05 09:21:28 +00003894{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003895 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
3896 ThrowException("getelementptr insn requires pointer operand!");
3897
3898 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
3899 // indices to uint struct indices for compatibility.
3900 generic_gep_type_iterator<std::vector<Value*>::iterator>
3901 GTI = gep_type_begin(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end()),
3902 GTE = gep_type_end(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end());
3903 for (unsigned i = 0, e = yyvsp[0].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
3904 if (isa<StructType>(*GTI)) // Only change struct indices
3905 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[0].ValueList)[i]))
3906 if (CUI->getType() == Type::UByteTy)
3907 (*yyvsp[0].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
3908
3909 if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, *yyvsp[0].ValueList, true))
3910 ThrowException("Invalid getelementptr indices for type '" +
3911 (*yyvsp[-2].TypeVal)->getDescription()+ "'!");
3912 yyval.InstVal = new GetElementPtrInst(getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal), *yyvsp[0].ValueList);
3913 delete yyvsp[-2].TypeVal; delete yyvsp[0].ValueList;
Nate Begeman14b05292005-11-05 09:21:28 +00003914 ;
3915 break;}
3916}
3917 /* the action file gets copied in in place of this dollarsign */
3918#line 543 "/usr/share/bison.simple"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003919
3920 yyvsp -= yylen;
3921 yyssp -= yylen;
Nate Begeman14b05292005-11-05 09:21:28 +00003922#ifdef YYLSP_NEEDED
3923 yylsp -= yylen;
3924#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00003925
Nate Begeman14b05292005-11-05 09:21:28 +00003926#if YYDEBUG != 0
3927 if (yydebug)
3928 {
3929 short *ssp1 = yyss - 1;
3930 fprintf (stderr, "state stack now");
3931 while (ssp1 != yyssp)
3932 fprintf (stderr, " %d", *++ssp1);
3933 fprintf (stderr, "\n");
3934 }
3935#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00003936
3937 *++yyvsp = yyval;
3938
Nate Begeman14b05292005-11-05 09:21:28 +00003939#ifdef YYLSP_NEEDED
3940 yylsp++;
3941 if (yylen == 0)
3942 {
3943 yylsp->first_line = yylloc.first_line;
3944 yylsp->first_column = yylloc.first_column;
3945 yylsp->last_line = (yylsp-1)->last_line;
3946 yylsp->last_column = (yylsp-1)->last_column;
3947 yylsp->text = 0;
3948 }
3949 else
3950 {
3951 yylsp->last_line = (yylsp+yylen-1)->last_line;
3952 yylsp->last_column = (yylsp+yylen-1)->last_column;
3953 }
3954#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00003955
Nate Begeman14b05292005-11-05 09:21:28 +00003956 /* Now "shift" the result of the reduction.
3957 Determine what state that goes to,
3958 based on the state we popped back to
3959 and the rule number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003960
3961 yyn = yyr1[yyn];
3962
Nate Begeman14b05292005-11-05 09:21:28 +00003963 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
3964 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003965 yystate = yytable[yystate];
3966 else
Nate Begeman14b05292005-11-05 09:21:28 +00003967 yystate = yydefgoto[yyn - YYNTBASE];
Reid Spencer68a24bd2005-08-27 18:50:39 +00003968
3969 goto yynewstate;
3970
Nate Begeman14b05292005-11-05 09:21:28 +00003971yyerrlab: /* here on detecting error */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003972
Nate Begeman14b05292005-11-05 09:21:28 +00003973 if (! yyerrstatus)
3974 /* If not already recovering from an error, report this error. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003975 {
3976 ++yynerrs;
Nate Begeman14b05292005-11-05 09:21:28 +00003977
3978#ifdef YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00003979 yyn = yypact[yystate];
3980
Nate Begeman14b05292005-11-05 09:21:28 +00003981 if (yyn > YYFLAG && yyn < YYLAST)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003982 {
Nate Begeman14b05292005-11-05 09:21:28 +00003983 int size = 0;
3984 char *msg;
3985 int x, count;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003986
Nate Begeman14b05292005-11-05 09:21:28 +00003987 count = 0;
3988 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
3989 for (x = (yyn < 0 ? -yyn : 0);
3990 x < (sizeof(yytname) / sizeof(char *)); x++)
3991 if (yycheck[x + yyn] == x)
3992 size += strlen(yytname[x]) + 15, count++;
3993 msg = (char *) malloc(size + 15);
3994 if (msg != 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003995 {
Nate Begeman14b05292005-11-05 09:21:28 +00003996 strcpy(msg, "parse error");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003997
Nate Begeman14b05292005-11-05 09:21:28 +00003998 if (count < 5)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003999 {
Nate Begeman14b05292005-11-05 09:21:28 +00004000 count = 0;
4001 for (x = (yyn < 0 ? -yyn : 0);
4002 x < (sizeof(yytname) / sizeof(char *)); x++)
4003 if (yycheck[x + yyn] == x)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004004 {
Nate Begeman14b05292005-11-05 09:21:28 +00004005 strcat(msg, count == 0 ? ", expecting `" : " or `");
4006 strcat(msg, yytname[x]);
4007 strcat(msg, "'");
4008 count++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004009 }
4010 }
Nate Begeman14b05292005-11-05 09:21:28 +00004011 yyerror(msg);
4012 free(msg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004013 }
4014 else
Nate Begeman14b05292005-11-05 09:21:28 +00004015 yyerror ("parse error; also virtual memory exceeded");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004016 }
4017 else
4018#endif /* YYERROR_VERBOSE */
Nate Begeman14b05292005-11-05 09:21:28 +00004019 yyerror("parse error");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004020 }
4021
Nate Begeman14b05292005-11-05 09:21:28 +00004022 goto yyerrlab1;
4023yyerrlab1: /* here on error raised explicitly by an action */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004024
4025 if (yyerrstatus == 3)
4026 {
Nate Begeman14b05292005-11-05 09:21:28 +00004027 /* if just tried and failed to reuse lookahead token after an error, discard it. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004028
Nate Begeman14b05292005-11-05 09:21:28 +00004029 /* return failure if at end of input */
4030 if (yychar == YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004031 YYABORT;
4032
Nate Begeman14b05292005-11-05 09:21:28 +00004033#if YYDEBUG != 0
4034 if (yydebug)
4035 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
4036#endif
4037
4038 yychar = YYEMPTY;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004039 }
4040
Nate Begeman14b05292005-11-05 09:21:28 +00004041 /* Else will try to reuse lookahead token
4042 after shifting the error token. */
4043
4044 yyerrstatus = 3; /* Each real token shifted decrements this */
4045
4046 goto yyerrhandle;
4047
4048yyerrdefault: /* current state does not do anything special for the error token. */
4049
4050#if 0
4051 /* This is wrong; only states that explicitly want error tokens
4052 should shift them. */
4053 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
4054 if (yyn) goto yydefault;
4055#endif
4056
4057yyerrpop: /* pop the current state because it cannot handle the error token */
4058
4059 if (yyssp == yyss) YYABORT;
4060 yyvsp--;
4061 yystate = *--yyssp;
4062#ifdef YYLSP_NEEDED
4063 yylsp--;
4064#endif
4065
4066#if YYDEBUG != 0
4067 if (yydebug)
4068 {
4069 short *ssp1 = yyss - 1;
4070 fprintf (stderr, "Error: state stack now");
4071 while (ssp1 != yyssp)
4072 fprintf (stderr, " %d", *++ssp1);
4073 fprintf (stderr, "\n");
4074 }
4075#endif
4076
4077yyerrhandle:
4078
4079 yyn = yypact[yystate];
4080 if (yyn == YYFLAG)
4081 goto yyerrdefault;
4082
4083 yyn += YYTERROR;
4084 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
4085 goto yyerrdefault;
4086
4087 yyn = yytable[yyn];
4088 if (yyn < 0)
4089 {
4090 if (yyn == YYFLAG)
4091 goto yyerrpop;
4092 yyn = -yyn;
4093 goto yyreduce;
4094 }
4095 else if (yyn == 0)
4096 goto yyerrpop;
4097
Reid Spencer68a24bd2005-08-27 18:50:39 +00004098 if (yyn == YYFINAL)
4099 YYACCEPT;
4100
Nate Begeman14b05292005-11-05 09:21:28 +00004101#if YYDEBUG != 0
4102 if (yydebug)
4103 fprintf(stderr, "Shifting error token, ");
4104#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00004105
4106 *++yyvsp = yylval;
Nate Begeman14b05292005-11-05 09:21:28 +00004107#ifdef YYLSP_NEEDED
4108 *++yylsp = yylloc;
4109#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00004110
4111 yystate = yyn;
4112 goto yynewstate;
4113
Nate Begeman14b05292005-11-05 09:21:28 +00004114 yyacceptlab:
4115 /* YYACCEPT comes here. */
4116 if (yyfree_stacks)
4117 {
4118 free (yyss);
4119 free (yyvs);
4120#ifdef YYLSP_NEEDED
4121 free (yyls);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004122#endif
Nate Begeman14b05292005-11-05 09:21:28 +00004123 }
4124 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004125
Nate Begeman14b05292005-11-05 09:21:28 +00004126 yyabortlab:
4127 /* YYABORT comes here. */
4128 if (yyfree_stacks)
4129 {
4130 free (yyss);
4131 free (yyvs);
4132#ifdef YYLSP_NEEDED
4133 free (yyls);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004134#endif
Nate Begeman14b05292005-11-05 09:21:28 +00004135 }
4136 return 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004137}
Robert Bocchino9c62b562006-01-10 19:04:32 +00004138#line 2360 "/Users/bocchino/vllvm-checkin/src/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00004139
4140int yyerror(const char *ErrorMsg) {
4141 std::string where
4142 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
4143 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
4144 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
4145 if (yychar == YYEMPTY || yychar == 0)
4146 errMsg += "end-of-file.";
4147 else
4148 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
4149 ThrowException(errMsg);
4150 return 0;
4151}