blob: 929940f08afa62c0c0ccf2da8de49323e179933c [file] [log] [blame]
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001
Chris Lattner680aab62006-08-18 17:34:45 +00002/* A Bison parser, made from /Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y
3 by GNU Bison version 1.28 */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004
Chris Lattner680aab62006-08-18 17:34:45 +00005#define YYBISON 1 /* Identify Bison output. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00006
Reid Spencerdfb3fb42005-08-27 18:50:39 +00007#define yyparse llvmAsmparse
Chris Lattner680aab62006-08-18 17:34:45 +00008#define yylex llvmAsmlex
Reid Spencerdfb3fb42005-08-27 18:50:39 +00009#define yyerror llvmAsmerror
Chris Lattner680aab62006-08-18 17:34:45 +000010#define yylval llvmAsmlval
11#define yychar llvmAsmchar
Reid Spencerdfb3fb42005-08-27 18:50:39 +000012#define yydebug llvmAsmdebug
13#define yynerrs llvmAsmnerrs
Chris Lattner680aab62006-08-18 17:34:45 +000014#define ESINT64VAL 257
15#define EUINT64VAL 258
16#define SINTVAL 259
17#define UINTVAL 260
18#define FPVAL 261
19#define VOID 262
20#define BOOL 263
21#define SBYTE 264
22#define UBYTE 265
23#define SHORT 266
24#define USHORT 267
25#define INT 268
26#define UINT 269
27#define LONG 270
28#define ULONG 271
29#define FLOAT 272
30#define DOUBLE 273
31#define TYPE 274
32#define LABEL 275
33#define VAR_ID 276
34#define LABELSTR 277
35#define STRINGCONSTANT 278
36#define IMPLEMENTATION 279
37#define ZEROINITIALIZER 280
38#define TRUETOK 281
39#define FALSETOK 282
40#define BEGINTOK 283
41#define ENDTOK 284
42#define DECLARE 285
43#define GLOBAL 286
44#define CONSTANT 287
45#define SECTION 288
46#define VOLATILE 289
47#define TO 290
48#define DOTDOTDOT 291
49#define NULL_TOK 292
50#define UNDEF 293
51#define CONST 294
52#define INTERNAL 295
53#define LINKONCE 296
54#define WEAK 297
55#define APPENDING 298
56#define OPAQUE 299
57#define NOT 300
58#define EXTERNAL 301
59#define TARGET 302
60#define TRIPLE 303
61#define ENDIAN 304
62#define POINTERSIZE 305
63#define LITTLE 306
64#define BIG 307
65#define ALIGN 308
66#define DEPLIBS 309
67#define CALL 310
68#define TAIL 311
69#define ASM_TOK 312
70#define MODULE 313
71#define SIDEEFFECT 314
72#define CC_TOK 315
73#define CCC_TOK 316
74#define CSRETCC_TOK 317
75#define FASTCC_TOK 318
76#define COLDCC_TOK 319
77#define RET 320
78#define BR 321
79#define SWITCH 322
80#define INVOKE 323
81#define UNWIND 324
82#define UNREACHABLE 325
83#define ADD 326
84#define SUB 327
85#define MUL 328
86#define DIV 329
87#define REM 330
88#define AND 331
89#define OR 332
90#define XOR 333
91#define SETLE 334
92#define SETGE 335
93#define SETLT 336
94#define SETGT 337
95#define SETEQ 338
96#define SETNE 339
97#define MALLOC 340
98#define ALLOCA 341
99#define FREE 342
100#define LOAD 343
101#define STORE 344
102#define GETELEMENTPTR 345
103#define PHI_TOK 346
104#define CAST 347
105#define SELECT 348
106#define SHL 349
107#define SHR 350
108#define VAARG 351
109#define EXTRACTELEMENT 352
110#define INSERTELEMENT 353
111#define SHUFFLEVECTOR 354
112#define VAARG_old 355
113#define VANEXT_old 356
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000114
Chris Lattner680aab62006-08-18 17:34:45 +0000115#line 14 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000116
117#include "ParserInternals.h"
118#include "llvm/CallingConv.h"
Chris Lattnere0a4ee92006-01-25 22:27:16 +0000119#include "llvm/InlineAsm.h"
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000120#include "llvm/Instructions.h"
121#include "llvm/Module.h"
122#include "llvm/SymbolTable.h"
Reid Spencerb4f9a6f2006-01-16 21:12:35 +0000123#include "llvm/Assembly/AutoUpgrade.h"
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000124#include "llvm/Support/GetElementPtrTypeIterator.h"
125#include "llvm/ADT/STLExtras.h"
Chris Lattner840f7892005-11-06 06:46:53 +0000126#include "llvm/Support/MathExtras.h"
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000127#include <algorithm>
128#include <iostream>
129#include <list>
130#include <utility>
131
Reid Spencerb50974a2006-08-18 17:32:55 +0000132// The following is a gross hack. In order to rid the libAsmParser library of
133// exceptions, we have to have a way of getting the yyparse function to go into
134// an error situation. So, whenever we want an error to occur, the GenerateError
135// function (see bottom of file) sets TriggerError. Then, at the end of each
136// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
137// (a goto) to put YACC in error state. Furthermore, several calls to
138// GenerateError are made from inside productions and they must simulate the
139// previous exception behavior by exiting the production immediately. We have
140// replaced these with the GEN_ERROR macro which calls GeneratError and then
141// immediately invokes YYERROR. This would be so much cleaner if it was a
142// recursive descent parser.
Reid Spencer713eedc2006-08-18 08:43:06 +0000143static bool TriggerError = false;
144#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYERROR; } }
Reid Spencer713eedc2006-08-18 08:43:06 +0000145#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
146
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000147int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
148int yylex(); // declaration" of xxx warnings.
149int yyparse();
150
151namespace llvm {
152 std::string CurFilename;
153}
154using namespace llvm;
155
156static Module *ParserResult;
157
158// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
159// relating to upreferences in the input stream.
160//
161//#define DEBUG_UPREFS 1
162#ifdef DEBUG_UPREFS
163#define UR_OUT(X) std::cerr << X
164#else
165#define UR_OUT(X)
166#endif
167
168#define YYERROR_VERBOSE 1
169
170static bool ObsoleteVarArgs;
171static bool NewVarArgs;
Chris Lattner11ca4d62005-11-12 18:22:38 +0000172static BasicBlock *CurBB;
173static GlobalVariable *CurGV;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000174
175
176// This contains info used when building the body of a function. It is
177// destroyed when the function is completed.
178//
179typedef std::vector<Value *> ValueList; // Numbered defs
180static void
181ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
182 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
183
184static struct PerModuleInfo {
185 Module *CurrentModule;
186 std::map<const Type *, ValueList> Values; // Module level numbered definitions
187 std::map<const Type *,ValueList> LateResolveValues;
188 std::vector<PATypeHolder> Types;
189 std::map<ValID, PATypeHolder> LateResolveTypes;
190
191 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner7aa45902006-06-21 16:53:00 +0000192 /// how they were referenced and on which line of the input they came from so
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000193 /// that we can resolve them later and print error messages as appropriate.
194 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
195
196 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
197 // references to global values. Global values may be referenced before they
198 // are defined, and if so, the temporary object that they represent is held
199 // here. This is used for forward references of GlobalValues.
200 //
201 typedef std::map<std::pair<const PointerType *,
202 ValID>, GlobalValue*> GlobalRefsType;
203 GlobalRefsType GlobalRefs;
204
205 void ModuleDone() {
206 // If we could not resolve some functions at function compilation time
207 // (calls to functions before they are defined), resolve them now... Types
208 // are resolved when the constant pool has been completely parsed.
209 //
210 ResolveDefinitions(LateResolveValues);
211
212 // Check to make sure that all global value forward references have been
213 // resolved!
214 //
215 if (!GlobalRefs.empty()) {
216 std::string UndefinedReferences = "Unresolved global references exist:\n";
217
218 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
219 I != E; ++I) {
220 UndefinedReferences += " " + I->first.first->getDescription() + " " +
221 I->first.second.getName() + "\n";
222 }
Reid Spencer713eedc2006-08-18 08:43:06 +0000223 GenerateError(UndefinedReferences);
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000224 }
225
Reid Spencerc8a9faf2006-01-19 01:21:04 +0000226 // Look for intrinsic functions and CallInst that need to be upgraded
Chris Lattner9ff96a72006-04-08 01:18:56 +0000227 for (Module::iterator FI = CurrentModule->begin(),
228 FE = CurrentModule->end(); FI != FE; )
Chris Lattneradf5ec62006-03-04 07:53:41 +0000229 UpgradeCallsToIntrinsic(FI++);
Reid Spencerb4f9a6f2006-01-16 21:12:35 +0000230
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000231 Values.clear(); // Clear out function local definitions
232 Types.clear();
233 CurrentModule = 0;
234 }
235
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000236 // GetForwardRefForGlobal - Check to see if there is a forward reference
237 // for this global. If so, remove it from the GlobalRefs map and return it.
238 // If not, just return null.
239 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
240 // Check to see if there is a forward reference to this global variable...
241 // if there is, eliminate it and patch the reference to use the new def'n.
242 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
243 GlobalValue *Ret = 0;
244 if (I != GlobalRefs.end()) {
245 Ret = I->second;
246 GlobalRefs.erase(I);
247 }
248 return Ret;
249 }
250} CurModule;
251
252static struct PerFunctionInfo {
253 Function *CurrentFunction; // Pointer to current function being created
254
255 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
256 std::map<const Type*, ValueList> LateResolveValues;
257 bool isDeclare; // Is this function a forward declararation?
258
259 /// BBForwardRefs - When we see forward references to basic blocks, keep
260 /// track of them here.
261 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
262 std::vector<BasicBlock*> NumberedBlocks;
263 unsigned NextBBNum;
264
265 inline PerFunctionInfo() {
266 CurrentFunction = 0;
267 isDeclare = false;
268 }
269
270 inline void FunctionStart(Function *M) {
271 CurrentFunction = M;
272 NextBBNum = 0;
273 }
274
275 void FunctionDone() {
276 NumberedBlocks.clear();
277
278 // Any forward referenced blocks left?
279 if (!BBForwardRefs.empty())
Reid Spencer713eedc2006-08-18 08:43:06 +0000280 GenerateError("Undefined reference to label " +
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000281 BBForwardRefs.begin()->first->getName());
282
283 // Resolve all forward references now.
284 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
285
286 Values.clear(); // Clear out function local definitions
287 CurrentFunction = 0;
288 isDeclare = false;
289 }
290} CurFun; // Info for the current function...
291
292static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
293
294
295//===----------------------------------------------------------------------===//
296// Code to handle definitions of all the types
297//===----------------------------------------------------------------------===//
298
299static int InsertValue(Value *V,
300 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
301 if (V->hasName()) return -1; // Is this a numbered definition?
302
303 // Yes, insert the value into the value table...
304 ValueList &List = ValueTab[V->getType()];
305 List.push_back(V);
306 return List.size()-1;
307}
308
309static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
310 switch (D.Type) {
311 case ValID::NumberVal: // Is it a numbered definition?
312 // Module constants occupy the lowest numbered slots...
313 if ((unsigned)D.Num < CurModule.Types.size())
314 return CurModule.Types[(unsigned)D.Num];
315 break;
316 case ValID::NameVal: // Is it a named definition?
317 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
318 D.destroy(); // Free old strdup'd memory...
319 return N;
320 }
321 break;
322 default:
Reid Spencer713eedc2006-08-18 08:43:06 +0000323 GenerateError("Internal parser error: Invalid symbol type reference!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000324 }
325
326 // If we reached here, we referenced either a symbol that we don't know about
327 // or an id number that hasn't been read yet. We may be referencing something
328 // forward, so just create an entry to be resolved later and get to it...
329 //
330 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
331
332
333 if (inFunctionScope()) {
334 if (D.Type == ValID::NameVal)
Reid Spencer713eedc2006-08-18 08:43:06 +0000335 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000336 else
Reid Spencer713eedc2006-08-18 08:43:06 +0000337 GenerateError("Reference to an undefined type: #" + itostr(D.Num));
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000338 }
339
340 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
341 if (I != CurModule.LateResolveTypes.end())
342 return I->second;
343
344 Type *Typ = OpaqueType::get();
345 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
346 return Typ;
347 }
348
349static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
350 SymbolTable &SymTab =
351 inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() :
352 CurModule.CurrentModule->getSymbolTable();
353 return SymTab.lookup(Ty, Name);
354}
355
356// getValNonImprovising - Look up the value specified by the provided type and
357// the provided ValID. If the value exists and has already been defined, return
358// it. Otherwise return null.
359//
360static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
361 if (isa<FunctionType>(Ty))
Reid Spencer713eedc2006-08-18 08:43:06 +0000362 GenerateError("Functions are not values and "
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000363 "must be referenced as pointers");
364
365 switch (D.Type) {
366 case ValID::NumberVal: { // Is it a numbered definition?
367 unsigned Num = (unsigned)D.Num;
368
369 // Module constants occupy the lowest numbered slots...
370 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
371 if (VI != CurModule.Values.end()) {
372 if (Num < VI->second.size())
373 return VI->second[Num];
374 Num -= VI->second.size();
375 }
376
377 // Make sure that our type is within bounds
378 VI = CurFun.Values.find(Ty);
379 if (VI == CurFun.Values.end()) return 0;
380
381 // Check that the number is within bounds...
382 if (VI->second.size() <= Num) return 0;
383
384 return VI->second[Num];
385 }
386
387 case ValID::NameVal: { // Is it a named definition?
388 Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
389 if (N == 0) return 0;
390
391 D.destroy(); // Free old strdup'd memory...
392 return N;
393 }
394
395 // Check to make sure that "Ty" is an integral type, and that our
396 // value will fit into the specified type...
397 case ValID::ConstSIntVal: // Is it a constant pool reference??
398 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64))
Reid Spencer713eedc2006-08-18 08:43:06 +0000399 GenerateError("Signed integral constant '" +
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000400 itostr(D.ConstPool64) + "' is invalid for type '" +
401 Ty->getDescription() + "'!");
402 return ConstantSInt::get(Ty, D.ConstPool64);
403
404 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
405 if (!ConstantUInt::isValueValidForType(Ty, D.UConstPool64)) {
406 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer713eedc2006-08-18 08:43:06 +0000407 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000408 "' is invalid or out of range!");
409 } else { // This is really a signed reference. Transmogrify.
410 return ConstantSInt::get(Ty, D.ConstPool64);
411 }
412 } else {
413 return ConstantUInt::get(Ty, D.UConstPool64);
414 }
415
416 case ValID::ConstFPVal: // Is it a floating point const pool reference?
417 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
Reid Spencer713eedc2006-08-18 08:43:06 +0000418 GenerateError("FP constant invalid for type!!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000419 return ConstantFP::get(Ty, D.ConstPoolFP);
420
421 case ValID::ConstNullVal: // Is it a null value?
422 if (!isa<PointerType>(Ty))
Reid Spencer713eedc2006-08-18 08:43:06 +0000423 GenerateError("Cannot create a a non pointer null!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000424 return ConstantPointerNull::get(cast<PointerType>(Ty));
425
426 case ValID::ConstUndefVal: // Is it an undef value?
427 return UndefValue::get(Ty);
428
Chris Lattnera054d122005-12-21 17:53:23 +0000429 case ValID::ConstZeroVal: // Is it a zero value?
430 return Constant::getNullValue(Ty);
431
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000432 case ValID::ConstantVal: // Fully resolved constant?
433 if (D.ConstantValue->getType() != Ty)
Reid Spencer713eedc2006-08-18 08:43:06 +0000434 GenerateError("Constant expression type different from required type!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000435 return D.ConstantValue;
436
Chris Lattnere0a4ee92006-01-25 22:27:16 +0000437 case ValID::InlineAsmVal: { // Inline asm expression
438 const PointerType *PTy = dyn_cast<PointerType>(Ty);
439 const FunctionType *FTy =
440 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
441 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints))
Reid Spencer713eedc2006-08-18 08:43:06 +0000442 GenerateError("Invalid type for asm constraint string!");
Chris Lattnere0a4ee92006-01-25 22:27:16 +0000443 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
444 D.IAD->HasSideEffects);
445 D.destroy(); // Free InlineAsmDescriptor.
446 return IA;
447 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000448 default:
449 assert(0 && "Unhandled case!");
450 return 0;
451 } // End of switch
452
453 assert(0 && "Unhandled case!");
454 return 0;
455}
456
457// getVal - This function is identical to getValNonImprovising, except that if a
458// value is not already defined, it "improvises" by creating a placeholder var
459// that looks and acts just like the requested variable. When the value is
460// defined later, all uses of the placeholder variable are replaced with the
461// real thing.
462//
463static Value *getVal(const Type *Ty, const ValID &ID) {
464 if (Ty == Type::LabelTy)
Reid Spencer713eedc2006-08-18 08:43:06 +0000465 GenerateError("Cannot use a basic block here");
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000466
467 // See if the value has already been defined.
468 Value *V = getValNonImprovising(Ty, ID);
469 if (V) return V;
470
471 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
Reid Spencer713eedc2006-08-18 08:43:06 +0000472 GenerateError("Invalid use of a composite type!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000473
474 // If we reached here, we referenced either a symbol that we don't know about
475 // or an id number that hasn't been read yet. We may be referencing something
476 // forward, so just create an entry to be resolved later and get to it...
477 //
478 V = new Argument(Ty);
479
480 // Remember where this forward reference came from. FIXME, shouldn't we try
481 // to recycle these things??
482 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
483 llvmAsmlineno)));
484
485 if (inFunctionScope())
486 InsertValue(V, CurFun.LateResolveValues);
487 else
488 InsertValue(V, CurModule.LateResolveValues);
489 return V;
490}
491
492/// getBBVal - This is used for two purposes:
493/// * If isDefinition is true, a new basic block with the specified ID is being
494/// defined.
495/// * If isDefinition is true, this is a reference to a basic block, which may
496/// or may not be a forward reference.
497///
498static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
499 assert(inFunctionScope() && "Can't get basic block at global scope!");
500
501 std::string Name;
502 BasicBlock *BB = 0;
503 switch (ID.Type) {
Reid Spencer713eedc2006-08-18 08:43:06 +0000504 default: GenerateError("Illegal label reference " + ID.getName());
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000505 case ValID::NumberVal: // Is it a numbered definition?
506 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
507 CurFun.NumberedBlocks.resize(ID.Num+1);
508 BB = CurFun.NumberedBlocks[ID.Num];
509 break;
510 case ValID::NameVal: // Is it a named definition?
511 Name = ID.Name;
512 if (Value *N = CurFun.CurrentFunction->
513 getSymbolTable().lookup(Type::LabelTy, Name))
514 BB = cast<BasicBlock>(N);
515 break;
516 }
517
518 // See if the block has already been defined.
519 if (BB) {
520 // If this is the definition of the block, make sure the existing value was
521 // just a forward reference. If it was a forward reference, there will be
522 // an entry for it in the PlaceHolderInfo map.
523 if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
524 // The existing value was a definition, not a forward reference.
Reid Spencer713eedc2006-08-18 08:43:06 +0000525 GenerateError("Redefinition of label " + ID.getName());
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000526
527 ID.destroy(); // Free strdup'd memory.
528 return BB;
529 }
530
531 // Otherwise this block has not been seen before.
532 BB = new BasicBlock("", CurFun.CurrentFunction);
533 if (ID.Type == ValID::NameVal) {
534 BB->setName(ID.Name);
535 } else {
536 CurFun.NumberedBlocks[ID.Num] = BB;
537 }
538
539 // If this is not a definition, keep track of it so we can use it as a forward
540 // reference.
541 if (!isDefinition) {
542 // Remember where this forward reference came from.
543 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
544 } else {
545 // The forward declaration could have been inserted anywhere in the
546 // function: insert it into the correct place now.
547 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
548 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
549 }
550 ID.destroy();
551 return BB;
552}
553
554
555//===----------------------------------------------------------------------===//
556// Code to handle forward references in instructions
557//===----------------------------------------------------------------------===//
558//
559// This code handles the late binding needed with statements that reference
560// values not defined yet... for example, a forward branch, or the PHI node for
561// a loop body.
562//
563// This keeps a table (CurFun.LateResolveValues) of all such forward references
564// and back patchs after we are done.
565//
566
567// ResolveDefinitions - If we could not resolve some defs at parsing
568// time (forward branches, phi functions for loops, etc...) resolve the
569// defs now...
570//
571static void
572ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
573 std::map<const Type*,ValueList> *FutureLateResolvers) {
574 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
575 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
576 E = LateResolvers.end(); LRI != E; ++LRI) {
577 ValueList &List = LRI->second;
578 while (!List.empty()) {
579 Value *V = List.back();
580 List.pop_back();
581
582 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
583 CurModule.PlaceHolderInfo.find(V);
584 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
585
586 ValID &DID = PHI->second.first;
587
588 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
589 if (TheRealValue) {
590 V->replaceAllUsesWith(TheRealValue);
591 delete V;
592 CurModule.PlaceHolderInfo.erase(PHI);
593 } else if (FutureLateResolvers) {
594 // Functions have their unresolved items forwarded to the module late
595 // resolver table
596 InsertValue(V, *FutureLateResolvers);
597 } else {
598 if (DID.Type == ValID::NameVal)
Reid Spencer713eedc2006-08-18 08:43:06 +0000599 GenerateError("Reference to an invalid definition: '" +DID.getName()+
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000600 "' of type '" + V->getType()->getDescription() + "'",
601 PHI->second.second);
602 else
Reid Spencer713eedc2006-08-18 08:43:06 +0000603 GenerateError("Reference to an invalid definition: #" +
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000604 itostr(DID.Num) + " of type '" +
605 V->getType()->getDescription() + "'",
606 PHI->second.second);
607 }
608 }
609 }
610
611 LateResolvers.clear();
612}
613
614// ResolveTypeTo - A brand new type was just declared. This means that (if
615// name is not null) things referencing Name can be resolved. Otherwise, things
616// refering to the number can be resolved. Do this now.
617//
618static void ResolveTypeTo(char *Name, const Type *ToTy) {
619 ValID D;
620 if (Name) D = ValID::create(Name);
621 else D = ValID::create((int)CurModule.Types.size());
622
623 std::map<ValID, PATypeHolder>::iterator I =
624 CurModule.LateResolveTypes.find(D);
625 if (I != CurModule.LateResolveTypes.end()) {
626 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
627 CurModule.LateResolveTypes.erase(I);
628 }
629}
630
631// setValueName - Set the specified value to the name given. The name may be
632// null potentially, in which case this is a noop. The string passed in is
633// assumed to be a malloc'd string buffer, and is free'd by this function.
634//
635static void setValueName(Value *V, char *NameStr) {
636 if (NameStr) {
637 std::string Name(NameStr); // Copy string
638 free(NameStr); // Free old string
639
640 if (V->getType() == Type::VoidTy)
Reid Spencer713eedc2006-08-18 08:43:06 +0000641 GenerateError("Can't assign name '" + Name+"' to value with void type!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000642
643 assert(inFunctionScope() && "Must be in function scope!");
644 SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable();
645 if (ST.lookup(V->getType(), Name))
Reid Spencer713eedc2006-08-18 08:43:06 +0000646 GenerateError("Redefinition of value named '" + Name + "' in the '" +
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000647 V->getType()->getDescription() + "' type plane!");
648
649 // Set the name.
650 V->setName(Name);
651 }
652}
653
654/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
655/// this is a declaration, otherwise it is a definition.
Chris Lattner11ca4d62005-11-12 18:22:38 +0000656static GlobalVariable *
657ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
658 bool isConstantGlobal, const Type *Ty,
659 Constant *Initializer) {
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000660 if (isa<FunctionType>(Ty))
Reid Spencer713eedc2006-08-18 08:43:06 +0000661 GenerateError("Cannot declare global vars of function type!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000662
663 const PointerType *PTy = PointerType::get(Ty);
664
665 std::string Name;
666 if (NameStr) {
667 Name = NameStr; // Copy string
668 free(NameStr); // Free old string
669 }
670
671 // See if this global value was forward referenced. If so, recycle the
672 // object.
673 ValID ID;
674 if (!Name.empty()) {
675 ID = ValID::create((char*)Name.c_str());
676 } else {
677 ID = ValID::create((int)CurModule.Values[PTy].size());
678 }
679
680 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
681 // Move the global to the end of the list, from whereever it was
682 // previously inserted.
683 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
684 CurModule.CurrentModule->getGlobalList().remove(GV);
685 CurModule.CurrentModule->getGlobalList().push_back(GV);
686 GV->setInitializer(Initializer);
687 GV->setLinkage(Linkage);
688 GV->setConstant(isConstantGlobal);
689 InsertValue(GV, CurModule.Values);
Chris Lattner11ca4d62005-11-12 18:22:38 +0000690 return GV;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000691 }
692
693 // If this global has a name, check to see if there is already a definition
694 // of this global in the module. If so, merge as appropriate. Note that
695 // this is really just a hack around problems in the CFE. :(
696 if (!Name.empty()) {
697 // We are a simple redefinition of a value, check to see if it is defined
698 // the same as the old one.
699 if (GlobalVariable *EGV =
700 CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
701 // We are allowed to redefine a global variable in two circumstances:
702 // 1. If at least one of the globals is uninitialized or
703 // 2. If both initializers have the same value.
704 //
705 if (!EGV->hasInitializer() || !Initializer ||
706 EGV->getInitializer() == Initializer) {
707
708 // Make sure the existing global version gets the initializer! Make
709 // sure that it also gets marked const if the new version is.
710 if (Initializer && !EGV->hasInitializer())
711 EGV->setInitializer(Initializer);
712 if (isConstantGlobal)
713 EGV->setConstant(true);
714 EGV->setLinkage(Linkage);
Chris Lattner11ca4d62005-11-12 18:22:38 +0000715 return EGV;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000716 }
717
Reid Spencer713eedc2006-08-18 08:43:06 +0000718 GenerateError("Redefinition of global variable named '" + Name +
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000719 "' in the '" + Ty->getDescription() + "' type plane!");
720 }
721 }
722
723 // Otherwise there is no existing GV to use, create one now.
724 GlobalVariable *GV =
725 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
726 CurModule.CurrentModule);
727 InsertValue(GV, CurModule.Values);
Chris Lattner11ca4d62005-11-12 18:22:38 +0000728 return GV;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000729}
730
731// setTypeName - Set the specified type to the name given. The name may be
732// null potentially, in which case this is a noop. The string passed in is
733// assumed to be a malloc'd string buffer, and is freed by this function.
734//
735// This function returns true if the type has already been defined, but is
736// allowed to be redefined in the specified context. If the name is a new name
737// for the type plane, it is inserted and false is returned.
738static bool setTypeName(const Type *T, char *NameStr) {
739 assert(!inFunctionScope() && "Can't give types function-local names!");
740 if (NameStr == 0) return false;
741
742 std::string Name(NameStr); // Copy string
743 free(NameStr); // Free old string
744
745 // We don't allow assigning names to void type
746 if (T == Type::VoidTy)
Reid Spencer713eedc2006-08-18 08:43:06 +0000747 GenerateError("Can't assign name '" + Name + "' to the void type!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000748
749 // Set the type name, checking for conflicts as we do so.
750 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
751
752 if (AlreadyExists) { // Inserting a name that is already defined???
753 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
754 assert(Existing && "Conflict but no matching type?");
755
756 // There is only one case where this is allowed: when we are refining an
757 // opaque type. In this case, Existing will be an opaque type.
758 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
759 // We ARE replacing an opaque type!
760 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
761 return true;
762 }
763
764 // Otherwise, this is an attempt to redefine a type. That's okay if
765 // the redefinition is identical to the original. This will be so if
766 // Existing and T point to the same Type object. In this one case we
767 // allow the equivalent redefinition.
768 if (Existing == T) return true; // Yes, it's equal.
769
770 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer713eedc2006-08-18 08:43:06 +0000771 GenerateError("Redefinition of type named '" + Name + "' in the '" +
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000772 T->getDescription() + "' type plane!");
773 }
774
775 return false;
776}
777
778//===----------------------------------------------------------------------===//
779// Code for handling upreferences in type names...
780//
781
782// TypeContains - Returns true if Ty directly contains E in it.
783//
784static bool TypeContains(const Type *Ty, const Type *E) {
785 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
786 E) != Ty->subtype_end();
787}
788
789namespace {
790 struct UpRefRecord {
791 // NestingLevel - The number of nesting levels that need to be popped before
792 // this type is resolved.
793 unsigned NestingLevel;
794
795 // LastContainedTy - This is the type at the current binding level for the
796 // type. Every time we reduce the nesting level, this gets updated.
797 const Type *LastContainedTy;
798
799 // UpRefTy - This is the actual opaque type that the upreference is
800 // represented with.
801 OpaqueType *UpRefTy;
802
803 UpRefRecord(unsigned NL, OpaqueType *URTy)
804 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
805 };
806}
807
808// UpRefs - A list of the outstanding upreferences that need to be resolved.
809static std::vector<UpRefRecord> UpRefs;
810
811/// HandleUpRefs - Every time we finish a new layer of types, this function is
812/// called. It loops through the UpRefs vector, which is a list of the
813/// currently active types. For each type, if the up reference is contained in
814/// the newly completed type, we decrement the level count. When the level
815/// count reaches zero, the upreferenced type is the type that is passed in:
816/// thus we can complete the cycle.
817///
818static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner680aab62006-08-18 17:34:45 +0000819 // If Ty isn't abstract, or if there are no up-references in it, then there is
820 // nothing to resolve here.
821 if (!ty->isAbstract() || UpRefs.empty()) return ty;
822
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000823 PATypeHolder Ty(ty);
824 UR_OUT("Type '" << Ty->getDescription() <<
825 "' newly formed. Resolving upreferences.\n" <<
826 UpRefs.size() << " upreferences active!\n");
827
828 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
829 // to zero), we resolve them all together before we resolve them to Ty. At
830 // the end of the loop, if there is anything to resolve to Ty, it will be in
831 // this variable.
832 OpaqueType *TypeToResolve = 0;
833
834 for (unsigned i = 0; i != UpRefs.size(); ++i) {
835 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
836 << UpRefs[i].second->getDescription() << ") = "
837 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
838 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
839 // Decrement level of upreference
840 unsigned Level = --UpRefs[i].NestingLevel;
841 UpRefs[i].LastContainedTy = Ty;
842 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
843 if (Level == 0) { // Upreference should be resolved!
844 if (!TypeToResolve) {
845 TypeToResolve = UpRefs[i].UpRefTy;
846 } else {
847 UR_OUT(" * Resolving upreference for "
848 << UpRefs[i].second->getDescription() << "\n";
849 std::string OldName = UpRefs[i].UpRefTy->getDescription());
850 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
851 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
852 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
853 }
854 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
855 --i; // Do not skip the next element...
856 }
857 }
858 }
859
860 if (TypeToResolve) {
861 UR_OUT(" * Resolving upreference for "
862 << UpRefs[i].second->getDescription() << "\n";
863 std::string OldName = TypeToResolve->getDescription());
864 TypeToResolve->refineAbstractTypeTo(Ty);
865 }
866
867 return Ty;
868}
869
870
871// common code from the two 'RunVMAsmParser' functions
872 static Module * RunParser(Module * M) {
873
874 llvmAsmlineno = 1; // Reset the current line number...
875 ObsoleteVarArgs = false;
876 NewVarArgs = false;
877
878 CurModule.CurrentModule = M;
879 yyparse(); // Parse the file, potentially throwing exception
Reid Spencer713eedc2006-08-18 08:43:06 +0000880 if (!ParserResult)
881 return 0;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000882
883 Module *Result = ParserResult;
884 ParserResult = 0;
885
886 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
887 {
888 Function* F;
889 if ((F = Result->getNamedFunction("llvm.va_start"))
890 && F->getFunctionType()->getNumParams() == 0)
891 ObsoleteVarArgs = true;
892 if((F = Result->getNamedFunction("llvm.va_copy"))
893 && F->getFunctionType()->getNumParams() == 1)
894 ObsoleteVarArgs = true;
895 }
896
897 if (ObsoleteVarArgs && NewVarArgs)
Reid Spencer713eedc2006-08-18 08:43:06 +0000898 GenerateError("This file is corrupt: it uses both new and old style varargs");
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000899
900 if(ObsoleteVarArgs) {
901 if(Function* F = Result->getNamedFunction("llvm.va_start")) {
902 if (F->arg_size() != 0)
Reid Spencer713eedc2006-08-18 08:43:06 +0000903 GenerateError("Obsolete va_start takes 0 argument!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000904
905 //foo = va_start()
906 // ->
907 //bar = alloca typeof(foo)
908 //va_start(bar)
909 //foo = load bar
910
911 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
912 const Type* ArgTy = F->getFunctionType()->getReturnType();
913 const Type* ArgTyPtr = PointerType::get(ArgTy);
914 Function* NF = Result->getOrInsertFunction("llvm.va_start",
Jeff Cohen11e26b52005-10-23 04:37:20 +0000915 RetTy, ArgTyPtr, (Type *)0);
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000916
917 while (!F->use_empty()) {
918 CallInst* CI = cast<CallInst>(F->use_back());
919 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
920 new CallInst(NF, bar, "", CI);
921 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
922 CI->replaceAllUsesWith(foo);
923 CI->getParent()->getInstList().erase(CI);
924 }
925 Result->getFunctionList().erase(F);
926 }
927
928 if(Function* F = Result->getNamedFunction("llvm.va_end")) {
929 if(F->arg_size() != 1)
Reid Spencer713eedc2006-08-18 08:43:06 +0000930 GenerateError("Obsolete va_end takes 1 argument!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000931
932 //vaend foo
933 // ->
934 //bar = alloca 1 of typeof(foo)
935 //vaend bar
936 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
937 const Type* ArgTy = F->getFunctionType()->getParamType(0);
938 const Type* ArgTyPtr = PointerType::get(ArgTy);
939 Function* NF = Result->getOrInsertFunction("llvm.va_end",
Jeff Cohen11e26b52005-10-23 04:37:20 +0000940 RetTy, ArgTyPtr, (Type *)0);
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000941
942 while (!F->use_empty()) {
943 CallInst* CI = cast<CallInst>(F->use_back());
944 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
945 new StoreInst(CI->getOperand(1), bar, CI);
946 new CallInst(NF, bar, "", CI);
947 CI->getParent()->getInstList().erase(CI);
948 }
949 Result->getFunctionList().erase(F);
950 }
951
952 if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
953 if(F->arg_size() != 1)
Reid Spencer713eedc2006-08-18 08:43:06 +0000954 GenerateError("Obsolete va_copy takes 1 argument!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000955 //foo = vacopy(bar)
956 // ->
957 //a = alloca 1 of typeof(foo)
958 //b = alloca 1 of typeof(foo)
959 //store bar -> b
960 //vacopy(a, b)
961 //foo = load a
962
963 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
964 const Type* ArgTy = F->getFunctionType()->getReturnType();
965 const Type* ArgTyPtr = PointerType::get(ArgTy);
966 Function* NF = Result->getOrInsertFunction("llvm.va_copy",
Jeff Cohen11e26b52005-10-23 04:37:20 +0000967 RetTy, ArgTyPtr, ArgTyPtr,
968 (Type *)0);
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000969
970 while (!F->use_empty()) {
971 CallInst* CI = cast<CallInst>(F->use_back());
972 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
973 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
974 new StoreInst(CI->getOperand(1), b, CI);
975 new CallInst(NF, a, b, "", CI);
976 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
977 CI->replaceAllUsesWith(foo);
978 CI->getParent()->getInstList().erase(CI);
979 }
980 Result->getFunctionList().erase(F);
981 }
982 }
983
984 return Result;
985
986 }
987
988//===----------------------------------------------------------------------===//
989// RunVMAsmParser - Define an interface to this parser
990//===----------------------------------------------------------------------===//
991//
992Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
993 set_scan_file(F);
994
995 CurFilename = Filename;
996 return RunParser(new Module(CurFilename));
997}
998
999Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1000 set_scan_string(AsmString);
1001
1002 CurFilename = "from_memory";
1003 if (M == NULL) {
1004 return RunParser(new Module (CurFilename));
1005 } else {
1006 return RunParser(M);
1007 }
1008}
1009
1010
Chris Lattner680aab62006-08-18 17:34:45 +00001011#line 910 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
1012typedef union {
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001013 llvm::Module *ModuleVal;
1014 llvm::Function *FunctionVal;
1015 std::pair<llvm::PATypeHolder*, char*> *ArgVal;
1016 llvm::BasicBlock *BasicBlockVal;
1017 llvm::TerminatorInst *TermInstVal;
1018 llvm::Instruction *InstVal;
1019 llvm::Constant *ConstVal;
1020
1021 const llvm::Type *PrimType;
1022 llvm::PATypeHolder *TypeVal;
1023 llvm::Value *ValueVal;
1024
1025 std::vector<std::pair<llvm::PATypeHolder*,char*> > *ArgList;
1026 std::vector<llvm::Value*> *ValueList;
1027 std::list<llvm::PATypeHolder> *TypeList;
1028 // Represent the RHS of PHI node
1029 std::list<std::pair<llvm::Value*,
1030 llvm::BasicBlock*> > *PHIList;
1031 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1032 std::vector<llvm::Constant*> *ConstVector;
1033
1034 llvm::GlobalValue::LinkageTypes Linkage;
1035 int64_t SInt64Val;
1036 uint64_t UInt64Val;
1037 int SIntVal;
1038 unsigned UIntVal;
1039 double FPVal;
1040 bool BoolVal;
1041
1042 char *StrVal; // This memory is strdup'd!
1043 llvm::ValID ValIDVal; // strdup'd memory maybe!
1044
1045 llvm::Instruction::BinaryOps BinaryOpVal;
1046 llvm::Instruction::TermOps TermOpVal;
1047 llvm::Instruction::MemoryOps MemOpVal;
1048 llvm::Instruction::OtherOps OtherOpVal;
1049 llvm::Module::Endianness Endianness;
1050} YYSTYPE;
Chris Lattner680aab62006-08-18 17:34:45 +00001051#include <stdio.h>
1052
1053#ifndef __cplusplus
1054#ifndef __STDC__
1055#define const
1056#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001057#endif
1058
1059
1060
Chris Lattner680aab62006-08-18 17:34:45 +00001061#define YYFINAL 496
1062#define YYFLAG -32768
1063#define YYNTBASE 117
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001064
Chris Lattner680aab62006-08-18 17:34:45 +00001065#define YYTRANSLATE(x) ((unsigned)(x) <= 356 ? yytranslate[x] : 188)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001066
Chris Lattner680aab62006-08-18 17:34:45 +00001067static const char yytranslate[] = { 0,
1068 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1069 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1070 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1071 2, 2, 2, 2, 2, 2, 2, 2, 2, 106,
1072 107, 115, 2, 104, 2, 2, 2, 2, 2, 2,
1073 2, 2, 2, 2, 2, 2, 2, 2, 2, 111,
1074 103, 112, 2, 2, 2, 2, 2, 2, 2, 2,
1075 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1076 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1077 108, 105, 110, 2, 2, 2, 2, 2, 116, 2,
1078 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1079 2, 2, 2, 2, 2, 2, 2, 2, 2, 109,
1080 2, 2, 113, 2, 114, 2, 2, 2, 2, 2,
1081 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1082 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1083 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1084 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1085 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1086 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1087 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1088 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1089 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1090 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1091 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1092 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1093 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
1094 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1095 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1096 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
1097 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
1098 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
1099 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1100 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1101 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1102 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
1103 97, 98, 99, 100, 101, 102
1104};
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001105
Chris Lattner680aab62006-08-18 17:34:45 +00001106#if YYDEBUG != 0
1107static const short yyprhs[] = { 0,
1108 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
1109 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
1110 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
1111 60, 62, 64, 67, 68, 70, 72, 74, 76, 77,
1112 78, 80, 82, 84, 86, 89, 90, 93, 94, 98,
1113 101, 102, 104, 105, 109, 111, 114, 116, 118, 120,
1114 122, 124, 126, 128, 130, 132, 134, 136, 138, 140,
1115 142, 144, 146, 148, 150, 152, 154, 156, 159, 164,
1116 170, 176, 180, 183, 186, 188, 192, 194, 198, 200,
1117 201, 206, 210, 214, 219, 224, 228, 231, 234, 237,
1118 240, 243, 246, 249, 252, 255, 258, 265, 271, 280,
1119 287, 294, 301, 308, 315, 324, 333, 337, 339, 341,
1120 343, 345, 348, 351, 356, 359, 361, 366, 369, 374,
1121 375, 383, 384, 392, 396, 401, 402, 404, 406, 408,
1122 412, 416, 420, 424, 428, 430, 431, 433, 435, 437,
1123 438, 441, 445, 447, 449, 453, 455, 456, 465, 467,
1124 469, 473, 475, 477, 480, 481, 485, 486, 488, 490,
1125 492, 494, 496, 498, 500, 502, 504, 508, 510, 516,
1126 518, 520, 522, 524, 527, 530, 533, 537, 540, 541,
1127 543, 546, 549, 553, 563, 573, 582, 596, 598, 600,
1128 607, 613, 616, 623, 631, 633, 637, 639, 640, 643,
1129 645, 651, 657, 663, 666, 671, 676, 683, 688, 693,
1130 698, 703, 710, 717, 720, 728, 730, 733, 734, 736,
1131 737, 741, 748, 752, 759, 762, 767, 774
1132};
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001133
Chris Lattner680aab62006-08-18 17:34:45 +00001134static const short yyrhs[] = { 5,
1135 0, 6, 0, 3, 0, 4, 0, 72, 0, 73,
1136 0, 74, 0, 75, 0, 76, 0, 77, 0, 78,
1137 0, 79, 0, 80, 0, 81, 0, 82, 0, 83,
1138 0, 84, 0, 85, 0, 95, 0, 96, 0, 16,
1139 0, 14, 0, 12, 0, 10, 0, 17, 0, 15,
1140 0, 13, 0, 11, 0, 123, 0, 124, 0, 18,
1141 0, 19, 0, 157, 103, 0, 0, 41, 0, 42,
1142 0, 43, 0, 44, 0, 0, 0, 62, 0, 63,
1143 0, 64, 0, 65, 0, 61, 4, 0, 0, 54,
1144 4, 0, 0, 104, 54, 4, 0, 34, 24, 0,
1145 0, 132, 0, 0, 104, 135, 134, 0, 132, 0,
1146 54, 4, 0, 138, 0, 8, 0, 140, 0, 8,
1147 0, 140, 0, 9, 0, 10, 0, 11, 0, 12,
1148 0, 13, 0, 14, 0, 15, 0, 16, 0, 17,
1149 0, 18, 0, 19, 0, 20, 0, 21, 0, 45,
1150 0, 139, 0, 171, 0, 105, 4, 0, 137, 106,
1151 142, 107, 0, 108, 4, 109, 140, 110, 0, 111,
1152 4, 109, 140, 112, 0, 113, 141, 114, 0, 113,
1153 114, 0, 140, 115, 0, 140, 0, 141, 104, 140,
1154 0, 141, 0, 141, 104, 37, 0, 37, 0, 0,
1155 138, 108, 145, 110, 0, 138, 108, 110, 0, 138,
1156 116, 24, 0, 138, 111, 145, 112, 0, 138, 113,
1157 145, 114, 0, 138, 113, 114, 0, 138, 38, 0,
1158 138, 39, 0, 138, 171, 0, 138, 144, 0, 138,
1159 26, 0, 123, 118, 0, 124, 4, 0, 9, 27,
1160 0, 9, 28, 0, 126, 7, 0, 93, 106, 143,
1161 36, 138, 107, 0, 91, 106, 143, 185, 107, 0,
1162 94, 106, 143, 104, 143, 104, 143, 107, 0, 119,
1163 106, 143, 104, 143, 107, 0, 120, 106, 143, 104,
1164 143, 107, 0, 121, 106, 143, 104, 143, 107, 0,
1165 122, 106, 143, 104, 143, 107, 0, 98, 106, 143,
1166 104, 143, 107, 0, 99, 106, 143, 104, 143, 104,
1167 143, 107, 0, 100, 106, 143, 104, 143, 104, 143,
1168 107, 0, 145, 104, 143, 0, 143, 0, 32, 0,
1169 33, 0, 148, 0, 148, 166, 0, 148, 167, 0,
1170 148, 59, 58, 152, 0, 148, 25, 0, 149, 0,
1171 149, 127, 20, 136, 0, 149, 167, 0, 149, 59,
1172 58, 152, 0, 0, 149, 127, 128, 146, 143, 150,
1173 134, 0, 0, 149, 127, 47, 146, 138, 151, 134,
1174 0, 149, 48, 154, 0, 149, 55, 103, 155, 0,
1175 0, 24, 0, 53, 0, 52, 0, 50, 103, 153,
1176 0, 51, 103, 4, 0, 49, 103, 24, 0, 108,
1177 156, 110, 0, 156, 104, 24, 0, 24, 0, 0,
1178 22, 0, 24, 0, 157, 0, 0, 138, 158, 0,
1179 160, 104, 159, 0, 159, 0, 160, 0, 160, 104,
1180 37, 0, 37, 0, 0, 129, 136, 157, 106, 161,
1181 107, 133, 130, 0, 29, 0, 113, 0, 128, 162,
1182 163, 0, 30, 0, 114, 0, 174, 165, 0, 0,
1183 31, 168, 162, 0, 0, 60, 0, 3, 0, 4,
1184 0, 7, 0, 27, 0, 28, 0, 38, 0, 39,
1185 0, 26, 0, 111, 145, 112, 0, 144, 0, 58,
1186 169, 24, 104, 24, 0, 117, 0, 157, 0, 171,
1187 0, 170, 0, 138, 172, 0, 174, 175, 0, 164,
1188 175, 0, 176, 127, 177, 0, 176, 179, 0, 0,
1189 23, 0, 66, 173, 0, 66, 8, 0, 67, 21,
1190 172, 0, 67, 9, 172, 104, 21, 172, 104, 21,
1191 172, 0, 68, 125, 172, 104, 21, 172, 108, 178,
1192 110, 0, 68, 125, 172, 104, 21, 172, 108, 110,
1193 0, 69, 129, 136, 172, 106, 182, 107, 36, 21,
1194 172, 70, 21, 172, 0, 70, 0, 71, 0, 178,
1195 125, 170, 104, 21, 172, 0, 125, 170, 104, 21,
1196 172, 0, 127, 184, 0, 138, 108, 172, 104, 172,
1197 110, 0, 180, 104, 108, 172, 104, 172, 110, 0,
1198 173, 0, 181, 104, 173, 0, 181, 0, 0, 57,
1199 56, 0, 56, 0, 119, 138, 172, 104, 172, 0,
1200 120, 138, 172, 104, 172, 0, 121, 138, 172, 104,
1201 172, 0, 46, 173, 0, 122, 173, 104, 173, 0,
1202 93, 173, 36, 138, 0, 94, 173, 104, 173, 104,
1203 173, 0, 97, 173, 104, 138, 0, 101, 173, 104,
1204 138, 0, 102, 173, 104, 138, 0, 98, 173, 104,
1205 173, 0, 99, 173, 104, 173, 104, 173, 0, 100,
1206 173, 104, 173, 104, 173, 0, 92, 180, 0, 183,
1207 129, 136, 172, 106, 182, 107, 0, 187, 0, 104,
1208 181, 0, 0, 35, 0, 0, 86, 138, 131, 0,
1209 86, 138, 104, 15, 172, 131, 0, 87, 138, 131,
1210 0, 87, 138, 104, 15, 172, 131, 0, 88, 173,
1211 0, 186, 89, 138, 172, 0, 186, 90, 173, 104,
1212 138, 172, 0, 91, 138, 172, 185, 0
1213};
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001214
1215#endif
1216
Chris Lattner680aab62006-08-18 17:34:45 +00001217#if YYDEBUG != 0
1218static const short yyrline[] = { 0,
1219 1030, 1031, 1039, 1040, 1050, 1050, 1050, 1050, 1050, 1051,
1220 1051, 1051, 1052, 1052, 1052, 1052, 1052, 1052, 1054, 1054,
1221 1058, 1058, 1058, 1058, 1059, 1059, 1059, 1059, 1060, 1060,
1222 1061, 1061, 1064, 1068, 1073, 1073, 1074, 1075, 1076, 1079,
1223 1079, 1080, 1081, 1082, 1083, 1093, 1093, 1100, 1100, 1109,
1224 1117, 1117, 1123, 1123, 1125, 1130, 1144, 1144, 1145, 1145,
1225 1147, 1157, 1157, 1157, 1157, 1157, 1157, 1157, 1158, 1158,
1226 1158, 1158, 1158, 1158, 1159, 1163, 1167, 1174, 1182, 1195,
1227 1200, 1212, 1222, 1226, 1235, 1240, 1246, 1247, 1251, 1255,
1228 1266, 1292, 1306, 1336, 1362, 1383, 1396, 1406, 1411, 1471,
1229 1478, 1487, 1493, 1499, 1503, 1507, 1515, 1526, 1558, 1566,
1230 1588, 1599, 1605, 1613, 1619, 1625, 1634, 1638, 1646, 1646,
1231 1656, 1664, 1669, 1673, 1677, 1681, 1696, 1717, 1720, 1723,
1232 1726, 1730, 1734, 1738, 1741, 1744, 1748, 1761, 1762, 1764,
1233 1768, 1777, 1783, 1785, 1790, 1795, 1804, 1804, 1805, 1805,
1234 1807, 1814, 1820, 1827, 1831, 1837, 1842, 1847, 1934, 1934,
1235 1936, 1944, 1944, 1946, 1951, 1951, 1961, 1965, 1970, 1974,
1236 1978, 1982, 1986, 1990, 1994, 1998, 2002, 2027, 2031, 2045,
1237 2049, 2055, 2055, 2061, 2066, 2070, 2079, 2089, 2094, 2105,
1238 2117, 2121, 2125, 2129, 2133, 2148, 2153, 2207, 2211, 2218,
1239 2227, 2238, 2246, 2252, 2260, 2265, 2272, 2272, 2274, 2278,
1240 2285, 2298, 2310, 2321, 2334, 2342, 2350, 2358, 2364, 2384,
1241 2407, 2413, 2419, 2425, 2440, 2498, 2505, 2508, 2513, 2517,
1242 2524, 2529, 2534, 2539, 2544, 2552, 2563, 2577
1243};
1244#endif
1245
1246
1247#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
1248
1249static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL",
1250"EUINT64VAL","SINTVAL","UINTVAL","FPVAL","VOID","BOOL","SBYTE","UBYTE","SHORT",
1251"USHORT","INT","UINT","LONG","ULONG","FLOAT","DOUBLE","TYPE","LABEL","VAR_ID",
1252"LABELSTR","STRINGCONSTANT","IMPLEMENTATION","ZEROINITIALIZER","TRUETOK","FALSETOK",
1253"BEGINTOK","ENDTOK","DECLARE","GLOBAL","CONSTANT","SECTION","VOLATILE","TO",
1254"DOTDOTDOT","NULL_TOK","UNDEF","CONST","INTERNAL","LINKONCE","WEAK","APPENDING",
1255"OPAQUE","NOT","EXTERNAL","TARGET","TRIPLE","ENDIAN","POINTERSIZE","LITTLE",
1256"BIG","ALIGN","DEPLIBS","CALL","TAIL","ASM_TOK","MODULE","SIDEEFFECT","CC_TOK",
1257"CCC_TOK","CSRETCC_TOK","FASTCC_TOK","COLDCC_TOK","RET","BR","SWITCH","INVOKE",
1258"UNWIND","UNREACHABLE","ADD","SUB","MUL","DIV","REM","AND","OR","XOR","SETLE",
1259"SETGE","SETLT","SETGT","SETEQ","SETNE","MALLOC","ALLOCA","FREE","LOAD","STORE",
1260"GETELEMENTPTR","PHI_TOK","CAST","SELECT","SHL","SHR","VAARG","EXTRACTELEMENT",
1261"INSERTELEMENT","SHUFFLEVECTOR","VAARG_old","VANEXT_old","'='","','","'\\\\'",
1262"'('","')'","'['","'x'","']'","'<'","'>'","'{'","'}'","'*'","'c'","INTVAL","EINT64VAL",
1263"ArithmeticOps","LogicalOps","SetCondOps","ShiftOps","SIntType","UIntType","IntType",
1264"FPType","OptAssign","OptLinkage","OptCallingConv","OptAlign","OptCAlign","SectionString",
1265"OptSection","GlobalVarAttributes","GlobalVarAttribute","TypesV","UpRTypesV",
1266"Types","PrimType","UpRTypes","TypeListI","ArgTypeListI","ConstVal","ConstExpr",
1267"ConstVector","GlobalType","Module","FunctionList","ConstPool","@1","@2","AsmBlock",
1268"BigOrLittle","TargetDefinition","LibrariesDefinition","LibList","Name","OptName",
1269"ArgVal","ArgListH","ArgList","FunctionHeaderH","BEGIN","FunctionHeader","END",
1270"Function","FunctionProto","@3","OptSideEffect","ConstValueRef","SymbolicValueRef",
1271"ValueRef","ResolvedVal","BasicBlockList","BasicBlock","InstructionList","BBTerminatorInst",
1272"JumpTable","Inst","PHIList","ValueRefList","ValueRefListE","OptTailCall","InstVal",
1273"IndexList","OptVolatile","MemoryInst", NULL
1274};
1275#endif
1276
1277static const short yyr1[] = { 0,
1278 117, 117, 118, 118, 119, 119, 119, 119, 119, 120,
1279 120, 120, 121, 121, 121, 121, 121, 121, 122, 122,
1280 123, 123, 123, 123, 124, 124, 124, 124, 125, 125,
1281 126, 126, 127, 127, 128, 128, 128, 128, 128, 129,
1282 129, 129, 129, 129, 129, 130, 130, 131, 131, 132,
1283 133, 133, 134, 134, 135, 135, 136, 136, 137, 137,
1284 138, 139, 139, 139, 139, 139, 139, 139, 139, 139,
1285 139, 139, 139, 139, 140, 140, 140, 140, 140, 140,
1286 140, 140, 140, 140, 141, 141, 142, 142, 142, 142,
1287 143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
1288 143, 143, 143, 143, 143, 143, 144, 144, 144, 144,
1289 144, 144, 144, 144, 144, 144, 145, 145, 146, 146,
1290 147, 148, 148, 148, 148, 148, 149, 149, 149, 150,
1291 149, 151, 149, 149, 149, 149, 152, 153, 153, 154,
1292 154, 154, 155, 156, 156, 156, 157, 157, 158, 158,
1293 159, 160, 160, 161, 161, 161, 161, 162, 163, 163,
1294 164, 165, 165, 166, 168, 167, 169, 169, 170, 170,
1295 170, 170, 170, 170, 170, 170, 170, 170, 170, 171,
1296 171, 172, 172, 173, 174, 174, 175, 176, 176, 176,
1297 177, 177, 177, 177, 177, 177, 177, 177, 177, 178,
1298 178, 179, 180, 180, 181, 181, 182, 182, 183, 183,
1299 184, 184, 184, 184, 184, 184, 184, 184, 184, 184,
1300 184, 184, 184, 184, 184, 184, 185, 185, 186, 186,
1301 187, 187, 187, 187, 187, 187, 187, 187
1302};
1303
1304static const short yyr2[] = { 0,
1305 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1306 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1307 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1308 1, 1, 2, 0, 1, 1, 1, 1, 0, 0,
1309 1, 1, 1, 1, 2, 0, 2, 0, 3, 2,
1310 0, 1, 0, 3, 1, 2, 1, 1, 1, 1,
1311 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1312 1, 1, 1, 1, 1, 1, 1, 2, 4, 5,
1313 5, 3, 2, 2, 1, 3, 1, 3, 1, 0,
1314 4, 3, 3, 4, 4, 3, 2, 2, 2, 2,
1315 2, 2, 2, 2, 2, 2, 6, 5, 8, 6,
1316 6, 6, 6, 6, 8, 8, 3, 1, 1, 1,
1317 1, 2, 2, 4, 2, 1, 4, 2, 4, 0,
1318 7, 0, 7, 3, 4, 0, 1, 1, 1, 3,
1319 3, 3, 3, 3, 1, 0, 1, 1, 1, 0,
1320 2, 3, 1, 1, 3, 1, 0, 8, 1, 1,
1321 3, 1, 1, 2, 0, 3, 0, 1, 1, 1,
1322 1, 1, 1, 1, 1, 1, 3, 1, 5, 1,
1323 1, 1, 1, 2, 2, 2, 3, 2, 0, 1,
1324 2, 2, 3, 9, 9, 8, 13, 1, 1, 6,
1325 5, 2, 6, 7, 1, 3, 1, 0, 2, 1,
1326 5, 5, 5, 2, 4, 4, 6, 4, 4, 4,
1327 4, 6, 6, 2, 7, 1, 2, 0, 1, 0,
1328 3, 6, 3, 6, 2, 4, 6, 4
1329};
1330
1331static const short yydefact[] = { 136,
1332 39, 126, 125, 165, 35, 36, 37, 38, 0, 40,
1333 189, 122, 123, 189, 147, 148, 0, 0, 0, 39,
1334 0, 128, 40, 0, 0, 41, 42, 43, 44, 0,
1335 0, 190, 186, 34, 162, 163, 164, 185, 0, 0,
1336 0, 134, 0, 0, 0, 0, 0, 33, 166, 137,
1337 124, 45, 1, 2, 58, 62, 63, 64, 65, 66,
1338 67, 68, 69, 70, 71, 72, 73, 74, 75, 0,
1339 0, 0, 0, 180, 0, 0, 57, 76, 61, 181,
1340 77, 159, 160, 161, 230, 188, 0, 0, 0, 146,
1341 135, 129, 127, 119, 120, 0, 0, 78, 0, 0,
1342 60, 83, 85, 0, 0, 90, 84, 229, 0, 210,
1343 0, 0, 0, 0, 40, 198, 199, 5, 6, 7,
1344 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
1345 18, 0, 0, 0, 0, 0, 0, 0, 19, 20,
1346 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1347 187, 40, 202, 0, 226, 142, 139, 138, 140, 141,
1348 145, 0, 132, 62, 63, 64, 65, 66, 67, 68,
1349 69, 70, 71, 72, 0, 0, 0, 0, 130, 0,
1350 0, 0, 82, 157, 89, 87, 0, 0, 214, 209,
1351 192, 191, 0, 0, 24, 28, 23, 27, 22, 26,
1352 21, 25, 29, 30, 0, 0, 48, 48, 235, 0,
1353 0, 224, 0, 0, 0, 0, 0, 0, 0, 0,
1354 0, 0, 0, 0, 0, 0, 0, 0, 143, 53,
1355 104, 105, 3, 4, 102, 103, 106, 101, 97, 98,
1356 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1357 0, 0, 0, 0, 100, 99, 53, 59, 59, 86,
1358 156, 150, 153, 154, 0, 0, 79, 169, 170, 171,
1359 176, 172, 173, 174, 175, 167, 0, 178, 183, 182,
1360 184, 0, 193, 0, 0, 0, 231, 0, 233, 228,
1361 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1362 0, 0, 0, 0, 0, 0, 0, 144, 0, 133,
1363 0, 0, 0, 0, 0, 0, 92, 118, 0, 0,
1364 96, 0, 93, 0, 0, 0, 0, 131, 80, 81,
1365 149, 151, 0, 51, 88, 168, 0, 0, 0, 0,
1366 0, 0, 0, 0, 0, 238, 0, 0, 216, 0,
1367 218, 221, 0, 0, 219, 220, 0, 0, 0, 215,
1368 0, 236, 0, 0, 0, 55, 53, 228, 0, 0,
1369 0, 0, 0, 0, 91, 94, 95, 0, 0, 0,
1370 0, 155, 152, 52, 46, 0, 177, 0, 0, 208,
1371 48, 49, 48, 205, 227, 0, 0, 0, 0, 0,
1372 211, 212, 213, 208, 0, 50, 56, 54, 0, 0,
1373 0, 0, 0, 0, 117, 0, 0, 0, 0, 0,
1374 158, 0, 0, 0, 207, 0, 0, 232, 234, 0,
1375 0, 0, 217, 222, 223, 0, 237, 108, 0, 0,
1376 0, 0, 0, 0, 0, 0, 0, 47, 179, 0,
1377 0, 0, 206, 203, 0, 225, 107, 0, 114, 0,
1378 0, 110, 111, 112, 113, 0, 196, 0, 0, 0,
1379 204, 0, 0, 0, 194, 0, 195, 0, 0, 109,
1380 115, 116, 0, 0, 0, 0, 0, 0, 201, 0,
1381 0, 200, 197, 0, 0, 0
1382};
1383
1384static const short yydefgoto[] = { 74,
1385 235, 251, 252, 253, 254, 175, 176, 205, 177, 20,
1386 10, 30, 421, 287, 366, 385, 310, 367, 75, 76,
1387 178, 78, 79, 104, 187, 318, 278, 319, 96, 494,
1388 1, 2, 257, 230, 51, 159, 42, 91, 162, 80,
1389 332, 263, 264, 265, 31, 84, 11, 37, 12, 13,
1390 23, 337, 279, 81, 281, 394, 14, 33, 34, 151,
1391 469, 86, 212, 425, 426, 152, 153, 346, 154, 155
1392};
1393
1394static const short yypact[] = {-32768,
1395 181, 372,-32768,-32768,-32768,-32768,-32768,-32768, -32, 94,
1396 38,-32768,-32768, -14,-32768,-32768, 45, -40, 18, 44,
1397 -25,-32768, 94, 57, 79,-32768,-32768,-32768,-32768, 1012,
1398 -21,-32768,-32768, 22,-32768,-32768,-32768,-32768, -6, -4,
1399 27,-32768, 26, 57, 1012, 77, 77,-32768,-32768,-32768,
1400-32768,-32768,-32768,-32768, 46,-32768,-32768,-32768,-32768,-32768,
1401-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 167,
1402 170, 171, 524,-32768, 22, 71,-32768,-32768, -17,-32768,
1403-32768,-32768,-32768,-32768, 1176,-32768, 154, 76, 175, 156,
1404-32768,-32768,-32768,-32768,-32768, 1050, 1088,-32768, 73, 74,
1405-32768,-32768, -17, -83, 78, 819,-32768,-32768, 1050,-32768,
1406 129, 1126, 56, 128, 94,-32768,-32768,-32768,-32768,-32768,
1407-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1408-32768, 1050, 1050, 1050, 1050, 1050, 1050, 1050,-32768,-32768,
1409 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050,
1410-32768, 94,-32768, 43,-32768,-32768,-32768,-32768,-32768,-32768,
1411-32768, -82,-32768, 119, 146, 183, 157, 190, 159, 194,
1412 166, 196, 195, 197, 169, 199, 198, 406,-32768, 1050,
1413 1050, 1050,-32768, 857,-32768, 97, 100, 617,-32768,-32768,
1414 46,-32768, 617, 617,-32768,-32768,-32768,-32768,-32768,-32768,
1415-32768,-32768,-32768,-32768, 617, 1012, 104, 105,-32768, 617,
1416 103, 109, 178, 111, 122, 123, 131, 132, 133, 134,
1417 617, 617, 617, 135, 1012, 1050, 1050, 209,-32768, 137,
1418-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1419 136, 138, 139, 140, 141, 144, 895, 1088, 566, 219,
1420 145, 147, 148, 149,-32768,-32768, 137, -48, -88, -17,
1421-32768, 22,-32768, 152, 150, 936,-32768,-32768,-32768,-32768,
1422-32768,-32768,-32768,-32768,-32768, 192, 1088,-32768,-32768,-32768,
1423-32768, 155,-32768, 158, 617, -5,-32768, 5,-32768, 172,
1424 617, 153, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1050,
1425 173, 174, 176, 1050, 617, 617, 177,-32768, -20,-32768,
1426 1088, 1088, 1088, 1088, 1088, 1088,-32768,-32768, -62, -11,
1427-32768, -79,-32768, 1088, 1088, 1088, 1088,-32768,-32768,-32768,
1428-32768,-32768, 974, 224,-32768,-32768, 236, 23, 251, 252,
1429 180, 617, 271, 617, 1050,-32768, 179, 617,-32768, 184,
1430-32768,-32768, 185, 186,-32768,-32768, 617, 617, 617,-32768,
1431 191,-32768, 1050, 258, 280,-32768, 137, 172, 256, 200,
1432 201, 202, 203, 1088,-32768,-32768,-32768, 204, 205, 206,
1433 207,-32768,-32768,-32768, 242, 208,-32768, 617, 617, 1050,
1434 210,-32768, 210,-32768, 216, 617, 222, 1050, 1050, 1050,
1435-32768,-32768,-32768, 1050, 617,-32768,-32768,-32768, 220, 1050,
1436 1088, 1088, 1088, 1088,-32768, 1088, 1088, 1088, 1088, 294,
1437-32768, 275, 225, 226, 216, 221, 259,-32768,-32768, 1050,
1438 227, 617,-32768,-32768,-32768, 223,-32768,-32768, 228, 232,
1439 234, 238, 239, 237, 240, 243, 244,-32768,-32768, 324,
1440 41, 310,-32768,-32768, 245,-32768,-32768, 1088,-32768, 1088,
1441 1088,-32768,-32768,-32768,-32768, 617,-32768, 715, 58, 328,
1442-32768, 246, 247, 250,-32768, 248,-32768, 715, 617,-32768,
1443-32768,-32768, 338, 260, 297, 617, 350, 351,-32768, 617,
1444 617,-32768,-32768, 376, 377,-32768
1445};
1446
1447static const short yypgoto[] = {-32768,
1448-32768, 296, 298, 299, 300, -113, -111, -439,-32768, 345,
1449 362, -92,-32768, -203, 52,-32768, -244,-32768, -39,-32768,
1450 -30,-32768, -56, 281,-32768, -95, 215, -230, 341,-32768,
1451-32768,-32768,-32768,-32768, 353,-32768,-32768,-32768,-32768, 9,
1452-32768, 62,-32768,-32768, 375,-32768,-32768,-32768,-32768, 397,
1453-32768,-32768, -388, -57, 168, -105,-32768, 387,-32768,-32768,
1454-32768,-32768,-32768, 61, -2,-32768,-32768, 39,-32768,-32768
1455};
1456
1457
1458#define YYLAST 1278
1459
1460
1461static const short yytable[] = { 77,
1462 203, 179, 204, 189, 289, 93, 192, 82, 32, 342,
1463 21, 468, 328, 364, 77, 35, 103, 320, 322, 344,
1464 182, 228, 206, 330, 374, 24, 107, 229, 209, 478,
1465 183, 213, 214, 365, 377, 215, 216, 217, 218, 219,
1466 220, 374, 21, 15, 224, 16, 338, 375, 343, 103,
1467 195, 196, 197, 198, 199, 200, 201, 202, 343, 225,
1468 32, 329, 43, 45, 193, 163, 107, 195, 196, 197,
1469 198, 199, 200, 201, 202, 44, 194, 48, 188, 476,
1470 50, 188, 52, 105, 5, 6, 7, 8, -59, 484,
1471 46, 83, 374, 39, 40, 41, 87, 107, 88, 36,
1472 376, 207, 208, 188, 210, 211, 188, 188, 94, 95,
1473 188, 188, 188, 188, 188, 188, 221, 222, 223, 188,
1474 256, 307, 408, 258, 259, 260, 374, 157, 158, 89,
1475 280, 226, 227, 90, 387, 280, 280, 195, 196, 197,
1476 198, 199, 200, 201, 202, 231, 232, 280, -24, -24,
1477 467, -60, 280, 262, 25, 26, 27, 28, 29, -23,
1478 -23, -22, -22, 280, 280, 280, 285, 477, -21, -21,
1479 98, 233, 234, 99, 100, 77, 106, 156, 160, 161,
1480 -121, 180, 181, 184, 190, 305, -28, 428, 350, 429,
1481 352, 353, 354, -27, 77, 306, 188, -26, 360, -25,
1482 266, -31, 236, -32, 237, 3, 267, 286, 288, 260,
1483 291, 4, 292, 293, 294, 368, 369, 370, 371, 372,
1484 373, 5, 6, 7, 8, 295, 296, 280, 378, 379,
1485 380, 381, 308, 280, 297, 298, 299, 300, 304, 9,
1486 309, 311, 323, 312, 313, 314, 315, 280, 280, 316,
1487 324, 336, 325, 326, 327, 333, 334, 364, 339, 386,
1488 348, 340, 349, 188, 351, 188, 188, 188, 355, 356,
1489 331, 388, 389, 188, 392, 345, 357, 358, 415, 359,
1490 363, 406, 396, 407, 280, 390, 280, 398, 399, 400,
1491 280, 410, 433, 434, 435, 420, 404, 448, 449, 280,
1492 280, 280, 262, 411, 412, 413, 414, 416, 417, 418,
1493 419, 422, 343, 427, 188, 440, 441, 442, 443, 430,
1494 444, 445, 446, 447, 453, 432, 438, 452, 450, 456,
1495 280, 280, 405, 451, 457, 458, 454, 203, 280, 204,
1496 459, 460, 461, 462, 466, 470, 463, 280, 479, 464,
1497 465, 483, 480, 481, 471, 203, 482, 204, 486, 188,
1498 282, 283, 472, 487, 473, 474, 488, 188, 188, 188,
1499 490, 491, 284, 188, 280, 495, 496, 290, 85, 439,
1500 147, 47, 148, 149, 150, 384, 186, 97, 301, 302,
1501 303, -34, 255, 15, 383, 16, 92, 49, 22, 188,
1502 38, 436, 4, -34, -34, 395, 409, 0, 280, 0,
1503 53, 54, -34, -34, -34, -34, 0, 0, -34, 17,
1504 0, 280, 0, 0, 0, 0, 18, 15, 280, 16,
1505 19, 238, 280, 280, 0, 0, 0, 0, 0, 0,
1506 0, 0, 0, 239, 240, 0, 0, 0, 0, 0,
1507 0, 0, 341, 0, 0, 0, 0, 0, 347, 0,
1508 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1509 0, 0, 361, 362, 0, 0, 0, 118, 119, 120,
1510 121, 122, 123, 124, 125, 126, 127, 128, 129, 130,
1511 131, 0, 0, 0, 0, 0, 241, 0, 242, 243,
1512 139, 140, 0, 244, 245, 246, 0, 0, 0, 391,
1513 0, 393, 0, 247, 0, 397, 248, 0, 249, 0,
1514 0, 250, 0, 0, 401, 402, 403, 0, 53, 54,
1515 0, 101, 56, 57, 58, 59, 60, 61, 62, 63,
1516 64, 65, 66, 67, 68, 15, 0, 16, 0, 0,
1517 0, 0, 0, 0, 0, 423, 424, 0, 0, 0,
1518 0, 0, 0, 431, 0, 0, 0, 0, 69, 0,
1519 53, 54, 437, 101, 164, 165, 166, 167, 168, 169,
1520 170, 171, 172, 173, 174, 67, 68, 15, 0, 16,
1521 0, 0, 0, 0, 0, 0, 0, 0, 0, 455,
1522 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1523 69, 0, 0, 0, 0, 0, 0, 0, 0, 268,
1524 269, 53, 54, 270, 0, 0, 0, 0, 70, 0,
1525 0, 71, 0, 475, 72, 0, 73, 102, 15, 0,
1526 16, 0, 271, 272, 273, 0, 485, 0, 0, 0,
1527 0, 0, 0, 489, 274, 275, 0, 492, 493, 0,
1528 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1529 70, 0, 0, 71, 276, 0, 72, 0, 73, 321,
1530 0, 0, 0, 0, 0, 0, 0, 0, 118, 119,
1531 120, 121, 122, 123, 124, 125, 126, 127, 128, 129,
1532 130, 131, 0, 0, 0, 0, 0, 241, 0, 242,
1533 243, 139, 140, 0, 244, 245, 246, 268, 269, 0,
1534 0, 270, 0, 0, 0, 0, 0, 277, 0, 0,
1535 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1536 271, 272, 273, 0, 0, 0, 0, 0, 0, 0,
1537 0, 0, 274, 275, 0, 0, 0, 0, 0, 0,
1538 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1539 0, 0, 276, 0, 0, 0, 0, 0, 0, 0,
1540 0, 0, 0, 0, 0, 0, 118, 119, 120, 121,
1541 122, 123, 124, 125, 126, 127, 128, 129, 130, 131,
1542 0, 0, 0, 0, 0, 241, 0, 242, 243, 139,
1543 140, 0, 244, 245, 246, 0, 0, 0, 0, 0,
1544 0, 0, 0, 53, 54, 277, 101, 56, 57, 58,
1545 59, 60, 61, 62, 63, 64, 65, 66, 67, 68,
1546 15, 0, 16, 0, 0, 0, 0, 0, 0, 0,
1547 0, 0, 0, 0, 0, 185, 0, 0, 0, 0,
1548 0, 53, 54, 69, 101, 56, 57, 58, 59, 60,
1549 61, 62, 63, 64, 65, 66, 67, 68, 15, 0,
1550 16, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1551 0, 0, 0, 261, 0, 0, 0, 0, 0, 53,
1552 54, 69, 101, 164, 165, 166, 167, 168, 169, 170,
1553 171, 172, 173, 174, 67, 68, 15, 0, 16, 0,
1554 0, 0, 0, 70, 0, 0, 71, 0, 0, 72,
1555 0, 73, 0, 0, 0, 0, 0, 0, 0, 69,
1556 53, 54, 0, 101, 56, 57, 58, 59, 60, 61,
1557 62, 63, 64, 65, 66, 67, 68, 15, 0, 16,
1558 0, 70, 0, 0, 71, 0, 0, 72, 0, 73,
1559 0, 0, 335, 0, 0, 0, 0, 0, 53, 54,
1560 69, 101, 56, 57, 58, 59, 60, 61, 62, 63,
1561 64, 65, 66, 67, 68, 15, 0, 16, 0, 70,
1562 0, 0, 71, 0, 317, 72, 0, 73, 0, 0,
1563 382, 0, 0, 0, 0, 0, 53, 54, 69, 55,
1564 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
1565 66, 67, 68, 15, 0, 16, 0, 0, 0, 0,
1566 70, 0, 0, 71, 0, 0, 72, 0, 73, 0,
1567 0, 0, 0, 0, 53, 54, 69, 101, 56, 57,
1568 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
1569 68, 15, 0, 16, 0, 0, 0, 0, 70, 0,
1570 0, 71, 0, 0, 72, 0, 73, 0, 0, 0,
1571 0, 0, 53, 54, 69, 101, 164, 165, 166, 167,
1572 168, 169, 170, 171, 172, 173, 174, 67, 68, 15,
1573 0, 16, 0, 0, 0, 0, 70, 0, 0, 71,
1574 0, 0, 72, 0, 73, 0, 0, 0, 0, 0,
1575 53, 54, 69, 191, 56, 57, 58, 59, 60, 61,
1576 62, 63, 64, 65, 66, 67, 68, 15, 0, 16,
1577 0, 0, 0, 0, 70, 0, 0, 71, 0, 0,
1578 72, 0, 73, 0, 0, 0, 0, 0, 0, 0,
1579 69, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1580 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1581 0, 0, 70, 0, 0, 71, 0, 0, 72, 0,
1582 73, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1583 108, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1584 0, 109, 0, 0, 0, 0, 0, 0, 0, 0,
1585 70, 110, 111, 71, 0, 0, 72, 0, 73, 0,
1586 0, 112, 113, 114, 115, 116, 117, 118, 119, 120,
1587 121, 122, 123, 124, 125, 126, 127, 128, 129, 130,
1588 131, 132, 133, 134, 0, 0, 135, 136, 137, 138,
1589 139, 140, 141, 142, 143, 144, 145, 146
1590};
1591
1592static const short yycheck[] = { 30,
1593 114, 97, 114, 109, 208, 45, 112, 29, 23, 15,
1594 2, 451, 257, 34, 45, 30, 73, 248, 249, 15,
1595 104, 104, 115, 112, 104, 58, 115, 110, 134, 469,
1596 114, 137, 138, 54, 114, 141, 142, 143, 144, 145,
1597 146, 104, 34, 22, 150, 24, 277, 110, 54, 106,
1598 10, 11, 12, 13, 14, 15, 16, 17, 54, 152,
1599 23, 110, 103, 20, 9, 96, 115, 10, 11, 12,
1600 13, 14, 15, 16, 17, 58, 21, 103, 109, 468,
1601 24, 112, 4, 75, 41, 42, 43, 44, 106, 478,
1602 47, 113, 104, 49, 50, 51, 103, 115, 103, 114,
1603 112, 132, 133, 134, 135, 136, 137, 138, 32, 33,
1604 141, 142, 143, 144, 145, 146, 147, 148, 149, 150,
1605 178, 227, 367, 180, 181, 182, 104, 52, 53, 103,
1606 188, 89, 90, 108, 112, 193, 194, 10, 11, 12,
1607 13, 14, 15, 16, 17, 27, 28, 205, 3, 4,
1608 110, 106, 210, 184, 61, 62, 63, 64, 65, 3,
1609 4, 3, 4, 221, 222, 223, 206, 110, 3, 4,
1610 4, 3, 4, 4, 4, 206, 106, 24, 4, 24,
1611 0, 109, 109, 106, 56, 225, 4, 391, 294, 393,
1612 296, 297, 298, 4, 225, 226, 227, 4, 304, 4,
1613 104, 7, 4, 7, 7, 25, 107, 104, 104, 266,
1614 108, 31, 104, 36, 104, 311, 312, 313, 314, 315,
1615 316, 41, 42, 43, 44, 104, 104, 285, 324, 325,
1616 326, 327, 24, 291, 104, 104, 104, 104, 104, 59,
1617 104, 106, 24, 106, 106, 106, 106, 305, 306, 106,
1618 106, 60, 106, 106, 106, 104, 107, 34, 104, 24,
1619 108, 104, 293, 294, 295, 296, 297, 298, 299, 300,
1620 262, 21, 21, 304, 4, 104, 104, 104, 374, 104,
1621 104, 24, 104, 4, 342, 106, 344, 104, 104, 104,
1622 348, 36, 398, 399, 400, 54, 106, 4, 24, 357,
1623 358, 359, 333, 104, 104, 104, 104, 104, 104, 104,
1624 104, 104, 54, 104, 345, 411, 412, 413, 414, 104,
1625 416, 417, 418, 419, 430, 104, 107, 107, 104, 107,
1626 388, 389, 363, 108, 107, 104, 110, 451, 396, 451,
1627 107, 104, 104, 107, 21, 36, 107, 405, 21, 107,
1628 107, 104, 107, 107, 110, 469, 107, 469, 21, 390,
1629 193, 194, 458, 104, 460, 461, 70, 398, 399, 400,
1630 21, 21, 205, 404, 432, 0, 0, 210, 34, 410,
1631 85, 20, 85, 85, 85, 334, 106, 47, 221, 222,
1632 223, 20, 178, 22, 333, 24, 44, 23, 2, 430,
1633 14, 404, 31, 32, 33, 345, 368, -1, 466, -1,
1634 5, 6, 41, 42, 43, 44, -1, -1, 47, 48,
1635 -1, 479, -1, -1, -1, -1, 55, 22, 486, 24,
1636 59, 26, 490, 491, -1, -1, -1, -1, -1, -1,
1637 -1, -1, -1, 38, 39, -1, -1, -1, -1, -1,
1638 -1, -1, 285, -1, -1, -1, -1, -1, 291, -1,
1639 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1640 -1, -1, 305, 306, -1, -1, -1, 72, 73, 74,
1641 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1642 85, -1, -1, -1, -1, -1, 91, -1, 93, 94,
1643 95, 96, -1, 98, 99, 100, -1, -1, -1, 342,
1644 -1, 344, -1, 108, -1, 348, 111, -1, 113, -1,
1645 -1, 116, -1, -1, 357, 358, 359, -1, 5, 6,
1646 -1, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1647 17, 18, 19, 20, 21, 22, -1, 24, -1, -1,
1648 -1, -1, -1, -1, -1, 388, 389, -1, -1, -1,
1649 -1, -1, -1, 396, -1, -1, -1, -1, 45, -1,
1650 5, 6, 405, 8, 9, 10, 11, 12, 13, 14,
1651 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
1652 -1, -1, -1, -1, -1, -1, -1, -1, -1, 432,
1653 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1654 45, -1, -1, -1, -1, -1, -1, -1, -1, 3,
1655 4, 5, 6, 7, -1, -1, -1, -1, 105, -1,
1656 -1, 108, -1, 466, 111, -1, 113, 114, 22, -1,
1657 24, -1, 26, 27, 28, -1, 479, -1, -1, -1,
1658 -1, -1, -1, 486, 38, 39, -1, 490, 491, -1,
1659 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1660 105, -1, -1, 108, 58, -1, 111, -1, 113, 114,
1661 -1, -1, -1, -1, -1, -1, -1, -1, 72, 73,
1662 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
1663 84, 85, -1, -1, -1, -1, -1, 91, -1, 93,
1664 94, 95, 96, -1, 98, 99, 100, 3, 4, -1,
1665 -1, 7, -1, -1, -1, -1, -1, 111, -1, -1,
1666 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1667 26, 27, 28, -1, -1, -1, -1, -1, -1, -1,
1668 -1, -1, 38, 39, -1, -1, -1, -1, -1, -1,
1669 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1670 -1, -1, 58, -1, -1, -1, -1, -1, -1, -1,
1671 -1, -1, -1, -1, -1, -1, 72, 73, 74, 75,
1672 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
1673 -1, -1, -1, -1, -1, 91, -1, 93, 94, 95,
1674 96, -1, 98, 99, 100, -1, -1, -1, -1, -1,
1675 -1, -1, -1, 5, 6, 111, 8, 9, 10, 11,
1676 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
1677 22, -1, 24, -1, -1, -1, -1, -1, -1, -1,
1678 -1, -1, -1, -1, -1, 37, -1, -1, -1, -1,
1679 -1, 5, 6, 45, 8, 9, 10, 11, 12, 13,
1680 14, 15, 16, 17, 18, 19, 20, 21, 22, -1,
1681 24, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1682 -1, -1, -1, 37, -1, -1, -1, -1, -1, 5,
1683 6, 45, 8, 9, 10, 11, 12, 13, 14, 15,
1684 16, 17, 18, 19, 20, 21, 22, -1, 24, -1,
1685 -1, -1, -1, 105, -1, -1, 108, -1, -1, 111,
1686 -1, 113, -1, -1, -1, -1, -1, -1, -1, 45,
1687 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
1688 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
1689 -1, 105, -1, -1, 108, -1, -1, 111, -1, 113,
1690 -1, -1, 37, -1, -1, -1, -1, -1, 5, 6,
1691 45, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1692 17, 18, 19, 20, 21, 22, -1, 24, -1, 105,
1693 -1, -1, 108, -1, 110, 111, -1, 113, -1, -1,
1694 37, -1, -1, -1, -1, -1, 5, 6, 45, 8,
1695 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
1696 19, 20, 21, 22, -1, 24, -1, -1, -1, -1,
1697 105, -1, -1, 108, -1, -1, 111, -1, 113, -1,
1698 -1, -1, -1, -1, 5, 6, 45, 8, 9, 10,
1699 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
1700 21, 22, -1, 24, -1, -1, -1, -1, 105, -1,
1701 -1, 108, -1, -1, 111, -1, 113, -1, -1, -1,
1702 -1, -1, 5, 6, 45, 8, 9, 10, 11, 12,
1703 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
1704 -1, 24, -1, -1, -1, -1, 105, -1, -1, 108,
1705 -1, -1, 111, -1, 113, -1, -1, -1, -1, -1,
1706 5, 6, 45, 8, 9, 10, 11, 12, 13, 14,
1707 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
1708 -1, -1, -1, -1, 105, -1, -1, 108, -1, -1,
1709 111, -1, 113, -1, -1, -1, -1, -1, -1, -1,
1710 45, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1711 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1712 -1, -1, 105, -1, -1, 108, -1, -1, 111, -1,
1713 113, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1714 35, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1715 -1, 46, -1, -1, -1, -1, -1, -1, -1, -1,
1716 105, 56, 57, 108, -1, -1, 111, -1, 113, -1,
1717 -1, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1718 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1719 85, 86, 87, 88, -1, -1, 91, 92, 93, 94,
1720 95, 96, 97, 98, 99, 100, 101, 102
1721};
1722/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
1723#line 3 "/usr/share/bison.simple"
1724/* This file comes from bison-1.28. */
1725
1726/* Skeleton output parser for bison,
1727 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
1728
1729 This program is free software; you can redistribute it and/or modify
1730 it under the terms of the GNU General Public License as published by
1731 the Free Software Foundation; either version 2, or (at your option)
1732 any later version.
1733
1734 This program is distributed in the hope that it will be useful,
1735 but WITHOUT ANY WARRANTY; without even the implied warranty of
1736 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1737 GNU General Public License for more details.
1738
1739 You should have received a copy of the GNU General Public License
1740 along with this program; if not, write to the Free Software
1741 Foundation, Inc., 59 Temple Place - Suite 330,
1742 Boston, MA 02111-1307, USA. */
1743
1744/* As a special exception, when this file is copied by Bison into a
1745 Bison output file, you may use that output file without restriction.
1746 This special exception was added by the Free Software Foundation
1747 in version 1.24 of Bison. */
1748
1749/* This is the parser code that is written into each bison parser
1750 when the %semantic_parser declaration is not specified in the grammar.
1751 It was written by Richard Stallman by simplifying the hairy parser
1752 used when %semantic_parser is specified. */
1753
1754#ifndef YYSTACK_USE_ALLOCA
1755#ifdef alloca
1756#define YYSTACK_USE_ALLOCA
1757#else /* alloca not defined */
1758#ifdef __GNUC__
1759#define YYSTACK_USE_ALLOCA
1760#define alloca __builtin_alloca
1761#else /* not GNU C. */
1762#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
1763#define YYSTACK_USE_ALLOCA
1764#include <alloca.h>
1765#else /* not sparc */
1766/* We think this test detects Watcom and Microsoft C. */
1767/* This used to test MSDOS, but that is a bad idea
1768 since that symbol is in the user namespace. */
1769#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
1770#if 0 /* No need for malloc.h, which pollutes the namespace;
1771 instead, just don't use alloca. */
1772#include <malloc.h>
1773#endif
1774#else /* not MSDOS, or __TURBOC__ */
1775#if defined(_AIX)
1776/* I don't know what this was needed for, but it pollutes the namespace.
1777 So I turned it off. rms, 2 May 1997. */
1778/* #include <malloc.h> */
1779 #pragma alloca
1780#define YYSTACK_USE_ALLOCA
1781#else /* not MSDOS, or __TURBOC__, or _AIX */
1782#if 0
1783#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
1784 and on HPUX 10. Eventually we can turn this on. */
1785#define YYSTACK_USE_ALLOCA
1786#define alloca __builtin_alloca
1787#endif /* __hpux */
1788#endif
1789#endif /* not _AIX */
1790#endif /* not MSDOS, or __TURBOC__ */
1791#endif /* not sparc */
1792#endif /* not GNU C */
1793#endif /* alloca not defined */
1794#endif /* YYSTACK_USE_ALLOCA not defined */
1795
1796#ifdef YYSTACK_USE_ALLOCA
1797#define YYSTACK_ALLOC alloca
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001798#else
Chris Lattner680aab62006-08-18 17:34:45 +00001799#define YYSTACK_ALLOC malloc
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001800#endif
1801
Chris Lattner680aab62006-08-18 17:34:45 +00001802/* Note: there must be only one dollar sign in this file.
1803 It is replaced by the list of actions, each action
1804 as one case of the switch. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001805
1806#define yyerrok (yyerrstatus = 0)
1807#define yyclearin (yychar = YYEMPTY)
Chris Lattner680aab62006-08-18 17:34:45 +00001808#define YYEMPTY -2
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001809#define YYEOF 0
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001810#define YYACCEPT goto yyacceptlab
Chris Lattner680aab62006-08-18 17:34:45 +00001811#define YYABORT goto yyabortlab
1812#define YYERROR goto yyerrlab1
1813/* Like YYERROR except do call yyerror.
1814 This remains here temporarily to ease the
1815 transition to the new meaning of YYERROR, for GCC.
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001816 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001817#define YYFAIL goto yyerrlab
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001818#define YYRECOVERING() (!!yyerrstatus)
Chris Lattner680aab62006-08-18 17:34:45 +00001819#define YYBACKUP(token, value) \
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001820do \
1821 if (yychar == YYEMPTY && yylen == 1) \
Chris Lattner680aab62006-08-18 17:34:45 +00001822 { yychar = (token), yylval = (value); \
1823 yychar1 = YYTRANSLATE (yychar); \
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001824 YYPOPSTACK; \
1825 goto yybackup; \
1826 } \
1827 else \
Chris Lattner680aab62006-08-18 17:34:45 +00001828 { yyerror ("syntax error: cannot back up"); YYERROR; } \
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001829while (0)
1830
1831#define YYTERROR 1
1832#define YYERRCODE 256
1833
Chris Lattner680aab62006-08-18 17:34:45 +00001834#ifndef YYPURE
1835#define YYLEX yylex()
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001836#endif
1837
Chris Lattner680aab62006-08-18 17:34:45 +00001838#ifdef YYPURE
1839#ifdef YYLSP_NEEDED
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001840#ifdef YYLEX_PARAM
Chris Lattner680aab62006-08-18 17:34:45 +00001841#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001842#else
Chris Lattner680aab62006-08-18 17:34:45 +00001843#define YYLEX yylex(&yylval, &yylloc)
1844#endif
1845#else /* not YYLSP_NEEDED */
1846#ifdef YYLEX_PARAM
1847#define YYLEX yylex(&yylval, YYLEX_PARAM)
1848#else
1849#define YYLEX yylex(&yylval)
1850#endif
1851#endif /* not YYLSP_NEEDED */
Chris Lattneredd9b032006-01-23 23:05:42 +00001852#endif
Reid Spencer713eedc2006-08-18 08:43:06 +00001853
Chris Lattner680aab62006-08-18 17:34:45 +00001854/* If nonreentrant, generate the variables here */
Reid Spencer713eedc2006-08-18 08:43:06 +00001855
Chris Lattner680aab62006-08-18 17:34:45 +00001856#ifndef YYPURE
Reid Spencer713eedc2006-08-18 08:43:06 +00001857
Chris Lattner680aab62006-08-18 17:34:45 +00001858int yychar; /* the lookahead symbol */
1859YYSTYPE yylval; /* the semantic value of the */
1860 /* lookahead symbol */
Reid Spencer713eedc2006-08-18 08:43:06 +00001861
Chris Lattner680aab62006-08-18 17:34:45 +00001862#ifdef YYLSP_NEEDED
1863YYLTYPE yylloc; /* location data for the lookahead */
1864 /* symbol */
Chris Lattneredd9b032006-01-23 23:05:42 +00001865#endif
Reid Spencer713eedc2006-08-18 08:43:06 +00001866
Chris Lattner680aab62006-08-18 17:34:45 +00001867int yynerrs; /* number of parse errors so far */
1868#endif /* not YYPURE */
Reid Spencer713eedc2006-08-18 08:43:06 +00001869
Chris Lattner680aab62006-08-18 17:34:45 +00001870#if YYDEBUG != 0
1871int yydebug; /* nonzero means print parse trace */
1872/* Since this is uninitialized, it does not stop multiple parsers
1873 from coexisting. */
Robert Bocchinofdf9e412006-01-17 20:06:25 +00001874#endif
Reid Spencerc8a9faf2006-01-19 01:21:04 +00001875
Chris Lattner680aab62006-08-18 17:34:45 +00001876/* YYINITDEPTH indicates the initial size of the parser's stacks */
Reid Spencerc8a9faf2006-01-19 01:21:04 +00001877
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001878#ifndef YYINITDEPTH
Chris Lattner680aab62006-08-18 17:34:45 +00001879#define YYINITDEPTH 200
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001880#endif
1881
Chris Lattner680aab62006-08-18 17:34:45 +00001882/* YYMAXDEPTH is the maximum size the stacks can grow to
1883 (effective only if the built-in stack extension method is used). */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001884
Chris Lattner680aab62006-08-18 17:34:45 +00001885#if YYMAXDEPTH == 0
1886#undef YYMAXDEPTH
1887#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001888
1889#ifndef YYMAXDEPTH
Chris Lattner680aab62006-08-18 17:34:45 +00001890#define YYMAXDEPTH 10000
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001891#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001892
Chris Lattner680aab62006-08-18 17:34:45 +00001893/* Define __yy_memcpy. Note that the size argument
1894 should be passed with type unsigned int, because that is what the non-GCC
1895 definitions require. With GCC, __builtin_memcpy takes an arg
1896 of type size_t, but it can handle unsigned int. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001897
Chris Lattner680aab62006-08-18 17:34:45 +00001898#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
1899#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
1900#else /* not GNU C or C++ */
1901#ifndef __cplusplus
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001902
Chris Lattner680aab62006-08-18 17:34:45 +00001903/* This is the most reliable way to avoid incompatibilities
1904 in available built-in functions on various systems. */
Reid Spencer713eedc2006-08-18 08:43:06 +00001905static void
Chris Lattner680aab62006-08-18 17:34:45 +00001906__yy_memcpy (to, from, count)
1907 char *to;
1908 char *from;
1909 unsigned int count;
1910{
1911 register char *f = from;
1912 register char *t = to;
1913 register int i = count;
1914
1915 while (i-- > 0)
1916 *t++ = *f++;
1917}
1918
1919#else /* __cplusplus */
1920
1921/* This is the most reliable way to avoid incompatibilities
1922 in available built-in functions on various systems. */
Reid Spencer713eedc2006-08-18 08:43:06 +00001923static void
Chris Lattner680aab62006-08-18 17:34:45 +00001924__yy_memcpy (char *to, char *from, unsigned int count)
1925{
1926 register char *t = to;
1927 register char *f = from;
1928 register int i = count;
1929
1930 while (i-- > 0)
1931 *t++ = *f++;
1932}
1933
Reid Spencer713eedc2006-08-18 08:43:06 +00001934#endif
Reid Spencer713eedc2006-08-18 08:43:06 +00001935#endif
Reid Spencer713eedc2006-08-18 08:43:06 +00001936
Chris Lattner680aab62006-08-18 17:34:45 +00001937#line 217 "/usr/share/bison.simple"
Reid Spencer713eedc2006-08-18 08:43:06 +00001938
Chris Lattner680aab62006-08-18 17:34:45 +00001939/* The user can define YYPARSE_PARAM as the name of an argument to be passed
1940 into yyparse. The argument should have type void *.
1941 It should actually point to an object.
1942 Grammar actions can access the variable by casting it
1943 to the proper pointer type. */
Reid Spencer713eedc2006-08-18 08:43:06 +00001944
1945#ifdef YYPARSE_PARAM
Chris Lattner680aab62006-08-18 17:34:45 +00001946#ifdef __cplusplus
1947#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
1948#define YYPARSE_PARAM_DECL
1949#else /* not __cplusplus */
1950#define YYPARSE_PARAM_ARG YYPARSE_PARAM
1951#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
1952#endif /* not __cplusplus */
1953#else /* not YYPARSE_PARAM */
1954#define YYPARSE_PARAM_ARG
1955#define YYPARSE_PARAM_DECL
1956#endif /* not YYPARSE_PARAM */
1957
1958/* Prevent warning if -Wstrict-prototypes. */
1959#ifdef __GNUC__
1960#ifdef YYPARSE_PARAM
1961int yyparse (void *);
1962#else
Reid Spencerc8a9faf2006-01-19 01:21:04 +00001963int yyparse (void);
Reid Spencer713eedc2006-08-18 08:43:06 +00001964#endif
Chris Lattner680aab62006-08-18 17:34:45 +00001965#endif
Reid Spencer713eedc2006-08-18 08:43:06 +00001966
Reid Spencer713eedc2006-08-18 08:43:06 +00001967int
Chris Lattner680aab62006-08-18 17:34:45 +00001968yyparse(YYPARSE_PARAM_ARG)
1969 YYPARSE_PARAM_DECL
Reid Spencer713eedc2006-08-18 08:43:06 +00001970{
Chris Lattner680aab62006-08-18 17:34:45 +00001971 register int yystate;
1972 register int yyn;
1973 register short *yyssp;
1974 register YYSTYPE *yyvsp;
1975 int yyerrstatus; /* number of tokens to shift before error messages enabled */
1976 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
Reid Spencer713eedc2006-08-18 08:43:06 +00001977
Chris Lattner680aab62006-08-18 17:34:45 +00001978 short yyssa[YYINITDEPTH]; /* the state stack */
1979 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
Reid Spencer713eedc2006-08-18 08:43:06 +00001980
Chris Lattner680aab62006-08-18 17:34:45 +00001981 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
1982 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
Reid Spencer713eedc2006-08-18 08:43:06 +00001983
Chris Lattner680aab62006-08-18 17:34:45 +00001984#ifdef YYLSP_NEEDED
1985 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
1986 YYLTYPE *yyls = yylsa;
1987 YYLTYPE *yylsp;
Reid Spencer713eedc2006-08-18 08:43:06 +00001988
Chris Lattner680aab62006-08-18 17:34:45 +00001989#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
1990#else
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001991#define YYPOPSTACK (yyvsp--, yyssp--)
Chris Lattner680aab62006-08-18 17:34:45 +00001992#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001993
Chris Lattner680aab62006-08-18 17:34:45 +00001994 int yystacksize = YYINITDEPTH;
1995 int yyfree_stacks = 0;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001996
Chris Lattner680aab62006-08-18 17:34:45 +00001997#ifdef YYPURE
1998 int yychar;
1999 YYSTYPE yylval;
2000 int yynerrs;
2001#ifdef YYLSP_NEEDED
2002 YYLTYPE yylloc;
2003#endif
2004#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002005
Chris Lattner680aab62006-08-18 17:34:45 +00002006 YYSTYPE yyval; /* the variable used to return */
2007 /* semantic values from the action */
2008 /* routines */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002009
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002010 int yylen;
2011
Chris Lattner680aab62006-08-18 17:34:45 +00002012#if YYDEBUG != 0
2013 if (yydebug)
2014 fprintf(stderr, "Starting parse\n");
2015#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002016
2017 yystate = 0;
2018 yyerrstatus = 0;
2019 yynerrs = 0;
2020 yychar = YYEMPTY; /* Cause a token to be read. */
2021
2022 /* Initialize stack pointers.
2023 Waste one element of value and location stack
2024 so that they stay on the same level as the state stack.
2025 The wasted elements are never initialized. */
2026
Chris Lattner680aab62006-08-18 17:34:45 +00002027 yyssp = yyss - 1;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002028 yyvsp = yyvs;
Chris Lattner680aab62006-08-18 17:34:45 +00002029#ifdef YYLSP_NEEDED
2030 yylsp = yyls;
2031#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002032
Chris Lattner680aab62006-08-18 17:34:45 +00002033/* Push a new state, which is found in yystate . */
2034/* In all cases, when you get here, the value and location stacks
2035 have just been pushed. so pushing a state here evens the stacks. */
2036yynewstate:
Jeff Cohen11e26b52005-10-23 04:37:20 +00002037
Chris Lattner680aab62006-08-18 17:34:45 +00002038 *++yyssp = yystate;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002039
Chris Lattner680aab62006-08-18 17:34:45 +00002040 if (yyssp >= yyss + yystacksize - 1)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002041 {
Chris Lattner680aab62006-08-18 17:34:45 +00002042 /* Give user a chance to reallocate the stack */
2043 /* Use copies of these so that the &'s don't force the real ones into memory. */
2044 YYSTYPE *yyvs1 = yyvs;
2045 short *yyss1 = yyss;
2046#ifdef YYLSP_NEEDED
2047 YYLTYPE *yyls1 = yyls;
2048#endif
2049
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002050 /* Get the current used size of the three stacks, in elements. */
Chris Lattner680aab62006-08-18 17:34:45 +00002051 int size = yyssp - yyss + 1;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002052
2053#ifdef yyoverflow
Chris Lattner680aab62006-08-18 17:34:45 +00002054 /* Each stack pointer address is followed by the size of
2055 the data in use in that stack, in bytes. */
2056#ifdef YYLSP_NEEDED
2057 /* This used to be a conditional around just the two extra args,
2058 but that might be undefined if yyoverflow is a macro. */
2059 yyoverflow("parser stack overflow",
2060 &yyss1, size * sizeof (*yyssp),
2061 &yyvs1, size * sizeof (*yyvsp),
2062 &yyls1, size * sizeof (*yylsp),
2063 &yystacksize);
2064#else
2065 yyoverflow("parser stack overflow",
2066 &yyss1, size * sizeof (*yyssp),
2067 &yyvs1, size * sizeof (*yyvsp),
2068 &yystacksize);
2069#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002070
Chris Lattner680aab62006-08-18 17:34:45 +00002071 yyss = yyss1; yyvs = yyvs1;
2072#ifdef YYLSP_NEEDED
2073 yyls = yyls1;
2074#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002075#else /* no yyoverflow */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002076 /* Extend the stack our own way. */
Chris Lattner680aab62006-08-18 17:34:45 +00002077 if (yystacksize >= YYMAXDEPTH)
2078 {
2079 yyerror("parser stack overflow");
2080 if (yyfree_stacks)
2081 {
2082 free (yyss);
2083 free (yyvs);
2084#ifdef YYLSP_NEEDED
2085 free (yyls);
2086#endif
2087 }
2088 return 2;
2089 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002090 yystacksize *= 2;
Chris Lattner680aab62006-08-18 17:34:45 +00002091 if (yystacksize > YYMAXDEPTH)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002092 yystacksize = YYMAXDEPTH;
Chris Lattner680aab62006-08-18 17:34:45 +00002093#ifndef YYSTACK_USE_ALLOCA
2094 yyfree_stacks = 1;
2095#endif
2096 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
2097 __yy_memcpy ((char *)yyss, (char *)yyss1,
2098 size * (unsigned int) sizeof (*yyssp));
2099 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
2100 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
2101 size * (unsigned int) sizeof (*yyvsp));
2102#ifdef YYLSP_NEEDED
2103 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
2104 __yy_memcpy ((char *)yyls, (char *)yyls1,
2105 size * (unsigned int) sizeof (*yylsp));
2106#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002107#endif /* no yyoverflow */
2108
Chris Lattner680aab62006-08-18 17:34:45 +00002109 yyssp = yyss + size - 1;
2110 yyvsp = yyvs + size - 1;
2111#ifdef YYLSP_NEEDED
2112 yylsp = yyls + size - 1;
2113#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002114
Chris Lattner680aab62006-08-18 17:34:45 +00002115#if YYDEBUG != 0
2116 if (yydebug)
2117 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2118#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002119
Chris Lattner680aab62006-08-18 17:34:45 +00002120 if (yyssp >= yyss + yystacksize - 1)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002121 YYABORT;
2122 }
2123
Chris Lattner680aab62006-08-18 17:34:45 +00002124#if YYDEBUG != 0
2125 if (yydebug)
2126 fprintf(stderr, "Entering state %d\n", yystate);
2127#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002128
2129 goto yybackup;
Chris Lattner680aab62006-08-18 17:34:45 +00002130 yybackup:
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002131
2132/* Do appropriate processing given the current state. */
Chris Lattner680aab62006-08-18 17:34:45 +00002133/* Read a lookahead token if we need one and don't already have one. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002134/* yyresume: */
2135
Chris Lattner680aab62006-08-18 17:34:45 +00002136 /* First try to decide what to do without reference to lookahead token. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002137
2138 yyn = yypact[yystate];
Chris Lattner680aab62006-08-18 17:34:45 +00002139 if (yyn == YYFLAG)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002140 goto yydefault;
2141
Chris Lattner680aab62006-08-18 17:34:45 +00002142 /* Not known => get a lookahead token if don't already have one. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002143
Chris Lattner680aab62006-08-18 17:34:45 +00002144 /* yychar is either YYEMPTY or YYEOF
2145 or a valid token in external form. */
2146
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002147 if (yychar == YYEMPTY)
2148 {
Chris Lattner680aab62006-08-18 17:34:45 +00002149#if YYDEBUG != 0
2150 if (yydebug)
2151 fprintf(stderr, "Reading a token: ");
2152#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002153 yychar = YYLEX;
2154 }
2155
Chris Lattner680aab62006-08-18 17:34:45 +00002156 /* Convert token to internal form (in yychar1) for indexing tables with */
2157
2158 if (yychar <= 0) /* This means end of input. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002159 {
Chris Lattner680aab62006-08-18 17:34:45 +00002160 yychar1 = 0;
2161 yychar = YYEOF; /* Don't call YYLEX any more */
2162
2163#if YYDEBUG != 0
2164 if (yydebug)
2165 fprintf(stderr, "Now at end of input.\n");
2166#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002167 }
2168 else
2169 {
Chris Lattner680aab62006-08-18 17:34:45 +00002170 yychar1 = YYTRANSLATE(yychar);
2171
2172#if YYDEBUG != 0
2173 if (yydebug)
2174 {
2175 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2176 /* Give the individual parser a way to print the precise meaning
2177 of a token, for further debugging info. */
2178#ifdef YYPRINT
2179 YYPRINT (stderr, yychar, yylval);
2180#endif
2181 fprintf (stderr, ")\n");
2182 }
2183#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002184 }
2185
Chris Lattner680aab62006-08-18 17:34:45 +00002186 yyn += yychar1;
2187 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002188 goto yydefault;
Chris Lattner680aab62006-08-18 17:34:45 +00002189
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002190 yyn = yytable[yyn];
Chris Lattner680aab62006-08-18 17:34:45 +00002191
2192 /* yyn is what to do for this token type in this state.
2193 Negative => reduce, -yyn is rule number.
2194 Positive => shift, yyn is new state.
2195 New state is final state => don't bother to shift,
2196 just return success.
2197 0, or most negative number => error. */
2198
2199 if (yyn < 0)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002200 {
Chris Lattner680aab62006-08-18 17:34:45 +00002201 if (yyn == YYFLAG)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002202 goto yyerrlab;
2203 yyn = -yyn;
2204 goto yyreduce;
2205 }
Chris Lattner680aab62006-08-18 17:34:45 +00002206 else if (yyn == 0)
2207 goto yyerrlab;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002208
2209 if (yyn == YYFINAL)
2210 YYACCEPT;
2211
Chris Lattner680aab62006-08-18 17:34:45 +00002212 /* Shift the lookahead token. */
2213
2214#if YYDEBUG != 0
2215 if (yydebug)
2216 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2217#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002218
2219 /* Discard the token being shifted unless it is eof. */
2220 if (yychar != YYEOF)
2221 yychar = YYEMPTY;
2222
2223 *++yyvsp = yylval;
Chris Lattner680aab62006-08-18 17:34:45 +00002224#ifdef YYLSP_NEEDED
2225 *++yylsp = yylloc;
2226#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002227
Chris Lattner680aab62006-08-18 17:34:45 +00002228 /* count tokens shifted since error; after three, turn off error status. */
2229 if (yyerrstatus) yyerrstatus--;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002230
2231 yystate = yyn;
2232 goto yynewstate;
2233
Chris Lattner680aab62006-08-18 17:34:45 +00002234/* Do the default action for the current state. */
Reid Spencer713eedc2006-08-18 08:43:06 +00002235yydefault:
Chris Lattner680aab62006-08-18 17:34:45 +00002236
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002237 yyn = yydefact[yystate];
2238 if (yyn == 0)
2239 goto yyerrlab;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002240
Chris Lattner680aab62006-08-18 17:34:45 +00002241/* Do a reduction. yyn is the number of a rule to reduce with. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002242yyreduce:
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002243 yylen = yyr2[yyn];
Chris Lattner680aab62006-08-18 17:34:45 +00002244 if (yylen > 0)
2245 yyval = yyvsp[1-yylen]; /* implement default value of the action */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002246
Chris Lattner680aab62006-08-18 17:34:45 +00002247#if YYDEBUG != 0
2248 if (yydebug)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002249 {
Chris Lattner680aab62006-08-18 17:34:45 +00002250 int i;
2251
2252 fprintf (stderr, "Reducing via rule %d (line %d), ",
2253 yyn, yyrline[yyn]);
2254
2255 /* Print the symbols being reduced, and their result. */
2256 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2257 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2258 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2259 }
2260#endif
2261
2262
2263 switch (yyn) {
2264
2265case 2:
2266#line 1031 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2267{
2268 if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX) // Outside of my range!
Reid Spencer713eedc2006-08-18 08:43:06 +00002269 GEN_ERROR("Value too large for type!");
Chris Lattner680aab62006-08-18 17:34:45 +00002270 yyval.SIntVal = (int32_t)yyvsp[0].UIntVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00002271 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002272;
2273 break;}
2274case 4:
2275#line 1040 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2276{
2277 if (yyvsp[0].UInt64Val > (uint64_t)INT64_MAX) // Outside of my range!
Reid Spencer713eedc2006-08-18 08:43:06 +00002278 GEN_ERROR("Value too large for type!");
Chris Lattner680aab62006-08-18 17:34:45 +00002279 yyval.SInt64Val = (int64_t)yyvsp[0].UInt64Val;
Reid Spencer713eedc2006-08-18 08:43:06 +00002280 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002281;
2282 break;}
2283case 33:
2284#line 1064 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2285{
2286 yyval.StrVal = yyvsp[-1].StrVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00002287 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002288 ;
2289 break;}
2290case 34:
2291#line 1068 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2292{
2293 yyval.StrVal = 0;
Reid Spencer713eedc2006-08-18 08:43:06 +00002294 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002295 ;
2296 break;}
2297case 35:
2298#line 1073 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2299{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2300 break;}
2301case 36:
2302#line 1074 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2303{ yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2304 break;}
2305case 37:
2306#line 1075 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2307{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2308 break;}
2309case 38:
2310#line 1076 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2311{ yyval.Linkage = GlobalValue::AppendingLinkage; ;
2312 break;}
2313case 39:
2314#line 1077 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2315{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2316 break;}
2317case 40:
2318#line 1079 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2319{ yyval.UIntVal = CallingConv::C; ;
2320 break;}
2321case 41:
2322#line 1080 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2323{ yyval.UIntVal = CallingConv::C; ;
2324 break;}
2325case 42:
2326#line 1081 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2327{ yyval.UIntVal = CallingConv::CSRet; ;
2328 break;}
2329case 43:
2330#line 1082 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2331{ yyval.UIntVal = CallingConv::Fast; ;
2332 break;}
2333case 44:
2334#line 1083 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2335{ yyval.UIntVal = CallingConv::Cold; ;
2336 break;}
2337case 45:
2338#line 1084 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2339{
2340 if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
Reid Spencer713eedc2006-08-18 08:43:06 +00002341 GEN_ERROR("Calling conv too large!");
Chris Lattner680aab62006-08-18 17:34:45 +00002342 yyval.UIntVal = yyvsp[0].UInt64Val;
Reid Spencer713eedc2006-08-18 08:43:06 +00002343 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002344 ;
2345 break;}
2346case 46:
2347#line 1093 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2348{ yyval.UIntVal = 0; ;
2349 break;}
2350case 47:
2351#line 1094 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2352{
2353 yyval.UIntVal = yyvsp[0].UInt64Val;
2354 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
Reid Spencer713eedc2006-08-18 08:43:06 +00002355 GEN_ERROR("Alignment must be a power of two!");
2356 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002357;
2358 break;}
2359case 48:
2360#line 1100 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2361{ yyval.UIntVal = 0; ;
2362 break;}
2363case 49:
2364#line 1101 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2365{
2366 yyval.UIntVal = yyvsp[0].UInt64Val;
2367 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
Reid Spencer713eedc2006-08-18 08:43:06 +00002368 GEN_ERROR("Alignment must be a power of two!");
2369 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002370;
2371 break;}
2372case 50:
2373#line 1109 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2374{
2375 for (unsigned i = 0, e = strlen(yyvsp[0].StrVal); i != e; ++i)
2376 if (yyvsp[0].StrVal[i] == '"' || yyvsp[0].StrVal[i] == '\\')
Reid Spencer713eedc2006-08-18 08:43:06 +00002377 GEN_ERROR("Invalid character in section name!");
Chris Lattner680aab62006-08-18 17:34:45 +00002378 yyval.StrVal = yyvsp[0].StrVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00002379 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002380;
2381 break;}
2382case 51:
2383#line 1117 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2384{ yyval.StrVal = 0; ;
2385 break;}
2386case 52:
2387#line 1118 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2388{ yyval.StrVal = yyvsp[0].StrVal; ;
2389 break;}
2390case 53:
2391#line 1123 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2392{;
2393 break;}
2394case 54:
2395#line 1124 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2396{;
2397 break;}
2398case 55:
2399#line 1125 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2400{
2401 CurGV->setSection(yyvsp[0].StrVal);
2402 free(yyvsp[0].StrVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00002403 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002404 ;
2405 break;}
2406case 56:
2407#line 1130 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2408{
2409 if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val))
Reid Spencer713eedc2006-08-18 08:43:06 +00002410 GEN_ERROR("Alignment must be a power of two!");
Chris Lattner680aab62006-08-18 17:34:45 +00002411 CurGV->setAlignment(yyvsp[0].UInt64Val);
Reid Spencer713eedc2006-08-18 08:43:06 +00002412 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002413 ;
2414 break;}
2415case 58:
2416#line 1144 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2417{ yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2418 break;}
2419case 60:
2420#line 1145 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2421{ yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2422 break;}
2423case 61:
2424#line 1147 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2425{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002426 if (!UpRefs.empty())
Chris Lattner680aab62006-08-18 17:34:45 +00002427 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
2428 yyval.TypeVal = yyvsp[0].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00002429 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002430 ;
2431 break;}
2432case 75:
2433#line 1159 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2434{
2435 yyval.TypeVal = new PATypeHolder(OpaqueType::get());
Reid Spencer713eedc2006-08-18 08:43:06 +00002436 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002437 ;
2438 break;}
2439case 76:
2440#line 1163 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2441{
2442 yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
Reid Spencer713eedc2006-08-18 08:43:06 +00002443 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002444 ;
2445 break;}
2446case 77:
2447#line 1167 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2448{ // Named types are also simple types...
2449 yyval.TypeVal = new PATypeHolder(getTypeVal(yyvsp[0].ValIDVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00002450 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002451;
2452 break;}
2453case 78:
2454#line 1174 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2455{ // Type UpReference
2456 if (yyvsp[0].UInt64Val > (uint64_t)~0U) GEN_ERROR("Value out of range!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002457 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Chris Lattner680aab62006-08-18 17:34:45 +00002458 UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector...
2459 yyval.TypeVal = new PATypeHolder(OT);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002460 UR_OUT("New Upreference!\n");
Reid Spencer713eedc2006-08-18 08:43:06 +00002461 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002462 ;
2463 break;}
2464case 79:
2465#line 1182 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2466{ // Function derived type?
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002467 std::vector<const Type*> Params;
Chris Lattner680aab62006-08-18 17:34:45 +00002468 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2469 E = yyvsp[-1].TypeList->end(); I != E; ++I)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002470 Params.push_back(*I);
2471 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
2472 if (isVarArg) Params.pop_back();
2473
Chris Lattner680aab62006-08-18 17:34:45 +00002474 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FunctionType::get(*yyvsp[-3].TypeVal,Params,isVarArg)));
2475 delete yyvsp[-1].TypeList; // Delete the argument list
2476 delete yyvsp[-3].TypeVal; // Delete the return type handle
Reid Spencer713eedc2006-08-18 08:43:06 +00002477 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002478 ;
2479 break;}
2480case 80:
2481#line 1195 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2482{ // Sized array type?
2483 yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2484 delete yyvsp[-1].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00002485 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002486 ;
2487 break;}
2488case 81:
2489#line 1200 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2490{ // Packed array type?
2491 const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
2492 if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val)
Reid Spencer713eedc2006-08-18 08:43:06 +00002493 GEN_ERROR("Unsigned result not equal to signed result");
Chris Lattner625b9c82005-11-10 01:42:43 +00002494 if (!ElemTy->isPrimitiveType())
Reid Spencer713eedc2006-08-18 08:43:06 +00002495 GEN_ERROR("Elemental type of a PackedType must be primitive");
Chris Lattner680aab62006-08-18 17:34:45 +00002496 if (!isPowerOf2_32(yyvsp[-3].UInt64Val))
Reid Spencer713eedc2006-08-18 08:43:06 +00002497 GEN_ERROR("Vector length should be a power of 2!");
Chris Lattner680aab62006-08-18 17:34:45 +00002498 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PackedType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2499 delete yyvsp[-1].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00002500 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002501 ;
2502 break;}
2503case 82:
2504#line 1212 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2505{ // Structure type?
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002506 std::vector<const Type*> Elements;
Chris Lattner680aab62006-08-18 17:34:45 +00002507 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2508 E = yyvsp[-1].TypeList->end(); I != E; ++I)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002509 Elements.push_back(*I);
2510
Chris Lattner680aab62006-08-18 17:34:45 +00002511 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
2512 delete yyvsp[-1].TypeList;
Reid Spencer713eedc2006-08-18 08:43:06 +00002513 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002514 ;
2515 break;}
2516case 83:
2517#line 1222 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2518{ // Empty structure type?
2519 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer713eedc2006-08-18 08:43:06 +00002520 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002521 ;
2522 break;}
2523case 84:
2524#line 1226 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2525{ // Pointer type?
2526 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal)));
2527 delete yyvsp[-1].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00002528 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002529 ;
2530 break;}
2531case 85:
2532#line 1235 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2533{
2534 yyval.TypeList = new std::list<PATypeHolder>();
2535 yyval.TypeList->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00002536 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002537 ;
2538 break;}
2539case 86:
2540#line 1240 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2541{
2542 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00002543 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002544 ;
2545 break;}
2546case 88:
2547#line 1247 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2548{
2549 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(Type::VoidTy);
Reid Spencer713eedc2006-08-18 08:43:06 +00002550 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002551 ;
2552 break;}
2553case 89:
2554#line 1251 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2555{
2556 (yyval.TypeList = new std::list<PATypeHolder>())->push_back(Type::VoidTy);
Reid Spencer713eedc2006-08-18 08:43:06 +00002557 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002558 ;
2559 break;}
2560case 90:
2561#line 1255 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2562{
2563 yyval.TypeList = new std::list<PATypeHolder>();
Reid Spencer713eedc2006-08-18 08:43:06 +00002564 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002565 ;
2566 break;}
2567case 91:
2568#line 1266 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2569{ // Nonempty unsized arr
2570 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002571 if (ATy == 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00002572 GEN_ERROR("Cannot make array constant with type: '" +
Chris Lattner680aab62006-08-18 17:34:45 +00002573 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002574 const Type *ETy = ATy->getElementType();
2575 int NumElements = ATy->getNumElements();
2576
2577 // Verify that we have the correct size...
Chris Lattner680aab62006-08-18 17:34:45 +00002578 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
Reid Spencer713eedc2006-08-18 08:43:06 +00002579 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Chris Lattner680aab62006-08-18 17:34:45 +00002580 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002581 itostr(NumElements) + "!");
2582
2583 // Verify all elements are correct type!
Chris Lattner680aab62006-08-18 17:34:45 +00002584 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2585 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Reid Spencer713eedc2006-08-18 08:43:06 +00002586 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002587 ETy->getDescription() +"' as required!\nIt is of type '"+
Chris Lattner680aab62006-08-18 17:34:45 +00002588 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002589 }
2590
Chris Lattner680aab62006-08-18 17:34:45 +00002591 yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
2592 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Reid Spencer713eedc2006-08-18 08:43:06 +00002593 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002594 ;
2595 break;}
2596case 92:
2597#line 1292 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2598{
2599 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002600 if (ATy == 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00002601 GEN_ERROR("Cannot make array constant with type: '" +
Chris Lattner680aab62006-08-18 17:34:45 +00002602 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002603
2604 int NumElements = ATy->getNumElements();
2605 if (NumElements != -1 && NumElements != 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00002606 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002607 " arguments, but has size of " + itostr(NumElements) +"!");
Chris Lattner680aab62006-08-18 17:34:45 +00002608 yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
2609 delete yyvsp[-2].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00002610 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002611 ;
2612 break;}
2613case 93:
2614#line 1306 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2615{
2616 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002617 if (ATy == 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00002618 GEN_ERROR("Cannot make array constant with type: '" +
Chris Lattner680aab62006-08-18 17:34:45 +00002619 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002620
2621 int NumElements = ATy->getNumElements();
2622 const Type *ETy = ATy->getElementType();
Chris Lattner680aab62006-08-18 17:34:45 +00002623 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
2624 if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal))
Reid Spencer713eedc2006-08-18 08:43:06 +00002625 GEN_ERROR("Can't build string constant of size " +
Chris Lattner680aab62006-08-18 17:34:45 +00002626 itostr((int)(EndStr-yyvsp[0].StrVal)) +
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002627 " when array has size " + itostr(NumElements) + "!");
2628 std::vector<Constant*> Vals;
2629 if (ETy == Type::SByteTy) {
Chris Lattner680aab62006-08-18 17:34:45 +00002630 for (signed char *C = (signed char *)yyvsp[0].StrVal; C != (signed char *)EndStr; ++C)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002631 Vals.push_back(ConstantSInt::get(ETy, *C));
2632 } else if (ETy == Type::UByteTy) {
Chris Lattner680aab62006-08-18 17:34:45 +00002633 for (unsigned char *C = (unsigned char *)yyvsp[0].StrVal;
Chris Lattner8ebd2162006-01-24 04:14:29 +00002634 C != (unsigned char*)EndStr; ++C)
2635 Vals.push_back(ConstantUInt::get(ETy, *C));
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002636 } else {
Chris Lattner680aab62006-08-18 17:34:45 +00002637 free(yyvsp[0].StrVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00002638 GEN_ERROR("Cannot build string arrays of non byte sized elements!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002639 }
Chris Lattner680aab62006-08-18 17:34:45 +00002640 free(yyvsp[0].StrVal);
2641 yyval.ConstVal = ConstantArray::get(ATy, Vals);
2642 delete yyvsp[-2].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00002643 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002644 ;
2645 break;}
2646case 94:
2647#line 1336 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2648{ // Nonempty unsized arr
2649 const PackedType *PTy = dyn_cast<PackedType>(yyvsp[-3].TypeVal->get());
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002650 if (PTy == 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00002651 GEN_ERROR("Cannot make packed constant with type: '" +
Chris Lattner680aab62006-08-18 17:34:45 +00002652 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002653 const Type *ETy = PTy->getElementType();
2654 int NumElements = PTy->getNumElements();
2655
2656 // Verify that we have the correct size...
Chris Lattner680aab62006-08-18 17:34:45 +00002657 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
Reid Spencer713eedc2006-08-18 08:43:06 +00002658 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Chris Lattner680aab62006-08-18 17:34:45 +00002659 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002660 itostr(NumElements) + "!");
2661
2662 // Verify all elements are correct type!
Chris Lattner680aab62006-08-18 17:34:45 +00002663 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2664 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Reid Spencer713eedc2006-08-18 08:43:06 +00002665 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002666 ETy->getDescription() +"' as required!\nIt is of type '"+
Chris Lattner680aab62006-08-18 17:34:45 +00002667 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002668 }
2669
Chris Lattner680aab62006-08-18 17:34:45 +00002670 yyval.ConstVal = ConstantPacked::get(PTy, *yyvsp[-1].ConstVector);
2671 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Reid Spencer713eedc2006-08-18 08:43:06 +00002672 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002673 ;
2674 break;}
2675case 95:
2676#line 1362 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2677{
2678 const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
Reid Spencer713eedc2006-08-18 08:43:06 +00002679 if (STy == 0)
2680 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattner680aab62006-08-18 17:34:45 +00002681 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
Reid Spencer713eedc2006-08-18 08:43:06 +00002682
Chris Lattner680aab62006-08-18 17:34:45 +00002683 if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
Reid Spencer713eedc2006-08-18 08:43:06 +00002684 GEN_ERROR("Illegal number of initializers for structure type!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002685
2686 // Check to ensure that constants are compatible with the type initializer!
Chris Lattner680aab62006-08-18 17:34:45 +00002687 for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
2688 if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
Reid Spencer713eedc2006-08-18 08:43:06 +00002689 GEN_ERROR("Expected type '" +
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002690 STy->getElementType(i)->getDescription() +
2691 "' for element #" + utostr(i) +
2692 " of structure initializer!");
2693
Chris Lattner680aab62006-08-18 17:34:45 +00002694 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
2695 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Reid Spencer713eedc2006-08-18 08:43:06 +00002696 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002697 ;
2698 break;}
2699case 96:
2700#line 1383 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2701{
2702 const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002703 if (STy == 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00002704 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattner680aab62006-08-18 17:34:45 +00002705 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002706
2707 if (STy->getNumContainedTypes() != 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00002708 GEN_ERROR("Illegal number of initializers for structure type!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002709
Chris Lattner680aab62006-08-18 17:34:45 +00002710 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
2711 delete yyvsp[-2].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00002712 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002713 ;
2714 break;}
2715case 97:
2716#line 1396 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2717{
2718 const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002719 if (PTy == 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00002720 GEN_ERROR("Cannot make null pointer constant with type: '" +
Chris Lattner680aab62006-08-18 17:34:45 +00002721 (*yyvsp[-1].TypeVal)->getDescription() + "'!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002722
Chris Lattner680aab62006-08-18 17:34:45 +00002723 yyval.ConstVal = ConstantPointerNull::get(PTy);
2724 delete yyvsp[-1].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00002725 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002726 ;
2727 break;}
2728case 98:
2729#line 1406 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2730{
2731 yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
2732 delete yyvsp[-1].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00002733 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002734 ;
2735 break;}
2736case 99:
2737#line 1411 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2738{
2739 const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002740 if (Ty == 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00002741 GEN_ERROR("Global const reference must be a pointer type!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002742
2743 // ConstExprs can exist in the body of a function, thus creating
2744 // GlobalValues whenever they refer to a variable. Because we are in
2745 // the context of a function, getValNonImprovising will search the functions
2746 // symbol table instead of the module symbol table for the global symbol,
2747 // which throws things all off. To get around this, we just tell
2748 // getValNonImprovising that we are at global scope here.
2749 //
2750 Function *SavedCurFn = CurFun.CurrentFunction;
2751 CurFun.CurrentFunction = 0;
2752
Chris Lattner680aab62006-08-18 17:34:45 +00002753 Value *V = getValNonImprovising(Ty, yyvsp[0].ValIDVal);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002754
2755 CurFun.CurrentFunction = SavedCurFn;
2756
2757 // If this is an initializer for a constant pointer, which is referencing a
2758 // (currently) undefined variable, create a stub now that shall be replaced
2759 // in the future with the right type of variable.
2760 //
2761 if (V == 0) {
2762 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
2763 const PointerType *PT = cast<PointerType>(Ty);
2764
2765 // First check to see if the forward references value is already created!
2766 PerModuleInfo::GlobalRefsType::iterator I =
Chris Lattner680aab62006-08-18 17:34:45 +00002767 CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002768
2769 if (I != CurModule.GlobalRefs.end()) {
2770 V = I->second; // Placeholder already exists, use it...
Chris Lattner680aab62006-08-18 17:34:45 +00002771 yyvsp[0].ValIDVal.destroy();
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002772 } else {
2773 std::string Name;
Chris Lattner680aab62006-08-18 17:34:45 +00002774 if (yyvsp[0].ValIDVal.Type == ValID::NameVal) Name = yyvsp[0].ValIDVal.Name;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002775
2776 // Create the forward referenced global.
2777 GlobalValue *GV;
2778 if (const FunctionType *FTy =
2779 dyn_cast<FunctionType>(PT->getElementType())) {
2780 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
2781 CurModule.CurrentModule);
2782 } else {
2783 GV = new GlobalVariable(PT->getElementType(), false,
2784 GlobalValue::ExternalLinkage, 0,
2785 Name, CurModule.CurrentModule);
2786 }
2787
2788 // Keep track of the fact that we have a forward ref to recycle it
Chris Lattner680aab62006-08-18 17:34:45 +00002789 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002790 V = GV;
2791 }
2792 }
2793
Chris Lattner680aab62006-08-18 17:34:45 +00002794 yyval.ConstVal = cast<GlobalValue>(V);
2795 delete yyvsp[-1].TypeVal; // Free the type handle
Reid Spencer713eedc2006-08-18 08:43:06 +00002796 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002797 ;
2798 break;}
2799case 100:
2800#line 1471 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2801{
2802 if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
Reid Spencer713eedc2006-08-18 08:43:06 +00002803 GEN_ERROR("Mismatched types for constant expression!");
Chris Lattner680aab62006-08-18 17:34:45 +00002804 yyval.ConstVal = yyvsp[0].ConstVal;
2805 delete yyvsp[-1].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00002806 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002807 ;
2808 break;}
2809case 101:
2810#line 1478 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2811{
2812 const Type *Ty = yyvsp[-1].TypeVal->get();
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002813 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
Reid Spencer713eedc2006-08-18 08:43:06 +00002814 GEN_ERROR("Cannot create a null initialized value of this type!");
Chris Lattner680aab62006-08-18 17:34:45 +00002815 yyval.ConstVal = Constant::getNullValue(Ty);
2816 delete yyvsp[-1].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00002817 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002818 ;
2819 break;}
2820case 102:
2821#line 1487 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2822{ // integral constants
2823 if (!ConstantSInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
Reid Spencer713eedc2006-08-18 08:43:06 +00002824 GEN_ERROR("Constant value doesn't fit in type!");
Chris Lattner680aab62006-08-18 17:34:45 +00002825 yyval.ConstVal = ConstantSInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val);
Reid Spencer713eedc2006-08-18 08:43:06 +00002826 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002827 ;
2828 break;}
2829case 103:
2830#line 1493 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2831{ // integral constants
2832 if (!ConstantUInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
Reid Spencer713eedc2006-08-18 08:43:06 +00002833 GEN_ERROR("Constant value doesn't fit in type!");
Chris Lattner680aab62006-08-18 17:34:45 +00002834 yyval.ConstVal = ConstantUInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val);
Reid Spencer713eedc2006-08-18 08:43:06 +00002835 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002836 ;
2837 break;}
2838case 104:
2839#line 1499 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2840{ // Boolean constants
2841 yyval.ConstVal = ConstantBool::True;
Reid Spencer713eedc2006-08-18 08:43:06 +00002842 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002843 ;
2844 break;}
2845case 105:
2846#line 1503 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2847{ // Boolean constants
2848 yyval.ConstVal = ConstantBool::False;
Reid Spencer713eedc2006-08-18 08:43:06 +00002849 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002850 ;
2851 break;}
2852case 106:
2853#line 1507 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2854{ // Float & Double constants
2855 if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal))
Reid Spencer713eedc2006-08-18 08:43:06 +00002856 GEN_ERROR("Floating point constant invalid for type!!");
Chris Lattner680aab62006-08-18 17:34:45 +00002857 yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00002858 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002859 ;
2860 break;}
2861case 107:
2862#line 1515 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2863{
2864 if (!yyvsp[-3].ConstVal->getType()->isFirstClassType())
Reid Spencer713eedc2006-08-18 08:43:06 +00002865 GEN_ERROR("cast constant expression from a non-primitive type: '" +
Chris Lattner680aab62006-08-18 17:34:45 +00002866 yyvsp[-3].ConstVal->getType()->getDescription() + "'!");
2867 if (!yyvsp[-1].TypeVal->get()->isFirstClassType())
Reid Spencer713eedc2006-08-18 08:43:06 +00002868 GEN_ERROR("cast constant expression to a non-primitive type: '" +
Chris Lattner680aab62006-08-18 17:34:45 +00002869 yyvsp[-1].TypeVal->get()->getDescription() + "'!");
2870 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-3].ConstVal, yyvsp[-1].TypeVal->get());
2871 delete yyvsp[-1].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00002872 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002873 ;
2874 break;}
2875case 108:
2876#line 1526 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2877{
2878 if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
Reid Spencer713eedc2006-08-18 08:43:06 +00002879 GEN_ERROR("GetElementPtr requires a pointer operand!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002880
2881 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
2882 // indices to uint struct indices for compatibility.
2883 generic_gep_type_iterator<std::vector<Value*>::iterator>
Chris Lattner680aab62006-08-18 17:34:45 +00002884 GTI = gep_type_begin(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end()),
2885 GTE = gep_type_end(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end());
2886 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002887 if (isa<StructType>(*GTI)) // Only change struct indices
Chris Lattner680aab62006-08-18 17:34:45 +00002888 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[-1].ValueList)[i]))
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002889 if (CUI->getType() == Type::UByteTy)
Chris Lattner680aab62006-08-18 17:34:45 +00002890 (*yyvsp[-1].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002891
2892 const Type *IdxTy =
Chris Lattner680aab62006-08-18 17:34:45 +00002893 GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), *yyvsp[-1].ValueList, true);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002894 if (!IdxTy)
Reid Spencer713eedc2006-08-18 08:43:06 +00002895 GEN_ERROR("Index list invalid for constant getelementptr!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002896
2897 std::vector<Constant*> IdxVec;
Chris Lattner680aab62006-08-18 17:34:45 +00002898 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
2899 if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002900 IdxVec.push_back(C);
2901 else
Reid Spencer713eedc2006-08-18 08:43:06 +00002902 GEN_ERROR("Indices to constant getelementptr must be constants!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002903
Chris Lattner680aab62006-08-18 17:34:45 +00002904 delete yyvsp[-1].ValueList;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002905
Chris Lattner680aab62006-08-18 17:34:45 +00002906 yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, IdxVec);
Reid Spencer713eedc2006-08-18 08:43:06 +00002907 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002908 ;
2909 break;}
2910case 109:
2911#line 1558 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2912{
2913 if (yyvsp[-5].ConstVal->getType() != Type::BoolTy)
Reid Spencer713eedc2006-08-18 08:43:06 +00002914 GEN_ERROR("Select condition must be of boolean type!");
Chris Lattner680aab62006-08-18 17:34:45 +00002915 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Reid Spencer713eedc2006-08-18 08:43:06 +00002916 GEN_ERROR("Select operand types must match!");
Chris Lattner680aab62006-08-18 17:34:45 +00002917 yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00002918 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002919 ;
2920 break;}
2921case 110:
2922#line 1566 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2923{
2924 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Reid Spencer713eedc2006-08-18 08:43:06 +00002925 GEN_ERROR("Binary operator types must match!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002926 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
2927 // To retain backward compatibility with these early compilers, we emit a
2928 // cast to the appropriate integer type automatically if we are in the
2929 // broken case. See PR424 for more information.
Chris Lattner680aab62006-08-18 17:34:45 +00002930 if (!isa<PointerType>(yyvsp[-3].ConstVal->getType())) {
2931 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002932 } else {
2933 const Type *IntPtrTy = 0;
2934 switch (CurModule.CurrentModule->getPointerSize()) {
2935 case Module::Pointer32: IntPtrTy = Type::IntTy; break;
2936 case Module::Pointer64: IntPtrTy = Type::LongTy; break;
Reid Spencer713eedc2006-08-18 08:43:06 +00002937 default: GEN_ERROR("invalid pointer binary constant expr!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002938 }
Chris Lattner680aab62006-08-18 17:34:45 +00002939 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, ConstantExpr::getCast(yyvsp[-3].ConstVal, IntPtrTy),
2940 ConstantExpr::getCast(yyvsp[-1].ConstVal, IntPtrTy));
2941 yyval.ConstVal = ConstantExpr::getCast(yyval.ConstVal, yyvsp[-3].ConstVal->getType());
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002942 }
Reid Spencer713eedc2006-08-18 08:43:06 +00002943 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002944 ;
2945 break;}
2946case 111:
2947#line 1588 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2948{
2949 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Reid Spencer713eedc2006-08-18 08:43:06 +00002950 GEN_ERROR("Logical operator types must match!");
Chris Lattner680aab62006-08-18 17:34:45 +00002951 if (!yyvsp[-3].ConstVal->getType()->isIntegral()) {
2952 if (!isa<PackedType>(yyvsp[-3].ConstVal->getType()) ||
2953 !cast<PackedType>(yyvsp[-3].ConstVal->getType())->getElementType()->isIntegral())
Reid Spencer713eedc2006-08-18 08:43:06 +00002954 GEN_ERROR("Logical operator requires integral operands!");
Chris Lattner15f5a182005-12-21 18:31:50 +00002955 }
Chris Lattner680aab62006-08-18 17:34:45 +00002956 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00002957 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002958 ;
2959 break;}
2960case 112:
2961#line 1599 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2962{
2963 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Reid Spencer713eedc2006-08-18 08:43:06 +00002964 GEN_ERROR("setcc operand types must match!");
Chris Lattner680aab62006-08-18 17:34:45 +00002965 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00002966 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002967 ;
2968 break;}
2969case 113:
2970#line 1605 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2971{
2972 if (yyvsp[-1].ConstVal->getType() != Type::UByteTy)
Reid Spencer713eedc2006-08-18 08:43:06 +00002973 GEN_ERROR("Shift count for shift constant must be unsigned byte!");
Chris Lattner680aab62006-08-18 17:34:45 +00002974 if (!yyvsp[-3].ConstVal->getType()->isInteger())
Reid Spencer713eedc2006-08-18 08:43:06 +00002975 GEN_ERROR("Shift constant expression requires integer operand!");
Chris Lattner680aab62006-08-18 17:34:45 +00002976 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].OtherOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00002977 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002978 ;
2979 break;}
2980case 114:
2981#line 1613 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2982{
2983 if (!ExtractElementInst::isValidOperands(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Reid Spencer713eedc2006-08-18 08:43:06 +00002984 GEN_ERROR("Invalid extractelement operands!");
Chris Lattner680aab62006-08-18 17:34:45 +00002985 yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00002986 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002987 ;
2988 break;}
2989case 115:
2990#line 1619 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2991{
2992 if (!InsertElementInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Reid Spencer713eedc2006-08-18 08:43:06 +00002993 GEN_ERROR("Invalid insertelement operands!");
Chris Lattner680aab62006-08-18 17:34:45 +00002994 yyval.ConstVal = ConstantExpr::getInsertElement(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00002995 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00002996 ;
2997 break;}
2998case 116:
2999#line 1625 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3000{
3001 if (!ShuffleVectorInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Reid Spencer713eedc2006-08-18 08:43:06 +00003002 GEN_ERROR("Invalid shufflevector operands!");
Chris Lattner680aab62006-08-18 17:34:45 +00003003 yyval.ConstVal = ConstantExpr::getShuffleVector(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003004 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003005 ;
3006 break;}
3007case 117:
3008#line 1634 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3009{
3010 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003011 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003012 ;
3013 break;}
3014case 118:
3015#line 1638 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3016{
3017 yyval.ConstVector = new std::vector<Constant*>();
3018 yyval.ConstVector->push_back(yyvsp[0].ConstVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003019 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003020 ;
3021 break;}
3022case 119:
3023#line 1646 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3024{ yyval.BoolVal = false; ;
3025 break;}
3026case 120:
3027#line 1646 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3028{ yyval.BoolVal = true; ;
3029 break;}
3030case 121:
3031#line 1656 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3032{
3033 yyval.ModuleVal = ParserResult = yyvsp[0].ModuleVal;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003034 CurModule.ModuleDone();
Reid Spencer713eedc2006-08-18 08:43:06 +00003035 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003036;
3037 break;}
3038case 122:
3039#line 1664 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3040{
3041 yyval.ModuleVal = yyvsp[-1].ModuleVal;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003042 CurFun.FunctionDone();
Reid Spencer713eedc2006-08-18 08:43:06 +00003043 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003044 ;
3045 break;}
3046case 123:
3047#line 1669 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3048{
3049 yyval.ModuleVal = yyvsp[-1].ModuleVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00003050 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003051 ;
3052 break;}
3053case 124:
3054#line 1673 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3055{
3056 yyval.ModuleVal = yyvsp[-3].ModuleVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00003057 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003058 ;
3059 break;}
3060case 125:
3061#line 1677 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3062{
3063 yyval.ModuleVal = yyvsp[-1].ModuleVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00003064 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003065 ;
3066 break;}
3067case 126:
3068#line 1681 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3069{
3070 yyval.ModuleVal = CurModule.CurrentModule;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003071 // Emit an error if there are any unresolved types left.
3072 if (!CurModule.LateResolveTypes.empty()) {
3073 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
Reid Spencer713eedc2006-08-18 08:43:06 +00003074 if (DID.Type == ValID::NameVal) {
3075 GEN_ERROR("Reference to an undefined type: '"+DID.getName() + "'");
3076 } else {
3077 GEN_ERROR("Reference to an undefined type: #" + itostr(DID.Num));
3078 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003079 }
Reid Spencer713eedc2006-08-18 08:43:06 +00003080 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003081 ;
3082 break;}
3083case 127:
3084#line 1696 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3085{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003086 // Eagerly resolve types. This is not an optimization, this is a
3087 // requirement that is due to the fact that we could have this:
3088 //
3089 // %list = type { %list * }
3090 // %list = type { %list * } ; repeated type decl
3091 //
3092 // If types are not resolved eagerly, then the two types will not be
3093 // determined to be the same type!
3094 //
Chris Lattner680aab62006-08-18 17:34:45 +00003095 ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003096
Chris Lattner680aab62006-08-18 17:34:45 +00003097 if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003098 // If this is a named type that is not a redefinition, add it to the slot
3099 // table.
Chris Lattner680aab62006-08-18 17:34:45 +00003100 CurModule.Types.push_back(*yyvsp[0].TypeVal);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003101 }
3102
Chris Lattner680aab62006-08-18 17:34:45 +00003103 delete yyvsp[0].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00003104 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003105 ;
3106 break;}
3107case 128:
3108#line 1717 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3109{ // Function prototypes can be in const pool
Reid Spencer713eedc2006-08-18 08:43:06 +00003110 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003111 ;
3112 break;}
3113case 129:
3114#line 1720 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3115{ // Asm blocks can be in the const pool
Reid Spencer713eedc2006-08-18 08:43:06 +00003116 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003117 ;
3118 break;}
3119case 130:
3120#line 1723 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3121{
3122 if (yyvsp[0].ConstVal == 0) GEN_ERROR("Global value initializer is not a constant!");
3123 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, yyvsp[-2].Linkage, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal);
3124 ;
3125 break;}
3126case 131:
3127#line 1726 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3128{
Chris Lattner11ca4d62005-11-12 18:22:38 +00003129 CurGV = 0;
Reid Spencer713eedc2006-08-18 08:43:06 +00003130 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003131 ;
3132 break;}
3133case 132:
3134#line 1730 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3135{
3136 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalLinkage,
3137 yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0);
3138 delete yyvsp[0].TypeVal;
3139 ;
3140 break;}
3141case 133:
3142#line 1734 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3143{
Chris Lattner11ca4d62005-11-12 18:22:38 +00003144 CurGV = 0;
Reid Spencer713eedc2006-08-18 08:43:06 +00003145 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003146 ;
3147 break;}
3148case 134:
3149#line 1738 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3150{
Reid Spencer713eedc2006-08-18 08:43:06 +00003151 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003152 ;
3153 break;}
3154case 135:
3155#line 1741 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3156{
Reid Spencer713eedc2006-08-18 08:43:06 +00003157 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003158 ;
3159 break;}
3160case 136:
3161#line 1744 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3162{
3163 ;
3164 break;}
3165case 137:
3166#line 1748 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3167{
Chris Lattner8ebd2162006-01-24 04:14:29 +00003168 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Chris Lattner680aab62006-08-18 17:34:45 +00003169 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
3170 std::string NewAsm(yyvsp[0].StrVal, EndStr);
3171 free(yyvsp[0].StrVal);
Chris Lattner8ebd2162006-01-24 04:14:29 +00003172
3173 if (AsmSoFar.empty())
3174 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
3175 else
3176 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Reid Spencer713eedc2006-08-18 08:43:06 +00003177 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003178;
3179 break;}
3180case 138:
3181#line 1761 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3182{ yyval.Endianness = Module::BigEndian; ;
3183 break;}
3184case 139:
3185#line 1762 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3186{ yyval.Endianness = Module::LittleEndian; ;
3187 break;}
3188case 140:
3189#line 1764 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3190{
3191 CurModule.CurrentModule->setEndianness(yyvsp[0].Endianness);
Reid Spencer713eedc2006-08-18 08:43:06 +00003192 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003193 ;
3194 break;}
3195case 141:
3196#line 1768 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3197{
3198 if (yyvsp[0].UInt64Val == 32)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003199 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
Chris Lattner680aab62006-08-18 17:34:45 +00003200 else if (yyvsp[0].UInt64Val == 64)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003201 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
3202 else
Chris Lattner680aab62006-08-18 17:34:45 +00003203 GEN_ERROR("Invalid pointer size: '" + utostr(yyvsp[0].UInt64Val) + "'!");
Reid Spencer713eedc2006-08-18 08:43:06 +00003204 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003205 ;
3206 break;}
3207case 142:
3208#line 1777 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3209{
3210 CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal);
3211 free(yyvsp[0].StrVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003212 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003213 ;
3214 break;}
3215case 144:
3216#line 1785 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3217{
3218 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3219 free(yyvsp[0].StrVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003220 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003221 ;
3222 break;}
3223case 145:
3224#line 1790 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3225{
3226 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3227 free(yyvsp[0].StrVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003228 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003229 ;
3230 break;}
3231case 146:
3232#line 1795 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3233{
Reid Spencer713eedc2006-08-18 08:43:06 +00003234 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003235 ;
3236 break;}
3237case 150:
3238#line 1805 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3239{ yyval.StrVal = 0; ;
3240 break;}
3241case 151:
3242#line 1807 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3243{
3244 if (*yyvsp[-1].TypeVal == Type::VoidTy)
Reid Spencer713eedc2006-08-18 08:43:06 +00003245 GEN_ERROR("void typed arguments are invalid!");
Chris Lattner680aab62006-08-18 17:34:45 +00003246 yyval.ArgVal = new std::pair<PATypeHolder*, char*>(yyvsp[-1].TypeVal, yyvsp[0].StrVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003247 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003248;
3249 break;}
3250case 152:
3251#line 1814 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3252{
3253 yyval.ArgList = yyvsp[-2].ArgList;
3254 yyvsp[-2].ArgList->push_back(*yyvsp[0].ArgVal);
3255 delete yyvsp[0].ArgVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00003256 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003257 ;
3258 break;}
3259case 153:
3260#line 1820 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3261{
3262 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
3263 yyval.ArgList->push_back(*yyvsp[0].ArgVal);
3264 delete yyvsp[0].ArgVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00003265 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003266 ;
3267 break;}
3268case 154:
3269#line 1827 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3270{
3271 yyval.ArgList = yyvsp[0].ArgList;
Reid Spencer713eedc2006-08-18 08:43:06 +00003272 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003273 ;
3274 break;}
3275case 155:
3276#line 1831 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3277{
3278 yyval.ArgList = yyvsp[-2].ArgList;
3279 yyval.ArgList->push_back(std::pair<PATypeHolder*,
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003280 char*>(new PATypeHolder(Type::VoidTy), 0));
Reid Spencer713eedc2006-08-18 08:43:06 +00003281 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003282 ;
3283 break;}
3284case 156:
3285#line 1837 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3286{
3287 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
3288 yyval.ArgList->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0));
Reid Spencer713eedc2006-08-18 08:43:06 +00003289 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003290 ;
3291 break;}
3292case 157:
3293#line 1842 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3294{
3295 yyval.ArgList = 0;
Reid Spencer713eedc2006-08-18 08:43:06 +00003296 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003297 ;
3298 break;}
3299case 158:
3300#line 1848 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3301{
3302 UnEscapeLexed(yyvsp[-5].StrVal);
3303 std::string FunctionName(yyvsp[-5].StrVal);
3304 free(yyvsp[-5].StrVal); // Free strdup'd memory!
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003305
Chris Lattner680aab62006-08-18 17:34:45 +00003306 if (!(*yyvsp[-6].TypeVal)->isFirstClassType() && *yyvsp[-6].TypeVal != Type::VoidTy)
Reid Spencer713eedc2006-08-18 08:43:06 +00003307 GEN_ERROR("LLVM functions cannot return aggregate types!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003308
3309 std::vector<const Type*> ParamTypeList;
Chris Lattner680aab62006-08-18 17:34:45 +00003310 if (yyvsp[-3].ArgList) { // If there are arguments...
3311 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-3].ArgList->begin();
3312 I != yyvsp[-3].ArgList->end(); ++I)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003313 ParamTypeList.push_back(I->first->get());
3314 }
3315
3316 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
3317 if (isVarArg) ParamTypeList.pop_back();
3318
Chris Lattner680aab62006-08-18 17:34:45 +00003319 const FunctionType *FT = FunctionType::get(*yyvsp[-6].TypeVal, ParamTypeList, isVarArg);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003320 const PointerType *PFT = PointerType::get(FT);
Chris Lattner680aab62006-08-18 17:34:45 +00003321 delete yyvsp[-6].TypeVal;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003322
3323 ValID ID;
3324 if (!FunctionName.empty()) {
3325 ID = ValID::create((char*)FunctionName.c_str());
3326 } else {
3327 ID = ValID::create((int)CurModule.Values[PFT].size());
3328 }
3329
3330 Function *Fn = 0;
3331 // See if this function was forward referenced. If so, recycle the object.
3332 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
3333 // Move the function to the end of the list, from whereever it was
3334 // previously inserted.
3335 Fn = cast<Function>(FWRef);
3336 CurModule.CurrentModule->getFunctionList().remove(Fn);
3337 CurModule.CurrentModule->getFunctionList().push_back(Fn);
3338 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
3339 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
3340 // If this is the case, either we need to be a forward decl, or it needs
3341 // to be.
3342 if (!CurFun.isDeclare && !Fn->isExternal())
Reid Spencer713eedc2006-08-18 08:43:06 +00003343 GEN_ERROR("Redefinition of function '" + FunctionName + "'!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003344
3345 // Make sure to strip off any argument names so we can't get conflicts.
3346 if (Fn->isExternal())
3347 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
3348 AI != AE; ++AI)
3349 AI->setName("");
3350
3351 } else { // Not already defined?
3352 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
3353 CurModule.CurrentModule);
3354 InsertValue(Fn, CurModule.Values);
3355 }
3356
3357 CurFun.FunctionStart(Fn);
Chris Lattner680aab62006-08-18 17:34:45 +00003358 Fn->setCallingConv(yyvsp[-7].UIntVal);
3359 Fn->setAlignment(yyvsp[0].UIntVal);
3360 if (yyvsp[-1].StrVal) {
3361 Fn->setSection(yyvsp[-1].StrVal);
3362 free(yyvsp[-1].StrVal);
Chris Lattnera0c20b42005-11-12 00:11:49 +00003363 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003364
3365 // Add all of the arguments we parsed to the function...
Chris Lattner680aab62006-08-18 17:34:45 +00003366 if (yyvsp[-3].ArgList) { // Is null if empty...
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003367 if (isVarArg) { // Nuke the last entry
Chris Lattner680aab62006-08-18 17:34:45 +00003368 assert(yyvsp[-3].ArgList->back().first->get() == Type::VoidTy && yyvsp[-3].ArgList->back().second == 0&&
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003369 "Not a varargs marker!");
Chris Lattner680aab62006-08-18 17:34:45 +00003370 delete yyvsp[-3].ArgList->back().first;
3371 yyvsp[-3].ArgList->pop_back(); // Delete the last entry
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003372 }
3373 Function::arg_iterator ArgIt = Fn->arg_begin();
Chris Lattner680aab62006-08-18 17:34:45 +00003374 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-3].ArgList->begin();
3375 I != yyvsp[-3].ArgList->end(); ++I, ++ArgIt) {
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003376 delete I->first; // Delete the typeholder...
3377
3378 setValueName(ArgIt, I->second); // Insert arg into symtab...
3379 InsertValue(ArgIt);
3380 }
3381
Chris Lattner680aab62006-08-18 17:34:45 +00003382 delete yyvsp[-3].ArgList; // We're now done with the argument list
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003383 }
Reid Spencer713eedc2006-08-18 08:43:06 +00003384 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003385;
3386 break;}
3387case 161:
3388#line 1936 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3389{
3390 yyval.FunctionVal = CurFun.CurrentFunction;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003391
3392 // Make sure that we keep track of the linkage type even if there was a
3393 // previous "declare".
Chris Lattner680aab62006-08-18 17:34:45 +00003394 yyval.FunctionVal->setLinkage(yyvsp[-2].Linkage);
3395;
3396 break;}
3397case 164:
3398#line 1946 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3399{
3400 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00003401 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003402;
3403 break;}
3404case 165:
3405#line 1951 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3406{ CurFun.isDeclare = true; ;
3407 break;}
3408case 166:
3409#line 1951 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3410{
3411 yyval.FunctionVal = CurFun.CurrentFunction;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003412 CurFun.FunctionDone();
Reid Spencer713eedc2006-08-18 08:43:06 +00003413 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003414;
3415 break;}
3416case 167:
3417#line 1961 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3418{
3419 yyval.BoolVal = false;
Reid Spencer713eedc2006-08-18 08:43:06 +00003420 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003421 ;
3422 break;}
3423case 168:
3424#line 1965 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3425{
3426 yyval.BoolVal = true;
Reid Spencer713eedc2006-08-18 08:43:06 +00003427 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003428 ;
3429 break;}
3430case 169:
3431#line 1970 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3432{ // A reference to a direct constant
3433 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
Reid Spencer713eedc2006-08-18 08:43:06 +00003434 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003435 ;
3436 break;}
3437case 170:
3438#line 1974 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3439{
3440 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
Reid Spencer713eedc2006-08-18 08:43:06 +00003441 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003442 ;
3443 break;}
3444case 171:
3445#line 1978 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3446{ // Perhaps it's an FP constant?
3447 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003448 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003449 ;
3450 break;}
3451case 172:
3452#line 1982 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3453{
3454 yyval.ValIDVal = ValID::create(ConstantBool::True);
Reid Spencer713eedc2006-08-18 08:43:06 +00003455 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003456 ;
3457 break;}
3458case 173:
3459#line 1986 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3460{
3461 yyval.ValIDVal = ValID::create(ConstantBool::False);
Reid Spencer713eedc2006-08-18 08:43:06 +00003462 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003463 ;
3464 break;}
3465case 174:
3466#line 1990 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3467{
3468 yyval.ValIDVal = ValID::createNull();
Reid Spencer713eedc2006-08-18 08:43:06 +00003469 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003470 ;
3471 break;}
3472case 175:
3473#line 1994 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3474{
3475 yyval.ValIDVal = ValID::createUndef();
Reid Spencer713eedc2006-08-18 08:43:06 +00003476 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003477 ;
3478 break;}
3479case 176:
3480#line 1998 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3481{ // A vector zero constant.
3482 yyval.ValIDVal = ValID::createZeroInit();
Reid Spencer713eedc2006-08-18 08:43:06 +00003483 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003484 ;
3485 break;}
3486case 177:
3487#line 2002 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3488{ // Nonempty unsized packed vector
3489 const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
3490 int NumElements = yyvsp[-1].ConstVector->size();
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003491
3492 PackedType* pt = PackedType::get(ETy, NumElements);
3493 PATypeHolder* PTy = new PATypeHolder(
3494 HandleUpRefs(
3495 PackedType::get(
3496 ETy,
3497 NumElements)
3498 )
3499 );
3500
3501 // Verify all elements are correct type!
Chris Lattner680aab62006-08-18 17:34:45 +00003502 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3503 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Reid Spencer713eedc2006-08-18 08:43:06 +00003504 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003505 ETy->getDescription() +"' as required!\nIt is of type '" +
Chris Lattner680aab62006-08-18 17:34:45 +00003506 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003507 }
3508
Chris Lattner680aab62006-08-18 17:34:45 +00003509 yyval.ValIDVal = ValID::create(ConstantPacked::get(pt, *yyvsp[-1].ConstVector));
3510 delete PTy; delete yyvsp[-1].ConstVector;
Reid Spencer713eedc2006-08-18 08:43:06 +00003511 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003512 ;
3513 break;}
3514case 178:
3515#line 2027 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3516{
3517 yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003518 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003519 ;
3520 break;}
3521case 179:
3522#line 2031 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3523{
3524 char *End = UnEscapeLexed(yyvsp[-2].StrVal, true);
3525 std::string AsmStr = std::string(yyvsp[-2].StrVal, End);
3526 End = UnEscapeLexed(yyvsp[0].StrVal, true);
3527 std::string Constraints = std::string(yyvsp[0].StrVal, End);
3528 yyval.ValIDVal = ValID::createInlineAsm(AsmStr, Constraints, yyvsp[-3].BoolVal);
3529 free(yyvsp[-2].StrVal);
3530 free(yyvsp[0].StrVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003531 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003532 ;
3533 break;}
3534case 180:
3535#line 2045 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3536{ // Is it an integer reference...?
3537 yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003538 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003539 ;
3540 break;}
3541case 181:
3542#line 2049 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3543{ // Is it a named reference...?
3544 yyval.ValIDVal = ValID::create(yyvsp[0].StrVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003545 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003546 ;
3547 break;}
3548case 184:
3549#line 2061 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3550{
3551 yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); delete yyvsp[-1].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00003552 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003553 ;
3554 break;}
3555case 185:
3556#line 2066 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3557{
3558 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00003559 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003560 ;
3561 break;}
3562case 186:
3563#line 2070 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3564{ // Do not allow functions with 0 basic blocks
3565 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00003566 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003567 ;
3568 break;}
3569case 187:
3570#line 2079 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3571{
3572 setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
3573 InsertValue(yyvsp[0].TermInstVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003574
Chris Lattner680aab62006-08-18 17:34:45 +00003575 yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
3576 InsertValue(yyvsp[-2].BasicBlockVal);
3577 yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00003578 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003579 ;
3580 break;}
3581case 188:
3582#line 2089 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3583{
3584 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
3585 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00003586 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003587 ;
3588 break;}
3589case 189:
3590#line 2094 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3591{
3592 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003593
3594 // Make sure to move the basic block to the correct location in the
3595 // function, instead of leaving it inserted wherever it was first
3596 // referenced.
3597 Function::BasicBlockListType &BBL =
3598 CurFun.CurrentFunction->getBasicBlockList();
Chris Lattner680aab62006-08-18 17:34:45 +00003599 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003600 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003601 ;
3602 break;}
3603case 190:
3604#line 2105 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3605{
3606 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create(yyvsp[0].StrVal), true);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003607
3608 // Make sure to move the basic block to the correct location in the
3609 // function, instead of leaving it inserted wherever it was first
3610 // referenced.
3611 Function::BasicBlockListType &BBL =
3612 CurFun.CurrentFunction->getBasicBlockList();
Chris Lattner680aab62006-08-18 17:34:45 +00003613 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003614 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003615 ;
3616 break;}
3617case 191:
3618#line 2117 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3619{ // Return with a result...
3620 yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003621 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003622 ;
3623 break;}
3624case 192:
3625#line 2121 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3626{ // Return with no result...
3627 yyval.TermInstVal = new ReturnInst();
Reid Spencer713eedc2006-08-18 08:43:06 +00003628 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003629 ;
3630 break;}
3631case 193:
3632#line 2125 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3633{ // Unconditional Branch...
3634 yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[0].ValIDVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00003635 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003636 ;
3637 break;}
3638case 194:
3639#line 2129 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3640{
3641 yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[-3].ValIDVal), getBBVal(yyvsp[0].ValIDVal), getVal(Type::BoolTy, yyvsp[-6].ValIDVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00003642 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003643 ;
3644 break;}
3645case 195:
3646#line 2133 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3647{
3648 SwitchInst *S = new SwitchInst(getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal), getBBVal(yyvsp[-3].ValIDVal), yyvsp[-1].JumpTable->size());
3649 yyval.TermInstVal = S;
Reid Spencer713eedc2006-08-18 08:43:06 +00003650
Chris Lattner680aab62006-08-18 17:34:45 +00003651 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
3652 E = yyvsp[-1].JumpTable->end();
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003653 for (; I != E; ++I) {
3654 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
3655 S->addCase(CI, I->second);
3656 else
Reid Spencer713eedc2006-08-18 08:43:06 +00003657 GEN_ERROR("Switch case is constant, but not a simple integer!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003658 }
Chris Lattner680aab62006-08-18 17:34:45 +00003659 delete yyvsp[-1].JumpTable;
Reid Spencer713eedc2006-08-18 08:43:06 +00003660 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003661 ;
3662 break;}
3663case 196:
3664#line 2148 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3665{
3666 SwitchInst *S = new SwitchInst(getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal), getBBVal(yyvsp[-2].ValIDVal), 0);
3667 yyval.TermInstVal = S;
Reid Spencer713eedc2006-08-18 08:43:06 +00003668 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003669 ;
3670 break;}
3671case 197:
3672#line 2154 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3673{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003674 const PointerType *PFTy;
3675 const FunctionType *Ty;
3676
Chris Lattner680aab62006-08-18 17:34:45 +00003677 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-10].TypeVal->get())) ||
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003678 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3679 // Pull out the types of all of the arguments...
3680 std::vector<const Type*> ParamTypes;
Chris Lattner680aab62006-08-18 17:34:45 +00003681 if (yyvsp[-7].ValueList) {
3682 for (std::vector<Value*>::iterator I = yyvsp[-7].ValueList->begin(), E = yyvsp[-7].ValueList->end();
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003683 I != E; ++I)
3684 ParamTypes.push_back((*I)->getType());
3685 }
3686
3687 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3688 if (isVarArg) ParamTypes.pop_back();
3689
Chris Lattner680aab62006-08-18 17:34:45 +00003690 Ty = FunctionType::get(yyvsp[-10].TypeVal->get(), ParamTypes, isVarArg);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003691 PFTy = PointerType::get(Ty);
3692 }
3693
Chris Lattner680aab62006-08-18 17:34:45 +00003694 Value *V = getVal(PFTy, yyvsp[-9].ValIDVal); // Get the function we're calling...
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003695
Chris Lattner680aab62006-08-18 17:34:45 +00003696 BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
3697 BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003698
3699 // Create the call node...
Chris Lattner680aab62006-08-18 17:34:45 +00003700 if (!yyvsp[-7].ValueList) { // Has no arguments?
3701 yyval.TermInstVal = new InvokeInst(V, Normal, Except, std::vector<Value*>());
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003702 } else { // Has arguments?
3703 // Loop through FunctionType's arguments and ensure they are specified
3704 // correctly!
3705 //
3706 FunctionType::param_iterator I = Ty->param_begin();
3707 FunctionType::param_iterator E = Ty->param_end();
Chris Lattner680aab62006-08-18 17:34:45 +00003708 std::vector<Value*>::iterator ArgI = yyvsp[-7].ValueList->begin(), ArgE = yyvsp[-7].ValueList->end();
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003709
3710 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3711 if ((*ArgI)->getType() != *I)
Reid Spencer713eedc2006-08-18 08:43:06 +00003712 GEN_ERROR("Parameter " +(*ArgI)->getName()+ " is not of type '" +
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003713 (*I)->getDescription() + "'!");
3714
3715 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
Reid Spencer713eedc2006-08-18 08:43:06 +00003716 GEN_ERROR("Invalid number of parameters detected!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003717
Chris Lattner680aab62006-08-18 17:34:45 +00003718 yyval.TermInstVal = new InvokeInst(V, Normal, Except, *yyvsp[-7].ValueList);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003719 }
Chris Lattner680aab62006-08-18 17:34:45 +00003720 cast<InvokeInst>(yyval.TermInstVal)->setCallingConv(yyvsp[-11].UIntVal);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003721
Chris Lattner680aab62006-08-18 17:34:45 +00003722 delete yyvsp[-10].TypeVal;
3723 delete yyvsp[-7].ValueList;
Reid Spencer713eedc2006-08-18 08:43:06 +00003724 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003725 ;
3726 break;}
3727case 198:
3728#line 2207 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3729{
3730 yyval.TermInstVal = new UnwindInst();
Reid Spencer713eedc2006-08-18 08:43:06 +00003731 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003732 ;
3733 break;}
3734case 199:
3735#line 2211 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3736{
3737 yyval.TermInstVal = new UnreachableInst();
Reid Spencer713eedc2006-08-18 08:43:06 +00003738 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003739 ;
3740 break;}
3741case 200:
3742#line 2218 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3743{
3744 yyval.JumpTable = yyvsp[-5].JumpTable;
3745 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00003746 if (V == 0)
3747 GEN_ERROR("May only switch on a constant pool value!");
3748
Chris Lattner680aab62006-08-18 17:34:45 +00003749 yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
Reid Spencer713eedc2006-08-18 08:43:06 +00003750 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003751 ;
3752 break;}
3753case 201:
3754#line 2227 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3755{
3756 yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
3757 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003758
3759 if (V == 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00003760 GEN_ERROR("May only switch on a constant pool value!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003761
Chris Lattner680aab62006-08-18 17:34:45 +00003762 yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
Reid Spencer713eedc2006-08-18 08:43:06 +00003763 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003764 ;
3765 break;}
3766case 202:
3767#line 2238 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3768{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003769 // Is this definition named?? if so, assign the name...
Chris Lattner680aab62006-08-18 17:34:45 +00003770 setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
3771 InsertValue(yyvsp[0].InstVal);
3772 yyval.InstVal = yyvsp[0].InstVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00003773 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003774;
3775 break;}
3776case 203:
3777#line 2246 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3778{ // Used for PHI nodes
3779 yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
3780 yyval.PHIList->push_back(std::make_pair(getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal), getBBVal(yyvsp[-1].ValIDVal)));
3781 delete yyvsp[-5].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00003782 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003783 ;
3784 break;}
3785case 204:
3786#line 2252 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3787{
3788 yyval.PHIList = yyvsp[-6].PHIList;
3789 yyvsp[-6].PHIList->push_back(std::make_pair(getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal),
3790 getBBVal(yyvsp[-1].ValIDVal)));
Reid Spencer713eedc2006-08-18 08:43:06 +00003791 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003792 ;
3793 break;}
3794case 205:
3795#line 2260 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3796{ // Used for call statements, and memory insts...
3797 yyval.ValueList = new std::vector<Value*>();
3798 yyval.ValueList->push_back(yyvsp[0].ValueVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003799 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003800 ;
3801 break;}
3802case 206:
3803#line 2265 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3804{
3805 yyval.ValueList = yyvsp[-2].ValueList;
3806 yyvsp[-2].ValueList->push_back(yyvsp[0].ValueVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003807 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003808 ;
3809 break;}
3810case 208:
3811#line 2272 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3812{ yyval.ValueList = 0; ;
3813 break;}
3814case 209:
3815#line 2274 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3816{
3817 yyval.BoolVal = true;
Reid Spencer713eedc2006-08-18 08:43:06 +00003818 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003819 ;
3820 break;}
3821case 210:
3822#line 2278 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3823{
3824 yyval.BoolVal = false;
Reid Spencer713eedc2006-08-18 08:43:06 +00003825 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003826 ;
3827 break;}
3828case 211:
3829#line 2285 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3830{
3831 if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
3832 !isa<PackedType>((*yyvsp[-3].TypeVal).get()))
Reid Spencer713eedc2006-08-18 08:43:06 +00003833 GEN_ERROR(
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003834 "Arithmetic operator requires integer, FP, or packed operands!");
Chris Lattner680aab62006-08-18 17:34:45 +00003835 if (isa<PackedType>((*yyvsp[-3].TypeVal).get()) && yyvsp[-4].BinaryOpVal == Instruction::Rem)
Reid Spencer713eedc2006-08-18 08:43:06 +00003836 GEN_ERROR("Rem not supported on packed types!");
Chris Lattner680aab62006-08-18 17:34:45 +00003837 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3838 if (yyval.InstVal == 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00003839 GEN_ERROR("binary operator returned null!");
Chris Lattner680aab62006-08-18 17:34:45 +00003840 delete yyvsp[-3].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00003841 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003842 ;
3843 break;}
3844case 212:
3845#line 2298 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3846{
3847 if (!(*yyvsp[-3].TypeVal)->isIntegral()) {
3848 if (!isa<PackedType>(yyvsp[-3].TypeVal->get()) ||
3849 !cast<PackedType>(yyvsp[-3].TypeVal->get())->getElementType()->isIntegral())
Reid Spencer713eedc2006-08-18 08:43:06 +00003850 GEN_ERROR("Logical operator requires integral operands!");
Chris Lattner15f5a182005-12-21 18:31:50 +00003851 }
Chris Lattner680aab62006-08-18 17:34:45 +00003852 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3853 if (yyval.InstVal == 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00003854 GEN_ERROR("binary operator returned null!");
Chris Lattner680aab62006-08-18 17:34:45 +00003855 delete yyvsp[-3].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00003856 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003857 ;
3858 break;}
3859case 213:
3860#line 2310 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3861{
3862 if(isa<PackedType>((*yyvsp[-3].TypeVal).get())) {
Reid Spencer713eedc2006-08-18 08:43:06 +00003863 GEN_ERROR(
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003864 "PackedTypes currently not supported in setcc instructions!");
3865 }
Chris Lattner680aab62006-08-18 17:34:45 +00003866 yyval.InstVal = new SetCondInst(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3867 if (yyval.InstVal == 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00003868 GEN_ERROR("binary operator returned null!");
Chris Lattner680aab62006-08-18 17:34:45 +00003869 delete yyvsp[-3].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00003870 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003871 ;
3872 break;}
3873case 214:
3874#line 2321 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3875{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003876 std::cerr << "WARNING: Use of eliminated 'not' instruction:"
3877 << " Replacing with 'xor'.\n";
3878
Chris Lattner680aab62006-08-18 17:34:45 +00003879 Value *Ones = ConstantIntegral::getAllOnesValue(yyvsp[0].ValueVal->getType());
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003880 if (Ones == 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00003881 GEN_ERROR("Expected integral type for not instruction!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003882
Chris Lattner680aab62006-08-18 17:34:45 +00003883 yyval.InstVal = BinaryOperator::create(Instruction::Xor, yyvsp[0].ValueVal, Ones);
3884 if (yyval.InstVal == 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00003885 GEN_ERROR("Could not create a xor instruction!");
3886 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003887 ;
3888 break;}
3889case 215:
3890#line 2334 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3891{
3892 if (yyvsp[0].ValueVal->getType() != Type::UByteTy)
Reid Spencer713eedc2006-08-18 08:43:06 +00003893 GEN_ERROR("Shift amount must be ubyte!");
Chris Lattner680aab62006-08-18 17:34:45 +00003894 if (!yyvsp[-2].ValueVal->getType()->isInteger())
Reid Spencer713eedc2006-08-18 08:43:06 +00003895 GEN_ERROR("Shift constant expression requires integer operand!");
Chris Lattner680aab62006-08-18 17:34:45 +00003896 yyval.InstVal = new ShiftInst(yyvsp[-3].OtherOpVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003897 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003898 ;
3899 break;}
3900case 216:
3901#line 2342 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3902{
3903 if (!yyvsp[0].TypeVal->get()->isFirstClassType())
Reid Spencer713eedc2006-08-18 08:43:06 +00003904 GEN_ERROR("cast instruction to a non-primitive type: '" +
Chris Lattner680aab62006-08-18 17:34:45 +00003905 yyvsp[0].TypeVal->get()->getDescription() + "'!");
3906 yyval.InstVal = new CastInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
3907 delete yyvsp[0].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00003908 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003909 ;
3910 break;}
3911case 217:
3912#line 2350 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3913{
3914 if (yyvsp[-4].ValueVal->getType() != Type::BoolTy)
Reid Spencer713eedc2006-08-18 08:43:06 +00003915 GEN_ERROR("select condition must be boolean!");
Chris Lattner680aab62006-08-18 17:34:45 +00003916 if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
Reid Spencer713eedc2006-08-18 08:43:06 +00003917 GEN_ERROR("select value types should match!");
Chris Lattner680aab62006-08-18 17:34:45 +00003918 yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003919 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003920 ;
3921 break;}
3922case 218:
3923#line 2358 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3924{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003925 NewVarArgs = true;
Chris Lattner680aab62006-08-18 17:34:45 +00003926 yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
3927 delete yyvsp[0].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00003928 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003929 ;
3930 break;}
3931case 219:
3932#line 2364 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3933{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003934 ObsoleteVarArgs = true;
Chris Lattner680aab62006-08-18 17:34:45 +00003935 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003936 Function* NF = CurModule.CurrentModule->
Jeff Cohen11e26b52005-10-23 04:37:20 +00003937 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003938
3939 //b = vaarg a, t ->
3940 //foo = alloca 1 of t
3941 //bar = vacopy a
3942 //store bar -> foo
3943 //b = vaarg foo, t
3944 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
3945 CurBB->getInstList().push_back(foo);
Chris Lattner680aab62006-08-18 17:34:45 +00003946 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003947 CurBB->getInstList().push_back(bar);
3948 CurBB->getInstList().push_back(new StoreInst(bar, foo));
Chris Lattner680aab62006-08-18 17:34:45 +00003949 yyval.InstVal = new VAArgInst(foo, *yyvsp[0].TypeVal);
3950 delete yyvsp[0].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00003951 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003952 ;
3953 break;}
3954case 220:
3955#line 2384 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3956{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003957 ObsoleteVarArgs = true;
Chris Lattner680aab62006-08-18 17:34:45 +00003958 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003959 Function* NF = CurModule.CurrentModule->
Jeff Cohen11e26b52005-10-23 04:37:20 +00003960 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003961
3962 //b = vanext a, t ->
3963 //foo = alloca 1 of t
3964 //bar = vacopy a
3965 //store bar -> foo
3966 //tmp = vaarg foo, t
3967 //b = load foo
3968 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
3969 CurBB->getInstList().push_back(foo);
Chris Lattner680aab62006-08-18 17:34:45 +00003970 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003971 CurBB->getInstList().push_back(bar);
3972 CurBB->getInstList().push_back(new StoreInst(bar, foo));
Chris Lattner680aab62006-08-18 17:34:45 +00003973 Instruction* tmp = new VAArgInst(foo, *yyvsp[0].TypeVal);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003974 CurBB->getInstList().push_back(tmp);
Chris Lattner680aab62006-08-18 17:34:45 +00003975 yyval.InstVal = new LoadInst(foo);
3976 delete yyvsp[0].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00003977 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003978 ;
3979 break;}
3980case 221:
3981#line 2407 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3982{
3983 if (!ExtractElementInst::isValidOperands(yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Reid Spencer713eedc2006-08-18 08:43:06 +00003984 GEN_ERROR("Invalid extractelement operands!");
Chris Lattner680aab62006-08-18 17:34:45 +00003985 yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003986 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003987 ;
3988 break;}
3989case 222:
3990#line 2413 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3991{
3992 if (!InsertElementInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Reid Spencer713eedc2006-08-18 08:43:06 +00003993 GEN_ERROR("Invalid insertelement operands!");
Chris Lattner680aab62006-08-18 17:34:45 +00003994 yyval.InstVal = new InsertElementInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003995 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00003996 ;
3997 break;}
3998case 223:
3999#line 2419 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4000{
4001 if (!ShuffleVectorInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Reid Spencer713eedc2006-08-18 08:43:06 +00004002 GEN_ERROR("Invalid shufflevector operands!");
Chris Lattner680aab62006-08-18 17:34:45 +00004003 yyval.InstVal = new ShuffleVectorInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00004004 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00004005 ;
4006 break;}
4007case 224:
4008#line 2425 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4009{
4010 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004011 if (!Ty->isFirstClassType())
Reid Spencer713eedc2006-08-18 08:43:06 +00004012 GEN_ERROR("PHI node operands must be of first class type!");
Chris Lattner680aab62006-08-18 17:34:45 +00004013 yyval.InstVal = new PHINode(Ty);
4014 ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
4015 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
4016 if (yyvsp[0].PHIList->front().first->getType() != Ty)
Reid Spencer713eedc2006-08-18 08:43:06 +00004017 GEN_ERROR("All elements of a PHI node must be of the same type!");
Chris Lattner680aab62006-08-18 17:34:45 +00004018 cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
4019 yyvsp[0].PHIList->pop_front();
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004020 }
Chris Lattner680aab62006-08-18 17:34:45 +00004021 delete yyvsp[0].PHIList; // Free the list...
Reid Spencer713eedc2006-08-18 08:43:06 +00004022 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00004023 ;
4024 break;}
4025case 225:
4026#line 2440 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4027{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004028 const PointerType *PFTy;
4029 const FunctionType *Ty;
4030
Chris Lattner680aab62006-08-18 17:34:45 +00004031 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-4].TypeVal->get())) ||
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004032 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4033 // Pull out the types of all of the arguments...
4034 std::vector<const Type*> ParamTypes;
Chris Lattner680aab62006-08-18 17:34:45 +00004035 if (yyvsp[-1].ValueList) {
4036 for (std::vector<Value*>::iterator I = yyvsp[-1].ValueList->begin(), E = yyvsp[-1].ValueList->end();
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004037 I != E; ++I)
4038 ParamTypes.push_back((*I)->getType());
4039 }
4040
4041 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
4042 if (isVarArg) ParamTypes.pop_back();
4043
Chris Lattner680aab62006-08-18 17:34:45 +00004044 if (!(*yyvsp[-4].TypeVal)->isFirstClassType() && *yyvsp[-4].TypeVal != Type::VoidTy)
Reid Spencer713eedc2006-08-18 08:43:06 +00004045 GEN_ERROR("LLVM functions cannot return aggregate types!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004046
Chris Lattner680aab62006-08-18 17:34:45 +00004047 Ty = FunctionType::get(yyvsp[-4].TypeVal->get(), ParamTypes, isVarArg);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004048 PFTy = PointerType::get(Ty);
4049 }
4050
Chris Lattner680aab62006-08-18 17:34:45 +00004051 Value *V = getVal(PFTy, yyvsp[-3].ValIDVal); // Get the function we're calling...
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004052
4053 // Create the call node...
Chris Lattner680aab62006-08-18 17:34:45 +00004054 if (!yyvsp[-1].ValueList) { // Has no arguments?
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004055 // Make sure no arguments is a good thing!
4056 if (Ty->getNumParams() != 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00004057 GEN_ERROR("No arguments passed to a function that "
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004058 "expects arguments!");
4059
Chris Lattner680aab62006-08-18 17:34:45 +00004060 yyval.InstVal = new CallInst(V, std::vector<Value*>());
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004061 } else { // Has arguments?
4062 // Loop through FunctionType's arguments and ensure they are specified
4063 // correctly!
4064 //
4065 FunctionType::param_iterator I = Ty->param_begin();
4066 FunctionType::param_iterator E = Ty->param_end();
Chris Lattner680aab62006-08-18 17:34:45 +00004067 std::vector<Value*>::iterator ArgI = yyvsp[-1].ValueList->begin(), ArgE = yyvsp[-1].ValueList->end();
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004068
4069 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
4070 if ((*ArgI)->getType() != *I)
Reid Spencer713eedc2006-08-18 08:43:06 +00004071 GEN_ERROR("Parameter " +(*ArgI)->getName()+ " is not of type '" +
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004072 (*I)->getDescription() + "'!");
4073
4074 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
Reid Spencer713eedc2006-08-18 08:43:06 +00004075 GEN_ERROR("Invalid number of parameters detected!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004076
Chris Lattner680aab62006-08-18 17:34:45 +00004077 yyval.InstVal = new CallInst(V, *yyvsp[-1].ValueList);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004078 }
Chris Lattner680aab62006-08-18 17:34:45 +00004079 cast<CallInst>(yyval.InstVal)->setTailCall(yyvsp[-6].BoolVal);
4080 cast<CallInst>(yyval.InstVal)->setCallingConv(yyvsp[-5].UIntVal);
4081 delete yyvsp[-4].TypeVal;
4082 delete yyvsp[-1].ValueList;
Reid Spencer713eedc2006-08-18 08:43:06 +00004083 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00004084 ;
4085 break;}
4086case 226:
4087#line 2498 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4088{
4089 yyval.InstVal = yyvsp[0].InstVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00004090 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00004091 ;
4092 break;}
4093case 227:
4094#line 2505 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4095{
4096 yyval.ValueList = yyvsp[0].ValueList;
Reid Spencer713eedc2006-08-18 08:43:06 +00004097 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00004098 ;
4099 break;}
4100case 228:
4101#line 2508 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4102{
4103 yyval.ValueList = new std::vector<Value*>();
Reid Spencer713eedc2006-08-18 08:43:06 +00004104 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00004105 ;
4106 break;}
4107case 229:
4108#line 2513 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4109{
4110 yyval.BoolVal = true;
Reid Spencer713eedc2006-08-18 08:43:06 +00004111 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00004112 ;
4113 break;}
4114case 230:
4115#line 2517 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4116{
4117 yyval.BoolVal = false;
Reid Spencer713eedc2006-08-18 08:43:06 +00004118 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00004119 ;
4120 break;}
4121case 231:
4122#line 2524 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4123{
4124 yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
4125 delete yyvsp[-1].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00004126 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00004127 ;
4128 break;}
4129case 232:
4130#line 2529 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4131{
4132 yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal);
4133 delete yyvsp[-4].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00004134 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00004135 ;
4136 break;}
4137case 233:
4138#line 2534 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4139{
4140 yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
4141 delete yyvsp[-1].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00004142 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00004143 ;
4144 break;}
4145case 234:
4146#line 2539 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4147{
4148 yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal);
4149 delete yyvsp[-4].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00004150 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00004151 ;
4152 break;}
4153case 235:
4154#line 2544 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4155{
4156 if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
Reid Spencer713eedc2006-08-18 08:43:06 +00004157 GEN_ERROR("Trying to free nonpointer type " +
Chris Lattner680aab62006-08-18 17:34:45 +00004158 yyvsp[0].ValueVal->getType()->getDescription() + "!");
4159 yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00004160 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00004161 ;
4162 break;}
4163case 236:
4164#line 2552 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4165{
4166 if (!isa<PointerType>(yyvsp[-1].TypeVal->get()))
Reid Spencer713eedc2006-08-18 08:43:06 +00004167 GEN_ERROR("Can't load from nonpointer type: " +
Chris Lattner680aab62006-08-18 17:34:45 +00004168 (*yyvsp[-1].TypeVal)->getDescription());
4169 if (!cast<PointerType>(yyvsp[-1].TypeVal->get())->getElementType()->isFirstClassType())
Reid Spencer713eedc2006-08-18 08:43:06 +00004170 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Chris Lattner680aab62006-08-18 17:34:45 +00004171 (*yyvsp[-1].TypeVal)->getDescription());
4172 yyval.InstVal = new LoadInst(getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), "", yyvsp[-3].BoolVal);
4173 delete yyvsp[-1].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00004174 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00004175 ;
4176 break;}
4177case 237:
4178#line 2563 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4179{
4180 const PointerType *PT = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004181 if (!PT)
Reid Spencer713eedc2006-08-18 08:43:06 +00004182 GEN_ERROR("Can't store to a nonpointer type: " +
Chris Lattner680aab62006-08-18 17:34:45 +00004183 (*yyvsp[-1].TypeVal)->getDescription());
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004184 const Type *ElTy = PT->getElementType();
Chris Lattner680aab62006-08-18 17:34:45 +00004185 if (ElTy != yyvsp[-3].ValueVal->getType())
4186 GEN_ERROR("Can't store '" + yyvsp[-3].ValueVal->getType()->getDescription() +
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004187 "' into space of type '" + ElTy->getDescription() + "'!");
4188
Chris Lattner680aab62006-08-18 17:34:45 +00004189 yyval.InstVal = new StoreInst(yyvsp[-3].ValueVal, getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), yyvsp[-5].BoolVal);
4190 delete yyvsp[-1].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00004191 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00004192 ;
4193 break;}
4194case 238:
4195#line 2577 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4196{
4197 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
Reid Spencer713eedc2006-08-18 08:43:06 +00004198 GEN_ERROR("getelementptr insn requires pointer operand!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004199
4200 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
4201 // indices to uint struct indices for compatibility.
4202 generic_gep_type_iterator<std::vector<Value*>::iterator>
Chris Lattner680aab62006-08-18 17:34:45 +00004203 GTI = gep_type_begin(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end()),
4204 GTE = gep_type_end(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end());
4205 for (unsigned i = 0, e = yyvsp[0].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004206 if (isa<StructType>(*GTI)) // Only change struct indices
Chris Lattner680aab62006-08-18 17:34:45 +00004207 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[0].ValueList)[i]))
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004208 if (CUI->getType() == Type::UByteTy)
Chris Lattner680aab62006-08-18 17:34:45 +00004209 (*yyvsp[0].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004210
Chris Lattner680aab62006-08-18 17:34:45 +00004211 if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, *yyvsp[0].ValueList, true))
Reid Spencer713eedc2006-08-18 08:43:06 +00004212 GEN_ERROR("Invalid getelementptr indices for type '" +
Chris Lattner680aab62006-08-18 17:34:45 +00004213 (*yyvsp[-2].TypeVal)->getDescription()+ "'!");
4214 yyval.InstVal = new GetElementPtrInst(getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal), *yyvsp[0].ValueList);
4215 delete yyvsp[-2].TypeVal; delete yyvsp[0].ValueList;
Reid Spencer713eedc2006-08-18 08:43:06 +00004216 CHECK_FOR_ERROR
Chris Lattner680aab62006-08-18 17:34:45 +00004217 ;
4218 break;}
4219}
4220 /* the action file gets copied in in place of this dollarsign */
4221#line 543 "/usr/share/bison.simple"
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004222
4223 yyvsp -= yylen;
4224 yyssp -= yylen;
Chris Lattner680aab62006-08-18 17:34:45 +00004225#ifdef YYLSP_NEEDED
4226 yylsp -= yylen;
4227#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004228
Chris Lattner680aab62006-08-18 17:34:45 +00004229#if YYDEBUG != 0
4230 if (yydebug)
4231 {
4232 short *ssp1 = yyss - 1;
4233 fprintf (stderr, "state stack now");
4234 while (ssp1 != yyssp)
4235 fprintf (stderr, " %d", *++ssp1);
4236 fprintf (stderr, "\n");
4237 }
4238#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004239
4240 *++yyvsp = yyval;
4241
Chris Lattner680aab62006-08-18 17:34:45 +00004242#ifdef YYLSP_NEEDED
4243 yylsp++;
4244 if (yylen == 0)
4245 {
4246 yylsp->first_line = yylloc.first_line;
4247 yylsp->first_column = yylloc.first_column;
4248 yylsp->last_line = (yylsp-1)->last_line;
4249 yylsp->last_column = (yylsp-1)->last_column;
4250 yylsp->text = 0;
4251 }
4252 else
4253 {
4254 yylsp->last_line = (yylsp+yylen-1)->last_line;
4255 yylsp->last_column = (yylsp+yylen-1)->last_column;
4256 }
4257#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004258
Chris Lattner680aab62006-08-18 17:34:45 +00004259 /* Now "shift" the result of the reduction.
4260 Determine what state that goes to,
4261 based on the state we popped back to
4262 and the rule number reduced by. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004263
4264 yyn = yyr1[yyn];
4265
Chris Lattner680aab62006-08-18 17:34:45 +00004266 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
4267 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004268 yystate = yytable[yystate];
4269 else
Chris Lattner680aab62006-08-18 17:34:45 +00004270 yystate = yydefgoto[yyn - YYNTBASE];
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004271
4272 goto yynewstate;
4273
Chris Lattner680aab62006-08-18 17:34:45 +00004274yyerrlab: /* here on detecting error */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004275
Chris Lattner680aab62006-08-18 17:34:45 +00004276 if (! yyerrstatus)
4277 /* If not already recovering from an error, report this error. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004278 {
4279 ++yynerrs;
Chris Lattner680aab62006-08-18 17:34:45 +00004280
4281#ifdef YYERROR_VERBOSE
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004282 yyn = yypact[yystate];
4283
Chris Lattner680aab62006-08-18 17:34:45 +00004284 if (yyn > YYFLAG && yyn < YYLAST)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004285 {
Chris Lattner680aab62006-08-18 17:34:45 +00004286 int size = 0;
4287 char *msg;
4288 int x, count;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004289
Chris Lattner680aab62006-08-18 17:34:45 +00004290 count = 0;
4291 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
4292 for (x = (yyn < 0 ? -yyn : 0);
4293 x < (sizeof(yytname) / sizeof(char *)); x++)
4294 if (yycheck[x + yyn] == x)
4295 size += strlen(yytname[x]) + 15, count++;
4296 msg = (char *) malloc(size + 15);
4297 if (msg != 0)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004298 {
Chris Lattner680aab62006-08-18 17:34:45 +00004299 strcpy(msg, "parse error");
4300
4301 if (count < 5)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004302 {
Chris Lattner680aab62006-08-18 17:34:45 +00004303 count = 0;
4304 for (x = (yyn < 0 ? -yyn : 0);
4305 x < (sizeof(yytname) / sizeof(char *)); x++)
4306 if (yycheck[x + yyn] == x)
4307 {
4308 strcat(msg, count == 0 ? ", expecting `" : " or `");
4309 strcat(msg, yytname[x]);
4310 strcat(msg, "'");
4311 count++;
4312 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004313 }
Chris Lattner680aab62006-08-18 17:34:45 +00004314 yyerror(msg);
4315 free(msg);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004316 }
4317 else
Chris Lattner680aab62006-08-18 17:34:45 +00004318 yyerror ("parse error; also virtual memory exceeded");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004319 }
4320 else
4321#endif /* YYERROR_VERBOSE */
Chris Lattner680aab62006-08-18 17:34:45 +00004322 yyerror("parse error");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004323 }
4324
Chris Lattner680aab62006-08-18 17:34:45 +00004325 goto yyerrlab1;
4326yyerrlab1: /* here on error raised explicitly by an action */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004327
4328 if (yyerrstatus == 3)
4329 {
Chris Lattner680aab62006-08-18 17:34:45 +00004330 /* if just tried and failed to reuse lookahead token after an error, discard it. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004331
Chris Lattner680aab62006-08-18 17:34:45 +00004332 /* return failure if at end of input */
4333 if (yychar == YYEOF)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004334 YYABORT;
4335
Chris Lattner680aab62006-08-18 17:34:45 +00004336#if YYDEBUG != 0
4337 if (yydebug)
4338 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
4339#endif
Chris Lattneredd9b032006-01-23 23:05:42 +00004340
Chris Lattner680aab62006-08-18 17:34:45 +00004341 yychar = YYEMPTY;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004342 }
4343
Chris Lattner680aab62006-08-18 17:34:45 +00004344 /* Else will try to reuse lookahead token
4345 after shifting the error token. */
4346
4347 yyerrstatus = 3; /* Each real token shifted decrements this */
4348
4349 goto yyerrhandle;
4350
4351yyerrdefault: /* current state does not do anything special for the error token. */
4352
4353#if 0
4354 /* This is wrong; only states that explicitly want error tokens
4355 should shift them. */
4356 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
4357 if (yyn) goto yydefault;
4358#endif
4359
4360yyerrpop: /* pop the current state because it cannot handle the error token */
4361
4362 if (yyssp == yyss) YYABORT;
4363 yyvsp--;
4364 yystate = *--yyssp;
4365#ifdef YYLSP_NEEDED
4366 yylsp--;
4367#endif
4368
4369#if YYDEBUG != 0
4370 if (yydebug)
4371 {
4372 short *ssp1 = yyss - 1;
4373 fprintf (stderr, "Error: state stack now");
4374 while (ssp1 != yyssp)
4375 fprintf (stderr, " %d", *++ssp1);
4376 fprintf (stderr, "\n");
4377 }
4378#endif
4379
4380yyerrhandle:
4381
4382 yyn = yypact[yystate];
4383 if (yyn == YYFLAG)
4384 goto yyerrdefault;
4385
4386 yyn += YYTERROR;
4387 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
4388 goto yyerrdefault;
4389
4390 yyn = yytable[yyn];
4391 if (yyn < 0)
4392 {
4393 if (yyn == YYFLAG)
4394 goto yyerrpop;
4395 yyn = -yyn;
4396 goto yyreduce;
4397 }
4398 else if (yyn == 0)
4399 goto yyerrpop;
4400
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004401 if (yyn == YYFINAL)
4402 YYACCEPT;
4403
Chris Lattner680aab62006-08-18 17:34:45 +00004404#if YYDEBUG != 0
4405 if (yydebug)
4406 fprintf(stderr, "Shifting error token, ");
4407#endif
4408
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004409 *++yyvsp = yylval;
Chris Lattner680aab62006-08-18 17:34:45 +00004410#ifdef YYLSP_NEEDED
4411 *++yylsp = yylloc;
4412#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004413
4414 yystate = yyn;
4415 goto yynewstate;
4416
Chris Lattner680aab62006-08-18 17:34:45 +00004417 yyacceptlab:
4418 /* YYACCEPT comes here. */
4419 if (yyfree_stacks)
Reid Spencer713eedc2006-08-18 08:43:06 +00004420 {
Chris Lattner680aab62006-08-18 17:34:45 +00004421 free (yyss);
4422 free (yyvs);
4423#ifdef YYLSP_NEEDED
4424 free (yyls);
Reid Spencer713eedc2006-08-18 08:43:06 +00004425#endif
Chris Lattner680aab62006-08-18 17:34:45 +00004426 }
4427 return 0;
4428
4429 yyabortlab:
4430 /* YYABORT comes here. */
4431 if (yyfree_stacks)
4432 {
4433 free (yyss);
4434 free (yyvs);
4435#ifdef YYLSP_NEEDED
4436 free (yyls);
4437#endif
4438 }
4439 return 1;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004440}
Chris Lattner680aab62006-08-18 17:34:45 +00004441#line 2601 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer713eedc2006-08-18 08:43:06 +00004442
4443
4444void llvm::GenerateError(const std::string &message, int LineNo) {
4445 if (LineNo == -1) LineNo = llvmAsmlineno;
4446 // TODO: column number in exception
4447 if (TheParseError)
4448 TheParseError->setError(CurFilename, message, LineNo);
4449 TriggerError = 1;
4450}
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004451
4452int yyerror(const char *ErrorMsg) {
4453 std::string where
4454 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
4455 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
4456 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
4457 if (yychar == YYEMPTY || yychar == 0)
4458 errMsg += "end-of-file.";
4459 else
4460 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
Reid Spencer713eedc2006-08-18 08:43:06 +00004461 GenerateError(errMsg);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004462 return 0;
4463}