blob: 111cfabe89268dc4f8f1b2a46bdae68e1c55b8fa [file] [log] [blame]
Reid Spencer68a24bd2005-08-27 18:50:39 +00001
Chris Lattner569f7372007-09-10 23:24:14 +00002/* A Bison parser, made from /Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y
Dale Johannesencdd509a2007-09-07 21:07:57 +00003 by GNU Bison version 1.28 */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004
Dale Johannesencdd509a2007-09-07 21:07:57 +00005#define YYBISON 1 /* Identify Bison output. */
Anton Korobeynikov178a3522007-01-12 19:22:51 +00006
Reid Spencer68a24bd2005-08-27 18:50:39 +00007#define yyparse llvmAsmparse
Dale Johannesencdd509a2007-09-07 21:07:57 +00008#define yylex llvmAsmlex
Reid Spencer68a24bd2005-08-27 18:50:39 +00009#define yyerror llvmAsmerror
Dale Johannesencdd509a2007-09-07 21:07:57 +000010#define yylval llvmAsmlval
11#define yychar llvmAsmchar
Reid Spencer68a24bd2005-08-27 18:50:39 +000012#define yydebug llvmAsmdebug
13#define yynerrs llvmAsmnerrs
Dale Johannesencdd509a2007-09-07 21:07:57 +000014#define ESINT64VAL 257
15#define EUINT64VAL 258
16#define ESAPINTVAL 259
17#define EUAPINTVAL 260
18#define LOCALVAL_ID 261
19#define GLOBALVAL_ID 262
20#define FPVAL 263
21#define VOID 264
22#define INTTYPE 265
23#define FLOAT 266
24#define DOUBLE 267
25#define X86_FP80 268
26#define FP128 269
27#define PPC_FP128 270
28#define LABEL 271
29#define TYPE 272
30#define LOCALVAR 273
31#define GLOBALVAR 274
32#define LABELSTR 275
33#define STRINGCONSTANT 276
34#define ATSTRINGCONSTANT 277
35#define PCTSTRINGCONSTANT 278
36#define ZEROINITIALIZER 279
37#define TRUETOK 280
38#define FALSETOK 281
39#define BEGINTOK 282
40#define ENDTOK 283
41#define DECLARE 284
42#define DEFINE 285
43#define GLOBAL 286
44#define CONSTANT 287
45#define SECTION 288
46#define ALIAS 289
47#define VOLATILE 290
48#define THREAD_LOCAL 291
49#define TO 292
50#define DOTDOTDOT 293
51#define NULL_TOK 294
52#define UNDEF 295
53#define INTERNAL 296
54#define LINKONCE 297
55#define WEAK 298
56#define APPENDING 299
57#define DLLIMPORT 300
58#define DLLEXPORT 301
59#define EXTERN_WEAK 302
60#define OPAQUE 303
61#define EXTERNAL 304
62#define TARGET 305
63#define TRIPLE 306
64#define ALIGN 307
65#define DEPLIBS 308
66#define CALL 309
67#define TAIL 310
68#define ASM_TOK 311
69#define MODULE 312
70#define SIDEEFFECT 313
71#define CC_TOK 314
72#define CCC_TOK 315
73#define FASTCC_TOK 316
74#define COLDCC_TOK 317
75#define X86_STDCALLCC_TOK 318
76#define X86_FASTCALLCC_TOK 319
77#define DATALAYOUT 320
78#define RET 321
79#define BR 322
80#define SWITCH 323
81#define INVOKE 324
82#define UNWIND 325
83#define UNREACHABLE 326
84#define ADD 327
85#define SUB 328
86#define MUL 329
87#define UDIV 330
88#define SDIV 331
89#define FDIV 332
90#define UREM 333
91#define SREM 334
92#define FREM 335
93#define AND 336
94#define OR 337
95#define XOR 338
96#define SHL 339
97#define LSHR 340
98#define ASHR 341
99#define ICMP 342
100#define FCMP 343
101#define EQ 344
102#define NE 345
103#define SLT 346
104#define SGT 347
105#define SLE 348
106#define SGE 349
107#define ULT 350
108#define UGT 351
109#define ULE 352
110#define UGE 353
111#define OEQ 354
112#define ONE 355
113#define OLT 356
114#define OGT 357
115#define OLE 358
116#define OGE 359
117#define ORD 360
118#define UNO 361
119#define UEQ 362
120#define UNE 363
121#define MALLOC 364
122#define ALLOCA 365
123#define FREE 366
124#define LOAD 367
125#define STORE 368
126#define GETELEMENTPTR 369
127#define TRUNC 370
128#define ZEXT 371
129#define SEXT 372
130#define FPTRUNC 373
131#define FPEXT 374
132#define BITCAST 375
133#define UITOFP 376
134#define SITOFP 377
135#define FPTOUI 378
136#define FPTOSI 379
137#define INTTOPTR 380
138#define PTRTOINT 381
139#define PHI_TOK 382
140#define SELECT 383
141#define VAARG 384
142#define EXTRACTELEMENT 385
143#define INSERTELEMENT 386
144#define SHUFFLEVECTOR 387
145#define SIGNEXT 388
146#define ZEROEXT 389
147#define NORETURN 390
148#define INREG 391
149#define SRET 392
150#define NOUNWIND 393
151#define NOALIAS 394
152#define BYVAL 395
153#define NEST 396
154#define DEFAULT 397
155#define HIDDEN 398
156#define PROTECTED 399
Reid Spencer68a24bd2005-08-27 18:50:39 +0000157
Chris Lattner569f7372007-09-10 23:24:14 +0000158#line 14 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000159
160#include "ParserInternals.h"
161#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000162#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000163#include "llvm/Instructions.h"
164#include "llvm/Module.h"
Reid Spenceref9b9a72007-02-05 20:47:22 +0000165#include "llvm/ValueSymbolTable.h"
Chandler Carruth02202192007-08-04 01:56:21 +0000166#include "llvm/AutoUpgrade.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000167#include "llvm/Support/GetElementPtrTypeIterator.h"
Reid Spencer14310612006-12-31 05:40:51 +0000168#include "llvm/Support/CommandLine.h"
Chris Lattnerf7469af2007-01-31 04:44:08 +0000169#include "llvm/ADT/SmallVector.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000170#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000171#include "llvm/Support/MathExtras.h"
Reid Spencer481169e2006-12-01 00:33:46 +0000172#include "llvm/Support/Streams.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000173#include <algorithm>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000174#include <list>
Chris Lattner8adde282007-02-11 21:40:10 +0000175#include <map>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000176#include <utility>
Reid Spencer14310612006-12-31 05:40:51 +0000177#ifndef NDEBUG
178#define YYDEBUG 1
179#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000180
Reid Spencere4f47592006-08-18 17:32:55 +0000181// The following is a gross hack. In order to rid the libAsmParser library of
182// exceptions, we have to have a way of getting the yyparse function to go into
183// an error situation. So, whenever we want an error to occur, the GenerateError
184// function (see bottom of file) sets TriggerError. Then, at the end of each
185// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
186// (a goto) to put YACC in error state. Furthermore, several calls to
187// GenerateError are made from inside productions and they must simulate the
188// previous exception behavior by exiting the production immediately. We have
189// replaced these with the GEN_ERROR macro which calls GeneratError and then
190// immediately invokes YYERROR. This would be so much cleaner if it was a
191// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000192static bool TriggerError = false;
Reid Spencerf63697d2006-10-09 17:36:59 +0000193#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000194#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
195
Reid Spencer68a24bd2005-08-27 18:50:39 +0000196int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
197int yylex(); // declaration" of xxx warnings.
198int yyparse();
199
200namespace llvm {
201 std::string CurFilename;
Reid Spencer14310612006-12-31 05:40:51 +0000202#if YYDEBUG
203static cl::opt<bool>
204Debug("debug-yacc", cl::desc("Print yacc debug state changes"),
205 cl::Hidden, cl::init(false));
206#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000207}
208using namespace llvm;
209
210static Module *ParserResult;
211
212// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
213// relating to upreferences in the input stream.
214//
215//#define DEBUG_UPREFS 1
216#ifdef DEBUG_UPREFS
Bill Wendlinge8156192006-12-07 01:30:32 +0000217#define UR_OUT(X) cerr << X
Reid Spencer68a24bd2005-08-27 18:50:39 +0000218#else
219#define UR_OUT(X)
220#endif
221
222#define YYERROR_VERBOSE 1
223
Chris Lattnerb475c422005-11-12 18:22:38 +0000224static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000225
226
227// This contains info used when building the body of a function. It is
228// destroyed when the function is completed.
229//
230typedef std::vector<Value *> ValueList; // Numbered defs
Reid Spencer14310612006-12-31 05:40:51 +0000231
Reid Spencer68a24bd2005-08-27 18:50:39 +0000232static void
Reid Spencer93c40032007-03-19 18:40:50 +0000233ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000234
235static struct PerModuleInfo {
236 Module *CurrentModule;
Reid Spencer93c40032007-03-19 18:40:50 +0000237 ValueList Values; // Module level numbered definitions
238 ValueList LateResolveValues;
Reid Spencer861d9d62006-11-28 07:29:44 +0000239 std::vector<PATypeHolder> Types;
240 std::map<ValID, PATypeHolder> LateResolveTypes;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000241
242 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000243 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000244 /// that we can resolve them later and print error messages as appropriate.
245 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
246
247 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
248 // references to global values. Global values may be referenced before they
249 // are defined, and if so, the temporary object that they represent is held
250 // here. This is used for forward references of GlobalValues.
251 //
252 typedef std::map<std::pair<const PointerType *,
253 ValID>, GlobalValue*> GlobalRefsType;
254 GlobalRefsType GlobalRefs;
255
256 void ModuleDone() {
257 // If we could not resolve some functions at function compilation time
258 // (calls to functions before they are defined), resolve them now... Types
259 // are resolved when the constant pool has been completely parsed.
260 //
261 ResolveDefinitions(LateResolveValues);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000262 if (TriggerError)
263 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000264
265 // Check to make sure that all global value forward references have been
266 // resolved!
267 //
268 if (!GlobalRefs.empty()) {
269 std::string UndefinedReferences = "Unresolved global references exist:\n";
270
271 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
272 I != E; ++I) {
273 UndefinedReferences += " " + I->first.first->getDescription() + " " +
274 I->first.second.getName() + "\n";
275 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000276 GenerateError(UndefinedReferences);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000277 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000278 }
279
Chandler Carruth02202192007-08-04 01:56:21 +0000280 // Look for intrinsic functions and CallInst that need to be upgraded
281 for (Module::iterator FI = CurrentModule->begin(),
282 FE = CurrentModule->end(); FI != FE; )
283 UpgradeCallsToIntrinsic(FI++); // must be post-increment, as we remove
284
Reid Spencer68a24bd2005-08-27 18:50:39 +0000285 Values.clear(); // Clear out function local definitions
286 Types.clear();
287 CurrentModule = 0;
288 }
289
Reid Spencer68a24bd2005-08-27 18:50:39 +0000290 // GetForwardRefForGlobal - Check to see if there is a forward reference
291 // for this global. If so, remove it from the GlobalRefs map and return it.
292 // If not, just return null.
293 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
294 // Check to see if there is a forward reference to this global variable...
295 // if there is, eliminate it and patch the reference to use the new def'n.
296 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
297 GlobalValue *Ret = 0;
298 if (I != GlobalRefs.end()) {
299 Ret = I->second;
300 GlobalRefs.erase(I);
301 }
302 return Ret;
303 }
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000304
305 bool TypeIsUnresolved(PATypeHolder* PATy) {
306 // If it isn't abstract, its resolved
307 const Type* Ty = PATy->get();
308 if (!Ty->isAbstract())
309 return false;
310 // Traverse the type looking for abstract types. If it isn't abstract then
311 // we don't need to traverse that leg of the type.
312 std::vector<const Type*> WorkList, SeenList;
313 WorkList.push_back(Ty);
314 while (!WorkList.empty()) {
315 const Type* Ty = WorkList.back();
316 SeenList.push_back(Ty);
317 WorkList.pop_back();
318 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
319 // Check to see if this is an unresolved type
320 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
321 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
322 for ( ; I != E; ++I) {
323 if (I->second.get() == OpTy)
324 return true;
325 }
326 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
327 const Type* TheTy = SeqTy->getElementType();
328 if (TheTy->isAbstract() && TheTy != Ty) {
329 std::vector<const Type*>::iterator I = SeenList.begin(),
330 E = SeenList.end();
331 for ( ; I != E; ++I)
332 if (*I == TheTy)
333 break;
334 if (I == E)
335 WorkList.push_back(TheTy);
336 }
337 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
338 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
339 const Type* TheTy = StrTy->getElementType(i);
340 if (TheTy->isAbstract() && TheTy != Ty) {
341 std::vector<const Type*>::iterator I = SeenList.begin(),
342 E = SeenList.end();
343 for ( ; I != E; ++I)
344 if (*I == TheTy)
345 break;
346 if (I == E)
347 WorkList.push_back(TheTy);
348 }
349 }
350 }
351 }
352 return false;
353 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000354} CurModule;
355
356static struct PerFunctionInfo {
357 Function *CurrentFunction; // Pointer to current function being created
358
Reid Spencer93c40032007-03-19 18:40:50 +0000359 ValueList Values; // Keep track of #'d definitions
360 unsigned NextValNum;
361 ValueList LateResolveValues;
Reid Spenceref9b9a72007-02-05 20:47:22 +0000362 bool isDeclare; // Is this function a forward declararation?
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000363 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000364 GlobalValue::VisibilityTypes Visibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000365
366 /// BBForwardRefs - When we see forward references to basic blocks, keep
367 /// track of them here.
Reid Spencer93c40032007-03-19 18:40:50 +0000368 std::map<ValID, BasicBlock*> BBForwardRefs;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000369
370 inline PerFunctionInfo() {
371 CurrentFunction = 0;
372 isDeclare = false;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000373 Linkage = GlobalValue::ExternalLinkage;
374 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000375 }
376
377 inline void FunctionStart(Function *M) {
378 CurrentFunction = M;
Reid Spencer93c40032007-03-19 18:40:50 +0000379 NextValNum = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000380 }
381
382 void FunctionDone() {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000383 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000384 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000385 GenerateError("Undefined reference to label " +
Reid Spencer93c40032007-03-19 18:40:50 +0000386 BBForwardRefs.begin()->second->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000387 return;
388 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000389
390 // Resolve all forward references now.
391 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
392
393 Values.clear(); // Clear out function local definitions
Reid Spencer93c40032007-03-19 18:40:50 +0000394 BBForwardRefs.clear();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000395 CurrentFunction = 0;
396 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000397 Linkage = GlobalValue::ExternalLinkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000398 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000399 }
400} CurFun; // Info for the current function...
401
402static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
403
404
405//===----------------------------------------------------------------------===//
406// Code to handle definitions of all the types
407//===----------------------------------------------------------------------===//
408
Reid Spencer93c40032007-03-19 18:40:50 +0000409static void InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) {
410 // Things that have names or are void typed don't get slot numbers
411 if (V->hasName() || (V->getType() == Type::VoidTy))
412 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000413
Reid Spencer93c40032007-03-19 18:40:50 +0000414 // In the case of function values, we have to allow for the forward reference
415 // of basic blocks, which are included in the numbering. Consequently, we keep
416 // track of the next insertion location with NextValNum. When a BB gets
417 // inserted, it could change the size of the CurFun.Values vector.
418 if (&ValueTab == &CurFun.Values) {
419 if (ValueTab.size() <= CurFun.NextValNum)
420 ValueTab.resize(CurFun.NextValNum+1);
421 ValueTab[CurFun.NextValNum++] = V;
422 return;
423 }
424 // For all other lists, its okay to just tack it on the back of the vector.
425 ValueTab.push_back(V);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000426}
427
428static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
429 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000430 case ValID::LocalID: // Is it a numbered definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000431 // Module constants occupy the lowest numbered slots...
Reid Spencer41dff5e2007-01-26 08:05:27 +0000432 if (D.Num < CurModule.Types.size())
433 return CurModule.Types[D.Num];
Reid Spencer68a24bd2005-08-27 18:50:39 +0000434 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000435 case ValID::LocalName: // Is it a named definition?
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000436 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.getName())) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000437 D.destroy(); // Free old strdup'd memory...
438 return N;
439 }
440 break;
441 default:
Reid Spencerb5334b02007-02-05 10:18:06 +0000442 GenerateError("Internal parser error: Invalid symbol type reference");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000443 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000444 }
445
446 // If we reached here, we referenced either a symbol that we don't know about
447 // or an id number that hasn't been read yet. We may be referencing something
448 // forward, so just create an entry to be resolved later and get to it...
449 //
450 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
451
452
453 if (inFunctionScope()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000454 if (D.Type == ValID::LocalName) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000455 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000456 return 0;
457 } else {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000458 GenerateError("Reference to an undefined type: #" + utostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000459 return 0;
460 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000461 }
462
Reid Spencer861d9d62006-11-28 07:29:44 +0000463 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000464 if (I != CurModule.LateResolveTypes.end())
Reid Spencer861d9d62006-11-28 07:29:44 +0000465 return I->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000466
Reid Spencer861d9d62006-11-28 07:29:44 +0000467 Type *Typ = OpaqueType::get();
468 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
469 return Typ;
Reid Spencera132e042006-12-03 05:46:11 +0000470 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000471
Reid Spencer93c40032007-03-19 18:40:50 +0000472// getExistingVal - Look up the value specified by the provided type and
Reid Spencer68a24bd2005-08-27 18:50:39 +0000473// the provided ValID. If the value exists and has already been defined, return
474// it. Otherwise return null.
475//
Reid Spencer93c40032007-03-19 18:40:50 +0000476static Value *getExistingVal(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000477 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000478 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000479 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000480 return 0;
481 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000482
483 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000484 case ValID::LocalID: { // Is it a numbered definition?
Reid Spencer41dff5e2007-01-26 08:05:27 +0000485 // Check that the number is within bounds.
Reid Spencer93c40032007-03-19 18:40:50 +0000486 if (D.Num >= CurFun.Values.size())
487 return 0;
488 Value *Result = CurFun.Values[D.Num];
489 if (Ty != Result->getType()) {
490 GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" +
491 Result->getType()->getDescription() + "' does not match "
492 "expected type, '" + Ty->getDescription() + "'");
493 return 0;
494 }
495 return Result;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000496 }
497 case ValID::GlobalID: { // Is it a numbered definition?
Reid Spencer93c40032007-03-19 18:40:50 +0000498 if (D.Num >= CurModule.Values.size())
Reid Spenceref9b9a72007-02-05 20:47:22 +0000499 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000500 Value *Result = CurModule.Values[D.Num];
501 if (Ty != Result->getType()) {
502 GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" +
503 Result->getType()->getDescription() + "' does not match "
504 "expected type, '" + Ty->getDescription() + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +0000505 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000506 }
507 return Result;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000508 }
Reid Spencer41dff5e2007-01-26 08:05:27 +0000509
510 case ValID::LocalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000511 if (!inFunctionScope())
512 return 0;
513 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000514 Value *N = SymTab.lookup(D.getName());
Reid Spenceref9b9a72007-02-05 20:47:22 +0000515 if (N == 0)
516 return 0;
517 if (N->getType() != Ty)
518 return 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000519
520 D.destroy(); // Free old strdup'd memory...
521 return N;
522 }
523 case ValID::GlobalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000524 ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000525 Value *N = SymTab.lookup(D.getName());
Reid Spenceref9b9a72007-02-05 20:47:22 +0000526 if (N == 0)
527 return 0;
528 if (N->getType() != Ty)
529 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000530
531 D.destroy(); // Free old strdup'd memory...
532 return N;
533 }
534
535 // Check to make sure that "Ty" is an integral type, and that our
536 // value will fit into the specified type...
537 case ValID::ConstSIntVal: // Is it a constant pool reference??
Reid Spencerb83eb642006-10-20 07:07:24 +0000538 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000539 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000540 itostr(D.ConstPool64) + "' is invalid for type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000541 Ty->getDescription() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000542 return 0;
543 }
Reid Spencer49d273e2007-03-19 20:40:51 +0000544 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000545
546 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Reid Spencerb83eb642006-10-20 07:07:24 +0000547 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
548 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000549 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
Reid Spencerb5334b02007-02-05 10:18:06 +0000550 "' is invalid or out of range");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000551 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000552 } else { // This is really a signed reference. Transmogrify.
Reid Spencer49d273e2007-03-19 20:40:51 +0000553 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000554 }
555 } else {
Reid Spencerb83eb642006-10-20 07:07:24 +0000556 return ConstantInt::get(Ty, D.UConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000557 }
558
559 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Dale Johannesencdd509a2007-09-07 21:07:57 +0000560 if (!ConstantFP::isValueValidForType(Ty, *D.ConstPoolFP)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000561 GenerateError("FP constant invalid for type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000562 return 0;
563 }
Dale Johannesencdd509a2007-09-07 21:07:57 +0000564 // Lexer has no type info, so builds all FP constants as double.
565 // Fix this here.
566 if (Ty==Type::FloatTy)
567 D.ConstPoolFP->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
568 return ConstantFP::get(Ty, *D.ConstPoolFP);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000569
570 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000571 if (!isa<PointerType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000572 GenerateError("Cannot create a a non pointer null");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000573 return 0;
574 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000575 return ConstantPointerNull::get(cast<PointerType>(Ty));
576
577 case ValID::ConstUndefVal: // Is it an undef value?
578 return UndefValue::get(Ty);
579
Chris Lattner7aa61892005-12-21 17:53:23 +0000580 case ValID::ConstZeroVal: // Is it a zero value?
581 return Constant::getNullValue(Ty);
582
Reid Spencer68a24bd2005-08-27 18:50:39 +0000583 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000584 if (D.ConstantValue->getType() != Ty) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000585 GenerateError("Constant expression type different from required type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000586 return 0;
587 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000588 return D.ConstantValue;
589
Chris Lattner0e9c3762006-01-25 22:27:16 +0000590 case ValID::InlineAsmVal: { // Inline asm expression
591 const PointerType *PTy = dyn_cast<PointerType>(Ty);
592 const FunctionType *FTy =
593 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000594 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000595 GenerateError("Invalid type for asm constraint string");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000596 return 0;
597 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000598 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
599 D.IAD->HasSideEffects);
600 D.destroy(); // Free InlineAsmDescriptor.
601 return IA;
602 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000603 default:
Reid Spencera9720f52007-02-05 17:04:00 +0000604 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000605 return 0;
606 } // End of switch
607
Reid Spencera9720f52007-02-05 17:04:00 +0000608 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000609 return 0;
610}
611
Reid Spencer93c40032007-03-19 18:40:50 +0000612// getVal - This function is identical to getExistingVal, except that if a
Reid Spencer68a24bd2005-08-27 18:50:39 +0000613// value is not already defined, it "improvises" by creating a placeholder var
614// that looks and acts just like the requested variable. When the value is
615// defined later, all uses of the placeholder variable are replaced with the
616// real thing.
617//
618static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000619 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000620 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000621 return 0;
622 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000623
624 // See if the value has already been defined.
Reid Spencer93c40032007-03-19 18:40:50 +0000625 Value *V = getExistingVal(Ty, ID);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000626 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000627 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000628
Reid Spencer5b7e7532006-09-28 19:28:24 +0000629 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000630 GenerateError("Invalid use of a composite type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000631 return 0;
632 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000633
634 // If we reached here, we referenced either a symbol that we don't know about
635 // or an id number that hasn't been read yet. We may be referencing something
636 // forward, so just create an entry to be resolved later and get to it...
637 //
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000638 switch (ID.Type) {
639 case ValID::GlobalName:
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000640 case ValID::GlobalID: {
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000641 const PointerType *PTy = dyn_cast<PointerType>(Ty);
642 if (!PTy) {
643 GenerateError("Invalid type for reference to global" );
644 return 0;
645 }
646 const Type* ElTy = PTy->getElementType();
647 if (const FunctionType *FTy = dyn_cast<FunctionType>(ElTy))
648 V = new Function(FTy, GlobalValue::ExternalLinkage);
649 else
650 V = new GlobalVariable(ElTy, false, GlobalValue::ExternalLinkage);
651 break;
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000652 }
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000653 default:
654 V = new Argument(Ty);
655 }
656
Reid Spencer68a24bd2005-08-27 18:50:39 +0000657 // Remember where this forward reference came from. FIXME, shouldn't we try
658 // to recycle these things??
659 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
660 llvmAsmlineno)));
661
662 if (inFunctionScope())
663 InsertValue(V, CurFun.LateResolveValues);
664 else
665 InsertValue(V, CurModule.LateResolveValues);
666 return V;
667}
668
Reid Spencer93c40032007-03-19 18:40:50 +0000669/// defineBBVal - This is a definition of a new basic block with the specified
670/// identifier which must be the same as CurFun.NextValNum, if its numeric.
671static BasicBlock *defineBBVal(const ValID &ID) {
Reid Spencera9720f52007-02-05 17:04:00 +0000672 assert(inFunctionScope() && "Can't get basic block at global scope!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000673
Reid Spencer68a24bd2005-08-27 18:50:39 +0000674 BasicBlock *BB = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000675
Reid Spencer93c40032007-03-19 18:40:50 +0000676 // First, see if this was forward referenced
Reid Spencer68a24bd2005-08-27 18:50:39 +0000677
Reid Spencer93c40032007-03-19 18:40:50 +0000678 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
679 if (BBI != CurFun.BBForwardRefs.end()) {
680 BB = BBI->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000681 // The forward declaration could have been inserted anywhere in the
682 // function: insert it into the correct place now.
683 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
684 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
Reid Spencer93c40032007-03-19 18:40:50 +0000685
Reid Spencer66728ef2007-03-20 01:13:36 +0000686 // We're about to erase the entry, save the key so we can clean it up.
687 ValID Tmp = BBI->first;
688
Reid Spencer93c40032007-03-19 18:40:50 +0000689 // Erase the forward ref from the map as its no longer "forward"
690 CurFun.BBForwardRefs.erase(ID);
691
Reid Spencer66728ef2007-03-20 01:13:36 +0000692 // The key has been removed from the map but so we don't want to leave
693 // strdup'd memory around so destroy it too.
694 Tmp.destroy();
695
Reid Spencer93c40032007-03-19 18:40:50 +0000696 // If its a numbered definition, bump the number and set the BB value.
697 if (ID.Type == ValID::LocalID) {
698 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
699 InsertValue(BB);
700 }
701
702 ID.destroy();
703 return BB;
704 }
705
706 // We haven't seen this BB before and its first mention is a definition.
707 // Just create it and return it.
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000708 std::string Name (ID.Type == ValID::LocalName ? ID.getName() : "");
Reid Spencer93c40032007-03-19 18:40:50 +0000709 BB = new BasicBlock(Name, CurFun.CurrentFunction);
710 if (ID.Type == ValID::LocalID) {
711 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
712 InsertValue(BB);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000713 }
Reid Spencer93c40032007-03-19 18:40:50 +0000714
715 ID.destroy(); // Free strdup'd memory
716 return BB;
717}
718
719/// getBBVal - get an existing BB value or create a forward reference for it.
720///
721static BasicBlock *getBBVal(const ValID &ID) {
722 assert(inFunctionScope() && "Can't get basic block at global scope!");
723
724 BasicBlock *BB = 0;
725
726 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
727 if (BBI != CurFun.BBForwardRefs.end()) {
728 BB = BBI->second;
729 } if (ID.Type == ValID::LocalName) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000730 std::string Name = ID.getName();
Reid Spencer93c40032007-03-19 18:40:50 +0000731 Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
732 if (N)
733 if (N->getType()->getTypeID() == Type::LabelTyID)
734 BB = cast<BasicBlock>(N);
735 else
736 GenerateError("Reference to label '" + Name + "' is actually of type '"+
737 N->getType()->getDescription() + "'");
738 } else if (ID.Type == ValID::LocalID) {
739 if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) {
740 if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID)
741 BB = cast<BasicBlock>(CurFun.Values[ID.Num]);
742 else
743 GenerateError("Reference to label '%" + utostr(ID.Num) +
744 "' is actually of type '"+
745 CurFun.Values[ID.Num]->getType()->getDescription() + "'");
746 }
747 } else {
748 GenerateError("Illegal label reference " + ID.getName());
749 return 0;
750 }
751
752 // If its already been defined, return it now.
753 if (BB) {
754 ID.destroy(); // Free strdup'd memory.
755 return BB;
756 }
757
758 // Otherwise, this block has not been seen before, create it.
759 std::string Name;
760 if (ID.Type == ValID::LocalName)
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000761 Name = ID.getName();
Reid Spencer93c40032007-03-19 18:40:50 +0000762 BB = new BasicBlock(Name, CurFun.CurrentFunction);
763
764 // Insert it in the forward refs map.
765 CurFun.BBForwardRefs[ID] = BB;
766
Reid Spencer68a24bd2005-08-27 18:50:39 +0000767 return BB;
768}
769
770
771//===----------------------------------------------------------------------===//
772// Code to handle forward references in instructions
773//===----------------------------------------------------------------------===//
774//
775// This code handles the late binding needed with statements that reference
776// values not defined yet... for example, a forward branch, or the PHI node for
777// a loop body.
778//
779// This keeps a table (CurFun.LateResolveValues) of all such forward references
780// and back patchs after we are done.
781//
782
783// ResolveDefinitions - If we could not resolve some defs at parsing
784// time (forward branches, phi functions for loops, etc...) resolve the
785// defs now...
786//
787static void
Reid Spencer93c40032007-03-19 18:40:50 +0000788ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000789 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
Reid Spencer93c40032007-03-19 18:40:50 +0000790 while (!LateResolvers.empty()) {
791 Value *V = LateResolvers.back();
792 LateResolvers.pop_back();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000793
Reid Spencer93c40032007-03-19 18:40:50 +0000794 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
795 CurModule.PlaceHolderInfo.find(V);
796 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000797
Reid Spencer93c40032007-03-19 18:40:50 +0000798 ValID &DID = PHI->second.first;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000799
Reid Spencer93c40032007-03-19 18:40:50 +0000800 Value *TheRealValue = getExistingVal(V->getType(), DID);
801 if (TriggerError)
802 return;
803 if (TheRealValue) {
804 V->replaceAllUsesWith(TheRealValue);
805 delete V;
806 CurModule.PlaceHolderInfo.erase(PHI);
807 } else if (FutureLateResolvers) {
808 // Functions have their unresolved items forwarded to the module late
809 // resolver table
810 InsertValue(V, *FutureLateResolvers);
811 } else {
812 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
813 GenerateError("Reference to an invalid definition: '" +DID.getName()+
814 "' of type '" + V->getType()->getDescription() + "'",
815 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000816 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000817 } else {
Reid Spencer93c40032007-03-19 18:40:50 +0000818 GenerateError("Reference to an invalid definition: #" +
819 itostr(DID.Num) + " of type '" +
820 V->getType()->getDescription() + "'",
821 PHI->second.second);
822 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000823 }
824 }
825 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000826 LateResolvers.clear();
827}
828
829// ResolveTypeTo - A brand new type was just declared. This means that (if
830// name is not null) things referencing Name can be resolved. Otherwise, things
831// refering to the number can be resolved. Do this now.
832//
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000833static void ResolveTypeTo(std::string *Name, const Type *ToTy) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000834 ValID D;
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000835 if (Name)
836 D = ValID::createLocalName(*Name);
837 else
838 D = ValID::createLocalID(CurModule.Types.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +0000839
Reid Spencer861d9d62006-11-28 07:29:44 +0000840 std::map<ValID, PATypeHolder>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +0000841 CurModule.LateResolveTypes.find(D);
842 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer861d9d62006-11-28 07:29:44 +0000843 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000844 CurModule.LateResolveTypes.erase(I);
845 }
846}
847
848// setValueName - Set the specified value to the name given. The name may be
849// null potentially, in which case this is a noop. The string passed in is
850// assumed to be a malloc'd string buffer, and is free'd by this function.
851//
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000852static void setValueName(Value *V, std::string *NameStr) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000853 if (!NameStr) return;
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000854 std::string Name(*NameStr); // Copy string
855 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +0000856
Reid Spencer41dff5e2007-01-26 08:05:27 +0000857 if (V->getType() == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000858 GenerateError("Can't assign name '" + Name+"' to value with void type");
Reid Spencer41dff5e2007-01-26 08:05:27 +0000859 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000860 }
Reid Spencer41dff5e2007-01-26 08:05:27 +0000861
Reid Spencera9720f52007-02-05 17:04:00 +0000862 assert(inFunctionScope() && "Must be in function scope!");
Reid Spenceref9b9a72007-02-05 20:47:22 +0000863 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
864 if (ST.lookup(Name)) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000865 GenerateError("Redefinition of value '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000866 V->getType()->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +0000867 return;
868 }
869
870 // Set the name.
871 V->setName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000872}
873
874/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
875/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +0000876static GlobalVariable *
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000877ParseGlobalVariable(std::string *NameStr,
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000878 GlobalValue::LinkageTypes Linkage,
879 GlobalValue::VisibilityTypes Visibility,
Chris Lattnerb475c422005-11-12 18:22:38 +0000880 bool isConstantGlobal, const Type *Ty,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +0000881 Constant *Initializer, bool IsThreadLocal) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000882 if (isa<FunctionType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000883 GenerateError("Cannot declare global vars of function type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000884 return 0;
885 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000886
887 const PointerType *PTy = PointerType::get(Ty);
888
889 std::string Name;
890 if (NameStr) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000891 Name = *NameStr; // Copy string
892 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +0000893 }
894
895 // See if this global value was forward referenced. If so, recycle the
896 // object.
897 ValID ID;
898 if (!Name.empty()) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000899 ID = ValID::createGlobalName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000900 } else {
Reid Spencer93c40032007-03-19 18:40:50 +0000901 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +0000902 }
903
904 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
905 // Move the global to the end of the list, from whereever it was
906 // previously inserted.
907 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
908 CurModule.CurrentModule->getGlobalList().remove(GV);
909 CurModule.CurrentModule->getGlobalList().push_back(GV);
910 GV->setInitializer(Initializer);
911 GV->setLinkage(Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000912 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000913 GV->setConstant(isConstantGlobal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +0000914 GV->setThreadLocal(IsThreadLocal);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000915 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000916 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000917 }
918
Reid Spenceref9b9a72007-02-05 20:47:22 +0000919 // If this global has a name
Reid Spencer68a24bd2005-08-27 18:50:39 +0000920 if (!Name.empty()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +0000921 // if the global we're parsing has an initializer (is a definition) and
922 // has external linkage.
923 if (Initializer && Linkage != GlobalValue::InternalLinkage)
924 // If there is already a global with external linkage with this name
925 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
926 // If we allow this GVar to get created, it will be renamed in the
927 // symbol table because it conflicts with an existing GVar. We can't
928 // allow redefinition of GVars whose linking indicates that their name
929 // must stay the same. Issue the error.
930 GenerateError("Redefinition of global variable named '" + Name +
931 "' of type '" + Ty->getDescription() + "'");
932 return 0;
933 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000934 }
935
936 // Otherwise there is no existing GV to use, create one now.
937 GlobalVariable *GV =
938 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +0000939 CurModule.CurrentModule, IsThreadLocal);
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000940 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000941 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000942 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000943}
944
945// setTypeName - Set the specified type to the name given. The name may be
946// null potentially, in which case this is a noop. The string passed in is
947// assumed to be a malloc'd string buffer, and is freed by this function.
948//
949// This function returns true if the type has already been defined, but is
950// allowed to be redefined in the specified context. If the name is a new name
951// for the type plane, it is inserted and false is returned.
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000952static bool setTypeName(const Type *T, std::string *NameStr) {
Reid Spencera9720f52007-02-05 17:04:00 +0000953 assert(!inFunctionScope() && "Can't give types function-local names!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000954 if (NameStr == 0) return false;
955
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000956 std::string Name(*NameStr); // Copy string
957 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +0000958
959 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +0000960 if (T == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000961 GenerateError("Can't assign name '" + Name + "' to the void type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000962 return false;
963 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000964
965 // Set the type name, checking for conflicts as we do so.
966 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
967
968 if (AlreadyExists) { // Inserting a name that is already defined???
969 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
Reid Spencera9720f52007-02-05 17:04:00 +0000970 assert(Existing && "Conflict but no matching type?!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000971
972 // There is only one case where this is allowed: when we are refining an
973 // opaque type. In this case, Existing will be an opaque type.
974 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
975 // We ARE replacing an opaque type!
976 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
977 return true;
978 }
979
980 // Otherwise, this is an attempt to redefine a type. That's okay if
981 // the redefinition is identical to the original. This will be so if
982 // Existing and T point to the same Type object. In this one case we
983 // allow the equivalent redefinition.
984 if (Existing == T) return true; // Yes, it's equal.
985
986 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer63c34452007-01-05 21:51:07 +0000987 GenerateError("Redefinition of type named '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000988 T->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000989 }
990
991 return false;
992}
993
994//===----------------------------------------------------------------------===//
995// Code for handling upreferences in type names...
996//
997
998// TypeContains - Returns true if Ty directly contains E in it.
999//
1000static bool TypeContains(const Type *Ty, const Type *E) {
1001 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1002 E) != Ty->subtype_end();
1003}
1004
1005namespace {
1006 struct UpRefRecord {
1007 // NestingLevel - The number of nesting levels that need to be popped before
1008 // this type is resolved.
1009 unsigned NestingLevel;
1010
1011 // LastContainedTy - This is the type at the current binding level for the
1012 // type. Every time we reduce the nesting level, this gets updated.
1013 const Type *LastContainedTy;
1014
1015 // UpRefTy - This is the actual opaque type that the upreference is
1016 // represented with.
1017 OpaqueType *UpRefTy;
1018
1019 UpRefRecord(unsigned NL, OpaqueType *URTy)
1020 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1021 };
1022}
1023
1024// UpRefs - A list of the outstanding upreferences that need to be resolved.
1025static std::vector<UpRefRecord> UpRefs;
1026
1027/// HandleUpRefs - Every time we finish a new layer of types, this function is
1028/// called. It loops through the UpRefs vector, which is a list of the
1029/// currently active types. For each type, if the up reference is contained in
1030/// the newly completed type, we decrement the level count. When the level
1031/// count reaches zero, the upreferenced type is the type that is passed in:
1032/// thus we can complete the cycle.
1033///
1034static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001035 // If Ty isn't abstract, or if there are no up-references in it, then there is
1036 // nothing to resolve here.
1037 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1038
Reid Spencer68a24bd2005-08-27 18:50:39 +00001039 PATypeHolder Ty(ty);
1040 UR_OUT("Type '" << Ty->getDescription() <<
1041 "' newly formed. Resolving upreferences.\n" <<
1042 UpRefs.size() << " upreferences active!\n");
1043
1044 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1045 // to zero), we resolve them all together before we resolve them to Ty. At
1046 // the end of the loop, if there is anything to resolve to Ty, it will be in
1047 // this variable.
1048 OpaqueType *TypeToResolve = 0;
1049
1050 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1051 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1052 << UpRefs[i].second->getDescription() << ") = "
1053 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1054 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1055 // Decrement level of upreference
1056 unsigned Level = --UpRefs[i].NestingLevel;
1057 UpRefs[i].LastContainedTy = Ty;
1058 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1059 if (Level == 0) { // Upreference should be resolved!
1060 if (!TypeToResolve) {
1061 TypeToResolve = UpRefs[i].UpRefTy;
1062 } else {
1063 UR_OUT(" * Resolving upreference for "
1064 << UpRefs[i].second->getDescription() << "\n";
1065 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1066 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1067 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1068 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1069 }
1070 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1071 --i; // Do not skip the next element...
1072 }
1073 }
1074 }
1075
1076 if (TypeToResolve) {
1077 UR_OUT(" * Resolving upreference for "
1078 << UpRefs[i].second->getDescription() << "\n";
1079 std::string OldName = TypeToResolve->getDescription());
1080 TypeToResolve->refineAbstractTypeTo(Ty);
1081 }
1082
1083 return Ty;
1084}
1085
Reid Spencer68a24bd2005-08-27 18:50:39 +00001086//===----------------------------------------------------------------------===//
1087// RunVMAsmParser - Define an interface to this parser
1088//===----------------------------------------------------------------------===//
1089//
Reid Spencer14310612006-12-31 05:40:51 +00001090static Module* RunParser(Module * M);
1091
Reid Spencer68a24bd2005-08-27 18:50:39 +00001092Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1093 set_scan_file(F);
1094
1095 CurFilename = Filename;
1096 return RunParser(new Module(CurFilename));
1097}
1098
1099Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1100 set_scan_string(AsmString);
1101
1102 CurFilename = "from_memory";
1103 if (M == NULL) {
1104 return RunParser(new Module (CurFilename));
1105 } else {
1106 return RunParser(M);
1107 }
1108}
1109
1110
Chris Lattner569f7372007-09-10 23:24:14 +00001111#line 967 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00001112typedef union {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001113 llvm::Module *ModuleVal;
1114 llvm::Function *FunctionVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001115 llvm::BasicBlock *BasicBlockVal;
1116 llvm::TerminatorInst *TermInstVal;
1117 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001118 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001119
Reid Spencera132e042006-12-03 05:46:11 +00001120 const llvm::Type *PrimType;
Reid Spencer14310612006-12-31 05:40:51 +00001121 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencera132e042006-12-03 05:46:11 +00001122 llvm::PATypeHolder *TypeVal;
1123 llvm::Value *ValueVal;
Reid Spencera132e042006-12-03 05:46:11 +00001124 std::vector<llvm::Value*> *ValueList;
Reid Spencer14310612006-12-31 05:40:51 +00001125 llvm::ArgListType *ArgList;
1126 llvm::TypeWithAttrs TypeWithAttrs;
1127 llvm::TypeWithAttrsList *TypeWithAttrsList;
1128 llvm::ValueRefList *ValueRefList;
1129
Reid Spencer68a24bd2005-08-27 18:50:39 +00001130 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001131 std::list<std::pair<llvm::Value*,
1132 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001133 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001134 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001135
1136 llvm::GlobalValue::LinkageTypes Linkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001137 llvm::GlobalValue::VisibilityTypes Visibility;
Reid Spencer7b5d4662007-04-09 06:16:21 +00001138 uint16_t ParamAttrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00001139 llvm::APInt *APIntVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001140 int64_t SInt64Val;
1141 uint64_t UInt64Val;
1142 int SIntVal;
1143 unsigned UIntVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00001144 llvm::APFloat *FPVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001145 bool BoolVal;
1146
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001147 std::string *StrVal; // This memory must be deleted
1148 llvm::ValID ValIDVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001149
Reid Spencera132e042006-12-03 05:46:11 +00001150 llvm::Instruction::BinaryOps BinaryOpVal;
1151 llvm::Instruction::TermOps TermOpVal;
1152 llvm::Instruction::MemoryOps MemOpVal;
1153 llvm::Instruction::CastOps CastOpVal;
1154 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencera132e042006-12-03 05:46:11 +00001155 llvm::ICmpInst::Predicate IPredicate;
1156 llvm::FCmpInst::Predicate FPredicate;
Chris Lattner0275cff2007-08-06 21:00:46 +00001157} YYSTYPE;
Dale Johannesencdd509a2007-09-07 21:07:57 +00001158#include <stdio.h>
1159
1160#ifndef __cplusplus
1161#ifndef __STDC__
1162#define const
1163#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001164#endif
1165
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001166
Reid Spencer68a24bd2005-08-27 18:50:39 +00001167
Dale Johannesencdd509a2007-09-07 21:07:57 +00001168#define YYFINAL 594
1169#define YYFLAG -32768
1170#define YYNTBASE 160
Reid Spencer68a24bd2005-08-27 18:50:39 +00001171
Dale Johannesencdd509a2007-09-07 21:07:57 +00001172#define YYTRANSLATE(x) ((unsigned)(x) <= 399 ? yytranslate[x] : 241)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001173
Dale Johannesencdd509a2007-09-07 21:07:57 +00001174static const short yytranslate[] = { 0,
1175 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1176 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1177 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1178 2, 2, 2, 2, 2, 2, 2, 2, 2, 150,
1179 151, 148, 2, 147, 2, 2, 2, 2, 2, 2,
1180 2, 2, 2, 2, 2, 2, 2, 2, 2, 155,
1181 146, 156, 2, 2, 2, 2, 2, 2, 2, 2,
1182 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1183 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1184 152, 149, 154, 2, 2, 2, 2, 2, 159, 2,
1185 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1186 2, 2, 2, 2, 2, 2, 2, 2, 2, 153,
1187 2, 2, 157, 2, 158, 2, 2, 2, 2, 2,
1188 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1189 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1190 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1191 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1192 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1193 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1194 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1195 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1196 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1197 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1198 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1199 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1200 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
1201 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1202 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1203 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
1204 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
1205 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
1206 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1207 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1208 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1209 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
1210 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
1211 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
1212 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
1213 127, 128, 129, 130, 131, 132, 133, 134, 135, 136,
1214 137, 138, 139, 140, 141, 142, 143, 144, 145
1215};
Reid Spencerb8f85052007-07-31 03:50:36 +00001216
Dale Johannesencdd509a2007-09-07 21:07:57 +00001217#if YYDEBUG != 0
1218static const short yyprhs[] = { 0,
1219 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
1220 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
1221 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
1222 60, 62, 64, 66, 68, 70, 72, 74, 76, 78,
1223 80, 82, 84, 86, 88, 90, 92, 94, 96, 98,
1224 100, 102, 104, 106, 108, 110, 112, 114, 116, 118,
1225 120, 122, 124, 126, 127, 130, 131, 133, 135, 137,
1226 138, 141, 143, 145, 147, 149, 151, 153, 155, 157,
1227 158, 160, 162, 164, 165, 167, 169, 170, 172, 174,
1228 176, 178, 179, 181, 183, 184, 186, 188, 190, 192,
1229 194, 197, 199, 201, 203, 205, 207, 209, 211, 213,
1230 215, 216, 219, 221, 223, 225, 227, 228, 231, 232,
1231 235, 236, 240, 243, 244, 246, 247, 251, 253, 256,
1232 258, 260, 262, 264, 266, 268, 270, 272, 274, 277,
1233 279, 282, 288, 294, 300, 306, 310, 313, 319, 324,
1234 327, 329, 331, 333, 337, 339, 343, 345, 346, 348,
1235 352, 357, 361, 365, 370, 375, 379, 386, 392, 395,
1236 398, 401, 404, 407, 410, 413, 416, 419, 422, 425,
1237 428, 435, 441, 450, 457, 464, 472, 480, 487, 496,
1238 505, 509, 511, 513, 515, 517, 518, 521, 528, 530,
1239 531, 533, 536, 537, 541, 542, 546, 550, 554, 558,
1240 559, 567, 568, 577, 578, 587, 593, 596, 600, 602,
1241 606, 610, 614, 618, 620, 621, 627, 631, 633, 637,
1242 639, 640, 650, 652, 654, 659, 661, 663, 666, 670,
1243 671, 673, 675, 677, 679, 681, 683, 685, 687, 689,
1244 693, 695, 701, 703, 705, 707, 709, 711, 713, 716,
1245 719, 722, 726, 729, 730, 732, 735, 738, 742, 752,
1246 762, 771, 786, 788, 790, 797, 803, 806, 813, 821,
1247 825, 831, 832, 833, 837, 840, 842, 848, 854, 861,
1248 868, 873, 880, 885, 890, 897, 904, 907, 916, 918,
1249 920, 921, 925, 932, 936, 943, 946, 952, 960
1250};
Chris Lattner0275cff2007-08-06 21:00:46 +00001251
Dale Johannesencdd509a2007-09-07 21:07:57 +00001252static const short yyrhs[] = { 73,
1253 0, 74, 0, 75, 0, 76, 0, 77, 0, 78,
1254 0, 79, 0, 80, 0, 81, 0, 85, 0, 86,
1255 0, 87, 0, 82, 0, 83, 0, 84, 0, 116,
1256 0, 117, 0, 118, 0, 119, 0, 120, 0, 121,
1257 0, 122, 0, 123, 0, 124, 0, 125, 0, 126,
1258 0, 127, 0, 90, 0, 91, 0, 92, 0, 93,
1259 0, 94, 0, 95, 0, 96, 0, 97, 0, 98,
1260 0, 99, 0, 100, 0, 101, 0, 102, 0, 103,
1261 0, 104, 0, 105, 0, 106, 0, 107, 0, 108,
1262 0, 109, 0, 96, 0, 97, 0, 98, 0, 99,
1263 0, 26, 0, 27, 0, 11, 0, 12, 0, 13,
1264 0, 16, 0, 15, 0, 14, 0, 19, 0, 22,
1265 0, 24, 0, 167, 0, 0, 167, 146, 0, 0,
1266 20, 0, 23, 0, 172, 0, 0, 170, 146, 0,
1267 42, 0, 44, 0, 43, 0, 45, 0, 47, 0,
1268 46, 0, 48, 0, 50, 0, 0, 143, 0, 144,
1269 0, 145, 0, 0, 46, 0, 48, 0, 0, 42,
1270 0, 43, 0, 44, 0, 47, 0, 0, 44, 0,
1271 42, 0, 0, 61, 0, 62, 0, 63, 0, 64,
1272 0, 65, 0, 60, 4, 0, 135, 0, 117, 0,
1273 134, 0, 118, 0, 137, 0, 138, 0, 140, 0,
1274 141, 0, 142, 0, 0, 181, 180, 0, 136, 0,
1275 139, 0, 135, 0, 134, 0, 0, 183, 182, 0,
1276 0, 53, 4, 0, 0, 147, 53, 4, 0, 34,
1277 22, 0, 0, 186, 0, 0, 147, 189, 188, 0,
1278 186, 0, 53, 4, 0, 11, 0, 12, 0, 13,
1279 0, 16, 0, 15, 0, 14, 0, 17, 0, 49,
1280 0, 190, 0, 191, 148, 0, 225, 0, 149, 4,
1281 0, 191, 150, 195, 151, 183, 0, 10, 150, 195,
1282 151, 183, 0, 152, 4, 153, 191, 154, 0, 155,
1283 4, 153, 191, 156, 0, 157, 196, 158, 0, 157,
1284 158, 0, 155, 157, 196, 158, 156, 0, 155, 157,
1285 158, 156, 0, 191, 181, 0, 191, 0, 10, 0,
1286 192, 0, 194, 147, 192, 0, 194, 0, 194, 147,
1287 39, 0, 39, 0, 0, 191, 0, 196, 147, 191,
1288 0, 191, 152, 199, 154, 0, 191, 152, 154, 0,
1289 191, 159, 22, 0, 191, 155, 199, 156, 0, 191,
1290 157, 199, 158, 0, 191, 157, 158, 0, 191, 155,
1291 157, 199, 158, 156, 0, 191, 155, 157, 158, 156,
1292 0, 191, 40, 0, 191, 41, 0, 191, 225, 0,
1293 191, 198, 0, 191, 25, 0, 165, 3, 0, 165,
1294 5, 0, 165, 4, 0, 165, 6, 0, 11, 26,
1295 0, 11, 27, 0, 166, 9, 0, 162, 150, 197,
1296 38, 191, 151, 0, 115, 150, 197, 236, 151, 0,
1297 129, 150, 197, 147, 197, 147, 197, 151, 0, 160,
1298 150, 197, 147, 197, 151, 0, 161, 150, 197, 147,
1299 197, 151, 0, 88, 163, 150, 197, 147, 197, 151,
1300 0, 89, 164, 150, 197, 147, 197, 151, 0, 131,
1301 150, 197, 147, 197, 151, 0, 132, 150, 197, 147,
1302 197, 147, 197, 151, 0, 133, 150, 197, 147, 197,
1303 147, 197, 151, 0, 199, 147, 197, 0, 197, 0,
1304 32, 0, 33, 0, 37, 0, 0, 193, 225, 0,
1305 121, 150, 202, 38, 191, 151, 0, 204, 0, 0,
1306 205, 0, 204, 205, 0, 0, 31, 206, 221, 0,
1307 0, 30, 207, 222, 0, 58, 57, 211, 0, 169,
1308 18, 191, 0, 169, 18, 10, 0, 0, 171, 175,
1309 201, 200, 197, 208, 188, 0, 0, 171, 173, 175,
1310 201, 200, 197, 209, 188, 0, 0, 171, 174, 175,
1311 201, 200, 191, 210, 188, 0, 171, 175, 35, 178,
1312 202, 0, 51, 212, 0, 54, 146, 213, 0, 22,
1313 0, 52, 146, 22, 0, 66, 146, 22, 0, 152,
1314 214, 154, 0, 214, 147, 22, 0, 22, 0, 0,
1315 215, 147, 191, 181, 168, 0, 191, 181, 168, 0,
1316 215, 0, 215, 147, 39, 0, 39, 0, 0, 179,
1317 193, 170, 150, 216, 151, 183, 187, 184, 0, 28,
1318 0, 157, 0, 177, 175, 217, 218, 0, 29, 0,
1319 158, 0, 228, 220, 0, 176, 175, 217, 0, 0,
1320 59, 0, 3, 0, 4, 0, 9, 0, 26, 0,
1321 27, 0, 40, 0, 41, 0, 25, 0, 155, 199,
1322 156, 0, 198, 0, 57, 223, 22, 147, 22, 0,
1323 7, 0, 8, 0, 167, 0, 170, 0, 225, 0,
1324 224, 0, 191, 226, 0, 228, 229, 0, 219, 229,
1325 0, 230, 169, 231, 0, 230, 233, 0, 0, 21,
1326 0, 67, 227, 0, 67, 10, 0, 68, 17, 226,
1327 0, 68, 11, 226, 147, 17, 226, 147, 17, 226,
1328 0, 69, 165, 226, 147, 17, 226, 152, 232, 154,
1329 0, 69, 165, 226, 147, 17, 226, 152, 154, 0,
1330 70, 179, 193, 226, 150, 235, 151, 183, 38, 17,
1331 226, 71, 17, 226, 0, 71, 0, 72, 0, 232,
1332 165, 224, 147, 17, 226, 0, 165, 224, 147, 17,
1333 226, 0, 169, 238, 0, 191, 152, 226, 147, 226,
1334 154, 0, 234, 147, 152, 226, 147, 226, 154, 0,
1335 191, 226, 181, 0, 235, 147, 191, 226, 181, 0,
1336 0, 0, 236, 147, 227, 0, 56, 55, 0, 55,
1337 0, 160, 191, 226, 147, 226, 0, 161, 191, 226,
1338 147, 226, 0, 88, 163, 191, 226, 147, 226, 0,
1339 89, 164, 191, 226, 147, 226, 0, 162, 227, 38,
1340 191, 0, 129, 227, 147, 227, 147, 227, 0, 130,
1341 227, 147, 191, 0, 131, 227, 147, 227, 0, 132,
1342 227, 147, 227, 147, 227, 0, 133, 227, 147, 227,
1343 147, 227, 0, 128, 234, 0, 237, 179, 193, 226,
1344 150, 235, 151, 183, 0, 240, 0, 36, 0, 0,
1345 110, 191, 185, 0, 110, 191, 147, 11, 226, 185,
1346 0, 111, 191, 185, 0, 111, 191, 147, 11, 226,
1347 185, 0, 112, 227, 0, 239, 113, 191, 226, 185,
1348 0, 239, 114, 227, 147, 191, 226, 185, 0, 115,
1349 191, 226, 236, 0
1350};
Chris Lattner0275cff2007-08-06 21:00:46 +00001351
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001352#endif
1353
Dale Johannesencdd509a2007-09-07 21:07:57 +00001354#if YYDEBUG != 0
1355static const short yyrline[] = { 0,
1356 1126, 1126, 1126, 1126, 1126, 1126, 1126, 1126, 1126, 1127,
1357 1127, 1127, 1127, 1127, 1127, 1128, 1128, 1128, 1128, 1128,
1358 1128, 1128, 1129, 1129, 1129, 1129, 1129, 1132, 1132, 1133,
1359 1133, 1134, 1134, 1135, 1135, 1136, 1136, 1140, 1140, 1141,
1360 1141, 1142, 1142, 1143, 1143, 1144, 1144, 1145, 1145, 1146,
1361 1146, 1147, 1148, 1153, 1154, 1154, 1154, 1154, 1154, 1156,
1362 1156, 1156, 1157, 1157, 1161, 1165, 1170, 1170, 1172, 1173,
1363 1178, 1184, 1185, 1186, 1187, 1188, 1192, 1193, 1194, 1198,
1364 1199, 1200, 1201, 1205, 1206, 1207, 1211, 1212, 1213, 1214,
1365 1215, 1219, 1220, 1221, 1224, 1224, 1225, 1226, 1227, 1228,
1366 1229, 1237, 1238, 1239, 1240, 1241, 1242, 1243, 1244, 1245,
1367 1248, 1249, 1254, 1255, 1256, 1257, 1260, 1261, 1268, 1268,
1368 1275, 1275, 1284, 1292, 1292, 1298, 1298, 1300, 1305, 1318,
1369 1318, 1318, 1318, 1318, 1318, 1318, 1321, 1325, 1329, 1336,
1370 1341, 1349, 1379, 1410, 1415, 1427, 1437, 1441, 1451, 1458,
1371 1465, 1472, 1477, 1482, 1489, 1490, 1497, 1504, 1512, 1518,
1372 1530, 1558, 1574, 1601, 1629, 1655, 1675, 1701, 1721, 1733,
1373 1740, 1806, 1816, 1826, 1832, 1842, 1848, 1858, 1863, 1868,
1374 1881, 1893, 1915, 1923, 1929, 1940, 1945, 1950, 1956, 1962,
1375 1971, 1975, 1983, 1983, 1986, 1986, 1989, 2001, 2022, 2027,
1376 2035, 2036, 2040, 2040, 2044, 2044, 2047, 2050, 2074, 2085,
Chris Lattner569f7372007-09-10 23:24:14 +00001377 2092, 2095, 2101, 2104, 2111, 2115, 2155, 2158, 2164, 2174,
1378 2178, 2183, 2185, 2190, 2195, 2204, 2214, 2225, 2229, 2238,
1379 2247, 2252, 2373, 2373, 2375, 2384, 2384, 2386, 2391, 2403,
1380 2407, 2412, 2416, 2420, 2424, 2428, 2432, 2436, 2440, 2444,
1381 2469, 2473, 2483, 2487, 2491, 2496, 2503, 2503, 2509, 2518,
1382 2522, 2531, 2540, 2549, 2553, 2560, 2564, 2568, 2573, 2583,
1383 2602, 2611, 2691, 2695, 2702, 2713, 2726, 2736, 2747, 2757,
1384 2766, 2775, 2778, 2779, 2786, 2790, 2795, 2816, 2833, 2847,
1385 2861, 2873, 2881, 2888, 2894, 2900, 2906, 2921, 3006, 3011,
1386 3015, 3022, 3029, 3037, 3044, 3052, 3060, 3074, 3091
Dale Johannesencdd509a2007-09-07 21:07:57 +00001387};
1388#endif
1389
1390
1391#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
1392
1393static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL",
1394"EUINT64VAL","ESAPINTVAL","EUAPINTVAL","LOCALVAL_ID","GLOBALVAL_ID","FPVAL",
1395"VOID","INTTYPE","FLOAT","DOUBLE","X86_FP80","FP128","PPC_FP128","LABEL","TYPE",
1396"LOCALVAR","GLOBALVAR","LABELSTR","STRINGCONSTANT","ATSTRINGCONSTANT","PCTSTRINGCONSTANT",
1397"ZEROINITIALIZER","TRUETOK","FALSETOK","BEGINTOK","ENDTOK","DECLARE","DEFINE",
1398"GLOBAL","CONSTANT","SECTION","ALIAS","VOLATILE","THREAD_LOCAL","TO","DOTDOTDOT",
1399"NULL_TOK","UNDEF","INTERNAL","LINKONCE","WEAK","APPENDING","DLLIMPORT","DLLEXPORT",
1400"EXTERN_WEAK","OPAQUE","EXTERNAL","TARGET","TRIPLE","ALIGN","DEPLIBS","CALL",
1401"TAIL","ASM_TOK","MODULE","SIDEEFFECT","CC_TOK","CCC_TOK","FASTCC_TOK","COLDCC_TOK",
1402"X86_STDCALLCC_TOK","X86_FASTCALLCC_TOK","DATALAYOUT","RET","BR","SWITCH","INVOKE",
1403"UNWIND","UNREACHABLE","ADD","SUB","MUL","UDIV","SDIV","FDIV","UREM","SREM",
1404"FREM","AND","OR","XOR","SHL","LSHR","ASHR","ICMP","FCMP","EQ","NE","SLT","SGT",
1405"SLE","SGE","ULT","UGT","ULE","UGE","OEQ","ONE","OLT","OGT","OLE","OGE","ORD",
1406"UNO","UEQ","UNE","MALLOC","ALLOCA","FREE","LOAD","STORE","GETELEMENTPTR","TRUNC",
1407"ZEXT","SEXT","FPTRUNC","FPEXT","BITCAST","UITOFP","SITOFP","FPTOUI","FPTOSI",
1408"INTTOPTR","PTRTOINT","PHI_TOK","SELECT","VAARG","EXTRACTELEMENT","INSERTELEMENT",
1409"SHUFFLEVECTOR","SIGNEXT","ZEROEXT","NORETURN","INREG","SRET","NOUNWIND","NOALIAS",
1410"BYVAL","NEST","DEFAULT","HIDDEN","PROTECTED","'='","','","'*'","'\\\\'","'('",
1411"')'","'['","'x'","']'","'<'","'>'","'{'","'}'","'c'","ArithmeticOps","LogicalOps",
1412"CastOps","IPredicates","FPredicates","IntType","FPType","LocalName","OptLocalName",
1413"OptLocalAssign","GlobalName","OptGlobalAssign","GlobalAssign","GVInternalLinkage",
1414"GVExternalLinkage","GVVisibilityStyle","FunctionDeclareLinkage","FunctionDefineLinkage",
1415"AliasLinkage","OptCallingConv","ParamAttr","OptParamAttrs","FuncAttr","OptFuncAttrs",
1416"OptAlign","OptCAlign","SectionString","OptSection","GlobalVarAttributes","GlobalVarAttribute",
1417"PrimType","Types","ArgType","ResultTypes","ArgTypeList","ArgTypeListI","TypeListI",
1418"ConstVal","ConstExpr","ConstVector","GlobalType","ThreadLocal","AliaseeRef",
1419"Module","DefinitionList","Definition","@1","@2","@3","@4","@5","AsmBlock","TargetDefinition",
1420"LibrariesDefinition","LibList","ArgListH","ArgList","FunctionHeaderH","BEGIN",
1421"FunctionHeader","END","Function","FunctionProto","OptSideEffect","ConstValueRef",
1422"SymbolicValueRef","ValueRef","ResolvedVal","BasicBlockList","BasicBlock","InstructionList",
1423"BBTerminatorInst","JumpTable","Inst","PHIList","ValueRefList","IndexList","OptTailCall",
1424"InstVal","OptVolatile","MemoryInst", NULL
1425};
1426#endif
1427
1428static const short yyr1[] = { 0,
1429 160, 160, 160, 160, 160, 160, 160, 160, 160, 161,
1430 161, 161, 161, 161, 161, 162, 162, 162, 162, 162,
1431 162, 162, 162, 162, 162, 162, 162, 163, 163, 163,
1432 163, 163, 163, 163, 163, 163, 163, 164, 164, 164,
1433 164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
1434 164, 164, 164, 165, 166, 166, 166, 166, 166, 167,
1435 167, 167, 168, 168, 169, 169, 170, 170, 171, 171,
1436 172, 173, 173, 173, 173, 173, 174, 174, 174, 175,
1437 175, 175, 175, 176, 176, 176, 177, 177, 177, 177,
1438 177, 178, 178, 178, 179, 179, 179, 179, 179, 179,
1439 179, 180, 180, 180, 180, 180, 180, 180, 180, 180,
1440 181, 181, 182, 182, 182, 182, 183, 183, 184, 184,
1441 185, 185, 186, 187, 187, 188, 188, 189, 189, 190,
1442 190, 190, 190, 190, 190, 190, 191, 191, 191, 191,
1443 191, 191, 191, 191, 191, 191, 191, 191, 191, 192,
1444 193, 193, 194, 194, 195, 195, 195, 195, 196, 196,
1445 197, 197, 197, 197, 197, 197, 197, 197, 197, 197,
1446 197, 197, 197, 197, 197, 197, 197, 197, 197, 197,
1447 198, 198, 198, 198, 198, 198, 198, 198, 198, 198,
1448 199, 199, 200, 200, 201, 201, 202, 202, 203, 203,
1449 204, 204, 206, 205, 207, 205, 205, 205, 205, 208,
1450 205, 209, 205, 210, 205, 205, 205, 205, 211, 212,
1451 212, 213, 214, 214, 214, 215, 215, 216, 216, 216,
1452 216, 217, 218, 218, 219, 220, 220, 221, 222, 223,
1453 223, 224, 224, 224, 224, 224, 224, 224, 224, 224,
1454 224, 224, 225, 225, 225, 225, 226, 226, 227, 228,
1455 228, 229, 230, 230, 230, 231, 231, 231, 231, 231,
1456 231, 231, 231, 231, 232, 232, 233, 234, 234, 235,
1457 235, 235, 236, 236, 237, 237, 238, 238, 238, 238,
1458 238, 238, 238, 238, 238, 238, 238, 238, 238, 239,
1459 239, 240, 240, 240, 240, 240, 240, 240, 240
1460};
1461
1462static const short yyr2[] = { 0,
1463 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1464 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1465 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1466 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1467 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1468 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1469 1, 1, 1, 0, 2, 0, 1, 1, 1, 0,
1470 2, 1, 1, 1, 1, 1, 1, 1, 1, 0,
1471 1, 1, 1, 0, 1, 1, 0, 1, 1, 1,
1472 1, 0, 1, 1, 0, 1, 1, 1, 1, 1,
1473 2, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1474 0, 2, 1, 1, 1, 1, 0, 2, 0, 2,
1475 0, 3, 2, 0, 1, 0, 3, 1, 2, 1,
1476 1, 1, 1, 1, 1, 1, 1, 1, 2, 1,
1477 2, 5, 5, 5, 5, 3, 2, 5, 4, 2,
1478 1, 1, 1, 3, 1, 3, 1, 0, 1, 3,
1479 4, 3, 3, 4, 4, 3, 6, 5, 2, 2,
1480 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1481 6, 5, 8, 6, 6, 7, 7, 6, 8, 8,
1482 3, 1, 1, 1, 1, 0, 2, 6, 1, 0,
1483 1, 2, 0, 3, 0, 3, 3, 3, 3, 0,
1484 7, 0, 8, 0, 8, 5, 2, 3, 1, 3,
1485 3, 3, 3, 1, 0, 5, 3, 1, 3, 1,
1486 0, 9, 1, 1, 4, 1, 1, 2, 3, 0,
1487 1, 1, 1, 1, 1, 1, 1, 1, 1, 3,
1488 1, 5, 1, 1, 1, 1, 1, 1, 2, 2,
1489 2, 3, 2, 0, 1, 2, 2, 3, 9, 9,
1490 8, 14, 1, 1, 6, 5, 2, 6, 7, 3,
1491 5, 0, 0, 3, 2, 1, 5, 5, 6, 6,
1492 4, 6, 4, 4, 6, 6, 2, 8, 1, 1,
1493 0, 3, 6, 3, 6, 2, 5, 7, 4
1494};
1495
1496static const short yydefact[] = { 70,
1497 60, 67, 61, 68, 62, 205, 203, 0, 0, 0,
1498 0, 0, 0, 80, 69, 70, 201, 84, 87, 0,
1499 0, 217, 0, 0, 65, 0, 71, 72, 74, 73,
1500 75, 77, 76, 78, 79, 81, 82, 83, 80, 80,
1501 196, 202, 85, 86, 80, 206, 88, 89, 90, 91,
1502 80, 264, 204, 264, 0, 0, 225, 218, 219, 207,
1503 253, 254, 209, 130, 131, 132, 135, 134, 133, 136,
1504 137, 0, 0, 0, 0, 255, 256, 138, 208, 140,
1505 196, 196, 92, 195, 0, 95, 95, 265, 261, 66,
1506 236, 237, 238, 260, 220, 221, 224, 0, 158, 141,
1507 0, 0, 0, 0, 147, 159, 0, 139, 158, 0,
1508 0, 94, 93, 0, 193, 194, 0, 0, 96, 97,
1509 98, 99, 100, 0, 239, 0, 301, 263, 0, 222,
1510 157, 111, 153, 155, 0, 0, 0, 0, 0, 0,
1511 146, 0, 0, 0, 152, 0, 151, 0, 216, 130,
1512 131, 132, 135, 134, 133, 0, 0, 0, 210, 101,
1513 0, 233, 234, 235, 300, 286, 0, 0, 0, 0,
1514 95, 273, 274, 1, 2, 3, 4, 5, 6, 7,
1515 8, 9, 13, 14, 15, 10, 11, 12, 0, 0,
1516 0, 0, 0, 0, 16, 17, 18, 19, 20, 21,
1517 22, 23, 24, 25, 26, 27, 0, 0, 0, 0,
1518 0, 0, 0, 0, 0, 262, 95, 277, 0, 299,
1519 223, 150, 0, 117, 0, 0, 149, 0, 160, 117,
1520 212, 214, 0, 197, 178, 179, 174, 176, 175, 177,
1521 180, 173, 169, 170, 0, 0, 0, 0, 0, 0,
1522 0, 0, 0, 0, 0, 0, 0, 0, 172, 171,
1523 126, 0, 285, 267, 0, 266, 0, 0, 54, 0,
1524 0, 28, 29, 30, 31, 32, 33, 34, 35, 36,
1525 37, 0, 52, 53, 48, 49, 50, 51, 38, 39,
1526 40, 41, 42, 43, 44, 45, 46, 47, 0, 121,
1527 121, 306, 0, 0, 297, 0, 0, 0, 0, 0,
1528 0, 0, 0, 0, 0, 0, 103, 105, 104, 102,
1529 106, 107, 108, 109, 110, 112, 156, 154, 143, 144,
1530 145, 148, 142, 126, 126, 0, 0, 0, 0, 0,
1531 0, 0, 0, 162, 192, 0, 0, 0, 166, 0,
1532 163, 0, 0, 0, 0, 211, 231, 242, 243, 244,
1533 249, 245, 246, 247, 248, 240, 0, 251, 258, 257,
1534 259, 0, 268, 0, 0, 0, 0, 0, 302, 0,
1535 304, 283, 0, 0, 0, 0, 0, 0, 0, 0,
1536 0, 0, 0, 0, 0, 116, 115, 113, 114, 118,
1537 213, 215, 0, 0, 0, 283, 0, 0, 0, 0,
1538 0, 161, 147, 159, 0, 164, 165, 0, 0, 0,
1539 0, 0, 128, 126, 230, 111, 228, 0, 241, 0,
1540 0, 0, 0, 0, 0, 0, 0, 0, 0, 309,
1541 0, 0, 0, 293, 294, 0, 0, 0, 0, 291,
1542 0, 121, 0, 0, 0, 0, 0, 0, 0, 0,
1543 0, 191, 168, 0, 0, 0, 0, 123, 129, 127,
1544 64, 0, 117, 0, 250, 0, 0, 282, 0, 0,
1545 121, 122, 121, 0, 0, 0, 0, 0, 0, 287,
1546 288, 282, 0, 307, 0, 198, 0, 0, 182, 0,
1547 0, 0, 0, 167, 0, 0, 0, 63, 227, 229,
1548 111, 124, 0, 0, 0, 0, 0, 289, 290, 303,
1549 305, 284, 0, 0, 292, 295, 296, 0, 121, 0,
1550 0, 0, 188, 0, 0, 184, 185, 181, 64, 125,
1551 119, 252, 0, 0, 111, 0, 117, 278, 0, 117,
1552 308, 186, 187, 0, 0, 0, 226, 0, 232, 0,
1553 271, 0, 0, 280, 0, 0, 279, 298, 183, 189,
1554 190, 120, 269, 0, 270, 0, 111, 0, 0, 0,
1555 281, 0, 0, 0, 0, 276, 0, 0, 275, 0,
1556 272, 0, 0, 0
1557};
1558
1559static const short yydefgoto[] = { 256,
1560 257, 258, 282, 299, 156, 157, 76, 509, 12, 77,
1561 14, 15, 39, 40, 41, 45, 51, 114, 124, 326,
1562 222, 400, 329, 559, 379, 423, 541, 356, 424, 78,
1563 158, 133, 148, 134, 135, 107, 345, 368, 346, 117,
1564 85, 149, 592, 16, 17, 19, 18, 261, 334, 335,
1565 60, 22, 58, 98, 427, 428, 125, 164, 52, 93,
1566 53, 46, 430, 369, 80, 371, 266, 54, 89, 90,
1567 216, 563, 128, 305, 517, 440, 217, 218, 219, 220
1568};
1569
1570static const short yypact[] = { 42,
1571-32768,-32768,-32768,-32768,-32768,-32768,-32768, -21, -131, 60,
1572 -93, 105, -22, 182,-32768, 525,-32768, 46, 168, -12,
1573 19,-32768, 1, 152,-32768, 1277,-32768,-32768,-32768,-32768,
1574-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 90, 90,
1575 100,-32768,-32768,-32768, 90,-32768,-32768,-32768,-32768,-32768,
1576 90, 186,-32768, 12, 187, 201, 209,-32768,-32768,-32768,
1577-32768,-32768, 93,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1578-32768, 252, 254, 2, 907,-32768,-32768,-32768, 13,-32768,
1579 225, 225, 150,-32768, 76, 116, 116,-32768,-32768, 108,
1580-32768,-32768,-32768,-32768,-32768,-32768,-32768, -79, 1027,-32768,
1581 111, 114, 947, 93,-32768, 13, -104,-32768, 1027, 76,
1582 76,-32768,-32768, 1067,-32768,-32768, 1299, 266,-32768,-32768,
1583-32768,-32768,-32768, 1330,-32768, -16, 1572,-32768, 256,-32768,
1584-32768, 13,-32768, 139, 144, 1370, 1370, 132, -95, 1370,
1585-32768, 145, 1299, 1370, 93, 147, 13, 311,-32768, 43,
1586 290, 293, 298, 299, 302, 247, 303, 724,-32768,-32768,
1587 35,-32768,-32768,-32768,-32768,-32768, 258, 1450, 70, 305,
1588 116,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1589-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 317, 405,
1590 1370, 1370, 1370, 1370,-32768,-32768,-32768,-32768,-32768,-32768,
1591-32768,-32768,-32768,-32768,-32768,-32768, 1370, 1370, 1370, 1370,
1592 1370, 1370, 1370, 1370, 1370,-32768, 116,-32768, 34,-32768,
1593-32768, 131, 1107,-32768, 6, -46,-32768, 164, 13,-32768,
1594-32768, 13, 1067,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1595-32768,-32768,-32768,-32768, 317, 405, 173, 178, 179, 189,
1596 192, 1179, 1481, 987, 314, 193, 197, 198,-32768,-32768,
1597 202, 203,-32768, 93, 565,-32768, 699, 699,-32768, 699,
1598 1330,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1599-32768, 1370,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1600-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 1370, 113,
1601 137,-32768, 565, -10, 205, 207, 208, 210, 218, 219,
1602 565, 565, 330, 1330, 1370, 1370,-32768,-32768,-32768,-32768,
1603-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 106,-32768,
1604-32768,-32768, 106, 202, 202, 331, 220, 221, 1299, 1299,
1605 1299, 1299, 1299,-32768,-32768, -41, 1005, -61,-32768, -91,
1606-32768, 1299, 1299, 1299, -13,-32768, 1219,-32768,-32768,-32768,
1607-32768,-32768,-32768,-32768,-32768, 313, 1299,-32768,-32768,-32768,
1608-32768, 226,-32768, 227, 699, 565, 565, 23,-32768, 24,
1609-32768,-32768, 699, 223, 1370, 1370, 1370, 1370, 1370, 232,
1610 233, 1370, 699, 565, 234,-32768,-32768,-32768,-32768,-32768,
1611-32768,-32768, 1370, 1299, 1299,-32768, 235, 236, 237, 239,
1612 1299,-32768, 231, 724, -76,-32768,-32768, 241, 242, 352,
1613 369, 388,-32768, 202,-32768, 13, 246, 243,-32768, 374,
1614 -59, 380, 385, 253, 257, 270, 699, 414, 699, 272,
1615 273, 699, 278, 13,-32768, 280, 282, 699, 699, 13,
1616 283, 287, 1370, -112, 288, 289, -33, 1299, 1299, 1299,
1617 1299,-32768,-32768, 294, 1299, 1299, 1370,-32768,-32768,-32768,
1618 79, 1259,-32768, 292,-32768, 699, 699, 1370, 699, 699,
1619 287,-32768, 287, 1370, 699, 307, 1370, 1370, 1370,-32768,
1620-32768, 1370, 392,-32768, 565,-32768, 1299, 1299,-32768, 308,
1621 295, 309, 310,-32768, 301, 315, 7,-32768,-32768,-32768,
1622 13, 10, 427, 318, 306, 565, 52,-32768,-32768,-32768,
1623-32768,-32768, 316, 699,-32768,-32768,-32768, 71, 287, 322,
1624 325, 1299,-32768, 1299, 1299,-32768,-32768,-32768, 79,-32768,
1625 407,-32768, 444, -4,-32768, 1370,-32768,-32768, 323,-32768,
1626-32768,-32768,-32768, 327, 328, 329,-32768, 464,-32768, 699,
1627-32768, 859, -3, 131, 565, -14,-32768, 106,-32768,-32768,
1628-32768,-32768,-32768, 334,-32768, 859,-32768, 452, 465, 336,
1629 131, 699, 699, 468, 416,-32768, 699, 471,-32768, 699,
1630-32768, 490, 491,-32768
1631};
1632
1633static const short yypgoto[] = { 365,
1634 366, 367, 255, 251, -168,-32768, 0, -40, 408, 14,
1635-32768,-32768,-32768,-32768, 40,-32768,-32768,-32768, -158,-32768,
1636 -406,-32768, -226,-32768, -290, 3,-32768, -317,-32768,-32768,
1637 -25, 296, -119,-32768, 409, 413, -60, -155, -231, 166,
1638 119, 284,-32768,-32768, 504,-32768,-32768,-32768,-32768,-32768,
1639-32768,-32768,-32768,-32768,-32768,-32768, 435,-32768,-32768,-32768,
1640-32768,-32768,-32768, -525, -139, 47, -183,-32768, 474,-32768,
1641-32768,-32768,-32768,-32768, 37, 124,-32768,-32768,-32768,-32768
1642};
1643
1644
1645#define YYLAST 1705
1646
1647
1648static const short yytable[] = { 11,
1649 79, 270, 259, 333, 161, 102, 269, 269, 234, 302,
1650 381, 162, 271, 13, 23, 11, 401, 402, 260, 471,
1651 421, 348, 350, 578, 306, 307, 308, 309, 310, 13,
1652 20, 313, 88, 437, 439, 108, 574, 109, 496, 422,
1653 91, -200, 140, 421, 21, -54, -54, -54, -54, 106,
1654 580, 140, 25, 141, 2, 411, 159, 4, 314, -66,
1655 1, 2, 228, 3, 4, 5, 417, 129, 235, 236,
1656 411, 6, 7, 132, 130, 438, 438, 106, 81, 82,
1657 267, 464, 231, 132, 86, 411, 268, 411, 147, 11,
1658 87, 43, 8, 44, 416, 9, 475, 1, 147, 10,
1659 3, 108, 5, 109, 539, 411, 470, 115, 116, 331,
1660 225, 226, 412, 484, 229, 415, 24, 499, 232, 396,
1661 397, 398, 26, 27, 399, 370, 1, 370, 370, 3,
1662 370, 5, 395, 55, 83, 431, 84, 108, 564, 109,
1663 163, 383, 265, 396, 397, 398, 315, 316, 399, 561,
1664 575, 375, 57, 108, 108, 109, 109, 538, 103, 330,
1665 108, 494, 109, 370, 56, 300, 301, 265, 303, 92,
1666 581, 370, 370, 59, 262, 118, 119, 120, 121, 122,
1667 123, 304, 265, 265, 265, 265, 265, 311, 312, 265,
1668 520, 112, 521, 113, 393, 317, 318, 132, 546, 110,
1669 111, 443, 547, 445, 446, 447, 88, 147, 95, 47,
1670 48, 49, 319, 320, 50, 321, 322, 546, 323, 324,
1671 325, 550, 96, 28, 29, 30, 31, 32, 33, 34,
1672 97, 35, 36, 37, 38, 370, 370, 370, 551, 396,
1673 397, 398, 99, 370, 399, 147, 512, 317, 318, 237,
1674 238, 239, 240, 370, 370, 100, 376, 101, 259, 378,
1675 108, 84, 109, 136, 319, 320, 137, 321, 322, 160,
1676 323, 324, 325, 377, 260, 143, 144, 221, 406, 407,
1677 408, 409, 410, 380, 108, 223, 109, 227, 147, 394,
1678 265, 418, 419, 420, 224, 230, 233, 370, -55, 370,
1679 522, -56, 370, 525, 526, 527, -59, -58, 370, 370,
1680 -57, 241, 263, 372, 373, 269, 374, 61, 62, 332,
1681 566, 414, 339, 568, 36, 37, 38, 340, 341, 1,
1682 2, 426, 3, 4, 5, 351, 370, 370, 342, 370,
1683 370, 343, 352, 455, 456, 370, 353, 354, 355, 382,
1684 462, 384, 357, 385, 386, 370, 387, 390, 391, 265,
1685 444, 265, 265, 265, 388, 389, 450, 392, 403, 404,
1686 405, 429, 432, 433, 442, 562, 370, 454, 448, 449,
1687 453, 458, 459, 460, 370, 461, 463, 465, 466, 467,
1688 468, 469, 472, 473, 576, 474, 476, 500, 501, 502,
1689 503, 477, 478, 479, 505, 506, 272, 273, 274, 275,
1690 276, 277, 278, 279, 280, 281, 480, 482, 484, 485,
1691 370, 434, 435, 436, 487, 370, 488, 495, 489, 441,
1692 283, 284, 492, 493, 497, 498, 530, 531, 513, 451,
1693 452, 507, 370, 370, 438, 533, 511, 370, 542, 504,
1694 370, 536, 516, 524, 532, 534, 535, 544, 265, 558,
1695 560, 265, 265, 265, 543, 537, 516, 572, 582, 548,
1696 508, 554, 552, 555, 556, 553, 567, 569, 570, 571,
1697 579, 583, 584, 481, 587, 483, 588, 590, 486, 593,
1698 594, 213, 214, 215, 490, 491, 338, 127, 557, 337,
1699 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1700 295, 296, 297, 298, 540, 139, 336, 142, 328, 42,
1701 565, 126, 514, 515, -199, 518, 519, 94, 528, 457,
1702 0, 523, 0, 0, 0, 0, 0, 0, 508, 0,
1703 0, 529, -66, 1, 2, 0, 3, 4, 5, 0,
1704 0, 0, 0, 0, 6, 7, 0, 0, 0, 0,
1705 0, 0, 545, 0, 0, 0, 0, 358, 359, 0,
1706 549, 61, 62, 360, 0, 8, 0, 0, 9, 0,
1707 0, 0, 10, 1, 2, 0, 3, 4, 5, 361,
1708 362, 363, 0, 0, 0, 0, 0, 0, 0, 0,
1709 0, 0, 0, 0, 364, 365, 573, 0, 0, 0,
1710 0, 577, 0, 0, 0, 0, 0, 0, 0, 0,
1711 0, 366, 0, 0, 0, 0, 0, 0, 585, 586,
1712 0, 0, 0, 589, 0, 0, 591, 174, 175, 176,
1713 177, 178, 179, 180, 181, 182, 183, 184, 185, 186,
1714 187, 188, 245, 246, 0, 0, 0, 0, 0, 0,
1715 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1716 0, 0, 0, 0, 0, 0, 0, 0, 0, 247,
1717 195, 196, 197, 198, 199, 200, 201, 202, 203, 204,
1718 205, 206, 0, 248, 0, 249, 250, 251, 0, 0,
1719 0, 358, 359, 0, 0, 61, 62, 360, 0, 0,
1720 0, 0, 108, 0, 109, 0, 0, 1, 2, 367,
1721 3, 4, 5, 361, 362, 363, 0, 0, 0, 0,
1722 61, 62, 0, 0, 0, 0, 0, 0, 364, 365,
1723 0, 0, 1, 2, 0, 3, 4, 5, 242, 0,
1724 0, 0, 0, 0, 0, 366, 0, 0, 0, 0,
1725 0, 0, 0, 243, 244, 0, 0, 0, 0, 0,
1726 0, 174, 175, 176, 177, 178, 179, 180, 181, 182,
1727 183, 184, 185, 186, 187, 188, 245, 246, 0, 0,
1728 0, 0, 0, 0, 0, 0, 174, 175, 176, 177,
1729 178, 179, 180, 181, 182, 183, 184, 185, 186, 187,
1730 188, 245, 246, 247, 195, 196, 197, 198, 199, 200,
1731 201, 202, 203, 204, 205, 206, 0, 248, 0, 249,
1732 250, 251, 0, 0, 0, 0, 0, 0, 247, 195,
1733 196, 197, 198, 199, 200, 201, 202, 203, 204, 205,
1734 206, 0, 248, 367, 249, 250, 251, 0, 0, 0,
1735 0, 358, 359, 0, 0, 0, 0, 360, 0, 0,
1736 0, 108, 0, 109, 0, 252, 0, 0, 253, 0,
1737 254, 0, 255, 361, 362, 363, 0, 0, 0, 0,
1738 0, 0, 0, 0, 0, 0, 0, 0, 364, 365,
1739 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1740 0, 0, 0, 61, 62, 366, 104, 64, 65, 66,
1741 67, 68, 69, 70, 0, 1, 2, 0, 3, 4,
1742 5, 174, 175, 176, 177, 178, 179, 180, 181, 182,
1743 183, 184, 185, 186, 187, 188, 245, 246, 0, 0,
1744 0, 0, 0, 61, 62, 71, 104, 64, 65, 66,
1745 67, 68, 69, 70, 0, 1, 2, 0, 3, 4,
1746 5, 0, 0, 247, 195, 196, 197, 198, 199, 200,
1747 201, 202, 203, 204, 205, 206, 0, 248, 0, 249,
1748 250, 251, 0, 61, 62, 71, 104, 150, 151, 152,
1749 153, 154, 155, 70, 0, 1, 2, 0, 3, 4,
1750 5, 61, 62, 367, 104, 150, 151, 152, 153, 154,
1751 155, 70, 0, 1, 2, 0, 3, 4, 5, 0,
1752 0, 0, 0, 61, 62, 71, 104, 64, 65, 66,
1753 67, 68, 69, 70, 0, 1, 2, 0, 3, 4,
1754 5, 0, 0, 71, 0, 72, 0, 0, 73, 0,
1755 0, 74, 0, 75, 105, 131, 0, 0, 0, 0,
1756 0, 0, 0, 61, 62, 71, 145, 64, 65, 66,
1757 67, 68, 69, 70, 0, 1, 2, 0, 3, 4,
1758 5, 0, 0, 0, 0, 72, 0, 0, 73, 0,
1759 0, 74, 0, 75, 138, 0, 0, 0, 0, 0,
1760 0, 0, 0, 61, 62, 71, 104, 64, 65, 66,
1761 67, 68, 69, 70, 0, 1, 2, 0, 3, 4,
1762 5, 0, 0, 0, 0, 72, 0, 0, 73, 0,
1763 0, 74, 0, 75, 349, 327, 0, 0, 0, 0,
1764 0, 0, 0, 72, 0, 71, 73, 0, 0, 74,
1765 0, 75, 413, 0, 0, 0, 0, 0, 0, 0,
1766 0, 0, 0, 0, 0, 72, 0, 0, 73, 0,
1767 0, 74, 0, 75, 0, 61, 62, 146, 104, 150,
1768 151, 152, 153, 154, 155, 70, 0, 1, 2, 0,
1769 3, 4, 5, 0, 0, 0, 0, 0, 0, 0,
1770 0, 0, 0, 0, 0, 72, 0, 0, 73, 0,
1771 0, 74, 0, 75, 0, 61, 62, 71, 104, 64,
1772 65, 66, 67, 68, 69, 70, 0, 1, 2, 0,
1773 3, 4, 5, 0, 0, 0, 0, 0, 0, 0,
1774 0, 0, 0, 0, 0, 72, 0, 425, 73, 0,
1775 0, 74, 0, 75, 0, 61, 62, 71, 104, 64,
1776 65, 66, 67, 68, 69, 70, 0, 1, 2, 0,
1777 3, 4, 5, 61, 62, 0, 63, 64, 65, 66,
1778 67, 68, 69, 70, 0, 1, 2, 510, 3, 4,
1779 5, 0, 0, 0, 0, 61, 62, 71, 104, 150,
1780 151, 152, 153, 154, 155, 70, 0, 1, 2, 0,
1781 3, 4, 5, 0, 0, 71, 0, 72, 0, 0,
1782 73, 0, 344, 74, 0, 75, 61, 62, 0, 145,
1783 64, 65, 66, 67, 68, 69, 70, 71, 1, 2,
1784 0, 3, 4, 5, 0, 0, 0, 0, 0, 0,
1785 0, 0, 0, 0, 0, 0, 0, 72, 0, 0,
1786 73, 0, 0, 74, 0, 75, 61, 62, 71, 104,
1787 64, 65, 66, 67, 68, 69, 70, 0, 1, 2,
1788 0, 3, 4, 5, 0, 0, 0, 0, 0, 0,
1789 0, 0, 0, 0, 0, 0, 0, 72, 0, 0,
1790 73, 0, 0, 74, 0, 75, 0, 0, 71, 0,
1791 0, 0, 0, 0, 0, 72, 0, 0, 73, 0,
1792 0, 74, 0, 75, 0, 0, 0, 0, 0, 0,
1793 0, 0, 0, 0, 0, 0, 0, 72, 0, 0,
1794 73, 0, 0, 74, 0, 75, 61, 62, 0, 264,
1795 64, 65, 66, 67, 68, 69, 70, 0, 1, 2,
1796 0, 3, 4, 5, 0, 0, 0, 0, 72, 0,
1797 0, 73, 0, 0, 74, 0, 75, 61, 62, 0,
1798 104, 150, 151, 152, 153, 154, 155, 70, 71, 1,
1799 2, 0, 3, 4, 5, 0, 0, 0, 0, 0,
1800 0, 0, 0, 0, 0, 0, 0, 0, 72, 0,
1801 0, 73, 0, 0, 74, 0, 75, 0, 0, 71,
1802 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1803 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1804 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1805 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1806 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1807 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1808 0, 0, 0, 0, 0, 0, 0, 0, 72, 0,
1809 0, 73, 0, 0, 74, 0, 75, 165, 0, 0,
1810 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1811 0, 0, 0, 0, 0, 0, 166, 167, 0, 72,
1812 0, 0, 73, 0, 0, 74, 0, 347, 168, 169,
1813 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
1814 180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
1815 190, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1816 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1817 0, 191, 192, 193, 0, 0, 194, 195, 196, 197,
1818 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
1819 208, 209, 210, 211, 212
1820};
1821
1822static const short yycheck[] = { 0,
1823 26, 170, 158, 230, 124, 4, 11, 11, 148, 193,
1824 301, 28, 171, 0, 146, 16, 334, 335, 158, 426,
1825 34, 253, 254, 38, 208, 209, 210, 211, 212, 16,
1826 52, 215, 21, 11, 11, 148, 562, 150, 151, 53,
1827 29, 0, 147, 34, 66, 3, 4, 5, 6, 75,
1828 576, 147, 146, 158, 20, 147, 117, 23, 217, 18,
1829 19, 20, 158, 22, 23, 24, 158, 147, 26, 27,
1830 147, 30, 31, 99, 154, 53, 53, 103, 39, 40,
1831 11, 158, 143, 109, 45, 147, 17, 147, 114, 90,
1832 51, 46, 51, 48, 156, 54, 156, 19, 124, 58,
1833 22, 148, 24, 150, 511, 147, 424, 32, 33, 156,
1834 136, 137, 154, 147, 140, 347, 57, 151, 144, 134,
1835 135, 136, 18, 146, 139, 265, 19, 267, 268, 22,
1836 270, 24, 316, 146, 35, 367, 37, 148, 545, 150,
1837 157, 152, 168, 134, 135, 136, 113, 114, 139, 154,
1838 154, 271, 152, 148, 148, 150, 150, 151, 157, 154,
1839 148, 452, 150, 303, 146, 191, 192, 193, 194, 158,
1840 577, 311, 312, 22, 161, 60, 61, 62, 63, 64,
1841 65, 207, 208, 209, 210, 211, 212, 213, 214, 215,
1842 481, 42, 483, 44, 314, 117, 118, 223, 147, 81,
1843 82, 385, 151, 387, 388, 389, 21, 233, 22, 42,
1844 43, 44, 134, 135, 47, 137, 138, 147, 140, 141,
1845 142, 151, 22, 42, 43, 44, 45, 46, 47, 48,
1846 22, 50, 143, 144, 145, 375, 376, 377, 529, 134,
1847 135, 136, 150, 383, 139, 271, 473, 117, 118, 3,
1848 4, 5, 6, 393, 394, 4, 282, 4, 414, 147,
1849 148, 37, 150, 153, 134, 135, 153, 137, 138, 4,
1850 140, 141, 142, 299, 414, 110, 111, 22, 339, 340,
1851 341, 342, 343, 147, 148, 147, 150, 156, 314, 315,
1852 316, 352, 353, 354, 151, 151, 150, 437, 9, 439,
1853 484, 9, 442, 487, 488, 489, 9, 9, 448, 449,
1854 9, 9, 55, 267, 268, 11, 270, 7, 8, 156,
1855 547, 347, 150, 550, 143, 144, 145, 150, 150, 19,
1856 20, 357, 22, 23, 24, 22, 476, 477, 150, 479,
1857 480, 150, 150, 404, 405, 485, 150, 150, 147, 303,
1858 411, 147, 150, 147, 147, 495, 147, 311, 312, 385,
1859 386, 387, 388, 389, 147, 147, 392, 38, 38, 150,
1860 150, 59, 147, 147, 152, 544, 516, 403, 147, 147,
1861 147, 147, 147, 147, 524, 147, 156, 147, 147, 38,
1862 22, 4, 147, 151, 563, 22, 17, 458, 459, 460,
1863 461, 17, 150, 147, 465, 466, 90, 91, 92, 93,
1864 94, 95, 96, 97, 98, 99, 147, 4, 147, 147,
1865 560, 375, 376, 377, 147, 565, 147, 453, 147, 383,
1866 26, 27, 150, 147, 147, 147, 497, 498, 147, 393,
1867 394, 467, 582, 583, 53, 151, 472, 587, 22, 156,
1868 590, 151, 478, 147, 147, 147, 147, 152, 484, 53,
1869 17, 487, 488, 489, 147, 151, 492, 4, 17, 154,
1870 471, 532, 151, 534, 535, 151, 154, 151, 151, 151,
1871 147, 17, 147, 437, 17, 439, 71, 17, 442, 0,
1872 0, 127, 127, 127, 448, 449, 246, 90, 539, 245,
1873 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
1874 106, 107, 108, 109, 512, 103, 233, 109, 223, 16,
1875 546, 87, 476, 477, 0, 479, 480, 54, 492, 406,
1876 -1, 485, -1, -1, -1, -1, -1, -1, 539, -1,
1877 -1, 495, 18, 19, 20, -1, 22, 23, 24, -1,
1878 -1, -1, -1, -1, 30, 31, -1, -1, -1, -1,
1879 -1, -1, 516, -1, -1, -1, -1, 3, 4, -1,
1880 524, 7, 8, 9, -1, 51, -1, -1, 54, -1,
1881 -1, -1, 58, 19, 20, -1, 22, 23, 24, 25,
1882 26, 27, -1, -1, -1, -1, -1, -1, -1, -1,
1883 -1, -1, -1, -1, 40, 41, 560, -1, -1, -1,
1884 -1, 565, -1, -1, -1, -1, -1, -1, -1, -1,
1885 -1, 57, -1, -1, -1, -1, -1, -1, 582, 583,
1886 -1, -1, -1, 587, -1, -1, 590, 73, 74, 75,
1887 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
1888 86, 87, 88, 89, -1, -1, -1, -1, -1, -1,
1889 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1890 -1, -1, -1, -1, -1, -1, -1, -1, -1, 115,
1891 116, 117, 118, 119, 120, 121, 122, 123, 124, 125,
1892 126, 127, -1, 129, -1, 131, 132, 133, -1, -1,
1893 -1, 3, 4, -1, -1, 7, 8, 9, -1, -1,
1894 -1, -1, 148, -1, 150, -1, -1, 19, 20, 155,
1895 22, 23, 24, 25, 26, 27, -1, -1, -1, -1,
1896 7, 8, -1, -1, -1, -1, -1, -1, 40, 41,
1897 -1, -1, 19, 20, -1, 22, 23, 24, 25, -1,
1898 -1, -1, -1, -1, -1, 57, -1, -1, -1, -1,
1899 -1, -1, -1, 40, 41, -1, -1, -1, -1, -1,
1900 -1, 73, 74, 75, 76, 77, 78, 79, 80, 81,
1901 82, 83, 84, 85, 86, 87, 88, 89, -1, -1,
1902 -1, -1, -1, -1, -1, -1, 73, 74, 75, 76,
1903 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1904 87, 88, 89, 115, 116, 117, 118, 119, 120, 121,
1905 122, 123, 124, 125, 126, 127, -1, 129, -1, 131,
1906 132, 133, -1, -1, -1, -1, -1, -1, 115, 116,
1907 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
1908 127, -1, 129, 155, 131, 132, 133, -1, -1, -1,
1909 -1, 3, 4, -1, -1, -1, -1, 9, -1, -1,
1910 -1, 148, -1, 150, -1, 152, -1, -1, 155, -1,
1911 157, -1, 159, 25, 26, 27, -1, -1, -1, -1,
1912 -1, -1, -1, -1, -1, -1, -1, -1, 40, 41,
1913 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1914 -1, -1, -1, 7, 8, 57, 10, 11, 12, 13,
1915 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
1916 24, 73, 74, 75, 76, 77, 78, 79, 80, 81,
1917 82, 83, 84, 85, 86, 87, 88, 89, -1, -1,
1918 -1, -1, -1, 7, 8, 49, 10, 11, 12, 13,
1919 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
1920 24, -1, -1, 115, 116, 117, 118, 119, 120, 121,
1921 122, 123, 124, 125, 126, 127, -1, 129, -1, 131,
1922 132, 133, -1, 7, 8, 49, 10, 11, 12, 13,
1923 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
1924 24, 7, 8, 155, 10, 11, 12, 13, 14, 15,
1925 16, 17, -1, 19, 20, -1, 22, 23, 24, -1,
1926 -1, -1, -1, 7, 8, 49, 10, 11, 12, 13,
1927 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
1928 24, -1, -1, 49, -1, 149, -1, -1, 152, -1,
1929 -1, 155, -1, 157, 158, 39, -1, -1, -1, -1,
1930 -1, -1, -1, 7, 8, 49, 10, 11, 12, 13,
1931 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
1932 24, -1, -1, -1, -1, 149, -1, -1, 152, -1,
1933 -1, 155, -1, 157, 158, -1, -1, -1, -1, -1,
1934 -1, -1, -1, 7, 8, 49, 10, 11, 12, 13,
1935 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
1936 24, -1, -1, -1, -1, 149, -1, -1, 152, -1,
1937 -1, 155, -1, 157, 158, 39, -1, -1, -1, -1,
1938 -1, -1, -1, 149, -1, 49, 152, -1, -1, 155,
1939 -1, 157, 158, -1, -1, -1, -1, -1, -1, -1,
1940 -1, -1, -1, -1, -1, 149, -1, -1, 152, -1,
1941 -1, 155, -1, 157, -1, 7, 8, 121, 10, 11,
1942 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
1943 22, 23, 24, -1, -1, -1, -1, -1, -1, -1,
1944 -1, -1, -1, -1, -1, 149, -1, -1, 152, -1,
1945 -1, 155, -1, 157, -1, 7, 8, 49, 10, 11,
1946 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
1947 22, 23, 24, -1, -1, -1, -1, -1, -1, -1,
1948 -1, -1, -1, -1, -1, 149, -1, 39, 152, -1,
1949 -1, 155, -1, 157, -1, 7, 8, 49, 10, 11,
1950 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
1951 22, 23, 24, 7, 8, -1, 10, 11, 12, 13,
1952 14, 15, 16, 17, -1, 19, 20, 39, 22, 23,
1953 24, -1, -1, -1, -1, 7, 8, 49, 10, 11,
1954 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
1955 22, 23, 24, -1, -1, 49, -1, 149, -1, -1,
1956 152, -1, 154, 155, -1, 157, 7, 8, -1, 10,
1957 11, 12, 13, 14, 15, 16, 17, 49, 19, 20,
1958 -1, 22, 23, 24, -1, -1, -1, -1, -1, -1,
1959 -1, -1, -1, -1, -1, -1, -1, 149, -1, -1,
1960 152, -1, -1, 155, -1, 157, 7, 8, 49, 10,
1961 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
1962 -1, 22, 23, 24, -1, -1, -1, -1, -1, -1,
1963 -1, -1, -1, -1, -1, -1, -1, 149, -1, -1,
1964 152, -1, -1, 155, -1, 157, -1, -1, 49, -1,
1965 -1, -1, -1, -1, -1, 149, -1, -1, 152, -1,
1966 -1, 155, -1, 157, -1, -1, -1, -1, -1, -1,
1967 -1, -1, -1, -1, -1, -1, -1, 149, -1, -1,
1968 152, -1, -1, 155, -1, 157, 7, 8, -1, 10,
1969 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
1970 -1, 22, 23, 24, -1, -1, -1, -1, 149, -1,
1971 -1, 152, -1, -1, 155, -1, 157, 7, 8, -1,
1972 10, 11, 12, 13, 14, 15, 16, 17, 49, 19,
1973 20, -1, 22, 23, 24, -1, -1, -1, -1, -1,
1974 -1, -1, -1, -1, -1, -1, -1, -1, 149, -1,
1975 -1, 152, -1, -1, 155, -1, 157, -1, -1, 49,
1976 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1977 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1978 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1979 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1980 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1981 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1982 -1, -1, -1, -1, -1, -1, -1, -1, 149, -1,
1983 -1, 152, -1, -1, 155, -1, 157, 36, -1, -1,
1984 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1985 -1, -1, -1, -1, -1, -1, 55, 56, -1, 149,
1986 -1, -1, 152, -1, -1, 155, -1, 157, 67, 68,
1987 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
1988 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
1989 89, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1990 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1991 -1, 110, 111, 112, -1, -1, 115, 116, 117, 118,
1992 119, 120, 121, 122, 123, 124, 125, 126, 127, 128,
1993 129, 130, 131, 132, 133
1994};
1995/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
1996#line 3 "/usr/share/bison.simple"
1997/* This file comes from bison-1.28. */
1998
1999/* Skeleton output parser for bison,
2000 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
2001
2002 This program is free software; you can redistribute it and/or modify
2003 it under the terms of the GNU General Public License as published by
2004 the Free Software Foundation; either version 2, or (at your option)
2005 any later version.
2006
2007 This program is distributed in the hope that it will be useful,
2008 but WITHOUT ANY WARRANTY; without even the implied warranty of
2009 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2010 GNU General Public License for more details.
2011
2012 You should have received a copy of the GNU General Public License
2013 along with this program; if not, write to the Free Software
2014 Foundation, Inc., 59 Temple Place - Suite 330,
2015 Boston, MA 02111-1307, USA. */
2016
2017/* As a special exception, when this file is copied by Bison into a
2018 Bison output file, you may use that output file without restriction.
2019 This special exception was added by the Free Software Foundation
2020 in version 1.24 of Bison. */
2021
2022/* This is the parser code that is written into each bison parser
2023 when the %semantic_parser declaration is not specified in the grammar.
2024 It was written by Richard Stallman by simplifying the hairy parser
2025 used when %semantic_parser is specified. */
2026
2027#ifndef YYSTACK_USE_ALLOCA
2028#ifdef alloca
2029#define YYSTACK_USE_ALLOCA
2030#else /* alloca not defined */
2031#ifdef __GNUC__
2032#define YYSTACK_USE_ALLOCA
2033#define alloca __builtin_alloca
2034#else /* not GNU C. */
2035#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
2036#define YYSTACK_USE_ALLOCA
2037#include <alloca.h>
2038#else /* not sparc */
2039/* We think this test detects Watcom and Microsoft C. */
2040/* This used to test MSDOS, but that is a bad idea
2041 since that symbol is in the user namespace. */
2042#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
2043#if 0 /* No need for malloc.h, which pollutes the namespace;
2044 instead, just don't use alloca. */
2045#include <malloc.h>
2046#endif
2047#else /* not MSDOS, or __TURBOC__ */
2048#if defined(_AIX)
2049/* I don't know what this was needed for, but it pollutes the namespace.
2050 So I turned it off. rms, 2 May 1997. */
2051/* #include <malloc.h> */
2052 #pragma alloca
2053#define YYSTACK_USE_ALLOCA
2054#else /* not MSDOS, or __TURBOC__, or _AIX */
2055#if 0
2056#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
2057 and on HPUX 10. Eventually we can turn this on. */
2058#define YYSTACK_USE_ALLOCA
2059#define alloca __builtin_alloca
2060#endif /* __hpux */
2061#endif
2062#endif /* not _AIX */
2063#endif /* not MSDOS, or __TURBOC__ */
2064#endif /* not sparc */
2065#endif /* not GNU C */
2066#endif /* alloca not defined */
2067#endif /* YYSTACK_USE_ALLOCA not defined */
2068
2069#ifdef YYSTACK_USE_ALLOCA
2070#define YYSTACK_ALLOC alloca
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002071#else
Dale Johannesencdd509a2007-09-07 21:07:57 +00002072#define YYSTACK_ALLOC malloc
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002073#endif
2074
Dale Johannesencdd509a2007-09-07 21:07:57 +00002075/* Note: there must be only one dollar sign in this file.
2076 It is replaced by the list of actions, each action
2077 as one case of the switch. */
David Greene718fda32007-08-01 03:59:32 +00002078
Reid Spencer68a24bd2005-08-27 18:50:39 +00002079#define yyerrok (yyerrstatus = 0)
2080#define yyclearin (yychar = YYEMPTY)
Dale Johannesencdd509a2007-09-07 21:07:57 +00002081#define YYEMPTY -2
Reid Spencer68a24bd2005-08-27 18:50:39 +00002082#define YYEOF 0
Reid Spencer68a24bd2005-08-27 18:50:39 +00002083#define YYACCEPT goto yyacceptlab
Dale Johannesencdd509a2007-09-07 21:07:57 +00002084#define YYABORT goto yyabortlab
2085#define YYERROR goto yyerrlab1
2086/* Like YYERROR except do call yyerror.
2087 This remains here temporarily to ease the
2088 transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002089 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002090#define YYFAIL goto yyerrlab
Reid Spencer68a24bd2005-08-27 18:50:39 +00002091#define YYRECOVERING() (!!yyerrstatus)
Dale Johannesencdd509a2007-09-07 21:07:57 +00002092#define YYBACKUP(token, value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002093do \
2094 if (yychar == YYEMPTY && yylen == 1) \
Dale Johannesencdd509a2007-09-07 21:07:57 +00002095 { yychar = (token), yylval = (value); \
2096 yychar1 = YYTRANSLATE (yychar); \
Chris Lattner0275cff2007-08-06 21:00:46 +00002097 YYPOPSTACK; \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002098 goto yybackup; \
2099 } \
2100 else \
Dale Johannesencdd509a2007-09-07 21:07:57 +00002101 { yyerror ("syntax error: cannot back up"); YYERROR; } \
Chris Lattner0275cff2007-08-06 21:00:46 +00002102while (0)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002103
Reid Spencer68a24bd2005-08-27 18:50:39 +00002104#define YYTERROR 1
2105#define YYERRCODE 256
2106
Dale Johannesencdd509a2007-09-07 21:07:57 +00002107#ifndef YYPURE
2108#define YYLEX yylex()
Reid Spencer68a24bd2005-08-27 18:50:39 +00002109#endif
2110
Dale Johannesencdd509a2007-09-07 21:07:57 +00002111#ifdef YYPURE
2112#ifdef YYLSP_NEEDED
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002113#ifdef YYLEX_PARAM
Dale Johannesencdd509a2007-09-07 21:07:57 +00002114#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002115#else
Dale Johannesencdd509a2007-09-07 21:07:57 +00002116#define YYLEX yylex(&yylval, &yylloc)
2117#endif
2118#else /* not YYLSP_NEEDED */
2119#ifdef YYLEX_PARAM
2120#define YYLEX yylex(&yylval, YYLEX_PARAM)
2121#else
2122#define YYLEX yylex(&yylval)
2123#endif
2124#endif /* not YYLSP_NEEDED */
Chris Lattner0275cff2007-08-06 21:00:46 +00002125#endif
David Greene5fd22a82007-09-04 18:46:50 +00002126
Dale Johannesencdd509a2007-09-07 21:07:57 +00002127/* If nonreentrant, generate the variables here */
David Greene5fd22a82007-09-04 18:46:50 +00002128
Dale Johannesencdd509a2007-09-07 21:07:57 +00002129#ifndef YYPURE
David Greene5fd22a82007-09-04 18:46:50 +00002130
Dale Johannesencdd509a2007-09-07 21:07:57 +00002131int yychar; /* the lookahead symbol */
2132YYSTYPE yylval; /* the semantic value of the */
2133 /* lookahead symbol */
David Greene5fd22a82007-09-04 18:46:50 +00002134
Dale Johannesencdd509a2007-09-07 21:07:57 +00002135#ifdef YYLSP_NEEDED
2136YYLTYPE yylloc; /* location data for the lookahead */
2137 /* symbol */
Chris Lattner0275cff2007-08-06 21:00:46 +00002138#endif
David Greene5fd22a82007-09-04 18:46:50 +00002139
Dale Johannesencdd509a2007-09-07 21:07:57 +00002140int yynerrs; /* number of parse errors so far */
2141#endif /* not YYPURE */
David Greene5fd22a82007-09-04 18:46:50 +00002142
Dale Johannesencdd509a2007-09-07 21:07:57 +00002143#if YYDEBUG != 0
2144int yydebug; /* nonzero means print parse trace */
2145/* Since this is uninitialized, it does not stop multiple parsers
2146 from coexisting. */
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002147#endif
Chandler Carruth02202192007-08-04 01:56:21 +00002148
Dale Johannesencdd509a2007-09-07 21:07:57 +00002149/* YYINITDEPTH indicates the initial size of the parser's stacks */
Chandler Carruth02202192007-08-04 01:56:21 +00002150
Reid Spencer68a24bd2005-08-27 18:50:39 +00002151#ifndef YYINITDEPTH
Dale Johannesencdd509a2007-09-07 21:07:57 +00002152#define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00002153#endif
2154
Dale Johannesencdd509a2007-09-07 21:07:57 +00002155/* YYMAXDEPTH is the maximum size the stacks can grow to
2156 (effective only if the built-in stack extension method is used). */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002157
Dale Johannesencdd509a2007-09-07 21:07:57 +00002158#if YYMAXDEPTH == 0
2159#undef YYMAXDEPTH
Chris Lattner0275cff2007-08-06 21:00:46 +00002160#endif
David Greene718fda32007-08-01 03:59:32 +00002161
Reid Spencer68a24bd2005-08-27 18:50:39 +00002162#ifndef YYMAXDEPTH
Dale Johannesencdd509a2007-09-07 21:07:57 +00002163#define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00002164#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002165
Dale Johannesencdd509a2007-09-07 21:07:57 +00002166/* Define __yy_memcpy. Note that the size argument
2167 should be passed with type unsigned int, because that is what the non-GCC
2168 definitions require. With GCC, __builtin_memcpy takes an arg
2169 of type size_t, but it can handle unsigned int. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002170
Dale Johannesencdd509a2007-09-07 21:07:57 +00002171#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
2172#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
2173#else /* not GNU C or C++ */
2174#ifndef __cplusplus
Reid Spencer68a24bd2005-08-27 18:50:39 +00002175
Dale Johannesencdd509a2007-09-07 21:07:57 +00002176/* This is the most reliable way to avoid incompatibilities
2177 in available built-in functions on various systems. */
David Greene5fd22a82007-09-04 18:46:50 +00002178static void
Dale Johannesencdd509a2007-09-07 21:07:57 +00002179__yy_memcpy (to, from, count)
2180 char *to;
2181 char *from;
2182 unsigned int count;
2183{
2184 register char *f = from;
2185 register char *t = to;
2186 register int i = count;
2187
2188 while (i-- > 0)
2189 *t++ = *f++;
2190}
2191
2192#else /* __cplusplus */
2193
2194/* This is the most reliable way to avoid incompatibilities
2195 in available built-in functions on various systems. */
David Greene5fd22a82007-09-04 18:46:50 +00002196static void
Dale Johannesencdd509a2007-09-07 21:07:57 +00002197__yy_memcpy (char *to, char *from, unsigned int count)
2198{
2199 register char *t = to;
2200 register char *f = from;
2201 register int i = count;
2202
2203 while (i-- > 0)
2204 *t++ = *f++;
2205}
2206
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002207#endif
David Greene5fd22a82007-09-04 18:46:50 +00002208#endif
David Greene5fd22a82007-09-04 18:46:50 +00002209
Dale Johannesencdd509a2007-09-07 21:07:57 +00002210#line 217 "/usr/share/bison.simple"
David Greene5fd22a82007-09-04 18:46:50 +00002211
Dale Johannesencdd509a2007-09-07 21:07:57 +00002212/* The user can define YYPARSE_PARAM as the name of an argument to be passed
2213 into yyparse. The argument should have type void *.
2214 It should actually point to an object.
2215 Grammar actions can access the variable by casting it
2216 to the proper pointer type. */
David Greene5fd22a82007-09-04 18:46:50 +00002217
2218#ifdef YYPARSE_PARAM
Dale Johannesencdd509a2007-09-07 21:07:57 +00002219#ifdef __cplusplus
2220#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
2221#define YYPARSE_PARAM_DECL
2222#else /* not __cplusplus */
2223#define YYPARSE_PARAM_ARG YYPARSE_PARAM
2224#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
2225#endif /* not __cplusplus */
2226#else /* not YYPARSE_PARAM */
2227#define YYPARSE_PARAM_ARG
2228#define YYPARSE_PARAM_DECL
2229#endif /* not YYPARSE_PARAM */
2230
2231/* Prevent warning if -Wstrict-prototypes. */
2232#ifdef __GNUC__
2233#ifdef YYPARSE_PARAM
2234int yyparse (void *);
2235#else
David Greene5fd22a82007-09-04 18:46:50 +00002236int yyparse (void);
David Greene5fd22a82007-09-04 18:46:50 +00002237#endif
Dale Johannesencdd509a2007-09-07 21:07:57 +00002238#endif
David Greene5fd22a82007-09-04 18:46:50 +00002239
David Greene5fd22a82007-09-04 18:46:50 +00002240int
Dale Johannesencdd509a2007-09-07 21:07:57 +00002241yyparse(YYPARSE_PARAM_ARG)
2242 YYPARSE_PARAM_DECL
David Greene5fd22a82007-09-04 18:46:50 +00002243{
Chris Lattner0275cff2007-08-06 21:00:46 +00002244 register int yystate;
2245 register int yyn;
2246 register short *yyssp;
2247 register YYSTYPE *yyvsp;
Dale Johannesencdd509a2007-09-07 21:07:57 +00002248 int yyerrstatus; /* number of tokens to shift before error messages enabled */
2249 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
Chris Lattner0275cff2007-08-06 21:00:46 +00002250
Dale Johannesencdd509a2007-09-07 21:07:57 +00002251 short yyssa[YYINITDEPTH]; /* the state stack */
2252 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
Chris Lattner0275cff2007-08-06 21:00:46 +00002253
Dale Johannesencdd509a2007-09-07 21:07:57 +00002254 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
2255 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
Chris Lattner0275cff2007-08-06 21:00:46 +00002256
Dale Johannesencdd509a2007-09-07 21:07:57 +00002257#ifdef YYLSP_NEEDED
2258 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
2259 YYLTYPE *yyls = yylsa;
2260 YYLTYPE *yylsp;
2261
2262#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
2263#else
Chris Lattner0275cff2007-08-06 21:00:46 +00002264#define YYPOPSTACK (yyvsp--, yyssp--)
Dale Johannesencdd509a2007-09-07 21:07:57 +00002265#endif
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002266
Dale Johannesencdd509a2007-09-07 21:07:57 +00002267 int yystacksize = YYINITDEPTH;
2268 int yyfree_stacks = 0;
Chandler Carruth02202192007-08-04 01:56:21 +00002269
Dale Johannesencdd509a2007-09-07 21:07:57 +00002270#ifdef YYPURE
2271 int yychar;
2272 YYSTYPE yylval;
2273 int yynerrs;
2274#ifdef YYLSP_NEEDED
2275 YYLTYPE yylloc;
2276#endif
2277#endif
Chandler Carruth02202192007-08-04 01:56:21 +00002278
Dale Johannesencdd509a2007-09-07 21:07:57 +00002279 YYSTYPE yyval; /* the variable used to return */
2280 /* semantic values from the action */
2281 /* routines */
Chandler Carruth02202192007-08-04 01:56:21 +00002282
Chris Lattner0275cff2007-08-06 21:00:46 +00002283 int yylen;
Chandler Carruth02202192007-08-04 01:56:21 +00002284
Dale Johannesencdd509a2007-09-07 21:07:57 +00002285#if YYDEBUG != 0
2286 if (yydebug)
2287 fprintf(stderr, "Starting parse\n");
2288#endif
Chandler Carruth02202192007-08-04 01:56:21 +00002289
Reid Spencer68a24bd2005-08-27 18:50:39 +00002290 yystate = 0;
2291 yyerrstatus = 0;
2292 yynerrs = 0;
2293 yychar = YYEMPTY; /* Cause a token to be read. */
2294
2295 /* Initialize stack pointers.
2296 Waste one element of value and location stack
2297 so that they stay on the same level as the state stack.
2298 The wasted elements are never initialized. */
2299
Dale Johannesencdd509a2007-09-07 21:07:57 +00002300 yyssp = yyss - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002301 yyvsp = yyvs;
Dale Johannesencdd509a2007-09-07 21:07:57 +00002302#ifdef YYLSP_NEEDED
2303 yylsp = yyls;
2304#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002305
Dale Johannesencdd509a2007-09-07 21:07:57 +00002306/* Push a new state, which is found in yystate . */
2307/* In all cases, when you get here, the value and location stacks
2308 have just been pushed. so pushing a state here evens the stacks. */
2309yynewstate:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002310
Dale Johannesencdd509a2007-09-07 21:07:57 +00002311 *++yyssp = yystate;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002312
Dale Johannesencdd509a2007-09-07 21:07:57 +00002313 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002314 {
Dale Johannesencdd509a2007-09-07 21:07:57 +00002315 /* Give user a chance to reallocate the stack */
2316 /* Use copies of these so that the &'s don't force the real ones into memory. */
2317 YYSTYPE *yyvs1 = yyvs;
2318 short *yyss1 = yyss;
2319#ifdef YYLSP_NEEDED
2320 YYLTYPE *yyls1 = yyls;
2321#endif
2322
Reid Spencer68a24bd2005-08-27 18:50:39 +00002323 /* Get the current used size of the three stacks, in elements. */
Dale Johannesencdd509a2007-09-07 21:07:57 +00002324 int size = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002325
2326#ifdef yyoverflow
Dale Johannesencdd509a2007-09-07 21:07:57 +00002327 /* Each stack pointer address is followed by the size of
2328 the data in use in that stack, in bytes. */
2329#ifdef YYLSP_NEEDED
2330 /* This used to be a conditional around just the two extra args,
2331 but that might be undefined if yyoverflow is a macro. */
2332 yyoverflow("parser stack overflow",
2333 &yyss1, size * sizeof (*yyssp),
2334 &yyvs1, size * sizeof (*yyvsp),
2335 &yyls1, size * sizeof (*yylsp),
2336 &yystacksize);
2337#else
2338 yyoverflow("parser stack overflow",
2339 &yyss1, size * sizeof (*yyssp),
2340 &yyvs1, size * sizeof (*yyvsp),
2341 &yystacksize);
2342#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002343
Dale Johannesencdd509a2007-09-07 21:07:57 +00002344 yyss = yyss1; yyvs = yyvs1;
2345#ifdef YYLSP_NEEDED
2346 yyls = yyls1;
2347#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002348#else /* no yyoverflow */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002349 /* Extend the stack our own way. */
Dale Johannesencdd509a2007-09-07 21:07:57 +00002350 if (yystacksize >= YYMAXDEPTH)
2351 {
2352 yyerror("parser stack overflow");
2353 if (yyfree_stacks)
2354 {
2355 free (yyss);
2356 free (yyvs);
2357#ifdef YYLSP_NEEDED
2358 free (yyls);
2359#endif
2360 }
2361 return 2;
2362 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002363 yystacksize *= 2;
Dale Johannesencdd509a2007-09-07 21:07:57 +00002364 if (yystacksize > YYMAXDEPTH)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002365 yystacksize = YYMAXDEPTH;
Dale Johannesencdd509a2007-09-07 21:07:57 +00002366#ifndef YYSTACK_USE_ALLOCA
2367 yyfree_stacks = 1;
2368#endif
2369 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
2370 __yy_memcpy ((char *)yyss, (char *)yyss1,
2371 size * (unsigned int) sizeof (*yyssp));
2372 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
2373 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
2374 size * (unsigned int) sizeof (*yyvsp));
2375#ifdef YYLSP_NEEDED
2376 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
2377 __yy_memcpy ((char *)yyls, (char *)yyls1,
2378 size * (unsigned int) sizeof (*yylsp));
2379#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002380#endif /* no yyoverflow */
2381
Dale Johannesencdd509a2007-09-07 21:07:57 +00002382 yyssp = yyss + size - 1;
2383 yyvsp = yyvs + size - 1;
2384#ifdef YYLSP_NEEDED
2385 yylsp = yyls + size - 1;
2386#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002387
Dale Johannesencdd509a2007-09-07 21:07:57 +00002388#if YYDEBUG != 0
2389 if (yydebug)
2390 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2391#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002392
Dale Johannesencdd509a2007-09-07 21:07:57 +00002393 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002394 YYABORT;
2395 }
2396
Dale Johannesencdd509a2007-09-07 21:07:57 +00002397#if YYDEBUG != 0
2398 if (yydebug)
2399 fprintf(stderr, "Entering state %d\n", yystate);
2400#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002401
2402 goto yybackup;
Dale Johannesencdd509a2007-09-07 21:07:57 +00002403 yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002404
Chris Lattner0275cff2007-08-06 21:00:46 +00002405/* Do appropriate processing given the current state. */
2406/* Read a lookahead token if we need one and don't already have one. */
2407/* yyresume: */
Andrew Lenharth6353e052006-12-08 18:07:09 +00002408
Chris Lattner0275cff2007-08-06 21:00:46 +00002409 /* First try to decide what to do without reference to lookahead token. */
Reid Spencer7780acb2007-04-16 06:56:07 +00002410
Reid Spencer68a24bd2005-08-27 18:50:39 +00002411 yyn = yypact[yystate];
Dale Johannesencdd509a2007-09-07 21:07:57 +00002412 if (yyn == YYFLAG)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002413 goto yydefault;
2414
Chris Lattner0275cff2007-08-06 21:00:46 +00002415 /* Not known => get a lookahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002416
Dale Johannesencdd509a2007-09-07 21:07:57 +00002417 /* yychar is either YYEMPTY or YYEOF
2418 or a valid token in external form. */
2419
Reid Spencer68a24bd2005-08-27 18:50:39 +00002420 if (yychar == YYEMPTY)
2421 {
Dale Johannesencdd509a2007-09-07 21:07:57 +00002422#if YYDEBUG != 0
2423 if (yydebug)
2424 fprintf(stderr, "Reading a token: ");
2425#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002426 yychar = YYLEX;
2427 }
2428
Dale Johannesencdd509a2007-09-07 21:07:57 +00002429 /* Convert token to internal form (in yychar1) for indexing tables with */
2430
2431 if (yychar <= 0) /* This means end of input. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002432 {
Dale Johannesencdd509a2007-09-07 21:07:57 +00002433 yychar1 = 0;
2434 yychar = YYEOF; /* Don't call YYLEX any more */
2435
2436#if YYDEBUG != 0
2437 if (yydebug)
2438 fprintf(stderr, "Now at end of input.\n");
2439#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002440 }
2441 else
2442 {
Dale Johannesencdd509a2007-09-07 21:07:57 +00002443 yychar1 = YYTRANSLATE(yychar);
2444
2445#if YYDEBUG != 0
2446 if (yydebug)
2447 {
2448 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2449 /* Give the individual parser a way to print the precise meaning
2450 of a token, for further debugging info. */
2451#ifdef YYPRINT
2452 YYPRINT (stderr, yychar, yylval);
2453#endif
2454 fprintf (stderr, ")\n");
2455 }
2456#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002457 }
2458
Dale Johannesencdd509a2007-09-07 21:07:57 +00002459 yyn += yychar1;
2460 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002461 goto yydefault;
Dale Johannesencdd509a2007-09-07 21:07:57 +00002462
Reid Spencer68a24bd2005-08-27 18:50:39 +00002463 yyn = yytable[yyn];
Dale Johannesencdd509a2007-09-07 21:07:57 +00002464
2465 /* yyn is what to do for this token type in this state.
2466 Negative => reduce, -yyn is rule number.
2467 Positive => shift, yyn is new state.
2468 New state is final state => don't bother to shift,
2469 just return success.
2470 0, or most negative number => error. */
2471
2472 if (yyn < 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002473 {
Dale Johannesencdd509a2007-09-07 21:07:57 +00002474 if (yyn == YYFLAG)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002475 goto yyerrlab;
2476 yyn = -yyn;
2477 goto yyreduce;
2478 }
Dale Johannesencdd509a2007-09-07 21:07:57 +00002479 else if (yyn == 0)
2480 goto yyerrlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002481
2482 if (yyn == YYFINAL)
2483 YYACCEPT;
2484
Chris Lattner0275cff2007-08-06 21:00:46 +00002485 /* Shift the lookahead token. */
Dale Johannesencdd509a2007-09-07 21:07:57 +00002486
2487#if YYDEBUG != 0
2488 if (yydebug)
2489 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2490#endif
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002491
Chris Lattner0275cff2007-08-06 21:00:46 +00002492 /* Discard the token being shifted unless it is eof. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002493 if (yychar != YYEOF)
2494 yychar = YYEMPTY;
2495
Chandler Carruth02202192007-08-04 01:56:21 +00002496 *++yyvsp = yylval;
Dale Johannesencdd509a2007-09-07 21:07:57 +00002497#ifdef YYLSP_NEEDED
2498 *++yylsp = yylloc;
2499#endif
Chandler Carruth02202192007-08-04 01:56:21 +00002500
Dale Johannesencdd509a2007-09-07 21:07:57 +00002501 /* count tokens shifted since error; after three, turn off error status. */
2502 if (yyerrstatus) yyerrstatus--;
Chris Lattner0275cff2007-08-06 21:00:46 +00002503
2504 yystate = yyn;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002505 goto yynewstate;
2506
Dale Johannesencdd509a2007-09-07 21:07:57 +00002507/* Do the default action for the current state. */
David Greene5fd22a82007-09-04 18:46:50 +00002508yydefault:
Dale Johannesencdd509a2007-09-07 21:07:57 +00002509
Reid Spencer68a24bd2005-08-27 18:50:39 +00002510 yyn = yydefact[yystate];
2511 if (yyn == 0)
2512 goto yyerrlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002513
Dale Johannesencdd509a2007-09-07 21:07:57 +00002514/* Do a reduction. yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002515yyreduce:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002516 yylen = yyr2[yyn];
Dale Johannesencdd509a2007-09-07 21:07:57 +00002517 if (yylen > 0)
2518 yyval = yyvsp[1-yylen]; /* implement default value of the action */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002519
Dale Johannesencdd509a2007-09-07 21:07:57 +00002520#if YYDEBUG != 0
2521 if (yydebug)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002522 {
Dale Johannesencdd509a2007-09-07 21:07:57 +00002523 int i;
Reid Spencer41dff5e2007-01-26 08:05:27 +00002524
Dale Johannesencdd509a2007-09-07 21:07:57 +00002525 fprintf (stderr, "Reducing via rule %d (line %d), ",
2526 yyn, yyrline[yyn]);
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002527
Dale Johannesencdd509a2007-09-07 21:07:57 +00002528 /* Print the symbols being reduced, and their result. */
2529 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2530 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2531 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2532 }
2533#endif
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002534
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002535
Dale Johannesencdd509a2007-09-07 21:07:57 +00002536 switch (yyn) {
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002537
Dale Johannesencdd509a2007-09-07 21:07:57 +00002538case 28:
Chris Lattner569f7372007-09-10 23:24:14 +00002539#line 1132 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002540{ yyval.IPredicate = ICmpInst::ICMP_EQ; ;
2541 break;}
2542case 29:
Chris Lattner569f7372007-09-10 23:24:14 +00002543#line 1132 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002544{ yyval.IPredicate = ICmpInst::ICMP_NE; ;
2545 break;}
2546case 30:
Chris Lattner569f7372007-09-10 23:24:14 +00002547#line 1133 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002548{ yyval.IPredicate = ICmpInst::ICMP_SLT; ;
2549 break;}
2550case 31:
Chris Lattner569f7372007-09-10 23:24:14 +00002551#line 1133 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002552{ yyval.IPredicate = ICmpInst::ICMP_SGT; ;
2553 break;}
2554case 32:
Chris Lattner569f7372007-09-10 23:24:14 +00002555#line 1134 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002556{ yyval.IPredicate = ICmpInst::ICMP_SLE; ;
2557 break;}
2558case 33:
Chris Lattner569f7372007-09-10 23:24:14 +00002559#line 1134 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002560{ yyval.IPredicate = ICmpInst::ICMP_SGE; ;
2561 break;}
2562case 34:
Chris Lattner569f7372007-09-10 23:24:14 +00002563#line 1135 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002564{ yyval.IPredicate = ICmpInst::ICMP_ULT; ;
2565 break;}
2566case 35:
Chris Lattner569f7372007-09-10 23:24:14 +00002567#line 1135 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002568{ yyval.IPredicate = ICmpInst::ICMP_UGT; ;
2569 break;}
2570case 36:
Chris Lattner569f7372007-09-10 23:24:14 +00002571#line 1136 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002572{ yyval.IPredicate = ICmpInst::ICMP_ULE; ;
2573 break;}
2574case 37:
Chris Lattner569f7372007-09-10 23:24:14 +00002575#line 1136 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002576{ yyval.IPredicate = ICmpInst::ICMP_UGE; ;
2577 break;}
2578case 38:
Chris Lattner569f7372007-09-10 23:24:14 +00002579#line 1140 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002580{ yyval.FPredicate = FCmpInst::FCMP_OEQ; ;
2581 break;}
2582case 39:
Chris Lattner569f7372007-09-10 23:24:14 +00002583#line 1140 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002584{ yyval.FPredicate = FCmpInst::FCMP_ONE; ;
2585 break;}
2586case 40:
Chris Lattner569f7372007-09-10 23:24:14 +00002587#line 1141 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002588{ yyval.FPredicate = FCmpInst::FCMP_OLT; ;
2589 break;}
2590case 41:
Chris Lattner569f7372007-09-10 23:24:14 +00002591#line 1141 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002592{ yyval.FPredicate = FCmpInst::FCMP_OGT; ;
2593 break;}
2594case 42:
Chris Lattner569f7372007-09-10 23:24:14 +00002595#line 1142 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002596{ yyval.FPredicate = FCmpInst::FCMP_OLE; ;
2597 break;}
2598case 43:
Chris Lattner569f7372007-09-10 23:24:14 +00002599#line 1142 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002600{ yyval.FPredicate = FCmpInst::FCMP_OGE; ;
2601 break;}
2602case 44:
Chris Lattner569f7372007-09-10 23:24:14 +00002603#line 1143 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002604{ yyval.FPredicate = FCmpInst::FCMP_ORD; ;
2605 break;}
2606case 45:
Chris Lattner569f7372007-09-10 23:24:14 +00002607#line 1143 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002608{ yyval.FPredicate = FCmpInst::FCMP_UNO; ;
2609 break;}
2610case 46:
Chris Lattner569f7372007-09-10 23:24:14 +00002611#line 1144 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002612{ yyval.FPredicate = FCmpInst::FCMP_UEQ; ;
2613 break;}
2614case 47:
Chris Lattner569f7372007-09-10 23:24:14 +00002615#line 1144 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002616{ yyval.FPredicate = FCmpInst::FCMP_UNE; ;
2617 break;}
2618case 48:
Chris Lattner569f7372007-09-10 23:24:14 +00002619#line 1145 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002620{ yyval.FPredicate = FCmpInst::FCMP_ULT; ;
2621 break;}
2622case 49:
Chris Lattner569f7372007-09-10 23:24:14 +00002623#line 1145 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002624{ yyval.FPredicate = FCmpInst::FCMP_UGT; ;
2625 break;}
2626case 50:
Chris Lattner569f7372007-09-10 23:24:14 +00002627#line 1146 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002628{ yyval.FPredicate = FCmpInst::FCMP_ULE; ;
2629 break;}
2630case 51:
Chris Lattner569f7372007-09-10 23:24:14 +00002631#line 1146 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002632{ yyval.FPredicate = FCmpInst::FCMP_UGE; ;
2633 break;}
2634case 52:
Chris Lattner569f7372007-09-10 23:24:14 +00002635#line 1147 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002636{ yyval.FPredicate = FCmpInst::FCMP_TRUE; ;
2637 break;}
2638case 53:
Chris Lattner569f7372007-09-10 23:24:14 +00002639#line 1148 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002640{ yyval.FPredicate = FCmpInst::FCMP_FALSE; ;
2641 break;}
2642case 64:
Chris Lattner569f7372007-09-10 23:24:14 +00002643#line 1157 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002644{ yyval.StrVal = 0; ;
2645 break;}
2646case 65:
Chris Lattner569f7372007-09-10 23:24:14 +00002647#line 1161 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002648{
Chris Lattner0275cff2007-08-06 21:00:46 +00002649 yyval.StrVal = yyvsp[-1].StrVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00002650 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00002651 ;
2652 break;}
2653case 66:
Chris Lattner569f7372007-09-10 23:24:14 +00002654#line 1165 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002655{
Chris Lattner0275cff2007-08-06 21:00:46 +00002656 yyval.StrVal = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00002657 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00002658 ;
2659 break;}
2660case 70:
Chris Lattner569f7372007-09-10 23:24:14 +00002661#line 1173 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002662{
Chris Lattner0275cff2007-08-06 21:00:46 +00002663 yyval.StrVal = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00002664 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00002665 ;
2666 break;}
2667case 71:
Chris Lattner569f7372007-09-10 23:24:14 +00002668#line 1178 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002669{
Chris Lattner0275cff2007-08-06 21:00:46 +00002670 yyval.StrVal = yyvsp[-1].StrVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00002671 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00002672 ;
2673 break;}
2674case 72:
Chris Lattner569f7372007-09-10 23:24:14 +00002675#line 1184 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002676{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2677 break;}
2678case 73:
Chris Lattner569f7372007-09-10 23:24:14 +00002679#line 1185 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002680{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2681 break;}
2682case 74:
Chris Lattner569f7372007-09-10 23:24:14 +00002683#line 1186 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002684{ yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2685 break;}
2686case 75:
Chris Lattner569f7372007-09-10 23:24:14 +00002687#line 1187 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002688{ yyval.Linkage = GlobalValue::AppendingLinkage; ;
2689 break;}
2690case 76:
Chris Lattner569f7372007-09-10 23:24:14 +00002691#line 1188 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002692{ yyval.Linkage = GlobalValue::DLLExportLinkage; ;
2693 break;}
2694case 77:
Chris Lattner569f7372007-09-10 23:24:14 +00002695#line 1192 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002696{ yyval.Linkage = GlobalValue::DLLImportLinkage; ;
2697 break;}
2698case 78:
Chris Lattner569f7372007-09-10 23:24:14 +00002699#line 1193 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002700{ yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;
2701 break;}
2702case 79:
Chris Lattner569f7372007-09-10 23:24:14 +00002703#line 1194 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002704{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2705 break;}
2706case 80:
Chris Lattner569f7372007-09-10 23:24:14 +00002707#line 1198 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002708{ yyval.Visibility = GlobalValue::DefaultVisibility; ;
2709 break;}
2710case 81:
Chris Lattner569f7372007-09-10 23:24:14 +00002711#line 1199 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002712{ yyval.Visibility = GlobalValue::DefaultVisibility; ;
2713 break;}
2714case 82:
Chris Lattner569f7372007-09-10 23:24:14 +00002715#line 1200 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002716{ yyval.Visibility = GlobalValue::HiddenVisibility; ;
2717 break;}
2718case 83:
Chris Lattner569f7372007-09-10 23:24:14 +00002719#line 1201 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002720{ yyval.Visibility = GlobalValue::ProtectedVisibility; ;
2721 break;}
2722case 84:
Chris Lattner569f7372007-09-10 23:24:14 +00002723#line 1205 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002724{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2725 break;}
2726case 85:
Chris Lattner569f7372007-09-10 23:24:14 +00002727#line 1206 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002728{ yyval.Linkage = GlobalValue::DLLImportLinkage; ;
2729 break;}
2730case 86:
Chris Lattner569f7372007-09-10 23:24:14 +00002731#line 1207 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002732{ yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;
2733 break;}
2734case 87:
Chris Lattner569f7372007-09-10 23:24:14 +00002735#line 1211 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002736{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2737 break;}
2738case 88:
Chris Lattner569f7372007-09-10 23:24:14 +00002739#line 1212 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002740{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2741 break;}
2742case 89:
Chris Lattner569f7372007-09-10 23:24:14 +00002743#line 1213 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002744{ yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2745 break;}
2746case 90:
Chris Lattner569f7372007-09-10 23:24:14 +00002747#line 1214 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002748{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2749 break;}
2750case 91:
Chris Lattner569f7372007-09-10 23:24:14 +00002751#line 1215 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002752{ yyval.Linkage = GlobalValue::DLLExportLinkage; ;
2753 break;}
2754case 92:
Chris Lattner569f7372007-09-10 23:24:14 +00002755#line 1219 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002756{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2757 break;}
2758case 93:
Chris Lattner569f7372007-09-10 23:24:14 +00002759#line 1220 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002760{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2761 break;}
2762case 94:
Chris Lattner569f7372007-09-10 23:24:14 +00002763#line 1221 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002764{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2765 break;}
2766case 95:
Chris Lattner569f7372007-09-10 23:24:14 +00002767#line 1224 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002768{ yyval.UIntVal = CallingConv::C; ;
2769 break;}
2770case 96:
Chris Lattner569f7372007-09-10 23:24:14 +00002771#line 1225 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002772{ yyval.UIntVal = CallingConv::C; ;
2773 break;}
2774case 97:
Chris Lattner569f7372007-09-10 23:24:14 +00002775#line 1226 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002776{ yyval.UIntVal = CallingConv::Fast; ;
2777 break;}
2778case 98:
Chris Lattner569f7372007-09-10 23:24:14 +00002779#line 1227 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002780{ yyval.UIntVal = CallingConv::Cold; ;
2781 break;}
2782case 99:
Chris Lattner569f7372007-09-10 23:24:14 +00002783#line 1228 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002784{ yyval.UIntVal = CallingConv::X86_StdCall; ;
2785 break;}
2786case 100:
Chris Lattner569f7372007-09-10 23:24:14 +00002787#line 1229 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002788{ yyval.UIntVal = CallingConv::X86_FastCall; ;
2789 break;}
2790case 101:
Chris Lattner569f7372007-09-10 23:24:14 +00002791#line 1230 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002792{
Chris Lattner0275cff2007-08-06 21:00:46 +00002793 if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002794 GEN_ERROR("Calling conv too large");
Chris Lattner0275cff2007-08-06 21:00:46 +00002795 yyval.UIntVal = yyvsp[0].UInt64Val;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002796 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00002797 ;
2798 break;}
2799case 102:
Chris Lattner569f7372007-09-10 23:24:14 +00002800#line 1237 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002801{ yyval.ParamAttrs = ParamAttr::ZExt; ;
2802 break;}
2803case 103:
Chris Lattner569f7372007-09-10 23:24:14 +00002804#line 1238 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002805{ yyval.ParamAttrs = ParamAttr::ZExt; ;
2806 break;}
2807case 104:
Chris Lattner569f7372007-09-10 23:24:14 +00002808#line 1239 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002809{ yyval.ParamAttrs = ParamAttr::SExt; ;
2810 break;}
2811case 105:
Chris Lattner569f7372007-09-10 23:24:14 +00002812#line 1240 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002813{ yyval.ParamAttrs = ParamAttr::SExt; ;
2814 break;}
2815case 106:
Chris Lattner569f7372007-09-10 23:24:14 +00002816#line 1241 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002817{ yyval.ParamAttrs = ParamAttr::InReg; ;
2818 break;}
2819case 107:
Chris Lattner569f7372007-09-10 23:24:14 +00002820#line 1242 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002821{ yyval.ParamAttrs = ParamAttr::StructRet; ;
2822 break;}
2823case 108:
Chris Lattner569f7372007-09-10 23:24:14 +00002824#line 1243 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002825{ yyval.ParamAttrs = ParamAttr::NoAlias; ;
2826 break;}
2827case 109:
Chris Lattner569f7372007-09-10 23:24:14 +00002828#line 1244 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002829{ yyval.ParamAttrs = ParamAttr::ByVal; ;
2830 break;}
2831case 110:
Chris Lattner569f7372007-09-10 23:24:14 +00002832#line 1245 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002833{ yyval.ParamAttrs = ParamAttr::Nest; ;
2834 break;}
2835case 111:
Chris Lattner569f7372007-09-10 23:24:14 +00002836#line 1248 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002837{ yyval.ParamAttrs = ParamAttr::None; ;
2838 break;}
2839case 112:
Chris Lattner569f7372007-09-10 23:24:14 +00002840#line 1249 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002841{
Chris Lattner0275cff2007-08-06 21:00:46 +00002842 yyval.ParamAttrs = yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs;
Dale Johannesencdd509a2007-09-07 21:07:57 +00002843 ;
2844 break;}
2845case 113:
Chris Lattner569f7372007-09-10 23:24:14 +00002846#line 1254 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002847{ yyval.ParamAttrs = ParamAttr::NoReturn; ;
2848 break;}
2849case 114:
Chris Lattner569f7372007-09-10 23:24:14 +00002850#line 1255 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002851{ yyval.ParamAttrs = ParamAttr::NoUnwind; ;
2852 break;}
2853case 115:
Chris Lattner569f7372007-09-10 23:24:14 +00002854#line 1256 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002855{ yyval.ParamAttrs = ParamAttr::ZExt; ;
2856 break;}
2857case 116:
Chris Lattner569f7372007-09-10 23:24:14 +00002858#line 1257 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002859{ yyval.ParamAttrs = ParamAttr::SExt; ;
2860 break;}
2861case 117:
Chris Lattner569f7372007-09-10 23:24:14 +00002862#line 1260 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002863{ yyval.ParamAttrs = ParamAttr::None; ;
2864 break;}
2865case 118:
Chris Lattner569f7372007-09-10 23:24:14 +00002866#line 1261 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002867{
Chris Lattner0275cff2007-08-06 21:00:46 +00002868 yyval.ParamAttrs = yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs;
Dale Johannesencdd509a2007-09-07 21:07:57 +00002869 ;
2870 break;}
2871case 119:
Chris Lattner569f7372007-09-10 23:24:14 +00002872#line 1268 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002873{ yyval.UIntVal = 0; ;
2874 break;}
2875case 120:
Chris Lattner569f7372007-09-10 23:24:14 +00002876#line 1269 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002877{
Chris Lattner0275cff2007-08-06 21:00:46 +00002878 yyval.UIntVal = yyvsp[0].UInt64Val;
2879 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002880 GEN_ERROR("Alignment must be a power of two");
2881 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00002882;
2883 break;}
2884case 121:
Chris Lattner569f7372007-09-10 23:24:14 +00002885#line 1275 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002886{ yyval.UIntVal = 0; ;
2887 break;}
2888case 122:
Chris Lattner569f7372007-09-10 23:24:14 +00002889#line 1276 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002890{
Chris Lattner0275cff2007-08-06 21:00:46 +00002891 yyval.UIntVal = yyvsp[0].UInt64Val;
2892 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002893 GEN_ERROR("Alignment must be a power of two");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002894 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00002895;
2896 break;}
2897case 123:
Chris Lattner569f7372007-09-10 23:24:14 +00002898#line 1284 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002899{
Chris Lattner0275cff2007-08-06 21:00:46 +00002900 for (unsigned i = 0, e = yyvsp[0].StrVal->length(); i != e; ++i)
2901 if ((*yyvsp[0].StrVal)[i] == '"' || (*yyvsp[0].StrVal)[i] == '\\')
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002902 GEN_ERROR("Invalid character in section name");
Chris Lattner0275cff2007-08-06 21:00:46 +00002903 yyval.StrVal = yyvsp[0].StrVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002904 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00002905;
2906 break;}
2907case 124:
Chris Lattner569f7372007-09-10 23:24:14 +00002908#line 1292 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002909{ yyval.StrVal = 0; ;
2910 break;}
2911case 125:
Chris Lattner569f7372007-09-10 23:24:14 +00002912#line 1293 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002913{ yyval.StrVal = yyvsp[0].StrVal; ;
2914 break;}
2915case 126:
Chris Lattner569f7372007-09-10 23:24:14 +00002916#line 1298 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002917{;
2918 break;}
2919case 127:
Chris Lattner569f7372007-09-10 23:24:14 +00002920#line 1299 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002921{;
2922 break;}
2923case 128:
Chris Lattner569f7372007-09-10 23:24:14 +00002924#line 1300 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002925{
Chris Lattner0275cff2007-08-06 21:00:46 +00002926 CurGV->setSection(*yyvsp[0].StrVal);
2927 delete yyvsp[0].StrVal;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002928 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00002929 ;
2930 break;}
2931case 129:
Chris Lattner569f7372007-09-10 23:24:14 +00002932#line 1305 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002933{
Chris Lattner0275cff2007-08-06 21:00:46 +00002934 if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002935 GEN_ERROR("Alignment must be a power of two");
Chris Lattner0275cff2007-08-06 21:00:46 +00002936 CurGV->setAlignment(yyvsp[0].UInt64Val);
Reid Spencer41dff5e2007-01-26 08:05:27 +00002937 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00002938 ;
2939 break;}
2940case 137:
Chris Lattner569f7372007-09-10 23:24:14 +00002941#line 1321 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002942{
Chris Lattner0275cff2007-08-06 21:00:46 +00002943 yyval.TypeVal = new PATypeHolder(OpaqueType::get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00002944 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00002945 ;
2946 break;}
2947case 138:
Chris Lattner569f7372007-09-10 23:24:14 +00002948#line 1325 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002949{
Chris Lattner0275cff2007-08-06 21:00:46 +00002950 yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002951 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00002952 ;
2953 break;}
2954case 139:
Chris Lattner569f7372007-09-10 23:24:14 +00002955#line 1329 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002956{ // Pointer type?
Chris Lattner0275cff2007-08-06 21:00:46 +00002957 if (*yyvsp[-1].TypeVal == Type::LabelTy)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002958 GEN_ERROR("Cannot form a pointer to a basic block");
Chris Lattner0275cff2007-08-06 21:00:46 +00002959 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal)));
2960 delete yyvsp[-1].TypeVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00002961 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00002962 ;
2963 break;}
2964case 140:
Chris Lattner569f7372007-09-10 23:24:14 +00002965#line 1336 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002966{ // Named types are also simple types...
Chris Lattner0275cff2007-08-06 21:00:46 +00002967 const Type* tmp = getTypeVal(yyvsp[0].ValIDVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00002968 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00002969 yyval.TypeVal = new PATypeHolder(tmp);
Dale Johannesencdd509a2007-09-07 21:07:57 +00002970 ;
2971 break;}
2972case 141:
Chris Lattner569f7372007-09-10 23:24:14 +00002973#line 1341 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002974{ // Type UpReference
Chris Lattner0275cff2007-08-06 21:00:46 +00002975 if (yyvsp[0].UInt64Val > (uint64_t)~0U) GEN_ERROR("Value out of range");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002976 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Chris Lattner0275cff2007-08-06 21:00:46 +00002977 UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector...
2978 yyval.TypeVal = new PATypeHolder(OT);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002979 UR_OUT("New Upreference!\n");
2980 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00002981 ;
2982 break;}
2983case 142:
Chris Lattner569f7372007-09-10 23:24:14 +00002984#line 1349 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002985{
Reid Spencer41dff5e2007-01-26 08:05:27 +00002986 std::vector<const Type*> Params;
Christopher Lamb5c104242007-04-22 20:09:11 +00002987 ParamAttrsVector Attrs;
Chris Lattner0275cff2007-08-06 21:00:46 +00002988 if (yyvsp[0].ParamAttrs != ParamAttr::None) {
2989 ParamAttrsWithIndex X; X.index = 0; X.attrs = yyvsp[0].ParamAttrs;
Christopher Lamb5c104242007-04-22 20:09:11 +00002990 Attrs.push_back(X);
2991 }
Reid Spencer7b5d4662007-04-09 06:16:21 +00002992 unsigned index = 1;
Chris Lattner0275cff2007-08-06 21:00:46 +00002993 TypeWithAttrsList::iterator I = yyvsp[-2].TypeWithAttrsList->begin(), E = yyvsp[-2].TypeWithAttrsList->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00002994 for (; I != E; ++I, ++index) {
Reid Spencer66728ef2007-03-20 01:13:36 +00002995 const Type *Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00002996 Params.push_back(Ty);
2997 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00002998 if (I->Attrs != ParamAttr::None) {
2999 ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs;
3000 Attrs.push_back(X);
3001 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00003002 }
3003 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3004 if (isVarArg) Params.pop_back();
3005
Reid Spencer7b5d4662007-04-09 06:16:21 +00003006 ParamAttrsList *ActualAttrs = 0;
3007 if (!Attrs.empty())
Christopher Lamb5c104242007-04-22 20:09:11 +00003008 ActualAttrs = ParamAttrsList::get(Attrs);
Chris Lattner0275cff2007-08-06 21:00:46 +00003009 FunctionType *FT = FunctionType::get(*yyvsp[-4].TypeVal, Params, isVarArg, ActualAttrs);
3010 delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list
3011 delete yyvsp[-4].TypeVal; // Delete the return type handle
3012 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT));
Reid Spencere4d87aa2006-12-23 06:05:41 +00003013 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003014 ;
3015 break;}
3016case 143:
Chris Lattner569f7372007-09-10 23:24:14 +00003017#line 1379 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003018{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003019 std::vector<const Type*> Params;
Christopher Lamb5c104242007-04-22 20:09:11 +00003020 ParamAttrsVector Attrs;
Chris Lattner0275cff2007-08-06 21:00:46 +00003021 if (yyvsp[0].ParamAttrs != ParamAttr::None) {
3022 ParamAttrsWithIndex X; X.index = 0; X.attrs = yyvsp[0].ParamAttrs;
Christopher Lamb5c104242007-04-22 20:09:11 +00003023 Attrs.push_back(X);
3024 }
Chris Lattner0275cff2007-08-06 21:00:46 +00003025 TypeWithAttrsList::iterator I = yyvsp[-2].TypeWithAttrsList->begin(), E = yyvsp[-2].TypeWithAttrsList->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00003026 unsigned index = 1;
3027 for ( ; I != E; ++I, ++index) {
Reid Spencer66728ef2007-03-20 01:13:36 +00003028 const Type* Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00003029 Params.push_back(Ty);
3030 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00003031 if (I->Attrs != ParamAttr::None) {
3032 ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs;
3033 Attrs.push_back(X);
3034 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003035 }
3036 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3037 if (isVarArg) Params.pop_back();
3038
Reid Spencer7b5d4662007-04-09 06:16:21 +00003039 ParamAttrsList *ActualAttrs = 0;
3040 if (!Attrs.empty())
Christopher Lamb5c104242007-04-22 20:09:11 +00003041 ActualAttrs = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00003042
Chris Lattner0275cff2007-08-06 21:00:46 +00003043 FunctionType *FT = FunctionType::get(yyvsp[-4].PrimType, Params, isVarArg, ActualAttrs);
3044 delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list
3045 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003046 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003047 ;
3048 break;}
3049case 144:
Chris Lattner569f7372007-09-10 23:24:14 +00003050#line 1410 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003051{ // Sized array type?
Chris Lattner0275cff2007-08-06 21:00:46 +00003052 yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
3053 delete yyvsp[-1].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003054 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003055 ;
3056 break;}
3057case 145:
Chris Lattner569f7372007-09-10 23:24:14 +00003058#line 1415 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003059{ // Vector type?
Chris Lattner0275cff2007-08-06 21:00:46 +00003060 const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
3061 if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003062 GEN_ERROR("Unsigned result not equal to signed result");
3063 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
3064 GEN_ERROR("Element type of a VectorType must be primitive");
Chris Lattner0275cff2007-08-06 21:00:46 +00003065 if (!isPowerOf2_32(yyvsp[-3].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003066 GEN_ERROR("Vector length should be a power of 2");
Chris Lattner0275cff2007-08-06 21:00:46 +00003067 yyval.TypeVal = new PATypeHolder(HandleUpRefs(VectorType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
3068 delete yyvsp[-1].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003069 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003070 ;
3071 break;}
3072case 146:
Chris Lattner569f7372007-09-10 23:24:14 +00003073#line 1427 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003074{ // Structure type?
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003075 std::vector<const Type*> Elements;
Chris Lattner0275cff2007-08-06 21:00:46 +00003076 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
3077 E = yyvsp[-1].TypeList->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003078 Elements.push_back(*I);
3079
Chris Lattner0275cff2007-08-06 21:00:46 +00003080 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
3081 delete yyvsp[-1].TypeList;
Reid Spencer14310612006-12-31 05:40:51 +00003082 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003083 ;
3084 break;}
3085case 147:
Chris Lattner569f7372007-09-10 23:24:14 +00003086#line 1437 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003087{ // Empty structure type?
Chris Lattner0275cff2007-08-06 21:00:46 +00003088 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer14310612006-12-31 05:40:51 +00003089 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003090 ;
3091 break;}
3092case 148:
Chris Lattner569f7372007-09-10 23:24:14 +00003093#line 1441 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003094{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003095 std::vector<const Type*> Elements;
Chris Lattner0275cff2007-08-06 21:00:46 +00003096 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-2].TypeList->begin(),
3097 E = yyvsp[-2].TypeList->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003098 Elements.push_back(*I);
3099
Chris Lattner0275cff2007-08-06 21:00:46 +00003100 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
3101 delete yyvsp[-2].TypeList;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003102 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003103 ;
3104 break;}
3105case 149:
Chris Lattner569f7372007-09-10 23:24:14 +00003106#line 1451 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003107{ // Empty structure type?
Chris Lattner0275cff2007-08-06 21:00:46 +00003108 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003109 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003110 ;
3111 break;}
3112case 150:
Chris Lattner569f7372007-09-10 23:24:14 +00003113#line 1458 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003114{
Chris Lattner0275cff2007-08-06 21:00:46 +00003115 yyval.TypeWithAttrs.Ty = yyvsp[-1].TypeVal;
3116 yyval.TypeWithAttrs.Attrs = yyvsp[0].ParamAttrs;
Dale Johannesencdd509a2007-09-07 21:07:57 +00003117 ;
3118 break;}
3119case 151:
Chris Lattner569f7372007-09-10 23:24:14 +00003120#line 1465 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003121{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003122 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003123 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
3124 if (!(*yyvsp[0].TypeVal)->isFirstClassType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003125 GEN_ERROR("LLVM functions cannot return aggregate types");
Chris Lattner0275cff2007-08-06 21:00:46 +00003126 yyval.TypeVal = yyvsp[0].TypeVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00003127 ;
3128 break;}
3129case 152:
Chris Lattner569f7372007-09-10 23:24:14 +00003130#line 1472 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003131{
Chris Lattner0275cff2007-08-06 21:00:46 +00003132 yyval.TypeVal = new PATypeHolder(Type::VoidTy);
Dale Johannesencdd509a2007-09-07 21:07:57 +00003133 ;
3134 break;}
3135case 153:
Chris Lattner569f7372007-09-10 23:24:14 +00003136#line 1477 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003137{
Chris Lattner0275cff2007-08-06 21:00:46 +00003138 yyval.TypeWithAttrsList = new TypeWithAttrsList();
3139 yyval.TypeWithAttrsList->push_back(yyvsp[0].TypeWithAttrs);
Reid Spencer3da59db2006-11-27 01:05:10 +00003140 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003141 ;
3142 break;}
3143case 154:
Chris Lattner569f7372007-09-10 23:24:14 +00003144#line 1482 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003145{
Chris Lattner0275cff2007-08-06 21:00:46 +00003146 (yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList)->push_back(yyvsp[0].TypeWithAttrs);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003147 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003148 ;
3149 break;}
3150case 156:
Chris Lattner569f7372007-09-10 23:24:14 +00003151#line 1490 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003152{
Chris Lattner0275cff2007-08-06 21:00:46 +00003153 yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList;
Reid Spencer18da0722007-04-11 02:44:20 +00003154 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003155 TWA.Ty = new PATypeHolder(Type::VoidTy);
Chris Lattner0275cff2007-08-06 21:00:46 +00003156 yyval.TypeWithAttrsList->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003157 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003158 ;
3159 break;}
3160case 157:
Chris Lattner569f7372007-09-10 23:24:14 +00003161#line 1497 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003162{
Chris Lattner0275cff2007-08-06 21:00:46 +00003163 yyval.TypeWithAttrsList = new TypeWithAttrsList;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003164 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
3165 TWA.Ty = new PATypeHolder(Type::VoidTy);
Chris Lattner0275cff2007-08-06 21:00:46 +00003166 yyval.TypeWithAttrsList->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003167 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003168 ;
3169 break;}
3170case 158:
Chris Lattner569f7372007-09-10 23:24:14 +00003171#line 1504 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003172{
Chris Lattner0275cff2007-08-06 21:00:46 +00003173 yyval.TypeWithAttrsList = new TypeWithAttrsList();
Reid Spencer41dff5e2007-01-26 08:05:27 +00003174 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003175 ;
3176 break;}
3177case 159:
Chris Lattner569f7372007-09-10 23:24:14 +00003178#line 1512 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003179{
Chris Lattner0275cff2007-08-06 21:00:46 +00003180 yyval.TypeList = new std::list<PATypeHolder>();
3181 yyval.TypeList->push_back(*yyvsp[0].TypeVal);
3182 delete yyvsp[0].TypeVal;
Reid Spencer3da59db2006-11-27 01:05:10 +00003183 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003184 ;
3185 break;}
3186case 160:
Chris Lattner569f7372007-09-10 23:24:14 +00003187#line 1518 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003188{
Chris Lattner0275cff2007-08-06 21:00:46 +00003189 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal);
3190 delete yyvsp[0].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003191 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003192 ;
3193 break;}
3194case 161:
Chris Lattner569f7372007-09-10 23:24:14 +00003195#line 1530 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003196{ // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00003197 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003198 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
3199 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003200 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003201 GEN_ERROR("Cannot make array constant with type: '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00003202 (*yyvsp[-3].TypeVal)->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003203 const Type *ETy = ATy->getElementType();
3204 int NumElements = ATy->getNumElements();
3205
3206 // Verify that we have the correct size...
Chris Lattner0275cff2007-08-06 21:00:46 +00003207 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003208 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Chris Lattner0275cff2007-08-06 21:00:46 +00003209 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00003210 itostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003211
3212 // Verify all elements are correct type!
Chris Lattner0275cff2007-08-06 21:00:46 +00003213 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3214 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003215 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3216 ETy->getDescription() +"' as required!\nIt is of type '"+
Chris Lattner0275cff2007-08-06 21:00:46 +00003217 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003218 }
3219
Chris Lattner0275cff2007-08-06 21:00:46 +00003220 yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
3221 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003222 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003223 ;
3224 break;}
3225case 162:
Chris Lattner569f7372007-09-10 23:24:14 +00003226#line 1558 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003227{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003228 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003229 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3230 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003231 if (ATy == 0)
3232 GEN_ERROR("Cannot make array constant with type: '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00003233 (*yyvsp[-2].TypeVal)->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003234
Andrew Lenharth6353e052006-12-08 18:07:09 +00003235 int NumElements = ATy->getNumElements();
3236 if (NumElements != -1 && NumElements != 0)
3237 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Reid Spencerb5334b02007-02-05 10:18:06 +00003238 " arguments, but has size of " + itostr(NumElements) +"");
Chris Lattner0275cff2007-08-06 21:00:46 +00003239 yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
3240 delete yyvsp[-2].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00003241 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003242 ;
3243 break;}
3244case 163:
Chris Lattner569f7372007-09-10 23:24:14 +00003245#line 1574 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003246{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003247 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003248 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3249 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003250 if (ATy == 0)
3251 GEN_ERROR("Cannot make array constant with type: '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00003252 (*yyvsp[-2].TypeVal)->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003253
3254 int NumElements = ATy->getNumElements();
3255 const Type *ETy = ATy->getElementType();
Chris Lattner0275cff2007-08-06 21:00:46 +00003256 if (NumElements != -1 && NumElements != int(yyvsp[0].StrVal->length()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003257 GEN_ERROR("Can't build string constant of size " +
Chris Lattner0275cff2007-08-06 21:00:46 +00003258 itostr((int)(yyvsp[0].StrVal->length())) +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003259 " when array has size " + itostr(NumElements) + "");
3260 std::vector<Constant*> Vals;
3261 if (ETy == Type::Int8Ty) {
Chris Lattner0275cff2007-08-06 21:00:46 +00003262 for (unsigned i = 0; i < yyvsp[0].StrVal->length(); ++i)
3263 Vals.push_back(ConstantInt::get(ETy, (*yyvsp[0].StrVal)[i]));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003264 } else {
Chris Lattner0275cff2007-08-06 21:00:46 +00003265 delete yyvsp[0].StrVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003266 GEN_ERROR("Cannot build string arrays of non byte sized elements");
3267 }
Chris Lattner0275cff2007-08-06 21:00:46 +00003268 delete yyvsp[0].StrVal;
3269 yyval.ConstVal = ConstantArray::get(ATy, Vals);
3270 delete yyvsp[-2].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003271 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003272 ;
3273 break;}
3274case 164:
Chris Lattner569f7372007-09-10 23:24:14 +00003275#line 1601 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003276{ // Nonempty unsized arr
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003277 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003278 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
3279 const VectorType *PTy = dyn_cast<VectorType>(yyvsp[-3].TypeVal->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003280 if (PTy == 0)
3281 GEN_ERROR("Cannot make packed constant with type: '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00003282 (*yyvsp[-3].TypeVal)->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003283 const Type *ETy = PTy->getElementType();
3284 int NumElements = PTy->getNumElements();
Reid Spencer41dff5e2007-01-26 08:05:27 +00003285
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003286 // Verify that we have the correct size...
Chris Lattner0275cff2007-08-06 21:00:46 +00003287 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003288 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Chris Lattner0275cff2007-08-06 21:00:46 +00003289 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00003290 itostr(NumElements) + "");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003291
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003292 // Verify all elements are correct type!
Chris Lattner0275cff2007-08-06 21:00:46 +00003293 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3294 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003295 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3296 ETy->getDescription() +"' as required!\nIt is of type '"+
Chris Lattner0275cff2007-08-06 21:00:46 +00003297 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003298 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00003299
Chris Lattner0275cff2007-08-06 21:00:46 +00003300 yyval.ConstVal = ConstantVector::get(PTy, *yyvsp[-1].ConstVector);
3301 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003302 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003303 ;
3304 break;}
3305case 165:
Chris Lattner569f7372007-09-10 23:24:14 +00003306#line 1629 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003307{
Chris Lattner0275cff2007-08-06 21:00:46 +00003308 const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003309 if (STy == 0)
3310 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00003311 (*yyvsp[-3].TypeVal)->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003312
Chris Lattner0275cff2007-08-06 21:00:46 +00003313 if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003314 GEN_ERROR("Illegal number of initializers for structure type");
3315
3316 // Check to ensure that constants are compatible with the type initializer!
Chris Lattner0275cff2007-08-06 21:00:46 +00003317 for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
3318 if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003319 GEN_ERROR("Expected type '" +
3320 STy->getElementType(i)->getDescription() +
3321 "' for element #" + utostr(i) +
3322 " of structure initializer");
3323
3324 // Check to ensure that Type is not packed
3325 if (STy->isPacked())
3326 GEN_ERROR("Unpacked Initializer to vector type '" +
3327 STy->getDescription() + "'");
3328
Chris Lattner0275cff2007-08-06 21:00:46 +00003329 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
3330 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003331 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003332 ;
3333 break;}
3334case 166:
Chris Lattner569f7372007-09-10 23:24:14 +00003335#line 1655 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003336{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003337 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003338 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3339 const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003340 if (STy == 0)
3341 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00003342 (*yyvsp[-2].TypeVal)->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003343
3344 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003345 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003346
3347 // Check to ensure that Type is not packed
3348 if (STy->isPacked())
Chris Lattner6cdc6822007-04-26 05:31:05 +00003349 GEN_ERROR("Unpacked Initializer to vector type '" +
3350 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003351
Chris Lattner0275cff2007-08-06 21:00:46 +00003352 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
3353 delete yyvsp[-2].TypeVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003354 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003355 ;
3356 break;}
3357case 167:
Chris Lattner569f7372007-09-10 23:24:14 +00003358#line 1675 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003359{
Chris Lattner0275cff2007-08-06 21:00:46 +00003360 const StructType *STy = dyn_cast<StructType>(yyvsp[-5].TypeVal->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003361 if (STy == 0)
3362 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00003363 (*yyvsp[-5].TypeVal)->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003364
Chris Lattner0275cff2007-08-06 21:00:46 +00003365 if (yyvsp[-2].ConstVector->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00003366 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003367
3368 // Check to ensure that constants are compatible with the type initializer!
Chris Lattner0275cff2007-08-06 21:00:46 +00003369 for (unsigned i = 0, e = yyvsp[-2].ConstVector->size(); i != e; ++i)
3370 if ((*yyvsp[-2].ConstVector)[i]->getType() != STy->getElementType(i))
Reid Spencer41dff5e2007-01-26 08:05:27 +00003371 GEN_ERROR("Expected type '" +
3372 STy->getElementType(i)->getDescription() +
3373 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00003374 " of structure initializer");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003375
3376 // Check to ensure that Type is packed
3377 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00003378 GEN_ERROR("Vector initializer to non-vector type '" +
3379 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003380
Chris Lattner0275cff2007-08-06 21:00:46 +00003381 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-2].ConstVector);
3382 delete yyvsp[-5].TypeVal; delete yyvsp[-2].ConstVector;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003383 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003384 ;
3385 break;}
3386case 168:
Chris Lattner569f7372007-09-10 23:24:14 +00003387#line 1701 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003388{
Reid Spencer41dff5e2007-01-26 08:05:27 +00003389 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003390 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
3391 const StructType *STy = dyn_cast<StructType>(yyvsp[-4].TypeVal->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003392 if (STy == 0)
3393 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00003394 (*yyvsp[-4].TypeVal)->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003395
3396 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003397 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003398
3399 // Check to ensure that Type is packed
3400 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00003401 GEN_ERROR("Vector initializer to non-vector type '" +
3402 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003403
Chris Lattner0275cff2007-08-06 21:00:46 +00003404 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
3405 delete yyvsp[-4].TypeVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003406 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003407 ;
3408 break;}
3409case 169:
Chris Lattner569f7372007-09-10 23:24:14 +00003410#line 1721 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003411{
Reid Spencer41dff5e2007-01-26 08:05:27 +00003412 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003413 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3414 const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003415 if (PTy == 0)
3416 GEN_ERROR("Cannot make null pointer constant with type: '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00003417 (*yyvsp[-1].TypeVal)->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003418
Chris Lattner0275cff2007-08-06 21:00:46 +00003419 yyval.ConstVal = ConstantPointerNull::get(PTy);
3420 delete yyvsp[-1].TypeVal;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003421 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003422 ;
3423 break;}
3424case 170:
Chris Lattner569f7372007-09-10 23:24:14 +00003425#line 1733 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003426{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003427 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003428 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3429 yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
3430 delete yyvsp[-1].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003431 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003432 ;
3433 break;}
3434case 171:
Chris Lattner569f7372007-09-10 23:24:14 +00003435#line 1740 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003436{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003437 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003438 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3439 const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003440 if (Ty == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003441 GEN_ERROR("Global const reference must be a pointer type");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003442
3443 // ConstExprs can exist in the body of a function, thus creating
3444 // GlobalValues whenever they refer to a variable. Because we are in
Reid Spencer93c40032007-03-19 18:40:50 +00003445 // the context of a function, getExistingVal will search the functions
Reid Spencer68a24bd2005-08-27 18:50:39 +00003446 // symbol table instead of the module symbol table for the global symbol,
3447 // which throws things all off. To get around this, we just tell
Reid Spencer93c40032007-03-19 18:40:50 +00003448 // getExistingVal that we are at global scope here.
Reid Spencer68a24bd2005-08-27 18:50:39 +00003449 //
3450 Function *SavedCurFn = CurFun.CurrentFunction;
3451 CurFun.CurrentFunction = 0;
3452
Chris Lattner0275cff2007-08-06 21:00:46 +00003453 Value *V = getExistingVal(Ty, yyvsp[0].ValIDVal);
Reid Spencer5b7e7532006-09-28 19:28:24 +00003454 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003455
3456 CurFun.CurrentFunction = SavedCurFn;
3457
3458 // If this is an initializer for a constant pointer, which is referencing a
3459 // (currently) undefined variable, create a stub now that shall be replaced
3460 // in the future with the right type of variable.
3461 //
3462 if (V == 0) {
Reid Spencera9720f52007-02-05 17:04:00 +00003463 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003464 const PointerType *PT = cast<PointerType>(Ty);
3465
3466 // First check to see if the forward references value is already created!
3467 PerModuleInfo::GlobalRefsType::iterator I =
Chris Lattner0275cff2007-08-06 21:00:46 +00003468 CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003469
3470 if (I != CurModule.GlobalRefs.end()) {
3471 V = I->second; // Placeholder already exists, use it...
Chris Lattner0275cff2007-08-06 21:00:46 +00003472 yyvsp[0].ValIDVal.destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003473 } else {
3474 std::string Name;
Chris Lattner0275cff2007-08-06 21:00:46 +00003475 if (yyvsp[0].ValIDVal.Type == ValID::GlobalName)
3476 Name = yyvsp[0].ValIDVal.getName();
3477 else if (yyvsp[0].ValIDVal.Type != ValID::GlobalID)
Reid Spencer41dff5e2007-01-26 08:05:27 +00003478 GEN_ERROR("Invalid reference to global");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003479
3480 // Create the forward referenced global.
3481 GlobalValue *GV;
3482 if (const FunctionType *FTy =
3483 dyn_cast<FunctionType>(PT->getElementType())) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00003484 GV = new Function(FTy, GlobalValue::ExternalWeakLinkage, Name,
Reid Spencer68a24bd2005-08-27 18:50:39 +00003485 CurModule.CurrentModule);
3486 } else {
3487 GV = new GlobalVariable(PT->getElementType(), false,
Chris Lattner6cdc6822007-04-26 05:31:05 +00003488 GlobalValue::ExternalWeakLinkage, 0,
Reid Spencer68a24bd2005-08-27 18:50:39 +00003489 Name, CurModule.CurrentModule);
3490 }
3491
3492 // Keep track of the fact that we have a forward ref to recycle it
Chris Lattner0275cff2007-08-06 21:00:46 +00003493 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003494 V = GV;
3495 }
3496 }
3497
Chris Lattner0275cff2007-08-06 21:00:46 +00003498 yyval.ConstVal = cast<GlobalValue>(V);
3499 delete yyvsp[-1].TypeVal; // Free the type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00003500 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003501 ;
3502 break;}
3503case 172:
Chris Lattner569f7372007-09-10 23:24:14 +00003504#line 1806 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003505{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003506 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003507 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3508 if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003509 GEN_ERROR("Mismatched types for constant expression: " +
Chris Lattner0275cff2007-08-06 21:00:46 +00003510 (*yyvsp[-1].TypeVal)->getDescription() + " and " + yyvsp[0].ConstVal->getType()->getDescription());
3511 yyval.ConstVal = yyvsp[0].ConstVal;
3512 delete yyvsp[-1].TypeVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003513 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003514 ;
3515 break;}
3516case 173:
Chris Lattner569f7372007-09-10 23:24:14 +00003517#line 1816 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003518{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003519 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003520 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3521 const Type *Ty = yyvsp[-1].TypeVal->get();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003522 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
3523 GEN_ERROR("Cannot create a null initialized value of this type");
Chris Lattner0275cff2007-08-06 21:00:46 +00003524 yyval.ConstVal = Constant::getNullValue(Ty);
3525 delete yyvsp[-1].TypeVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003526 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003527 ;
3528 break;}
3529case 174:
Chris Lattner569f7372007-09-10 23:24:14 +00003530#line 1826 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003531{ // integral constants
Chris Lattner0275cff2007-08-06 21:00:46 +00003532 if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003533 GEN_ERROR("Constant value doesn't fit in type");
Chris Lattner0275cff2007-08-06 21:00:46 +00003534 yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val, true);
Reid Spencer38c91a92007-02-28 02:24:54 +00003535 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003536 ;
3537 break;}
3538case 175:
Chris Lattner569f7372007-09-10 23:24:14 +00003539#line 1832 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003540{ // arbitrary precision integer constants
Chris Lattner0275cff2007-08-06 21:00:46 +00003541 uint32_t BitWidth = cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth();
3542 if (yyvsp[0].APIntVal->getBitWidth() > BitWidth) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003543 GEN_ERROR("Constant value does not fit in type");
3544 }
Chris Lattner0275cff2007-08-06 21:00:46 +00003545 yyvsp[0].APIntVal->sextOrTrunc(BitWidth);
3546 yyval.ConstVal = ConstantInt::get(*yyvsp[0].APIntVal);
3547 delete yyvsp[0].APIntVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003548 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003549 ;
3550 break;}
3551case 176:
Chris Lattner569f7372007-09-10 23:24:14 +00003552#line 1842 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003553{ // integral constants
Chris Lattner0275cff2007-08-06 21:00:46 +00003554 if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003555 GEN_ERROR("Constant value doesn't fit in type");
Chris Lattner0275cff2007-08-06 21:00:46 +00003556 yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val, false);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003557 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003558 ;
3559 break;}
3560case 177:
Chris Lattner569f7372007-09-10 23:24:14 +00003561#line 1848 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003562{ // arbitrary precision integer constants
Chris Lattner0275cff2007-08-06 21:00:46 +00003563 uint32_t BitWidth = cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth();
3564 if (yyvsp[0].APIntVal->getBitWidth() > BitWidth) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003565 GEN_ERROR("Constant value does not fit in type");
3566 }
Chris Lattner0275cff2007-08-06 21:00:46 +00003567 yyvsp[0].APIntVal->zextOrTrunc(BitWidth);
3568 yyval.ConstVal = ConstantInt::get(*yyvsp[0].APIntVal);
3569 delete yyvsp[0].APIntVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003570 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003571 ;
3572 break;}
3573case 178:
Chris Lattner569f7372007-09-10 23:24:14 +00003574#line 1858 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003575{ // Boolean constants
Chris Lattner0275cff2007-08-06 21:00:46 +00003576 assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?");
3577 yyval.ConstVal = ConstantInt::getTrue();
Reid Spencer38c91a92007-02-28 02:24:54 +00003578 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003579 ;
3580 break;}
3581case 179:
Chris Lattner569f7372007-09-10 23:24:14 +00003582#line 1863 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003583{ // Boolean constants
Chris Lattner0275cff2007-08-06 21:00:46 +00003584 assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?");
3585 yyval.ConstVal = ConstantInt::getFalse();
Reid Spencer6f407902007-01-13 05:00:46 +00003586 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003587 ;
3588 break;}
3589case 180:
Chris Lattner569f7372007-09-10 23:24:14 +00003590#line 1868 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003591{ // Float & Double constants
3592 if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, *yyvsp[0].FPVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003593 GEN_ERROR("Floating point constant invalid for type");
Dale Johannesencdd509a2007-09-07 21:07:57 +00003594 // Lexer has no type info, so builds all FP constants as double.
3595 // Fix this here.
3596 if (yyvsp[-1].PrimType==Type::FloatTy)
3597 yyvsp[0].FPVal->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
3598 yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, *yyvsp[0].FPVal);
3599 delete yyvsp[0].FPVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003600 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003601 ;
3602 break;}
3603case 181:
Chris Lattner569f7372007-09-10 23:24:14 +00003604#line 1881 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003605{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003606 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003607 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3608 Constant *Val = yyvsp[-3].ConstVal;
3609 const Type *DestTy = yyvsp[-1].TypeVal->get();
3610 if (!CastInst::castIsValid(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003611 GEN_ERROR("invalid cast opcode for cast from '" +
3612 Val->getType()->getDescription() + "' to '" +
3613 DestTy->getDescription() + "'");
Chris Lattner0275cff2007-08-06 21:00:46 +00003614 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy);
3615 delete yyvsp[-1].TypeVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00003616 ;
3617 break;}
3618case 182:
Chris Lattner569f7372007-09-10 23:24:14 +00003619#line 1893 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003620{
Chris Lattner0275cff2007-08-06 21:00:46 +00003621 if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
Reid Spencerb5334b02007-02-05 10:18:06 +00003622 GEN_ERROR("GetElementPtr requires a pointer operand");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003623
3624 const Type *IdxTy =
David Greene5fd22a82007-09-04 18:46:50 +00003625 GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end(),
Chris Lattner7d9801d2007-02-13 00:58:01 +00003626 true);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003627 if (!IdxTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00003628 GEN_ERROR("Index list invalid for constant getelementptr");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003629
Chris Lattnerf7469af2007-01-31 04:44:08 +00003630 SmallVector<Constant*, 8> IdxVec;
Chris Lattner0275cff2007-08-06 21:00:46 +00003631 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
3632 if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003633 IdxVec.push_back(C);
3634 else
Reid Spencerb5334b02007-02-05 10:18:06 +00003635 GEN_ERROR("Indices to constant getelementptr must be constants");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003636
Chris Lattner0275cff2007-08-06 21:00:46 +00003637 delete yyvsp[-1].ValueList;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003638
Chris Lattner0275cff2007-08-06 21:00:46 +00003639 yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, &IdxVec[0], IdxVec.size());
Andrew Lenharth6353e052006-12-08 18:07:09 +00003640 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003641 ;
3642 break;}
3643case 183:
Chris Lattner569f7372007-09-10 23:24:14 +00003644#line 1915 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003645{
Chris Lattner0275cff2007-08-06 21:00:46 +00003646 if (yyvsp[-5].ConstVal->getType() != Type::Int1Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003647 GEN_ERROR("Select condition must be of boolean type");
Chris Lattner0275cff2007-08-06 21:00:46 +00003648 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003649 GEN_ERROR("Select operand types must match");
Chris Lattner0275cff2007-08-06 21:00:46 +00003650 yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003651 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003652 ;
3653 break;}
3654case 184:
Chris Lattner569f7372007-09-10 23:24:14 +00003655#line 1923 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003656{
Chris Lattner0275cff2007-08-06 21:00:46 +00003657 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003658 GEN_ERROR("Binary operator types must match");
3659 CHECK_FOR_ERROR;
Chris Lattner0275cff2007-08-06 21:00:46 +00003660 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Dale Johannesencdd509a2007-09-07 21:07:57 +00003661 ;
3662 break;}
3663case 185:
Chris Lattner569f7372007-09-10 23:24:14 +00003664#line 1929 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003665{
Chris Lattner0275cff2007-08-06 21:00:46 +00003666 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003667 GEN_ERROR("Logical operator types must match");
Chris Lattner0275cff2007-08-06 21:00:46 +00003668 if (!yyvsp[-3].ConstVal->getType()->isInteger()) {
3669 if (Instruction::isShift(yyvsp[-5].BinaryOpVal) || !isa<VectorType>(yyvsp[-3].ConstVal->getType()) ||
3670 !cast<VectorType>(yyvsp[-3].ConstVal->getType())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003671 GEN_ERROR("Logical operator requires integral operands");
3672 }
Chris Lattner0275cff2007-08-06 21:00:46 +00003673 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003674 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003675 ;
3676 break;}
3677case 186:
Chris Lattner569f7372007-09-10 23:24:14 +00003678#line 1940 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003679{
Chris Lattner0275cff2007-08-06 21:00:46 +00003680 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003681 GEN_ERROR("icmp operand types must match");
Chris Lattner0275cff2007-08-06 21:00:46 +00003682 yyval.ConstVal = ConstantExpr::getICmp(yyvsp[-5].IPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Dale Johannesencdd509a2007-09-07 21:07:57 +00003683 ;
3684 break;}
3685case 187:
Chris Lattner569f7372007-09-10 23:24:14 +00003686#line 1945 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003687{
Chris Lattner0275cff2007-08-06 21:00:46 +00003688 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003689 GEN_ERROR("fcmp operand types must match");
Chris Lattner0275cff2007-08-06 21:00:46 +00003690 yyval.ConstVal = ConstantExpr::getFCmp(yyvsp[-5].FPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Dale Johannesencdd509a2007-09-07 21:07:57 +00003691 ;
3692 break;}
3693case 188:
Chris Lattner569f7372007-09-10 23:24:14 +00003694#line 1950 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003695{
Chris Lattner0275cff2007-08-06 21:00:46 +00003696 if (!ExtractElementInst::isValidOperands(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003697 GEN_ERROR("Invalid extractelement operands");
Chris Lattner0275cff2007-08-06 21:00:46 +00003698 yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003699 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003700 ;
3701 break;}
3702case 189:
Chris Lattner569f7372007-09-10 23:24:14 +00003703#line 1956 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003704{
Chris Lattner0275cff2007-08-06 21:00:46 +00003705 if (!InsertElementInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003706 GEN_ERROR("Invalid insertelement operands");
Chris Lattner0275cff2007-08-06 21:00:46 +00003707 yyval.ConstVal = ConstantExpr::getInsertElement(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003708 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003709 ;
3710 break;}
3711case 190:
Chris Lattner569f7372007-09-10 23:24:14 +00003712#line 1962 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003713{
Chris Lattner0275cff2007-08-06 21:00:46 +00003714 if (!ShuffleVectorInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003715 GEN_ERROR("Invalid shufflevector operands");
Chris Lattner0275cff2007-08-06 21:00:46 +00003716 yyval.ConstVal = ConstantExpr::getShuffleVector(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003717 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003718 ;
3719 break;}
3720case 191:
Chris Lattner569f7372007-09-10 23:24:14 +00003721#line 1971 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003722{
Chris Lattner0275cff2007-08-06 21:00:46 +00003723 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003724 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003725 ;
3726 break;}
3727case 192:
Chris Lattner569f7372007-09-10 23:24:14 +00003728#line 1975 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003729{
Chris Lattner0275cff2007-08-06 21:00:46 +00003730 yyval.ConstVector = new std::vector<Constant*>();
3731 yyval.ConstVector->push_back(yyvsp[0].ConstVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003732 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003733 ;
3734 break;}
3735case 193:
Chris Lattner569f7372007-09-10 23:24:14 +00003736#line 1983 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003737{ yyval.BoolVal = false; ;
3738 break;}
3739case 194:
Chris Lattner569f7372007-09-10 23:24:14 +00003740#line 1983 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003741{ yyval.BoolVal = true; ;
3742 break;}
3743case 195:
Chris Lattner569f7372007-09-10 23:24:14 +00003744#line 1986 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003745{ yyval.BoolVal = true; ;
3746 break;}
3747case 196:
Chris Lattner569f7372007-09-10 23:24:14 +00003748#line 1986 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003749{ yyval.BoolVal = false; ;
3750 break;}
3751case 197:
Chris Lattner569f7372007-09-10 23:24:14 +00003752#line 1989 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003753{
Chris Lattner0275cff2007-08-06 21:00:46 +00003754 const Type* VTy = yyvsp[-1].TypeVal->get();
3755 Value *V = getVal(VTy, yyvsp[0].ValIDVal);
3756 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003757 GlobalValue* Aliasee = dyn_cast<GlobalValue>(V);
3758 if (!Aliasee)
3759 GEN_ERROR("Aliases can be created only to global values");
3760
Chris Lattner0275cff2007-08-06 21:00:46 +00003761 yyval.ConstVal = Aliasee;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003762 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003763 delete yyvsp[-1].TypeVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00003764 ;
3765 break;}
3766case 198:
Chris Lattner569f7372007-09-10 23:24:14 +00003767#line 2001 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003768{
Chris Lattner0275cff2007-08-06 21:00:46 +00003769 Constant *Val = yyvsp[-3].ConstVal;
3770 const Type *DestTy = yyvsp[-1].TypeVal->get();
3771 if (!CastInst::castIsValid(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy))
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003772 GEN_ERROR("invalid cast opcode for cast from '" +
3773 Val->getType()->getDescription() + "' to '" +
3774 DestTy->getDescription() + "'");
3775
Chris Lattner0275cff2007-08-06 21:00:46 +00003776 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003777 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003778 delete yyvsp[-1].TypeVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00003779 ;
3780 break;}
3781case 199:
Chris Lattner569f7372007-09-10 23:24:14 +00003782#line 2022 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003783{
Chris Lattner0275cff2007-08-06 21:00:46 +00003784 yyval.ModuleVal = ParserResult = CurModule.CurrentModule;
Reid Spencer1013b4d2007-07-31 14:41:17 +00003785 CurModule.ModuleDone();
3786 CHECK_FOR_ERROR;
Dale Johannesencdd509a2007-09-07 21:07:57 +00003787 ;
3788 break;}
3789case 200:
Chris Lattner569f7372007-09-10 23:24:14 +00003790#line 2027 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003791{
Chris Lattner0275cff2007-08-06 21:00:46 +00003792 yyval.ModuleVal = ParserResult = CurModule.CurrentModule;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003793 CurModule.ModuleDone();
3794 CHECK_FOR_ERROR;
Dale Johannesencdd509a2007-09-07 21:07:57 +00003795 ;
3796 break;}
3797case 203:
Chris Lattner569f7372007-09-10 23:24:14 +00003798#line 2040 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003799{ CurFun.isDeclare = false; ;
3800 break;}
3801case 204:
Chris Lattner569f7372007-09-10 23:24:14 +00003802#line 2040 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003803{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003804 CurFun.FunctionDone();
3805 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003806 ;
3807 break;}
3808case 205:
Chris Lattner569f7372007-09-10 23:24:14 +00003809#line 2044 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003810{ CurFun.isDeclare = true; ;
3811 break;}
3812case 206:
Chris Lattner569f7372007-09-10 23:24:14 +00003813#line 2044 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003814{
Reid Spencer1013b4d2007-07-31 14:41:17 +00003815 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003816 ;
3817 break;}
3818case 207:
Chris Lattner569f7372007-09-10 23:24:14 +00003819#line 2047 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003820{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003821 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003822 ;
3823 break;}
3824case 208:
Chris Lattner569f7372007-09-10 23:24:14 +00003825#line 2050 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003826{
Reid Spencer14310612006-12-31 05:40:51 +00003827 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003828 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003829 // Eagerly resolve types. This is not an optimization, this is a
3830 // requirement that is due to the fact that we could have this:
3831 //
3832 // %list = type { %list * }
3833 // %list = type { %list * } ; repeated type decl
3834 //
3835 // If types are not resolved eagerly, then the two types will not be
3836 // determined to be the same type!
3837 //
Chris Lattner0275cff2007-08-06 21:00:46 +00003838 ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003839
Chris Lattner0275cff2007-08-06 21:00:46 +00003840 if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00003841 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003842 // If this is a named type that is not a redefinition, add it to the slot
3843 // table.
Chris Lattner0275cff2007-08-06 21:00:46 +00003844 CurModule.Types.push_back(*yyvsp[0].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003845 }
Reid Spencera132e042006-12-03 05:46:11 +00003846
Chris Lattner0275cff2007-08-06 21:00:46 +00003847 delete yyvsp[0].TypeVal;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003848 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003849 ;
3850 break;}
3851case 209:
Chris Lattner569f7372007-09-10 23:24:14 +00003852#line 2074 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003853{
Chris Lattner0275cff2007-08-06 21:00:46 +00003854 ResolveTypeTo(yyvsp[-2].StrVal, yyvsp[0].PrimType);
Reid Spencerb8f85052007-07-31 03:50:36 +00003855
Chris Lattner0275cff2007-08-06 21:00:46 +00003856 if (!setTypeName(yyvsp[0].PrimType, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003857 CHECK_FOR_ERROR
3858 // If this is a named type that is not a redefinition, add it to the slot
3859 // table.
Chris Lattner0275cff2007-08-06 21:00:46 +00003860 CurModule.Types.push_back(yyvsp[0].PrimType);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003861 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003862 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003863 ;
3864 break;}
3865case 210:
Chris Lattner569f7372007-09-10 23:24:14 +00003866#line 2085 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003867{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003868 /* "Externally Visible" Linkage */
Chris Lattner0275cff2007-08-06 21:00:46 +00003869 if (yyvsp[0].ConstVal == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003870 GEN_ERROR("Global value initializer is not a constant");
Chris Lattner0275cff2007-08-06 21:00:46 +00003871 CurGV = ParseGlobalVariable(yyvsp[-4].StrVal, GlobalValue::ExternalLinkage,
3872 yyvsp[-3].Visibility, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal, yyvsp[-2].BoolVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003873 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003874 ;
3875 break;}
3876case 211:
Chris Lattner569f7372007-09-10 23:24:14 +00003877#line 2092 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003878{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003879 CurGV = 0;
Dale Johannesencdd509a2007-09-07 21:07:57 +00003880 ;
3881 break;}
3882case 212:
Chris Lattner569f7372007-09-10 23:24:14 +00003883#line 2096 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003884{
Chris Lattner0275cff2007-08-06 21:00:46 +00003885 if (yyvsp[0].ConstVal == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003886 GEN_ERROR("Global value initializer is not a constant");
Chris Lattner0275cff2007-08-06 21:00:46 +00003887 CurGV = ParseGlobalVariable(yyvsp[-5].StrVal, yyvsp[-4].Linkage, yyvsp[-3].Visibility, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal, yyvsp[-2].BoolVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003888 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003889 ;
3890 break;}
3891case 213:
Chris Lattner569f7372007-09-10 23:24:14 +00003892#line 2101 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003893{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003894 CurGV = 0;
Dale Johannesencdd509a2007-09-07 21:07:57 +00003895 ;
3896 break;}
3897case 214:
Chris Lattner569f7372007-09-10 23:24:14 +00003898#line 2105 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003899{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003900 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003901 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
3902 CurGV = ParseGlobalVariable(yyvsp[-5].StrVal, yyvsp[-4].Linkage, yyvsp[-3].Visibility, yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0, yyvsp[-2].BoolVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003903 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003904 delete yyvsp[0].TypeVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00003905 ;
3906 break;}
3907case 215:
Chris Lattner569f7372007-09-10 23:24:14 +00003908#line 2111 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003909{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003910 CurGV = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003911 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003912 ;
3913 break;}
3914case 216:
Chris Lattner569f7372007-09-10 23:24:14 +00003915#line 2115 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003916{
Reid Spencer0a8a16b2007-05-22 18:52:55 +00003917 std::string Name;
Chris Lattner0275cff2007-08-06 21:00:46 +00003918 if (yyvsp[-4].StrVal) {
3919 Name = *yyvsp[-4].StrVal;
3920 delete yyvsp[-4].StrVal;
Reid Spencer0a8a16b2007-05-22 18:52:55 +00003921 }
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003922 if (Name.empty())
3923 GEN_ERROR("Alias name cannot be empty");
3924
Chris Lattner0275cff2007-08-06 21:00:46 +00003925 Constant* Aliasee = yyvsp[0].ConstVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003926 if (Aliasee == 0)
Reid Spencer0a8a16b2007-05-22 18:52:55 +00003927 GEN_ERROR(std::string("Invalid aliasee for alias: ") + Name);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003928
Chris Lattner0275cff2007-08-06 21:00:46 +00003929 GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), yyvsp[-1].Linkage, Name, Aliasee,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003930 CurModule.CurrentModule);
Chris Lattner0275cff2007-08-06 21:00:46 +00003931 GA->setVisibility(yyvsp[-3].Visibility);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003932 InsertValue(GA, CurModule.Values);
Chris Lattner569f7372007-09-10 23:24:14 +00003933
3934
3935 // If there was a forward reference of this alias, resolve it now.
3936
3937 ValID ID;
3938 if (!Name.empty())
3939 ID = ValID::createGlobalName(Name);
3940 else
3941 ID = ValID::createGlobalID(CurModule.Values.size()-1);
3942
3943 if (GlobalValue *FWGV =
3944 CurModule.GetForwardRefForGlobal(GA->getType(), ID)) {
3945 // Replace uses of the fwdref with the actual alias.
3946 FWGV->replaceAllUsesWith(GA);
3947 if (GlobalVariable *GV = dyn_cast<GlobalVariable>(FWGV))
3948 GV->eraseFromParent();
3949 else
3950 cast<Function>(FWGV)->eraseFromParent();
3951 }
3952 ID.destroy();
3953
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003954 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003955 ;
3956 break;}
3957case 217:
Chris Lattner569f7372007-09-10 23:24:14 +00003958#line 2155 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003959{
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003960 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003961 ;
3962 break;}
3963case 218:
Chris Lattner569f7372007-09-10 23:24:14 +00003964#line 2158 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003965{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003966 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003967 ;
3968 break;}
3969case 219:
Chris Lattner569f7372007-09-10 23:24:14 +00003970#line 2164 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003971{
Chris Lattner66316012006-01-24 04:14:29 +00003972 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Chris Lattner66316012006-01-24 04:14:29 +00003973 if (AsmSoFar.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003974 CurModule.CurrentModule->setModuleInlineAsm(*yyvsp[0].StrVal);
Chris Lattner66316012006-01-24 04:14:29 +00003975 else
Chris Lattner0275cff2007-08-06 21:00:46 +00003976 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+*yyvsp[0].StrVal);
3977 delete yyvsp[0].StrVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00003978 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003979;
3980 break;}
3981case 220:
Chris Lattner569f7372007-09-10 23:24:14 +00003982#line 2174 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003983{
Chris Lattner0275cff2007-08-06 21:00:46 +00003984 CurModule.CurrentModule->setTargetTriple(*yyvsp[0].StrVal);
3985 delete yyvsp[0].StrVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00003986 ;
3987 break;}
3988case 221:
Chris Lattner569f7372007-09-10 23:24:14 +00003989#line 2178 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003990{
Chris Lattner0275cff2007-08-06 21:00:46 +00003991 CurModule.CurrentModule->setDataLayout(*yyvsp[0].StrVal);
3992 delete yyvsp[0].StrVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00003993 ;
3994 break;}
3995case 223:
Chris Lattner569f7372007-09-10 23:24:14 +00003996#line 2185 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003997{
Chris Lattner0275cff2007-08-06 21:00:46 +00003998 CurModule.CurrentModule->addLibrary(*yyvsp[0].StrVal);
3999 delete yyvsp[0].StrVal;
Reid Spencer1013b4d2007-07-31 14:41:17 +00004000 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004001 ;
4002 break;}
4003case 224:
Chris Lattner569f7372007-09-10 23:24:14 +00004004#line 2190 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004005{
Chris Lattner0275cff2007-08-06 21:00:46 +00004006 CurModule.CurrentModule->addLibrary(*yyvsp[0].StrVal);
4007 delete yyvsp[0].StrVal;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004008 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004009 ;
4010 break;}
4011case 225:
Chris Lattner569f7372007-09-10 23:24:14 +00004012#line 2195 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004013{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004014 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004015 ;
4016 break;}
4017case 226:
Chris Lattner569f7372007-09-10 23:24:14 +00004018#line 2204 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004019{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004020 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004021 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4022 if (*yyvsp[-2].TypeVal == Type::VoidTy)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004023 GEN_ERROR("void typed arguments are invalid");
Chris Lattner0275cff2007-08-06 21:00:46 +00004024 ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal;
4025 yyval.ArgList = yyvsp[-4].ArgList;
4026 yyvsp[-4].ArgList->push_back(E);
Reid Spencer6f407902007-01-13 05:00:46 +00004027 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004028 ;
4029 break;}
4030case 227:
Chris Lattner569f7372007-09-10 23:24:14 +00004031#line 2214 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004032{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004033 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004034 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4035 if (*yyvsp[-2].TypeVal == Type::VoidTy)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004036 GEN_ERROR("void typed arguments are invalid");
Chris Lattner0275cff2007-08-06 21:00:46 +00004037 ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal;
4038 yyval.ArgList = new ArgListType;
4039 yyval.ArgList->push_back(E);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004040 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004041 ;
4042 break;}
4043case 228:
Chris Lattner569f7372007-09-10 23:24:14 +00004044#line 2225 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004045{
Chris Lattner0275cff2007-08-06 21:00:46 +00004046 yyval.ArgList = yyvsp[0].ArgList;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004047 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004048 ;
4049 break;}
4050case 229:
Chris Lattner569f7372007-09-10 23:24:14 +00004051#line 2229 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004052{
Chris Lattner0275cff2007-08-06 21:00:46 +00004053 yyval.ArgList = yyvsp[-2].ArgList;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004054 struct ArgListEntry E;
4055 E.Ty = new PATypeHolder(Type::VoidTy);
4056 E.Name = 0;
Reid Spencer18da0722007-04-11 02:44:20 +00004057 E.Attrs = ParamAttr::None;
Chris Lattner0275cff2007-08-06 21:00:46 +00004058 yyval.ArgList->push_back(E);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004059 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004060 ;
4061 break;}
4062case 230:
Chris Lattner569f7372007-09-10 23:24:14 +00004063#line 2238 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004064{
Chris Lattner0275cff2007-08-06 21:00:46 +00004065 yyval.ArgList = new ArgListType;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004066 struct ArgListEntry E;
4067 E.Ty = new PATypeHolder(Type::VoidTy);
4068 E.Name = 0;
4069 E.Attrs = ParamAttr::None;
Chris Lattner0275cff2007-08-06 21:00:46 +00004070 yyval.ArgList->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00004071 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004072 ;
4073 break;}
4074case 231:
Chris Lattner569f7372007-09-10 23:24:14 +00004075#line 2247 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004076{
Chris Lattner0275cff2007-08-06 21:00:46 +00004077 yyval.ArgList = 0;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004078 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004079 ;
4080 break;}
4081case 232:
Chris Lattner569f7372007-09-10 23:24:14 +00004082#line 2253 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004083{
Chris Lattner0275cff2007-08-06 21:00:46 +00004084 std::string FunctionName(*yyvsp[-6].StrVal);
4085 delete yyvsp[-6].StrVal; // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004086
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004087 // Check the function result for abstractness if this is a define. We should
4088 // have no abstract types at this point
Chris Lattner0275cff2007-08-06 21:00:46 +00004089 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(yyvsp[-7].TypeVal))
4090 GEN_ERROR("Reference to abstract result: "+ yyvsp[-7].TypeVal->get()->getDescription());
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004091
Reid Spencer68a24bd2005-08-27 18:50:39 +00004092 std::vector<const Type*> ParamTypeList;
Christopher Lamb5c104242007-04-22 20:09:11 +00004093 ParamAttrsVector Attrs;
Chris Lattner0275cff2007-08-06 21:00:46 +00004094 if (yyvsp[-2].ParamAttrs != ParamAttr::None) {
4095 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[-2].ParamAttrs;
Christopher Lamb5c104242007-04-22 20:09:11 +00004096 Attrs.push_back(PAWI);
4097 }
Chris Lattner0275cff2007-08-06 21:00:46 +00004098 if (yyvsp[-4].ArgList) { // If there are arguments...
Reid Spencer7b5d4662007-04-09 06:16:21 +00004099 unsigned index = 1;
Chris Lattner0275cff2007-08-06 21:00:46 +00004100 for (ArgListType::iterator I = yyvsp[-4].ArgList->begin(); I != yyvsp[-4].ArgList->end(); ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00004101 const Type* Ty = I->Ty->get();
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004102 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
4103 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00004104 ParamTypeList.push_back(Ty);
4105 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00004106 if (I->Attrs != ParamAttr::None) {
4107 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
4108 Attrs.push_back(PAWI);
4109 }
Reid Spencer14310612006-12-31 05:40:51 +00004110 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004111 }
4112
4113 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
4114 if (isVarArg) ParamTypeList.pop_back();
4115
Christopher Lamb5c104242007-04-22 20:09:11 +00004116 ParamAttrsList *PAL = 0;
4117 if (!Attrs.empty())
4118 PAL = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00004119
Chris Lattner0275cff2007-08-06 21:00:46 +00004120 FunctionType *FT = FunctionType::get(*yyvsp[-7].TypeVal, ParamTypeList, isVarArg, PAL);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004121 const PointerType *PFT = PointerType::get(FT);
Chris Lattner0275cff2007-08-06 21:00:46 +00004122 delete yyvsp[-7].TypeVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004123
4124 ValID ID;
4125 if (!FunctionName.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004126 ID = ValID::createGlobalName((char*)FunctionName.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004127 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00004128 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004129 }
4130
4131 Function *Fn = 0;
4132 // See if this function was forward referenced. If so, recycle the object.
4133 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4134 // Move the function to the end of the list, from whereever it was
4135 // previously inserted.
4136 Fn = cast<Function>(FWRef);
4137 CurModule.CurrentModule->getFunctionList().remove(Fn);
4138 CurModule.CurrentModule->getFunctionList().push_back(Fn);
4139 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
Reid Spenceref9b9a72007-02-05 20:47:22 +00004140 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00004141 if (Fn->getFunctionType() != FT) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00004142 // The existing function doesn't have the same type. This is an overload
4143 // error.
4144 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
4145 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00004146 // Neither the existing or the current function is a declaration and they
4147 // have the same name and same type. Clearly this is a redefinition.
4148 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +00004149 } if (Fn->isDeclaration()) {
4150 // Make sure to strip off any argument names so we can't get conflicts.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004151 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
4152 AI != AE; ++AI)
4153 AI->setName("");
Reid Spenceref9b9a72007-02-05 20:47:22 +00004154 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004155 } else { // Not already defined?
Chris Lattner6cdc6822007-04-26 05:31:05 +00004156 Fn = new Function(FT, GlobalValue::ExternalWeakLinkage, FunctionName,
Reid Spencer68a24bd2005-08-27 18:50:39 +00004157 CurModule.CurrentModule);
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004158
Reid Spencer68a24bd2005-08-27 18:50:39 +00004159 InsertValue(Fn, CurModule.Values);
4160 }
4161
4162 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004163
4164 if (CurFun.isDeclare) {
4165 // If we have declaration, always overwrite linkage. This will allow us to
4166 // correctly handle cases, when pointer to function is passed as argument to
4167 // another function.
4168 Fn->setLinkage(CurFun.Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004169 Fn->setVisibility(CurFun.Visibility);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004170 }
Chris Lattner0275cff2007-08-06 21:00:46 +00004171 Fn->setCallingConv(yyvsp[-8].UIntVal);
4172 Fn->setAlignment(yyvsp[0].UIntVal);
4173 if (yyvsp[-1].StrVal) {
4174 Fn->setSection(*yyvsp[-1].StrVal);
4175 delete yyvsp[-1].StrVal;
Chris Lattnere869eef2005-11-12 00:11:49 +00004176 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004177
4178 // Add all of the arguments we parsed to the function...
Chris Lattner0275cff2007-08-06 21:00:46 +00004179 if (yyvsp[-4].ArgList) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00004180 if (isVarArg) { // Nuke the last entry
Chris Lattner0275cff2007-08-06 21:00:46 +00004181 assert(yyvsp[-4].ArgList->back().Ty->get() == Type::VoidTy && yyvsp[-4].ArgList->back().Name == 0 &&
Reid Spencera9720f52007-02-05 17:04:00 +00004182 "Not a varargs marker!");
Chris Lattner0275cff2007-08-06 21:00:46 +00004183 delete yyvsp[-4].ArgList->back().Ty;
4184 yyvsp[-4].ArgList->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00004185 }
4186 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00004187 Function::arg_iterator ArgEnd = Fn->arg_end();
Reid Spencer14310612006-12-31 05:40:51 +00004188 unsigned Idx = 1;
Chris Lattner0275cff2007-08-06 21:00:46 +00004189 for (ArgListType::iterator I = yyvsp[-4].ArgList->begin();
4190 I != yyvsp[-4].ArgList->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencer14310612006-12-31 05:40:51 +00004191 delete I->Ty; // Delete the typeholder...
Reid Spencer0a8a16b2007-05-22 18:52:55 +00004192 setValueName(ArgIt, I->Name); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00004193 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004194 InsertValue(ArgIt);
Reid Spencer14310612006-12-31 05:40:51 +00004195 Idx++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004196 }
Reid Spencera132e042006-12-03 05:46:11 +00004197
Chris Lattner0275cff2007-08-06 21:00:46 +00004198 delete yyvsp[-4].ArgList; // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00004199 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004200 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004201;
4202 break;}
4203case 235:
Chris Lattner569f7372007-09-10 23:24:14 +00004204#line 2375 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004205{
Chris Lattner0275cff2007-08-06 21:00:46 +00004206 yyval.FunctionVal = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004207
4208 // Make sure that we keep track of the linkage type even if there was a
4209 // previous "declare".
Chris Lattner0275cff2007-08-06 21:00:46 +00004210 yyval.FunctionVal->setLinkage(yyvsp[-3].Linkage);
4211 yyval.FunctionVal->setVisibility(yyvsp[-2].Visibility);
Dale Johannesencdd509a2007-09-07 21:07:57 +00004212;
4213 break;}
4214case 238:
Chris Lattner569f7372007-09-10 23:24:14 +00004215#line 2386 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004216{
Chris Lattner0275cff2007-08-06 21:00:46 +00004217 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004218 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004219;
4220 break;}
4221case 239:
Chris Lattner569f7372007-09-10 23:24:14 +00004222#line 2391 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004223{
Chris Lattner0275cff2007-08-06 21:00:46 +00004224 CurFun.CurrentFunction->setLinkage(yyvsp[-2].Linkage);
4225 CurFun.CurrentFunction->setVisibility(yyvsp[-1].Visibility);
4226 yyval.FunctionVal = CurFun.CurrentFunction;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004227 CurFun.FunctionDone();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004228 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004229 ;
4230 break;}
4231case 240:
Chris Lattner569f7372007-09-10 23:24:14 +00004232#line 2403 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004233{
Chris Lattner0275cff2007-08-06 21:00:46 +00004234 yyval.BoolVal = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00004235 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004236 ;
4237 break;}
4238case 241:
Chris Lattner569f7372007-09-10 23:24:14 +00004239#line 2407 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004240{
Chris Lattner0275cff2007-08-06 21:00:46 +00004241 yyval.BoolVal = true;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004242 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004243 ;
4244 break;}
4245case 242:
Chris Lattner569f7372007-09-10 23:24:14 +00004246#line 2412 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004247{ // A reference to a direct constant
Chris Lattner0275cff2007-08-06 21:00:46 +00004248 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004249 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004250 ;
4251 break;}
4252case 243:
Chris Lattner569f7372007-09-10 23:24:14 +00004253#line 2416 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004254{
Chris Lattner0275cff2007-08-06 21:00:46 +00004255 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004256 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004257 ;
4258 break;}
4259case 244:
Chris Lattner569f7372007-09-10 23:24:14 +00004260#line 2420 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004261{ // Perhaps it's an FP constant?
Chris Lattner0275cff2007-08-06 21:00:46 +00004262 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004263 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004264 ;
4265 break;}
4266case 245:
Chris Lattner569f7372007-09-10 23:24:14 +00004267#line 2424 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004268{
Chris Lattner0275cff2007-08-06 21:00:46 +00004269 yyval.ValIDVal = ValID::create(ConstantInt::getTrue());
Reid Spencere4d87aa2006-12-23 06:05:41 +00004270 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004271 ;
4272 break;}
4273case 246:
Chris Lattner569f7372007-09-10 23:24:14 +00004274#line 2428 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004275{
Chris Lattner0275cff2007-08-06 21:00:46 +00004276 yyval.ValIDVal = ValID::create(ConstantInt::getFalse());
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004277 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004278 ;
4279 break;}
4280case 247:
Chris Lattner569f7372007-09-10 23:24:14 +00004281#line 2432 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004282{
Chris Lattner0275cff2007-08-06 21:00:46 +00004283 yyval.ValIDVal = ValID::createNull();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004284 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004285 ;
4286 break;}
4287case 248:
Chris Lattner569f7372007-09-10 23:24:14 +00004288#line 2436 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004289{
Chris Lattner0275cff2007-08-06 21:00:46 +00004290 yyval.ValIDVal = ValID::createUndef();
Reid Spencer61c83e02006-08-18 08:43:06 +00004291 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004292 ;
4293 break;}
4294case 249:
Chris Lattner569f7372007-09-10 23:24:14 +00004295#line 2440 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004296{ // A vector zero constant.
Chris Lattner0275cff2007-08-06 21:00:46 +00004297 yyval.ValIDVal = ValID::createZeroInit();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004298 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004299 ;
4300 break;}
4301case 250:
Chris Lattner569f7372007-09-10 23:24:14 +00004302#line 2444 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004303{ // Nonempty unsized packed vector
Chris Lattner0275cff2007-08-06 21:00:46 +00004304 const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
4305 int NumElements = yyvsp[-1].ConstVector->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004306
Reid Spencer9d6565a2007-02-15 02:26:10 +00004307 VectorType* pt = VectorType::get(ETy, NumElements);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004308 PATypeHolder* PTy = new PATypeHolder(
Reid Spencera132e042006-12-03 05:46:11 +00004309 HandleUpRefs(
Reid Spencer9d6565a2007-02-15 02:26:10 +00004310 VectorType::get(
Reid Spencera132e042006-12-03 05:46:11 +00004311 ETy,
4312 NumElements)
4313 )
4314 );
Reid Spencer68a24bd2005-08-27 18:50:39 +00004315
4316 // Verify all elements are correct type!
Chris Lattner0275cff2007-08-06 21:00:46 +00004317 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
4318 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00004319 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00004320 ETy->getDescription() +"' as required!\nIt is of type '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00004321 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004322 }
4323
Chris Lattner0275cff2007-08-06 21:00:46 +00004324 yyval.ValIDVal = ValID::create(ConstantVector::get(pt, *yyvsp[-1].ConstVector));
4325 delete PTy; delete yyvsp[-1].ConstVector;
Reid Spencer832254e2007-02-02 02:16:23 +00004326 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004327 ;
4328 break;}
4329case 251:
Chris Lattner569f7372007-09-10 23:24:14 +00004330#line 2469 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004331{
Chris Lattner0275cff2007-08-06 21:00:46 +00004332 yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
Reid Spencer832254e2007-02-02 02:16:23 +00004333 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004334 ;
4335 break;}
4336case 252:
Chris Lattner569f7372007-09-10 23:24:14 +00004337#line 2473 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004338{
Chris Lattner0275cff2007-08-06 21:00:46 +00004339 yyval.ValIDVal = ValID::createInlineAsm(*yyvsp[-2].StrVal, *yyvsp[0].StrVal, yyvsp[-3].BoolVal);
4340 delete yyvsp[-2].StrVal;
4341 delete yyvsp[0].StrVal;
Reid Spencer832254e2007-02-02 02:16:23 +00004342 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004343 ;
4344 break;}
4345case 253:
Chris Lattner569f7372007-09-10 23:24:14 +00004346#line 2483 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004347{ // Is it an integer reference...?
Chris Lattner0275cff2007-08-06 21:00:46 +00004348 yyval.ValIDVal = ValID::createLocalID(yyvsp[0].UIntVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004349 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004350 ;
4351 break;}
4352case 254:
Chris Lattner569f7372007-09-10 23:24:14 +00004353#line 2487 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004354{
Chris Lattner0275cff2007-08-06 21:00:46 +00004355 yyval.ValIDVal = ValID::createGlobalID(yyvsp[0].UIntVal);
Reid Spencer832254e2007-02-02 02:16:23 +00004356 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004357 ;
4358 break;}
4359case 255:
Chris Lattner569f7372007-09-10 23:24:14 +00004360#line 2491 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004361{ // Is it a named reference...?
Chris Lattner0275cff2007-08-06 21:00:46 +00004362 yyval.ValIDVal = ValID::createLocalName(*yyvsp[0].StrVal);
4363 delete yyvsp[0].StrVal;
Reid Spencer832254e2007-02-02 02:16:23 +00004364 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004365 ;
4366 break;}
4367case 256:
Chris Lattner569f7372007-09-10 23:24:14 +00004368#line 2496 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004369{ // Is it a named reference...?
Chris Lattner0275cff2007-08-06 21:00:46 +00004370 yyval.ValIDVal = ValID::createGlobalName(*yyvsp[0].StrVal);
4371 delete yyvsp[0].StrVal;
Reid Spencer832254e2007-02-02 02:16:23 +00004372 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004373 ;
4374 break;}
4375case 259:
Chris Lattner569f7372007-09-10 23:24:14 +00004376#line 2509 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004377{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004378 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004379 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4380 yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
4381 delete yyvsp[-1].TypeVal;
Reid Spencer832254e2007-02-02 02:16:23 +00004382 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004383 ;
4384 break;}
4385case 260:
Chris Lattner569f7372007-09-10 23:24:14 +00004386#line 2518 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004387{
Chris Lattner0275cff2007-08-06 21:00:46 +00004388 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004389 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004390 ;
4391 break;}
4392case 261:
Chris Lattner569f7372007-09-10 23:24:14 +00004393#line 2522 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004394{ // Do not allow functions with 0 basic blocks
Chris Lattner0275cff2007-08-06 21:00:46 +00004395 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004396 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004397 ;
4398 break;}
4399case 262:
Chris Lattner569f7372007-09-10 23:24:14 +00004400#line 2531 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004401{
Chris Lattner0275cff2007-08-06 21:00:46 +00004402 setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004403 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004404 InsertValue(yyvsp[0].TermInstVal);
4405 yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
4406 yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004407 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004408 ;
4409 break;}
4410case 263:
Chris Lattner569f7372007-09-10 23:24:14 +00004411#line 2540 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004412{
Chris Lattner0275cff2007-08-06 21:00:46 +00004413 if (CastInst *CI1 = dyn_cast<CastInst>(yyvsp[0].InstVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004414 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
4415 if (CI2->getParent() == 0)
Chris Lattner0275cff2007-08-06 21:00:46 +00004416 yyvsp[-1].BasicBlockVal->getInstList().push_back(CI2);
4417 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
4418 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004419 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004420 ;
4421 break;}
4422case 264:
Chris Lattner569f7372007-09-10 23:24:14 +00004423#line 2549 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004424{ // Empty space between instruction lists
Chris Lattner0275cff2007-08-06 21:00:46 +00004425 yyval.BasicBlockVal = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
Reid Spencered951ea2007-05-19 07:22:10 +00004426 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004427 ;
4428 break;}
4429case 265:
Chris Lattner569f7372007-09-10 23:24:14 +00004430#line 2553 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004431{ // Labelled (named) basic block
Chris Lattner0275cff2007-08-06 21:00:46 +00004432 yyval.BasicBlockVal = defineBBVal(ValID::createLocalName(*yyvsp[0].StrVal));
4433 delete yyvsp[0].StrVal;
Reid Spencered951ea2007-05-19 07:22:10 +00004434 CHECK_FOR_ERROR
Reid Spencer0a8a16b2007-05-22 18:52:55 +00004435
Dale Johannesencdd509a2007-09-07 21:07:57 +00004436 ;
4437 break;}
4438case 266:
Chris Lattner569f7372007-09-10 23:24:14 +00004439#line 2560 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004440{ // Return with a result...
Chris Lattner0275cff2007-08-06 21:00:46 +00004441 yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
4442 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004443 ;
4444 break;}
4445case 267:
Chris Lattner569f7372007-09-10 23:24:14 +00004446#line 2564 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004447{ // Return with no result...
Chris Lattner0275cff2007-08-06 21:00:46 +00004448 yyval.TermInstVal = new ReturnInst();
4449 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004450 ;
4451 break;}
4452case 268:
Chris Lattner569f7372007-09-10 23:24:14 +00004453#line 2568 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004454{ // Unconditional Branch...
Chris Lattner0275cff2007-08-06 21:00:46 +00004455 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
4456 CHECK_FOR_ERROR
4457 yyval.TermInstVal = new BranchInst(tmpBB);
Dale Johannesencdd509a2007-09-07 21:07:57 +00004458 ;
4459 break;}
4460case 269:
Chris Lattner569f7372007-09-10 23:24:14 +00004461#line 2573 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004462{
Chris Lattner0275cff2007-08-06 21:00:46 +00004463 assert(cast<IntegerType>(yyvsp[-7].PrimType)->getBitWidth() == 1 && "Not Bool?");
4464 BasicBlock* tmpBBA = getBBVal(yyvsp[-3].ValIDVal);
4465 CHECK_FOR_ERROR
4466 BasicBlock* tmpBBB = getBBVal(yyvsp[0].ValIDVal);
4467 CHECK_FOR_ERROR
4468 Value* tmpVal = getVal(Type::Int1Ty, yyvsp[-6].ValIDVal);
4469 CHECK_FOR_ERROR
4470 yyval.TermInstVal = new BranchInst(tmpBBA, tmpBBB, tmpVal);
Dale Johannesencdd509a2007-09-07 21:07:57 +00004471 ;
4472 break;}
4473case 270:
Chris Lattner569f7372007-09-10 23:24:14 +00004474#line 2583 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004475{
Chris Lattner0275cff2007-08-06 21:00:46 +00004476 Value* tmpVal = getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal);
4477 CHECK_FOR_ERROR
4478 BasicBlock* tmpBB = getBBVal(yyvsp[-3].ValIDVal);
4479 CHECK_FOR_ERROR
4480 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, yyvsp[-1].JumpTable->size());
4481 yyval.TermInstVal = S;
Reid Spencerb8f85052007-07-31 03:50:36 +00004482
Chris Lattner0275cff2007-08-06 21:00:46 +00004483 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
4484 E = yyvsp[-1].JumpTable->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004485 for (; I != E; ++I) {
4486 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
4487 S->addCase(CI, I->second);
4488 else
Reid Spencerb5334b02007-02-05 10:18:06 +00004489 GEN_ERROR("Switch case is constant, but not a simple integer");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004490 }
Chris Lattner0275cff2007-08-06 21:00:46 +00004491 delete yyvsp[-1].JumpTable;
Reid Spencer61c83e02006-08-18 08:43:06 +00004492 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004493 ;
4494 break;}
4495case 271:
Chris Lattner569f7372007-09-10 23:24:14 +00004496#line 2602 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004497{
Chris Lattner0275cff2007-08-06 21:00:46 +00004498 Value* tmpVal = getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004499 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004500 BasicBlock* tmpBB = getBBVal(yyvsp[-2].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004501 CHECK_FOR_ERROR
4502 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Chris Lattner0275cff2007-08-06 21:00:46 +00004503 yyval.TermInstVal = S;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004504 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004505 ;
4506 break;}
4507case 272:
Chris Lattner569f7372007-09-10 23:24:14 +00004508#line 2612 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004509{
Reid Spencer3822ff52006-11-08 06:47:33 +00004510
Reid Spencer14310612006-12-31 05:40:51 +00004511 // Handle the short syntax
4512 const PointerType *PFTy = 0;
4513 const FunctionType *Ty = 0;
Chris Lattner0275cff2007-08-06 21:00:46 +00004514 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-11].TypeVal->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00004515 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4516 // Pull out the types of all of the arguments...
4517 std::vector<const Type*> ParamTypes;
Christopher Lamb5c104242007-04-22 20:09:11 +00004518 ParamAttrsVector Attrs;
Chris Lattner0275cff2007-08-06 21:00:46 +00004519 if (yyvsp[-6].ParamAttrs != ParamAttr::None) {
4520 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[-6].ParamAttrs;
Christopher Lamb5c104242007-04-22 20:09:11 +00004521 Attrs.push_back(PAWI);
4522 }
Chris Lattner0275cff2007-08-06 21:00:46 +00004523 ValueRefList::iterator I = yyvsp[-8].ValueRefList->begin(), E = yyvsp[-8].ValueRefList->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00004524 unsigned index = 1;
4525 for (; I != E; ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00004526 const Type *Ty = I->Val->getType();
4527 if (Ty == Type::VoidTy)
4528 GEN_ERROR("Short call syntax cannot be used with varargs");
4529 ParamTypes.push_back(Ty);
Christopher Lamb5c104242007-04-22 20:09:11 +00004530 if (I->Attrs != ParamAttr::None) {
4531 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
4532 Attrs.push_back(PAWI);
4533 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004534 }
4535
Christopher Lamb5c104242007-04-22 20:09:11 +00004536 ParamAttrsList *PAL = 0;
4537 if (!Attrs.empty())
4538 PAL = ParamAttrsList::get(Attrs);
Chris Lattner0275cff2007-08-06 21:00:46 +00004539 Ty = FunctionType::get(yyvsp[-11].TypeVal->get(), ParamTypes, false, PAL);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004540 PFTy = PointerType::get(Ty);
4541 }
4542
Chris Lattner0275cff2007-08-06 21:00:46 +00004543 delete yyvsp[-11].TypeVal;
Reid Spencer66728ef2007-03-20 01:13:36 +00004544
Chris Lattner0275cff2007-08-06 21:00:46 +00004545 Value *V = getVal(PFTy, yyvsp[-10].ValIDVal); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00004546 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004547 BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004548 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004549 BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
Reid Spencer5b7e7532006-09-28 19:28:24 +00004550 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004551
Reid Spencer14310612006-12-31 05:40:51 +00004552 // Check the arguments
4553 ValueList Args;
Chris Lattner0275cff2007-08-06 21:00:46 +00004554 if (yyvsp[-8].ValueRefList->empty()) { // Has no arguments?
Reid Spencer14310612006-12-31 05:40:51 +00004555 // Make sure no arguments is a good thing!
4556 if (Ty->getNumParams() != 0)
4557 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00004558 "expects arguments");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004559 } else { // Has arguments?
4560 // Loop through FunctionType's arguments and ensure they are specified
4561 // correctly!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004562 FunctionType::param_iterator I = Ty->param_begin();
4563 FunctionType::param_iterator E = Ty->param_end();
Chris Lattner0275cff2007-08-06 21:00:46 +00004564 ValueRefList::iterator ArgI = yyvsp[-8].ValueRefList->begin(), ArgE = yyvsp[-8].ValueRefList->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004565
Reid Spencer14310612006-12-31 05:40:51 +00004566 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
4567 if (ArgI->Val->getType() != *I)
4568 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00004569 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00004570 Args.push_back(ArgI->Val);
4571 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004572
Reid Spencer14310612006-12-31 05:40:51 +00004573 if (Ty->isVarArg()) {
4574 if (I == E)
4575 for (; ArgI != ArgE; ++ArgI)
4576 Args.push_back(ArgI->Val); // push the remaining varargs
4577 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00004578 GEN_ERROR("Invalid number of parameters detected");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004579 }
Reid Spencer14310612006-12-31 05:40:51 +00004580
4581 // Create the InvokeInst
Chris Lattnerd80fb8b2007-08-29 16:15:23 +00004582 InvokeInst *II = new InvokeInst(V, Normal, Except, Args.begin(), Args.end());
Chris Lattner0275cff2007-08-06 21:00:46 +00004583 II->setCallingConv(yyvsp[-12].UIntVal);
4584 yyval.TermInstVal = II;
4585 delete yyvsp[-8].ValueRefList;
Andrew Lenharth6353e052006-12-08 18:07:09 +00004586 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004587 ;
4588 break;}
4589case 273:
Chris Lattner569f7372007-09-10 23:24:14 +00004590#line 2691 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004591{
Chris Lattner0275cff2007-08-06 21:00:46 +00004592 yyval.TermInstVal = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00004593 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004594 ;
4595 break;}
4596case 274:
Chris Lattner569f7372007-09-10 23:24:14 +00004597#line 2695 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004598{
Chris Lattner0275cff2007-08-06 21:00:46 +00004599 yyval.TermInstVal = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00004600 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004601 ;
4602 break;}
4603case 275:
Chris Lattner569f7372007-09-10 23:24:14 +00004604#line 2702 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004605{
Chris Lattner0275cff2007-08-06 21:00:46 +00004606 yyval.JumpTable = yyvsp[-5].JumpTable;
4607 Constant *V = cast<Constant>(getExistingVal(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004608 CHECK_FOR_ERROR
4609 if (V == 0)
4610 GEN_ERROR("May only switch on a constant pool value");
4611
Chris Lattner0275cff2007-08-06 21:00:46 +00004612 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004613 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004614 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
Dale Johannesencdd509a2007-09-07 21:07:57 +00004615 ;
4616 break;}
4617case 276:
Chris Lattner569f7372007-09-10 23:24:14 +00004618#line 2713 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004619{
Chris Lattner0275cff2007-08-06 21:00:46 +00004620 yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
4621 Constant *V = cast<Constant>(getExistingVal(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004622 CHECK_FOR_ERROR
4623
4624 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004625 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00004626
Chris Lattner0275cff2007-08-06 21:00:46 +00004627 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004628 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004629 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
Dale Johannesencdd509a2007-09-07 21:07:57 +00004630 ;
4631 break;}
4632case 277:
Chris Lattner569f7372007-09-10 23:24:14 +00004633#line 2726 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004634{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004635 // Is this definition named?? if so, assign the name...
Chris Lattner0275cff2007-08-06 21:00:46 +00004636 setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004637 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004638 InsertValue(yyvsp[0].InstVal);
4639 yyval.InstVal = yyvsp[0].InstVal;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004640 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004641 ;
4642 break;}
4643case 278:
Chris Lattner569f7372007-09-10 23:24:14 +00004644#line 2736 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004645{ // Used for PHI nodes
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004646 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004647 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-5].TypeVal)->getDescription());
4648 yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
4649 Value* tmpVal = getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal);
Reid Spencer6f407902007-01-13 05:00:46 +00004650 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004651 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004652 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004653 yyval.PHIList->push_back(std::make_pair(tmpVal, tmpBB));
4654 delete yyvsp[-5].TypeVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00004655 ;
4656 break;}
4657case 279:
Chris Lattner569f7372007-09-10 23:24:14 +00004658#line 2747 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004659{
Chris Lattner0275cff2007-08-06 21:00:46 +00004660 yyval.PHIList = yyvsp[-6].PHIList;
4661 Value* tmpVal = getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004662 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004663 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004664 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004665 yyvsp[-6].PHIList->push_back(std::make_pair(tmpVal, tmpBB));
Dale Johannesencdd509a2007-09-07 21:07:57 +00004666 ;
4667 break;}
4668case 280:
Chris Lattner569f7372007-09-10 23:24:14 +00004669#line 2757 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004670{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004671 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004672 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004673 // Used for call and invoke instructions
Chris Lattner0275cff2007-08-06 21:00:46 +00004674 yyval.ValueRefList = new ValueRefList();
4675 ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal);
4676 yyval.ValueRefList->push_back(E);
4677 delete yyvsp[-2].TypeVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00004678 ;
4679 break;}
4680case 281:
Chris Lattner569f7372007-09-10 23:24:14 +00004681#line 2766 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004682{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004683 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004684 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4685 yyval.ValueRefList = yyvsp[-4].ValueRefList;
4686 ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal);
4687 yyval.ValueRefList->push_back(E);
4688 delete yyvsp[-2].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004689 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004690 ;
4691 break;}
4692case 282:
Chris Lattner569f7372007-09-10 23:24:14 +00004693#line 2775 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004694{ yyval.ValueRefList = new ValueRefList(); ;
4695 break;}
4696case 283:
Chris Lattner569f7372007-09-10 23:24:14 +00004697#line 2778 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004698{ yyval.ValueList = new std::vector<Value*>(); ;
4699 break;}
4700case 284:
Chris Lattner569f7372007-09-10 23:24:14 +00004701#line 2779 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004702{
Chris Lattner0275cff2007-08-06 21:00:46 +00004703 yyval.ValueList = yyvsp[-2].ValueList;
4704 yyval.ValueList->push_back(yyvsp[0].ValueVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004705 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004706 ;
4707 break;}
4708case 285:
Chris Lattner569f7372007-09-10 23:24:14 +00004709#line 2786 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004710{
Chris Lattner0275cff2007-08-06 21:00:46 +00004711 yyval.BoolVal = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004712 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004713 ;
4714 break;}
4715case 286:
Chris Lattner569f7372007-09-10 23:24:14 +00004716#line 2790 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004717{
Chris Lattner0275cff2007-08-06 21:00:46 +00004718 yyval.BoolVal = false;
Andrew Lenharth6353e052006-12-08 18:07:09 +00004719 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004720 ;
4721 break;}
4722case 287:
Chris Lattner569f7372007-09-10 23:24:14 +00004723#line 2795 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004724{
Reid Spencer14310612006-12-31 05:40:51 +00004725 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004726 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4727 if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
4728 !isa<VectorType>((*yyvsp[-3].TypeVal).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004729 GEN_ERROR(
4730 "Arithmetic operator requires integer, FP, or packed operands");
Chris Lattner0275cff2007-08-06 21:00:46 +00004731 if (isa<VectorType>((*yyvsp[-3].TypeVal).get()) &&
4732 (yyvsp[-4].BinaryOpVal == Instruction::URem ||
4733 yyvsp[-4].BinaryOpVal == Instruction::SRem ||
4734 yyvsp[-4].BinaryOpVal == Instruction::FRem))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004735 GEN_ERROR("Remainder not supported on vector types");
Chris Lattner0275cff2007-08-06 21:00:46 +00004736 Value* val1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004737 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004738 Value* val2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004739 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004740 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, val1, val2);
4741 if (yyval.InstVal == 0)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004742 GEN_ERROR("binary operator returned null");
Chris Lattner0275cff2007-08-06 21:00:46 +00004743 delete yyvsp[-3].TypeVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00004744 ;
4745 break;}
4746case 288:
Chris Lattner569f7372007-09-10 23:24:14 +00004747#line 2816 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004748{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004749 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004750 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4751 if (!(*yyvsp[-3].TypeVal)->isInteger()) {
4752 if (Instruction::isShift(yyvsp[-4].BinaryOpVal) || !isa<VectorType>(yyvsp[-3].TypeVal->get()) ||
4753 !cast<VectorType>(yyvsp[-3].TypeVal->get())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004754 GEN_ERROR("Logical operator requires integral operands");
4755 }
Chris Lattner0275cff2007-08-06 21:00:46 +00004756 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004757 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004758 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004759 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004760 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, tmpVal1, tmpVal2);
4761 if (yyval.InstVal == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004762 GEN_ERROR("binary operator returned null");
Chris Lattner0275cff2007-08-06 21:00:46 +00004763 delete yyvsp[-3].TypeVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00004764 ;
4765 break;}
4766case 289:
Chris Lattner569f7372007-09-10 23:24:14 +00004767#line 2833 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004768{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004769 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004770 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4771 if (isa<VectorType>((*yyvsp[-3].TypeVal).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004772 GEN_ERROR("Vector types not supported by icmp instruction");
Chris Lattner0275cff2007-08-06 21:00:46 +00004773 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004774 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004775 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004776 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004777 yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].IPredicate, tmpVal1, tmpVal2);
4778 if (yyval.InstVal == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004779 GEN_ERROR("icmp operator returned null");
Chris Lattner0275cff2007-08-06 21:00:46 +00004780 delete yyvsp[-3].TypeVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00004781 ;
4782 break;}
4783case 290:
Chris Lattner569f7372007-09-10 23:24:14 +00004784#line 2847 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004785{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004786 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004787 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4788 if (isa<VectorType>((*yyvsp[-3].TypeVal).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004789 GEN_ERROR("Vector types not supported by fcmp instruction");
Chris Lattner0275cff2007-08-06 21:00:46 +00004790 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004791 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004792 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004793 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004794 yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].FPredicate, tmpVal1, tmpVal2);
4795 if (yyval.InstVal == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004796 GEN_ERROR("fcmp operator returned null");
Chris Lattner0275cff2007-08-06 21:00:46 +00004797 delete yyvsp[-3].TypeVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00004798 ;
4799 break;}
4800case 291:
Chris Lattner569f7372007-09-10 23:24:14 +00004801#line 2861 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004802{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004803 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004804 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
4805 Value* Val = yyvsp[-2].ValueVal;
4806 const Type* DestTy = yyvsp[0].TypeVal->get();
4807 if (!CastInst::castIsValid(yyvsp[-3].CastOpVal, Val, DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004808 GEN_ERROR("invalid cast opcode for cast from '" +
4809 Val->getType()->getDescription() + "' to '" +
4810 DestTy->getDescription() + "'");
Chris Lattner0275cff2007-08-06 21:00:46 +00004811 yyval.InstVal = CastInst::create(yyvsp[-3].CastOpVal, Val, DestTy);
4812 delete yyvsp[0].TypeVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00004813 ;
4814 break;}
4815case 292:
Chris Lattner569f7372007-09-10 23:24:14 +00004816#line 2873 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004817{
Chris Lattner0275cff2007-08-06 21:00:46 +00004818 if (yyvsp[-4].ValueVal->getType() != Type::Int1Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004819 GEN_ERROR("select condition must be boolean");
Chris Lattner0275cff2007-08-06 21:00:46 +00004820 if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004821 GEN_ERROR("select value types should match");
Chris Lattner0275cff2007-08-06 21:00:46 +00004822 yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004823 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004824 ;
4825 break;}
4826case 293:
Chris Lattner569f7372007-09-10 23:24:14 +00004827#line 2881 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004828{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004829 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004830 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
4831 yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
4832 delete yyvsp[0].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00004833 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004834 ;
4835 break;}
4836case 294:
Chris Lattner569f7372007-09-10 23:24:14 +00004837#line 2888 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004838{
Chris Lattner0275cff2007-08-06 21:00:46 +00004839 if (!ExtractElementInst::isValidOperands(yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004840 GEN_ERROR("Invalid extractelement operands");
Chris Lattner0275cff2007-08-06 21:00:46 +00004841 yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004842 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004843 ;
4844 break;}
4845case 295:
Chris Lattner569f7372007-09-10 23:24:14 +00004846#line 2894 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004847{
Chris Lattner0275cff2007-08-06 21:00:46 +00004848 if (!InsertElementInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004849 GEN_ERROR("Invalid insertelement operands");
Chris Lattner0275cff2007-08-06 21:00:46 +00004850 yyval.InstVal = new InsertElementInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004851 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004852 ;
4853 break;}
4854case 296:
Chris Lattner569f7372007-09-10 23:24:14 +00004855#line 2900 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004856{
Chris Lattner0275cff2007-08-06 21:00:46 +00004857 if (!ShuffleVectorInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004858 GEN_ERROR("Invalid shufflevector operands");
Chris Lattner0275cff2007-08-06 21:00:46 +00004859 yyval.InstVal = new ShuffleVectorInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004860 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004861 ;
4862 break;}
4863case 297:
Chris Lattner569f7372007-09-10 23:24:14 +00004864#line 2906 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004865{
Chris Lattner0275cff2007-08-06 21:00:46 +00004866 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004867 if (!Ty->isFirstClassType())
4868 GEN_ERROR("PHI node operands must be of first class type");
Chris Lattner0275cff2007-08-06 21:00:46 +00004869 yyval.InstVal = new PHINode(Ty);
4870 ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
4871 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
4872 if (yyvsp[0].PHIList->front().first->getType() != Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004873 GEN_ERROR("All elements of a PHI node must be of the same type");
Chris Lattner0275cff2007-08-06 21:00:46 +00004874 cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
4875 yyvsp[0].PHIList->pop_front();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004876 }
Chris Lattner0275cff2007-08-06 21:00:46 +00004877 delete yyvsp[0].PHIList; // Free the list...
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004878 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004879 ;
4880 break;}
4881case 298:
Chris Lattner569f7372007-09-10 23:24:14 +00004882#line 2922 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004883{
Reid Spencer14310612006-12-31 05:40:51 +00004884
4885 // Handle the short syntax
Andrew Lenharth6353e052006-12-08 18:07:09 +00004886 const PointerType *PFTy = 0;
4887 const FunctionType *Ty = 0;
Chris Lattner0275cff2007-08-06 21:00:46 +00004888 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-5].TypeVal->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00004889 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4890 // Pull out the types of all of the arguments...
4891 std::vector<const Type*> ParamTypes;
Christopher Lamb5c104242007-04-22 20:09:11 +00004892 ParamAttrsVector Attrs;
Chris Lattner0275cff2007-08-06 21:00:46 +00004893 if (yyvsp[0].ParamAttrs != ParamAttr::None) {
4894 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[0].ParamAttrs;
Christopher Lamb5c104242007-04-22 20:09:11 +00004895 Attrs.push_back(PAWI);
4896 }
Reid Spencer7b5d4662007-04-09 06:16:21 +00004897 unsigned index = 1;
Chris Lattner0275cff2007-08-06 21:00:46 +00004898 ValueRefList::iterator I = yyvsp[-2].ValueRefList->begin(), E = yyvsp[-2].ValueRefList->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00004899 for (; I != E; ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00004900 const Type *Ty = I->Val->getType();
4901 if (Ty == Type::VoidTy)
4902 GEN_ERROR("Short call syntax cannot be used with varargs");
4903 ParamTypes.push_back(Ty);
Christopher Lamb5c104242007-04-22 20:09:11 +00004904 if (I->Attrs != ParamAttr::None) {
4905 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
4906 Attrs.push_back(PAWI);
4907 }
Andrew Lenharth6353e052006-12-08 18:07:09 +00004908 }
4909
Christopher Lamb5c104242007-04-22 20:09:11 +00004910 ParamAttrsList *PAL = 0;
4911 if (!Attrs.empty())
4912 PAL = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00004913
Chris Lattner0275cff2007-08-06 21:00:46 +00004914 Ty = FunctionType::get(yyvsp[-5].TypeVal->get(), ParamTypes, false, PAL);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004915 PFTy = PointerType::get(Ty);
4916 }
Chris Lattner6cdc6822007-04-26 05:31:05 +00004917
Chris Lattner0275cff2007-08-06 21:00:46 +00004918 Value *V = getVal(PFTy, yyvsp[-4].ValIDVal); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00004919 CHECK_FOR_ERROR
Chris Lattner6cdc6822007-04-26 05:31:05 +00004920
Reid Spencer7780acb2007-04-16 06:56:07 +00004921 // Check for call to invalid intrinsic to avoid crashing later.
4922 if (Function *theF = dyn_cast<Function>(V)) {
Reid Spencered48de22007-04-16 22:02:23 +00004923 if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) &&
Reid Spencer36fdde12007-04-16 20:35:38 +00004924 (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) &&
4925 !theF->getIntrinsicID(true))
Reid Spencer7780acb2007-04-16 06:56:07 +00004926 GEN_ERROR("Call to invalid LLVM intrinsic function '" +
4927 theF->getName() + "'");
4928 }
4929
Reid Spencer14310612006-12-31 05:40:51 +00004930 // Check the arguments
4931 ValueList Args;
Chris Lattner0275cff2007-08-06 21:00:46 +00004932 if (yyvsp[-2].ValueRefList->empty()) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00004933 // Make sure no arguments is a good thing!
4934 if (Ty->getNumParams() != 0)
4935 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00004936 "expects arguments");
Andrew Lenharth6353e052006-12-08 18:07:09 +00004937 } else { // Has arguments?
4938 // Loop through FunctionType's arguments and ensure they are specified
4939 // correctly!
4940 //
4941 FunctionType::param_iterator I = Ty->param_begin();
4942 FunctionType::param_iterator E = Ty->param_end();
Chris Lattner0275cff2007-08-06 21:00:46 +00004943 ValueRefList::iterator ArgI = yyvsp[-2].ValueRefList->begin(), ArgE = yyvsp[-2].ValueRefList->end();
Andrew Lenharth6353e052006-12-08 18:07:09 +00004944
Reid Spencer14310612006-12-31 05:40:51 +00004945 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
4946 if (ArgI->Val->getType() != *I)
4947 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00004948 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00004949 Args.push_back(ArgI->Val);
4950 }
4951 if (Ty->isVarArg()) {
4952 if (I == E)
4953 for (; ArgI != ArgE; ++ArgI)
4954 Args.push_back(ArgI->Val); // push the remaining varargs
4955 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00004956 GEN_ERROR("Invalid number of parameters detected");
Andrew Lenharth6353e052006-12-08 18:07:09 +00004957 }
Reid Spencer14310612006-12-31 05:40:51 +00004958 // Create the call node
David Greene718fda32007-08-01 03:59:32 +00004959 CallInst *CI = new CallInst(V, Args.begin(), Args.end());
Chris Lattner0275cff2007-08-06 21:00:46 +00004960 CI->setTailCall(yyvsp[-7].BoolVal);
4961 CI->setCallingConv(yyvsp[-6].UIntVal);
4962 yyval.InstVal = CI;
4963 delete yyvsp[-2].ValueRefList;
4964 delete yyvsp[-5].TypeVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004965 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004966 ;
4967 break;}
4968case 299:
Chris Lattner569f7372007-09-10 23:24:14 +00004969#line 3006 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004970{
Chris Lattner0275cff2007-08-06 21:00:46 +00004971 yyval.InstVal = yyvsp[0].InstVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004972 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004973 ;
4974 break;}
4975case 300:
Chris Lattner569f7372007-09-10 23:24:14 +00004976#line 3011 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004977{
Chris Lattner0275cff2007-08-06 21:00:46 +00004978 yyval.BoolVal = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004979 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004980 ;
4981 break;}
4982case 301:
Chris Lattner569f7372007-09-10 23:24:14 +00004983#line 3015 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004984{
Chris Lattner0275cff2007-08-06 21:00:46 +00004985 yyval.BoolVal = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00004986 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004987 ;
4988 break;}
4989case 302:
Chris Lattner569f7372007-09-10 23:24:14 +00004990#line 3022 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004991{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004992 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004993 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4994 yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
4995 delete yyvsp[-1].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00004996 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004997 ;
4998 break;}
4999case 303:
Chris Lattner569f7372007-09-10 23:24:14 +00005000#line 3029 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00005001{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005002 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00005003 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
5004 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005005 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00005006 yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
5007 delete yyvsp[-4].TypeVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00005008 ;
5009 break;}
5010case 304:
Chris Lattner569f7372007-09-10 23:24:14 +00005011#line 3037 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00005012{
Reid Spencer14310612006-12-31 05:40:51 +00005013 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00005014 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
5015 yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
5016 delete yyvsp[-1].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00005017 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00005018 ;
5019 break;}
5020case 305:
Chris Lattner569f7372007-09-10 23:24:14 +00005021#line 3044 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00005022{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005023 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00005024 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
5025 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005026 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00005027 yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
5028 delete yyvsp[-4].TypeVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00005029 ;
5030 break;}
5031case 306:
Chris Lattner569f7372007-09-10 23:24:14 +00005032#line 3052 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00005033{
Chris Lattner0275cff2007-08-06 21:00:46 +00005034 if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005035 GEN_ERROR("Trying to free nonpointer type " +
Chris Lattner0275cff2007-08-06 21:00:46 +00005036 yyvsp[0].ValueVal->getType()->getDescription() + "");
5037 yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005038 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00005039 ;
5040 break;}
5041case 307:
Chris Lattner569f7372007-09-10 23:24:14 +00005042#line 3060 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00005043{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005044 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00005045 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
5046 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005047 GEN_ERROR("Can't load from nonpointer type: " +
Chris Lattner0275cff2007-08-06 21:00:46 +00005048 (*yyvsp[-2].TypeVal)->getDescription());
5049 if (!cast<PointerType>(yyvsp[-2].TypeVal->get())->getElementType()->isFirstClassType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005050 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Chris Lattner0275cff2007-08-06 21:00:46 +00005051 (*yyvsp[-2].TypeVal)->getDescription());
5052 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005053 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00005054 yyval.InstVal = new LoadInst(tmpVal, "", yyvsp[-4].BoolVal, yyvsp[0].UIntVal);
5055 delete yyvsp[-2].TypeVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00005056 ;
5057 break;}
5058case 308:
Chris Lattner569f7372007-09-10 23:24:14 +00005059#line 3074 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00005060{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005061 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00005062 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
5063 const PointerType *PT = dyn_cast<PointerType>(yyvsp[-2].TypeVal->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005064 if (!PT)
5065 GEN_ERROR("Can't store to a nonpointer type: " +
Chris Lattner0275cff2007-08-06 21:00:46 +00005066 (*yyvsp[-2].TypeVal)->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005067 const Type *ElTy = PT->getElementType();
Chris Lattner0275cff2007-08-06 21:00:46 +00005068 if (ElTy != yyvsp[-4].ValueVal->getType())
5069 GEN_ERROR("Can't store '" + yyvsp[-4].ValueVal->getType()->getDescription() +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005070 "' into space of type '" + ElTy->getDescription() + "'");
5071
Chris Lattner0275cff2007-08-06 21:00:46 +00005072 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005073 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00005074 yyval.InstVal = new StoreInst(yyvsp[-4].ValueVal, tmpVal, yyvsp[-6].BoolVal, yyvsp[0].UIntVal);
5075 delete yyvsp[-2].TypeVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00005076 ;
5077 break;}
5078case 309:
Chris Lattner569f7372007-09-10 23:24:14 +00005079#line 3091 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00005080{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005081 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00005082 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
5083 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
Reid Spencerb5334b02007-02-05 10:18:06 +00005084 GEN_ERROR("getelementptr insn requires pointer operand");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005085
David Greene5fd22a82007-09-04 18:46:50 +00005086 if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end(), true))
Reid Spencer61c83e02006-08-18 08:43:06 +00005087 GEN_ERROR("Invalid getelementptr indices for type '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00005088 (*yyvsp[-2].TypeVal)->getDescription()+ "'");
5089 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005090 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005091 yyval.InstVal = new GetElementPtrInst(tmpVal, yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end());
Chris Lattner0275cff2007-08-06 21:00:46 +00005092 delete yyvsp[-2].TypeVal;
5093 delete yyvsp[0].ValueList;
Dale Johannesencdd509a2007-09-07 21:07:57 +00005094 ;
5095 break;}
5096}
5097 /* the action file gets copied in in place of this dollarsign */
5098#line 543 "/usr/share/bison.simple"
Chris Lattner0275cff2007-08-06 21:00:46 +00005099
5100 yyvsp -= yylen;
5101 yyssp -= yylen;
Dale Johannesencdd509a2007-09-07 21:07:57 +00005102#ifdef YYLSP_NEEDED
5103 yylsp -= yylen;
5104#endif
Reid Spencer7780acb2007-04-16 06:56:07 +00005105
Dale Johannesencdd509a2007-09-07 21:07:57 +00005106#if YYDEBUG != 0
5107 if (yydebug)
5108 {
5109 short *ssp1 = yyss - 1;
5110 fprintf (stderr, "state stack now");
5111 while (ssp1 != yyssp)
5112 fprintf (stderr, " %d", *++ssp1);
5113 fprintf (stderr, "\n");
5114 }
5115#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00005116
5117 *++yyvsp = yyval;
5118
Dale Johannesencdd509a2007-09-07 21:07:57 +00005119#ifdef YYLSP_NEEDED
5120 yylsp++;
5121 if (yylen == 0)
5122 {
5123 yylsp->first_line = yylloc.first_line;
5124 yylsp->first_column = yylloc.first_column;
5125 yylsp->last_line = (yylsp-1)->last_line;
5126 yylsp->last_column = (yylsp-1)->last_column;
5127 yylsp->text = 0;
5128 }
5129 else
5130 {
5131 yylsp->last_line = (yylsp+yylen-1)->last_line;
5132 yylsp->last_column = (yylsp+yylen-1)->last_column;
5133 }
5134#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00005135
Dale Johannesencdd509a2007-09-07 21:07:57 +00005136 /* Now "shift" the result of the reduction.
5137 Determine what state that goes to,
5138 based on the state we popped back to
5139 and the rule number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005140
5141 yyn = yyr1[yyn];
5142
Dale Johannesencdd509a2007-09-07 21:07:57 +00005143 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
5144 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005145 yystate = yytable[yystate];
5146 else
Dale Johannesencdd509a2007-09-07 21:07:57 +00005147 yystate = yydefgoto[yyn - YYNTBASE];
Reid Spencer68a24bd2005-08-27 18:50:39 +00005148
5149 goto yynewstate;
5150
Dale Johannesencdd509a2007-09-07 21:07:57 +00005151yyerrlab: /* here on detecting error */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005152
Dale Johannesencdd509a2007-09-07 21:07:57 +00005153 if (! yyerrstatus)
5154 /* If not already recovering from an error, report this error. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005155 {
5156 ++yynerrs;
Dale Johannesencdd509a2007-09-07 21:07:57 +00005157
5158#ifdef YYERROR_VERBOSE
Chris Lattner0275cff2007-08-06 21:00:46 +00005159 yyn = yypact[yystate];
5160
Dale Johannesencdd509a2007-09-07 21:07:57 +00005161 if (yyn > YYFLAG && yyn < YYLAST)
Chris Lattner0275cff2007-08-06 21:00:46 +00005162 {
Dale Johannesencdd509a2007-09-07 21:07:57 +00005163 int size = 0;
5164 char *msg;
5165 int x, count;
Chris Lattner0275cff2007-08-06 21:00:46 +00005166
Dale Johannesencdd509a2007-09-07 21:07:57 +00005167 count = 0;
5168 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
5169 for (x = (yyn < 0 ? -yyn : 0);
5170 x < (sizeof(yytname) / sizeof(char *)); x++)
5171 if (yycheck[x + yyn] == x)
5172 size += strlen(yytname[x]) + 15, count++;
5173 msg = (char *) malloc(size + 15);
5174 if (msg != 0)
Chris Lattner0275cff2007-08-06 21:00:46 +00005175 {
Dale Johannesencdd509a2007-09-07 21:07:57 +00005176 strcpy(msg, "parse error");
Chris Lattner0275cff2007-08-06 21:00:46 +00005177
Dale Johannesencdd509a2007-09-07 21:07:57 +00005178 if (count < 5)
Chris Lattner0275cff2007-08-06 21:00:46 +00005179 {
Dale Johannesencdd509a2007-09-07 21:07:57 +00005180 count = 0;
5181 for (x = (yyn < 0 ? -yyn : 0);
5182 x < (sizeof(yytname) / sizeof(char *)); x++)
5183 if (yycheck[x + yyn] == x)
Chris Lattner0275cff2007-08-06 21:00:46 +00005184 {
Dale Johannesencdd509a2007-09-07 21:07:57 +00005185 strcat(msg, count == 0 ? ", expecting `" : " or `");
5186 strcat(msg, yytname[x]);
5187 strcat(msg, "'");
5188 count++;
Chris Lattner0275cff2007-08-06 21:00:46 +00005189 }
5190 }
Dale Johannesencdd509a2007-09-07 21:07:57 +00005191 yyerror(msg);
5192 free(msg);
Chris Lattner0275cff2007-08-06 21:00:46 +00005193 }
5194 else
Dale Johannesencdd509a2007-09-07 21:07:57 +00005195 yyerror ("parse error; also virtual memory exceeded");
Chris Lattner0275cff2007-08-06 21:00:46 +00005196 }
5197 else
5198#endif /* YYERROR_VERBOSE */
Dale Johannesencdd509a2007-09-07 21:07:57 +00005199 yyerror("parse error");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005200 }
5201
Dale Johannesencdd509a2007-09-07 21:07:57 +00005202 goto yyerrlab1;
5203yyerrlab1: /* here on error raised explicitly by an action */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005204
5205 if (yyerrstatus == 3)
5206 {
Dale Johannesencdd509a2007-09-07 21:07:57 +00005207 /* if just tried and failed to reuse lookahead token after an error, discard it. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005208
Dale Johannesencdd509a2007-09-07 21:07:57 +00005209 /* return failure if at end of input */
5210 if (yychar == YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005211 YYABORT;
5212
Dale Johannesencdd509a2007-09-07 21:07:57 +00005213#if YYDEBUG != 0
5214 if (yydebug)
5215 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
5216#endif
5217
5218 yychar = YYEMPTY;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005219 }
5220
Dale Johannesencdd509a2007-09-07 21:07:57 +00005221 /* Else will try to reuse lookahead token
5222 after shifting the error token. */
5223
5224 yyerrstatus = 3; /* Each real token shifted decrements this */
5225
5226 goto yyerrhandle;
5227
5228yyerrdefault: /* current state does not do anything special for the error token. */
5229
5230#if 0
5231 /* This is wrong; only states that explicitly want error tokens
5232 should shift them. */
5233 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
5234 if (yyn) goto yydefault;
5235#endif
5236
5237yyerrpop: /* pop the current state because it cannot handle the error token */
5238
5239 if (yyssp == yyss) YYABORT;
5240 yyvsp--;
5241 yystate = *--yyssp;
5242#ifdef YYLSP_NEEDED
5243 yylsp--;
5244#endif
5245
5246#if YYDEBUG != 0
5247 if (yydebug)
5248 {
5249 short *ssp1 = yyss - 1;
5250 fprintf (stderr, "Error: state stack now");
5251 while (ssp1 != yyssp)
5252 fprintf (stderr, " %d", *++ssp1);
5253 fprintf (stderr, "\n");
5254 }
5255#endif
5256
5257yyerrhandle:
5258
5259 yyn = yypact[yystate];
5260 if (yyn == YYFLAG)
5261 goto yyerrdefault;
5262
5263 yyn += YYTERROR;
5264 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
5265 goto yyerrdefault;
5266
5267 yyn = yytable[yyn];
5268 if (yyn < 0)
5269 {
5270 if (yyn == YYFLAG)
5271 goto yyerrpop;
5272 yyn = -yyn;
5273 goto yyreduce;
5274 }
5275 else if (yyn == 0)
5276 goto yyerrpop;
5277
Reid Spencer68a24bd2005-08-27 18:50:39 +00005278 if (yyn == YYFINAL)
5279 YYACCEPT;
5280
Dale Johannesencdd509a2007-09-07 21:07:57 +00005281#if YYDEBUG != 0
5282 if (yydebug)
5283 fprintf(stderr, "Shifting error token, ");
5284#endif
Chris Lattner0275cff2007-08-06 21:00:46 +00005285
Reid Spencer68a24bd2005-08-27 18:50:39 +00005286 *++yyvsp = yylval;
Dale Johannesencdd509a2007-09-07 21:07:57 +00005287#ifdef YYLSP_NEEDED
5288 *++yylsp = yylloc;
5289#endif
Reid Spencerb8f85052007-07-31 03:50:36 +00005290
Reid Spencer68a24bd2005-08-27 18:50:39 +00005291 yystate = yyn;
5292 goto yynewstate;
5293
Dale Johannesencdd509a2007-09-07 21:07:57 +00005294 yyacceptlab:
5295 /* YYACCEPT comes here. */
5296 if (yyfree_stacks)
5297 {
5298 free (yyss);
5299 free (yyvs);
5300#ifdef YYLSP_NEEDED
5301 free (yyls);
Chandler Carruth02202192007-08-04 01:56:21 +00005302#endif
Dale Johannesencdd509a2007-09-07 21:07:57 +00005303 }
5304 return 0;
David Greene5fd22a82007-09-04 18:46:50 +00005305
Dale Johannesencdd509a2007-09-07 21:07:57 +00005306 yyabortlab:
5307 /* YYABORT comes here. */
5308 if (yyfree_stacks)
5309 {
5310 free (yyss);
5311 free (yyvs);
5312#ifdef YYLSP_NEEDED
5313 free (yyls);
David Greene5fd22a82007-09-04 18:46:50 +00005314#endif
Dale Johannesencdd509a2007-09-07 21:07:57 +00005315 }
5316 return 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005317}
Chris Lattner569f7372007-09-10 23:24:14 +00005318#line 3108 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00005319
5320
Reid Spencer14310612006-12-31 05:40:51 +00005321// common code from the two 'RunVMAsmParser' functions
5322static Module* RunParser(Module * M) {
5323
5324 llvmAsmlineno = 1; // Reset the current line number...
5325 CurModule.CurrentModule = M;
5326#if YYDEBUG
5327 yydebug = Debug;
5328#endif
5329
5330 // Check to make sure the parser succeeded
5331 if (yyparse()) {
5332 if (ParserResult)
5333 delete ParserResult;
5334 return 0;
5335 }
5336
Reid Spencer0d60b5a2007-03-30 01:37:39 +00005337 // Emit an error if there are any unresolved types left.
5338 if (!CurModule.LateResolveTypes.empty()) {
5339 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
5340 if (DID.Type == ValID::LocalName) {
5341 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
5342 } else {
5343 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
5344 }
5345 if (ParserResult)
5346 delete ParserResult;
5347 return 0;
5348 }
5349
5350 // Emit an error if there are any unresolved values left.
5351 if (!CurModule.LateResolveValues.empty()) {
5352 Value *V = CurModule.LateResolveValues.back();
5353 std::map<Value*, std::pair<ValID, int> >::iterator I =
5354 CurModule.PlaceHolderInfo.find(V);
5355
5356 if (I != CurModule.PlaceHolderInfo.end()) {
5357 ValID &DID = I->second.first;
5358 if (DID.Type == ValID::LocalName) {
5359 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
5360 } else {
5361 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
5362 }
5363 if (ParserResult)
5364 delete ParserResult;
5365 return 0;
5366 }
5367 }
5368
Reid Spencer14310612006-12-31 05:40:51 +00005369 // Check to make sure that parsing produced a result
5370 if (!ParserResult)
5371 return 0;
5372
5373 // Reset ParserResult variable while saving its value for the result.
5374 Module *Result = ParserResult;
5375 ParserResult = 0;
5376
5377 return Result;
5378}
5379
Reid Spencer61c83e02006-08-18 08:43:06 +00005380void llvm::GenerateError(const std::string &message, int LineNo) {
5381 if (LineNo == -1) LineNo = llvmAsmlineno;
5382 // TODO: column number in exception
5383 if (TheParseError)
5384 TheParseError->setError(CurFilename, message, LineNo);
5385 TriggerError = 1;
5386}
Reid Spencer68a24bd2005-08-27 18:50:39 +00005387
5388int yyerror(const char *ErrorMsg) {
5389 std::string where
5390 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
5391 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
Reid Spenceref9b9a72007-02-05 20:47:22 +00005392 std::string errMsg = where + "error: " + std::string(ErrorMsg);
5393 if (yychar != YYEMPTY && yychar != 0)
5394 errMsg += " while reading token: '" + std::string(llvmAsmtext, llvmAsmleng)+
5395 "'";
Reid Spencer61c83e02006-08-18 08:43:06 +00005396 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005397 return 0;
5398}