blob: 98d2177ccbbd517ccbfc258762771ea0f02b4cef [file] [log] [blame]
Reid Spencer68a24bd2005-08-27 18:50:39 +00001
Chris Lattner0fab59c2007-01-12 18:33:30 +00002/* A Bison parser, made from /Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y
3 by GNU Bison version 1.28 */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004
Chris Lattner0fab59c2007-01-12 18:33:30 +00005#define YYBISON 1 /* Identify Bison output. */
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00006
Reid Spencer68a24bd2005-08-27 18:50:39 +00007#define yyparse llvmAsmparse
Chris Lattner0fab59c2007-01-12 18:33:30 +00008#define yylex llvmAsmlex
Reid Spencer68a24bd2005-08-27 18:50:39 +00009#define yyerror llvmAsmerror
Chris Lattner0fab59c2007-01-12 18:33:30 +000010#define yylval llvmAsmlval
11#define yychar llvmAsmchar
Reid Spencer68a24bd2005-08-27 18:50:39 +000012#define yydebug llvmAsmdebug
13#define yynerrs llvmAsmnerrs
Chris Lattner0fab59c2007-01-12 18:33:30 +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 INTTYPE 264
22#define FLOAT 265
23#define DOUBLE 266
24#define LABEL 267
25#define TYPE 268
26#define VAR_ID 269
27#define LABELSTR 270
28#define STRINGCONSTANT 271
29#define IMPLEMENTATION 272
30#define ZEROINITIALIZER 273
31#define TRUETOK 274
32#define FALSETOK 275
33#define BEGINTOK 276
34#define ENDTOK 277
35#define DECLARE 278
36#define DEFINE 279
37#define GLOBAL 280
38#define CONSTANT 281
39#define SECTION 282
40#define VOLATILE 283
41#define TO 284
42#define DOTDOTDOT 285
43#define NULL_TOK 286
44#define UNDEF 287
45#define INTERNAL 288
46#define LINKONCE 289
47#define WEAK 290
48#define APPENDING 291
49#define DLLIMPORT 292
50#define DLLEXPORT 293
51#define EXTERN_WEAK 294
52#define OPAQUE 295
53#define EXTERNAL 296
54#define TARGET 297
55#define TRIPLE 298
56#define ENDIAN 299
57#define POINTERSIZE 300
58#define LITTLE 301
59#define BIG 302
60#define ALIGN 303
61#define DEPLIBS 304
62#define CALL 305
63#define TAIL 306
64#define ASM_TOK 307
65#define MODULE 308
66#define SIDEEFFECT 309
67#define CC_TOK 310
68#define CCC_TOK 311
69#define CSRETCC_TOK 312
70#define FASTCC_TOK 313
71#define COLDCC_TOK 314
72#define X86_STDCALLCC_TOK 315
73#define X86_FASTCALLCC_TOK 316
74#define DATALAYOUT 317
75#define RET 318
76#define BR 319
77#define SWITCH 320
78#define INVOKE 321
79#define UNWIND 322
80#define UNREACHABLE 323
81#define ADD 324
82#define SUB 325
83#define MUL 326
84#define UDIV 327
85#define SDIV 328
86#define FDIV 329
87#define UREM 330
88#define SREM 331
89#define FREM 332
90#define AND 333
91#define OR 334
92#define XOR 335
93#define ICMP 336
94#define FCMP 337
95#define EQ 338
96#define NE 339
97#define SLT 340
98#define SGT 341
99#define SLE 342
100#define SGE 343
101#define ULT 344
102#define UGT 345
103#define ULE 346
104#define UGE 347
105#define OEQ 348
106#define ONE 349
107#define OLT 350
108#define OGT 351
109#define OLE 352
110#define OGE 353
111#define ORD 354
112#define UNO 355
113#define UEQ 356
114#define UNE 357
115#define MALLOC 358
116#define ALLOCA 359
117#define FREE 360
118#define LOAD 361
119#define STORE 362
120#define GETELEMENTPTR 363
121#define TRUNC 364
122#define ZEXT 365
123#define SEXT 366
124#define FPTRUNC 367
125#define FPEXT 368
126#define BITCAST 369
127#define UITOFP 370
128#define SITOFP 371
129#define FPTOUI 372
130#define FPTOSI 373
131#define INTTOPTR 374
132#define PTRTOINT 375
133#define PHI_TOK 376
134#define SELECT 377
135#define SHL 378
136#define LSHR 379
137#define ASHR 380
138#define VAARG 381
139#define EXTRACTELEMENT 382
140#define INSERTELEMENT 383
141#define SHUFFLEVECTOR 384
142#define NORETURN 385
Reid Spencer68a24bd2005-08-27 18:50:39 +0000143
Chris Lattner0fab59c2007-01-12 18:33:30 +0000144#line 14 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000145
146#include "ParserInternals.h"
147#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000148#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000149#include "llvm/Instructions.h"
150#include "llvm/Module.h"
151#include "llvm/SymbolTable.h"
152#include "llvm/Support/GetElementPtrTypeIterator.h"
Reid Spencer14310612006-12-31 05:40:51 +0000153#include "llvm/Support/CommandLine.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000154#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000155#include "llvm/Support/MathExtras.h"
Reid Spencer481169e2006-12-01 00:33:46 +0000156#include "llvm/Support/Streams.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000157#include <algorithm>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000158#include <list>
159#include <utility>
Reid Spencer14310612006-12-31 05:40:51 +0000160#ifndef NDEBUG
161#define YYDEBUG 1
162#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000163
Reid Spencere4f47592006-08-18 17:32:55 +0000164// The following is a gross hack. In order to rid the libAsmParser library of
165// exceptions, we have to have a way of getting the yyparse function to go into
166// an error situation. So, whenever we want an error to occur, the GenerateError
167// function (see bottom of file) sets TriggerError. Then, at the end of each
168// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
169// (a goto) to put YACC in error state. Furthermore, several calls to
170// GenerateError are made from inside productions and they must simulate the
171// previous exception behavior by exiting the production immediately. We have
172// replaced these with the GEN_ERROR macro which calls GeneratError and then
173// immediately invokes YYERROR. This would be so much cleaner if it was a
174// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000175static bool TriggerError = false;
Reid Spencerf63697d2006-10-09 17:36:59 +0000176#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000177#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
178
Reid Spencer68a24bd2005-08-27 18:50:39 +0000179int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
180int yylex(); // declaration" of xxx warnings.
181int yyparse();
182
183namespace llvm {
184 std::string CurFilename;
Reid Spencer14310612006-12-31 05:40:51 +0000185#if YYDEBUG
186static cl::opt<bool>
187Debug("debug-yacc", cl::desc("Print yacc debug state changes"),
188 cl::Hidden, cl::init(false));
189#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000190}
191using namespace llvm;
192
193static Module *ParserResult;
194
195// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
196// relating to upreferences in the input stream.
197//
198//#define DEBUG_UPREFS 1
199#ifdef DEBUG_UPREFS
Bill Wendlinge8156192006-12-07 01:30:32 +0000200#define UR_OUT(X) cerr << X
Reid Spencer68a24bd2005-08-27 18:50:39 +0000201#else
202#define UR_OUT(X)
203#endif
204
205#define YYERROR_VERBOSE 1
206
Chris Lattnerb475c422005-11-12 18:22:38 +0000207static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000208
209
210// This contains info used when building the body of a function. It is
211// destroyed when the function is completed.
212//
213typedef std::vector<Value *> ValueList; // Numbered defs
Reid Spencer14310612006-12-31 05:40:51 +0000214
Reid Spencer68a24bd2005-08-27 18:50:39 +0000215static void
216ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
217 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
218
219static struct PerModuleInfo {
220 Module *CurrentModule;
221 std::map<const Type *, ValueList> Values; // Module level numbered definitions
222 std::map<const Type *,ValueList> LateResolveValues;
Reid Spencer861d9d62006-11-28 07:29:44 +0000223 std::vector<PATypeHolder> Types;
224 std::map<ValID, PATypeHolder> LateResolveTypes;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000225
226 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000227 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000228 /// that we can resolve them later and print error messages as appropriate.
229 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
230
231 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
232 // references to global values. Global values may be referenced before they
233 // are defined, and if so, the temporary object that they represent is held
234 // here. This is used for forward references of GlobalValues.
235 //
236 typedef std::map<std::pair<const PointerType *,
237 ValID>, GlobalValue*> GlobalRefsType;
238 GlobalRefsType GlobalRefs;
239
240 void ModuleDone() {
241 // If we could not resolve some functions at function compilation time
242 // (calls to functions before they are defined), resolve them now... Types
243 // are resolved when the constant pool has been completely parsed.
244 //
245 ResolveDefinitions(LateResolveValues);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000246 if (TriggerError)
247 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000248
249 // Check to make sure that all global value forward references have been
250 // resolved!
251 //
252 if (!GlobalRefs.empty()) {
253 std::string UndefinedReferences = "Unresolved global references exist:\n";
254
255 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
256 I != E; ++I) {
257 UndefinedReferences += " " + I->first.first->getDescription() + " " +
258 I->first.second.getName() + "\n";
259 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000260 GenerateError(UndefinedReferences);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000261 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000262 }
263
264 Values.clear(); // Clear out function local definitions
265 Types.clear();
266 CurrentModule = 0;
267 }
268
Reid Spencer68a24bd2005-08-27 18:50:39 +0000269 // GetForwardRefForGlobal - Check to see if there is a forward reference
270 // for this global. If so, remove it from the GlobalRefs map and return it.
271 // If not, just return null.
272 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
273 // Check to see if there is a forward reference to this global variable...
274 // if there is, eliminate it and patch the reference to use the new def'n.
275 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
276 GlobalValue *Ret = 0;
277 if (I != GlobalRefs.end()) {
278 Ret = I->second;
279 GlobalRefs.erase(I);
280 }
281 return Ret;
282 }
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000283
284 bool TypeIsUnresolved(PATypeHolder* PATy) {
285 // If it isn't abstract, its resolved
286 const Type* Ty = PATy->get();
287 if (!Ty->isAbstract())
288 return false;
289 // Traverse the type looking for abstract types. If it isn't abstract then
290 // we don't need to traverse that leg of the type.
291 std::vector<const Type*> WorkList, SeenList;
292 WorkList.push_back(Ty);
293 while (!WorkList.empty()) {
294 const Type* Ty = WorkList.back();
295 SeenList.push_back(Ty);
296 WorkList.pop_back();
297 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
298 // Check to see if this is an unresolved type
299 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
300 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
301 for ( ; I != E; ++I) {
302 if (I->second.get() == OpTy)
303 return true;
304 }
305 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
306 const Type* TheTy = SeqTy->getElementType();
307 if (TheTy->isAbstract() && TheTy != Ty) {
308 std::vector<const Type*>::iterator I = SeenList.begin(),
309 E = SeenList.end();
310 for ( ; I != E; ++I)
311 if (*I == TheTy)
312 break;
313 if (I == E)
314 WorkList.push_back(TheTy);
315 }
316 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
317 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
318 const Type* TheTy = StrTy->getElementType(i);
319 if (TheTy->isAbstract() && TheTy != Ty) {
320 std::vector<const Type*>::iterator I = SeenList.begin(),
321 E = SeenList.end();
322 for ( ; I != E; ++I)
323 if (*I == TheTy)
324 break;
325 if (I == E)
326 WorkList.push_back(TheTy);
327 }
328 }
329 }
330 }
331 return false;
332 }
333
334
Reid Spencer68a24bd2005-08-27 18:50:39 +0000335} CurModule;
336
337static struct PerFunctionInfo {
338 Function *CurrentFunction; // Pointer to current function being created
339
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000340 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
Reid Spencer68a24bd2005-08-27 18:50:39 +0000341 std::map<const Type*, ValueList> LateResolveValues;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000342 bool isDeclare; // Is this function a forward declararation?
343 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Reid Spencer68a24bd2005-08-27 18:50:39 +0000344
345 /// BBForwardRefs - When we see forward references to basic blocks, keep
346 /// track of them here.
347 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
348 std::vector<BasicBlock*> NumberedBlocks;
349 unsigned NextBBNum;
350
351 inline PerFunctionInfo() {
352 CurrentFunction = 0;
353 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000354 Linkage = GlobalValue::ExternalLinkage;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000355 }
356
357 inline void FunctionStart(Function *M) {
358 CurrentFunction = M;
359 NextBBNum = 0;
360 }
361
362 void FunctionDone() {
363 NumberedBlocks.clear();
364
365 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000366 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000367 GenerateError("Undefined reference to label " +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000368 BBForwardRefs.begin()->first->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000369 return;
370 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000371
372 // Resolve all forward references now.
373 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
374
375 Values.clear(); // Clear out function local definitions
376 CurrentFunction = 0;
377 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000378 Linkage = GlobalValue::ExternalLinkage;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000379 }
380} CurFun; // Info for the current function...
381
382static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
383
384
385//===----------------------------------------------------------------------===//
386// Code to handle definitions of all the types
387//===----------------------------------------------------------------------===//
388
389static int InsertValue(Value *V,
390 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
391 if (V->hasName()) return -1; // Is this a numbered definition?
392
393 // Yes, insert the value into the value table...
394 ValueList &List = ValueTab[V->getType()];
395 List.push_back(V);
396 return List.size()-1;
397}
398
399static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
400 switch (D.Type) {
401 case ValID::NumberVal: // Is it a numbered definition?
402 // Module constants occupy the lowest numbered slots...
403 if ((unsigned)D.Num < CurModule.Types.size())
Reid Spencer861d9d62006-11-28 07:29:44 +0000404 return CurModule.Types[(unsigned)D.Num];
Reid Spencer68a24bd2005-08-27 18:50:39 +0000405 break;
406 case ValID::NameVal: // Is it a named definition?
407 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
408 D.destroy(); // Free old strdup'd memory...
409 return N;
410 }
411 break;
412 default:
Reid Spencer61c83e02006-08-18 08:43:06 +0000413 GenerateError("Internal parser error: Invalid symbol type reference!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000414 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000415 }
416
417 // If we reached here, we referenced either a symbol that we don't know about
418 // or an id number that hasn't been read yet. We may be referencing something
419 // forward, so just create an entry to be resolved later and get to it...
420 //
421 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
422
423
424 if (inFunctionScope()) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000425 if (D.Type == ValID::NameVal) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000426 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000427 return 0;
428 } else {
Reid Spencer61c83e02006-08-18 08:43:06 +0000429 GenerateError("Reference to an undefined type: #" + itostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000430 return 0;
431 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000432 }
433
Reid Spencer861d9d62006-11-28 07:29:44 +0000434 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000435 if (I != CurModule.LateResolveTypes.end())
Reid Spencer861d9d62006-11-28 07:29:44 +0000436 return I->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000437
Reid Spencer861d9d62006-11-28 07:29:44 +0000438 Type *Typ = OpaqueType::get();
439 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
440 return Typ;
Reid Spencera132e042006-12-03 05:46:11 +0000441 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000442
443static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
444 SymbolTable &SymTab =
Reid Spencer78d033e2007-01-06 07:24:44 +0000445 inFunctionScope() ? CurFun.CurrentFunction->getValueSymbolTable() :
446 CurModule.CurrentModule->getValueSymbolTable();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000447 return SymTab.lookup(Ty, Name);
448}
449
450// getValNonImprovising - Look up the value specified by the provided type and
451// the provided ValID. If the value exists and has already been defined, return
452// it. Otherwise return null.
453//
454static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000455 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000456 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000457 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000458 return 0;
459 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000460
461 switch (D.Type) {
462 case ValID::NumberVal: { // Is it a numbered definition?
463 unsigned Num = (unsigned)D.Num;
464
465 // Module constants occupy the lowest numbered slots...
466 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
467 if (VI != CurModule.Values.end()) {
468 if (Num < VI->second.size())
469 return VI->second[Num];
470 Num -= VI->second.size();
471 }
472
473 // Make sure that our type is within bounds
474 VI = CurFun.Values.find(Ty);
475 if (VI == CurFun.Values.end()) return 0;
476
477 // Check that the number is within bounds...
478 if (VI->second.size() <= Num) return 0;
479
480 return VI->second[Num];
481 }
482
483 case ValID::NameVal: { // Is it a named definition?
484 Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
485 if (N == 0) return 0;
486
487 D.destroy(); // Free old strdup'd memory...
488 return N;
489 }
490
491 // Check to make sure that "Ty" is an integral type, and that our
492 // value will fit into the specified type...
493 case ValID::ConstSIntVal: // Is it a constant pool reference??
Reid Spencerb83eb642006-10-20 07:07:24 +0000494 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000495 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000496 itostr(D.ConstPool64) + "' is invalid for type '" +
497 Ty->getDescription() + "'!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000498 return 0;
499 }
Reid Spencerb83eb642006-10-20 07:07:24 +0000500 return ConstantInt::get(Ty, D.ConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000501
502 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Reid Spencerb83eb642006-10-20 07:07:24 +0000503 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
504 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000505 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000506 "' is invalid or out of range!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000507 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000508 } else { // This is really a signed reference. Transmogrify.
Reid Spencerb83eb642006-10-20 07:07:24 +0000509 return ConstantInt::get(Ty, D.ConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000510 }
511 } else {
Reid Spencerb83eb642006-10-20 07:07:24 +0000512 return ConstantInt::get(Ty, D.UConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000513 }
514
515 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000516 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000517 GenerateError("FP constant invalid for type!!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000518 return 0;
519 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000520 return ConstantFP::get(Ty, D.ConstPoolFP);
521
522 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000523 if (!isa<PointerType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000524 GenerateError("Cannot create a a non pointer null!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000525 return 0;
526 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000527 return ConstantPointerNull::get(cast<PointerType>(Ty));
528
529 case ValID::ConstUndefVal: // Is it an undef value?
530 return UndefValue::get(Ty);
531
Chris Lattner7aa61892005-12-21 17:53:23 +0000532 case ValID::ConstZeroVal: // Is it a zero value?
533 return Constant::getNullValue(Ty);
534
Reid Spencer68a24bd2005-08-27 18:50:39 +0000535 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000536 if (D.ConstantValue->getType() != Ty) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000537 GenerateError("Constant expression type different from required type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000538 return 0;
539 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000540 return D.ConstantValue;
541
Chris Lattner0e9c3762006-01-25 22:27:16 +0000542 case ValID::InlineAsmVal: { // Inline asm expression
543 const PointerType *PTy = dyn_cast<PointerType>(Ty);
544 const FunctionType *FTy =
545 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000546 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000547 GenerateError("Invalid type for asm constraint string!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000548 return 0;
549 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000550 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
551 D.IAD->HasSideEffects);
552 D.destroy(); // Free InlineAsmDescriptor.
553 return IA;
554 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000555 default:
556 assert(0 && "Unhandled case!");
557 return 0;
558 } // End of switch
559
560 assert(0 && "Unhandled case!");
561 return 0;
562}
563
564// getVal - This function is identical to getValNonImprovising, except that if a
565// value is not already defined, it "improvises" by creating a placeholder var
566// that looks and acts just like the requested variable. When the value is
567// defined later, all uses of the placeholder variable are replaced with the
568// real thing.
569//
570static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000571 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000572 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000573 return 0;
574 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000575
576 // See if the value has already been defined.
577 Value *V = getValNonImprovising(Ty, ID);
578 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000579 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000580
Reid Spencer5b7e7532006-09-28 19:28:24 +0000581 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000582 GenerateError("Invalid use of a composite type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000583 return 0;
584 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000585
586 // If we reached here, we referenced either a symbol that we don't know about
587 // or an id number that hasn't been read yet. We may be referencing something
588 // forward, so just create an entry to be resolved later and get to it...
589 //
590 V = new Argument(Ty);
591
592 // Remember where this forward reference came from. FIXME, shouldn't we try
593 // to recycle these things??
594 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
595 llvmAsmlineno)));
596
597 if (inFunctionScope())
598 InsertValue(V, CurFun.LateResolveValues);
599 else
600 InsertValue(V, CurModule.LateResolveValues);
601 return V;
602}
603
604/// getBBVal - This is used for two purposes:
605/// * If isDefinition is true, a new basic block with the specified ID is being
606/// defined.
607/// * If isDefinition is true, this is a reference to a basic block, which may
608/// or may not be a forward reference.
609///
610static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
611 assert(inFunctionScope() && "Can't get basic block at global scope!");
612
613 std::string Name;
614 BasicBlock *BB = 0;
615 switch (ID.Type) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000616 default:
617 GenerateError("Illegal label reference " + ID.getName());
618 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000619 case ValID::NumberVal: // Is it a numbered definition?
620 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
621 CurFun.NumberedBlocks.resize(ID.Num+1);
622 BB = CurFun.NumberedBlocks[ID.Num];
623 break;
624 case ValID::NameVal: // Is it a named definition?
625 Name = ID.Name;
626 if (Value *N = CurFun.CurrentFunction->
Reid Spencer78d033e2007-01-06 07:24:44 +0000627 getValueSymbolTable().lookup(Type::LabelTy, Name))
Reid Spencer68a24bd2005-08-27 18:50:39 +0000628 BB = cast<BasicBlock>(N);
629 break;
630 }
631
632 // See if the block has already been defined.
633 if (BB) {
634 // If this is the definition of the block, make sure the existing value was
635 // just a forward reference. If it was a forward reference, there will be
636 // an entry for it in the PlaceHolderInfo map.
Reid Spencer5b7e7532006-09-28 19:28:24 +0000637 if (isDefinition && !CurFun.BBForwardRefs.erase(BB)) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000638 // The existing value was a definition, not a forward reference.
Reid Spencer61c83e02006-08-18 08:43:06 +0000639 GenerateError("Redefinition of label " + ID.getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000640 return 0;
641 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000642
643 ID.destroy(); // Free strdup'd memory.
644 return BB;
645 }
646
647 // Otherwise this block has not been seen before.
648 BB = new BasicBlock("", CurFun.CurrentFunction);
649 if (ID.Type == ValID::NameVal) {
650 BB->setName(ID.Name);
651 } else {
652 CurFun.NumberedBlocks[ID.Num] = BB;
653 }
654
655 // If this is not a definition, keep track of it so we can use it as a forward
656 // reference.
657 if (!isDefinition) {
658 // Remember where this forward reference came from.
659 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
660 } else {
661 // The forward declaration could have been inserted anywhere in the
662 // function: insert it into the correct place now.
663 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
664 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
665 }
666 ID.destroy();
667 return BB;
668}
669
670
671//===----------------------------------------------------------------------===//
672// Code to handle forward references in instructions
673//===----------------------------------------------------------------------===//
674//
675// This code handles the late binding needed with statements that reference
676// values not defined yet... for example, a forward branch, or the PHI node for
677// a loop body.
678//
679// This keeps a table (CurFun.LateResolveValues) of all such forward references
680// and back patchs after we are done.
681//
682
683// ResolveDefinitions - If we could not resolve some defs at parsing
684// time (forward branches, phi functions for loops, etc...) resolve the
685// defs now...
686//
687static void
688ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
689 std::map<const Type*,ValueList> *FutureLateResolvers) {
690 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
691 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
692 E = LateResolvers.end(); LRI != E; ++LRI) {
693 ValueList &List = LRI->second;
694 while (!List.empty()) {
695 Value *V = List.back();
696 List.pop_back();
697
698 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
699 CurModule.PlaceHolderInfo.find(V);
700 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
701
702 ValID &DID = PHI->second.first;
703
704 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000705 if (TriggerError)
706 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000707 if (TheRealValue) {
708 V->replaceAllUsesWith(TheRealValue);
709 delete V;
710 CurModule.PlaceHolderInfo.erase(PHI);
711 } else if (FutureLateResolvers) {
712 // Functions have their unresolved items forwarded to the module late
713 // resolver table
714 InsertValue(V, *FutureLateResolvers);
715 } else {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000716 if (DID.Type == ValID::NameVal) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000717 GenerateError("Reference to an invalid definition: '" +DID.getName()+
Reid Spencer68a24bd2005-08-27 18:50:39 +0000718 "' of type '" + V->getType()->getDescription() + "'",
719 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000720 return;
721 } else {
Reid Spencer61c83e02006-08-18 08:43:06 +0000722 GenerateError("Reference to an invalid definition: #" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000723 itostr(DID.Num) + " of type '" +
724 V->getType()->getDescription() + "'",
725 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000726 return;
727 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000728 }
729 }
730 }
731
732 LateResolvers.clear();
733}
734
735// ResolveTypeTo - A brand new type was just declared. This means that (if
736// name is not null) things referencing Name can be resolved. Otherwise, things
737// refering to the number can be resolved. Do this now.
738//
739static void ResolveTypeTo(char *Name, const Type *ToTy) {
740 ValID D;
741 if (Name) D = ValID::create(Name);
742 else D = ValID::create((int)CurModule.Types.size());
743
Reid Spencer861d9d62006-11-28 07:29:44 +0000744 std::map<ValID, PATypeHolder>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +0000745 CurModule.LateResolveTypes.find(D);
746 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer861d9d62006-11-28 07:29:44 +0000747 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000748 CurModule.LateResolveTypes.erase(I);
749 }
750}
751
752// setValueName - Set the specified value to the name given. The name may be
753// null potentially, in which case this is a noop. The string passed in is
754// assumed to be a malloc'd string buffer, and is free'd by this function.
755//
756static void setValueName(Value *V, char *NameStr) {
757 if (NameStr) {
758 std::string Name(NameStr); // Copy string
759 free(NameStr); // Free old string
760
Reid Spencer5b7e7532006-09-28 19:28:24 +0000761 if (V->getType() == Type::VoidTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000762 GenerateError("Can't assign name '" + Name+"' to value with void type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000763 return;
764 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000765
766 assert(inFunctionScope() && "Must be in function scope!");
Reid Spencer78d033e2007-01-06 07:24:44 +0000767 SymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
Reid Spencer5b7e7532006-09-28 19:28:24 +0000768 if (ST.lookup(V->getType(), Name)) {
Reid Spencer63c34452007-01-05 21:51:07 +0000769 GenerateError("Redefinition of value '" + Name + "' of type '" +
770 V->getType()->getDescription() + "'!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000771 return;
772 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000773
774 // Set the name.
775 V->setName(Name);
776 }
777}
778
779/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
780/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +0000781static GlobalVariable *
782ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
783 bool isConstantGlobal, const Type *Ty,
784 Constant *Initializer) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000785 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000786 GenerateError("Cannot declare global vars of function type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000787 return 0;
788 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000789
790 const PointerType *PTy = PointerType::get(Ty);
791
792 std::string Name;
793 if (NameStr) {
794 Name = NameStr; // Copy string
795 free(NameStr); // Free old string
796 }
797
798 // See if this global value was forward referenced. If so, recycle the
799 // object.
800 ValID ID;
801 if (!Name.empty()) {
802 ID = ValID::create((char*)Name.c_str());
803 } else {
804 ID = ValID::create((int)CurModule.Values[PTy].size());
805 }
806
807 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
808 // Move the global to the end of the list, from whereever it was
809 // previously inserted.
810 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
811 CurModule.CurrentModule->getGlobalList().remove(GV);
812 CurModule.CurrentModule->getGlobalList().push_back(GV);
813 GV->setInitializer(Initializer);
814 GV->setLinkage(Linkage);
815 GV->setConstant(isConstantGlobal);
816 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000817 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000818 }
819
820 // If this global has a name, check to see if there is already a definition
Reid Spencer63c34452007-01-05 21:51:07 +0000821 // of this global in the module. If so, it is an error.
Reid Spencer68a24bd2005-08-27 18:50:39 +0000822 if (!Name.empty()) {
823 // We are a simple redefinition of a value, check to see if it is defined
824 // the same as the old one.
Reid Spencer63c34452007-01-05 21:51:07 +0000825 if (CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000826 GenerateError("Redefinition of global variable named '" + Name +
Reid Spencer63c34452007-01-05 21:51:07 +0000827 "' of type '" + Ty->getDescription() + "'!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000828 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000829 }
830 }
831
832 // Otherwise there is no existing GV to use, create one now.
833 GlobalVariable *GV =
834 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
835 CurModule.CurrentModule);
836 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000837 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000838}
839
840// setTypeName - Set the specified type to the name given. The name may be
841// null potentially, in which case this is a noop. The string passed in is
842// assumed to be a malloc'd string buffer, and is freed by this function.
843//
844// This function returns true if the type has already been defined, but is
845// allowed to be redefined in the specified context. If the name is a new name
846// for the type plane, it is inserted and false is returned.
847static bool setTypeName(const Type *T, char *NameStr) {
848 assert(!inFunctionScope() && "Can't give types function-local names!");
849 if (NameStr == 0) return false;
850
851 std::string Name(NameStr); // Copy string
852 free(NameStr); // Free old string
853
854 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +0000855 if (T == Type::VoidTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000856 GenerateError("Can't assign name '" + Name + "' to the void type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000857 return false;
858 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000859
860 // Set the type name, checking for conflicts as we do so.
861 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
862
863 if (AlreadyExists) { // Inserting a name that is already defined???
864 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
865 assert(Existing && "Conflict but no matching type?");
866
867 // There is only one case where this is allowed: when we are refining an
868 // opaque type. In this case, Existing will be an opaque type.
869 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
870 // We ARE replacing an opaque type!
871 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
872 return true;
873 }
874
875 // Otherwise, this is an attempt to redefine a type. That's okay if
876 // the redefinition is identical to the original. This will be so if
877 // Existing and T point to the same Type object. In this one case we
878 // allow the equivalent redefinition.
879 if (Existing == T) return true; // Yes, it's equal.
880
881 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer63c34452007-01-05 21:51:07 +0000882 GenerateError("Redefinition of type named '" + Name + "' of type '" +
883 T->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000884 }
885
886 return false;
887}
888
889//===----------------------------------------------------------------------===//
890// Code for handling upreferences in type names...
891//
892
893// TypeContains - Returns true if Ty directly contains E in it.
894//
895static bool TypeContains(const Type *Ty, const Type *E) {
896 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
897 E) != Ty->subtype_end();
898}
899
900namespace {
901 struct UpRefRecord {
902 // NestingLevel - The number of nesting levels that need to be popped before
903 // this type is resolved.
904 unsigned NestingLevel;
905
906 // LastContainedTy - This is the type at the current binding level for the
907 // type. Every time we reduce the nesting level, this gets updated.
908 const Type *LastContainedTy;
909
910 // UpRefTy - This is the actual opaque type that the upreference is
911 // represented with.
912 OpaqueType *UpRefTy;
913
914 UpRefRecord(unsigned NL, OpaqueType *URTy)
915 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
916 };
917}
918
919// UpRefs - A list of the outstanding upreferences that need to be resolved.
920static std::vector<UpRefRecord> UpRefs;
921
922/// HandleUpRefs - Every time we finish a new layer of types, this function is
923/// called. It loops through the UpRefs vector, which is a list of the
924/// currently active types. For each type, if the up reference is contained in
925/// the newly completed type, we decrement the level count. When the level
926/// count reaches zero, the upreferenced type is the type that is passed in:
927/// thus we can complete the cycle.
928///
929static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +0000930 // If Ty isn't abstract, or if there are no up-references in it, then there is
931 // nothing to resolve here.
932 if (!ty->isAbstract() || UpRefs.empty()) return ty;
933
Reid Spencer68a24bd2005-08-27 18:50:39 +0000934 PATypeHolder Ty(ty);
935 UR_OUT("Type '" << Ty->getDescription() <<
936 "' newly formed. Resolving upreferences.\n" <<
937 UpRefs.size() << " upreferences active!\n");
938
939 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
940 // to zero), we resolve them all together before we resolve them to Ty. At
941 // the end of the loop, if there is anything to resolve to Ty, it will be in
942 // this variable.
943 OpaqueType *TypeToResolve = 0;
944
945 for (unsigned i = 0; i != UpRefs.size(); ++i) {
946 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
947 << UpRefs[i].second->getDescription() << ") = "
948 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
949 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
950 // Decrement level of upreference
951 unsigned Level = --UpRefs[i].NestingLevel;
952 UpRefs[i].LastContainedTy = Ty;
953 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
954 if (Level == 0) { // Upreference should be resolved!
955 if (!TypeToResolve) {
956 TypeToResolve = UpRefs[i].UpRefTy;
957 } else {
958 UR_OUT(" * Resolving upreference for "
959 << UpRefs[i].second->getDescription() << "\n";
960 std::string OldName = UpRefs[i].UpRefTy->getDescription());
961 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
962 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
963 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
964 }
965 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
966 --i; // Do not skip the next element...
967 }
968 }
969 }
970
971 if (TypeToResolve) {
972 UR_OUT(" * Resolving upreference for "
973 << UpRefs[i].second->getDescription() << "\n";
974 std::string OldName = TypeToResolve->getDescription());
975 TypeToResolve->refineAbstractTypeTo(Ty);
976 }
977
978 return Ty;
979}
980
Reid Spencer68a24bd2005-08-27 18:50:39 +0000981//===----------------------------------------------------------------------===//
982// RunVMAsmParser - Define an interface to this parser
983//===----------------------------------------------------------------------===//
984//
Reid Spencer14310612006-12-31 05:40:51 +0000985static Module* RunParser(Module * M);
986
Reid Spencer68a24bd2005-08-27 18:50:39 +0000987Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
988 set_scan_file(F);
989
990 CurFilename = Filename;
991 return RunParser(new Module(CurFilename));
992}
993
994Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
995 set_scan_string(AsmString);
996
997 CurFilename = "from_memory";
998 if (M == NULL) {
999 return RunParser(new Module (CurFilename));
1000 } else {
1001 return RunParser(M);
1002 }
1003}
1004
1005
Chris Lattner0fab59c2007-01-12 18:33:30 +00001006#line 876 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
1007typedef union {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001008 llvm::Module *ModuleVal;
1009 llvm::Function *FunctionVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001010 llvm::BasicBlock *BasicBlockVal;
1011 llvm::TerminatorInst *TermInstVal;
1012 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001013 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001014
Reid Spencera132e042006-12-03 05:46:11 +00001015 const llvm::Type *PrimType;
Reid Spencer14310612006-12-31 05:40:51 +00001016 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencera132e042006-12-03 05:46:11 +00001017 llvm::PATypeHolder *TypeVal;
1018 llvm::Value *ValueVal;
Reid Spencera132e042006-12-03 05:46:11 +00001019 std::vector<llvm::Value*> *ValueList;
Reid Spencer14310612006-12-31 05:40:51 +00001020 llvm::ArgListType *ArgList;
1021 llvm::TypeWithAttrs TypeWithAttrs;
1022 llvm::TypeWithAttrsList *TypeWithAttrsList;
1023 llvm::ValueRefList *ValueRefList;
1024
Reid Spencer68a24bd2005-08-27 18:50:39 +00001025 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001026 std::list<std::pair<llvm::Value*,
1027 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001028 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001029 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001030
1031 llvm::GlobalValue::LinkageTypes Linkage;
Reid Spencer14310612006-12-31 05:40:51 +00001032 llvm::FunctionType::ParameterAttributes ParamAttrs;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001033 int64_t SInt64Val;
1034 uint64_t UInt64Val;
1035 int SIntVal;
1036 unsigned UIntVal;
1037 double FPVal;
1038 bool BoolVal;
1039
1040 char *StrVal; // This memory is strdup'd!
Reid Spencer1628cec2006-10-26 06:15:43 +00001041 llvm::ValID ValIDVal; // strdup'd memory maybe!
Reid Spencer68a24bd2005-08-27 18:50:39 +00001042
Reid Spencera132e042006-12-03 05:46:11 +00001043 llvm::Instruction::BinaryOps BinaryOpVal;
1044 llvm::Instruction::TermOps TermOpVal;
1045 llvm::Instruction::MemoryOps MemOpVal;
1046 llvm::Instruction::CastOps CastOpVal;
1047 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencer1628cec2006-10-26 06:15:43 +00001048 llvm::Module::Endianness Endianness;
Reid Spencera132e042006-12-03 05:46:11 +00001049 llvm::ICmpInst::Predicate IPredicate;
1050 llvm::FCmpInst::Predicate FPredicate;
Andrew Lenharth6353e052006-12-08 18:07:09 +00001051} YYSTYPE;
Chris Lattner0fab59c2007-01-12 18:33:30 +00001052#include <stdio.h>
1053
1054#ifndef __cplusplus
1055#ifndef __STDC__
1056#define const
1057#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001058#endif
1059
1060
1061
Chris Lattner0fab59c2007-01-12 18:33:30 +00001062#define YYFINAL 565
1063#define YYFLAG -32768
1064#define YYNTBASE 146
Reid Spencer68a24bd2005-08-27 18:50:39 +00001065
Chris Lattner0fab59c2007-01-12 18:33:30 +00001066#define YYTRANSLATE(x) ((unsigned)(x) <= 385 ? yytranslate[x] : 223)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001067
Chris Lattner0fab59c2007-01-12 18:33:30 +00001068static const short yytranslate[] = { 0,
1069 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1070 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1071 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1072 2, 2, 2, 2, 2, 2, 2, 2, 2, 136,
1073 137, 134, 2, 133, 2, 2, 2, 2, 2, 2,
1074 2, 2, 2, 2, 2, 2, 2, 2, 2, 141,
1075 132, 142, 2, 2, 2, 2, 2, 2, 2, 2,
1076 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1077 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1078 138, 135, 140, 2, 2, 2, 2, 2, 145, 2,
1079 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1080 2, 2, 2, 2, 2, 2, 2, 2, 2, 139,
1081 2, 2, 143, 2, 144, 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, 2, 2, 2, 2, 2,
1094 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
1095 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1096 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1097 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
1098 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
1099 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
1100 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1101 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1102 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1103 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
1104 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
1105 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
1106 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
1107 127, 128, 129, 130, 131
1108};
Reid Spencere4d87aa2006-12-23 06:05:41 +00001109
Chris Lattner0fab59c2007-01-12 18:33:30 +00001110#if YYDEBUG != 0
1111static const short yyprhs[] = { 0,
1112 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
1113 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
1114 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
1115 60, 62, 64, 66, 68, 70, 72, 74, 76, 78,
1116 80, 82, 84, 86, 88, 90, 92, 94, 96, 98,
1117 100, 102, 104, 106, 108, 110, 112, 114, 116, 119,
1118 120, 122, 124, 126, 128, 130, 132, 134, 136, 137,
1119 139, 141, 142, 144, 146, 148, 150, 151, 153, 155,
1120 157, 159, 161, 163, 166, 168, 170, 171, 174, 176,
1121 178, 179, 182, 183, 186, 187, 191, 194, 195, 197,
1122 198, 202, 204, 207, 209, 211, 213, 215, 217, 219,
1123 221, 224, 226, 229, 235, 241, 247, 253, 257, 260,
1124 266, 271, 274, 276, 278, 280, 284, 286, 290, 292,
1125 293, 295, 299, 304, 308, 312, 317, 322, 326, 333,
1126 339, 342, 345, 348, 351, 354, 357, 360, 363, 366,
1127 369, 376, 382, 391, 398, 405, 413, 421, 428, 435,
1128 444, 453, 457, 459, 461, 463, 465, 466, 468, 471,
1129 472, 476, 477, 481, 485, 487, 491, 495, 496, 502,
1130 503, 510, 511, 518, 521, 525, 527, 529, 531, 535,
1131 539, 543, 547, 551, 555, 557, 558, 560, 562, 564,
1132 565, 571, 575, 577, 581, 583, 584, 594, 596, 598,
1133 602, 604, 606, 609, 612, 613, 615, 617, 619, 621,
1134 623, 625, 627, 629, 631, 635, 637, 643, 645, 647,
1135 649, 651, 654, 657, 660, 664, 667, 668, 670, 673,
1136 676, 680, 690, 700, 709, 724, 726, 728, 735, 741,
1137 744, 751, 759, 763, 769, 770, 771, 775, 778, 780,
1138 786, 792, 799, 806, 811, 816, 823, 828, 833, 840,
1139 847, 850, 859, 861, 863, 864, 868, 875, 879, 886,
1140 889, 894, 901
1141};
Reid Spencere4d87aa2006-12-23 06:05:41 +00001142
Chris Lattner0fab59c2007-01-12 18:33:30 +00001143static const short yyrhs[] = { 5,
1144 0, 6, 0, 70, 0, 71, 0, 72, 0, 73,
1145 0, 74, 0, 75, 0, 76, 0, 77, 0, 78,
1146 0, 79, 0, 80, 0, 81, 0, 110, 0, 111,
1147 0, 112, 0, 113, 0, 114, 0, 115, 0, 116,
1148 0, 117, 0, 118, 0, 119, 0, 120, 0, 121,
1149 0, 124, 0, 125, 0, 126, 0, 84, 0, 85,
1150 0, 86, 0, 87, 0, 88, 0, 89, 0, 90,
1151 0, 91, 0, 92, 0, 93, 0, 94, 0, 95,
1152 0, 96, 0, 97, 0, 98, 0, 99, 0, 100,
1153 0, 101, 0, 102, 0, 103, 0, 90, 0, 91,
1154 0, 92, 0, 93, 0, 20, 0, 21, 0, 10,
1155 0, 11, 0, 12, 0, 195, 132, 0, 0, 34,
1156 0, 36, 0, 35, 0, 37, 0, 39, 0, 38,
1157 0, 40, 0, 42, 0, 0, 38, 0, 40, 0,
1158 0, 34, 0, 35, 0, 36, 0, 39, 0, 0,
1159 57, 0, 58, 0, 59, 0, 60, 0, 61, 0,
1160 62, 0, 56, 4, 0, 111, 0, 112, 0, 0,
1161 162, 161, 0, 131, 0, 161, 0, 0, 164, 163,
1162 0, 0, 49, 4, 0, 0, 133, 49, 4, 0,
1163 28, 17, 0, 0, 167, 0, 0, 133, 170, 169,
1164 0, 167, 0, 49, 4, 0, 9, 0, 10, 0,
1165 11, 0, 12, 0, 13, 0, 41, 0, 171, 0,
1166 172, 134, 0, 207, 0, 135, 4, 0, 172, 136,
1167 176, 137, 164, 0, 8, 136, 176, 137, 164, 0,
1168 138, 4, 139, 172, 140, 0, 141, 4, 139, 172,
1169 142, 0, 143, 177, 144, 0, 143, 144, 0, 141,
1170 143, 177, 144, 142, 0, 141, 143, 144, 142, 0,
1171 172, 162, 0, 172, 0, 8, 0, 173, 0, 175,
1172 133, 173, 0, 175, 0, 175, 133, 31, 0, 31,
1173 0, 0, 172, 0, 177, 133, 172, 0, 172, 138,
1174 180, 140, 0, 172, 138, 140, 0, 172, 145, 17,
1175 0, 172, 141, 180, 142, 0, 172, 143, 180, 144,
1176 0, 172, 143, 144, 0, 172, 141, 143, 180, 144,
1177 142, 0, 172, 141, 143, 144, 142, 0, 172, 32,
1178 0, 172, 33, 0, 172, 207, 0, 172, 179, 0,
1179 172, 19, 0, 153, 3, 0, 153, 4, 0, 9,
1180 20, 0, 9, 21, 0, 154, 7, 0, 149, 136,
1181 178, 30, 172, 137, 0, 109, 136, 178, 218, 137,
1182 0, 123, 136, 178, 133, 178, 133, 178, 137, 0,
1183 147, 136, 178, 133, 178, 137, 0, 148, 136, 178,
1184 133, 178, 137, 0, 82, 151, 136, 178, 133, 178,
1185 137, 0, 83, 152, 136, 178, 133, 178, 137, 0,
1186 150, 136, 178, 133, 178, 137, 0, 128, 136, 178,
1187 133, 178, 137, 0, 129, 136, 178, 133, 178, 133,
1188 178, 137, 0, 130, 136, 178, 133, 178, 133, 178,
1189 137, 0, 180, 133, 178, 0, 178, 0, 26, 0,
1190 27, 0, 183, 0, 0, 184, 0, 183, 184, 0,
1191 0, 25, 185, 203, 0, 0, 24, 186, 204, 0,
1192 54, 53, 190, 0, 18, 0, 155, 14, 172, 0,
1193 155, 14, 8, 0, 0, 155, 181, 178, 187, 169,
1194 0, 0, 155, 156, 181, 178, 188, 169, 0, 0,
1195 155, 157, 181, 172, 189, 169, 0, 43, 192, 0,
1196 50, 132, 193, 0, 17, 0, 48, 0, 47, 0,
1197 45, 132, 191, 0, 46, 132, 4, 0, 44, 132,
1198 17, 0, 63, 132, 17, 0, 138, 194, 140, 0,
1199 194, 133, 17, 0, 17, 0, 0, 15, 0, 17,
1200 0, 195, 0, 0, 197, 133, 172, 162, 196, 0,
1201 172, 162, 196, 0, 197, 0, 197, 133, 31, 0,
1202 31, 0, 0, 160, 174, 195, 136, 198, 137, 164,
1203 168, 165, 0, 22, 0, 143, 0, 159, 199, 200,
1204 0, 23, 0, 144, 0, 210, 202, 0, 158, 199,
1205 0, 0, 55, 0, 3, 0, 4, 0, 7, 0,
1206 20, 0, 21, 0, 32, 0, 33, 0, 19, 0,
1207 141, 180, 142, 0, 179, 0, 53, 205, 17, 133,
1208 17, 0, 146, 0, 195, 0, 207, 0, 206, 0,
1209 172, 208, 0, 210, 211, 0, 201, 211, 0, 212,
1210 155, 213, 0, 212, 215, 0, 0, 16, 0, 64,
1211 209, 0, 64, 8, 0, 65, 13, 208, 0, 65,
1212 9, 208, 133, 13, 208, 133, 13, 208, 0, 66,
1213 153, 208, 133, 13, 208, 138, 214, 140, 0, 66,
1214 153, 208, 133, 13, 208, 138, 140, 0, 67, 160,
1215 174, 208, 136, 217, 137, 164, 30, 13, 208, 68,
1216 13, 208, 0, 68, 0, 69, 0, 214, 153, 206,
1217 133, 13, 208, 0, 153, 206, 133, 13, 208, 0,
1218 155, 220, 0, 172, 138, 208, 133, 208, 140, 0,
1219 216, 133, 138, 208, 133, 208, 140, 0, 172, 208,
1220 162, 0, 217, 133, 172, 208, 162, 0, 0, 0,
1221 218, 133, 209, 0, 52, 51, 0, 51, 0, 147,
1222 172, 208, 133, 208, 0, 148, 172, 208, 133, 208,
1223 0, 82, 151, 172, 208, 133, 208, 0, 83, 152,
1224 172, 208, 133, 208, 0, 150, 209, 133, 209, 0,
1225 149, 209, 30, 172, 0, 123, 209, 133, 209, 133,
1226 209, 0, 127, 209, 133, 172, 0, 128, 209, 133,
1227 209, 0, 129, 209, 133, 209, 133, 209, 0, 130,
1228 209, 133, 209, 133, 209, 0, 122, 216, 0, 219,
1229 160, 174, 208, 136, 217, 137, 164, 0, 222, 0,
1230 29, 0, 0, 104, 172, 166, 0, 104, 172, 133,
1231 10, 208, 166, 0, 105, 172, 166, 0, 105, 172,
1232 133, 10, 208, 166, 0, 106, 209, 0, 221, 107,
1233 172, 208, 0, 221, 108, 209, 133, 172, 208, 0,
1234 109, 172, 208, 218, 0
1235};
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00001236
1237#endif
1238
Chris Lattner0fab59c2007-01-12 18:33:30 +00001239#if YYDEBUG != 0
1240static const short yyrline[] = { 0,
1241 1019, 1020, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030,
1242 1030, 1031, 1031, 1031, 1032, 1032, 1032, 1032, 1032, 1032,
1243 1032, 1033, 1033, 1033, 1033, 1033, 1034, 1034, 1034, 1036,
1244 1036, 1037, 1037, 1038, 1038, 1039, 1039, 1040, 1040, 1044,
1245 1044, 1045, 1045, 1046, 1046, 1047, 1047, 1048, 1048, 1049,
1246 1049, 1050, 1050, 1051, 1052, 1057, 1058, 1058, 1061, 1065,
1247 1071, 1072, 1073, 1074, 1075, 1079, 1080, 1081, 1085, 1086,
1248 1087, 1091, 1092, 1093, 1094, 1095, 1098, 1098, 1099, 1100,
1249 1101, 1102, 1103, 1104, 1112, 1113, 1116, 1117, 1122, 1123,
1250 1126, 1127, 1134, 1134, 1141, 1141, 1150, 1158, 1158, 1164,
1251 1164, 1166, 1171, 1184, 1184, 1184, 1184, 1184, 1187, 1191,
1252 1195, 1202, 1207, 1215, 1233, 1251, 1256, 1268, 1278, 1282,
1253 1292, 1299, 1306, 1313, 1318, 1323, 1330, 1331, 1338, 1345,
1254 1353, 1358, 1369, 1397, 1413, 1442, 1470, 1495, 1514, 1539,
1255 1558, 1570, 1577, 1640, 1650, 1660, 1666, 1672, 1676, 1680,
1256 1688, 1702, 1723, 1731, 1737, 1748, 1753, 1758, 1767, 1773,
1257 1779, 1788, 1792, 1800, 1800, 1811, 1816, 1824, 1825, 1829,
1258 1829, 1833, 1833, 1836, 1839, 1851, 1875, 1886, 1892, 1895,
1259 1900, 1903, 1909, 1913, 1916, 1922, 1935, 1936, 1938, 1942,
1260 1951, 1955, 1960, 1962, 1967, 1972, 1981, 1981, 1982, 1982,
1261 1984, 1994, 2005, 2009, 2018, 2027, 2032, 2137, 2137, 2139,
1262 2147, 2147, 2149, 2154, 2165, 2169, 2174, 2178, 2182, 2186,
1263 2190, 2194, 2198, 2202, 2206, 2231, 2235, 2249, 2253, 2259,
1264 2259, 2265, 2274, 2278, 2287, 2298, 2307, 2319, 2332, 2336,
1265 2340, 2345, 2354, 2373, 2382, 2449, 2453, 2460, 2471, 2484,
1266 2493, 2504, 2514, 2522, 2530, 2533, 2534, 2541, 2545, 2550,
1267 2571, 2588, 2601, 2614, 2623, 2636, 2644, 2651, 2657, 2663,
1268 2669, 2684, 2747, 2752, 2756, 2763, 2770, 2778, 2785, 2793,
1269 2801, 2815, 2832
1270};
1271#endif
1272
1273
1274#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
1275
1276static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL",
1277"EUINT64VAL","SINTVAL","UINTVAL","FPVAL","VOID","BOOL","INTTYPE","FLOAT","DOUBLE",
1278"LABEL","TYPE","VAR_ID","LABELSTR","STRINGCONSTANT","IMPLEMENTATION","ZEROINITIALIZER",
1279"TRUETOK","FALSETOK","BEGINTOK","ENDTOK","DECLARE","DEFINE","GLOBAL","CONSTANT",
1280"SECTION","VOLATILE","TO","DOTDOTDOT","NULL_TOK","UNDEF","INTERNAL","LINKONCE",
1281"WEAK","APPENDING","DLLIMPORT","DLLEXPORT","EXTERN_WEAK","OPAQUE","EXTERNAL",
1282"TARGET","TRIPLE","ENDIAN","POINTERSIZE","LITTLE","BIG","ALIGN","DEPLIBS","CALL",
1283"TAIL","ASM_TOK","MODULE","SIDEEFFECT","CC_TOK","CCC_TOK","CSRETCC_TOK","FASTCC_TOK",
1284"COLDCC_TOK","X86_STDCALLCC_TOK","X86_FASTCALLCC_TOK","DATALAYOUT","RET","BR",
1285"SWITCH","INVOKE","UNWIND","UNREACHABLE","ADD","SUB","MUL","UDIV","SDIV","FDIV",
1286"UREM","SREM","FREM","AND","OR","XOR","ICMP","FCMP","EQ","NE","SLT","SGT","SLE",
1287"SGE","ULT","UGT","ULE","UGE","OEQ","ONE","OLT","OGT","OLE","OGE","ORD","UNO",
1288"UEQ","UNE","MALLOC","ALLOCA","FREE","LOAD","STORE","GETELEMENTPTR","TRUNC",
1289"ZEXT","SEXT","FPTRUNC","FPEXT","BITCAST","UITOFP","SITOFP","FPTOUI","FPTOSI",
1290"INTTOPTR","PTRTOINT","PHI_TOK","SELECT","SHL","LSHR","ASHR","VAARG","EXTRACTELEMENT",
1291"INSERTELEMENT","SHUFFLEVECTOR","NORETURN","'='","','","'*'","'\\\\'","'('",
1292"')'","'['","'x'","']'","'<'","'>'","'{'","'}'","'c'","INTVAL","ArithmeticOps",
1293"LogicalOps","CastOps","ShiftOps","IPredicates","FPredicates","IntType","FPType",
1294"OptAssign","GVInternalLinkage","GVExternalLinkage","FunctionDeclareLinkage",
1295"FunctionDefineLinkage","OptCallingConv","ParamAttr","OptParamAttrs","FuncAttr",
1296"OptFuncAttrs","OptAlign","OptCAlign","SectionString","OptSection","GlobalVarAttributes",
1297"GlobalVarAttribute","PrimType","Types","ArgType","ResultTypes","ArgTypeList",
1298"ArgTypeListI","TypeListI","ConstVal","ConstExpr","ConstVector","GlobalType",
1299"Module","DefinitionList","Definition","@1","@2","@3","@4","@5","AsmBlock","BigOrLittle",
1300"TargetDefinition","LibrariesDefinition","LibList","Name","OptName","ArgListH",
1301"ArgList","FunctionHeaderH","BEGIN","FunctionHeader","END","Function","FunctionProto",
1302"OptSideEffect","ConstValueRef","SymbolicValueRef","ValueRef","ResolvedVal",
1303"BasicBlockList","BasicBlock","InstructionList","BBTerminatorInst","JumpTable",
1304"Inst","PHIList","ValueRefList","IndexList","OptTailCall","InstVal","OptVolatile",
1305"MemoryInst", NULL
1306};
1307#endif
1308
1309static const short yyr1[] = { 0,
1310 146, 146, 147, 147, 147, 147, 147, 147, 147, 147,
1311 147, 148, 148, 148, 149, 149, 149, 149, 149, 149,
1312 149, 149, 149, 149, 149, 149, 150, 150, 150, 151,
1313 151, 151, 151, 151, 151, 151, 151, 151, 151, 152,
1314 152, 152, 152, 152, 152, 152, 152, 152, 152, 152,
1315 152, 152, 152, 152, 152, 153, 154, 154, 155, 155,
1316 156, 156, 156, 156, 156, 157, 157, 157, 158, 158,
1317 158, 159, 159, 159, 159, 159, 160, 160, 160, 160,
1318 160, 160, 160, 160, 161, 161, 162, 162, 163, 163,
1319 164, 164, 165, 165, 166, 166, 167, 168, 168, 169,
1320 169, 170, 170, 171, 171, 171, 171, 171, 172, 172,
1321 172, 172, 172, 172, 172, 172, 172, 172, 172, 172,
1322 172, 173, 174, 174, 175, 175, 176, 176, 176, 176,
1323 177, 177, 178, 178, 178, 178, 178, 178, 178, 178,
1324 178, 178, 178, 178, 178, 178, 178, 178, 178, 178,
1325 179, 179, 179, 179, 179, 179, 179, 179, 179, 179,
1326 179, 180, 180, 181, 181, 182, 182, 183, 183, 185,
1327 184, 186, 184, 184, 184, 184, 184, 187, 184, 188,
1328 184, 189, 184, 184, 184, 190, 191, 191, 192, 192,
1329 192, 192, 193, 194, 194, 194, 195, 195, 196, 196,
1330 197, 197, 198, 198, 198, 198, 199, 200, 200, 201,
1331 202, 202, 203, 204, 205, 205, 206, 206, 206, 206,
1332 206, 206, 206, 206, 206, 206, 206, 207, 207, 208,
1333 208, 209, 210, 210, 211, 212, 212, 212, 213, 213,
1334 213, 213, 213, 213, 213, 213, 213, 214, 214, 215,
1335 216, 216, 217, 217, 217, 218, 218, 219, 219, 220,
1336 220, 220, 220, 220, 220, 220, 220, 220, 220, 220,
1337 220, 220, 220, 221, 221, 222, 222, 222, 222, 222,
1338 222, 222, 222
1339};
1340
1341static const short yyr2[] = { 0,
1342 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1343 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1344 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1345 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1346 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1347 1, 1, 1, 1, 1, 1, 1, 1, 2, 0,
1348 1, 1, 1, 1, 1, 1, 1, 1, 0, 1,
1349 1, 0, 1, 1, 1, 1, 0, 1, 1, 1,
1350 1, 1, 1, 2, 1, 1, 0, 2, 1, 1,
1351 0, 2, 0, 2, 0, 3, 2, 0, 1, 0,
1352 3, 1, 2, 1, 1, 1, 1, 1, 1, 1,
1353 2, 1, 2, 5, 5, 5, 5, 3, 2, 5,
1354 4, 2, 1, 1, 1, 3, 1, 3, 1, 0,
1355 1, 3, 4, 3, 3, 4, 4, 3, 6, 5,
1356 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1357 6, 5, 8, 6, 6, 7, 7, 6, 6, 8,
1358 8, 3, 1, 1, 1, 1, 0, 1, 2, 0,
1359 3, 0, 3, 3, 1, 3, 3, 0, 5, 0,
1360 6, 0, 6, 2, 3, 1, 1, 1, 3, 3,
1361 3, 3, 3, 3, 1, 0, 1, 1, 1, 0,
1362 5, 3, 1, 3, 1, 0, 9, 1, 1, 3,
1363 1, 1, 2, 2, 0, 1, 1, 1, 1, 1,
1364 1, 1, 1, 1, 3, 1, 5, 1, 1, 1,
1365 1, 2, 2, 2, 3, 2, 0, 1, 2, 2,
1366 3, 9, 9, 8, 14, 1, 1, 6, 5, 2,
1367 6, 7, 3, 5, 0, 0, 3, 2, 1, 5,
1368 5, 6, 6, 4, 4, 6, 4, 4, 6, 6,
1369 2, 8, 1, 1, 0, 3, 6, 3, 6, 2,
1370 4, 6, 4
1371};
1372
1373static const short yydefact[] = { 60,
1374 197, 198, 175, 172, 170, 0, 0, 0, 0, 60,
1375 168, 0, 69, 72, 0, 0, 0, 0, 184, 0,
1376 0, 0, 164, 165, 61, 63, 62, 64, 66, 65,
1377 67, 68, 0, 0, 0, 169, 59, 70, 71, 77,
1378 173, 73, 74, 75, 76, 77, 237, 171, 237, 0,
1379 0, 0, 0, 196, 185, 186, 174, 1, 2, 177,
1380 104, 105, 106, 107, 108, 109, 0, 0, 0, 0,
1381 228, 110, 176, 229, 112, 0, 0, 0, 104, 105,
1382 106, 107, 0, 0, 0, 178, 0, 78, 79, 80,
1383 81, 82, 83, 0, 214, 0, 238, 234, 60, 211,
1384 212, 213, 233, 191, 188, 187, 189, 190, 192, 195,
1385 0, 130, 113, 0, 0, 0, 119, 131, 0, 111,
1386 130, 180, 182, 148, 149, 146, 147, 150, 145, 141,
1387 142, 3, 4, 5, 6, 7, 8, 9, 10, 11,
1388 12, 13, 14, 0, 0, 0, 15, 16, 17, 18,
1389 19, 20, 21, 22, 23, 24, 25, 26, 0, 27,
1390 28, 29, 0, 0, 0, 0, 0, 0, 0, 0,
1391 0, 0, 0, 144, 143, 100, 84, 124, 123, 0,
1392 208, 209, 210, 275, 236, 0, 193, 129, 87, 125,
1393 127, 0, 0, 0, 0, 0, 0, 118, 0, 100,
1394 100, 30, 31, 32, 33, 34, 35, 36, 37, 38,
1395 39, 0, 54, 55, 50, 51, 52, 53, 40, 41,
1396 42, 43, 44, 45, 46, 47, 48, 49, 0, 0,
1397 0, 0, 0, 0, 134, 163, 0, 0, 0, 138,
1398 0, 135, 0, 0, 0, 0, 0, 179, 0, 274,
1399 259, 0, 0, 0, 0, 77, 246, 247, 0, 0,
1400 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1401 0, 0, 0, 0, 235, 77, 250, 0, 273, 194,
1402 122, 0, 91, 0, 0, 121, 0, 132, 91, 181,
1403 183, 0, 0, 256, 0, 0, 0, 0, 0, 133,
1404 119, 131, 0, 136, 137, 0, 0, 0, 0, 0,
1405 0, 102, 100, 206, 258, 240, 0, 239, 0, 0,
1406 56, 0, 0, 0, 0, 95, 95, 280, 0, 0,
1407 271, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1408 0, 0, 0, 85, 86, 88, 128, 126, 115, 116,
1409 117, 120, 114, 0, 0, 0, 0, 0, 0, 0,
1410 162, 140, 0, 0, 0, 0, 0, 97, 103, 101,
1411 205, 87, 203, 0, 217, 218, 219, 224, 220, 221,
1412 222, 223, 215, 0, 226, 231, 230, 232, 0, 241,
1413 0, 0, 0, 0, 0, 276, 0, 278, 256, 0,
1414 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1415 0, 0, 0, 89, 90, 92, 0, 0, 0, 152,
1416 0, 0, 0, 0, 139, 0, 0, 0, 0, 200,
1417 0, 91, 216, 0, 0, 0, 0, 0, 0, 0,
1418 0, 0, 0, 283, 0, 0, 0, 267, 268, 0,
1419 0, 0, 0, 265, 264, 0, 281, 0, 0, 0,
1420 257, 0, 159, 0, 0, 154, 155, 151, 158, 199,
1421 202, 204, 87, 98, 0, 225, 0, 0, 255, 0,
1422 0, 95, 96, 95, 0, 0, 0, 0, 0, 260,
1423 261, 255, 0, 156, 157, 0, 0, 0, 200, 99,
1424 93, 0, 0, 0, 0, 0, 262, 263, 0, 277,
1425 279, 0, 0, 266, 269, 270, 0, 282, 153, 160,
1426 161, 201, 0, 207, 227, 0, 0, 87, 0, 91,
1427 251, 0, 91, 94, 0, 244, 0, 0, 253, 0,
1428 0, 252, 272, 242, 0, 243, 0, 87, 0, 0,
1429 0, 254, 0, 0, 0, 0, 249, 0, 0, 248,
1430 0, 245, 0, 0, 0
1431};
1432
1433static const short yydefgoto[] = { 71,
1434 170, 171, 172, 173, 212, 229, 83, 84, 9, 33,
1435 34, 40, 46, 94, 346, 281, 416, 349, 524, 396,
1436 312, 501, 248, 313, 72, 85, 190, 180, 191, 192,
1437 119, 236, 385, 237, 35, 563, 10, 11, 14, 13,
1438 176, 200, 201, 57, 107, 19, 55, 111, 74, 471,
1439 373, 374, 95, 183, 47, 102, 48, 41, 434, 386,
1440 75, 388, 318, 49, 98, 99, 275, 538, 185, 331,
1441 506, 356, 276, 277, 278, 279
1442};
1443
1444static const short yypact[] = { 25,
1445-32768,-32768,-32768,-32768,-32768, 41, -96, 30, 537, 95,
1446-32768, -80, 58, 134, -54, -41, -24, -21,-32768, -15,
1447 110, 349,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1448-32768,-32768, 114, 114, 964,-32768,-32768,-32768,-32768, 176,
1449-32768,-32768,-32768,-32768,-32768, 176, 151,-32768, -2, 195,
1450 103, 210, 200, 206,-32768,-32768,-32768,-32768,-32768, 121,
1451-32768,-32768,-32768,-32768,-32768,-32768, 257, 258, 4, 22,
1452-32768,-32768, -4,-32768,-32768, 964, 1217, 121, 183, 222,
1453 256, 259, 224, 262, 596,-32768, 260,-32768,-32768,-32768,
1454-32768,-32768,-32768, 1230,-32768, -7,-32768,-32768, 147,-32768,
1455-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1456 -9, 518,-32768, 126, 131, 174,-32768, -4, -77,-32768,
1457 518,-32768, -4,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1458-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1459-32768,-32768,-32768, 283, 917, 135,-32768,-32768,-32768,-32768,
1460-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 136,-32768,
1461-32768,-32768, 137, 140, 141, 822, 1244, 677, 264, 146,
1462 148, 149, 152,-32768,-32768, 150,-32768, 121, -4, 147,
1463-32768,-32768,-32768, 1324,-32768, 270,-32768,-32768, -4,-32768,
1464 156, 153, 1217, 1217, 154, -71, 1217,-32768, 157, 150,
1465 150,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1466-32768, 155,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1467-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 159, 964,
1468 964, 964, 964, 964,-32768,-32768, -5, 737, -89,-32768,
1469 -62,-32768, 964, 964, 964, 964, 17,-32768, 161,-32768,
1470-32768, 242, 1278, 105, 288, 176,-32768,-32768, 283, 917,
1471 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217,
1472 1217, 1217, 1217, 1217,-32768, 176,-32768, 122,-32768,-32768,
1473 143, 1134,-32768, 12, -27,-32768, 158, -4,-32768,-32768,
1474-32768, 964, 964,-32768, 166, 171, 172, 173, 964,-32768,
1475 165, 596, -52,-32768,-32768, 175, 178, 284, 180, 299,
1476 318,-32768, 150, 1177,-32768, 121, 776,-32768, 915, 915,
1477-32768, 915, 1230, 1217, 1217, 20, 66,-32768, 776, 54,
1478 190, 191, 193, 196, 198, 203, 776, 776, 308, 208,
1479 1230, 1217, 1217,-32768,-32768,-32768,-32768,-32768, -42,-32768,
1480-32768,-32768, -42, 214, 215, -11, 964, 964, 964, 964,
1481-32768,-32768, 201, 964, 964, 1217, 964,-32768,-32768,-32768,
1482-32768, -4, 216, 213,-32768,-32768,-32768,-32768,-32768,-32768,
1483-32768,-32768, 296, 964,-32768,-32768,-32768,-32768, 219,-32768,
1484 220, 915, 776, 776, 28,-32768, 31,-32768,-32768, 915,
1485 218, 1217, 1217, 1217, 1217, 1217, 230, 232, 1217, 1217,
1486 915, 776, 244,-32768,-32768,-32768, 964, 964, 1217,-32768,
1487 245, 248, 246, 253,-32768, 252, 254, 40, 261, 5,
1488 1190,-32768,-32768, 377, -45, 382, 383, 263, 271, 272,
1489 915, 399, 915, 273, 274, 915, 277, -4,-32768, 278,
1490 279, 915, 915, -4,-32768, 280,-32768, 1217, 276, 281,
1491-32768, 964,-32768, 964, 964,-32768,-32768,-32768,-32768,-32768,
1492-32768,-32768, -4, -10, 282,-32768, 915, 915, 1217, 915,
1493 915, 289,-32768, 289, 915, 292, 1217, 1217, 1217,-32768,
1494-32768, 1217, 776,-32768,-32768, 290, 291, 293, 5,-32768,
1495 365, 400, 301, 294, 776, 0,-32768,-32768, 372,-32768,
1496-32768, 295, 915,-32768,-32768,-32768, 61,-32768,-32768,-32768,
1497-32768,-32768, 425,-32768,-32768, 430, -1,-32768, 1217,-32768,
1498-32768, 298,-32768,-32768, 915,-32768, 1043, 3, 143, 776,
1499 -6,-32768, -42,-32768, 311,-32768, 1043,-32768, 432, 433,
1500 314, 143, 915, 915, 435, 384,-32768, 915, 437,-32768,
1501 915,-32768, 453, 455,-32768
1502};
1503
1504static const short yypgoto[] = {-32768,
1505 275, 285, 287, 297, 197, 202, -252,-32768, 359,-32768,
1506-32768,-32768,-32768, -230, -330, -370,-32768, -277,-32768, -323,
1507 2,-32768, -184,-32768,-32768, -22, 181, -294,-32768, 343,
1508 352, -25, -78, -162, 225,-32768,-32768, 462,-32768,-32768,
1509-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 1, -26,
1510-32768,-32768, 428,-32768,-32768,-32768,-32768,-32768,-32768, -463,
1511 8, 104, -209,-32768, 426,-32768,-32768,-32768,-32768,-32768,
1512 -14, 78,-32768,-32768,-32768,-32768
1513};
1514
1515
1516#define YYLAST 1454
1517
1518
1519static const short yytable[] = { 73,
1520 12, 430, 322, 398, 239, 241, 174, 115, 321, 86,
1521 12, 353, 321, 97, 181, 290, 291, 310, 415, 1,
1522 100, 2, 415, 549, -167, 323, 58, 59, 392, 78,
1523 61, 62, 63, 64, 65, 20, 1, 441, 2, 1,
1524 443, 2, 3, 299, 310, 341, 411, 118, 4, 5,
1525 122, 37, 304, 328, 123, 197, 332, 333, 334, 335,
1526 336, 197, 66, 339, 340, 311, 198, 6, 344, 345,
1527 299, 179, 287, 545, 7, 303, 442, 50, 8, 442,
1528 299, 305, 21, 551, 15, 16, 17, 299, 414, 189,
1529 51, 363, 175, 118, -166, 38, 476, 39, 189, 12,
1530 344, 345, 499, 18, 344, 345, 120, 52, 121, 1,
1531 53, 2, 3, 319, 351, 344, 345, 320, 4, 5,
1532 414, 419, 54, 186, 414, 420, 56, 299, 370, 120,
1533 187, 121, 529, 413, 300, 182, 530, 6, 536, 23,
1534 24, 101, 546, 415, 7, 120, 116, 121, 8, 105,
1535 106, 350, 395, 120, 474, 121, 67, 539, 510, 68,
1536 511, 1, 69, 2, 70, 117, 97, 42, 43, 44,
1537 284, 285, 45, 120, 288, 121, 468, 552, 58, 59,
1538 249, 78, 61, 62, 63, 64, 65, 120, 1, 121,
1539 2, 400, 447, 529, 449, 450, 451, 533, 397, 120,
1540 455, 121, 124, 125, 294, 295, 296, 297, 298, 461,
1541 415, 104, 415, 108, 66, 302, 109, 306, 307, 308,
1542 309, 435, 110, 174, -56, -56, 126, 127, 342, 343,
1543 317, 87, 88, 89, 90, 91, 92, 93, 326, 327,
1544 317, 329, 330, 317, 317, 317, 317, 317, 337, 338,
1545 317, 317, 541, 344, 345, 543, 112, 76, 77, 189,
1546 113, 114, -57, 177, 193, -58, 354, 355, 128, 194,
1547 230, 231, 232, 361, 537, 233, 234, 514, 515, 516,
1548 242, 243, 247, 244, 245, 547, 280, 246, 282, 283,
1549 292, 372, 315, 289, 293, 286, 314, 321, 357, 352,
1550 179, 393, 394, 358, 359, 360, 362, 364, 67, 175,
1551 365, 68, 367, 366, 69, 368, 70, 195, 179, 412,
1552 317, 369, 401, 402, 387, 403, 387, 387, 404, 387,
1553 405, 421, 422, 423, 424, 406, 387, 409, 426, 427,
1554 410, 429, 425, 428, 387, 387, 417, 418, 431, 432,
1555 433, 436, 437, 58, 59, 446, 60, 61, 62, 63,
1556 64, 65, 452, 1, 453, 2, 202, 203, 204, 205,
1557 206, 207, 208, 209, 210, 211, 458, 462, 464, 317,
1558 448, 317, 317, 317, 463, 465, 454, 317, 466, 66,
1559 467, 459, 460, 475, 477, 478, 317, 469, 479, 387,
1560 387, 387, 483, 480, 481, 419, 485, 387, 473, 487,
1561 488, 489, 494, 523, 502, 492, 525, 495, 387, 387,
1562 442, 509, 389, 390, 513, 391, 519, 520, 534, 521,
1563 470, 527, 399, 526, 531, 493, 496, 542, 497, 498,
1564 407, 408, 535, 550, 553, 554, 555, 558, 387, 561,
1565 387, 559, 564, 387, 565, 324, 505, 184, 271, 387,
1566 387, 325, 348, 199, 317, 317, 317, 196, 272, 505,
1567 273, 36, 522, 96, 103, 500, 444, 517, 0, 0,
1568 274, 0, 0, 67, 387, 387, 68, 387, 387, 69,
1569 0, 70, 387, 0, 0, 438, 439, 440, 0, 470,
1570 387, 0, 0, 445, 0, 0, 540, 0, 0, 0,
1571 0, 0, 387, 0, 456, 457, 0, 0, 0, 0,
1572 387, 0, 58, 59, 0, 78, 61, 62, 63, 64,
1573 65, 0, 1, 0, 2, 0, 0, 0, 0, 0,
1574 0, 0, 387, 0, 482, 0, 484, 387, 188, 486,
1575 22, 0, 0, 0, 0, 490, 491, 0, 66, 0,
1576 387, 387, 23, 24, 0, 387, 0, 0, 387, 0,
1577 25, 26, 27, 28, 29, 30, 31, 0, 32, 0,
1578 503, 504, 0, 507, 508, 0, 0, 0, 512, 0,
1579 0, 0, 0, 0, 0, 0, 518, 0, 0, 0,
1580 58, 59, 0, 0, 0, 0, 0, 0, 528, 0,
1581 1, 0, 2, 0, 129, 0, 532, 0, 0, 0,
1582 0, 0, 0, 0, 0, 0, 0, 130, 131, 0,
1583 0, 0, 0, 0, 0, 0, 0, 0, 544, 0,
1584 0, 0, 0, 548, 0, 0, 0, 0, 0, 0,
1585 0, 0, 67, 0, 0, 68, 556, 557, 69, 0,
1586 70, 560, 0, 0, 562, 132, 133, 134, 135, 136,
1587 137, 138, 139, 140, 141, 142, 143, 144, 145, 0,
1588 0, 58, 59, 0, 78, 79, 80, 81, 82, 65,
1589 0, 1, 0, 2, 0, 0, 0, 0, 0, 0,
1590 0, 0, 0, 0, 146, 147, 148, 149, 150, 151,
1591 152, 153, 154, 155, 156, 157, 158, 66, 159, 160,
1592 161, 162, 0, 163, 164, 165, 0, 0, 0, 120,
1593 0, 121, 0, 166, 0, 0, 167, 0, 168, 0,
1594 169, 58, 59, 0, 78, 79, 80, 81, 82, 65,
1595 0, 1, 0, 2, 0, 0, 0, 0, 0, 0,
1596 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1597 0, 0, 0, 0, 0, 0, 0, 66, 375, 376,
1598 58, 59, 377, 0, 0, 0, 0, 0, 0, 0,
1599 1, 0, 2, 0, 378, 379, 380, 0, 0, 0,
1600 0, 0, 0, 0, 0, 0, 0, 381, 382, 0,
1601 0, 67, 0, 0, 68, 0, 0, 69, 0, 70,
1602 240, 0, 0, 0, 0, 0, 58, 59, 383, 78,
1603 79, 80, 81, 82, 65, 0, 1, 0, 2, 0,
1604 0, 0, 0, 0, 0, 132, 133, 134, 135, 136,
1605 137, 138, 139, 140, 141, 142, 143, 144, 145, 0,
1606 0, 0, 66, 0, 0, 0, 0, 0, 0, 0,
1607 0, 67, 0, 0, 68, 0, 0, 69, 0, 70,
1608 301, 0, 0, 0, 146, 147, 148, 149, 150, 151,
1609 152, 153, 154, 155, 156, 157, 158, 0, 159, 160,
1610 161, 162, 0, 163, 164, 165, 0, 0, 0, 120,
1611 0, 121, 0, 0, 0, 0, 384, 375, 376, 58,
1612 59, 377, 0, 0, 0, 0, 0, 0, 0, 1,
1613 0, 2, 0, 378, 379, 380, 213, 214, 0, 0,
1614 0, 0, 0, 0, 0, 0, 381, 382, 0, 0,
1615 0, 0, 0, 0, 0, 0, 67, 0, 0, 68,
1616 0, 235, 69, 0, 70, 0, 0, 383, 58, 59,
1617 0, 78, 79, 80, 81, 82, 65, 0, 1, 0,
1618 2, 0, 0, 0, 132, 133, 134, 135, 136, 137,
1619 138, 139, 140, 141, 142, 143, 144, 145, 0, 0,
1620 0, 0, 0, 0, 66, 0, 215, 216, 217, 218,
1621 219, 220, 221, 222, 223, 224, 225, 226, 227, 228,
1622 0, 0, 0, 146, 147, 148, 149, 150, 151, 152,
1623 153, 154, 155, 156, 157, 158, 0, 159, 160, 161,
1624 162, 0, 163, 164, 165, 375, 376, 0, 0, 377,
1625 0, 0, 0, 0, 0, 384, 0, 0, 0, 0,
1626 0, 378, 379, 380, 0, 0, 0, 0, 0, 0,
1627 0, 0, 0, 0, 381, 382, 0, 0, 0, 0,
1628 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1629 0, 0, 0, 0, 0, 383, 0, 0, 67, 0,
1630 0, 68, 0, 0, 69, 0, 70, 0, 0, 0,
1631 0, 0, 132, 133, 134, 135, 136, 137, 138, 139,
1632 140, 141, 142, 143, 144, 145, 0, 0, 0, 0,
1633 0, 0, 0, 0, 0, 0, 0, 0, 58, 59,
1634 0, 78, 61, 62, 63, 64, 65, 0, 1, 0,
1635 2, 146, 147, 148, 149, 150, 151, 152, 153, 154,
1636 155, 156, 157, 158, 347, 159, 160, 161, 162, 0,
1637 163, 164, 165, 0, 66, 0, 0, 0, 0, 0,
1638 0, 58, 59, 384, 78, 61, 62, 63, 64, 65,
1639 0, 1, 0, 2, 58, 59, 0, 78, 61, 62,
1640 63, 64, 65, 0, 1, 0, 2, 371, 0, 0,
1641 0, 0, 0, 0, 0, 0, 0, 66, 0, 0,
1642 472, 58, 59, 0, 78, 61, 62, 63, 64, 65,
1643 66, 1, 0, 2, 58, 59, 0, 178, 61, 62,
1644 63, 64, 65, 0, 1, 0, 2, 0, 58, 59,
1645 0, 78, 79, 80, 81, 82, 65, 66, 1, 0,
1646 2, 0, 0, 0, 0, 0, 0, 0, 67, 0,
1647 66, 68, 0, 0, 69, 0, 70, 0, 0, 0,
1648 0, 0, 58, 59, 66, 316, 61, 62, 63, 64,
1649 65, 0, 1, 0, 2, 0, 0, 0, 0, 0,
1650 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1651 0, 67, 0, 0, 68, 0, 0, 69, 66, 70,
1652 0, 0, 0, 0, 67, 0, 0, 68, 0, 0,
1653 69, 0, 70, 0, 0, 0, 0, 0, 0, 0,
1654 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1655 0, 67, 250, 0, 68, 0, 0, 69, 0, 70,
1656 0, 0, 0, 0, 67, 0, 0, 68, 0, 0,
1657 69, 0, 70, 0, 251, 252, 0, 0, 67, 0,
1658 0, 68, 0, 0, 69, 0, 238, 253, 254, 255,
1659 256, 257, 258, 132, 133, 134, 135, 136, 137, 138,
1660 139, 140, 141, 142, 143, 259, 260, 0, 0, 0,
1661 0, 0, 67, 0, 0, 68, 0, 0, 69, 0,
1662 70, 0, 0, 0, 0, 0, 0, 261, 262, 263,
1663 0, 0, 264, 147, 148, 149, 150, 151, 152, 153,
1664 154, 155, 156, 157, 158, 265, 266, 160, 161, 162,
1665 267, 268, 269, 270
1666};
1667
1668static const short yycheck[] = { 22,
1669 0, 372, 255, 327, 167, 168, 85, 4, 10, 35,
1670 10, 289, 10, 16, 22, 200, 201, 28, 349, 15,
1671 23, 17, 353, 30, 0, 256, 5, 6, 323, 8,
1672 9, 10, 11, 12, 13, 132, 15, 10, 17, 15,
1673 10, 17, 18, 133, 28, 276, 341, 70, 24, 25,
1674 76, 132, 142, 263, 77, 133, 266, 267, 268, 269,
1675 270, 133, 41, 273, 274, 49, 144, 43, 111, 112,
1676 133, 94, 144, 537, 50, 238, 49, 132, 54, 49,
1677 133, 144, 53, 547, 44, 45, 46, 133, 131, 112,
1678 132, 144, 85, 116, 0, 38, 142, 40, 121, 99,
1679 111, 112, 473, 63, 111, 112, 134, 132, 136, 15,
1680 132, 17, 18, 9, 142, 111, 112, 13, 24, 25,
1681 131, 133, 138, 133, 131, 137, 17, 133, 313, 134,
1682 140, 136, 133, 343, 140, 143, 137, 43, 140, 26,
1683 27, 144, 140, 474, 50, 134, 143, 136, 54, 47,
1684 48, 140, 133, 134, 432, 136, 135, 528, 482, 138,
1685 484, 15, 141, 17, 143, 144, 16, 34, 35, 36,
1686 193, 194, 39, 134, 197, 136, 137, 548, 5, 6,
1687 180, 8, 9, 10, 11, 12, 13, 134, 15, 136,
1688 17, 138, 402, 133, 404, 405, 406, 137, 133, 134,
1689 410, 136, 20, 21, 230, 231, 232, 233, 234, 419,
1690 541, 17, 543, 4, 41, 238, 17, 243, 244, 245,
1691 246, 384, 17, 302, 3, 4, 3, 4, 107, 108,
1692 253, 56, 57, 58, 59, 60, 61, 62, 261, 262,
1693 263, 264, 265, 266, 267, 268, 269, 270, 271, 272,
1694 273, 274, 530, 111, 112, 533, 136, 33, 34, 282,
1695 4, 4, 7, 4, 139, 7, 292, 293, 7, 139,
1696 136, 136, 136, 299, 527, 136, 136, 487, 488, 489,
1697 17, 136, 133, 136, 136, 538, 17, 136, 133, 137,
1698 136, 314, 51, 137, 136, 142, 136, 10, 133, 142,
1699 323, 324, 325, 133, 133, 133, 142, 133, 135, 302,
1700 133, 138, 133, 30, 141, 17, 143, 144, 341, 342,
1701 343, 4, 133, 133, 317, 133, 319, 320, 133, 322,
1702 133, 357, 358, 359, 360, 133, 329, 30, 364, 365,
1703 133, 367, 142, 366, 337, 338, 133, 133, 133, 137,
1704 55, 133, 133, 5, 6, 138, 8, 9, 10, 11,
1705 12, 13, 133, 15, 133, 17, 84, 85, 86, 87,
1706 88, 89, 90, 91, 92, 93, 133, 133, 133, 402,
1707 403, 404, 405, 406, 137, 133, 409, 410, 137, 41,
1708 137, 417, 418, 17, 13, 13, 419, 137, 136, 392,
1709 393, 394, 4, 133, 133, 133, 133, 400, 431, 133,
1710 133, 133, 137, 49, 133, 136, 17, 137, 411, 412,
1711 49, 133, 319, 320, 133, 322, 137, 137, 4, 137,
1712 430, 138, 329, 133, 140, 458, 462, 140, 464, 465,
1713 337, 338, 13, 133, 13, 13, 133, 13, 441, 13,
1714 443, 68, 0, 446, 0, 259, 479, 99, 184, 452,
1715 453, 260, 282, 121, 487, 488, 489, 116, 184, 492,
1716 184, 10, 499, 46, 49, 474, 399, 492, -1, -1,
1717 184, -1, -1, 135, 477, 478, 138, 480, 481, 141,
1718 -1, 143, 485, -1, -1, 392, 393, 394, -1, 499,
1719 493, -1, -1, 400, -1, -1, 529, -1, -1, -1,
1720 -1, -1, 505, -1, 411, 412, -1, -1, -1, -1,
1721 513, -1, 5, 6, -1, 8, 9, 10, 11, 12,
1722 13, -1, 15, -1, 17, -1, -1, -1, -1, -1,
1723 -1, -1, 535, -1, 441, -1, 443, 540, 31, 446,
1724 14, -1, -1, -1, -1, 452, 453, -1, 41, -1,
1725 553, 554, 26, 27, -1, 558, -1, -1, 561, -1,
1726 34, 35, 36, 37, 38, 39, 40, -1, 42, -1,
1727 477, 478, -1, 480, 481, -1, -1, -1, 485, -1,
1728 -1, -1, -1, -1, -1, -1, 493, -1, -1, -1,
1729 5, 6, -1, -1, -1, -1, -1, -1, 505, -1,
1730 15, -1, 17, -1, 19, -1, 513, -1, -1, -1,
1731 -1, -1, -1, -1, -1, -1, -1, 32, 33, -1,
1732 -1, -1, -1, -1, -1, -1, -1, -1, 535, -1,
1733 -1, -1, -1, 540, -1, -1, -1, -1, -1, -1,
1734 -1, -1, 135, -1, -1, 138, 553, 554, 141, -1,
1735 143, 558, -1, -1, 561, 70, 71, 72, 73, 74,
1736 75, 76, 77, 78, 79, 80, 81, 82, 83, -1,
1737 -1, 5, 6, -1, 8, 9, 10, 11, 12, 13,
1738 -1, 15, -1, 17, -1, -1, -1, -1, -1, -1,
1739 -1, -1, -1, -1, 109, 110, 111, 112, 113, 114,
1740 115, 116, 117, 118, 119, 120, 121, 41, 123, 124,
1741 125, 126, -1, 128, 129, 130, -1, -1, -1, 134,
1742 -1, 136, -1, 138, -1, -1, 141, -1, 143, -1,
1743 145, 5, 6, -1, 8, 9, 10, 11, 12, 13,
1744 -1, 15, -1, 17, -1, -1, -1, -1, -1, -1,
1745 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1746 -1, -1, -1, -1, -1, -1, -1, 41, 3, 4,
1747 5, 6, 7, -1, -1, -1, -1, -1, -1, -1,
1748 15, -1, 17, -1, 19, 20, 21, -1, -1, -1,
1749 -1, -1, -1, -1, -1, -1, -1, 32, 33, -1,
1750 -1, 135, -1, -1, 138, -1, -1, 141, -1, 143,
1751 144, -1, -1, -1, -1, -1, 5, 6, 53, 8,
1752 9, 10, 11, 12, 13, -1, 15, -1, 17, -1,
1753 -1, -1, -1, -1, -1, 70, 71, 72, 73, 74,
1754 75, 76, 77, 78, 79, 80, 81, 82, 83, -1,
1755 -1, -1, 41, -1, -1, -1, -1, -1, -1, -1,
1756 -1, 135, -1, -1, 138, -1, -1, 141, -1, 143,
1757 144, -1, -1, -1, 109, 110, 111, 112, 113, 114,
1758 115, 116, 117, 118, 119, 120, 121, -1, 123, 124,
1759 125, 126, -1, 128, 129, 130, -1, -1, -1, 134,
1760 -1, 136, -1, -1, -1, -1, 141, 3, 4, 5,
1761 6, 7, -1, -1, -1, -1, -1, -1, -1, 15,
1762 -1, 17, -1, 19, 20, 21, 20, 21, -1, -1,
1763 -1, -1, -1, -1, -1, -1, 32, 33, -1, -1,
1764 -1, -1, -1, -1, -1, -1, 135, -1, -1, 138,
1765 -1, 140, 141, -1, 143, -1, -1, 53, 5, 6,
1766 -1, 8, 9, 10, 11, 12, 13, -1, 15, -1,
1767 17, -1, -1, -1, 70, 71, 72, 73, 74, 75,
1768 76, 77, 78, 79, 80, 81, 82, 83, -1, -1,
1769 -1, -1, -1, -1, 41, -1, 90, 91, 92, 93,
1770 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
1771 -1, -1, -1, 109, 110, 111, 112, 113, 114, 115,
1772 116, 117, 118, 119, 120, 121, -1, 123, 124, 125,
1773 126, -1, 128, 129, 130, 3, 4, -1, -1, 7,
1774 -1, -1, -1, -1, -1, 141, -1, -1, -1, -1,
1775 -1, 19, 20, 21, -1, -1, -1, -1, -1, -1,
1776 -1, -1, -1, -1, 32, 33, -1, -1, -1, -1,
1777 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1778 -1, -1, -1, -1, -1, 53, -1, -1, 135, -1,
1779 -1, 138, -1, -1, 141, -1, 143, -1, -1, -1,
1780 -1, -1, 70, 71, 72, 73, 74, 75, 76, 77,
1781 78, 79, 80, 81, 82, 83, -1, -1, -1, -1,
1782 -1, -1, -1, -1, -1, -1, -1, -1, 5, 6,
1783 -1, 8, 9, 10, 11, 12, 13, -1, 15, -1,
1784 17, 109, 110, 111, 112, 113, 114, 115, 116, 117,
1785 118, 119, 120, 121, 31, 123, 124, 125, 126, -1,
1786 128, 129, 130, -1, 41, -1, -1, -1, -1, -1,
1787 -1, 5, 6, 141, 8, 9, 10, 11, 12, 13,
1788 -1, 15, -1, 17, 5, 6, -1, 8, 9, 10,
1789 11, 12, 13, -1, 15, -1, 17, 31, -1, -1,
1790 -1, -1, -1, -1, -1, -1, -1, 41, -1, -1,
1791 31, 5, 6, -1, 8, 9, 10, 11, 12, 13,
1792 41, 15, -1, 17, 5, 6, -1, 8, 9, 10,
1793 11, 12, 13, -1, 15, -1, 17, -1, 5, 6,
1794 -1, 8, 9, 10, 11, 12, 13, 41, 15, -1,
1795 17, -1, -1, -1, -1, -1, -1, -1, 135, -1,
1796 41, 138, -1, -1, 141, -1, 143, -1, -1, -1,
1797 -1, -1, 5, 6, 41, 8, 9, 10, 11, 12,
1798 13, -1, 15, -1, 17, -1, -1, -1, -1, -1,
1799 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1800 -1, 135, -1, -1, 138, -1, -1, 141, 41, 143,
1801 -1, -1, -1, -1, 135, -1, -1, 138, -1, -1,
1802 141, -1, 143, -1, -1, -1, -1, -1, -1, -1,
1803 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1804 -1, 135, 29, -1, 138, -1, -1, 141, -1, 143,
1805 -1, -1, -1, -1, 135, -1, -1, 138, -1, -1,
1806 141, -1, 143, -1, 51, 52, -1, -1, 135, -1,
1807 -1, 138, -1, -1, 141, -1, 143, 64, 65, 66,
1808 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1809 77, 78, 79, 80, 81, 82, 83, -1, -1, -1,
1810 -1, -1, 135, -1, -1, 138, -1, -1, 141, -1,
1811 143, -1, -1, -1, -1, -1, -1, 104, 105, 106,
1812 -1, -1, 109, 110, 111, 112, 113, 114, 115, 116,
1813 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
1814 127, 128, 129, 130
1815};
1816/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
1817#line 3 "/usr/share/bison.simple"
1818/* This file comes from bison-1.28. */
1819
1820/* Skeleton output parser for bison,
1821 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
1822
1823 This program is free software; you can redistribute it and/or modify
1824 it under the terms of the GNU General Public License as published by
1825 the Free Software Foundation; either version 2, or (at your option)
1826 any later version.
1827
1828 This program is distributed in the hope that it will be useful,
1829 but WITHOUT ANY WARRANTY; without even the implied warranty of
1830 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1831 GNU General Public License for more details.
1832
1833 You should have received a copy of the GNU General Public License
1834 along with this program; if not, write to the Free Software
1835 Foundation, Inc., 59 Temple Place - Suite 330,
1836 Boston, MA 02111-1307, USA. */
1837
1838/* As a special exception, when this file is copied by Bison into a
1839 Bison output file, you may use that output file without restriction.
1840 This special exception was added by the Free Software Foundation
1841 in version 1.24 of Bison. */
1842
1843/* This is the parser code that is written into each bison parser
1844 when the %semantic_parser declaration is not specified in the grammar.
1845 It was written by Richard Stallman by simplifying the hairy parser
1846 used when %semantic_parser is specified. */
1847
1848#ifndef YYSTACK_USE_ALLOCA
1849#ifdef alloca
1850#define YYSTACK_USE_ALLOCA
1851#else /* alloca not defined */
1852#ifdef __GNUC__
1853#define YYSTACK_USE_ALLOCA
1854#define alloca __builtin_alloca
1855#else /* not GNU C. */
1856#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
1857#define YYSTACK_USE_ALLOCA
1858#include <alloca.h>
1859#else /* not sparc */
1860/* We think this test detects Watcom and Microsoft C. */
1861/* This used to test MSDOS, but that is a bad idea
1862 since that symbol is in the user namespace. */
1863#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
1864#if 0 /* No need for malloc.h, which pollutes the namespace;
1865 instead, just don't use alloca. */
1866#include <malloc.h>
1867#endif
1868#else /* not MSDOS, or __TURBOC__ */
1869#if defined(_AIX)
1870/* I don't know what this was needed for, but it pollutes the namespace.
1871 So I turned it off. rms, 2 May 1997. */
1872/* #include <malloc.h> */
1873 #pragma alloca
1874#define YYSTACK_USE_ALLOCA
1875#else /* not MSDOS, or __TURBOC__, or _AIX */
1876#if 0
1877#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
1878 and on HPUX 10. Eventually we can turn this on. */
1879#define YYSTACK_USE_ALLOCA
1880#define alloca __builtin_alloca
1881#endif /* __hpux */
1882#endif
1883#endif /* not _AIX */
1884#endif /* not MSDOS, or __TURBOC__ */
1885#endif /* not sparc */
1886#endif /* not GNU C */
1887#endif /* alloca not defined */
1888#endif /* YYSTACK_USE_ALLOCA not defined */
1889
1890#ifdef YYSTACK_USE_ALLOCA
1891#define YYSTACK_ALLOC alloca
Andrew Lenharth6353e052006-12-08 18:07:09 +00001892#else
Chris Lattner0fab59c2007-01-12 18:33:30 +00001893#define YYSTACK_ALLOC malloc
Andrew Lenharth6353e052006-12-08 18:07:09 +00001894#endif
1895
Chris Lattner0fab59c2007-01-12 18:33:30 +00001896/* Note: there must be only one dollar sign in this file.
1897 It is replaced by the list of actions, each action
1898 as one case of the switch. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001899
1900#define yyerrok (yyerrstatus = 0)
1901#define yyclearin (yychar = YYEMPTY)
Chris Lattner0fab59c2007-01-12 18:33:30 +00001902#define YYEMPTY -2
Reid Spencer68a24bd2005-08-27 18:50:39 +00001903#define YYEOF 0
Reid Spencer68a24bd2005-08-27 18:50:39 +00001904#define YYACCEPT goto yyacceptlab
Chris Lattner0fab59c2007-01-12 18:33:30 +00001905#define YYABORT goto yyabortlab
1906#define YYERROR goto yyerrlab1
1907/* Like YYERROR except do call yyerror.
1908 This remains here temporarily to ease the
1909 transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00001910 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001911#define YYFAIL goto yyerrlab
Reid Spencer68a24bd2005-08-27 18:50:39 +00001912#define YYRECOVERING() (!!yyerrstatus)
Chris Lattner0fab59c2007-01-12 18:33:30 +00001913#define YYBACKUP(token, value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00001914do \
1915 if (yychar == YYEMPTY && yylen == 1) \
Chris Lattner0fab59c2007-01-12 18:33:30 +00001916 { yychar = (token), yylval = (value); \
1917 yychar1 = YYTRANSLATE (yychar); \
Andrew Lenharth6353e052006-12-08 18:07:09 +00001918 YYPOPSTACK; \
Reid Spencer68a24bd2005-08-27 18:50:39 +00001919 goto yybackup; \
1920 } \
1921 else \
Chris Lattner0fab59c2007-01-12 18:33:30 +00001922 { yyerror ("syntax error: cannot back up"); YYERROR; } \
Andrew Lenharth6353e052006-12-08 18:07:09 +00001923while (0)
Reid Spencer3822ff52006-11-08 06:47:33 +00001924
Reid Spencer68a24bd2005-08-27 18:50:39 +00001925#define YYTERROR 1
1926#define YYERRCODE 256
1927
Chris Lattner0fab59c2007-01-12 18:33:30 +00001928#ifndef YYPURE
1929#define YYLEX yylex()
Reid Spencer68a24bd2005-08-27 18:50:39 +00001930#endif
1931
Chris Lattner0fab59c2007-01-12 18:33:30 +00001932#ifdef YYPURE
1933#ifdef YYLSP_NEEDED
Reid Spencer68a24bd2005-08-27 18:50:39 +00001934#ifdef YYLEX_PARAM
Chris Lattner0fab59c2007-01-12 18:33:30 +00001935#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001936#else
Chris Lattner0fab59c2007-01-12 18:33:30 +00001937#define YYLEX yylex(&yylval, &yylloc)
1938#endif
1939#else /* not YYLSP_NEEDED */
1940#ifdef YYLEX_PARAM
1941#define YYLEX yylex(&yylval, YYLEX_PARAM)
1942#else
1943#define YYLEX yylex(&yylval)
1944#endif
1945#endif /* not YYLSP_NEEDED */
Chris Lattnerf49c1762006-11-08 05:58:47 +00001946#endif
Reid Spencer3822ff52006-11-08 06:47:33 +00001947
Chris Lattner0fab59c2007-01-12 18:33:30 +00001948/* If nonreentrant, generate the variables here */
Reid Spencer3822ff52006-11-08 06:47:33 +00001949
Chris Lattner0fab59c2007-01-12 18:33:30 +00001950#ifndef YYPURE
Reid Spencer3822ff52006-11-08 06:47:33 +00001951
Chris Lattner0fab59c2007-01-12 18:33:30 +00001952int yychar; /* the lookahead symbol */
1953YYSTYPE yylval; /* the semantic value of the */
1954 /* lookahead symbol */
Reid Spencer3822ff52006-11-08 06:47:33 +00001955
Chris Lattner0fab59c2007-01-12 18:33:30 +00001956#ifdef YYLSP_NEEDED
1957YYLTYPE yylloc; /* location data for the lookahead */
1958 /* symbol */
Chris Lattnerf49c1762006-11-08 05:58:47 +00001959#endif
Reid Spencer3822ff52006-11-08 06:47:33 +00001960
Chris Lattner0fab59c2007-01-12 18:33:30 +00001961int yynerrs; /* number of parse errors so far */
1962#endif /* not YYPURE */
Reid Spencer3822ff52006-11-08 06:47:33 +00001963
Chris Lattner0fab59c2007-01-12 18:33:30 +00001964#if YYDEBUG != 0
1965int yydebug; /* nonzero means print parse trace */
1966/* Since this is uninitialized, it does not stop multiple parsers
1967 from coexisting. */
Chris Lattner1ae022f2006-10-22 06:08:13 +00001968#endif
Reid Spencer21be8652006-10-22 07:03:43 +00001969
Chris Lattner0fab59c2007-01-12 18:33:30 +00001970/* YYINITDEPTH indicates the initial size of the parser's stacks */
Reid Spencer21be8652006-10-22 07:03:43 +00001971
Reid Spencer68a24bd2005-08-27 18:50:39 +00001972#ifndef YYINITDEPTH
Chris Lattner0fab59c2007-01-12 18:33:30 +00001973#define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00001974#endif
1975
Chris Lattner0fab59c2007-01-12 18:33:30 +00001976/* YYMAXDEPTH is the maximum size the stacks can grow to
1977 (effective only if the built-in stack extension method is used). */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001978
Chris Lattner0fab59c2007-01-12 18:33:30 +00001979#if YYMAXDEPTH == 0
1980#undef YYMAXDEPTH
1981#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001982
1983#ifndef YYMAXDEPTH
Chris Lattner0fab59c2007-01-12 18:33:30 +00001984#define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00001985#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001986
Chris Lattner0fab59c2007-01-12 18:33:30 +00001987/* Define __yy_memcpy. Note that the size argument
1988 should be passed with type unsigned int, because that is what the non-GCC
1989 definitions require. With GCC, __builtin_memcpy takes an arg
1990 of type size_t, but it can handle unsigned int. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001991
Chris Lattner0fab59c2007-01-12 18:33:30 +00001992#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
1993#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
1994#else /* not GNU C or C++ */
1995#ifndef __cplusplus
Reid Spencer68a24bd2005-08-27 18:50:39 +00001996
Chris Lattner0fab59c2007-01-12 18:33:30 +00001997/* This is the most reliable way to avoid incompatibilities
1998 in available built-in functions on various systems. */
Reid Spencer3822ff52006-11-08 06:47:33 +00001999static void
Chris Lattner0fab59c2007-01-12 18:33:30 +00002000__yy_memcpy (to, from, count)
2001 char *to;
2002 char *from;
2003 unsigned int count;
2004{
2005 register char *f = from;
2006 register char *t = to;
2007 register int i = count;
2008
2009 while (i-- > 0)
2010 *t++ = *f++;
2011}
2012
2013#else /* __cplusplus */
2014
2015/* This is the most reliable way to avoid incompatibilities
2016 in available built-in functions on various systems. */
Reid Spencer3822ff52006-11-08 06:47:33 +00002017static void
Chris Lattner0fab59c2007-01-12 18:33:30 +00002018__yy_memcpy (char *to, char *from, unsigned int count)
2019{
2020 register char *t = to;
2021 register char *f = from;
2022 register int i = count;
2023
2024 while (i-- > 0)
2025 *t++ = *f++;
2026}
2027
Reid Spencer3822ff52006-11-08 06:47:33 +00002028#endif
Andrew Lenharth6353e052006-12-08 18:07:09 +00002029#endif
Reid Spencer3822ff52006-11-08 06:47:33 +00002030
Chris Lattner0fab59c2007-01-12 18:33:30 +00002031#line 217 "/usr/share/bison.simple"
Reid Spencer3822ff52006-11-08 06:47:33 +00002032
Chris Lattner0fab59c2007-01-12 18:33:30 +00002033/* The user can define YYPARSE_PARAM as the name of an argument to be passed
2034 into yyparse. The argument should have type void *.
2035 It should actually point to an object.
2036 Grammar actions can access the variable by casting it
2037 to the proper pointer type. */
Reid Spencer3822ff52006-11-08 06:47:33 +00002038
2039#ifdef YYPARSE_PARAM
Chris Lattner0fab59c2007-01-12 18:33:30 +00002040#ifdef __cplusplus
2041#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
2042#define YYPARSE_PARAM_DECL
2043#else /* not __cplusplus */
2044#define YYPARSE_PARAM_ARG YYPARSE_PARAM
2045#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
2046#endif /* not __cplusplus */
2047#else /* not YYPARSE_PARAM */
2048#define YYPARSE_PARAM_ARG
2049#define YYPARSE_PARAM_DECL
2050#endif /* not YYPARSE_PARAM */
2051
2052/* Prevent warning if -Wstrict-prototypes. */
2053#ifdef __GNUC__
2054#ifdef YYPARSE_PARAM
2055int yyparse (void *);
2056#else
Reid Spencere812fb22006-01-19 01:21:04 +00002057int yyparse (void);
Reid Spencer3822ff52006-11-08 06:47:33 +00002058#endif
Chris Lattner0fab59c2007-01-12 18:33:30 +00002059#endif
Reid Spencer3822ff52006-11-08 06:47:33 +00002060
Reid Spencer3822ff52006-11-08 06:47:33 +00002061int
Chris Lattner0fab59c2007-01-12 18:33:30 +00002062yyparse(YYPARSE_PARAM_ARG)
2063 YYPARSE_PARAM_DECL
Reid Spencer3822ff52006-11-08 06:47:33 +00002064{
Chris Lattner0fab59c2007-01-12 18:33:30 +00002065 register int yystate;
2066 register int yyn;
2067 register short *yyssp;
2068 register YYSTYPE *yyvsp;
2069 int yyerrstatus; /* number of tokens to shift before error messages enabled */
2070 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
Reid Spencer3822ff52006-11-08 06:47:33 +00002071
Chris Lattner0fab59c2007-01-12 18:33:30 +00002072 short yyssa[YYINITDEPTH]; /* the state stack */
2073 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
Reid Spencer3822ff52006-11-08 06:47:33 +00002074
Chris Lattner0fab59c2007-01-12 18:33:30 +00002075 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
2076 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
Reid Spencer3822ff52006-11-08 06:47:33 +00002077
Chris Lattner0fab59c2007-01-12 18:33:30 +00002078#ifdef YYLSP_NEEDED
2079 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
2080 YYLTYPE *yyls = yylsa;
2081 YYLTYPE *yylsp;
Reid Spencer3822ff52006-11-08 06:47:33 +00002082
Chris Lattner0fab59c2007-01-12 18:33:30 +00002083#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
2084#else
Andrew Lenharth6353e052006-12-08 18:07:09 +00002085#define YYPOPSTACK (yyvsp--, yyssp--)
Chris Lattner0fab59c2007-01-12 18:33:30 +00002086#endif
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002087
Chris Lattner0fab59c2007-01-12 18:33:30 +00002088 int yystacksize = YYINITDEPTH;
2089 int yyfree_stacks = 0;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002090
Chris Lattner0fab59c2007-01-12 18:33:30 +00002091#ifdef YYPURE
2092 int yychar;
2093 YYSTYPE yylval;
2094 int yynerrs;
2095#ifdef YYLSP_NEEDED
2096 YYLTYPE yylloc;
2097#endif
2098#endif
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002099
Chris Lattner0fab59c2007-01-12 18:33:30 +00002100 YYSTYPE yyval; /* the variable used to return */
2101 /* semantic values from the action */
2102 /* routines */
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002103
Andrew Lenharth6353e052006-12-08 18:07:09 +00002104 int yylen;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002105
Chris Lattner0fab59c2007-01-12 18:33:30 +00002106#if YYDEBUG != 0
2107 if (yydebug)
2108 fprintf(stderr, "Starting parse\n");
2109#endif
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002110
Reid Spencer68a24bd2005-08-27 18:50:39 +00002111 yystate = 0;
2112 yyerrstatus = 0;
2113 yynerrs = 0;
2114 yychar = YYEMPTY; /* Cause a token to be read. */
2115
2116 /* Initialize stack pointers.
2117 Waste one element of value and location stack
2118 so that they stay on the same level as the state stack.
2119 The wasted elements are never initialized. */
2120
Chris Lattner0fab59c2007-01-12 18:33:30 +00002121 yyssp = yyss - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002122 yyvsp = yyvs;
Chris Lattner0fab59c2007-01-12 18:33:30 +00002123#ifdef YYLSP_NEEDED
2124 yylsp = yyls;
2125#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002126
Chris Lattner0fab59c2007-01-12 18:33:30 +00002127/* Push a new state, which is found in yystate . */
2128/* In all cases, when you get here, the value and location stacks
2129 have just been pushed. so pushing a state here evens the stacks. */
2130yynewstate:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002131
Chris Lattner0fab59c2007-01-12 18:33:30 +00002132 *++yyssp = yystate;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002133
Chris Lattner0fab59c2007-01-12 18:33:30 +00002134 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002135 {
Chris Lattner0fab59c2007-01-12 18:33:30 +00002136 /* Give user a chance to reallocate the stack */
2137 /* Use copies of these so that the &'s don't force the real ones into memory. */
2138 YYSTYPE *yyvs1 = yyvs;
2139 short *yyss1 = yyss;
2140#ifdef YYLSP_NEEDED
2141 YYLTYPE *yyls1 = yyls;
2142#endif
2143
Reid Spencer68a24bd2005-08-27 18:50:39 +00002144 /* Get the current used size of the three stacks, in elements. */
Chris Lattner0fab59c2007-01-12 18:33:30 +00002145 int size = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002146
2147#ifdef yyoverflow
Chris Lattner0fab59c2007-01-12 18:33:30 +00002148 /* Each stack pointer address is followed by the size of
2149 the data in use in that stack, in bytes. */
2150#ifdef YYLSP_NEEDED
2151 /* This used to be a conditional around just the two extra args,
2152 but that might be undefined if yyoverflow is a macro. */
2153 yyoverflow("parser stack overflow",
2154 &yyss1, size * sizeof (*yyssp),
2155 &yyvs1, size * sizeof (*yyvsp),
2156 &yyls1, size * sizeof (*yylsp),
2157 &yystacksize);
2158#else
2159 yyoverflow("parser stack overflow",
2160 &yyss1, size * sizeof (*yyssp),
2161 &yyvs1, size * sizeof (*yyvsp),
2162 &yystacksize);
2163#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002164
Chris Lattner0fab59c2007-01-12 18:33:30 +00002165 yyss = yyss1; yyvs = yyvs1;
2166#ifdef YYLSP_NEEDED
2167 yyls = yyls1;
2168#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002169#else /* no yyoverflow */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002170 /* Extend the stack our own way. */
Chris Lattner0fab59c2007-01-12 18:33:30 +00002171 if (yystacksize >= YYMAXDEPTH)
2172 {
2173 yyerror("parser stack overflow");
2174 if (yyfree_stacks)
2175 {
2176 free (yyss);
2177 free (yyvs);
2178#ifdef YYLSP_NEEDED
2179 free (yyls);
2180#endif
2181 }
2182 return 2;
2183 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002184 yystacksize *= 2;
Chris Lattner0fab59c2007-01-12 18:33:30 +00002185 if (yystacksize > YYMAXDEPTH)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002186 yystacksize = YYMAXDEPTH;
Chris Lattner0fab59c2007-01-12 18:33:30 +00002187#ifndef YYSTACK_USE_ALLOCA
2188 yyfree_stacks = 1;
2189#endif
2190 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
2191 __yy_memcpy ((char *)yyss, (char *)yyss1,
2192 size * (unsigned int) sizeof (*yyssp));
2193 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
2194 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
2195 size * (unsigned int) sizeof (*yyvsp));
2196#ifdef YYLSP_NEEDED
2197 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
2198 __yy_memcpy ((char *)yyls, (char *)yyls1,
2199 size * (unsigned int) sizeof (*yylsp));
2200#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002201#endif /* no yyoverflow */
2202
Chris Lattner0fab59c2007-01-12 18:33:30 +00002203 yyssp = yyss + size - 1;
2204 yyvsp = yyvs + size - 1;
2205#ifdef YYLSP_NEEDED
2206 yylsp = yyls + size - 1;
2207#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002208
Chris Lattner0fab59c2007-01-12 18:33:30 +00002209#if YYDEBUG != 0
2210 if (yydebug)
2211 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2212#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002213
Chris Lattner0fab59c2007-01-12 18:33:30 +00002214 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002215 YYABORT;
2216 }
2217
Chris Lattner0fab59c2007-01-12 18:33:30 +00002218#if YYDEBUG != 0
2219 if (yydebug)
2220 fprintf(stderr, "Entering state %d\n", yystate);
2221#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002222
2223 goto yybackup;
Chris Lattner0fab59c2007-01-12 18:33:30 +00002224 yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002225
Andrew Lenharth6353e052006-12-08 18:07:09 +00002226/* Do appropriate processing given the current state. */
Chris Lattner0fab59c2007-01-12 18:33:30 +00002227/* Read a lookahead token if we need one and don't already have one. */
Andrew Lenharth6353e052006-12-08 18:07:09 +00002228/* yyresume: */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002229
Chris Lattner0fab59c2007-01-12 18:33:30 +00002230 /* First try to decide what to do without reference to lookahead token. */
Andrew Lenharth6353e052006-12-08 18:07:09 +00002231
Reid Spencer68a24bd2005-08-27 18:50:39 +00002232 yyn = yypact[yystate];
Chris Lattner0fab59c2007-01-12 18:33:30 +00002233 if (yyn == YYFLAG)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002234 goto yydefault;
2235
Chris Lattner0fab59c2007-01-12 18:33:30 +00002236 /* Not known => get a lookahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002237
Chris Lattner0fab59c2007-01-12 18:33:30 +00002238 /* yychar is either YYEMPTY or YYEOF
2239 or a valid token in external form. */
2240
Reid Spencer68a24bd2005-08-27 18:50:39 +00002241 if (yychar == YYEMPTY)
2242 {
Chris Lattner0fab59c2007-01-12 18:33:30 +00002243#if YYDEBUG != 0
2244 if (yydebug)
2245 fprintf(stderr, "Reading a token: ");
2246#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002247 yychar = YYLEX;
2248 }
2249
Chris Lattner0fab59c2007-01-12 18:33:30 +00002250 /* Convert token to internal form (in yychar1) for indexing tables with */
2251
2252 if (yychar <= 0) /* This means end of input. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002253 {
Chris Lattner0fab59c2007-01-12 18:33:30 +00002254 yychar1 = 0;
2255 yychar = YYEOF; /* Don't call YYLEX any more */
2256
2257#if YYDEBUG != 0
2258 if (yydebug)
2259 fprintf(stderr, "Now at end of input.\n");
2260#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002261 }
2262 else
2263 {
Chris Lattner0fab59c2007-01-12 18:33:30 +00002264 yychar1 = YYTRANSLATE(yychar);
2265
2266#if YYDEBUG != 0
2267 if (yydebug)
2268 {
2269 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2270 /* Give the individual parser a way to print the precise meaning
2271 of a token, for further debugging info. */
2272#ifdef YYPRINT
2273 YYPRINT (stderr, yychar, yylval);
2274#endif
2275 fprintf (stderr, ")\n");
2276 }
2277#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002278 }
2279
Chris Lattner0fab59c2007-01-12 18:33:30 +00002280 yyn += yychar1;
2281 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002282 goto yydefault;
Chris Lattner0fab59c2007-01-12 18:33:30 +00002283
Reid Spencer68a24bd2005-08-27 18:50:39 +00002284 yyn = yytable[yyn];
Chris Lattner0fab59c2007-01-12 18:33:30 +00002285
2286 /* yyn is what to do for this token type in this state.
2287 Negative => reduce, -yyn is rule number.
2288 Positive => shift, yyn is new state.
2289 New state is final state => don't bother to shift,
2290 just return success.
2291 0, or most negative number => error. */
2292
2293 if (yyn < 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002294 {
Chris Lattner0fab59c2007-01-12 18:33:30 +00002295 if (yyn == YYFLAG)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002296 goto yyerrlab;
2297 yyn = -yyn;
2298 goto yyreduce;
2299 }
Chris Lattner0fab59c2007-01-12 18:33:30 +00002300 else if (yyn == 0)
2301 goto yyerrlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002302
2303 if (yyn == YYFINAL)
2304 YYACCEPT;
2305
Chris Lattner0fab59c2007-01-12 18:33:30 +00002306 /* Shift the lookahead token. */
2307
2308#if YYDEBUG != 0
2309 if (yydebug)
2310 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2311#endif
Andrew Lenharth6353e052006-12-08 18:07:09 +00002312
2313 /* Discard the token being shifted unless it is eof. */
2314 if (yychar != YYEOF)
2315 yychar = YYEMPTY;
2316
2317 *++yyvsp = yylval;
Chris Lattner0fab59c2007-01-12 18:33:30 +00002318#ifdef YYLSP_NEEDED
2319 *++yylsp = yylloc;
2320#endif
Andrew Lenharth6353e052006-12-08 18:07:09 +00002321
Chris Lattner0fab59c2007-01-12 18:33:30 +00002322 /* count tokens shifted since error; after three, turn off error status. */
2323 if (yyerrstatus) yyerrstatus--;
Chris Lattner224f84f2006-08-18 17:34:45 +00002324
Reid Spencer68a24bd2005-08-27 18:50:39 +00002325 yystate = yyn;
2326 goto yynewstate;
2327
Chris Lattner0fab59c2007-01-12 18:33:30 +00002328/* Do the default action for the current state. */
Reid Spencer3822ff52006-11-08 06:47:33 +00002329yydefault:
Chris Lattner0fab59c2007-01-12 18:33:30 +00002330
Reid Spencer68a24bd2005-08-27 18:50:39 +00002331 yyn = yydefact[yystate];
2332 if (yyn == 0)
2333 goto yyerrlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002334
Chris Lattner0fab59c2007-01-12 18:33:30 +00002335/* Do a reduction. yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002336yyreduce:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002337 yylen = yyr2[yyn];
Chris Lattner0fab59c2007-01-12 18:33:30 +00002338 if (yylen > 0)
2339 yyval = yyvsp[1-yylen]; /* implement default value of the action */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002340
Chris Lattner0fab59c2007-01-12 18:33:30 +00002341#if YYDEBUG != 0
2342 if (yydebug)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002343 {
Chris Lattner0fab59c2007-01-12 18:33:30 +00002344 int i;
2345
2346 fprintf (stderr, "Reducing via rule %d (line %d), ",
2347 yyn, yyrline[yyn]);
2348
2349 /* Print the symbols being reduced, and their result. */
2350 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2351 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2352 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2353 }
2354#endif
2355
2356
2357 switch (yyn) {
2358
2359case 2:
2360#line 1020 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2361{
2362 if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX) // Outside of my range!
Reid Spencer61c83e02006-08-18 08:43:06 +00002363 GEN_ERROR("Value too large for type!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00002364 yyval.SIntVal = (int32_t)yyvsp[0].UIntVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00002365 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00002366;
2367 break;}
2368case 30:
2369#line 1036 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2370{ yyval.IPredicate = ICmpInst::ICMP_EQ; ;
2371 break;}
2372case 31:
2373#line 1036 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2374{ yyval.IPredicate = ICmpInst::ICMP_NE; ;
2375 break;}
2376case 32:
2377#line 1037 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2378{ yyval.IPredicate = ICmpInst::ICMP_SLT; ;
2379 break;}
2380case 33:
2381#line 1037 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2382{ yyval.IPredicate = ICmpInst::ICMP_SGT; ;
2383 break;}
2384case 34:
2385#line 1038 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2386{ yyval.IPredicate = ICmpInst::ICMP_SLE; ;
2387 break;}
2388case 35:
2389#line 1038 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2390{ yyval.IPredicate = ICmpInst::ICMP_SGE; ;
2391 break;}
2392case 36:
2393#line 1039 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2394{ yyval.IPredicate = ICmpInst::ICMP_ULT; ;
2395 break;}
2396case 37:
2397#line 1039 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2398{ yyval.IPredicate = ICmpInst::ICMP_UGT; ;
2399 break;}
2400case 38:
2401#line 1040 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2402{ yyval.IPredicate = ICmpInst::ICMP_ULE; ;
2403 break;}
2404case 39:
2405#line 1040 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2406{ yyval.IPredicate = ICmpInst::ICMP_UGE; ;
2407 break;}
2408case 40:
2409#line 1044 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2410{ yyval.FPredicate = FCmpInst::FCMP_OEQ; ;
2411 break;}
2412case 41:
2413#line 1044 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2414{ yyval.FPredicate = FCmpInst::FCMP_ONE; ;
2415 break;}
2416case 42:
2417#line 1045 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2418{ yyval.FPredicate = FCmpInst::FCMP_OLT; ;
2419 break;}
2420case 43:
2421#line 1045 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2422{ yyval.FPredicate = FCmpInst::FCMP_OGT; ;
2423 break;}
2424case 44:
2425#line 1046 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2426{ yyval.FPredicate = FCmpInst::FCMP_OLE; ;
2427 break;}
2428case 45:
2429#line 1046 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2430{ yyval.FPredicate = FCmpInst::FCMP_OGE; ;
2431 break;}
2432case 46:
2433#line 1047 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2434{ yyval.FPredicate = FCmpInst::FCMP_ORD; ;
2435 break;}
2436case 47:
2437#line 1047 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2438{ yyval.FPredicate = FCmpInst::FCMP_UNO; ;
2439 break;}
2440case 48:
2441#line 1048 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2442{ yyval.FPredicate = FCmpInst::FCMP_UEQ; ;
2443 break;}
2444case 49:
2445#line 1048 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2446{ yyval.FPredicate = FCmpInst::FCMP_UNE; ;
2447 break;}
2448case 50:
2449#line 1049 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2450{ yyval.FPredicate = FCmpInst::FCMP_ULT; ;
2451 break;}
2452case 51:
2453#line 1049 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2454{ yyval.FPredicate = FCmpInst::FCMP_UGT; ;
2455 break;}
2456case 52:
2457#line 1050 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2458{ yyval.FPredicate = FCmpInst::FCMP_ULE; ;
2459 break;}
2460case 53:
2461#line 1050 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2462{ yyval.FPredicate = FCmpInst::FCMP_UGE; ;
2463 break;}
2464case 54:
2465#line 1051 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2466{ yyval.FPredicate = FCmpInst::FCMP_TRUE; ;
2467 break;}
2468case 55:
2469#line 1052 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2470{ yyval.FPredicate = FCmpInst::FCMP_FALSE; ;
2471 break;}
2472case 59:
2473#line 1061 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2474{
2475 yyval.StrVal = yyvsp[-1].StrVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00002476 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00002477 ;
2478 break;}
2479case 60:
2480#line 1065 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2481{
2482 yyval.StrVal = 0;
Reid Spencere4d87aa2006-12-23 06:05:41 +00002483 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00002484 ;
2485 break;}
2486case 61:
2487#line 1071 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2488{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2489 break;}
2490case 62:
2491#line 1072 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2492{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2493 break;}
2494case 63:
2495#line 1073 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2496{ yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2497 break;}
2498case 64:
2499#line 1074 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2500{ yyval.Linkage = GlobalValue::AppendingLinkage; ;
2501 break;}
2502case 65:
2503#line 1075 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2504{ yyval.Linkage = GlobalValue::DLLExportLinkage; ;
2505 break;}
2506case 66:
2507#line 1079 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2508{ yyval.Linkage = GlobalValue::DLLImportLinkage; ;
2509 break;}
2510case 67:
2511#line 1080 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2512{ yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;
2513 break;}
2514case 68:
2515#line 1081 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2516{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2517 break;}
2518case 69:
2519#line 1085 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2520{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2521 break;}
2522case 70:
2523#line 1086 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2524{ yyval.Linkage = GlobalValue::DLLImportLinkage; ;
2525 break;}
2526case 71:
2527#line 1087 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2528{ yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;
2529 break;}
2530case 72:
2531#line 1091 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2532{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2533 break;}
2534case 73:
2535#line 1092 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2536{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2537 break;}
2538case 74:
2539#line 1093 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2540{ yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2541 break;}
2542case 75:
2543#line 1094 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2544{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2545 break;}
2546case 76:
2547#line 1095 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2548{ yyval.Linkage = GlobalValue::DLLExportLinkage; ;
2549 break;}
2550case 77:
2551#line 1098 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2552{ yyval.UIntVal = CallingConv::C; ;
2553 break;}
2554case 78:
2555#line 1099 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2556{ yyval.UIntVal = CallingConv::C; ;
2557 break;}
2558case 79:
2559#line 1100 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2560{ yyval.UIntVal = CallingConv::CSRet; ;
2561 break;}
2562case 80:
2563#line 1101 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2564{ yyval.UIntVal = CallingConv::Fast; ;
2565 break;}
2566case 81:
2567#line 1102 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2568{ yyval.UIntVal = CallingConv::Cold; ;
2569 break;}
2570case 82:
2571#line 1103 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2572{ yyval.UIntVal = CallingConv::X86_StdCall; ;
2573 break;}
2574case 83:
2575#line 1104 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2576{ yyval.UIntVal = CallingConv::X86_FastCall; ;
2577 break;}
2578case 84:
2579#line 1105 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2580{
2581 if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
Reid Spencer61c83e02006-08-18 08:43:06 +00002582 GEN_ERROR("Calling conv too large!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00002583 yyval.UIntVal = yyvsp[0].UInt64Val;
Reid Spencer61c83e02006-08-18 08:43:06 +00002584 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00002585 ;
2586 break;}
2587case 85:
2588#line 1112 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2589{ yyval.ParamAttrs = FunctionType::ZExtAttribute; ;
2590 break;}
2591case 86:
2592#line 1113 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2593{ yyval.ParamAttrs = FunctionType::SExtAttribute; ;
2594 break;}
2595case 87:
2596#line 1116 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2597{ yyval.ParamAttrs = FunctionType::NoAttributeSet; ;
2598 break;}
2599case 88:
2600#line 1117 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2601{
2602 yyval.ParamAttrs = FunctionType::ParameterAttributes(yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs);
2603 ;
2604 break;}
2605case 89:
2606#line 1122 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2607{ yyval.ParamAttrs = FunctionType::NoReturnAttribute; ;
2608 break;}
2609case 91:
2610#line 1126 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2611{ yyval.ParamAttrs = FunctionType::NoAttributeSet; ;
2612 break;}
2613case 92:
2614#line 1127 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2615{
2616 yyval.ParamAttrs = FunctionType::ParameterAttributes(yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs);
2617 ;
2618 break;}
2619case 93:
2620#line 1134 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2621{ yyval.UIntVal = 0; ;
2622 break;}
2623case 94:
2624#line 1135 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2625{
2626 yyval.UIntVal = yyvsp[0].UInt64Val;
2627 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
Reid Spencera54b7cb2007-01-12 07:05:14 +00002628 GEN_ERROR("Alignment must be a power of two!");
2629 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00002630;
2631 break;}
2632case 95:
2633#line 1141 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2634{ yyval.UIntVal = 0; ;
2635 break;}
2636case 96:
2637#line 1142 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2638{
2639 yyval.UIntVal = yyvsp[0].UInt64Val;
2640 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
Reid Spencera54b7cb2007-01-12 07:05:14 +00002641 GEN_ERROR("Alignment must be a power of two!");
2642 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00002643;
2644 break;}
2645case 97:
2646#line 1150 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2647{
2648 for (unsigned i = 0, e = strlen(yyvsp[0].StrVal); i != e; ++i)
2649 if (yyvsp[0].StrVal[i] == '"' || yyvsp[0].StrVal[i] == '\\')
Reid Spencere4d87aa2006-12-23 06:05:41 +00002650 GEN_ERROR("Invalid character in section name!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00002651 yyval.StrVal = yyvsp[0].StrVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00002652 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00002653;
2654 break;}
2655case 98:
2656#line 1158 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2657{ yyval.StrVal = 0; ;
2658 break;}
2659case 99:
2660#line 1159 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2661{ yyval.StrVal = yyvsp[0].StrVal; ;
2662 break;}
2663case 100:
2664#line 1164 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2665{;
2666 break;}
2667case 101:
2668#line 1165 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2669{;
2670 break;}
2671case 102:
2672#line 1166 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2673{
2674 CurGV->setSection(yyvsp[0].StrVal);
2675 free(yyvsp[0].StrVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00002676 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00002677 ;
2678 break;}
2679case 103:
2680#line 1171 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2681{
2682 if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val))
Reid Spencere4d87aa2006-12-23 06:05:41 +00002683 GEN_ERROR("Alignment must be a power of two!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00002684 CurGV->setAlignment(yyvsp[0].UInt64Val);
Reid Spencere4d87aa2006-12-23 06:05:41 +00002685 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00002686 ;
2687 break;}
2688case 109:
2689#line 1187 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2690{
2691 yyval.TypeVal = new PATypeHolder(OpaqueType::get());
Reid Spencera132e042006-12-03 05:46:11 +00002692 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00002693 ;
2694 break;}
2695case 110:
2696#line 1191 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2697{
2698 yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
Reid Spencera132e042006-12-03 05:46:11 +00002699 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00002700 ;
2701 break;}
2702case 111:
2703#line 1195 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2704{ // Pointer type?
2705 if (*yyvsp[-1].TypeVal == Type::LabelTy)
Reid Spencer14310612006-12-31 05:40:51 +00002706 GEN_ERROR("Cannot form a pointer to a basic block");
Chris Lattner0fab59c2007-01-12 18:33:30 +00002707 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal)));
2708 delete yyvsp[-1].TypeVal;
Reid Spencer14310612006-12-31 05:40:51 +00002709 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00002710 ;
2711 break;}
2712case 112:
2713#line 1202 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2714{ // Named types are also simple types...
2715 const Type* tmp = getTypeVal(yyvsp[0].ValIDVal);
Reid Spencer14310612006-12-31 05:40:51 +00002716 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00002717 yyval.TypeVal = new PATypeHolder(tmp);
2718 ;
2719 break;}
2720case 113:
2721#line 1207 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2722{ // Type UpReference
2723 if (yyvsp[0].UInt64Val > (uint64_t)~0U) GEN_ERROR("Value out of range!");
Reid Spencer3da59db2006-11-27 01:05:10 +00002724 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Chris Lattner0fab59c2007-01-12 18:33:30 +00002725 UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector...
2726 yyval.TypeVal = new PATypeHolder(OT);
Reid Spencer3da59db2006-11-27 01:05:10 +00002727 UR_OUT("New Upreference!\n");
Reid Spencer61c83e02006-08-18 08:43:06 +00002728 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00002729 ;
2730 break;}
2731case 114:
2732#line 1215 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2733{
Reid Spencer3da59db2006-11-27 01:05:10 +00002734 std::vector<const Type*> Params;
Reid Spencer14310612006-12-31 05:40:51 +00002735 std::vector<FunctionType::ParameterAttributes> Attrs;
Chris Lattner0fab59c2007-01-12 18:33:30 +00002736 Attrs.push_back(yyvsp[0].ParamAttrs);
2737 for (TypeWithAttrsList::iterator I=yyvsp[-2].TypeWithAttrsList->begin(), E=yyvsp[-2].TypeWithAttrsList->end(); I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00002738 Params.push_back(I->Ty->get());
2739 if (I->Ty->get() != Type::VoidTy)
2740 Attrs.push_back(I->Attrs);
2741 }
Reid Spencer3da59db2006-11-27 01:05:10 +00002742 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
2743 if (isVarArg) Params.pop_back();
2744
Chris Lattner0fab59c2007-01-12 18:33:30 +00002745 FunctionType *FT = FunctionType::get(*yyvsp[-4].TypeVal, Params, isVarArg, Attrs);
2746 delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list
2747 delete yyvsp[-4].TypeVal; // Delete the return type handle
2748 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT));
Reid Spencere4d87aa2006-12-23 06:05:41 +00002749 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00002750 ;
2751 break;}
2752case 115:
2753#line 1233 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2754{
Reid Spencer14310612006-12-31 05:40:51 +00002755 std::vector<const Type*> Params;
2756 std::vector<FunctionType::ParameterAttributes> Attrs;
Chris Lattner0fab59c2007-01-12 18:33:30 +00002757 Attrs.push_back(yyvsp[0].ParamAttrs);
2758 for (TypeWithAttrsList::iterator I=yyvsp[-2].TypeWithAttrsList->begin(), E=yyvsp[-2].TypeWithAttrsList->end(); I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00002759 Params.push_back(I->Ty->get());
2760 if (I->Ty->get() != Type::VoidTy)
2761 Attrs.push_back(I->Attrs);
2762 }
2763 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
2764 if (isVarArg) Params.pop_back();
2765
Chris Lattner0fab59c2007-01-12 18:33:30 +00002766 FunctionType *FT = FunctionType::get(yyvsp[-4].PrimType, Params, isVarArg, Attrs);
2767 delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list
2768 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT));
Reid Spencer14310612006-12-31 05:40:51 +00002769 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00002770 ;
2771 break;}
2772case 116:
2773#line 1251 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2774{ // Sized array type?
2775 yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2776 delete yyvsp[-1].TypeVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00002777 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00002778 ;
2779 break;}
2780case 117:
2781#line 1256 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2782{ // Packed array type?
2783 const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
2784 if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val)
Reid Spencere4d87aa2006-12-23 06:05:41 +00002785 GEN_ERROR("Unsigned result not equal to signed result");
Reid Spencera54b7cb2007-01-12 07:05:14 +00002786 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
2787 GEN_ERROR("Element type of a PackedType must be primitive");
Chris Lattner0fab59c2007-01-12 18:33:30 +00002788 if (!isPowerOf2_32(yyvsp[-3].UInt64Val))
Reid Spencere4d87aa2006-12-23 06:05:41 +00002789 GEN_ERROR("Vector length should be a power of 2!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00002790 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PackedType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2791 delete yyvsp[-1].TypeVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00002792 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00002793 ;
2794 break;}
2795case 118:
2796#line 1268 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2797{ // Structure type?
Reid Spencere4d87aa2006-12-23 06:05:41 +00002798 std::vector<const Type*> Elements;
Chris Lattner0fab59c2007-01-12 18:33:30 +00002799 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2800 E = yyvsp[-1].TypeList->end(); I != E; ++I)
Reid Spencere4d87aa2006-12-23 06:05:41 +00002801 Elements.push_back(*I);
2802
Chris Lattner0fab59c2007-01-12 18:33:30 +00002803 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
2804 delete yyvsp[-1].TypeList;
Reid Spencere4d87aa2006-12-23 06:05:41 +00002805 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00002806 ;
2807 break;}
2808case 119:
2809#line 1278 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2810{ // Empty structure type?
2811 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencere4d87aa2006-12-23 06:05:41 +00002812 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00002813 ;
2814 break;}
2815case 120:
2816#line 1282 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2817{
Reid Spencere4d87aa2006-12-23 06:05:41 +00002818 std::vector<const Type*> Elements;
Chris Lattner0fab59c2007-01-12 18:33:30 +00002819 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-2].TypeList->begin(),
2820 E = yyvsp[-2].TypeList->end(); I != E; ++I)
Reid Spencere4d87aa2006-12-23 06:05:41 +00002821 Elements.push_back(*I);
2822
Chris Lattner0fab59c2007-01-12 18:33:30 +00002823 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
2824 delete yyvsp[-2].TypeList;
Reid Spencere4d87aa2006-12-23 06:05:41 +00002825 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00002826 ;
2827 break;}
2828case 121:
2829#line 1292 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2830{ // Empty structure type?
2831 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Reid Spencere4d87aa2006-12-23 06:05:41 +00002832 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00002833 ;
2834 break;}
2835case 122:
2836#line 1299 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2837{
2838 yyval.TypeWithAttrs.Ty = yyvsp[-1].TypeVal;
2839 yyval.TypeWithAttrs.Attrs = yyvsp[0].ParamAttrs;
2840 ;
2841 break;}
2842case 123:
2843#line 1306 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2844{
Reid Spencer218ded22007-01-05 17:07:23 +00002845 if (!UpRefs.empty())
Chris Lattner0fab59c2007-01-12 18:33:30 +00002846 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
2847 if (!(*yyvsp[0].TypeVal)->isFirstClassType())
Reid Spencer218ded22007-01-05 17:07:23 +00002848 GEN_ERROR("LLVM functions cannot return aggregate types!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00002849 yyval.TypeVal = yyvsp[0].TypeVal;
2850 ;
2851 break;}
2852case 124:
2853#line 1313 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2854{
2855 yyval.TypeVal = new PATypeHolder(Type::VoidTy);
2856 ;
2857 break;}
2858case 125:
2859#line 1318 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2860{
2861 yyval.TypeWithAttrsList = new TypeWithAttrsList();
2862 yyval.TypeWithAttrsList->push_back(yyvsp[0].TypeWithAttrs);
Reid Spencer14310612006-12-31 05:40:51 +00002863 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00002864 ;
2865 break;}
2866case 126:
2867#line 1323 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2868{
2869 (yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList)->push_back(yyvsp[0].TypeWithAttrs);
Reid Spencer14310612006-12-31 05:40:51 +00002870 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00002871 ;
2872 break;}
2873case 128:
2874#line 1331 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2875{
2876 yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList;
Reid Spencer14310612006-12-31 05:40:51 +00002877 TypeWithAttrs TWA; TWA.Attrs = FunctionType::NoAttributeSet;
2878 TWA.Ty = new PATypeHolder(Type::VoidTy);
Chris Lattner0fab59c2007-01-12 18:33:30 +00002879 yyval.TypeWithAttrsList->push_back(TWA);
Reid Spencere4d87aa2006-12-23 06:05:41 +00002880 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00002881 ;
2882 break;}
2883case 129:
2884#line 1338 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2885{
2886 yyval.TypeWithAttrsList = new TypeWithAttrsList;
Reid Spencer14310612006-12-31 05:40:51 +00002887 TypeWithAttrs TWA; TWA.Attrs = FunctionType::NoAttributeSet;
2888 TWA.Ty = new PATypeHolder(Type::VoidTy);
Chris Lattner0fab59c2007-01-12 18:33:30 +00002889 yyval.TypeWithAttrsList->push_back(TWA);
Reid Spencer14310612006-12-31 05:40:51 +00002890 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00002891 ;
2892 break;}
2893case 130:
2894#line 1345 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2895{
2896 yyval.TypeWithAttrsList = new TypeWithAttrsList();
Reid Spencer14310612006-12-31 05:40:51 +00002897 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00002898 ;
2899 break;}
2900case 131:
2901#line 1353 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2902{
2903 yyval.TypeList = new std::list<PATypeHolder>();
2904 yyval.TypeList->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
Reid Spencer3da59db2006-11-27 01:05:10 +00002905 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00002906 ;
2907 break;}
2908case 132:
2909#line 1358 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2910{
2911 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
Reid Spencer3da59db2006-11-27 01:05:10 +00002912 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00002913 ;
2914 break;}
2915case 133:
2916#line 1369 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2917{ // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00002918 if (!UpRefs.empty())
Chris Lattner0fab59c2007-01-12 18:33:30 +00002919 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
2920 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
Reid Spencere4d87aa2006-12-23 06:05:41 +00002921 if (ATy == 0)
2922 GEN_ERROR("Cannot make array constant with type: '" +
Chris Lattner0fab59c2007-01-12 18:33:30 +00002923 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00002924 const Type *ETy = ATy->getElementType();
2925 int NumElements = ATy->getNumElements();
2926
2927 // Verify that we have the correct size...
Chris Lattner0fab59c2007-01-12 18:33:30 +00002928 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
Reid Spencere4d87aa2006-12-23 06:05:41 +00002929 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Chris Lattner0fab59c2007-01-12 18:33:30 +00002930 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
Reid Spencere4d87aa2006-12-23 06:05:41 +00002931 itostr(NumElements) + "!");
2932
2933 // Verify all elements are correct type!
Chris Lattner0fab59c2007-01-12 18:33:30 +00002934 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2935 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Reid Spencere4d87aa2006-12-23 06:05:41 +00002936 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
2937 ETy->getDescription() +"' as required!\nIt is of type '"+
Chris Lattner0fab59c2007-01-12 18:33:30 +00002938 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Reid Spencere4d87aa2006-12-23 06:05:41 +00002939 }
2940
Chris Lattner0fab59c2007-01-12 18:33:30 +00002941 yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
2942 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Reid Spencer3da59db2006-11-27 01:05:10 +00002943 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00002944 ;
2945 break;}
2946case 134:
2947#line 1397 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2948{
Reid Spencer14310612006-12-31 05:40:51 +00002949 if (!UpRefs.empty())
Chris Lattner0fab59c2007-01-12 18:33:30 +00002950 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
2951 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00002952 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00002953 GEN_ERROR("Cannot make array constant with type: '" +
Chris Lattner0fab59c2007-01-12 18:33:30 +00002954 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00002955
Andrew Lenharth6353e052006-12-08 18:07:09 +00002956 int NumElements = ATy->getNumElements();
2957 if (NumElements != -1 && NumElements != 0)
2958 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
2959 " arguments, but has size of " + itostr(NumElements) +"!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00002960 yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
2961 delete yyvsp[-2].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00002962 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00002963 ;
2964 break;}
2965case 135:
2966#line 1413 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2967{
Reid Spencer14310612006-12-31 05:40:51 +00002968 if (!UpRefs.empty())
Chris Lattner0fab59c2007-01-12 18:33:30 +00002969 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
2970 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
Andrew Lenharth6353e052006-12-08 18:07:09 +00002971 if (ATy == 0)
2972 GEN_ERROR("Cannot make array constant with type: '" +
Chris Lattner0fab59c2007-01-12 18:33:30 +00002973 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
Reid Spencer61c83e02006-08-18 08:43:06 +00002974
Andrew Lenharth6353e052006-12-08 18:07:09 +00002975 int NumElements = ATy->getNumElements();
2976 const Type *ETy = ATy->getElementType();
Chris Lattner0fab59c2007-01-12 18:33:30 +00002977 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
2978 if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal))
Andrew Lenharth6353e052006-12-08 18:07:09 +00002979 GEN_ERROR("Can't build string constant of size " +
Chris Lattner0fab59c2007-01-12 18:33:30 +00002980 itostr((int)(EndStr-yyvsp[0].StrVal)) +
Andrew Lenharth6353e052006-12-08 18:07:09 +00002981 " when array has size " + itostr(NumElements) + "!");
2982 std::vector<Constant*> Vals;
Reid Spencer14310612006-12-31 05:40:51 +00002983 if (ETy == Type::Int8Ty) {
Chris Lattner0fab59c2007-01-12 18:33:30 +00002984 for (unsigned char *C = (unsigned char *)yyvsp[0].StrVal;
Reid Spencer14310612006-12-31 05:40:51 +00002985 C != (unsigned char*)EndStr; ++C)
2986 Vals.push_back(ConstantInt::get(ETy, *C));
Andrew Lenharth6353e052006-12-08 18:07:09 +00002987 } else {
Chris Lattner0fab59c2007-01-12 18:33:30 +00002988 free(yyvsp[0].StrVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00002989 GEN_ERROR("Cannot build string arrays of non byte sized elements!");
2990 }
Chris Lattner0fab59c2007-01-12 18:33:30 +00002991 free(yyvsp[0].StrVal);
2992 yyval.ConstVal = ConstantArray::get(ATy, Vals);
2993 delete yyvsp[-2].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00002994 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00002995 ;
2996 break;}
2997case 136:
2998#line 1442 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2999{ // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00003000 if (!UpRefs.empty())
Chris Lattner0fab59c2007-01-12 18:33:30 +00003001 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
3002 const PackedType *PTy = dyn_cast<PackedType>(yyvsp[-3].TypeVal->get());
Andrew Lenharth6353e052006-12-08 18:07:09 +00003003 if (PTy == 0)
3004 GEN_ERROR("Cannot make packed constant with type: '" +
Chris Lattner0fab59c2007-01-12 18:33:30 +00003005 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
Andrew Lenharth6353e052006-12-08 18:07:09 +00003006 const Type *ETy = PTy->getElementType();
3007 int NumElements = PTy->getNumElements();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003008
Andrew Lenharth6353e052006-12-08 18:07:09 +00003009 // Verify that we have the correct size...
Chris Lattner0fab59c2007-01-12 18:33:30 +00003010 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
Andrew Lenharth6353e052006-12-08 18:07:09 +00003011 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Chris Lattner0fab59c2007-01-12 18:33:30 +00003012 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
Andrew Lenharth6353e052006-12-08 18:07:09 +00003013 itostr(NumElements) + "!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003014
Andrew Lenharth6353e052006-12-08 18:07:09 +00003015 // Verify all elements are correct type!
Chris Lattner0fab59c2007-01-12 18:33:30 +00003016 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3017 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Andrew Lenharth6353e052006-12-08 18:07:09 +00003018 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3019 ETy->getDescription() +"' as required!\nIt is of type '"+
Chris Lattner0fab59c2007-01-12 18:33:30 +00003020 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Andrew Lenharth6353e052006-12-08 18:07:09 +00003021 }
3022
Chris Lattner0fab59c2007-01-12 18:33:30 +00003023 yyval.ConstVal = ConstantPacked::get(PTy, *yyvsp[-1].ConstVector);
3024 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Reid Spencer61c83e02006-08-18 08:43:06 +00003025 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003026 ;
3027 break;}
3028case 137:
3029#line 1470 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3030{
3031 const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
Andrew Lenharth6353e052006-12-08 18:07:09 +00003032 if (STy == 0)
3033 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattner0fab59c2007-01-12 18:33:30 +00003034 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003035
Chris Lattner0fab59c2007-01-12 18:33:30 +00003036 if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
Andrew Lenharth6353e052006-12-08 18:07:09 +00003037 GEN_ERROR("Illegal number of initializers for structure type!");
3038
3039 // Check to ensure that constants are compatible with the type initializer!
Chris Lattner0fab59c2007-01-12 18:33:30 +00003040 for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
3041 if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
Andrew Lenharth6353e052006-12-08 18:07:09 +00003042 GEN_ERROR("Expected type '" +
3043 STy->getElementType(i)->getDescription() +
3044 "' for element #" + utostr(i) +
3045 " of structure initializer!");
3046
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003047 // Check to ensure that Type is not packed
3048 if (STy->isPacked())
3049 GEN_ERROR("Unpacked Initializer to packed type '" + STy->getDescription() + "'");
3050
Chris Lattner0fab59c2007-01-12 18:33:30 +00003051 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
3052 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Reid Spencer61c83e02006-08-18 08:43:06 +00003053 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003054 ;
3055 break;}
3056case 138:
3057#line 1495 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3058{
Reid Spencer14310612006-12-31 05:40:51 +00003059 if (!UpRefs.empty())
Chris Lattner0fab59c2007-01-12 18:33:30 +00003060 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3061 const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
Andrew Lenharth6353e052006-12-08 18:07:09 +00003062 if (STy == 0)
3063 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattner0fab59c2007-01-12 18:33:30 +00003064 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
Andrew Lenharth6353e052006-12-08 18:07:09 +00003065
3066 if (STy->getNumContainedTypes() != 0)
3067 GEN_ERROR("Illegal number of initializers for structure type!");
3068
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003069 // Check to ensure that Type is not packed
3070 if (STy->isPacked())
3071 GEN_ERROR("Unpacked Initializer to packed type '" + STy->getDescription() + "'");
3072
Chris Lattner0fab59c2007-01-12 18:33:30 +00003073 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
3074 delete yyvsp[-2].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00003075 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003076 ;
3077 break;}
3078case 139:
3079#line 1514 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3080{
3081 const StructType *STy = dyn_cast<StructType>(yyvsp[-5].TypeVal->get());
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003082 if (STy == 0)
3083 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattner0fab59c2007-01-12 18:33:30 +00003084 (*yyvsp[-5].TypeVal)->getDescription() + "'!");
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003085
Chris Lattner0fab59c2007-01-12 18:33:30 +00003086 if (yyvsp[-2].ConstVector->size() != STy->getNumContainedTypes())
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003087 GEN_ERROR("Illegal number of initializers for structure type!");
3088
3089 // Check to ensure that constants are compatible with the type initializer!
Chris Lattner0fab59c2007-01-12 18:33:30 +00003090 for (unsigned i = 0, e = yyvsp[-2].ConstVector->size(); i != e; ++i)
3091 if ((*yyvsp[-2].ConstVector)[i]->getType() != STy->getElementType(i))
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003092 GEN_ERROR("Expected type '" +
3093 STy->getElementType(i)->getDescription() +
3094 "' for element #" + utostr(i) +
3095 " of structure initializer!");
3096
3097 // Check to ensure that Type is packed
3098 if (!STy->isPacked())
3099 GEN_ERROR("Packed Initializer to unpacked type '" + STy->getDescription() + "'");
3100
Chris Lattner0fab59c2007-01-12 18:33:30 +00003101 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-2].ConstVector);
3102 delete yyvsp[-5].TypeVal; delete yyvsp[-2].ConstVector;
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003103 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003104 ;
3105 break;}
3106case 140:
3107#line 1539 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3108{
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003109 if (!UpRefs.empty())
Chris Lattner0fab59c2007-01-12 18:33:30 +00003110 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
3111 const StructType *STy = dyn_cast<StructType>(yyvsp[-4].TypeVal->get());
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003112 if (STy == 0)
3113 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattner0fab59c2007-01-12 18:33:30 +00003114 (*yyvsp[-4].TypeVal)->getDescription() + "'!");
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003115
3116 if (STy->getNumContainedTypes() != 0)
3117 GEN_ERROR("Illegal number of initializers for structure type!");
3118
3119 // Check to ensure that Type is packed
3120 if (!STy->isPacked())
3121 GEN_ERROR("Packed Initializer to unpacked type '" + STy->getDescription() + "'");
3122
Chris Lattner0fab59c2007-01-12 18:33:30 +00003123 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
3124 delete yyvsp[-4].TypeVal;
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003125 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003126 ;
3127 break;}
3128case 141:
3129#line 1558 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3130{
Reid Spencer14310612006-12-31 05:40:51 +00003131 if (!UpRefs.empty())
Chris Lattner0fab59c2007-01-12 18:33:30 +00003132 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3133 const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
Andrew Lenharth6353e052006-12-08 18:07:09 +00003134 if (PTy == 0)
3135 GEN_ERROR("Cannot make null pointer constant with type: '" +
Chris Lattner0fab59c2007-01-12 18:33:30 +00003136 (*yyvsp[-1].TypeVal)->getDescription() + "'!");
Andrew Lenharth6353e052006-12-08 18:07:09 +00003137
Chris Lattner0fab59c2007-01-12 18:33:30 +00003138 yyval.ConstVal = ConstantPointerNull::get(PTy);
3139 delete yyvsp[-1].TypeVal;
Andrew Lenharth6353e052006-12-08 18:07:09 +00003140 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003141 ;
3142 break;}
3143case 142:
3144#line 1570 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3145{
Reid Spencer14310612006-12-31 05:40:51 +00003146 if (!UpRefs.empty())
Chris Lattner0fab59c2007-01-12 18:33:30 +00003147 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3148 yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
3149 delete yyvsp[-1].TypeVal;
Andrew Lenharth6353e052006-12-08 18:07:09 +00003150 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003151 ;
3152 break;}
3153case 143:
3154#line 1577 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3155{
Reid Spencer14310612006-12-31 05:40:51 +00003156 if (!UpRefs.empty())
Chris Lattner0fab59c2007-01-12 18:33:30 +00003157 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3158 const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003159 if (Ty == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003160 GEN_ERROR("Global const reference must be a pointer type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003161
3162 // ConstExprs can exist in the body of a function, thus creating
3163 // GlobalValues whenever they refer to a variable. Because we are in
3164 // the context of a function, getValNonImprovising will search the functions
3165 // symbol table instead of the module symbol table for the global symbol,
3166 // which throws things all off. To get around this, we just tell
3167 // getValNonImprovising that we are at global scope here.
3168 //
3169 Function *SavedCurFn = CurFun.CurrentFunction;
3170 CurFun.CurrentFunction = 0;
3171
Chris Lattner0fab59c2007-01-12 18:33:30 +00003172 Value *V = getValNonImprovising(Ty, yyvsp[0].ValIDVal);
Reid Spencer5b7e7532006-09-28 19:28:24 +00003173 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003174
3175 CurFun.CurrentFunction = SavedCurFn;
3176
3177 // If this is an initializer for a constant pointer, which is referencing a
3178 // (currently) undefined variable, create a stub now that shall be replaced
3179 // in the future with the right type of variable.
3180 //
3181 if (V == 0) {
3182 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
3183 const PointerType *PT = cast<PointerType>(Ty);
3184
3185 // First check to see if the forward references value is already created!
3186 PerModuleInfo::GlobalRefsType::iterator I =
Chris Lattner0fab59c2007-01-12 18:33:30 +00003187 CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003188
3189 if (I != CurModule.GlobalRefs.end()) {
3190 V = I->second; // Placeholder already exists, use it...
Chris Lattner0fab59c2007-01-12 18:33:30 +00003191 yyvsp[0].ValIDVal.destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003192 } else {
3193 std::string Name;
Chris Lattner0fab59c2007-01-12 18:33:30 +00003194 if (yyvsp[0].ValIDVal.Type == ValID::NameVal) Name = yyvsp[0].ValIDVal.Name;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003195
3196 // Create the forward referenced global.
3197 GlobalValue *GV;
3198 if (const FunctionType *FTy =
3199 dyn_cast<FunctionType>(PT->getElementType())) {
3200 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
3201 CurModule.CurrentModule);
3202 } else {
3203 GV = new GlobalVariable(PT->getElementType(), false,
3204 GlobalValue::ExternalLinkage, 0,
3205 Name, CurModule.CurrentModule);
3206 }
3207
3208 // Keep track of the fact that we have a forward ref to recycle it
Chris Lattner0fab59c2007-01-12 18:33:30 +00003209 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003210 V = GV;
3211 }
3212 }
3213
Chris Lattner0fab59c2007-01-12 18:33:30 +00003214 yyval.ConstVal = cast<GlobalValue>(V);
3215 delete yyvsp[-1].TypeVal; // Free the type handle
Reid Spencere4d87aa2006-12-23 06:05:41 +00003216 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003217 ;
3218 break;}
3219case 144:
3220#line 1640 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3221{
Reid Spencer14310612006-12-31 05:40:51 +00003222 if (!UpRefs.empty())
Chris Lattner0fab59c2007-01-12 18:33:30 +00003223 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3224 if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
Reid Spencere68853b2007-01-04 00:06:14 +00003225 GEN_ERROR("Mismatched types for constant expression: " +
Chris Lattner0fab59c2007-01-12 18:33:30 +00003226 (*yyvsp[-1].TypeVal)->getDescription() + " and " + yyvsp[0].ConstVal->getType()->getDescription());
3227 yyval.ConstVal = yyvsp[0].ConstVal;
3228 delete yyvsp[-1].TypeVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00003229 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003230 ;
3231 break;}
3232case 145:
3233#line 1650 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3234{
Reid Spencer14310612006-12-31 05:40:51 +00003235 if (!UpRefs.empty())
Chris Lattner0fab59c2007-01-12 18:33:30 +00003236 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3237 const Type *Ty = yyvsp[-1].TypeVal->get();
Reid Spencere4d87aa2006-12-23 06:05:41 +00003238 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
3239 GEN_ERROR("Cannot create a null initialized value of this type!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00003240 yyval.ConstVal = Constant::getNullValue(Ty);
3241 delete yyvsp[-1].TypeVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00003242 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003243 ;
3244 break;}
3245case 146:
3246#line 1660 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3247{ // integral constants
3248 if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
Reid Spencer14310612006-12-31 05:40:51 +00003249 GEN_ERROR("Constant value doesn't fit in type!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00003250 yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val);
Reid Spencer14310612006-12-31 05:40:51 +00003251 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003252 ;
3253 break;}
3254case 147:
3255#line 1666 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3256{ // integral constants
3257 if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
Reid Spencer14310612006-12-31 05:40:51 +00003258 GEN_ERROR("Constant value doesn't fit in type!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00003259 yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val);
Reid Spencer14310612006-12-31 05:40:51 +00003260 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003261 ;
3262 break;}
3263case 148:
3264#line 1672 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3265{ // Boolean constants
3266 yyval.ConstVal = ConstantInt::getTrue();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003267 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003268 ;
3269 break;}
3270case 149:
3271#line 1676 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3272{ // Boolean constants
3273 yyval.ConstVal = ConstantInt::getFalse();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003274 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003275 ;
3276 break;}
3277case 150:
3278#line 1680 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3279{ // Float & Double constants
3280 if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal))
Reid Spencere4d87aa2006-12-23 06:05:41 +00003281 GEN_ERROR("Floating point constant invalid for type!!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00003282 yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003283 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003284 ;
3285 break;}
3286case 151:
3287#line 1688 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3288{
Reid Spencer14310612006-12-31 05:40:51 +00003289 if (!UpRefs.empty())
Chris Lattner0fab59c2007-01-12 18:33:30 +00003290 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3291 Constant *Val = yyvsp[-3].ConstVal;
3292 const Type *Ty = yyvsp[-1].TypeVal->get();
Reid Spencer3da59db2006-11-27 01:05:10 +00003293 if (!Val->getType()->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003294 GEN_ERROR("cast constant expression from a non-primitive type: '" +
Reid Spencer3da59db2006-11-27 01:05:10 +00003295 Val->getType()->getDescription() + "'!");
3296 if (!Ty->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003297 GEN_ERROR("cast constant expression to a non-primitive type: '" +
Reid Spencer3da59db2006-11-27 01:05:10 +00003298 Ty->getDescription() + "'!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00003299 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, yyvsp[-1].TypeVal->get());
3300 delete yyvsp[-1].TypeVal;
3301 ;
3302 break;}
3303case 152:
3304#line 1702 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3305{
3306 if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
Andrew Lenharth6353e052006-12-08 18:07:09 +00003307 GEN_ERROR("GetElementPtr requires a pointer operand!");
3308
3309 const Type *IdxTy =
Chris Lattner0fab59c2007-01-12 18:33:30 +00003310 GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), *yyvsp[-1].ValueList, true);
Andrew Lenharth6353e052006-12-08 18:07:09 +00003311 if (!IdxTy)
3312 GEN_ERROR("Index list invalid for constant getelementptr!");
3313
3314 std::vector<Constant*> IdxVec;
Chris Lattner0fab59c2007-01-12 18:33:30 +00003315 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
3316 if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
Andrew Lenharth6353e052006-12-08 18:07:09 +00003317 IdxVec.push_back(C);
3318 else
3319 GEN_ERROR("Indices to constant getelementptr must be constants!");
3320
Chris Lattner0fab59c2007-01-12 18:33:30 +00003321 delete yyvsp[-1].ValueList;
Andrew Lenharth6353e052006-12-08 18:07:09 +00003322
Chris Lattner0fab59c2007-01-12 18:33:30 +00003323 yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, IdxVec);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003324 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003325 ;
3326 break;}
3327case 153:
3328#line 1723 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3329{
3330 if (yyvsp[-5].ConstVal->getType() != Type::Int1Ty)
Reid Spencere4d87aa2006-12-23 06:05:41 +00003331 GEN_ERROR("Select condition must be of boolean type!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00003332 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Reid Spencere4d87aa2006-12-23 06:05:41 +00003333 GEN_ERROR("Select operand types must match!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00003334 yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003335 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003336 ;
3337 break;}
3338case 154:
3339#line 1731 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3340{
3341 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Reid Spencere4d87aa2006-12-23 06:05:41 +00003342 GEN_ERROR("Binary operator types must match!");
3343 CHECK_FOR_ERROR;
Chris Lattner0fab59c2007-01-12 18:33:30 +00003344 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3345 ;
3346 break;}
3347case 155:
3348#line 1737 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3349{
3350 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Reid Spencere4d87aa2006-12-23 06:05:41 +00003351 GEN_ERROR("Logical operator types must match!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00003352 if (!yyvsp[-3].ConstVal->getType()->isIntegral()) {
3353 if (!isa<PackedType>(yyvsp[-3].ConstVal->getType()) ||
3354 !cast<PackedType>(yyvsp[-3].ConstVal->getType())->getElementType()->isIntegral())
Reid Spencere4d87aa2006-12-23 06:05:41 +00003355 GEN_ERROR("Logical operator requires integral operands!");
3356 }
Chris Lattner0fab59c2007-01-12 18:33:30 +00003357 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003358 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003359 ;
3360 break;}
3361case 156:
3362#line 1748 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3363{
3364 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Reid Spencere4d87aa2006-12-23 06:05:41 +00003365 GEN_ERROR("icmp operand types must match!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00003366 yyval.ConstVal = ConstantExpr::getICmp(yyvsp[-5].IPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3367 ;
3368 break;}
3369case 157:
3370#line 1753 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3371{
3372 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Reid Spencere4d87aa2006-12-23 06:05:41 +00003373 GEN_ERROR("fcmp operand types must match!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00003374 yyval.ConstVal = ConstantExpr::getFCmp(yyvsp[-5].FPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3375 ;
3376 break;}
3377case 158:
3378#line 1758 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3379{
3380 if (yyvsp[-1].ConstVal->getType() != Type::Int8Ty)
Reid Spencer14310612006-12-31 05:40:51 +00003381 GEN_ERROR("Shift count for shift constant must be i8 type!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00003382 if (!yyvsp[-3].ConstVal->getType()->isInteger())
Reid Spencere4d87aa2006-12-23 06:05:41 +00003383 GEN_ERROR("Shift constant expression requires integer operand!");
3384 CHECK_FOR_ERROR;
Chris Lattner0fab59c2007-01-12 18:33:30 +00003385 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].OtherOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00003386 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003387 ;
3388 break;}
3389case 159:
3390#line 1767 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3391{
3392 if (!ExtractElementInst::isValidOperands(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Reid Spencere4d87aa2006-12-23 06:05:41 +00003393 GEN_ERROR("Invalid extractelement operands!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00003394 yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003395 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003396 ;
3397 break;}
3398case 160:
3399#line 1773 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3400{
3401 if (!InsertElementInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Reid Spencere4d87aa2006-12-23 06:05:41 +00003402 GEN_ERROR("Invalid insertelement operands!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00003403 yyval.ConstVal = ConstantExpr::getInsertElement(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003404 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003405 ;
3406 break;}
3407case 161:
3408#line 1779 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3409{
3410 if (!ShuffleVectorInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Reid Spencere4d87aa2006-12-23 06:05:41 +00003411 GEN_ERROR("Invalid shufflevector operands!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00003412 yyval.ConstVal = ConstantExpr::getShuffleVector(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00003413 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003414 ;
3415 break;}
3416case 162:
3417#line 1788 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3418{
3419 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00003420 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003421 ;
3422 break;}
3423case 163:
3424#line 1792 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3425{
3426 yyval.ConstVector = new std::vector<Constant*>();
3427 yyval.ConstVector->push_back(yyvsp[0].ConstVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003428 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003429 ;
3430 break;}
3431case 164:
3432#line 1800 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3433{ yyval.BoolVal = false; ;
3434 break;}
3435case 165:
3436#line 1800 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3437{ yyval.BoolVal = true; ;
3438 break;}
3439case 166:
3440#line 1811 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3441{
3442 yyval.ModuleVal = ParserResult = CurModule.CurrentModule;
Reid Spencer14310612006-12-31 05:40:51 +00003443 CurModule.ModuleDone();
3444 CHECK_FOR_ERROR;
Chris Lattner0fab59c2007-01-12 18:33:30 +00003445 ;
3446 break;}
3447case 167:
3448#line 1816 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3449{
3450 yyval.ModuleVal = ParserResult = CurModule.CurrentModule;
Reid Spencer218ded22007-01-05 17:07:23 +00003451 CurModule.ModuleDone();
3452 CHECK_FOR_ERROR;
Chris Lattner0fab59c2007-01-12 18:33:30 +00003453 ;
3454 break;}
3455case 170:
3456#line 1829 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3457{ CurFun.isDeclare = false ;
3458 break;}
3459case 171:
3460#line 1829 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3461{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003462 CurFun.FunctionDone();
Reid Spencer61c83e02006-08-18 08:43:06 +00003463 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003464 ;
3465 break;}
3466case 172:
3467#line 1833 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3468{ CurFun.isDeclare = true; ;
3469 break;}
3470case 173:
3471#line 1833 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3472{
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003473 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003474 ;
3475 break;}
3476case 174:
3477#line 1836 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3478{
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003479 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003480 ;
3481 break;}
3482case 175:
3483#line 1839 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3484{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003485 // Emit an error if there are any unresolved types left.
3486 if (!CurModule.LateResolveTypes.empty()) {
3487 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
Reid Spencer61c83e02006-08-18 08:43:06 +00003488 if (DID.Type == ValID::NameVal) {
3489 GEN_ERROR("Reference to an undefined type: '"+DID.getName() + "'");
3490 } else {
3491 GEN_ERROR("Reference to an undefined type: #" + itostr(DID.Num));
3492 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00003493 }
Reid Spencer61c83e02006-08-18 08:43:06 +00003494 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003495 ;
3496 break;}
3497case 176:
3498#line 1851 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3499{
Reid Spencer14310612006-12-31 05:40:51 +00003500 if (!UpRefs.empty())
Chris Lattner0fab59c2007-01-12 18:33:30 +00003501 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003502 // Eagerly resolve types. This is not an optimization, this is a
3503 // requirement that is due to the fact that we could have this:
3504 //
3505 // %list = type { %list * }
3506 // %list = type { %list * } ; repeated type decl
3507 //
3508 // If types are not resolved eagerly, then the two types will not be
3509 // determined to be the same type!
3510 //
Chris Lattner0fab59c2007-01-12 18:33:30 +00003511 ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003512
Chris Lattner0fab59c2007-01-12 18:33:30 +00003513 if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00003514 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003515 // If this is a named type that is not a redefinition, add it to the slot
3516 // table.
Chris Lattner0fab59c2007-01-12 18:33:30 +00003517 CurModule.Types.push_back(*yyvsp[0].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003518 }
Reid Spencera132e042006-12-03 05:46:11 +00003519
Chris Lattner0fab59c2007-01-12 18:33:30 +00003520 delete yyvsp[0].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00003521 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003522 ;
3523 break;}
3524case 177:
3525#line 1875 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3526{
3527 ResolveTypeTo(yyvsp[-2].StrVal, yyvsp[0].PrimType);
Reid Spencer3822ff52006-11-08 06:47:33 +00003528
Chris Lattner0fab59c2007-01-12 18:33:30 +00003529 if (!setTypeName(yyvsp[0].PrimType, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
Reid Spencer14310612006-12-31 05:40:51 +00003530 CHECK_FOR_ERROR
3531 // If this is a named type that is not a redefinition, add it to the slot
3532 // table.
Chris Lattner0fab59c2007-01-12 18:33:30 +00003533 CurModule.Types.push_back(yyvsp[0].PrimType);
Reid Spencer14310612006-12-31 05:40:51 +00003534 }
3535 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003536 ;
3537 break;}
3538case 178:
3539#line 1886 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3540{ /* "Externally Visible" Linkage */
3541 if (yyvsp[0].ConstVal == 0)
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003542 GEN_ERROR("Global value initializer is not a constant!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00003543 CurGV = ParseGlobalVariable(yyvsp[-2].StrVal, GlobalValue::ExternalLinkage, yyvsp[-1].BoolVal,
3544 yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003545 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003546 ;
3547 break;}
3548case 179:
3549#line 1892 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3550{
Reid Spencer6fd36ab2006-12-29 20:35:03 +00003551 CurGV = 0;
Chris Lattner0fab59c2007-01-12 18:33:30 +00003552 ;
3553 break;}
3554case 180:
3555#line 1895 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3556{
3557 if (yyvsp[0].ConstVal == 0)
Andrew Lenharth6353e052006-12-08 18:07:09 +00003558 GEN_ERROR("Global value initializer is not a constant!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00003559 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, yyvsp[-2].Linkage, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003560 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003561 ;
3562 break;}
3563case 181:
3564#line 1900 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3565{
Reid Spencere4d87aa2006-12-23 06:05:41 +00003566 CurGV = 0;
Chris Lattner0fab59c2007-01-12 18:33:30 +00003567 ;
3568 break;}
3569case 182:
3570#line 1903 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3571{
Reid Spencer14310612006-12-31 05:40:51 +00003572 if (!UpRefs.empty())
Chris Lattner0fab59c2007-01-12 18:33:30 +00003573 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
3574 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, yyvsp[-2].Linkage, yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003575 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003576 delete yyvsp[0].TypeVal;
3577 ;
3578 break;}
3579case 183:
3580#line 1909 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3581{
Reid Spencere4d87aa2006-12-23 06:05:41 +00003582 CurGV = 0;
3583 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003584 ;
3585 break;}
3586case 184:
3587#line 1913 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3588{
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003589 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003590 ;
3591 break;}
3592case 185:
3593#line 1916 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3594{
Reid Spencer218ded22007-01-05 17:07:23 +00003595 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003596 ;
3597 break;}
3598case 186:
3599#line 1922 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3600{
Chris Lattner66316012006-01-24 04:14:29 +00003601 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Chris Lattner0fab59c2007-01-12 18:33:30 +00003602 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
3603 std::string NewAsm(yyvsp[0].StrVal, EndStr);
3604 free(yyvsp[0].StrVal);
Chris Lattner66316012006-01-24 04:14:29 +00003605
3606 if (AsmSoFar.empty())
3607 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
3608 else
3609 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Reid Spencer61c83e02006-08-18 08:43:06 +00003610 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003611;
3612 break;}
3613case 187:
3614#line 1935 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3615{ yyval.Endianness = Module::BigEndian; ;
3616 break;}
3617case 188:
3618#line 1936 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3619{ yyval.Endianness = Module::LittleEndian; ;
3620 break;}
3621case 189:
3622#line 1938 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3623{
3624 CurModule.CurrentModule->setEndianness(yyvsp[0].Endianness);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003625 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003626 ;
3627 break;}
3628case 190:
3629#line 1942 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3630{
3631 if (yyvsp[0].UInt64Val == 32)
Reid Spencere4d87aa2006-12-23 06:05:41 +00003632 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
Chris Lattner0fab59c2007-01-12 18:33:30 +00003633 else if (yyvsp[0].UInt64Val == 64)
Reid Spencere4d87aa2006-12-23 06:05:41 +00003634 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
3635 else
Chris Lattner0fab59c2007-01-12 18:33:30 +00003636 GEN_ERROR("Invalid pointer size: '" + utostr(yyvsp[0].UInt64Val) + "'!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00003637 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003638 ;
3639 break;}
3640case 191:
3641#line 1951 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3642{
3643 CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal);
3644 free(yyvsp[0].StrVal);
3645 ;
3646 break;}
3647case 192:
3648#line 1955 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3649{
3650 CurModule.CurrentModule->setDataLayout(yyvsp[0].StrVal);
3651 free(yyvsp[0].StrVal);
3652 ;
3653 break;}
3654case 194:
3655#line 1962 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3656{
3657 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3658 free(yyvsp[0].StrVal);
Reid Spencera54b7cb2007-01-12 07:05:14 +00003659 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003660 ;
3661 break;}
3662case 195:
3663#line 1967 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3664{
3665 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3666 free(yyvsp[0].StrVal);
Reid Spencera54b7cb2007-01-12 07:05:14 +00003667 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003668 ;
3669 break;}
3670case 196:
3671#line 1972 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3672{
Reid Spencera54b7cb2007-01-12 07:05:14 +00003673 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003674 ;
3675 break;}
3676case 200:
3677#line 1982 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3678{ yyval.StrVal = 0; ;
3679 break;}
3680case 201:
3681#line 1984 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3682{
Reid Spencer14310612006-12-31 05:40:51 +00003683 if (!UpRefs.empty())
Chris Lattner0fab59c2007-01-12 18:33:30 +00003684 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3685 if (*yyvsp[-2].TypeVal == Type::VoidTy)
Reid Spencer14310612006-12-31 05:40:51 +00003686 GEN_ERROR("void typed arguments are invalid!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00003687 ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal;
3688 yyval.ArgList = yyvsp[-4].ArgList;
3689 yyvsp[-4].ArgList->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00003690 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003691 ;
3692 break;}
3693case 202:
3694#line 1994 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3695{
Reid Spencer14310612006-12-31 05:40:51 +00003696 if (!UpRefs.empty())
Chris Lattner0fab59c2007-01-12 18:33:30 +00003697 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3698 if (*yyvsp[-2].TypeVal == Type::VoidTy)
Reid Spencer14310612006-12-31 05:40:51 +00003699 GEN_ERROR("void typed arguments are invalid!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00003700 ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal;
3701 yyval.ArgList = new ArgListType;
3702 yyval.ArgList->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00003703 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003704 ;
3705 break;}
3706case 203:
3707#line 2005 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3708{
3709 yyval.ArgList = yyvsp[0].ArgList;
Reid Spencer61c83e02006-08-18 08:43:06 +00003710 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003711 ;
3712 break;}
3713case 204:
3714#line 2009 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3715{
3716 yyval.ArgList = yyvsp[-2].ArgList;
Reid Spencer14310612006-12-31 05:40:51 +00003717 struct ArgListEntry E;
3718 E.Ty = new PATypeHolder(Type::VoidTy);
3719 E.Name = 0;
3720 E.Attrs = FunctionType::NoAttributeSet;
Chris Lattner0fab59c2007-01-12 18:33:30 +00003721 yyval.ArgList->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00003722 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003723 ;
3724 break;}
3725case 205:
3726#line 2018 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3727{
3728 yyval.ArgList = new ArgListType;
Reid Spencer14310612006-12-31 05:40:51 +00003729 struct ArgListEntry E;
3730 E.Ty = new PATypeHolder(Type::VoidTy);
3731 E.Name = 0;
3732 E.Attrs = FunctionType::NoAttributeSet;
Chris Lattner0fab59c2007-01-12 18:33:30 +00003733 yyval.ArgList->push_back(E);
Andrew Lenharth6353e052006-12-08 18:07:09 +00003734 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003735 ;
3736 break;}
3737case 206:
3738#line 2027 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3739{
3740 yyval.ArgList = 0;
Andrew Lenharth6353e052006-12-08 18:07:09 +00003741 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003742 ;
3743 break;}
3744case 207:
3745#line 2033 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3746{
3747 UnEscapeLexed(yyvsp[-6].StrVal);
3748 std::string FunctionName(yyvsp[-6].StrVal);
3749 free(yyvsp[-6].StrVal); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00003750
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00003751 // Check the function result for abstractness if this is a define. We should
3752 // have no abstract types at this point
Chris Lattner0fab59c2007-01-12 18:33:30 +00003753 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(yyvsp[-7].TypeVal))
3754 GEN_ERROR("Reference to abstract result: "+ yyvsp[-7].TypeVal->get()->getDescription());
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00003755
Reid Spencer68a24bd2005-08-27 18:50:39 +00003756 std::vector<const Type*> ParamTypeList;
Reid Spencer14310612006-12-31 05:40:51 +00003757 std::vector<FunctionType::ParameterAttributes> ParamAttrs;
Chris Lattner0fab59c2007-01-12 18:33:30 +00003758 ParamAttrs.push_back(yyvsp[-2].ParamAttrs);
3759 if (yyvsp[-4].ArgList) { // If there are arguments...
3760 for (ArgListType::iterator I = yyvsp[-4].ArgList->begin(); I != yyvsp[-4].ArgList->end(); ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00003761 const Type* Ty = I->Ty->get();
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00003762 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
3763 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00003764 ParamTypeList.push_back(Ty);
3765 if (Ty != Type::VoidTy)
3766 ParamAttrs.push_back(I->Attrs);
3767 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00003768 }
3769
3770 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
3771 if (isVarArg) ParamTypeList.pop_back();
3772
Chris Lattner0fab59c2007-01-12 18:33:30 +00003773 FunctionType *FT = FunctionType::get(*yyvsp[-7].TypeVal, ParamTypeList, isVarArg,
Reid Spencer14310612006-12-31 05:40:51 +00003774 ParamAttrs);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003775 const PointerType *PFT = PointerType::get(FT);
Chris Lattner0fab59c2007-01-12 18:33:30 +00003776 delete yyvsp[-7].TypeVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003777
3778 ValID ID;
3779 if (!FunctionName.empty()) {
3780 ID = ValID::create((char*)FunctionName.c_str());
3781 } else {
3782 ID = ValID::create((int)CurModule.Values[PFT].size());
3783 }
3784
3785 Function *Fn = 0;
3786 // See if this function was forward referenced. If so, recycle the object.
3787 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
3788 // Move the function to the end of the list, from whereever it was
3789 // previously inserted.
3790 Fn = cast<Function>(FWRef);
3791 CurModule.CurrentModule->getFunctionList().remove(Fn);
3792 CurModule.CurrentModule->getFunctionList().push_back(Fn);
3793 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
3794 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
3795 // If this is the case, either we need to be a forward decl, or it needs
3796 // to be.
3797 if (!CurFun.isDeclare && !Fn->isExternal())
Reid Spencer61c83e02006-08-18 08:43:06 +00003798 GEN_ERROR("Redefinition of function '" + FunctionName + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003799
3800 // Make sure to strip off any argument names so we can't get conflicts.
3801 if (Fn->isExternal())
3802 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
3803 AI != AE; ++AI)
3804 AI->setName("");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003805 } else { // Not already defined?
3806 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
3807 CurModule.CurrentModule);
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00003808
Reid Spencer68a24bd2005-08-27 18:50:39 +00003809 InsertValue(Fn, CurModule.Values);
3810 }
3811
3812 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00003813
3814 if (CurFun.isDeclare) {
3815 // If we have declaration, always overwrite linkage. This will allow us to
3816 // correctly handle cases, when pointer to function is passed as argument to
3817 // another function.
3818 Fn->setLinkage(CurFun.Linkage);
3819 }
Chris Lattner0fab59c2007-01-12 18:33:30 +00003820 Fn->setCallingConv(yyvsp[-8].UIntVal);
3821 Fn->setAlignment(yyvsp[0].UIntVal);
3822 if (yyvsp[-1].StrVal) {
3823 Fn->setSection(yyvsp[-1].StrVal);
3824 free(yyvsp[-1].StrVal);
Chris Lattnere869eef2005-11-12 00:11:49 +00003825 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00003826
3827 // Add all of the arguments we parsed to the function...
Chris Lattner0fab59c2007-01-12 18:33:30 +00003828 if (yyvsp[-4].ArgList) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00003829 if (isVarArg) { // Nuke the last entry
Chris Lattner0fab59c2007-01-12 18:33:30 +00003830 assert(yyvsp[-4].ArgList->back().Ty->get() == Type::VoidTy && yyvsp[-4].ArgList->back().Name == 0&&
Reid Spencera132e042006-12-03 05:46:11 +00003831 "Not a varargs marker!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00003832 delete yyvsp[-4].ArgList->back().Ty;
3833 yyvsp[-4].ArgList->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00003834 }
3835 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spencer14310612006-12-31 05:40:51 +00003836 unsigned Idx = 1;
Chris Lattner0fab59c2007-01-12 18:33:30 +00003837 for (ArgListType::iterator I = yyvsp[-4].ArgList->begin(); I != yyvsp[-4].ArgList->end(); ++I, ++ArgIt) {
Reid Spencer14310612006-12-31 05:40:51 +00003838 delete I->Ty; // Delete the typeholder...
3839 setValueName(ArgIt, I->Name); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00003840 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003841 InsertValue(ArgIt);
Reid Spencer14310612006-12-31 05:40:51 +00003842 Idx++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003843 }
Reid Spencera132e042006-12-03 05:46:11 +00003844
Chris Lattner0fab59c2007-01-12 18:33:30 +00003845 delete yyvsp[-4].ArgList; // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00003846 }
Reid Spencer61c83e02006-08-18 08:43:06 +00003847 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003848;
3849 break;}
3850case 210:
3851#line 2139 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3852{
3853 yyval.FunctionVal = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003854
3855 // Make sure that we keep track of the linkage type even if there was a
3856 // previous "declare".
Chris Lattner0fab59c2007-01-12 18:33:30 +00003857 yyval.FunctionVal->setLinkage(yyvsp[-2].Linkage);
3858;
3859 break;}
3860case 213:
3861#line 2149 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3862{
3863 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Andrew Lenharth6353e052006-12-08 18:07:09 +00003864 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003865;
3866 break;}
3867case 214:
3868#line 2154 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3869{
3870 CurFun.CurrentFunction->setLinkage(yyvsp[-1].Linkage);
3871 yyval.FunctionVal = CurFun.CurrentFunction;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00003872 CurFun.FunctionDone();
Reid Spencer61c83e02006-08-18 08:43:06 +00003873 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003874 ;
3875 break;}
3876case 215:
3877#line 2165 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3878{
3879 yyval.BoolVal = false;
Reid Spencere4d87aa2006-12-23 06:05:41 +00003880 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003881 ;
3882 break;}
3883case 216:
3884#line 2169 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3885{
3886 yyval.BoolVal = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00003887 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003888 ;
3889 break;}
3890case 217:
3891#line 2174 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3892{ // A reference to a direct constant
3893 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003894 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003895 ;
3896 break;}
3897case 218:
3898#line 2178 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3899{
3900 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003901 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003902 ;
3903 break;}
3904case 219:
3905#line 2182 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3906{ // Perhaps it's an FP constant?
3907 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003908 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003909 ;
3910 break;}
3911case 220:
3912#line 2186 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3913{
3914 yyval.ValIDVal = ValID::create(ConstantInt::getTrue());
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003915 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003916 ;
3917 break;}
3918case 221:
3919#line 2190 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3920{
3921 yyval.ValIDVal = ValID::create(ConstantInt::getFalse());
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003922 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003923 ;
3924 break;}
3925case 222:
3926#line 2194 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3927{
3928 yyval.ValIDVal = ValID::createNull();
Reid Spencer61c83e02006-08-18 08:43:06 +00003929 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003930 ;
3931 break;}
3932case 223:
3933#line 2198 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3934{
3935 yyval.ValIDVal = ValID::createUndef();
Reid Spencer61c83e02006-08-18 08:43:06 +00003936 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003937 ;
3938 break;}
3939case 224:
3940#line 2202 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3941{ // A vector zero constant.
3942 yyval.ValIDVal = ValID::createZeroInit();
Reid Spencer61c83e02006-08-18 08:43:06 +00003943 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003944 ;
3945 break;}
3946case 225:
3947#line 2206 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3948{ // Nonempty unsized packed vector
3949 const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
3950 int NumElements = yyvsp[-1].ConstVector->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003951
3952 PackedType* pt = PackedType::get(ETy, NumElements);
3953 PATypeHolder* PTy = new PATypeHolder(
Reid Spencera132e042006-12-03 05:46:11 +00003954 HandleUpRefs(
3955 PackedType::get(
3956 ETy,
3957 NumElements)
3958 )
3959 );
Reid Spencer68a24bd2005-08-27 18:50:39 +00003960
3961 // Verify all elements are correct type!
Chris Lattner0fab59c2007-01-12 18:33:30 +00003962 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3963 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003964 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003965 ETy->getDescription() +"' as required!\nIt is of type '" +
Chris Lattner0fab59c2007-01-12 18:33:30 +00003966 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003967 }
3968
Chris Lattner0fab59c2007-01-12 18:33:30 +00003969 yyval.ValIDVal = ValID::create(ConstantPacked::get(pt, *yyvsp[-1].ConstVector));
3970 delete PTy; delete yyvsp[-1].ConstVector;
Reid Spencere4d87aa2006-12-23 06:05:41 +00003971 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003972 ;
3973 break;}
3974case 226:
3975#line 2231 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3976{
3977 yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003978 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003979 ;
3980 break;}
3981case 227:
3982#line 2235 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3983{
3984 char *End = UnEscapeLexed(yyvsp[-2].StrVal, true);
3985 std::string AsmStr = std::string(yyvsp[-2].StrVal, End);
3986 End = UnEscapeLexed(yyvsp[0].StrVal, true);
3987 std::string Constraints = std::string(yyvsp[0].StrVal, End);
3988 yyval.ValIDVal = ValID::createInlineAsm(AsmStr, Constraints, yyvsp[-3].BoolVal);
3989 free(yyvsp[-2].StrVal);
3990 free(yyvsp[0].StrVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003991 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003992 ;
3993 break;}
3994case 228:
3995#line 2249 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3996{ // Is it an integer reference...?
3997 yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003998 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00003999 ;
4000 break;}
4001case 229:
4002#line 2253 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4003{ // Is it a named reference...?
4004 yyval.ValIDVal = ValID::create(yyvsp[0].StrVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004005 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004006 ;
4007 break;}
4008case 232:
4009#line 2265 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4010{
Reid Spencer14310612006-12-31 05:40:51 +00004011 if (!UpRefs.empty())
Chris Lattner0fab59c2007-01-12 18:33:30 +00004012 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4013 yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
4014 delete yyvsp[-1].TypeVal;
Reid Spencer21be8652006-10-22 07:03:43 +00004015 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004016 ;
4017 break;}
4018case 233:
4019#line 2274 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4020{
4021 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Reid Spencer3822ff52006-11-08 06:47:33 +00004022 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004023 ;
4024 break;}
4025case 234:
4026#line 2278 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4027{ // Do not allow functions with 0 basic blocks
4028 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Andrew Lenharth6353e052006-12-08 18:07:09 +00004029 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004030 ;
4031 break;}
4032case 235:
4033#line 2287 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4034{
4035 setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004036 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004037 InsertValue(yyvsp[0].TermInstVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004038
Chris Lattner0fab59c2007-01-12 18:33:30 +00004039 yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
4040 InsertValue(yyvsp[-2].BasicBlockVal);
4041 yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
Andrew Lenharth6353e052006-12-08 18:07:09 +00004042 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004043 ;
4044 break;}
4045case 236:
4046#line 2298 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4047{
4048 if (CastInst *CI1 = dyn_cast<CastInst>(yyvsp[0].InstVal))
Reid Spencere4d87aa2006-12-23 06:05:41 +00004049 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
4050 if (CI2->getParent() == 0)
Chris Lattner0fab59c2007-01-12 18:33:30 +00004051 yyvsp[-1].BasicBlockVal->getInstList().push_back(CI2);
4052 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
4053 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004054 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004055 ;
4056 break;}
4057case 237:
4058#line 2307 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4059{
4060 yyval.BasicBlockVal = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004061 CHECK_FOR_ERROR
4062
4063 // Make sure to move the basic block to the correct location in the
4064 // function, instead of leaving it inserted wherever it was first
4065 // referenced.
4066 Function::BasicBlockListType &BBL =
4067 CurFun.CurrentFunction->getBasicBlockList();
Chris Lattner0fab59c2007-01-12 18:33:30 +00004068 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004069 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004070 ;
4071 break;}
4072case 238:
4073#line 2319 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4074{
4075 yyval.BasicBlockVal = getBBVal(ValID::create(yyvsp[0].StrVal), true);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004076 CHECK_FOR_ERROR
4077
4078 // Make sure to move the basic block to the correct location in the
4079 // function, instead of leaving it inserted wherever it was first
4080 // referenced.
4081 Function::BasicBlockListType &BBL =
4082 CurFun.CurrentFunction->getBasicBlockList();
Chris Lattner0fab59c2007-01-12 18:33:30 +00004083 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00004084 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004085 ;
4086 break;}
4087case 239:
4088#line 2332 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4089{ // Return with a result...
4090 yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
4091 CHECK_FOR_ERROR
4092 ;
4093 break;}
4094case 240:
4095#line 2336 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4096{ // Return with no result...
4097 yyval.TermInstVal = new ReturnInst();
4098 CHECK_FOR_ERROR
4099 ;
4100 break;}
4101case 241:
4102#line 2340 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4103{ // Unconditional Branch...
4104 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
4105 CHECK_FOR_ERROR
4106 yyval.TermInstVal = new BranchInst(tmpBB);
4107 ;
4108 break;}
4109case 242:
4110#line 2345 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4111{
4112 BasicBlock* tmpBBA = getBBVal(yyvsp[-3].ValIDVal);
4113 CHECK_FOR_ERROR
4114 BasicBlock* tmpBBB = getBBVal(yyvsp[0].ValIDVal);
4115 CHECK_FOR_ERROR
4116 Value* tmpVal = getVal(Type::Int1Ty, yyvsp[-6].ValIDVal);
4117 CHECK_FOR_ERROR
4118 yyval.TermInstVal = new BranchInst(tmpBBA, tmpBBB, tmpVal);
4119 ;
4120 break;}
4121case 243:
4122#line 2354 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4123{
4124 Value* tmpVal = getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal);
4125 CHECK_FOR_ERROR
4126 BasicBlock* tmpBB = getBBVal(yyvsp[-3].ValIDVal);
4127 CHECK_FOR_ERROR
4128 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, yyvsp[-1].JumpTable->size());
4129 yyval.TermInstVal = S;
Reid Spencer3822ff52006-11-08 06:47:33 +00004130
Chris Lattner0fab59c2007-01-12 18:33:30 +00004131 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
4132 E = yyvsp[-1].JumpTable->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004133 for (; I != E; ++I) {
4134 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
4135 S->addCase(CI, I->second);
4136 else
Reid Spencer61c83e02006-08-18 08:43:06 +00004137 GEN_ERROR("Switch case is constant, but not a simple integer!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004138 }
Chris Lattner0fab59c2007-01-12 18:33:30 +00004139 delete yyvsp[-1].JumpTable;
Reid Spencer61c83e02006-08-18 08:43:06 +00004140 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004141 ;
4142 break;}
4143case 244:
4144#line 2373 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4145{
4146 Value* tmpVal = getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004147 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004148 BasicBlock* tmpBB = getBBVal(yyvsp[-2].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004149 CHECK_FOR_ERROR
4150 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Chris Lattner0fab59c2007-01-12 18:33:30 +00004151 yyval.TermInstVal = S;
Reid Spencer61c83e02006-08-18 08:43:06 +00004152 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004153 ;
4154 break;}
4155case 245:
4156#line 2383 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4157{
Reid Spencer3822ff52006-11-08 06:47:33 +00004158
Reid Spencer14310612006-12-31 05:40:51 +00004159 // Handle the short syntax
4160 const PointerType *PFTy = 0;
4161 const FunctionType *Ty = 0;
Chris Lattner0fab59c2007-01-12 18:33:30 +00004162 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-11].TypeVal->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00004163 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4164 // Pull out the types of all of the arguments...
4165 std::vector<const Type*> ParamTypes;
Reid Spencer14310612006-12-31 05:40:51 +00004166 FunctionType::ParamAttrsList ParamAttrs;
Chris Lattner0fab59c2007-01-12 18:33:30 +00004167 ParamAttrs.push_back(yyvsp[-6].ParamAttrs);
4168 for (ValueRefList::iterator I = yyvsp[-8].ValueRefList->begin(), E = yyvsp[-8].ValueRefList->end(); I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00004169 const Type *Ty = I->Val->getType();
4170 if (Ty == Type::VoidTy)
4171 GEN_ERROR("Short call syntax cannot be used with varargs");
4172 ParamTypes.push_back(Ty);
4173 ParamAttrs.push_back(I->Attrs);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004174 }
4175
Chris Lattner0fab59c2007-01-12 18:33:30 +00004176 Ty = FunctionType::get(yyvsp[-11].TypeVal->get(), ParamTypes, false, ParamAttrs);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004177 PFTy = PointerType::get(Ty);
4178 }
4179
Chris Lattner0fab59c2007-01-12 18:33:30 +00004180 Value *V = getVal(PFTy, yyvsp[-10].ValIDVal); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00004181 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004182 BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004183 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004184 BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
Reid Spencer5b7e7532006-09-28 19:28:24 +00004185 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004186
Reid Spencer14310612006-12-31 05:40:51 +00004187 // Check the arguments
4188 ValueList Args;
Chris Lattner0fab59c2007-01-12 18:33:30 +00004189 if (yyvsp[-8].ValueRefList->empty()) { // Has no arguments?
Reid Spencer14310612006-12-31 05:40:51 +00004190 // Make sure no arguments is a good thing!
4191 if (Ty->getNumParams() != 0)
4192 GEN_ERROR("No arguments passed to a function that "
4193 "expects arguments!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004194 } else { // Has arguments?
4195 // Loop through FunctionType's arguments and ensure they are specified
4196 // correctly!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004197 FunctionType::param_iterator I = Ty->param_begin();
4198 FunctionType::param_iterator E = Ty->param_end();
Chris Lattner0fab59c2007-01-12 18:33:30 +00004199 ValueRefList::iterator ArgI = yyvsp[-8].ValueRefList->begin(), ArgE = yyvsp[-8].ValueRefList->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004200
Reid Spencer14310612006-12-31 05:40:51 +00004201 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
4202 if (ArgI->Val->getType() != *I)
4203 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencera132e042006-12-03 05:46:11 +00004204 (*I)->getDescription() + "'!");
Reid Spencer14310612006-12-31 05:40:51 +00004205 Args.push_back(ArgI->Val);
4206 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004207
Reid Spencer14310612006-12-31 05:40:51 +00004208 if (Ty->isVarArg()) {
4209 if (I == E)
4210 for (; ArgI != ArgE; ++ArgI)
4211 Args.push_back(ArgI->Val); // push the remaining varargs
4212 } else if (I != E || ArgI != ArgE)
Reid Spencer61c83e02006-08-18 08:43:06 +00004213 GEN_ERROR("Invalid number of parameters detected!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004214 }
Reid Spencer14310612006-12-31 05:40:51 +00004215
4216 // Create the InvokeInst
4217 InvokeInst *II = new InvokeInst(V, Normal, Except, Args);
Chris Lattner0fab59c2007-01-12 18:33:30 +00004218 II->setCallingConv(yyvsp[-12].UIntVal);
4219 yyval.TermInstVal = II;
4220 delete yyvsp[-8].ValueRefList;
Andrew Lenharth6353e052006-12-08 18:07:09 +00004221 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004222 ;
4223 break;}
4224case 246:
4225#line 2449 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4226{
4227 yyval.TermInstVal = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00004228 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004229 ;
4230 break;}
4231case 247:
4232#line 2453 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4233{
4234 yyval.TermInstVal = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00004235 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004236 ;
4237 break;}
4238case 248:
4239#line 2460 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4240{
4241 yyval.JumpTable = yyvsp[-5].JumpTable;
4242 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004243 CHECK_FOR_ERROR
4244 if (V == 0)
4245 GEN_ERROR("May only switch on a constant pool value!");
4246
Chris Lattner0fab59c2007-01-12 18:33:30 +00004247 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004248 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004249 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
4250 ;
4251 break;}
4252case 249:
4253#line 2471 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4254{
4255 yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
4256 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004257 CHECK_FOR_ERROR
4258
4259 if (V == 0)
4260 GEN_ERROR("May only switch on a constant pool value!");
4261
Chris Lattner0fab59c2007-01-12 18:33:30 +00004262 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004263 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004264 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
4265 ;
4266 break;}
4267case 250:
4268#line 2484 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4269{
Andrew Lenharth6353e052006-12-08 18:07:09 +00004270 // Is this definition named?? if so, assign the name...
Chris Lattner0fab59c2007-01-12 18:33:30 +00004271 setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004272 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004273 InsertValue(yyvsp[0].InstVal);
4274 yyval.InstVal = yyvsp[0].InstVal;
Andrew Lenharth6353e052006-12-08 18:07:09 +00004275 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004276;
4277 break;}
4278case 251:
4279#line 2493 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4280{ // Used for PHI nodes
Reid Spencer14310612006-12-31 05:40:51 +00004281 if (!UpRefs.empty())
Chris Lattner0fab59c2007-01-12 18:33:30 +00004282 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-5].TypeVal)->getDescription());
4283 yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
4284 Value* tmpVal = getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004285 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004286 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004287 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004288 yyval.PHIList->push_back(std::make_pair(tmpVal, tmpBB));
4289 delete yyvsp[-5].TypeVal;
4290 ;
4291 break;}
4292case 252:
4293#line 2504 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4294{
4295 yyval.PHIList = yyvsp[-6].PHIList;
4296 Value* tmpVal = getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004297 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004298 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004299 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004300 yyvsp[-6].PHIList->push_back(std::make_pair(tmpVal, tmpBB));
4301 ;
4302 break;}
4303case 253:
4304#line 2514 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4305{
Reid Spencer14310612006-12-31 05:40:51 +00004306 if (!UpRefs.empty())
Chris Lattner0fab59c2007-01-12 18:33:30 +00004307 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00004308 // Used for call and invoke instructions
Chris Lattner0fab59c2007-01-12 18:33:30 +00004309 yyval.ValueRefList = new ValueRefList();
4310 ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal);
4311 yyval.ValueRefList->push_back(E);
4312 ;
4313 break;}
4314case 254:
4315#line 2522 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4316{
Reid Spencer14310612006-12-31 05:40:51 +00004317 if (!UpRefs.empty())
Chris Lattner0fab59c2007-01-12 18:33:30 +00004318 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4319 yyval.ValueRefList = yyvsp[-4].ValueRefList;
4320 ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal);
4321 yyval.ValueRefList->push_back(E);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004322 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004323 ;
4324 break;}
4325case 255:
4326#line 2530 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4327{ yyval.ValueRefList = new ValueRefList(); ;
4328 break;}
4329case 256:
4330#line 2533 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4331{ yyval.ValueList = new std::vector<Value*>(); ;
4332 break;}
4333case 257:
4334#line 2534 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4335{
4336 yyval.ValueList = yyvsp[-2].ValueList;
4337 yyval.ValueList->push_back(yyvsp[0].ValueVal);
Reid Spencer14310612006-12-31 05:40:51 +00004338 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004339 ;
4340 break;}
4341case 258:
4342#line 2541 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4343{
4344 yyval.BoolVal = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004345 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004346 ;
4347 break;}
4348case 259:
4349#line 2545 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4350{
4351 yyval.BoolVal = false;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004352 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004353 ;
4354 break;}
4355case 260:
4356#line 2550 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4357{
Reid Spencer14310612006-12-31 05:40:51 +00004358 if (!UpRefs.empty())
Chris Lattner0fab59c2007-01-12 18:33:30 +00004359 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4360 if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
4361 !isa<PackedType>((*yyvsp[-3].TypeVal).get()))
Reid Spencere4d87aa2006-12-23 06:05:41 +00004362 GEN_ERROR(
4363 "Arithmetic operator requires integer, FP, or packed operands!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00004364 if (isa<PackedType>((*yyvsp[-3].TypeVal).get()) &&
4365 (yyvsp[-4].BinaryOpVal == Instruction::URem ||
4366 yyvsp[-4].BinaryOpVal == Instruction::SRem ||
4367 yyvsp[-4].BinaryOpVal == Instruction::FRem))
Reid Spencere4d87aa2006-12-23 06:05:41 +00004368 GEN_ERROR("U/S/FRem not supported on packed types!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00004369 Value* val1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004370 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004371 Value* val2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004372 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004373 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, val1, val2);
4374 if (yyval.InstVal == 0)
Reid Spencere4d87aa2006-12-23 06:05:41 +00004375 GEN_ERROR("binary operator returned null!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00004376 delete yyvsp[-3].TypeVal;
4377 ;
4378 break;}
4379case 261:
4380#line 2571 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4381{
Reid Spencer14310612006-12-31 05:40:51 +00004382 if (!UpRefs.empty())
Chris Lattner0fab59c2007-01-12 18:33:30 +00004383 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4384 if (!(*yyvsp[-3].TypeVal)->isIntegral()) {
4385 if (!isa<PackedType>(yyvsp[-3].TypeVal->get()) ||
4386 !cast<PackedType>(yyvsp[-3].TypeVal->get())->getElementType()->isIntegral())
Reid Spencere4d87aa2006-12-23 06:05:41 +00004387 GEN_ERROR("Logical operator requires integral operands!");
4388 }
Chris Lattner0fab59c2007-01-12 18:33:30 +00004389 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004390 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004391 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004392 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004393 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, tmpVal1, tmpVal2);
4394 if (yyval.InstVal == 0)
Reid Spencere4d87aa2006-12-23 06:05:41 +00004395 GEN_ERROR("binary operator returned null!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00004396 delete yyvsp[-3].TypeVal;
4397 ;
4398 break;}
4399case 262:
4400#line 2588 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4401{
Reid Spencer14310612006-12-31 05:40:51 +00004402 if (!UpRefs.empty())
Chris Lattner0fab59c2007-01-12 18:33:30 +00004403 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4404 if (isa<PackedType>((*yyvsp[-3].TypeVal).get()))
Reid Spencerac4a1dd2007-01-04 02:57:52 +00004405 GEN_ERROR("Packed types not supported by icmp instruction");
Chris Lattner0fab59c2007-01-12 18:33:30 +00004406 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004407 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004408 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004409 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004410 yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].IPredicate, tmpVal1, tmpVal2);
4411 if (yyval.InstVal == 0)
Andrew Lenharth6353e052006-12-08 18:07:09 +00004412 GEN_ERROR("icmp operator returned null!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00004413 ;
4414 break;}
4415case 263:
4416#line 2601 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4417{
Reid Spencer14310612006-12-31 05:40:51 +00004418 if (!UpRefs.empty())
Chris Lattner0fab59c2007-01-12 18:33:30 +00004419 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4420 if (isa<PackedType>((*yyvsp[-3].TypeVal).get()))
Reid Spencerac4a1dd2007-01-04 02:57:52 +00004421 GEN_ERROR("Packed types not supported by fcmp instruction");
Chris Lattner0fab59c2007-01-12 18:33:30 +00004422 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004423 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004424 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004425 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004426 yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].FPredicate, tmpVal1, tmpVal2);
4427 if (yyval.InstVal == 0)
Andrew Lenharth6353e052006-12-08 18:07:09 +00004428 GEN_ERROR("fcmp operator returned null!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00004429 ;
4430 break;}
4431case 264:
4432#line 2614 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4433{
4434 if (yyvsp[0].ValueVal->getType() != Type::Int8Ty)
Reid Spencer14310612006-12-31 05:40:51 +00004435 GEN_ERROR("Shift amount must be i8 type!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00004436 if (!yyvsp[-2].ValueVal->getType()->isInteger())
Andrew Lenharth6353e052006-12-08 18:07:09 +00004437 GEN_ERROR("Shift constant expression requires integer operand!");
4438 CHECK_FOR_ERROR;
Chris Lattner0fab59c2007-01-12 18:33:30 +00004439 yyval.InstVal = new ShiftInst(yyvsp[-3].OtherOpVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004440 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004441 ;
4442 break;}
4443case 265:
4444#line 2623 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4445{
Reid Spencer14310612006-12-31 05:40:51 +00004446 if (!UpRefs.empty())
Chris Lattner0fab59c2007-01-12 18:33:30 +00004447 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
4448 Value* Val = yyvsp[-2].ValueVal;
4449 const Type* Ty = yyvsp[0].TypeVal->get();
Andrew Lenharth6353e052006-12-08 18:07:09 +00004450 if (!Val->getType()->isFirstClassType())
4451 GEN_ERROR("cast from a non-primitive type: '" +
4452 Val->getType()->getDescription() + "'!");
4453 if (!Ty->isFirstClassType())
4454 GEN_ERROR("cast to a non-primitive type: '" + Ty->getDescription() +"'!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00004455 yyval.InstVal = CastInst::create(yyvsp[-3].CastOpVal, Val, yyvsp[0].TypeVal->get());
4456 delete yyvsp[0].TypeVal;
4457 ;
4458 break;}
4459case 266:
4460#line 2636 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4461{
4462 if (yyvsp[-4].ValueVal->getType() != Type::Int1Ty)
Andrew Lenharth6353e052006-12-08 18:07:09 +00004463 GEN_ERROR("select condition must be boolean!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00004464 if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
Andrew Lenharth6353e052006-12-08 18:07:09 +00004465 GEN_ERROR("select value types should match!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00004466 yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004467 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004468 ;
4469 break;}
4470case 267:
4471#line 2644 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4472{
Reid Spencer14310612006-12-31 05:40:51 +00004473 if (!UpRefs.empty())
Chris Lattner0fab59c2007-01-12 18:33:30 +00004474 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
4475 yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
4476 delete yyvsp[0].TypeVal;
Andrew Lenharth6353e052006-12-08 18:07:09 +00004477 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004478 ;
4479 break;}
4480case 268:
4481#line 2651 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4482{
4483 if (!ExtractElementInst::isValidOperands(yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Andrew Lenharth6353e052006-12-08 18:07:09 +00004484 GEN_ERROR("Invalid extractelement operands!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00004485 yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004486 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004487 ;
4488 break;}
4489case 269:
4490#line 2657 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4491{
4492 if (!InsertElementInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Andrew Lenharth6353e052006-12-08 18:07:09 +00004493 GEN_ERROR("Invalid insertelement operands!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00004494 yyval.InstVal = new InsertElementInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004495 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004496 ;
4497 break;}
4498case 270:
4499#line 2663 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4500{
4501 if (!ShuffleVectorInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Andrew Lenharth6353e052006-12-08 18:07:09 +00004502 GEN_ERROR("Invalid shufflevector operands!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00004503 yyval.InstVal = new ShuffleVectorInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004504 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004505 ;
4506 break;}
4507case 271:
4508#line 2669 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4509{
4510 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
Andrew Lenharth6353e052006-12-08 18:07:09 +00004511 if (!Ty->isFirstClassType())
4512 GEN_ERROR("PHI node operands must be of first class type!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00004513 yyval.InstVal = new PHINode(Ty);
4514 ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
4515 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
4516 if (yyvsp[0].PHIList->front().first->getType() != Ty)
Andrew Lenharth6353e052006-12-08 18:07:09 +00004517 GEN_ERROR("All elements of a PHI node must be of the same type!");
Chris Lattner0fab59c2007-01-12 18:33:30 +00004518 cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
4519 yyvsp[0].PHIList->pop_front();
Andrew Lenharth6353e052006-12-08 18:07:09 +00004520 }
Chris Lattner0fab59c2007-01-12 18:33:30 +00004521 delete yyvsp[0].PHIList; // Free the list...
Reid Spencer61c83e02006-08-18 08:43:06 +00004522 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004523 ;
4524 break;}
4525case 272:
4526#line 2685 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4527{
Reid Spencer14310612006-12-31 05:40:51 +00004528
4529 // Handle the short syntax
Andrew Lenharth6353e052006-12-08 18:07:09 +00004530 const PointerType *PFTy = 0;
4531 const FunctionType *Ty = 0;
Chris Lattner0fab59c2007-01-12 18:33:30 +00004532 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-5].TypeVal->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00004533 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4534 // Pull out the types of all of the arguments...
4535 std::vector<const Type*> ParamTypes;
Reid Spencer14310612006-12-31 05:40:51 +00004536 FunctionType::ParamAttrsList ParamAttrs;
Chris Lattner0fab59c2007-01-12 18:33:30 +00004537 ParamAttrs.push_back(yyvsp[0].ParamAttrs);
4538 for (ValueRefList::iterator I = yyvsp[-2].ValueRefList->begin(), E = yyvsp[-2].ValueRefList->end(); I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00004539 const Type *Ty = I->Val->getType();
4540 if (Ty == Type::VoidTy)
4541 GEN_ERROR("Short call syntax cannot be used with varargs");
4542 ParamTypes.push_back(Ty);
4543 ParamAttrs.push_back(I->Attrs);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004544 }
4545
Chris Lattner0fab59c2007-01-12 18:33:30 +00004546 Ty = FunctionType::get(yyvsp[-5].TypeVal->get(), ParamTypes, false, ParamAttrs);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004547 PFTy = PointerType::get(Ty);
4548 }
4549
Chris Lattner0fab59c2007-01-12 18:33:30 +00004550 Value *V = getVal(PFTy, yyvsp[-4].ValIDVal); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00004551 CHECK_FOR_ERROR
4552
Reid Spencer14310612006-12-31 05:40:51 +00004553 // Check the arguments
4554 ValueList Args;
Chris Lattner0fab59c2007-01-12 18:33:30 +00004555 if (yyvsp[-2].ValueRefList->empty()) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00004556 // Make sure no arguments is a good thing!
4557 if (Ty->getNumParams() != 0)
4558 GEN_ERROR("No arguments passed to a function that "
4559 "expects arguments!");
Andrew Lenharth6353e052006-12-08 18:07:09 +00004560 } else { // Has arguments?
4561 // Loop through FunctionType's arguments and ensure they are specified
4562 // correctly!
4563 //
4564 FunctionType::param_iterator I = Ty->param_begin();
4565 FunctionType::param_iterator E = Ty->param_end();
Chris Lattner0fab59c2007-01-12 18:33:30 +00004566 ValueRefList::iterator ArgI = yyvsp[-2].ValueRefList->begin(), ArgE = yyvsp[-2].ValueRefList->end();
Andrew Lenharth6353e052006-12-08 18:07:09 +00004567
Reid Spencer14310612006-12-31 05:40:51 +00004568 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
4569 if (ArgI->Val->getType() != *I)
4570 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Andrew Lenharth6353e052006-12-08 18:07:09 +00004571 (*I)->getDescription() + "'!");
Reid Spencer14310612006-12-31 05:40:51 +00004572 Args.push_back(ArgI->Val);
4573 }
4574 if (Ty->isVarArg()) {
4575 if (I == E)
4576 for (; ArgI != ArgE; ++ArgI)
4577 Args.push_back(ArgI->Val); // push the remaining varargs
4578 } else if (I != E || ArgI != ArgE)
Andrew Lenharth6353e052006-12-08 18:07:09 +00004579 GEN_ERROR("Invalid number of parameters detected!");
Andrew Lenharth6353e052006-12-08 18:07:09 +00004580 }
Reid Spencer14310612006-12-31 05:40:51 +00004581 // Create the call node
4582 CallInst *CI = new CallInst(V, Args);
Chris Lattner0fab59c2007-01-12 18:33:30 +00004583 CI->setTailCall(yyvsp[-7].BoolVal);
4584 CI->setCallingConv(yyvsp[-6].UIntVal);
4585 yyval.InstVal = CI;
4586 delete yyvsp[-2].ValueRefList;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004587 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004588 ;
4589 break;}
4590case 273:
4591#line 2747 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4592{
4593 yyval.InstVal = yyvsp[0].InstVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004594 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004595 ;
4596 break;}
4597case 274:
4598#line 2752 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4599{
4600 yyval.BoolVal = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004601 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004602 ;
4603 break;}
4604case 275:
4605#line 2756 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4606{
4607 yyval.BoolVal = false;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004608 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004609 ;
4610 break;}
4611case 276:
4612#line 2763 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4613{
Reid Spencer14310612006-12-31 05:40:51 +00004614 if (!UpRefs.empty())
Chris Lattner0fab59c2007-01-12 18:33:30 +00004615 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4616 yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
4617 delete yyvsp[-1].TypeVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004618 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004619 ;
4620 break;}
4621case 277:
4622#line 2770 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4623{
Reid Spencer14310612006-12-31 05:40:51 +00004624 if (!UpRefs.empty())
Chris Lattner0fab59c2007-01-12 18:33:30 +00004625 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
4626 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004627 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004628 yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
4629 delete yyvsp[-4].TypeVal;
4630 ;
4631 break;}
4632case 278:
4633#line 2778 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4634{
Reid Spencer14310612006-12-31 05:40:51 +00004635 if (!UpRefs.empty())
Chris Lattner0fab59c2007-01-12 18:33:30 +00004636 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4637 yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
4638 delete yyvsp[-1].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00004639 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004640 ;
4641 break;}
4642case 279:
4643#line 2785 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4644{
Reid Spencer14310612006-12-31 05:40:51 +00004645 if (!UpRefs.empty())
Chris Lattner0fab59c2007-01-12 18:33:30 +00004646 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
4647 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004648 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004649 yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
4650 delete yyvsp[-4].TypeVal;
4651 ;
4652 break;}
4653case 280:
4654#line 2793 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4655{
4656 if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
Reid Spencere4d87aa2006-12-23 06:05:41 +00004657 GEN_ERROR("Trying to free nonpointer type " +
Chris Lattner0fab59c2007-01-12 18:33:30 +00004658 yyvsp[0].ValueVal->getType()->getDescription() + "!");
4659 yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004660 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004661 ;
4662 break;}
4663case 281:
4664#line 2801 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4665{
Reid Spencer14310612006-12-31 05:40:51 +00004666 if (!UpRefs.empty())
Chris Lattner0fab59c2007-01-12 18:33:30 +00004667 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4668 if (!isa<PointerType>(yyvsp[-1].TypeVal->get()))
Reid Spencere4d87aa2006-12-23 06:05:41 +00004669 GEN_ERROR("Can't load from nonpointer type: " +
Chris Lattner0fab59c2007-01-12 18:33:30 +00004670 (*yyvsp[-1].TypeVal)->getDescription());
4671 if (!cast<PointerType>(yyvsp[-1].TypeVal->get())->getElementType()->isFirstClassType())
Reid Spencere4d87aa2006-12-23 06:05:41 +00004672 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Chris Lattner0fab59c2007-01-12 18:33:30 +00004673 (*yyvsp[-1].TypeVal)->getDescription());
4674 Value* tmpVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004675 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004676 yyval.InstVal = new LoadInst(tmpVal, "", yyvsp[-3].BoolVal);
4677 delete yyvsp[-1].TypeVal;
4678 ;
4679 break;}
4680case 282:
4681#line 2815 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4682{
Reid Spencer14310612006-12-31 05:40:51 +00004683 if (!UpRefs.empty())
Chris Lattner0fab59c2007-01-12 18:33:30 +00004684 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4685 const PointerType *PT = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
Reid Spencere4d87aa2006-12-23 06:05:41 +00004686 if (!PT)
4687 GEN_ERROR("Can't store to a nonpointer type: " +
Chris Lattner0fab59c2007-01-12 18:33:30 +00004688 (*yyvsp[-1].TypeVal)->getDescription());
Reid Spencere4d87aa2006-12-23 06:05:41 +00004689 const Type *ElTy = PT->getElementType();
Chris Lattner0fab59c2007-01-12 18:33:30 +00004690 if (ElTy != yyvsp[-3].ValueVal->getType())
4691 GEN_ERROR("Can't store '" + yyvsp[-3].ValueVal->getType()->getDescription() +
Reid Spencere4d87aa2006-12-23 06:05:41 +00004692 "' into space of type '" + ElTy->getDescription() + "'!");
4693
Chris Lattner0fab59c2007-01-12 18:33:30 +00004694 Value* tmpVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004695 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004696 yyval.InstVal = new StoreInst(yyvsp[-3].ValueVal, tmpVal, yyvsp[-5].BoolVal);
4697 delete yyvsp[-1].TypeVal;
4698 ;
4699 break;}
4700case 283:
4701#line 2832 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4702{
Reid Spencer14310612006-12-31 05:40:51 +00004703 if (!UpRefs.empty())
Chris Lattner0fab59c2007-01-12 18:33:30 +00004704 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4705 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
Reid Spencer61c83e02006-08-18 08:43:06 +00004706 GEN_ERROR("getelementptr insn requires pointer operand!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004707
Chris Lattner0fab59c2007-01-12 18:33:30 +00004708 if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, *yyvsp[0].ValueList, true))
Reid Spencer61c83e02006-08-18 08:43:06 +00004709 GEN_ERROR("Invalid getelementptr indices for type '" +
Chris Lattner0fab59c2007-01-12 18:33:30 +00004710 (*yyvsp[-2].TypeVal)->getDescription()+ "'!");
4711 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004712 CHECK_FOR_ERROR
Chris Lattner0fab59c2007-01-12 18:33:30 +00004713 yyval.InstVal = new GetElementPtrInst(tmpVal, *yyvsp[0].ValueList);
4714 delete yyvsp[-2].TypeVal;
4715 delete yyvsp[0].ValueList;
4716 ;
4717 break;}
4718}
4719 /* the action file gets copied in in place of this dollarsign */
4720#line 543 "/usr/share/bison.simple"
Andrew Lenharth6353e052006-12-08 18:07:09 +00004721
4722 yyvsp -= yylen;
4723 yyssp -= yylen;
Chris Lattner0fab59c2007-01-12 18:33:30 +00004724#ifdef YYLSP_NEEDED
4725 yylsp -= yylen;
4726#endif
Andrew Lenharth6353e052006-12-08 18:07:09 +00004727
Chris Lattner0fab59c2007-01-12 18:33:30 +00004728#if YYDEBUG != 0
4729 if (yydebug)
4730 {
4731 short *ssp1 = yyss - 1;
4732 fprintf (stderr, "state stack now");
4733 while (ssp1 != yyssp)
4734 fprintf (stderr, " %d", *++ssp1);
4735 fprintf (stderr, "\n");
4736 }
4737#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00004738
4739 *++yyvsp = yyval;
4740
Chris Lattner0fab59c2007-01-12 18:33:30 +00004741#ifdef YYLSP_NEEDED
4742 yylsp++;
4743 if (yylen == 0)
4744 {
4745 yylsp->first_line = yylloc.first_line;
4746 yylsp->first_column = yylloc.first_column;
4747 yylsp->last_line = (yylsp-1)->last_line;
4748 yylsp->last_column = (yylsp-1)->last_column;
4749 yylsp->text = 0;
4750 }
4751 else
4752 {
4753 yylsp->last_line = (yylsp+yylen-1)->last_line;
4754 yylsp->last_column = (yylsp+yylen-1)->last_column;
4755 }
4756#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00004757
Chris Lattner0fab59c2007-01-12 18:33:30 +00004758 /* Now "shift" the result of the reduction.
4759 Determine what state that goes to,
4760 based on the state we popped back to
4761 and the rule number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004762
4763 yyn = yyr1[yyn];
4764
Chris Lattner0fab59c2007-01-12 18:33:30 +00004765 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
4766 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004767 yystate = yytable[yystate];
4768 else
Chris Lattner0fab59c2007-01-12 18:33:30 +00004769 yystate = yydefgoto[yyn - YYNTBASE];
Reid Spencer68a24bd2005-08-27 18:50:39 +00004770
4771 goto yynewstate;
4772
Chris Lattner0fab59c2007-01-12 18:33:30 +00004773yyerrlab: /* here on detecting error */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004774
Chris Lattner0fab59c2007-01-12 18:33:30 +00004775 if (! yyerrstatus)
4776 /* If not already recovering from an error, report this error. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004777 {
4778 ++yynerrs;
Chris Lattner0fab59c2007-01-12 18:33:30 +00004779
4780#ifdef YYERROR_VERBOSE
Andrew Lenharth6353e052006-12-08 18:07:09 +00004781 yyn = yypact[yystate];
Bill Wendlinge8156192006-12-07 01:30:32 +00004782
Chris Lattner0fab59c2007-01-12 18:33:30 +00004783 if (yyn > YYFLAG && yyn < YYLAST)
Andrew Lenharth6353e052006-12-08 18:07:09 +00004784 {
Chris Lattner0fab59c2007-01-12 18:33:30 +00004785 int size = 0;
4786 char *msg;
4787 int x, count;
Andrew Lenharth6353e052006-12-08 18:07:09 +00004788
Chris Lattner0fab59c2007-01-12 18:33:30 +00004789 count = 0;
4790 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
4791 for (x = (yyn < 0 ? -yyn : 0);
4792 x < (sizeof(yytname) / sizeof(char *)); x++)
4793 if (yycheck[x + yyn] == x)
4794 size += strlen(yytname[x]) + 15, count++;
4795 msg = (char *) malloc(size + 15);
4796 if (msg != 0)
Reid Spencere4d87aa2006-12-23 06:05:41 +00004797 {
Chris Lattner0fab59c2007-01-12 18:33:30 +00004798 strcpy(msg, "parse error");
4799
4800 if (count < 5)
Andrew Lenharth6353e052006-12-08 18:07:09 +00004801 {
Chris Lattner0fab59c2007-01-12 18:33:30 +00004802 count = 0;
4803 for (x = (yyn < 0 ? -yyn : 0);
4804 x < (sizeof(yytname) / sizeof(char *)); x++)
4805 if (yycheck[x + yyn] == x)
4806 {
4807 strcat(msg, count == 0 ? ", expecting `" : " or `");
4808 strcat(msg, yytname[x]);
4809 strcat(msg, "'");
4810 count++;
4811 }
Andrew Lenharth6353e052006-12-08 18:07:09 +00004812 }
Chris Lattner0fab59c2007-01-12 18:33:30 +00004813 yyerror(msg);
4814 free(msg);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004815 }
4816 else
Chris Lattner0fab59c2007-01-12 18:33:30 +00004817 yyerror ("parse error; also virtual memory exceeded");
Andrew Lenharth6353e052006-12-08 18:07:09 +00004818 }
4819 else
4820#endif /* YYERROR_VERBOSE */
Chris Lattner0fab59c2007-01-12 18:33:30 +00004821 yyerror("parse error");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004822 }
4823
Chris Lattner0fab59c2007-01-12 18:33:30 +00004824 goto yyerrlab1;
4825yyerrlab1: /* here on error raised explicitly by an action */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004826
4827 if (yyerrstatus == 3)
4828 {
Chris Lattner0fab59c2007-01-12 18:33:30 +00004829 /* if just tried and failed to reuse lookahead token after an error, discard it. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004830
Chris Lattner0fab59c2007-01-12 18:33:30 +00004831 /* return failure if at end of input */
4832 if (yychar == YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004833 YYABORT;
4834
Chris Lattner0fab59c2007-01-12 18:33:30 +00004835#if YYDEBUG != 0
4836 if (yydebug)
4837 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
4838#endif
Reid Spencere4d87aa2006-12-23 06:05:41 +00004839
Chris Lattner0fab59c2007-01-12 18:33:30 +00004840 yychar = YYEMPTY;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004841 }
4842
Chris Lattner0fab59c2007-01-12 18:33:30 +00004843 /* Else will try to reuse lookahead token
4844 after shifting the error token. */
4845
4846 yyerrstatus = 3; /* Each real token shifted decrements this */
4847
4848 goto yyerrhandle;
4849
4850yyerrdefault: /* current state does not do anything special for the error token. */
4851
4852#if 0
4853 /* This is wrong; only states that explicitly want error tokens
4854 should shift them. */
4855 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
4856 if (yyn) goto yydefault;
4857#endif
4858
4859yyerrpop: /* pop the current state because it cannot handle the error token */
4860
4861 if (yyssp == yyss) YYABORT;
4862 yyvsp--;
4863 yystate = *--yyssp;
4864#ifdef YYLSP_NEEDED
4865 yylsp--;
4866#endif
4867
4868#if YYDEBUG != 0
4869 if (yydebug)
4870 {
4871 short *ssp1 = yyss - 1;
4872 fprintf (stderr, "Error: state stack now");
4873 while (ssp1 != yyssp)
4874 fprintf (stderr, " %d", *++ssp1);
4875 fprintf (stderr, "\n");
4876 }
4877#endif
4878
4879yyerrhandle:
4880
4881 yyn = yypact[yystate];
4882 if (yyn == YYFLAG)
4883 goto yyerrdefault;
4884
4885 yyn += YYTERROR;
4886 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
4887 goto yyerrdefault;
4888
4889 yyn = yytable[yyn];
4890 if (yyn < 0)
4891 {
4892 if (yyn == YYFLAG)
4893 goto yyerrpop;
4894 yyn = -yyn;
4895 goto yyreduce;
4896 }
4897 else if (yyn == 0)
4898 goto yyerrpop;
4899
Reid Spencer68a24bd2005-08-27 18:50:39 +00004900 if (yyn == YYFINAL)
4901 YYACCEPT;
4902
Chris Lattner0fab59c2007-01-12 18:33:30 +00004903#if YYDEBUG != 0
4904 if (yydebug)
4905 fprintf(stderr, "Shifting error token, ");
4906#endif
4907
Reid Spencer68a24bd2005-08-27 18:50:39 +00004908 *++yyvsp = yylval;
Chris Lattner0fab59c2007-01-12 18:33:30 +00004909#ifdef YYLSP_NEEDED
4910 *++yylsp = yylloc;
4911#endif
Reid Spencere4d87aa2006-12-23 06:05:41 +00004912
Reid Spencer68a24bd2005-08-27 18:50:39 +00004913 yystate = yyn;
4914 goto yynewstate;
4915
Chris Lattner0fab59c2007-01-12 18:33:30 +00004916 yyacceptlab:
4917 /* YYACCEPT comes here. */
4918 if (yyfree_stacks)
Reid Spencere4d87aa2006-12-23 06:05:41 +00004919 {
Chris Lattner0fab59c2007-01-12 18:33:30 +00004920 free (yyss);
4921 free (yyvs);
4922#ifdef YYLSP_NEEDED
4923 free (yyls);
Reid Spencer3822ff52006-11-08 06:47:33 +00004924#endif
Chris Lattner0fab59c2007-01-12 18:33:30 +00004925 }
4926 return 0;
4927
4928 yyabortlab:
4929 /* YYABORT comes here. */
4930 if (yyfree_stacks)
4931 {
4932 free (yyss);
4933 free (yyvs);
4934#ifdef YYLSP_NEEDED
4935 free (yyls);
4936#endif
4937 }
4938 return 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004939}
Chris Lattner0fab59c2007-01-12 18:33:30 +00004940#line 2849 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004941
4942
Reid Spencer14310612006-12-31 05:40:51 +00004943// common code from the two 'RunVMAsmParser' functions
4944static Module* RunParser(Module * M) {
4945
4946 llvmAsmlineno = 1; // Reset the current line number...
4947 CurModule.CurrentModule = M;
4948#if YYDEBUG
4949 yydebug = Debug;
4950#endif
4951
4952 // Check to make sure the parser succeeded
4953 if (yyparse()) {
4954 if (ParserResult)
4955 delete ParserResult;
4956 return 0;
4957 }
4958
4959 // Check to make sure that parsing produced a result
4960 if (!ParserResult)
4961 return 0;
4962
4963 // Reset ParserResult variable while saving its value for the result.
4964 Module *Result = ParserResult;
4965 ParserResult = 0;
4966
4967 return Result;
4968}
4969
Reid Spencer61c83e02006-08-18 08:43:06 +00004970void llvm::GenerateError(const std::string &message, int LineNo) {
4971 if (LineNo == -1) LineNo = llvmAsmlineno;
4972 // TODO: column number in exception
4973 if (TheParseError)
4974 TheParseError->setError(CurFilename, message, LineNo);
4975 TriggerError = 1;
4976}
Reid Spencer68a24bd2005-08-27 18:50:39 +00004977
4978int yyerror(const char *ErrorMsg) {
4979 std::string where
4980 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
4981 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
4982 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
4983 if (yychar == YYEMPTY || yychar == 0)
4984 errMsg += "end-of-file.";
4985 else
4986 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
Reid Spencer61c83e02006-08-18 08:43:06 +00004987 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004988 return 0;
4989}