blob: 7a11236f8c7b4ec469ece638329a2ae912ee85e3 [file] [log] [blame]
Reid Spencer68a24bd2005-08-27 18:50:39 +00001
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002/* A Bison parser, made from /Volumes/MacOS9/gcc/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
Dale Johannesenc72cd7e2007-09-11 18:33:39 +0000158#line 14 "/Volumes/MacOS9/gcc/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 Johannesenc72cd7e2007-09-11 18:33:39 +0000564 // Lexer has no type info, so builds all float and double FP constants
565 // as double. Fix this here. Long double does not need this.
566 if (&D.ConstPoolFP->getSemantics() == &APFloat::IEEEdouble &&
567 Ty==Type::FloatTy)
Dale Johannesencdd509a2007-09-07 21:07:57 +0000568 D.ConstPoolFP->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
569 return ConstantFP::get(Ty, *D.ConstPoolFP);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000570
571 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000572 if (!isa<PointerType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000573 GenerateError("Cannot create a a non pointer null");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000574 return 0;
575 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000576 return ConstantPointerNull::get(cast<PointerType>(Ty));
577
578 case ValID::ConstUndefVal: // Is it an undef value?
579 return UndefValue::get(Ty);
580
Chris Lattner7aa61892005-12-21 17:53:23 +0000581 case ValID::ConstZeroVal: // Is it a zero value?
582 return Constant::getNullValue(Ty);
583
Reid Spencer68a24bd2005-08-27 18:50:39 +0000584 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000585 if (D.ConstantValue->getType() != Ty) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000586 GenerateError("Constant expression type different from required type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000587 return 0;
588 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000589 return D.ConstantValue;
590
Chris Lattner0e9c3762006-01-25 22:27:16 +0000591 case ValID::InlineAsmVal: { // Inline asm expression
592 const PointerType *PTy = dyn_cast<PointerType>(Ty);
593 const FunctionType *FTy =
594 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000595 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000596 GenerateError("Invalid type for asm constraint string");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000597 return 0;
598 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000599 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
600 D.IAD->HasSideEffects);
601 D.destroy(); // Free InlineAsmDescriptor.
602 return IA;
603 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000604 default:
Reid Spencera9720f52007-02-05 17:04:00 +0000605 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000606 return 0;
607 } // End of switch
608
Reid Spencera9720f52007-02-05 17:04:00 +0000609 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000610 return 0;
611}
612
Reid Spencer93c40032007-03-19 18:40:50 +0000613// getVal - This function is identical to getExistingVal, except that if a
Reid Spencer68a24bd2005-08-27 18:50:39 +0000614// value is not already defined, it "improvises" by creating a placeholder var
615// that looks and acts just like the requested variable. When the value is
616// defined later, all uses of the placeholder variable are replaced with the
617// real thing.
618//
619static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000620 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000621 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000622 return 0;
623 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000624
625 // See if the value has already been defined.
Reid Spencer93c40032007-03-19 18:40:50 +0000626 Value *V = getExistingVal(Ty, ID);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000627 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000628 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000629
Reid Spencer5b7e7532006-09-28 19:28:24 +0000630 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000631 GenerateError("Invalid use of a composite type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000632 return 0;
633 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000634
635 // If we reached here, we referenced either a symbol that we don't know about
636 // or an id number that hasn't been read yet. We may be referencing something
637 // forward, so just create an entry to be resolved later and get to it...
638 //
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000639 switch (ID.Type) {
640 case ValID::GlobalName:
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000641 case ValID::GlobalID: {
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000642 const PointerType *PTy = dyn_cast<PointerType>(Ty);
643 if (!PTy) {
644 GenerateError("Invalid type for reference to global" );
645 return 0;
646 }
647 const Type* ElTy = PTy->getElementType();
648 if (const FunctionType *FTy = dyn_cast<FunctionType>(ElTy))
649 V = new Function(FTy, GlobalValue::ExternalLinkage);
650 else
651 V = new GlobalVariable(ElTy, false, GlobalValue::ExternalLinkage);
652 break;
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000653 }
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000654 default:
655 V = new Argument(Ty);
656 }
657
Reid Spencer68a24bd2005-08-27 18:50:39 +0000658 // Remember where this forward reference came from. FIXME, shouldn't we try
659 // to recycle these things??
660 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
661 llvmAsmlineno)));
662
663 if (inFunctionScope())
664 InsertValue(V, CurFun.LateResolveValues);
665 else
666 InsertValue(V, CurModule.LateResolveValues);
667 return V;
668}
669
Reid Spencer93c40032007-03-19 18:40:50 +0000670/// defineBBVal - This is a definition of a new basic block with the specified
671/// identifier which must be the same as CurFun.NextValNum, if its numeric.
672static BasicBlock *defineBBVal(const ValID &ID) {
Reid Spencera9720f52007-02-05 17:04:00 +0000673 assert(inFunctionScope() && "Can't get basic block at global scope!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000674
Reid Spencer68a24bd2005-08-27 18:50:39 +0000675 BasicBlock *BB = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000676
Reid Spencer93c40032007-03-19 18:40:50 +0000677 // First, see if this was forward referenced
Reid Spencer68a24bd2005-08-27 18:50:39 +0000678
Reid Spencer93c40032007-03-19 18:40:50 +0000679 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
680 if (BBI != CurFun.BBForwardRefs.end()) {
681 BB = BBI->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000682 // The forward declaration could have been inserted anywhere in the
683 // function: insert it into the correct place now.
684 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
685 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
Reid Spencer93c40032007-03-19 18:40:50 +0000686
Reid Spencer66728ef2007-03-20 01:13:36 +0000687 // We're about to erase the entry, save the key so we can clean it up.
688 ValID Tmp = BBI->first;
689
Reid Spencer93c40032007-03-19 18:40:50 +0000690 // Erase the forward ref from the map as its no longer "forward"
691 CurFun.BBForwardRefs.erase(ID);
692
Reid Spencer66728ef2007-03-20 01:13:36 +0000693 // The key has been removed from the map but so we don't want to leave
694 // strdup'd memory around so destroy it too.
695 Tmp.destroy();
696
Reid Spencer93c40032007-03-19 18:40:50 +0000697 // If its a numbered definition, bump the number and set the BB value.
698 if (ID.Type == ValID::LocalID) {
699 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
700 InsertValue(BB);
701 }
702
703 ID.destroy();
704 return BB;
705 }
706
707 // We haven't seen this BB before and its first mention is a definition.
708 // Just create it and return it.
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000709 std::string Name (ID.Type == ValID::LocalName ? ID.getName() : "");
Reid Spencer93c40032007-03-19 18:40:50 +0000710 BB = new BasicBlock(Name, CurFun.CurrentFunction);
711 if (ID.Type == ValID::LocalID) {
712 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
713 InsertValue(BB);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000714 }
Reid Spencer93c40032007-03-19 18:40:50 +0000715
716 ID.destroy(); // Free strdup'd memory
717 return BB;
718}
719
720/// getBBVal - get an existing BB value or create a forward reference for it.
721///
722static BasicBlock *getBBVal(const ValID &ID) {
723 assert(inFunctionScope() && "Can't get basic block at global scope!");
724
725 BasicBlock *BB = 0;
726
727 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
728 if (BBI != CurFun.BBForwardRefs.end()) {
729 BB = BBI->second;
730 } if (ID.Type == ValID::LocalName) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000731 std::string Name = ID.getName();
Reid Spencer93c40032007-03-19 18:40:50 +0000732 Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
733 if (N)
734 if (N->getType()->getTypeID() == Type::LabelTyID)
735 BB = cast<BasicBlock>(N);
736 else
737 GenerateError("Reference to label '" + Name + "' is actually of type '"+
738 N->getType()->getDescription() + "'");
739 } else if (ID.Type == ValID::LocalID) {
740 if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) {
741 if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID)
742 BB = cast<BasicBlock>(CurFun.Values[ID.Num]);
743 else
744 GenerateError("Reference to label '%" + utostr(ID.Num) +
745 "' is actually of type '"+
746 CurFun.Values[ID.Num]->getType()->getDescription() + "'");
747 }
748 } else {
749 GenerateError("Illegal label reference " + ID.getName());
750 return 0;
751 }
752
753 // If its already been defined, return it now.
754 if (BB) {
755 ID.destroy(); // Free strdup'd memory.
756 return BB;
757 }
758
759 // Otherwise, this block has not been seen before, create it.
760 std::string Name;
761 if (ID.Type == ValID::LocalName)
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000762 Name = ID.getName();
Reid Spencer93c40032007-03-19 18:40:50 +0000763 BB = new BasicBlock(Name, CurFun.CurrentFunction);
764
765 // Insert it in the forward refs map.
766 CurFun.BBForwardRefs[ID] = BB;
767
Reid Spencer68a24bd2005-08-27 18:50:39 +0000768 return BB;
769}
770
771
772//===----------------------------------------------------------------------===//
773// Code to handle forward references in instructions
774//===----------------------------------------------------------------------===//
775//
776// This code handles the late binding needed with statements that reference
777// values not defined yet... for example, a forward branch, or the PHI node for
778// a loop body.
779//
780// This keeps a table (CurFun.LateResolveValues) of all such forward references
781// and back patchs after we are done.
782//
783
784// ResolveDefinitions - If we could not resolve some defs at parsing
785// time (forward branches, phi functions for loops, etc...) resolve the
786// defs now...
787//
788static void
Reid Spencer93c40032007-03-19 18:40:50 +0000789ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000790 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
Reid Spencer93c40032007-03-19 18:40:50 +0000791 while (!LateResolvers.empty()) {
792 Value *V = LateResolvers.back();
793 LateResolvers.pop_back();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000794
Reid Spencer93c40032007-03-19 18:40:50 +0000795 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
796 CurModule.PlaceHolderInfo.find(V);
797 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000798
Reid Spencer93c40032007-03-19 18:40:50 +0000799 ValID &DID = PHI->second.first;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000800
Reid Spencer93c40032007-03-19 18:40:50 +0000801 Value *TheRealValue = getExistingVal(V->getType(), DID);
802 if (TriggerError)
803 return;
804 if (TheRealValue) {
805 V->replaceAllUsesWith(TheRealValue);
806 delete V;
807 CurModule.PlaceHolderInfo.erase(PHI);
808 } else if (FutureLateResolvers) {
809 // Functions have their unresolved items forwarded to the module late
810 // resolver table
811 InsertValue(V, *FutureLateResolvers);
812 } else {
813 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
814 GenerateError("Reference to an invalid definition: '" +DID.getName()+
815 "' of type '" + V->getType()->getDescription() + "'",
816 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000817 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000818 } else {
Reid Spencer93c40032007-03-19 18:40:50 +0000819 GenerateError("Reference to an invalid definition: #" +
820 itostr(DID.Num) + " of type '" +
821 V->getType()->getDescription() + "'",
822 PHI->second.second);
823 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000824 }
825 }
826 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000827 LateResolvers.clear();
828}
829
830// ResolveTypeTo - A brand new type was just declared. This means that (if
831// name is not null) things referencing Name can be resolved. Otherwise, things
832// refering to the number can be resolved. Do this now.
833//
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000834static void ResolveTypeTo(std::string *Name, const Type *ToTy) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000835 ValID D;
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000836 if (Name)
837 D = ValID::createLocalName(*Name);
838 else
839 D = ValID::createLocalID(CurModule.Types.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +0000840
Reid Spencer861d9d62006-11-28 07:29:44 +0000841 std::map<ValID, PATypeHolder>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +0000842 CurModule.LateResolveTypes.find(D);
843 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer861d9d62006-11-28 07:29:44 +0000844 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000845 CurModule.LateResolveTypes.erase(I);
846 }
847}
848
849// setValueName - Set the specified value to the name given. The name may be
850// null potentially, in which case this is a noop. The string passed in is
851// assumed to be a malloc'd string buffer, and is free'd by this function.
852//
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000853static void setValueName(Value *V, std::string *NameStr) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000854 if (!NameStr) return;
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000855 std::string Name(*NameStr); // Copy string
856 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +0000857
Reid Spencer41dff5e2007-01-26 08:05:27 +0000858 if (V->getType() == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000859 GenerateError("Can't assign name '" + Name+"' to value with void type");
Reid Spencer41dff5e2007-01-26 08:05:27 +0000860 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000861 }
Reid Spencer41dff5e2007-01-26 08:05:27 +0000862
Reid Spencera9720f52007-02-05 17:04:00 +0000863 assert(inFunctionScope() && "Must be in function scope!");
Reid Spenceref9b9a72007-02-05 20:47:22 +0000864 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
865 if (ST.lookup(Name)) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000866 GenerateError("Redefinition of value '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000867 V->getType()->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +0000868 return;
869 }
870
871 // Set the name.
872 V->setName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000873}
874
875/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
876/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +0000877static GlobalVariable *
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000878ParseGlobalVariable(std::string *NameStr,
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000879 GlobalValue::LinkageTypes Linkage,
880 GlobalValue::VisibilityTypes Visibility,
Chris Lattnerb475c422005-11-12 18:22:38 +0000881 bool isConstantGlobal, const Type *Ty,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +0000882 Constant *Initializer, bool IsThreadLocal) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000883 if (isa<FunctionType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000884 GenerateError("Cannot declare global vars of function type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000885 return 0;
886 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000887
888 const PointerType *PTy = PointerType::get(Ty);
889
890 std::string Name;
891 if (NameStr) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000892 Name = *NameStr; // Copy string
893 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +0000894 }
895
896 // See if this global value was forward referenced. If so, recycle the
897 // object.
898 ValID ID;
899 if (!Name.empty()) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000900 ID = ValID::createGlobalName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000901 } else {
Reid Spencer93c40032007-03-19 18:40:50 +0000902 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +0000903 }
904
905 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
906 // Move the global to the end of the list, from whereever it was
907 // previously inserted.
908 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
909 CurModule.CurrentModule->getGlobalList().remove(GV);
910 CurModule.CurrentModule->getGlobalList().push_back(GV);
911 GV->setInitializer(Initializer);
912 GV->setLinkage(Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000913 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000914 GV->setConstant(isConstantGlobal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +0000915 GV->setThreadLocal(IsThreadLocal);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000916 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000917 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000918 }
919
Reid Spenceref9b9a72007-02-05 20:47:22 +0000920 // If this global has a name
Reid Spencer68a24bd2005-08-27 18:50:39 +0000921 if (!Name.empty()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +0000922 // if the global we're parsing has an initializer (is a definition) and
923 // has external linkage.
924 if (Initializer && Linkage != GlobalValue::InternalLinkage)
925 // If there is already a global with external linkage with this name
926 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
927 // If we allow this GVar to get created, it will be renamed in the
928 // symbol table because it conflicts with an existing GVar. We can't
929 // allow redefinition of GVars whose linking indicates that their name
930 // must stay the same. Issue the error.
931 GenerateError("Redefinition of global variable named '" + Name +
932 "' of type '" + Ty->getDescription() + "'");
933 return 0;
934 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000935 }
936
937 // Otherwise there is no existing GV to use, create one now.
938 GlobalVariable *GV =
939 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +0000940 CurModule.CurrentModule, IsThreadLocal);
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000941 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000942 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000943 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000944}
945
946// setTypeName - Set the specified type to the name given. The name may be
947// null potentially, in which case this is a noop. The string passed in is
948// assumed to be a malloc'd string buffer, and is freed by this function.
949//
950// This function returns true if the type has already been defined, but is
951// allowed to be redefined in the specified context. If the name is a new name
952// for the type plane, it is inserted and false is returned.
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000953static bool setTypeName(const Type *T, std::string *NameStr) {
Reid Spencera9720f52007-02-05 17:04:00 +0000954 assert(!inFunctionScope() && "Can't give types function-local names!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000955 if (NameStr == 0) return false;
956
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000957 std::string Name(*NameStr); // Copy string
958 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +0000959
960 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +0000961 if (T == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000962 GenerateError("Can't assign name '" + Name + "' to the void type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000963 return false;
964 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000965
966 // Set the type name, checking for conflicts as we do so.
967 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
968
969 if (AlreadyExists) { // Inserting a name that is already defined???
970 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
Reid Spencera9720f52007-02-05 17:04:00 +0000971 assert(Existing && "Conflict but no matching type?!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000972
973 // There is only one case where this is allowed: when we are refining an
974 // opaque type. In this case, Existing will be an opaque type.
975 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
976 // We ARE replacing an opaque type!
977 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
978 return true;
979 }
980
981 // Otherwise, this is an attempt to redefine a type. That's okay if
982 // the redefinition is identical to the original. This will be so if
983 // Existing and T point to the same Type object. In this one case we
984 // allow the equivalent redefinition.
985 if (Existing == T) return true; // Yes, it's equal.
986
987 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer63c34452007-01-05 21:51:07 +0000988 GenerateError("Redefinition of type named '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000989 T->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000990 }
991
992 return false;
993}
994
995//===----------------------------------------------------------------------===//
996// Code for handling upreferences in type names...
997//
998
999// TypeContains - Returns true if Ty directly contains E in it.
1000//
1001static bool TypeContains(const Type *Ty, const Type *E) {
1002 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1003 E) != Ty->subtype_end();
1004}
1005
1006namespace {
1007 struct UpRefRecord {
1008 // NestingLevel - The number of nesting levels that need to be popped before
1009 // this type is resolved.
1010 unsigned NestingLevel;
1011
1012 // LastContainedTy - This is the type at the current binding level for the
1013 // type. Every time we reduce the nesting level, this gets updated.
1014 const Type *LastContainedTy;
1015
1016 // UpRefTy - This is the actual opaque type that the upreference is
1017 // represented with.
1018 OpaqueType *UpRefTy;
1019
1020 UpRefRecord(unsigned NL, OpaqueType *URTy)
1021 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1022 };
1023}
1024
1025// UpRefs - A list of the outstanding upreferences that need to be resolved.
1026static std::vector<UpRefRecord> UpRefs;
1027
1028/// HandleUpRefs - Every time we finish a new layer of types, this function is
1029/// called. It loops through the UpRefs vector, which is a list of the
1030/// currently active types. For each type, if the up reference is contained in
1031/// the newly completed type, we decrement the level count. When the level
1032/// count reaches zero, the upreferenced type is the type that is passed in:
1033/// thus we can complete the cycle.
1034///
1035static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001036 // If Ty isn't abstract, or if there are no up-references in it, then there is
1037 // nothing to resolve here.
1038 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1039
Reid Spencer68a24bd2005-08-27 18:50:39 +00001040 PATypeHolder Ty(ty);
1041 UR_OUT("Type '" << Ty->getDescription() <<
1042 "' newly formed. Resolving upreferences.\n" <<
1043 UpRefs.size() << " upreferences active!\n");
1044
1045 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1046 // to zero), we resolve them all together before we resolve them to Ty. At
1047 // the end of the loop, if there is anything to resolve to Ty, it will be in
1048 // this variable.
1049 OpaqueType *TypeToResolve = 0;
1050
1051 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1052 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1053 << UpRefs[i].second->getDescription() << ") = "
1054 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1055 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1056 // Decrement level of upreference
1057 unsigned Level = --UpRefs[i].NestingLevel;
1058 UpRefs[i].LastContainedTy = Ty;
1059 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1060 if (Level == 0) { // Upreference should be resolved!
1061 if (!TypeToResolve) {
1062 TypeToResolve = UpRefs[i].UpRefTy;
1063 } else {
1064 UR_OUT(" * Resolving upreference for "
1065 << UpRefs[i].second->getDescription() << "\n";
1066 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1067 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1068 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1069 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1070 }
1071 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1072 --i; // Do not skip the next element...
1073 }
1074 }
1075 }
1076
1077 if (TypeToResolve) {
1078 UR_OUT(" * Resolving upreference for "
1079 << UpRefs[i].second->getDescription() << "\n";
1080 std::string OldName = TypeToResolve->getDescription());
1081 TypeToResolve->refineAbstractTypeTo(Ty);
1082 }
1083
1084 return Ty;
1085}
1086
Reid Spencer68a24bd2005-08-27 18:50:39 +00001087//===----------------------------------------------------------------------===//
1088// RunVMAsmParser - Define an interface to this parser
1089//===----------------------------------------------------------------------===//
1090//
Reid Spencer14310612006-12-31 05:40:51 +00001091static Module* RunParser(Module * M);
1092
Reid Spencer68a24bd2005-08-27 18:50:39 +00001093Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1094 set_scan_file(F);
1095
1096 CurFilename = Filename;
1097 return RunParser(new Module(CurFilename));
1098}
1099
1100Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1101 set_scan_string(AsmString);
1102
1103 CurFilename = "from_memory";
1104 if (M == NULL) {
1105 return RunParser(new Module (CurFilename));
1106 } else {
1107 return RunParser(M);
1108 }
1109}
1110
1111
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00001112#line 968 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00001113typedef union {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001114 llvm::Module *ModuleVal;
1115 llvm::Function *FunctionVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001116 llvm::BasicBlock *BasicBlockVal;
1117 llvm::TerminatorInst *TermInstVal;
1118 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001119 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001120
Reid Spencera132e042006-12-03 05:46:11 +00001121 const llvm::Type *PrimType;
Reid Spencer14310612006-12-31 05:40:51 +00001122 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencera132e042006-12-03 05:46:11 +00001123 llvm::PATypeHolder *TypeVal;
1124 llvm::Value *ValueVal;
Reid Spencera132e042006-12-03 05:46:11 +00001125 std::vector<llvm::Value*> *ValueList;
Reid Spencer14310612006-12-31 05:40:51 +00001126 llvm::ArgListType *ArgList;
1127 llvm::TypeWithAttrs TypeWithAttrs;
1128 llvm::TypeWithAttrsList *TypeWithAttrsList;
1129 llvm::ValueRefList *ValueRefList;
1130
Reid Spencer68a24bd2005-08-27 18:50:39 +00001131 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001132 std::list<std::pair<llvm::Value*,
1133 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001134 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001135 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001136
1137 llvm::GlobalValue::LinkageTypes Linkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001138 llvm::GlobalValue::VisibilityTypes Visibility;
Reid Spencer7b5d4662007-04-09 06:16:21 +00001139 uint16_t ParamAttrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00001140 llvm::APInt *APIntVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001141 int64_t SInt64Val;
1142 uint64_t UInt64Val;
1143 int SIntVal;
1144 unsigned UIntVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00001145 llvm::APFloat *FPVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001146 bool BoolVal;
1147
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001148 std::string *StrVal; // This memory must be deleted
1149 llvm::ValID ValIDVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001150
Reid Spencera132e042006-12-03 05:46:11 +00001151 llvm::Instruction::BinaryOps BinaryOpVal;
1152 llvm::Instruction::TermOps TermOpVal;
1153 llvm::Instruction::MemoryOps MemOpVal;
1154 llvm::Instruction::CastOps CastOpVal;
1155 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencera132e042006-12-03 05:46:11 +00001156 llvm::ICmpInst::Predicate IPredicate;
1157 llvm::FCmpInst::Predicate FPredicate;
Chris Lattner0275cff2007-08-06 21:00:46 +00001158} YYSTYPE;
Dale Johannesencdd509a2007-09-07 21:07:57 +00001159#include <stdio.h>
1160
1161#ifndef __cplusplus
1162#ifndef __STDC__
1163#define const
1164#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001165#endif
1166
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001167
Reid Spencer68a24bd2005-08-27 18:50:39 +00001168
Dale Johannesencdd509a2007-09-07 21:07:57 +00001169#define YYFINAL 594
1170#define YYFLAG -32768
1171#define YYNTBASE 160
Reid Spencer68a24bd2005-08-27 18:50:39 +00001172
Dale Johannesencdd509a2007-09-07 21:07:57 +00001173#define YYTRANSLATE(x) ((unsigned)(x) <= 399 ? yytranslate[x] : 241)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001174
Dale Johannesencdd509a2007-09-07 21:07:57 +00001175static const short yytranslate[] = { 0,
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, 2,
1179 2, 2, 2, 2, 2, 2, 2, 2, 2, 150,
1180 151, 148, 2, 147, 2, 2, 2, 2, 2, 2,
1181 2, 2, 2, 2, 2, 2, 2, 2, 2, 155,
1182 146, 156, 2, 2, 2, 2, 2, 2, 2, 2,
1183 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1184 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1185 152, 149, 154, 2, 2, 2, 2, 2, 159, 2,
1186 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1187 2, 2, 2, 2, 2, 2, 2, 2, 2, 153,
1188 2, 2, 157, 2, 158, 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, 2, 2, 2, 2, 2,
1201 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
1202 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1203 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1204 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
1205 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
1206 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
1207 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1208 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1209 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1210 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
1211 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
1212 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
1213 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
1214 127, 128, 129, 130, 131, 132, 133, 134, 135, 136,
1215 137, 138, 139, 140, 141, 142, 143, 144, 145
1216};
Reid Spencerb8f85052007-07-31 03:50:36 +00001217
Dale Johannesencdd509a2007-09-07 21:07:57 +00001218#if YYDEBUG != 0
1219static const short yyprhs[] = { 0,
1220 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
1221 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
1222 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
1223 60, 62, 64, 66, 68, 70, 72, 74, 76, 78,
1224 80, 82, 84, 86, 88, 90, 92, 94, 96, 98,
1225 100, 102, 104, 106, 108, 110, 112, 114, 116, 118,
1226 120, 122, 124, 126, 127, 130, 131, 133, 135, 137,
1227 138, 141, 143, 145, 147, 149, 151, 153, 155, 157,
1228 158, 160, 162, 164, 165, 167, 169, 170, 172, 174,
1229 176, 178, 179, 181, 183, 184, 186, 188, 190, 192,
1230 194, 197, 199, 201, 203, 205, 207, 209, 211, 213,
1231 215, 216, 219, 221, 223, 225, 227, 228, 231, 232,
1232 235, 236, 240, 243, 244, 246, 247, 251, 253, 256,
1233 258, 260, 262, 264, 266, 268, 270, 272, 274, 277,
1234 279, 282, 288, 294, 300, 306, 310, 313, 319, 324,
1235 327, 329, 331, 333, 337, 339, 343, 345, 346, 348,
1236 352, 357, 361, 365, 370, 375, 379, 386, 392, 395,
1237 398, 401, 404, 407, 410, 413, 416, 419, 422, 425,
1238 428, 435, 441, 450, 457, 464, 472, 480, 487, 496,
1239 505, 509, 511, 513, 515, 517, 518, 521, 528, 530,
1240 531, 533, 536, 537, 541, 542, 546, 550, 554, 558,
1241 559, 567, 568, 577, 578, 587, 593, 596, 600, 602,
1242 606, 610, 614, 618, 620, 621, 627, 631, 633, 637,
1243 639, 640, 650, 652, 654, 659, 661, 663, 666, 670,
1244 671, 673, 675, 677, 679, 681, 683, 685, 687, 689,
1245 693, 695, 701, 703, 705, 707, 709, 711, 713, 716,
1246 719, 722, 726, 729, 730, 732, 735, 738, 742, 752,
1247 762, 771, 786, 788, 790, 797, 803, 806, 813, 821,
1248 825, 831, 832, 833, 837, 840, 842, 848, 854, 861,
1249 868, 873, 880, 885, 890, 897, 904, 907, 916, 918,
1250 920, 921, 925, 932, 936, 943, 946, 952, 960
1251};
Chris Lattner0275cff2007-08-06 21:00:46 +00001252
Dale Johannesencdd509a2007-09-07 21:07:57 +00001253static const short yyrhs[] = { 73,
1254 0, 74, 0, 75, 0, 76, 0, 77, 0, 78,
1255 0, 79, 0, 80, 0, 81, 0, 85, 0, 86,
1256 0, 87, 0, 82, 0, 83, 0, 84, 0, 116,
1257 0, 117, 0, 118, 0, 119, 0, 120, 0, 121,
1258 0, 122, 0, 123, 0, 124, 0, 125, 0, 126,
1259 0, 127, 0, 90, 0, 91, 0, 92, 0, 93,
1260 0, 94, 0, 95, 0, 96, 0, 97, 0, 98,
1261 0, 99, 0, 100, 0, 101, 0, 102, 0, 103,
1262 0, 104, 0, 105, 0, 106, 0, 107, 0, 108,
1263 0, 109, 0, 96, 0, 97, 0, 98, 0, 99,
1264 0, 26, 0, 27, 0, 11, 0, 12, 0, 13,
1265 0, 16, 0, 15, 0, 14, 0, 19, 0, 22,
1266 0, 24, 0, 167, 0, 0, 167, 146, 0, 0,
1267 20, 0, 23, 0, 172, 0, 0, 170, 146, 0,
1268 42, 0, 44, 0, 43, 0, 45, 0, 47, 0,
1269 46, 0, 48, 0, 50, 0, 0, 143, 0, 144,
1270 0, 145, 0, 0, 46, 0, 48, 0, 0, 42,
1271 0, 43, 0, 44, 0, 47, 0, 0, 44, 0,
1272 42, 0, 0, 61, 0, 62, 0, 63, 0, 64,
1273 0, 65, 0, 60, 4, 0, 135, 0, 117, 0,
1274 134, 0, 118, 0, 137, 0, 138, 0, 140, 0,
1275 141, 0, 142, 0, 0, 181, 180, 0, 136, 0,
1276 139, 0, 135, 0, 134, 0, 0, 183, 182, 0,
1277 0, 53, 4, 0, 0, 147, 53, 4, 0, 34,
1278 22, 0, 0, 186, 0, 0, 147, 189, 188, 0,
1279 186, 0, 53, 4, 0, 11, 0, 12, 0, 13,
1280 0, 16, 0, 15, 0, 14, 0, 17, 0, 49,
1281 0, 190, 0, 191, 148, 0, 225, 0, 149, 4,
1282 0, 191, 150, 195, 151, 183, 0, 10, 150, 195,
1283 151, 183, 0, 152, 4, 153, 191, 154, 0, 155,
1284 4, 153, 191, 156, 0, 157, 196, 158, 0, 157,
1285 158, 0, 155, 157, 196, 158, 156, 0, 155, 157,
1286 158, 156, 0, 191, 181, 0, 191, 0, 10, 0,
1287 192, 0, 194, 147, 192, 0, 194, 0, 194, 147,
1288 39, 0, 39, 0, 0, 191, 0, 196, 147, 191,
1289 0, 191, 152, 199, 154, 0, 191, 152, 154, 0,
1290 191, 159, 22, 0, 191, 155, 199, 156, 0, 191,
1291 157, 199, 158, 0, 191, 157, 158, 0, 191, 155,
1292 157, 199, 158, 156, 0, 191, 155, 157, 158, 156,
1293 0, 191, 40, 0, 191, 41, 0, 191, 225, 0,
1294 191, 198, 0, 191, 25, 0, 165, 3, 0, 165,
1295 5, 0, 165, 4, 0, 165, 6, 0, 11, 26,
1296 0, 11, 27, 0, 166, 9, 0, 162, 150, 197,
1297 38, 191, 151, 0, 115, 150, 197, 236, 151, 0,
1298 129, 150, 197, 147, 197, 147, 197, 151, 0, 160,
1299 150, 197, 147, 197, 151, 0, 161, 150, 197, 147,
1300 197, 151, 0, 88, 163, 150, 197, 147, 197, 151,
1301 0, 89, 164, 150, 197, 147, 197, 151, 0, 131,
1302 150, 197, 147, 197, 151, 0, 132, 150, 197, 147,
1303 197, 147, 197, 151, 0, 133, 150, 197, 147, 197,
1304 147, 197, 151, 0, 199, 147, 197, 0, 197, 0,
1305 32, 0, 33, 0, 37, 0, 0, 193, 225, 0,
1306 121, 150, 202, 38, 191, 151, 0, 204, 0, 0,
1307 205, 0, 204, 205, 0, 0, 31, 206, 221, 0,
1308 0, 30, 207, 222, 0, 58, 57, 211, 0, 169,
1309 18, 191, 0, 169, 18, 10, 0, 0, 171, 175,
1310 201, 200, 197, 208, 188, 0, 0, 171, 173, 175,
1311 201, 200, 197, 209, 188, 0, 0, 171, 174, 175,
1312 201, 200, 191, 210, 188, 0, 171, 175, 35, 178,
1313 202, 0, 51, 212, 0, 54, 146, 213, 0, 22,
1314 0, 52, 146, 22, 0, 66, 146, 22, 0, 152,
1315 214, 154, 0, 214, 147, 22, 0, 22, 0, 0,
1316 215, 147, 191, 181, 168, 0, 191, 181, 168, 0,
1317 215, 0, 215, 147, 39, 0, 39, 0, 0, 179,
1318 193, 170, 150, 216, 151, 183, 187, 184, 0, 28,
1319 0, 157, 0, 177, 175, 217, 218, 0, 29, 0,
1320 158, 0, 228, 220, 0, 176, 175, 217, 0, 0,
1321 59, 0, 3, 0, 4, 0, 9, 0, 26, 0,
1322 27, 0, 40, 0, 41, 0, 25, 0, 155, 199,
1323 156, 0, 198, 0, 57, 223, 22, 147, 22, 0,
1324 7, 0, 8, 0, 167, 0, 170, 0, 225, 0,
1325 224, 0, 191, 226, 0, 228, 229, 0, 219, 229,
1326 0, 230, 169, 231, 0, 230, 233, 0, 0, 21,
1327 0, 67, 227, 0, 67, 10, 0, 68, 17, 226,
1328 0, 68, 11, 226, 147, 17, 226, 147, 17, 226,
1329 0, 69, 165, 226, 147, 17, 226, 152, 232, 154,
1330 0, 69, 165, 226, 147, 17, 226, 152, 154, 0,
1331 70, 179, 193, 226, 150, 235, 151, 183, 38, 17,
1332 226, 71, 17, 226, 0, 71, 0, 72, 0, 232,
1333 165, 224, 147, 17, 226, 0, 165, 224, 147, 17,
1334 226, 0, 169, 238, 0, 191, 152, 226, 147, 226,
1335 154, 0, 234, 147, 152, 226, 147, 226, 154, 0,
1336 191, 226, 181, 0, 235, 147, 191, 226, 181, 0,
1337 0, 0, 236, 147, 227, 0, 56, 55, 0, 55,
1338 0, 160, 191, 226, 147, 226, 0, 161, 191, 226,
1339 147, 226, 0, 88, 163, 191, 226, 147, 226, 0,
1340 89, 164, 191, 226, 147, 226, 0, 162, 227, 38,
1341 191, 0, 129, 227, 147, 227, 147, 227, 0, 130,
1342 227, 147, 191, 0, 131, 227, 147, 227, 0, 132,
1343 227, 147, 227, 147, 227, 0, 133, 227, 147, 227,
1344 147, 227, 0, 128, 234, 0, 237, 179, 193, 226,
1345 150, 235, 151, 183, 0, 240, 0, 36, 0, 0,
1346 110, 191, 185, 0, 110, 191, 147, 11, 226, 185,
1347 0, 111, 191, 185, 0, 111, 191, 147, 11, 226,
1348 185, 0, 112, 227, 0, 239, 113, 191, 226, 185,
1349 0, 239, 114, 227, 147, 191, 226, 185, 0, 115,
1350 191, 226, 236, 0
1351};
Chris Lattner0275cff2007-08-06 21:00:46 +00001352
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001353#endif
1354
Dale Johannesencdd509a2007-09-07 21:07:57 +00001355#if YYDEBUG != 0
1356static const short yyrline[] = { 0,
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00001357 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1128,
1358 1128, 1128, 1128, 1128, 1128, 1129, 1129, 1129, 1129, 1129,
1359 1129, 1129, 1130, 1130, 1130, 1130, 1130, 1133, 1133, 1134,
1360 1134, 1135, 1135, 1136, 1136, 1137, 1137, 1141, 1141, 1142,
1361 1142, 1143, 1143, 1144, 1144, 1145, 1145, 1146, 1146, 1147,
1362 1147, 1148, 1149, 1154, 1155, 1155, 1155, 1155, 1155, 1157,
1363 1157, 1157, 1158, 1158, 1162, 1166, 1171, 1171, 1173, 1174,
1364 1179, 1185, 1186, 1187, 1188, 1189, 1193, 1194, 1195, 1199,
1365 1200, 1201, 1202, 1206, 1207, 1208, 1212, 1213, 1214, 1215,
1366 1216, 1220, 1221, 1222, 1225, 1225, 1226, 1227, 1228, 1229,
1367 1230, 1238, 1239, 1240, 1241, 1242, 1243, 1244, 1245, 1246,
1368 1249, 1250, 1255, 1256, 1257, 1258, 1261, 1262, 1269, 1269,
1369 1276, 1276, 1285, 1293, 1293, 1299, 1299, 1301, 1306, 1319,
1370 1319, 1319, 1319, 1319, 1319, 1319, 1322, 1326, 1330, 1337,
1371 1342, 1350, 1380, 1411, 1416, 1428, 1438, 1442, 1452, 1459,
1372 1466, 1473, 1478, 1483, 1490, 1491, 1498, 1505, 1513, 1519,
1373 1531, 1559, 1575, 1602, 1630, 1656, 1676, 1702, 1722, 1734,
1374 1741, 1807, 1817, 1827, 1833, 1843, 1849, 1859, 1864, 1869,
1375 1882, 1894, 1916, 1924, 1930, 1941, 1946, 1951, 1957, 1963,
1376 1972, 1976, 1984, 1984, 1987, 1987, 1990, 2002, 2023, 2028,
1377 2036, 2037, 2041, 2041, 2045, 2045, 2048, 2051, 2075, 2086,
1378 2093, 2096, 2102, 2105, 2112, 2116, 2156, 2159, 2165, 2175,
1379 2179, 2184, 2186, 2191, 2196, 2205, 2215, 2226, 2230, 2239,
1380 2248, 2253, 2374, 2374, 2376, 2385, 2385, 2387, 2392, 2404,
1381 2408, 2413, 2417, 2421, 2425, 2429, 2433, 2437, 2441, 2445,
1382 2470, 2474, 2484, 2488, 2492, 2497, 2504, 2504, 2510, 2519,
1383 2523, 2532, 2541, 2550, 2554, 2561, 2565, 2569, 2574, 2584,
1384 2603, 2612, 2692, 2696, 2703, 2714, 2727, 2737, 2748, 2758,
1385 2767, 2776, 2779, 2780, 2787, 2791, 2796, 2817, 2834, 2848,
1386 2862, 2874, 2882, 2889, 2895, 2901, 2907, 2922, 3007, 3012,
1387 3016, 3023, 3030, 3038, 3045, 3053, 3061, 3075, 3092
Dale Johannesencdd509a2007-09-07 21:07:57 +00001388};
1389#endif
1390
1391
1392#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
1393
1394static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL",
1395"EUINT64VAL","ESAPINTVAL","EUAPINTVAL","LOCALVAL_ID","GLOBALVAL_ID","FPVAL",
1396"VOID","INTTYPE","FLOAT","DOUBLE","X86_FP80","FP128","PPC_FP128","LABEL","TYPE",
1397"LOCALVAR","GLOBALVAR","LABELSTR","STRINGCONSTANT","ATSTRINGCONSTANT","PCTSTRINGCONSTANT",
1398"ZEROINITIALIZER","TRUETOK","FALSETOK","BEGINTOK","ENDTOK","DECLARE","DEFINE",
1399"GLOBAL","CONSTANT","SECTION","ALIAS","VOLATILE","THREAD_LOCAL","TO","DOTDOTDOT",
1400"NULL_TOK","UNDEF","INTERNAL","LINKONCE","WEAK","APPENDING","DLLIMPORT","DLLEXPORT",
1401"EXTERN_WEAK","OPAQUE","EXTERNAL","TARGET","TRIPLE","ALIGN","DEPLIBS","CALL",
1402"TAIL","ASM_TOK","MODULE","SIDEEFFECT","CC_TOK","CCC_TOK","FASTCC_TOK","COLDCC_TOK",
1403"X86_STDCALLCC_TOK","X86_FASTCALLCC_TOK","DATALAYOUT","RET","BR","SWITCH","INVOKE",
1404"UNWIND","UNREACHABLE","ADD","SUB","MUL","UDIV","SDIV","FDIV","UREM","SREM",
1405"FREM","AND","OR","XOR","SHL","LSHR","ASHR","ICMP","FCMP","EQ","NE","SLT","SGT",
1406"SLE","SGE","ULT","UGT","ULE","UGE","OEQ","ONE","OLT","OGT","OLE","OGE","ORD",
1407"UNO","UEQ","UNE","MALLOC","ALLOCA","FREE","LOAD","STORE","GETELEMENTPTR","TRUNC",
1408"ZEXT","SEXT","FPTRUNC","FPEXT","BITCAST","UITOFP","SITOFP","FPTOUI","FPTOSI",
1409"INTTOPTR","PTRTOINT","PHI_TOK","SELECT","VAARG","EXTRACTELEMENT","INSERTELEMENT",
1410"SHUFFLEVECTOR","SIGNEXT","ZEROEXT","NORETURN","INREG","SRET","NOUNWIND","NOALIAS",
1411"BYVAL","NEST","DEFAULT","HIDDEN","PROTECTED","'='","','","'*'","'\\\\'","'('",
1412"')'","'['","'x'","']'","'<'","'>'","'{'","'}'","'c'","ArithmeticOps","LogicalOps",
1413"CastOps","IPredicates","FPredicates","IntType","FPType","LocalName","OptLocalName",
1414"OptLocalAssign","GlobalName","OptGlobalAssign","GlobalAssign","GVInternalLinkage",
1415"GVExternalLinkage","GVVisibilityStyle","FunctionDeclareLinkage","FunctionDefineLinkage",
1416"AliasLinkage","OptCallingConv","ParamAttr","OptParamAttrs","FuncAttr","OptFuncAttrs",
1417"OptAlign","OptCAlign","SectionString","OptSection","GlobalVarAttributes","GlobalVarAttribute",
1418"PrimType","Types","ArgType","ResultTypes","ArgTypeList","ArgTypeListI","TypeListI",
1419"ConstVal","ConstExpr","ConstVector","GlobalType","ThreadLocal","AliaseeRef",
1420"Module","DefinitionList","Definition","@1","@2","@3","@4","@5","AsmBlock","TargetDefinition",
1421"LibrariesDefinition","LibList","ArgListH","ArgList","FunctionHeaderH","BEGIN",
1422"FunctionHeader","END","Function","FunctionProto","OptSideEffect","ConstValueRef",
1423"SymbolicValueRef","ValueRef","ResolvedVal","BasicBlockList","BasicBlock","InstructionList",
1424"BBTerminatorInst","JumpTable","Inst","PHIList","ValueRefList","IndexList","OptTailCall",
1425"InstVal","OptVolatile","MemoryInst", NULL
1426};
1427#endif
1428
1429static const short yyr1[] = { 0,
1430 160, 160, 160, 160, 160, 160, 160, 160, 160, 161,
1431 161, 161, 161, 161, 161, 162, 162, 162, 162, 162,
1432 162, 162, 162, 162, 162, 162, 162, 163, 163, 163,
1433 163, 163, 163, 163, 163, 163, 163, 164, 164, 164,
1434 164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
1435 164, 164, 164, 165, 166, 166, 166, 166, 166, 167,
1436 167, 167, 168, 168, 169, 169, 170, 170, 171, 171,
1437 172, 173, 173, 173, 173, 173, 174, 174, 174, 175,
1438 175, 175, 175, 176, 176, 176, 177, 177, 177, 177,
1439 177, 178, 178, 178, 179, 179, 179, 179, 179, 179,
1440 179, 180, 180, 180, 180, 180, 180, 180, 180, 180,
1441 181, 181, 182, 182, 182, 182, 183, 183, 184, 184,
1442 185, 185, 186, 187, 187, 188, 188, 189, 189, 190,
1443 190, 190, 190, 190, 190, 190, 191, 191, 191, 191,
1444 191, 191, 191, 191, 191, 191, 191, 191, 191, 192,
1445 193, 193, 194, 194, 195, 195, 195, 195, 196, 196,
1446 197, 197, 197, 197, 197, 197, 197, 197, 197, 197,
1447 197, 197, 197, 197, 197, 197, 197, 197, 197, 197,
1448 198, 198, 198, 198, 198, 198, 198, 198, 198, 198,
1449 199, 199, 200, 200, 201, 201, 202, 202, 203, 203,
1450 204, 204, 206, 205, 207, 205, 205, 205, 205, 208,
1451 205, 209, 205, 210, 205, 205, 205, 205, 211, 212,
1452 212, 213, 214, 214, 214, 215, 215, 216, 216, 216,
1453 216, 217, 218, 218, 219, 220, 220, 221, 222, 223,
1454 223, 224, 224, 224, 224, 224, 224, 224, 224, 224,
1455 224, 224, 225, 225, 225, 225, 226, 226, 227, 228,
1456 228, 229, 230, 230, 230, 231, 231, 231, 231, 231,
1457 231, 231, 231, 231, 232, 232, 233, 234, 234, 235,
1458 235, 235, 236, 236, 237, 237, 238, 238, 238, 238,
1459 238, 238, 238, 238, 238, 238, 238, 238, 238, 239,
1460 239, 240, 240, 240, 240, 240, 240, 240, 240
1461};
1462
1463static const short yyr2[] = { 0,
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, 1, 1, 1, 1, 1, 1, 1,
1470 1, 1, 1, 0, 2, 0, 1, 1, 1, 0,
1471 2, 1, 1, 1, 1, 1, 1, 1, 1, 0,
1472 1, 1, 1, 0, 1, 1, 0, 1, 1, 1,
1473 1, 0, 1, 1, 0, 1, 1, 1, 1, 1,
1474 2, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1475 0, 2, 1, 1, 1, 1, 0, 2, 0, 2,
1476 0, 3, 2, 0, 1, 0, 3, 1, 2, 1,
1477 1, 1, 1, 1, 1, 1, 1, 1, 2, 1,
1478 2, 5, 5, 5, 5, 3, 2, 5, 4, 2,
1479 1, 1, 1, 3, 1, 3, 1, 0, 1, 3,
1480 4, 3, 3, 4, 4, 3, 6, 5, 2, 2,
1481 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1482 6, 5, 8, 6, 6, 7, 7, 6, 8, 8,
1483 3, 1, 1, 1, 1, 0, 2, 6, 1, 0,
1484 1, 2, 0, 3, 0, 3, 3, 3, 3, 0,
1485 7, 0, 8, 0, 8, 5, 2, 3, 1, 3,
1486 3, 3, 3, 1, 0, 5, 3, 1, 3, 1,
1487 0, 9, 1, 1, 4, 1, 1, 2, 3, 0,
1488 1, 1, 1, 1, 1, 1, 1, 1, 1, 3,
1489 1, 5, 1, 1, 1, 1, 1, 1, 2, 2,
1490 2, 3, 2, 0, 1, 2, 2, 3, 9, 9,
1491 8, 14, 1, 1, 6, 5, 2, 6, 7, 3,
1492 5, 0, 0, 3, 2, 1, 5, 5, 6, 6,
1493 4, 6, 4, 4, 6, 6, 2, 8, 1, 1,
1494 0, 3, 6, 3, 6, 2, 5, 7, 4
1495};
1496
1497static const short yydefact[] = { 70,
1498 60, 67, 61, 68, 62, 205, 203, 0, 0, 0,
1499 0, 0, 0, 80, 69, 70, 201, 84, 87, 0,
1500 0, 217, 0, 0, 65, 0, 71, 72, 74, 73,
1501 75, 77, 76, 78, 79, 81, 82, 83, 80, 80,
1502 196, 202, 85, 86, 80, 206, 88, 89, 90, 91,
1503 80, 264, 204, 264, 0, 0, 225, 218, 219, 207,
1504 253, 254, 209, 130, 131, 132, 135, 134, 133, 136,
1505 137, 0, 0, 0, 0, 255, 256, 138, 208, 140,
1506 196, 196, 92, 195, 0, 95, 95, 265, 261, 66,
1507 236, 237, 238, 260, 220, 221, 224, 0, 158, 141,
1508 0, 0, 0, 0, 147, 159, 0, 139, 158, 0,
1509 0, 94, 93, 0, 193, 194, 0, 0, 96, 97,
1510 98, 99, 100, 0, 239, 0, 301, 263, 0, 222,
1511 157, 111, 153, 155, 0, 0, 0, 0, 0, 0,
1512 146, 0, 0, 0, 152, 0, 151, 0, 216, 130,
1513 131, 132, 135, 134, 133, 0, 0, 0, 210, 101,
1514 0, 233, 234, 235, 300, 286, 0, 0, 0, 0,
1515 95, 273, 274, 1, 2, 3, 4, 5, 6, 7,
1516 8, 9, 13, 14, 15, 10, 11, 12, 0, 0,
1517 0, 0, 0, 0, 16, 17, 18, 19, 20, 21,
1518 22, 23, 24, 25, 26, 27, 0, 0, 0, 0,
1519 0, 0, 0, 0, 0, 262, 95, 277, 0, 299,
1520 223, 150, 0, 117, 0, 0, 149, 0, 160, 117,
1521 212, 214, 0, 197, 178, 179, 174, 176, 175, 177,
1522 180, 173, 169, 170, 0, 0, 0, 0, 0, 0,
1523 0, 0, 0, 0, 0, 0, 0, 0, 172, 171,
1524 126, 0, 285, 267, 0, 266, 0, 0, 54, 0,
1525 0, 28, 29, 30, 31, 32, 33, 34, 35, 36,
1526 37, 0, 52, 53, 48, 49, 50, 51, 38, 39,
1527 40, 41, 42, 43, 44, 45, 46, 47, 0, 121,
1528 121, 306, 0, 0, 297, 0, 0, 0, 0, 0,
1529 0, 0, 0, 0, 0, 0, 103, 105, 104, 102,
1530 106, 107, 108, 109, 110, 112, 156, 154, 143, 144,
1531 145, 148, 142, 126, 126, 0, 0, 0, 0, 0,
1532 0, 0, 0, 162, 192, 0, 0, 0, 166, 0,
1533 163, 0, 0, 0, 0, 211, 231, 242, 243, 244,
1534 249, 245, 246, 247, 248, 240, 0, 251, 258, 257,
1535 259, 0, 268, 0, 0, 0, 0, 0, 302, 0,
1536 304, 283, 0, 0, 0, 0, 0, 0, 0, 0,
1537 0, 0, 0, 0, 0, 116, 115, 113, 114, 118,
1538 213, 215, 0, 0, 0, 283, 0, 0, 0, 0,
1539 0, 161, 147, 159, 0, 164, 165, 0, 0, 0,
1540 0, 0, 128, 126, 230, 111, 228, 0, 241, 0,
1541 0, 0, 0, 0, 0, 0, 0, 0, 0, 309,
1542 0, 0, 0, 293, 294, 0, 0, 0, 0, 291,
1543 0, 121, 0, 0, 0, 0, 0, 0, 0, 0,
1544 0, 191, 168, 0, 0, 0, 0, 123, 129, 127,
1545 64, 0, 117, 0, 250, 0, 0, 282, 0, 0,
1546 121, 122, 121, 0, 0, 0, 0, 0, 0, 287,
1547 288, 282, 0, 307, 0, 198, 0, 0, 182, 0,
1548 0, 0, 0, 167, 0, 0, 0, 63, 227, 229,
1549 111, 124, 0, 0, 0, 0, 0, 289, 290, 303,
1550 305, 284, 0, 0, 292, 295, 296, 0, 121, 0,
1551 0, 0, 188, 0, 0, 184, 185, 181, 64, 125,
1552 119, 252, 0, 0, 111, 0, 117, 278, 0, 117,
1553 308, 186, 187, 0, 0, 0, 226, 0, 232, 0,
1554 271, 0, 0, 280, 0, 0, 279, 298, 183, 189,
1555 190, 120, 269, 0, 270, 0, 111, 0, 0, 0,
1556 281, 0, 0, 0, 0, 276, 0, 0, 275, 0,
1557 272, 0, 0, 0
1558};
1559
1560static const short yydefgoto[] = { 256,
1561 257, 258, 282, 299, 156, 157, 76, 509, 12, 77,
1562 14, 15, 39, 40, 41, 45, 51, 114, 124, 326,
1563 222, 400, 329, 559, 379, 423, 541, 356, 424, 78,
1564 158, 133, 148, 134, 135, 107, 345, 368, 346, 117,
1565 85, 149, 592, 16, 17, 19, 18, 261, 334, 335,
1566 60, 22, 58, 98, 427, 428, 125, 164, 52, 93,
1567 53, 46, 430, 369, 80, 371, 266, 54, 89, 90,
1568 216, 563, 128, 305, 517, 440, 217, 218, 219, 220
1569};
1570
1571static const short yypact[] = { 42,
1572-32768,-32768,-32768,-32768,-32768,-32768,-32768, -21, -131, 60,
1573 -93, 105, -22, 182,-32768, 525,-32768, 46, 168, -12,
1574 19,-32768, 1, 152,-32768, 1277,-32768,-32768,-32768,-32768,
1575-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 90, 90,
1576 100,-32768,-32768,-32768, 90,-32768,-32768,-32768,-32768,-32768,
1577 90, 186,-32768, 12, 187, 201, 209,-32768,-32768,-32768,
1578-32768,-32768, 93,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1579-32768, 252, 254, 2, 907,-32768,-32768,-32768, 13,-32768,
1580 225, 225, 150,-32768, 76, 116, 116,-32768,-32768, 108,
1581-32768,-32768,-32768,-32768,-32768,-32768,-32768, -79, 1027,-32768,
1582 111, 114, 947, 93,-32768, 13, -104,-32768, 1027, 76,
1583 76,-32768,-32768, 1067,-32768,-32768, 1299, 266,-32768,-32768,
1584-32768,-32768,-32768, 1330,-32768, -16, 1572,-32768, 256,-32768,
1585-32768, 13,-32768, 139, 144, 1370, 1370, 132, -95, 1370,
1586-32768, 145, 1299, 1370, 93, 147, 13, 311,-32768, 43,
1587 290, 293, 298, 299, 302, 247, 303, 724,-32768,-32768,
1588 35,-32768,-32768,-32768,-32768,-32768, 258, 1450, 70, 305,
1589 116,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1590-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 317, 405,
1591 1370, 1370, 1370, 1370,-32768,-32768,-32768,-32768,-32768,-32768,
1592-32768,-32768,-32768,-32768,-32768,-32768, 1370, 1370, 1370, 1370,
1593 1370, 1370, 1370, 1370, 1370,-32768, 116,-32768, 34,-32768,
1594-32768, 131, 1107,-32768, 6, -46,-32768, 164, 13,-32768,
1595-32768, 13, 1067,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1596-32768,-32768,-32768,-32768, 317, 405, 173, 178, 179, 189,
1597 192, 1179, 1481, 987, 314, 193, 197, 198,-32768,-32768,
1598 202, 203,-32768, 93, 565,-32768, 699, 699,-32768, 699,
1599 1330,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1600-32768, 1370,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1601-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 1370, 113,
1602 137,-32768, 565, -10, 205, 207, 208, 210, 218, 219,
1603 565, 565, 330, 1330, 1370, 1370,-32768,-32768,-32768,-32768,
1604-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 106,-32768,
1605-32768,-32768, 106, 202, 202, 331, 220, 221, 1299, 1299,
1606 1299, 1299, 1299,-32768,-32768, -41, 1005, -61,-32768, -91,
1607-32768, 1299, 1299, 1299, -13,-32768, 1219,-32768,-32768,-32768,
1608-32768,-32768,-32768,-32768,-32768, 313, 1299,-32768,-32768,-32768,
1609-32768, 226,-32768, 227, 699, 565, 565, 23,-32768, 24,
1610-32768,-32768, 699, 223, 1370, 1370, 1370, 1370, 1370, 232,
1611 233, 1370, 699, 565, 234,-32768,-32768,-32768,-32768,-32768,
1612-32768,-32768, 1370, 1299, 1299,-32768, 235, 236, 237, 239,
1613 1299,-32768, 231, 724, -76,-32768,-32768, 241, 242, 352,
1614 369, 388,-32768, 202,-32768, 13, 246, 243,-32768, 374,
1615 -59, 380, 385, 253, 257, 270, 699, 414, 699, 272,
1616 273, 699, 278, 13,-32768, 280, 282, 699, 699, 13,
1617 283, 287, 1370, -112, 288, 289, -33, 1299, 1299, 1299,
1618 1299,-32768,-32768, 294, 1299, 1299, 1370,-32768,-32768,-32768,
1619 79, 1259,-32768, 292,-32768, 699, 699, 1370, 699, 699,
1620 287,-32768, 287, 1370, 699, 307, 1370, 1370, 1370,-32768,
1621-32768, 1370, 392,-32768, 565,-32768, 1299, 1299,-32768, 308,
1622 295, 309, 310,-32768, 301, 315, 7,-32768,-32768,-32768,
1623 13, 10, 427, 318, 306, 565, 52,-32768,-32768,-32768,
1624-32768,-32768, 316, 699,-32768,-32768,-32768, 71, 287, 322,
1625 325, 1299,-32768, 1299, 1299,-32768,-32768,-32768, 79,-32768,
1626 407,-32768, 444, -4,-32768, 1370,-32768,-32768, 323,-32768,
1627-32768,-32768,-32768, 327, 328, 329,-32768, 464,-32768, 699,
1628-32768, 859, -3, 131, 565, -14,-32768, 106,-32768,-32768,
1629-32768,-32768,-32768, 334,-32768, 859,-32768, 452, 465, 336,
1630 131, 699, 699, 468, 416,-32768, 699, 471,-32768, 699,
1631-32768, 490, 491,-32768
1632};
1633
1634static const short yypgoto[] = { 365,
1635 366, 367, 255, 251, -168,-32768, 0, -40, 408, 14,
1636-32768,-32768,-32768,-32768, 40,-32768,-32768,-32768, -158,-32768,
1637 -406,-32768, -226,-32768, -290, 3,-32768, -317,-32768,-32768,
1638 -25, 296, -119,-32768, 409, 413, -60, -155, -231, 166,
1639 119, 284,-32768,-32768, 504,-32768,-32768,-32768,-32768,-32768,
1640-32768,-32768,-32768,-32768,-32768,-32768, 435,-32768,-32768,-32768,
1641-32768,-32768,-32768, -525, -139, 47, -183,-32768, 474,-32768,
1642-32768,-32768,-32768,-32768, 37, 124,-32768,-32768,-32768,-32768
1643};
1644
1645
1646#define YYLAST 1705
1647
1648
1649static const short yytable[] = { 11,
1650 79, 270, 259, 333, 161, 102, 269, 269, 234, 302,
1651 381, 162, 271, 13, 23, 11, 401, 402, 260, 471,
1652 421, 348, 350, 578, 306, 307, 308, 309, 310, 13,
1653 20, 313, 88, 437, 439, 108, 574, 109, 496, 422,
1654 91, -200, 140, 421, 21, -54, -54, -54, -54, 106,
1655 580, 140, 25, 141, 2, 411, 159, 4, 314, -66,
1656 1, 2, 228, 3, 4, 5, 417, 129, 235, 236,
1657 411, 6, 7, 132, 130, 438, 438, 106, 81, 82,
1658 267, 464, 231, 132, 86, 411, 268, 411, 147, 11,
1659 87, 43, 8, 44, 416, 9, 475, 1, 147, 10,
1660 3, 108, 5, 109, 539, 411, 470, 115, 116, 331,
1661 225, 226, 412, 484, 229, 415, 24, 499, 232, 396,
1662 397, 398, 26, 27, 399, 370, 1, 370, 370, 3,
1663 370, 5, 395, 55, 83, 431, 84, 108, 564, 109,
1664 163, 383, 265, 396, 397, 398, 315, 316, 399, 561,
1665 575, 375, 57, 108, 108, 109, 109, 538, 103, 330,
1666 108, 494, 109, 370, 56, 300, 301, 265, 303, 92,
1667 581, 370, 370, 59, 262, 118, 119, 120, 121, 122,
1668 123, 304, 265, 265, 265, 265, 265, 311, 312, 265,
1669 520, 112, 521, 113, 393, 317, 318, 132, 546, 110,
1670 111, 443, 547, 445, 446, 447, 88, 147, 95, 47,
1671 48, 49, 319, 320, 50, 321, 322, 546, 323, 324,
1672 325, 550, 96, 28, 29, 30, 31, 32, 33, 34,
1673 97, 35, 36, 37, 38, 370, 370, 370, 551, 396,
1674 397, 398, 99, 370, 399, 147, 512, 317, 318, 237,
1675 238, 239, 240, 370, 370, 100, 376, 101, 259, 378,
1676 108, 84, 109, 136, 319, 320, 137, 321, 322, 160,
1677 323, 324, 325, 377, 260, 143, 144, 221, 406, 407,
1678 408, 409, 410, 380, 108, 223, 109, 227, 147, 394,
1679 265, 418, 419, 420, 224, 230, 233, 370, -55, 370,
1680 522, -56, 370, 525, 526, 527, -59, -58, 370, 370,
1681 -57, 241, 263, 372, 373, 269, 374, 61, 62, 332,
1682 566, 414, 339, 568, 36, 37, 38, 340, 341, 1,
1683 2, 426, 3, 4, 5, 351, 370, 370, 342, 370,
1684 370, 343, 352, 455, 456, 370, 353, 354, 355, 382,
1685 462, 384, 357, 385, 386, 370, 387, 390, 391, 265,
1686 444, 265, 265, 265, 388, 389, 450, 392, 403, 404,
1687 405, 429, 432, 433, 442, 562, 370, 454, 448, 449,
1688 453, 458, 459, 460, 370, 461, 463, 465, 466, 467,
1689 468, 469, 472, 473, 576, 474, 476, 500, 501, 502,
1690 503, 477, 478, 479, 505, 506, 272, 273, 274, 275,
1691 276, 277, 278, 279, 280, 281, 480, 482, 484, 485,
1692 370, 434, 435, 436, 487, 370, 488, 495, 489, 441,
1693 283, 284, 492, 493, 497, 498, 530, 531, 513, 451,
1694 452, 507, 370, 370, 438, 533, 511, 370, 542, 504,
1695 370, 536, 516, 524, 532, 534, 535, 544, 265, 558,
1696 560, 265, 265, 265, 543, 537, 516, 572, 582, 548,
1697 508, 554, 552, 555, 556, 553, 567, 569, 570, 571,
1698 579, 583, 584, 481, 587, 483, 588, 590, 486, 593,
1699 594, 213, 214, 215, 490, 491, 338, 127, 557, 337,
1700 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1701 295, 296, 297, 298, 540, 139, 336, 142, 328, 42,
1702 565, 126, 514, 515, -199, 518, 519, 94, 528, 457,
1703 0, 523, 0, 0, 0, 0, 0, 0, 508, 0,
1704 0, 529, -66, 1, 2, 0, 3, 4, 5, 0,
1705 0, 0, 0, 0, 6, 7, 0, 0, 0, 0,
1706 0, 0, 545, 0, 0, 0, 0, 358, 359, 0,
1707 549, 61, 62, 360, 0, 8, 0, 0, 9, 0,
1708 0, 0, 10, 1, 2, 0, 3, 4, 5, 361,
1709 362, 363, 0, 0, 0, 0, 0, 0, 0, 0,
1710 0, 0, 0, 0, 364, 365, 573, 0, 0, 0,
1711 0, 577, 0, 0, 0, 0, 0, 0, 0, 0,
1712 0, 366, 0, 0, 0, 0, 0, 0, 585, 586,
1713 0, 0, 0, 589, 0, 0, 591, 174, 175, 176,
1714 177, 178, 179, 180, 181, 182, 183, 184, 185, 186,
1715 187, 188, 245, 246, 0, 0, 0, 0, 0, 0,
1716 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1717 0, 0, 0, 0, 0, 0, 0, 0, 0, 247,
1718 195, 196, 197, 198, 199, 200, 201, 202, 203, 204,
1719 205, 206, 0, 248, 0, 249, 250, 251, 0, 0,
1720 0, 358, 359, 0, 0, 61, 62, 360, 0, 0,
1721 0, 0, 108, 0, 109, 0, 0, 1, 2, 367,
1722 3, 4, 5, 361, 362, 363, 0, 0, 0, 0,
1723 61, 62, 0, 0, 0, 0, 0, 0, 364, 365,
1724 0, 0, 1, 2, 0, 3, 4, 5, 242, 0,
1725 0, 0, 0, 0, 0, 366, 0, 0, 0, 0,
1726 0, 0, 0, 243, 244, 0, 0, 0, 0, 0,
1727 0, 174, 175, 176, 177, 178, 179, 180, 181, 182,
1728 183, 184, 185, 186, 187, 188, 245, 246, 0, 0,
1729 0, 0, 0, 0, 0, 0, 174, 175, 176, 177,
1730 178, 179, 180, 181, 182, 183, 184, 185, 186, 187,
1731 188, 245, 246, 247, 195, 196, 197, 198, 199, 200,
1732 201, 202, 203, 204, 205, 206, 0, 248, 0, 249,
1733 250, 251, 0, 0, 0, 0, 0, 0, 247, 195,
1734 196, 197, 198, 199, 200, 201, 202, 203, 204, 205,
1735 206, 0, 248, 367, 249, 250, 251, 0, 0, 0,
1736 0, 358, 359, 0, 0, 0, 0, 360, 0, 0,
1737 0, 108, 0, 109, 0, 252, 0, 0, 253, 0,
1738 254, 0, 255, 361, 362, 363, 0, 0, 0, 0,
1739 0, 0, 0, 0, 0, 0, 0, 0, 364, 365,
1740 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1741 0, 0, 0, 61, 62, 366, 104, 64, 65, 66,
1742 67, 68, 69, 70, 0, 1, 2, 0, 3, 4,
1743 5, 174, 175, 176, 177, 178, 179, 180, 181, 182,
1744 183, 184, 185, 186, 187, 188, 245, 246, 0, 0,
1745 0, 0, 0, 61, 62, 71, 104, 64, 65, 66,
1746 67, 68, 69, 70, 0, 1, 2, 0, 3, 4,
1747 5, 0, 0, 247, 195, 196, 197, 198, 199, 200,
1748 201, 202, 203, 204, 205, 206, 0, 248, 0, 249,
1749 250, 251, 0, 61, 62, 71, 104, 150, 151, 152,
1750 153, 154, 155, 70, 0, 1, 2, 0, 3, 4,
1751 5, 61, 62, 367, 104, 150, 151, 152, 153, 154,
1752 155, 70, 0, 1, 2, 0, 3, 4, 5, 0,
1753 0, 0, 0, 61, 62, 71, 104, 64, 65, 66,
1754 67, 68, 69, 70, 0, 1, 2, 0, 3, 4,
1755 5, 0, 0, 71, 0, 72, 0, 0, 73, 0,
1756 0, 74, 0, 75, 105, 131, 0, 0, 0, 0,
1757 0, 0, 0, 61, 62, 71, 145, 64, 65, 66,
1758 67, 68, 69, 70, 0, 1, 2, 0, 3, 4,
1759 5, 0, 0, 0, 0, 72, 0, 0, 73, 0,
1760 0, 74, 0, 75, 138, 0, 0, 0, 0, 0,
1761 0, 0, 0, 61, 62, 71, 104, 64, 65, 66,
1762 67, 68, 69, 70, 0, 1, 2, 0, 3, 4,
1763 5, 0, 0, 0, 0, 72, 0, 0, 73, 0,
1764 0, 74, 0, 75, 349, 327, 0, 0, 0, 0,
1765 0, 0, 0, 72, 0, 71, 73, 0, 0, 74,
1766 0, 75, 413, 0, 0, 0, 0, 0, 0, 0,
1767 0, 0, 0, 0, 0, 72, 0, 0, 73, 0,
1768 0, 74, 0, 75, 0, 61, 62, 146, 104, 150,
1769 151, 152, 153, 154, 155, 70, 0, 1, 2, 0,
1770 3, 4, 5, 0, 0, 0, 0, 0, 0, 0,
1771 0, 0, 0, 0, 0, 72, 0, 0, 73, 0,
1772 0, 74, 0, 75, 0, 61, 62, 71, 104, 64,
1773 65, 66, 67, 68, 69, 70, 0, 1, 2, 0,
1774 3, 4, 5, 0, 0, 0, 0, 0, 0, 0,
1775 0, 0, 0, 0, 0, 72, 0, 425, 73, 0,
1776 0, 74, 0, 75, 0, 61, 62, 71, 104, 64,
1777 65, 66, 67, 68, 69, 70, 0, 1, 2, 0,
1778 3, 4, 5, 61, 62, 0, 63, 64, 65, 66,
1779 67, 68, 69, 70, 0, 1, 2, 510, 3, 4,
1780 5, 0, 0, 0, 0, 61, 62, 71, 104, 150,
1781 151, 152, 153, 154, 155, 70, 0, 1, 2, 0,
1782 3, 4, 5, 0, 0, 71, 0, 72, 0, 0,
1783 73, 0, 344, 74, 0, 75, 61, 62, 0, 145,
1784 64, 65, 66, 67, 68, 69, 70, 71, 1, 2,
1785 0, 3, 4, 5, 0, 0, 0, 0, 0, 0,
1786 0, 0, 0, 0, 0, 0, 0, 72, 0, 0,
1787 73, 0, 0, 74, 0, 75, 61, 62, 71, 104,
1788 64, 65, 66, 67, 68, 69, 70, 0, 1, 2,
1789 0, 3, 4, 5, 0, 0, 0, 0, 0, 0,
1790 0, 0, 0, 0, 0, 0, 0, 72, 0, 0,
1791 73, 0, 0, 74, 0, 75, 0, 0, 71, 0,
1792 0, 0, 0, 0, 0, 72, 0, 0, 73, 0,
1793 0, 74, 0, 75, 0, 0, 0, 0, 0, 0,
1794 0, 0, 0, 0, 0, 0, 0, 72, 0, 0,
1795 73, 0, 0, 74, 0, 75, 61, 62, 0, 264,
1796 64, 65, 66, 67, 68, 69, 70, 0, 1, 2,
1797 0, 3, 4, 5, 0, 0, 0, 0, 72, 0,
1798 0, 73, 0, 0, 74, 0, 75, 61, 62, 0,
1799 104, 150, 151, 152, 153, 154, 155, 70, 71, 1,
1800 2, 0, 3, 4, 5, 0, 0, 0, 0, 0,
1801 0, 0, 0, 0, 0, 0, 0, 0, 72, 0,
1802 0, 73, 0, 0, 74, 0, 75, 0, 0, 71,
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, 0, 0,
1809 0, 0, 0, 0, 0, 0, 0, 0, 72, 0,
1810 0, 73, 0, 0, 74, 0, 75, 165, 0, 0,
1811 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1812 0, 0, 0, 0, 0, 0, 166, 167, 0, 72,
1813 0, 0, 73, 0, 0, 74, 0, 347, 168, 169,
1814 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
1815 180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
1816 190, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1817 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1818 0, 191, 192, 193, 0, 0, 194, 195, 196, 197,
1819 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
1820 208, 209, 210, 211, 212
1821};
1822
1823static const short yycheck[] = { 0,
1824 26, 170, 158, 230, 124, 4, 11, 11, 148, 193,
1825 301, 28, 171, 0, 146, 16, 334, 335, 158, 426,
1826 34, 253, 254, 38, 208, 209, 210, 211, 212, 16,
1827 52, 215, 21, 11, 11, 148, 562, 150, 151, 53,
1828 29, 0, 147, 34, 66, 3, 4, 5, 6, 75,
1829 576, 147, 146, 158, 20, 147, 117, 23, 217, 18,
1830 19, 20, 158, 22, 23, 24, 158, 147, 26, 27,
1831 147, 30, 31, 99, 154, 53, 53, 103, 39, 40,
1832 11, 158, 143, 109, 45, 147, 17, 147, 114, 90,
1833 51, 46, 51, 48, 156, 54, 156, 19, 124, 58,
1834 22, 148, 24, 150, 511, 147, 424, 32, 33, 156,
1835 136, 137, 154, 147, 140, 347, 57, 151, 144, 134,
1836 135, 136, 18, 146, 139, 265, 19, 267, 268, 22,
1837 270, 24, 316, 146, 35, 367, 37, 148, 545, 150,
1838 157, 152, 168, 134, 135, 136, 113, 114, 139, 154,
1839 154, 271, 152, 148, 148, 150, 150, 151, 157, 154,
1840 148, 452, 150, 303, 146, 191, 192, 193, 194, 158,
1841 577, 311, 312, 22, 161, 60, 61, 62, 63, 64,
1842 65, 207, 208, 209, 210, 211, 212, 213, 214, 215,
1843 481, 42, 483, 44, 314, 117, 118, 223, 147, 81,
1844 82, 385, 151, 387, 388, 389, 21, 233, 22, 42,
1845 43, 44, 134, 135, 47, 137, 138, 147, 140, 141,
1846 142, 151, 22, 42, 43, 44, 45, 46, 47, 48,
1847 22, 50, 143, 144, 145, 375, 376, 377, 529, 134,
1848 135, 136, 150, 383, 139, 271, 473, 117, 118, 3,
1849 4, 5, 6, 393, 394, 4, 282, 4, 414, 147,
1850 148, 37, 150, 153, 134, 135, 153, 137, 138, 4,
1851 140, 141, 142, 299, 414, 110, 111, 22, 339, 340,
1852 341, 342, 343, 147, 148, 147, 150, 156, 314, 315,
1853 316, 352, 353, 354, 151, 151, 150, 437, 9, 439,
1854 484, 9, 442, 487, 488, 489, 9, 9, 448, 449,
1855 9, 9, 55, 267, 268, 11, 270, 7, 8, 156,
1856 547, 347, 150, 550, 143, 144, 145, 150, 150, 19,
1857 20, 357, 22, 23, 24, 22, 476, 477, 150, 479,
1858 480, 150, 150, 404, 405, 485, 150, 150, 147, 303,
1859 411, 147, 150, 147, 147, 495, 147, 311, 312, 385,
1860 386, 387, 388, 389, 147, 147, 392, 38, 38, 150,
1861 150, 59, 147, 147, 152, 544, 516, 403, 147, 147,
1862 147, 147, 147, 147, 524, 147, 156, 147, 147, 38,
1863 22, 4, 147, 151, 563, 22, 17, 458, 459, 460,
1864 461, 17, 150, 147, 465, 466, 90, 91, 92, 93,
1865 94, 95, 96, 97, 98, 99, 147, 4, 147, 147,
1866 560, 375, 376, 377, 147, 565, 147, 453, 147, 383,
1867 26, 27, 150, 147, 147, 147, 497, 498, 147, 393,
1868 394, 467, 582, 583, 53, 151, 472, 587, 22, 156,
1869 590, 151, 478, 147, 147, 147, 147, 152, 484, 53,
1870 17, 487, 488, 489, 147, 151, 492, 4, 17, 154,
1871 471, 532, 151, 534, 535, 151, 154, 151, 151, 151,
1872 147, 17, 147, 437, 17, 439, 71, 17, 442, 0,
1873 0, 127, 127, 127, 448, 449, 246, 90, 539, 245,
1874 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
1875 106, 107, 108, 109, 512, 103, 233, 109, 223, 16,
1876 546, 87, 476, 477, 0, 479, 480, 54, 492, 406,
1877 -1, 485, -1, -1, -1, -1, -1, -1, 539, -1,
1878 -1, 495, 18, 19, 20, -1, 22, 23, 24, -1,
1879 -1, -1, -1, -1, 30, 31, -1, -1, -1, -1,
1880 -1, -1, 516, -1, -1, -1, -1, 3, 4, -1,
1881 524, 7, 8, 9, -1, 51, -1, -1, 54, -1,
1882 -1, -1, 58, 19, 20, -1, 22, 23, 24, 25,
1883 26, 27, -1, -1, -1, -1, -1, -1, -1, -1,
1884 -1, -1, -1, -1, 40, 41, 560, -1, -1, -1,
1885 -1, 565, -1, -1, -1, -1, -1, -1, -1, -1,
1886 -1, 57, -1, -1, -1, -1, -1, -1, 582, 583,
1887 -1, -1, -1, 587, -1, -1, 590, 73, 74, 75,
1888 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
1889 86, 87, 88, 89, -1, -1, -1, -1, -1, -1,
1890 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1891 -1, -1, -1, -1, -1, -1, -1, -1, -1, 115,
1892 116, 117, 118, 119, 120, 121, 122, 123, 124, 125,
1893 126, 127, -1, 129, -1, 131, 132, 133, -1, -1,
1894 -1, 3, 4, -1, -1, 7, 8, 9, -1, -1,
1895 -1, -1, 148, -1, 150, -1, -1, 19, 20, 155,
1896 22, 23, 24, 25, 26, 27, -1, -1, -1, -1,
1897 7, 8, -1, -1, -1, -1, -1, -1, 40, 41,
1898 -1, -1, 19, 20, -1, 22, 23, 24, 25, -1,
1899 -1, -1, -1, -1, -1, 57, -1, -1, -1, -1,
1900 -1, -1, -1, 40, 41, -1, -1, -1, -1, -1,
1901 -1, 73, 74, 75, 76, 77, 78, 79, 80, 81,
1902 82, 83, 84, 85, 86, 87, 88, 89, -1, -1,
1903 -1, -1, -1, -1, -1, -1, 73, 74, 75, 76,
1904 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1905 87, 88, 89, 115, 116, 117, 118, 119, 120, 121,
1906 122, 123, 124, 125, 126, 127, -1, 129, -1, 131,
1907 132, 133, -1, -1, -1, -1, -1, -1, 115, 116,
1908 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
1909 127, -1, 129, 155, 131, 132, 133, -1, -1, -1,
1910 -1, 3, 4, -1, -1, -1, -1, 9, -1, -1,
1911 -1, 148, -1, 150, -1, 152, -1, -1, 155, -1,
1912 157, -1, 159, 25, 26, 27, -1, -1, -1, -1,
1913 -1, -1, -1, -1, -1, -1, -1, -1, 40, 41,
1914 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1915 -1, -1, -1, 7, 8, 57, 10, 11, 12, 13,
1916 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
1917 24, 73, 74, 75, 76, 77, 78, 79, 80, 81,
1918 82, 83, 84, 85, 86, 87, 88, 89, -1, -1,
1919 -1, -1, -1, 7, 8, 49, 10, 11, 12, 13,
1920 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
1921 24, -1, -1, 115, 116, 117, 118, 119, 120, 121,
1922 122, 123, 124, 125, 126, 127, -1, 129, -1, 131,
1923 132, 133, -1, 7, 8, 49, 10, 11, 12, 13,
1924 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
1925 24, 7, 8, 155, 10, 11, 12, 13, 14, 15,
1926 16, 17, -1, 19, 20, -1, 22, 23, 24, -1,
1927 -1, -1, -1, 7, 8, 49, 10, 11, 12, 13,
1928 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
1929 24, -1, -1, 49, -1, 149, -1, -1, 152, -1,
1930 -1, 155, -1, 157, 158, 39, -1, -1, -1, -1,
1931 -1, -1, -1, 7, 8, 49, 10, 11, 12, 13,
1932 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
1933 24, -1, -1, -1, -1, 149, -1, -1, 152, -1,
1934 -1, 155, -1, 157, 158, -1, -1, -1, -1, -1,
1935 -1, -1, -1, 7, 8, 49, 10, 11, 12, 13,
1936 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
1937 24, -1, -1, -1, -1, 149, -1, -1, 152, -1,
1938 -1, 155, -1, 157, 158, 39, -1, -1, -1, -1,
1939 -1, -1, -1, 149, -1, 49, 152, -1, -1, 155,
1940 -1, 157, 158, -1, -1, -1, -1, -1, -1, -1,
1941 -1, -1, -1, -1, -1, 149, -1, -1, 152, -1,
1942 -1, 155, -1, 157, -1, 7, 8, 121, 10, 11,
1943 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
1944 22, 23, 24, -1, -1, -1, -1, -1, -1, -1,
1945 -1, -1, -1, -1, -1, 149, -1, -1, 152, -1,
1946 -1, 155, -1, 157, -1, 7, 8, 49, 10, 11,
1947 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
1948 22, 23, 24, -1, -1, -1, -1, -1, -1, -1,
1949 -1, -1, -1, -1, -1, 149, -1, 39, 152, -1,
1950 -1, 155, -1, 157, -1, 7, 8, 49, 10, 11,
1951 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
1952 22, 23, 24, 7, 8, -1, 10, 11, 12, 13,
1953 14, 15, 16, 17, -1, 19, 20, 39, 22, 23,
1954 24, -1, -1, -1, -1, 7, 8, 49, 10, 11,
1955 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
1956 22, 23, 24, -1, -1, 49, -1, 149, -1, -1,
1957 152, -1, 154, 155, -1, 157, 7, 8, -1, 10,
1958 11, 12, 13, 14, 15, 16, 17, 49, 19, 20,
1959 -1, 22, 23, 24, -1, -1, -1, -1, -1, -1,
1960 -1, -1, -1, -1, -1, -1, -1, 149, -1, -1,
1961 152, -1, -1, 155, -1, 157, 7, 8, 49, 10,
1962 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
1963 -1, 22, 23, 24, -1, -1, -1, -1, -1, -1,
1964 -1, -1, -1, -1, -1, -1, -1, 149, -1, -1,
1965 152, -1, -1, 155, -1, 157, -1, -1, 49, -1,
1966 -1, -1, -1, -1, -1, 149, -1, -1, 152, -1,
1967 -1, 155, -1, 157, -1, -1, -1, -1, -1, -1,
1968 -1, -1, -1, -1, -1, -1, -1, 149, -1, -1,
1969 152, -1, -1, 155, -1, 157, 7, 8, -1, 10,
1970 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
1971 -1, 22, 23, 24, -1, -1, -1, -1, 149, -1,
1972 -1, 152, -1, -1, 155, -1, 157, 7, 8, -1,
1973 10, 11, 12, 13, 14, 15, 16, 17, 49, 19,
1974 20, -1, 22, 23, 24, -1, -1, -1, -1, -1,
1975 -1, -1, -1, -1, -1, -1, -1, -1, 149, -1,
1976 -1, 152, -1, -1, 155, -1, 157, -1, -1, 49,
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, -1, -1,
1983 -1, -1, -1, -1, -1, -1, -1, -1, 149, -1,
1984 -1, 152, -1, -1, 155, -1, 157, 36, -1, -1,
1985 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1986 -1, -1, -1, -1, -1, -1, 55, 56, -1, 149,
1987 -1, -1, 152, -1, -1, 155, -1, 157, 67, 68,
1988 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
1989 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
1990 89, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1991 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1992 -1, 110, 111, 112, -1, -1, 115, 116, 117, 118,
1993 119, 120, 121, 122, 123, 124, 125, 126, 127, 128,
1994 129, 130, 131, 132, 133
1995};
1996/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
1997#line 3 "/usr/share/bison.simple"
1998/* This file comes from bison-1.28. */
1999
2000/* Skeleton output parser for bison,
2001 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
2002
2003 This program is free software; you can redistribute it and/or modify
2004 it under the terms of the GNU General Public License as published by
2005 the Free Software Foundation; either version 2, or (at your option)
2006 any later version.
2007
2008 This program is distributed in the hope that it will be useful,
2009 but WITHOUT ANY WARRANTY; without even the implied warranty of
2010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2011 GNU General Public License for more details.
2012
2013 You should have received a copy of the GNU General Public License
2014 along with this program; if not, write to the Free Software
2015 Foundation, Inc., 59 Temple Place - Suite 330,
2016 Boston, MA 02111-1307, USA. */
2017
2018/* As a special exception, when this file is copied by Bison into a
2019 Bison output file, you may use that output file without restriction.
2020 This special exception was added by the Free Software Foundation
2021 in version 1.24 of Bison. */
2022
2023/* This is the parser code that is written into each bison parser
2024 when the %semantic_parser declaration is not specified in the grammar.
2025 It was written by Richard Stallman by simplifying the hairy parser
2026 used when %semantic_parser is specified. */
2027
2028#ifndef YYSTACK_USE_ALLOCA
2029#ifdef alloca
2030#define YYSTACK_USE_ALLOCA
2031#else /* alloca not defined */
2032#ifdef __GNUC__
2033#define YYSTACK_USE_ALLOCA
2034#define alloca __builtin_alloca
2035#else /* not GNU C. */
2036#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
2037#define YYSTACK_USE_ALLOCA
2038#include <alloca.h>
2039#else /* not sparc */
2040/* We think this test detects Watcom and Microsoft C. */
2041/* This used to test MSDOS, but that is a bad idea
2042 since that symbol is in the user namespace. */
2043#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
2044#if 0 /* No need for malloc.h, which pollutes the namespace;
2045 instead, just don't use alloca. */
2046#include <malloc.h>
2047#endif
2048#else /* not MSDOS, or __TURBOC__ */
2049#if defined(_AIX)
2050/* I don't know what this was needed for, but it pollutes the namespace.
2051 So I turned it off. rms, 2 May 1997. */
2052/* #include <malloc.h> */
2053 #pragma alloca
2054#define YYSTACK_USE_ALLOCA
2055#else /* not MSDOS, or __TURBOC__, or _AIX */
2056#if 0
2057#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
2058 and on HPUX 10. Eventually we can turn this on. */
2059#define YYSTACK_USE_ALLOCA
2060#define alloca __builtin_alloca
2061#endif /* __hpux */
2062#endif
2063#endif /* not _AIX */
2064#endif /* not MSDOS, or __TURBOC__ */
2065#endif /* not sparc */
2066#endif /* not GNU C */
2067#endif /* alloca not defined */
2068#endif /* YYSTACK_USE_ALLOCA not defined */
2069
2070#ifdef YYSTACK_USE_ALLOCA
2071#define YYSTACK_ALLOC alloca
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002072#else
Dale Johannesencdd509a2007-09-07 21:07:57 +00002073#define YYSTACK_ALLOC malloc
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002074#endif
2075
Dale Johannesencdd509a2007-09-07 21:07:57 +00002076/* Note: there must be only one dollar sign in this file.
2077 It is replaced by the list of actions, each action
2078 as one case of the switch. */
David Greene718fda32007-08-01 03:59:32 +00002079
Reid Spencer68a24bd2005-08-27 18:50:39 +00002080#define yyerrok (yyerrstatus = 0)
2081#define yyclearin (yychar = YYEMPTY)
Dale Johannesencdd509a2007-09-07 21:07:57 +00002082#define YYEMPTY -2
Reid Spencer68a24bd2005-08-27 18:50:39 +00002083#define YYEOF 0
Reid Spencer68a24bd2005-08-27 18:50:39 +00002084#define YYACCEPT goto yyacceptlab
Dale Johannesencdd509a2007-09-07 21:07:57 +00002085#define YYABORT goto yyabortlab
2086#define YYERROR goto yyerrlab1
2087/* Like YYERROR except do call yyerror.
2088 This remains here temporarily to ease the
2089 transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002090 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002091#define YYFAIL goto yyerrlab
Reid Spencer68a24bd2005-08-27 18:50:39 +00002092#define YYRECOVERING() (!!yyerrstatus)
Dale Johannesencdd509a2007-09-07 21:07:57 +00002093#define YYBACKUP(token, value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002094do \
2095 if (yychar == YYEMPTY && yylen == 1) \
Dale Johannesencdd509a2007-09-07 21:07:57 +00002096 { yychar = (token), yylval = (value); \
2097 yychar1 = YYTRANSLATE (yychar); \
Chris Lattner0275cff2007-08-06 21:00:46 +00002098 YYPOPSTACK; \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002099 goto yybackup; \
2100 } \
2101 else \
Dale Johannesencdd509a2007-09-07 21:07:57 +00002102 { yyerror ("syntax error: cannot back up"); YYERROR; } \
Chris Lattner0275cff2007-08-06 21:00:46 +00002103while (0)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002104
Reid Spencer68a24bd2005-08-27 18:50:39 +00002105#define YYTERROR 1
2106#define YYERRCODE 256
2107
Dale Johannesencdd509a2007-09-07 21:07:57 +00002108#ifndef YYPURE
2109#define YYLEX yylex()
Reid Spencer68a24bd2005-08-27 18:50:39 +00002110#endif
2111
Dale Johannesencdd509a2007-09-07 21:07:57 +00002112#ifdef YYPURE
2113#ifdef YYLSP_NEEDED
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002114#ifdef YYLEX_PARAM
Dale Johannesencdd509a2007-09-07 21:07:57 +00002115#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002116#else
Dale Johannesencdd509a2007-09-07 21:07:57 +00002117#define YYLEX yylex(&yylval, &yylloc)
2118#endif
2119#else /* not YYLSP_NEEDED */
2120#ifdef YYLEX_PARAM
2121#define YYLEX yylex(&yylval, YYLEX_PARAM)
2122#else
2123#define YYLEX yylex(&yylval)
2124#endif
2125#endif /* not YYLSP_NEEDED */
Chris Lattner0275cff2007-08-06 21:00:46 +00002126#endif
David Greene5fd22a82007-09-04 18:46:50 +00002127
Dale Johannesencdd509a2007-09-07 21:07:57 +00002128/* If nonreentrant, generate the variables here */
David Greene5fd22a82007-09-04 18:46:50 +00002129
Dale Johannesencdd509a2007-09-07 21:07:57 +00002130#ifndef YYPURE
David Greene5fd22a82007-09-04 18:46:50 +00002131
Dale Johannesencdd509a2007-09-07 21:07:57 +00002132int yychar; /* the lookahead symbol */
2133YYSTYPE yylval; /* the semantic value of the */
2134 /* lookahead symbol */
David Greene5fd22a82007-09-04 18:46:50 +00002135
Dale Johannesencdd509a2007-09-07 21:07:57 +00002136#ifdef YYLSP_NEEDED
2137YYLTYPE yylloc; /* location data for the lookahead */
2138 /* symbol */
Chris Lattner0275cff2007-08-06 21:00:46 +00002139#endif
David Greene5fd22a82007-09-04 18:46:50 +00002140
Dale Johannesencdd509a2007-09-07 21:07:57 +00002141int yynerrs; /* number of parse errors so far */
2142#endif /* not YYPURE */
David Greene5fd22a82007-09-04 18:46:50 +00002143
Dale Johannesencdd509a2007-09-07 21:07:57 +00002144#if YYDEBUG != 0
2145int yydebug; /* nonzero means print parse trace */
2146/* Since this is uninitialized, it does not stop multiple parsers
2147 from coexisting. */
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002148#endif
Chandler Carruth02202192007-08-04 01:56:21 +00002149
Dale Johannesencdd509a2007-09-07 21:07:57 +00002150/* YYINITDEPTH indicates the initial size of the parser's stacks */
Chandler Carruth02202192007-08-04 01:56:21 +00002151
Reid Spencer68a24bd2005-08-27 18:50:39 +00002152#ifndef YYINITDEPTH
Dale Johannesencdd509a2007-09-07 21:07:57 +00002153#define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00002154#endif
2155
Dale Johannesencdd509a2007-09-07 21:07:57 +00002156/* YYMAXDEPTH is the maximum size the stacks can grow to
2157 (effective only if the built-in stack extension method is used). */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002158
Dale Johannesencdd509a2007-09-07 21:07:57 +00002159#if YYMAXDEPTH == 0
2160#undef YYMAXDEPTH
Chris Lattner0275cff2007-08-06 21:00:46 +00002161#endif
David Greene718fda32007-08-01 03:59:32 +00002162
Reid Spencer68a24bd2005-08-27 18:50:39 +00002163#ifndef YYMAXDEPTH
Dale Johannesencdd509a2007-09-07 21:07:57 +00002164#define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00002165#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002166
Dale Johannesencdd509a2007-09-07 21:07:57 +00002167/* Define __yy_memcpy. Note that the size argument
2168 should be passed with type unsigned int, because that is what the non-GCC
2169 definitions require. With GCC, __builtin_memcpy takes an arg
2170 of type size_t, but it can handle unsigned int. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002171
Dale Johannesencdd509a2007-09-07 21:07:57 +00002172#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
2173#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
2174#else /* not GNU C or C++ */
2175#ifndef __cplusplus
Reid Spencer68a24bd2005-08-27 18:50:39 +00002176
Dale Johannesencdd509a2007-09-07 21:07:57 +00002177/* This is the most reliable way to avoid incompatibilities
2178 in available built-in functions on various systems. */
David Greene5fd22a82007-09-04 18:46:50 +00002179static void
Dale Johannesencdd509a2007-09-07 21:07:57 +00002180__yy_memcpy (to, from, count)
2181 char *to;
2182 char *from;
2183 unsigned int count;
2184{
2185 register char *f = from;
2186 register char *t = to;
2187 register int i = count;
2188
2189 while (i-- > 0)
2190 *t++ = *f++;
2191}
2192
2193#else /* __cplusplus */
2194
2195/* This is the most reliable way to avoid incompatibilities
2196 in available built-in functions on various systems. */
David Greene5fd22a82007-09-04 18:46:50 +00002197static void
Dale Johannesencdd509a2007-09-07 21:07:57 +00002198__yy_memcpy (char *to, char *from, unsigned int count)
2199{
2200 register char *t = to;
2201 register char *f = from;
2202 register int i = count;
2203
2204 while (i-- > 0)
2205 *t++ = *f++;
2206}
2207
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002208#endif
David Greene5fd22a82007-09-04 18:46:50 +00002209#endif
David Greene5fd22a82007-09-04 18:46:50 +00002210
Dale Johannesencdd509a2007-09-07 21:07:57 +00002211#line 217 "/usr/share/bison.simple"
David Greene5fd22a82007-09-04 18:46:50 +00002212
Dale Johannesencdd509a2007-09-07 21:07:57 +00002213/* The user can define YYPARSE_PARAM as the name of an argument to be passed
2214 into yyparse. The argument should have type void *.
2215 It should actually point to an object.
2216 Grammar actions can access the variable by casting it
2217 to the proper pointer type. */
David Greene5fd22a82007-09-04 18:46:50 +00002218
2219#ifdef YYPARSE_PARAM
Dale Johannesencdd509a2007-09-07 21:07:57 +00002220#ifdef __cplusplus
2221#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
2222#define YYPARSE_PARAM_DECL
2223#else /* not __cplusplus */
2224#define YYPARSE_PARAM_ARG YYPARSE_PARAM
2225#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
2226#endif /* not __cplusplus */
2227#else /* not YYPARSE_PARAM */
2228#define YYPARSE_PARAM_ARG
2229#define YYPARSE_PARAM_DECL
2230#endif /* not YYPARSE_PARAM */
2231
2232/* Prevent warning if -Wstrict-prototypes. */
2233#ifdef __GNUC__
2234#ifdef YYPARSE_PARAM
2235int yyparse (void *);
2236#else
David Greene5fd22a82007-09-04 18:46:50 +00002237int yyparse (void);
David Greene5fd22a82007-09-04 18:46:50 +00002238#endif
Dale Johannesencdd509a2007-09-07 21:07:57 +00002239#endif
David Greene5fd22a82007-09-04 18:46:50 +00002240
David Greene5fd22a82007-09-04 18:46:50 +00002241int
Dale Johannesencdd509a2007-09-07 21:07:57 +00002242yyparse(YYPARSE_PARAM_ARG)
2243 YYPARSE_PARAM_DECL
David Greene5fd22a82007-09-04 18:46:50 +00002244{
Chris Lattner0275cff2007-08-06 21:00:46 +00002245 register int yystate;
2246 register int yyn;
2247 register short *yyssp;
2248 register YYSTYPE *yyvsp;
Dale Johannesencdd509a2007-09-07 21:07:57 +00002249 int yyerrstatus; /* number of tokens to shift before error messages enabled */
2250 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
Chris Lattner0275cff2007-08-06 21:00:46 +00002251
Dale Johannesencdd509a2007-09-07 21:07:57 +00002252 short yyssa[YYINITDEPTH]; /* the state stack */
2253 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
Chris Lattner0275cff2007-08-06 21:00:46 +00002254
Dale Johannesencdd509a2007-09-07 21:07:57 +00002255 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
2256 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
Chris Lattner0275cff2007-08-06 21:00:46 +00002257
Dale Johannesencdd509a2007-09-07 21:07:57 +00002258#ifdef YYLSP_NEEDED
2259 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
2260 YYLTYPE *yyls = yylsa;
2261 YYLTYPE *yylsp;
2262
2263#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
2264#else
Chris Lattner0275cff2007-08-06 21:00:46 +00002265#define YYPOPSTACK (yyvsp--, yyssp--)
Dale Johannesencdd509a2007-09-07 21:07:57 +00002266#endif
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002267
Dale Johannesencdd509a2007-09-07 21:07:57 +00002268 int yystacksize = YYINITDEPTH;
2269 int yyfree_stacks = 0;
Chandler Carruth02202192007-08-04 01:56:21 +00002270
Dale Johannesencdd509a2007-09-07 21:07:57 +00002271#ifdef YYPURE
2272 int yychar;
2273 YYSTYPE yylval;
2274 int yynerrs;
2275#ifdef YYLSP_NEEDED
2276 YYLTYPE yylloc;
2277#endif
2278#endif
Chandler Carruth02202192007-08-04 01:56:21 +00002279
Dale Johannesencdd509a2007-09-07 21:07:57 +00002280 YYSTYPE yyval; /* the variable used to return */
2281 /* semantic values from the action */
2282 /* routines */
Chandler Carruth02202192007-08-04 01:56:21 +00002283
Chris Lattner0275cff2007-08-06 21:00:46 +00002284 int yylen;
Chandler Carruth02202192007-08-04 01:56:21 +00002285
Dale Johannesencdd509a2007-09-07 21:07:57 +00002286#if YYDEBUG != 0
2287 if (yydebug)
2288 fprintf(stderr, "Starting parse\n");
2289#endif
Chandler Carruth02202192007-08-04 01:56:21 +00002290
Reid Spencer68a24bd2005-08-27 18:50:39 +00002291 yystate = 0;
2292 yyerrstatus = 0;
2293 yynerrs = 0;
2294 yychar = YYEMPTY; /* Cause a token to be read. */
2295
2296 /* Initialize stack pointers.
2297 Waste one element of value and location stack
2298 so that they stay on the same level as the state stack.
2299 The wasted elements are never initialized. */
2300
Dale Johannesencdd509a2007-09-07 21:07:57 +00002301 yyssp = yyss - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002302 yyvsp = yyvs;
Dale Johannesencdd509a2007-09-07 21:07:57 +00002303#ifdef YYLSP_NEEDED
2304 yylsp = yyls;
2305#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002306
Dale Johannesencdd509a2007-09-07 21:07:57 +00002307/* Push a new state, which is found in yystate . */
2308/* In all cases, when you get here, the value and location stacks
2309 have just been pushed. so pushing a state here evens the stacks. */
2310yynewstate:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002311
Dale Johannesencdd509a2007-09-07 21:07:57 +00002312 *++yyssp = yystate;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002313
Dale Johannesencdd509a2007-09-07 21:07:57 +00002314 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002315 {
Dale Johannesencdd509a2007-09-07 21:07:57 +00002316 /* Give user a chance to reallocate the stack */
2317 /* Use copies of these so that the &'s don't force the real ones into memory. */
2318 YYSTYPE *yyvs1 = yyvs;
2319 short *yyss1 = yyss;
2320#ifdef YYLSP_NEEDED
2321 YYLTYPE *yyls1 = yyls;
2322#endif
2323
Reid Spencer68a24bd2005-08-27 18:50:39 +00002324 /* Get the current used size of the three stacks, in elements. */
Dale Johannesencdd509a2007-09-07 21:07:57 +00002325 int size = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002326
2327#ifdef yyoverflow
Dale Johannesencdd509a2007-09-07 21:07:57 +00002328 /* Each stack pointer address is followed by the size of
2329 the data in use in that stack, in bytes. */
2330#ifdef YYLSP_NEEDED
2331 /* This used to be a conditional around just the two extra args,
2332 but that might be undefined if yyoverflow is a macro. */
2333 yyoverflow("parser stack overflow",
2334 &yyss1, size * sizeof (*yyssp),
2335 &yyvs1, size * sizeof (*yyvsp),
2336 &yyls1, size * sizeof (*yylsp),
2337 &yystacksize);
2338#else
2339 yyoverflow("parser stack overflow",
2340 &yyss1, size * sizeof (*yyssp),
2341 &yyvs1, size * sizeof (*yyvsp),
2342 &yystacksize);
2343#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002344
Dale Johannesencdd509a2007-09-07 21:07:57 +00002345 yyss = yyss1; yyvs = yyvs1;
2346#ifdef YYLSP_NEEDED
2347 yyls = yyls1;
2348#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002349#else /* no yyoverflow */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002350 /* Extend the stack our own way. */
Dale Johannesencdd509a2007-09-07 21:07:57 +00002351 if (yystacksize >= YYMAXDEPTH)
2352 {
2353 yyerror("parser stack overflow");
2354 if (yyfree_stacks)
2355 {
2356 free (yyss);
2357 free (yyvs);
2358#ifdef YYLSP_NEEDED
2359 free (yyls);
2360#endif
2361 }
2362 return 2;
2363 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002364 yystacksize *= 2;
Dale Johannesencdd509a2007-09-07 21:07:57 +00002365 if (yystacksize > YYMAXDEPTH)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002366 yystacksize = YYMAXDEPTH;
Dale Johannesencdd509a2007-09-07 21:07:57 +00002367#ifndef YYSTACK_USE_ALLOCA
2368 yyfree_stacks = 1;
2369#endif
2370 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
2371 __yy_memcpy ((char *)yyss, (char *)yyss1,
2372 size * (unsigned int) sizeof (*yyssp));
2373 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
2374 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
2375 size * (unsigned int) sizeof (*yyvsp));
2376#ifdef YYLSP_NEEDED
2377 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
2378 __yy_memcpy ((char *)yyls, (char *)yyls1,
2379 size * (unsigned int) sizeof (*yylsp));
2380#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002381#endif /* no yyoverflow */
2382
Dale Johannesencdd509a2007-09-07 21:07:57 +00002383 yyssp = yyss + size - 1;
2384 yyvsp = yyvs + size - 1;
2385#ifdef YYLSP_NEEDED
2386 yylsp = yyls + size - 1;
2387#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002388
Dale Johannesencdd509a2007-09-07 21:07:57 +00002389#if YYDEBUG != 0
2390 if (yydebug)
2391 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2392#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002393
Dale Johannesencdd509a2007-09-07 21:07:57 +00002394 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002395 YYABORT;
2396 }
2397
Dale Johannesencdd509a2007-09-07 21:07:57 +00002398#if YYDEBUG != 0
2399 if (yydebug)
2400 fprintf(stderr, "Entering state %d\n", yystate);
2401#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002402
2403 goto yybackup;
Dale Johannesencdd509a2007-09-07 21:07:57 +00002404 yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002405
Chris Lattner0275cff2007-08-06 21:00:46 +00002406/* Do appropriate processing given the current state. */
2407/* Read a lookahead token if we need one and don't already have one. */
2408/* yyresume: */
Andrew Lenharth6353e052006-12-08 18:07:09 +00002409
Chris Lattner0275cff2007-08-06 21:00:46 +00002410 /* First try to decide what to do without reference to lookahead token. */
Reid Spencer7780acb2007-04-16 06:56:07 +00002411
Reid Spencer68a24bd2005-08-27 18:50:39 +00002412 yyn = yypact[yystate];
Dale Johannesencdd509a2007-09-07 21:07:57 +00002413 if (yyn == YYFLAG)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002414 goto yydefault;
2415
Chris Lattner0275cff2007-08-06 21:00:46 +00002416 /* Not known => get a lookahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002417
Dale Johannesencdd509a2007-09-07 21:07:57 +00002418 /* yychar is either YYEMPTY or YYEOF
2419 or a valid token in external form. */
2420
Reid Spencer68a24bd2005-08-27 18:50:39 +00002421 if (yychar == YYEMPTY)
2422 {
Dale Johannesencdd509a2007-09-07 21:07:57 +00002423#if YYDEBUG != 0
2424 if (yydebug)
2425 fprintf(stderr, "Reading a token: ");
2426#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002427 yychar = YYLEX;
2428 }
2429
Dale Johannesencdd509a2007-09-07 21:07:57 +00002430 /* Convert token to internal form (in yychar1) for indexing tables with */
2431
2432 if (yychar <= 0) /* This means end of input. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002433 {
Dale Johannesencdd509a2007-09-07 21:07:57 +00002434 yychar1 = 0;
2435 yychar = YYEOF; /* Don't call YYLEX any more */
2436
2437#if YYDEBUG != 0
2438 if (yydebug)
2439 fprintf(stderr, "Now at end of input.\n");
2440#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002441 }
2442 else
2443 {
Dale Johannesencdd509a2007-09-07 21:07:57 +00002444 yychar1 = YYTRANSLATE(yychar);
2445
2446#if YYDEBUG != 0
2447 if (yydebug)
2448 {
2449 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2450 /* Give the individual parser a way to print the precise meaning
2451 of a token, for further debugging info. */
2452#ifdef YYPRINT
2453 YYPRINT (stderr, yychar, yylval);
2454#endif
2455 fprintf (stderr, ")\n");
2456 }
2457#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002458 }
2459
Dale Johannesencdd509a2007-09-07 21:07:57 +00002460 yyn += yychar1;
2461 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002462 goto yydefault;
Dale Johannesencdd509a2007-09-07 21:07:57 +00002463
Reid Spencer68a24bd2005-08-27 18:50:39 +00002464 yyn = yytable[yyn];
Dale Johannesencdd509a2007-09-07 21:07:57 +00002465
2466 /* yyn is what to do for this token type in this state.
2467 Negative => reduce, -yyn is rule number.
2468 Positive => shift, yyn is new state.
2469 New state is final state => don't bother to shift,
2470 just return success.
2471 0, or most negative number => error. */
2472
2473 if (yyn < 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002474 {
Dale Johannesencdd509a2007-09-07 21:07:57 +00002475 if (yyn == YYFLAG)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002476 goto yyerrlab;
2477 yyn = -yyn;
2478 goto yyreduce;
2479 }
Dale Johannesencdd509a2007-09-07 21:07:57 +00002480 else if (yyn == 0)
2481 goto yyerrlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002482
2483 if (yyn == YYFINAL)
2484 YYACCEPT;
2485
Chris Lattner0275cff2007-08-06 21:00:46 +00002486 /* Shift the lookahead token. */
Dale Johannesencdd509a2007-09-07 21:07:57 +00002487
2488#if YYDEBUG != 0
2489 if (yydebug)
2490 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2491#endif
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002492
Chris Lattner0275cff2007-08-06 21:00:46 +00002493 /* Discard the token being shifted unless it is eof. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002494 if (yychar != YYEOF)
2495 yychar = YYEMPTY;
2496
Chandler Carruth02202192007-08-04 01:56:21 +00002497 *++yyvsp = yylval;
Dale Johannesencdd509a2007-09-07 21:07:57 +00002498#ifdef YYLSP_NEEDED
2499 *++yylsp = yylloc;
2500#endif
Chandler Carruth02202192007-08-04 01:56:21 +00002501
Dale Johannesencdd509a2007-09-07 21:07:57 +00002502 /* count tokens shifted since error; after three, turn off error status. */
2503 if (yyerrstatus) yyerrstatus--;
Chris Lattner0275cff2007-08-06 21:00:46 +00002504
2505 yystate = yyn;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002506 goto yynewstate;
2507
Dale Johannesencdd509a2007-09-07 21:07:57 +00002508/* Do the default action for the current state. */
David Greene5fd22a82007-09-04 18:46:50 +00002509yydefault:
Dale Johannesencdd509a2007-09-07 21:07:57 +00002510
Reid Spencer68a24bd2005-08-27 18:50:39 +00002511 yyn = yydefact[yystate];
2512 if (yyn == 0)
2513 goto yyerrlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002514
Dale Johannesencdd509a2007-09-07 21:07:57 +00002515/* Do a reduction. yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002516yyreduce:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002517 yylen = yyr2[yyn];
Dale Johannesencdd509a2007-09-07 21:07:57 +00002518 if (yylen > 0)
2519 yyval = yyvsp[1-yylen]; /* implement default value of the action */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002520
Dale Johannesencdd509a2007-09-07 21:07:57 +00002521#if YYDEBUG != 0
2522 if (yydebug)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002523 {
Dale Johannesencdd509a2007-09-07 21:07:57 +00002524 int i;
Reid Spencer41dff5e2007-01-26 08:05:27 +00002525
Dale Johannesencdd509a2007-09-07 21:07:57 +00002526 fprintf (stderr, "Reducing via rule %d (line %d), ",
2527 yyn, yyrline[yyn]);
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002528
Dale Johannesencdd509a2007-09-07 21:07:57 +00002529 /* Print the symbols being reduced, and their result. */
2530 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2531 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2532 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2533 }
2534#endif
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002535
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002536
Dale Johannesencdd509a2007-09-07 21:07:57 +00002537 switch (yyn) {
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002538
Dale Johannesencdd509a2007-09-07 21:07:57 +00002539case 28:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002540#line 1133 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002541{ yyval.IPredicate = ICmpInst::ICMP_EQ; ;
2542 break;}
2543case 29:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002544#line 1133 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002545{ yyval.IPredicate = ICmpInst::ICMP_NE; ;
2546 break;}
2547case 30:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002548#line 1134 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002549{ yyval.IPredicate = ICmpInst::ICMP_SLT; ;
2550 break;}
2551case 31:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002552#line 1134 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002553{ yyval.IPredicate = ICmpInst::ICMP_SGT; ;
2554 break;}
2555case 32:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002556#line 1135 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002557{ yyval.IPredicate = ICmpInst::ICMP_SLE; ;
2558 break;}
2559case 33:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002560#line 1135 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002561{ yyval.IPredicate = ICmpInst::ICMP_SGE; ;
2562 break;}
2563case 34:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002564#line 1136 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002565{ yyval.IPredicate = ICmpInst::ICMP_ULT; ;
2566 break;}
2567case 35:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002568#line 1136 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002569{ yyval.IPredicate = ICmpInst::ICMP_UGT; ;
2570 break;}
2571case 36:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002572#line 1137 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002573{ yyval.IPredicate = ICmpInst::ICMP_ULE; ;
2574 break;}
2575case 37:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002576#line 1137 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002577{ yyval.IPredicate = ICmpInst::ICMP_UGE; ;
2578 break;}
2579case 38:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002580#line 1141 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002581{ yyval.FPredicate = FCmpInst::FCMP_OEQ; ;
2582 break;}
2583case 39:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002584#line 1141 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002585{ yyval.FPredicate = FCmpInst::FCMP_ONE; ;
2586 break;}
2587case 40:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002588#line 1142 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002589{ yyval.FPredicate = FCmpInst::FCMP_OLT; ;
2590 break;}
2591case 41:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002592#line 1142 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002593{ yyval.FPredicate = FCmpInst::FCMP_OGT; ;
2594 break;}
2595case 42:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002596#line 1143 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002597{ yyval.FPredicate = FCmpInst::FCMP_OLE; ;
2598 break;}
2599case 43:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002600#line 1143 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002601{ yyval.FPredicate = FCmpInst::FCMP_OGE; ;
2602 break;}
2603case 44:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002604#line 1144 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002605{ yyval.FPredicate = FCmpInst::FCMP_ORD; ;
2606 break;}
2607case 45:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002608#line 1144 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002609{ yyval.FPredicate = FCmpInst::FCMP_UNO; ;
2610 break;}
2611case 46:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002612#line 1145 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002613{ yyval.FPredicate = FCmpInst::FCMP_UEQ; ;
2614 break;}
2615case 47:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002616#line 1145 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002617{ yyval.FPredicate = FCmpInst::FCMP_UNE; ;
2618 break;}
2619case 48:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002620#line 1146 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002621{ yyval.FPredicate = FCmpInst::FCMP_ULT; ;
2622 break;}
2623case 49:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002624#line 1146 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002625{ yyval.FPredicate = FCmpInst::FCMP_UGT; ;
2626 break;}
2627case 50:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002628#line 1147 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002629{ yyval.FPredicate = FCmpInst::FCMP_ULE; ;
2630 break;}
2631case 51:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002632#line 1147 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002633{ yyval.FPredicate = FCmpInst::FCMP_UGE; ;
2634 break;}
2635case 52:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002636#line 1148 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002637{ yyval.FPredicate = FCmpInst::FCMP_TRUE; ;
2638 break;}
2639case 53:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002640#line 1149 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002641{ yyval.FPredicate = FCmpInst::FCMP_FALSE; ;
2642 break;}
2643case 64:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002644#line 1158 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002645{ yyval.StrVal = 0; ;
2646 break;}
2647case 65:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002648#line 1162 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002649{
Chris Lattner0275cff2007-08-06 21:00:46 +00002650 yyval.StrVal = yyvsp[-1].StrVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00002651 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00002652 ;
2653 break;}
2654case 66:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002655#line 1166 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002656{
Chris Lattner0275cff2007-08-06 21:00:46 +00002657 yyval.StrVal = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00002658 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00002659 ;
2660 break;}
2661case 70:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002662#line 1174 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002663{
Chris Lattner0275cff2007-08-06 21:00:46 +00002664 yyval.StrVal = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00002665 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00002666 ;
2667 break;}
2668case 71:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002669#line 1179 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002670{
Chris Lattner0275cff2007-08-06 21:00:46 +00002671 yyval.StrVal = yyvsp[-1].StrVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00002672 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00002673 ;
2674 break;}
2675case 72:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002676#line 1185 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002677{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2678 break;}
2679case 73:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002680#line 1186 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002681{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2682 break;}
2683case 74:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002684#line 1187 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002685{ yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2686 break;}
2687case 75:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002688#line 1188 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002689{ yyval.Linkage = GlobalValue::AppendingLinkage; ;
2690 break;}
2691case 76:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002692#line 1189 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002693{ yyval.Linkage = GlobalValue::DLLExportLinkage; ;
2694 break;}
2695case 77:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002696#line 1193 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002697{ yyval.Linkage = GlobalValue::DLLImportLinkage; ;
2698 break;}
2699case 78:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002700#line 1194 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002701{ yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;
2702 break;}
2703case 79:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002704#line 1195 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002705{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2706 break;}
2707case 80:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002708#line 1199 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002709{ yyval.Visibility = GlobalValue::DefaultVisibility; ;
2710 break;}
2711case 81:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002712#line 1200 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002713{ yyval.Visibility = GlobalValue::DefaultVisibility; ;
2714 break;}
2715case 82:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002716#line 1201 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002717{ yyval.Visibility = GlobalValue::HiddenVisibility; ;
2718 break;}
2719case 83:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002720#line 1202 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002721{ yyval.Visibility = GlobalValue::ProtectedVisibility; ;
2722 break;}
2723case 84:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002724#line 1206 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002725{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2726 break;}
2727case 85:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002728#line 1207 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002729{ yyval.Linkage = GlobalValue::DLLImportLinkage; ;
2730 break;}
2731case 86:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002732#line 1208 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002733{ yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;
2734 break;}
2735case 87:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002736#line 1212 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002737{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2738 break;}
2739case 88:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002740#line 1213 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002741{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2742 break;}
2743case 89:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002744#line 1214 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002745{ yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2746 break;}
2747case 90:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002748#line 1215 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002749{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2750 break;}
2751case 91:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002752#line 1216 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002753{ yyval.Linkage = GlobalValue::DLLExportLinkage; ;
2754 break;}
2755case 92:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002756#line 1220 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002757{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2758 break;}
2759case 93:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002760#line 1221 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002761{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2762 break;}
2763case 94:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002764#line 1222 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002765{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2766 break;}
2767case 95:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002768#line 1225 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002769{ yyval.UIntVal = CallingConv::C; ;
2770 break;}
2771case 96:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002772#line 1226 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002773{ yyval.UIntVal = CallingConv::C; ;
2774 break;}
2775case 97:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002776#line 1227 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002777{ yyval.UIntVal = CallingConv::Fast; ;
2778 break;}
2779case 98:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002780#line 1228 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002781{ yyval.UIntVal = CallingConv::Cold; ;
2782 break;}
2783case 99:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002784#line 1229 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002785{ yyval.UIntVal = CallingConv::X86_StdCall; ;
2786 break;}
2787case 100:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002788#line 1230 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002789{ yyval.UIntVal = CallingConv::X86_FastCall; ;
2790 break;}
2791case 101:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002792#line 1231 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002793{
Chris Lattner0275cff2007-08-06 21:00:46 +00002794 if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002795 GEN_ERROR("Calling conv too large");
Chris Lattner0275cff2007-08-06 21:00:46 +00002796 yyval.UIntVal = yyvsp[0].UInt64Val;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002797 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00002798 ;
2799 break;}
2800case 102:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002801#line 1238 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002802{ yyval.ParamAttrs = ParamAttr::ZExt; ;
2803 break;}
2804case 103:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002805#line 1239 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002806{ yyval.ParamAttrs = ParamAttr::ZExt; ;
2807 break;}
2808case 104:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002809#line 1240 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002810{ yyval.ParamAttrs = ParamAttr::SExt; ;
2811 break;}
2812case 105:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002813#line 1241 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002814{ yyval.ParamAttrs = ParamAttr::SExt; ;
2815 break;}
2816case 106:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002817#line 1242 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002818{ yyval.ParamAttrs = ParamAttr::InReg; ;
2819 break;}
2820case 107:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002821#line 1243 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002822{ yyval.ParamAttrs = ParamAttr::StructRet; ;
2823 break;}
2824case 108:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002825#line 1244 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002826{ yyval.ParamAttrs = ParamAttr::NoAlias; ;
2827 break;}
2828case 109:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002829#line 1245 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002830{ yyval.ParamAttrs = ParamAttr::ByVal; ;
2831 break;}
2832case 110:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002833#line 1246 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002834{ yyval.ParamAttrs = ParamAttr::Nest; ;
2835 break;}
2836case 111:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002837#line 1249 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002838{ yyval.ParamAttrs = ParamAttr::None; ;
2839 break;}
2840case 112:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002841#line 1250 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002842{
Chris Lattner0275cff2007-08-06 21:00:46 +00002843 yyval.ParamAttrs = yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs;
Dale Johannesencdd509a2007-09-07 21:07:57 +00002844 ;
2845 break;}
2846case 113:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002847#line 1255 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002848{ yyval.ParamAttrs = ParamAttr::NoReturn; ;
2849 break;}
2850case 114:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002851#line 1256 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002852{ yyval.ParamAttrs = ParamAttr::NoUnwind; ;
2853 break;}
2854case 115:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002855#line 1257 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002856{ yyval.ParamAttrs = ParamAttr::ZExt; ;
2857 break;}
2858case 116:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002859#line 1258 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002860{ yyval.ParamAttrs = ParamAttr::SExt; ;
2861 break;}
2862case 117:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002863#line 1261 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002864{ yyval.ParamAttrs = ParamAttr::None; ;
2865 break;}
2866case 118:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002867#line 1262 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002868{
Chris Lattner0275cff2007-08-06 21:00:46 +00002869 yyval.ParamAttrs = yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs;
Dale Johannesencdd509a2007-09-07 21:07:57 +00002870 ;
2871 break;}
2872case 119:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002873#line 1269 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002874{ yyval.UIntVal = 0; ;
2875 break;}
2876case 120:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002877#line 1270 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002878{
Chris Lattner0275cff2007-08-06 21:00:46 +00002879 yyval.UIntVal = yyvsp[0].UInt64Val;
2880 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002881 GEN_ERROR("Alignment must be a power of two");
2882 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00002883;
2884 break;}
2885case 121:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002886#line 1276 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002887{ yyval.UIntVal = 0; ;
2888 break;}
2889case 122:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002890#line 1277 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002891{
Chris Lattner0275cff2007-08-06 21:00:46 +00002892 yyval.UIntVal = yyvsp[0].UInt64Val;
2893 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002894 GEN_ERROR("Alignment must be a power of two");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002895 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00002896;
2897 break;}
2898case 123:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002899#line 1285 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002900{
Chris Lattner0275cff2007-08-06 21:00:46 +00002901 for (unsigned i = 0, e = yyvsp[0].StrVal->length(); i != e; ++i)
2902 if ((*yyvsp[0].StrVal)[i] == '"' || (*yyvsp[0].StrVal)[i] == '\\')
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002903 GEN_ERROR("Invalid character in section name");
Chris Lattner0275cff2007-08-06 21:00:46 +00002904 yyval.StrVal = yyvsp[0].StrVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002905 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00002906;
2907 break;}
2908case 124:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002909#line 1293 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002910{ yyval.StrVal = 0; ;
2911 break;}
2912case 125:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002913#line 1294 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002914{ yyval.StrVal = yyvsp[0].StrVal; ;
2915 break;}
2916case 126:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002917#line 1299 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002918{;
2919 break;}
2920case 127:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002921#line 1300 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002922{;
2923 break;}
2924case 128:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002925#line 1301 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002926{
Chris Lattner0275cff2007-08-06 21:00:46 +00002927 CurGV->setSection(*yyvsp[0].StrVal);
2928 delete yyvsp[0].StrVal;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002929 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00002930 ;
2931 break;}
2932case 129:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002933#line 1306 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002934{
Chris Lattner0275cff2007-08-06 21:00:46 +00002935 if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002936 GEN_ERROR("Alignment must be a power of two");
Chris Lattner0275cff2007-08-06 21:00:46 +00002937 CurGV->setAlignment(yyvsp[0].UInt64Val);
Reid Spencer41dff5e2007-01-26 08:05:27 +00002938 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00002939 ;
2940 break;}
2941case 137:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002942#line 1322 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002943{
Chris Lattner0275cff2007-08-06 21:00:46 +00002944 yyval.TypeVal = new PATypeHolder(OpaqueType::get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00002945 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00002946 ;
2947 break;}
2948case 138:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002949#line 1326 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002950{
Chris Lattner0275cff2007-08-06 21:00:46 +00002951 yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002952 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00002953 ;
2954 break;}
2955case 139:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002956#line 1330 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002957{ // Pointer type?
Chris Lattner0275cff2007-08-06 21:00:46 +00002958 if (*yyvsp[-1].TypeVal == Type::LabelTy)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002959 GEN_ERROR("Cannot form a pointer to a basic block");
Chris Lattner0275cff2007-08-06 21:00:46 +00002960 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal)));
2961 delete yyvsp[-1].TypeVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00002962 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00002963 ;
2964 break;}
2965case 140:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002966#line 1337 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002967{ // Named types are also simple types...
Chris Lattner0275cff2007-08-06 21:00:46 +00002968 const Type* tmp = getTypeVal(yyvsp[0].ValIDVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00002969 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00002970 yyval.TypeVal = new PATypeHolder(tmp);
Dale Johannesencdd509a2007-09-07 21:07:57 +00002971 ;
2972 break;}
2973case 141:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002974#line 1342 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002975{ // Type UpReference
Chris Lattner0275cff2007-08-06 21:00:46 +00002976 if (yyvsp[0].UInt64Val > (uint64_t)~0U) GEN_ERROR("Value out of range");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002977 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Chris Lattner0275cff2007-08-06 21:00:46 +00002978 UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector...
2979 yyval.TypeVal = new PATypeHolder(OT);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002980 UR_OUT("New Upreference!\n");
2981 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00002982 ;
2983 break;}
2984case 142:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00002985#line 1350 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00002986{
Reid Spencer41dff5e2007-01-26 08:05:27 +00002987 std::vector<const Type*> Params;
Christopher Lamb5c104242007-04-22 20:09:11 +00002988 ParamAttrsVector Attrs;
Chris Lattner0275cff2007-08-06 21:00:46 +00002989 if (yyvsp[0].ParamAttrs != ParamAttr::None) {
2990 ParamAttrsWithIndex X; X.index = 0; X.attrs = yyvsp[0].ParamAttrs;
Christopher Lamb5c104242007-04-22 20:09:11 +00002991 Attrs.push_back(X);
2992 }
Reid Spencer7b5d4662007-04-09 06:16:21 +00002993 unsigned index = 1;
Chris Lattner0275cff2007-08-06 21:00:46 +00002994 TypeWithAttrsList::iterator I = yyvsp[-2].TypeWithAttrsList->begin(), E = yyvsp[-2].TypeWithAttrsList->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00002995 for (; I != E; ++I, ++index) {
Reid Spencer66728ef2007-03-20 01:13:36 +00002996 const Type *Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00002997 Params.push_back(Ty);
2998 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00002999 if (I->Attrs != ParamAttr::None) {
3000 ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs;
3001 Attrs.push_back(X);
3002 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00003003 }
3004 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3005 if (isVarArg) Params.pop_back();
3006
Reid Spencer7b5d4662007-04-09 06:16:21 +00003007 ParamAttrsList *ActualAttrs = 0;
3008 if (!Attrs.empty())
Christopher Lamb5c104242007-04-22 20:09:11 +00003009 ActualAttrs = ParamAttrsList::get(Attrs);
Chris Lattner0275cff2007-08-06 21:00:46 +00003010 FunctionType *FT = FunctionType::get(*yyvsp[-4].TypeVal, Params, isVarArg, ActualAttrs);
3011 delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list
3012 delete yyvsp[-4].TypeVal; // Delete the return type handle
3013 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT));
Reid Spencere4d87aa2006-12-23 06:05:41 +00003014 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003015 ;
3016 break;}
3017case 143:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003018#line 1380 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003019{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003020 std::vector<const Type*> Params;
Christopher Lamb5c104242007-04-22 20:09:11 +00003021 ParamAttrsVector Attrs;
Chris Lattner0275cff2007-08-06 21:00:46 +00003022 if (yyvsp[0].ParamAttrs != ParamAttr::None) {
3023 ParamAttrsWithIndex X; X.index = 0; X.attrs = yyvsp[0].ParamAttrs;
Christopher Lamb5c104242007-04-22 20:09:11 +00003024 Attrs.push_back(X);
3025 }
Chris Lattner0275cff2007-08-06 21:00:46 +00003026 TypeWithAttrsList::iterator I = yyvsp[-2].TypeWithAttrsList->begin(), E = yyvsp[-2].TypeWithAttrsList->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00003027 unsigned index = 1;
3028 for ( ; I != E; ++I, ++index) {
Reid Spencer66728ef2007-03-20 01:13:36 +00003029 const Type* Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00003030 Params.push_back(Ty);
3031 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00003032 if (I->Attrs != ParamAttr::None) {
3033 ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs;
3034 Attrs.push_back(X);
3035 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003036 }
3037 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3038 if (isVarArg) Params.pop_back();
3039
Reid Spencer7b5d4662007-04-09 06:16:21 +00003040 ParamAttrsList *ActualAttrs = 0;
3041 if (!Attrs.empty())
Christopher Lamb5c104242007-04-22 20:09:11 +00003042 ActualAttrs = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00003043
Chris Lattner0275cff2007-08-06 21:00:46 +00003044 FunctionType *FT = FunctionType::get(yyvsp[-4].PrimType, Params, isVarArg, ActualAttrs);
3045 delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list
3046 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003047 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003048 ;
3049 break;}
3050case 144:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003051#line 1411 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003052{ // Sized array type?
Chris Lattner0275cff2007-08-06 21:00:46 +00003053 yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
3054 delete yyvsp[-1].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003055 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003056 ;
3057 break;}
3058case 145:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003059#line 1416 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003060{ // Vector type?
Chris Lattner0275cff2007-08-06 21:00:46 +00003061 const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
3062 if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003063 GEN_ERROR("Unsigned result not equal to signed result");
3064 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
3065 GEN_ERROR("Element type of a VectorType must be primitive");
Chris Lattner0275cff2007-08-06 21:00:46 +00003066 if (!isPowerOf2_32(yyvsp[-3].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003067 GEN_ERROR("Vector length should be a power of 2");
Chris Lattner0275cff2007-08-06 21:00:46 +00003068 yyval.TypeVal = new PATypeHolder(HandleUpRefs(VectorType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
3069 delete yyvsp[-1].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003070 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003071 ;
3072 break;}
3073case 146:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003074#line 1428 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003075{ // Structure type?
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003076 std::vector<const Type*> Elements;
Chris Lattner0275cff2007-08-06 21:00:46 +00003077 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
3078 E = yyvsp[-1].TypeList->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003079 Elements.push_back(*I);
3080
Chris Lattner0275cff2007-08-06 21:00:46 +00003081 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
3082 delete yyvsp[-1].TypeList;
Reid Spencer14310612006-12-31 05:40:51 +00003083 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003084 ;
3085 break;}
3086case 147:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003087#line 1438 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003088{ // Empty structure type?
Chris Lattner0275cff2007-08-06 21:00:46 +00003089 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer14310612006-12-31 05:40:51 +00003090 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003091 ;
3092 break;}
3093case 148:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003094#line 1442 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003095{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003096 std::vector<const Type*> Elements;
Chris Lattner0275cff2007-08-06 21:00:46 +00003097 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-2].TypeList->begin(),
3098 E = yyvsp[-2].TypeList->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003099 Elements.push_back(*I);
3100
Chris Lattner0275cff2007-08-06 21:00:46 +00003101 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
3102 delete yyvsp[-2].TypeList;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003103 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003104 ;
3105 break;}
3106case 149:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003107#line 1452 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003108{ // Empty structure type?
Chris Lattner0275cff2007-08-06 21:00:46 +00003109 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003110 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003111 ;
3112 break;}
3113case 150:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003114#line 1459 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003115{
Chris Lattner0275cff2007-08-06 21:00:46 +00003116 yyval.TypeWithAttrs.Ty = yyvsp[-1].TypeVal;
3117 yyval.TypeWithAttrs.Attrs = yyvsp[0].ParamAttrs;
Dale Johannesencdd509a2007-09-07 21:07:57 +00003118 ;
3119 break;}
3120case 151:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003121#line 1466 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003122{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003123 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003124 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
3125 if (!(*yyvsp[0].TypeVal)->isFirstClassType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003126 GEN_ERROR("LLVM functions cannot return aggregate types");
Chris Lattner0275cff2007-08-06 21:00:46 +00003127 yyval.TypeVal = yyvsp[0].TypeVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00003128 ;
3129 break;}
3130case 152:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003131#line 1473 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003132{
Chris Lattner0275cff2007-08-06 21:00:46 +00003133 yyval.TypeVal = new PATypeHolder(Type::VoidTy);
Dale Johannesencdd509a2007-09-07 21:07:57 +00003134 ;
3135 break;}
3136case 153:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003137#line 1478 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003138{
Chris Lattner0275cff2007-08-06 21:00:46 +00003139 yyval.TypeWithAttrsList = new TypeWithAttrsList();
3140 yyval.TypeWithAttrsList->push_back(yyvsp[0].TypeWithAttrs);
Reid Spencer3da59db2006-11-27 01:05:10 +00003141 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003142 ;
3143 break;}
3144case 154:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003145#line 1483 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003146{
Chris Lattner0275cff2007-08-06 21:00:46 +00003147 (yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList)->push_back(yyvsp[0].TypeWithAttrs);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003148 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003149 ;
3150 break;}
3151case 156:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003152#line 1491 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003153{
Chris Lattner0275cff2007-08-06 21:00:46 +00003154 yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList;
Reid Spencer18da0722007-04-11 02:44:20 +00003155 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003156 TWA.Ty = new PATypeHolder(Type::VoidTy);
Chris Lattner0275cff2007-08-06 21:00:46 +00003157 yyval.TypeWithAttrsList->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003158 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003159 ;
3160 break;}
3161case 157:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003162#line 1498 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003163{
Chris Lattner0275cff2007-08-06 21:00:46 +00003164 yyval.TypeWithAttrsList = new TypeWithAttrsList;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003165 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
3166 TWA.Ty = new PATypeHolder(Type::VoidTy);
Chris Lattner0275cff2007-08-06 21:00:46 +00003167 yyval.TypeWithAttrsList->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003168 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003169 ;
3170 break;}
3171case 158:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003172#line 1505 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003173{
Chris Lattner0275cff2007-08-06 21:00:46 +00003174 yyval.TypeWithAttrsList = new TypeWithAttrsList();
Reid Spencer41dff5e2007-01-26 08:05:27 +00003175 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003176 ;
3177 break;}
3178case 159:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003179#line 1513 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003180{
Chris Lattner0275cff2007-08-06 21:00:46 +00003181 yyval.TypeList = new std::list<PATypeHolder>();
3182 yyval.TypeList->push_back(*yyvsp[0].TypeVal);
3183 delete yyvsp[0].TypeVal;
Reid Spencer3da59db2006-11-27 01:05:10 +00003184 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003185 ;
3186 break;}
3187case 160:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003188#line 1519 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003189{
Chris Lattner0275cff2007-08-06 21:00:46 +00003190 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal);
3191 delete yyvsp[0].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003192 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003193 ;
3194 break;}
3195case 161:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003196#line 1531 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003197{ // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00003198 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003199 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
3200 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003201 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003202 GEN_ERROR("Cannot make array constant with type: '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00003203 (*yyvsp[-3].TypeVal)->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003204 const Type *ETy = ATy->getElementType();
3205 int NumElements = ATy->getNumElements();
3206
3207 // Verify that we have the correct size...
Chris Lattner0275cff2007-08-06 21:00:46 +00003208 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003209 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Chris Lattner0275cff2007-08-06 21:00:46 +00003210 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00003211 itostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003212
3213 // Verify all elements are correct type!
Chris Lattner0275cff2007-08-06 21:00:46 +00003214 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3215 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003216 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3217 ETy->getDescription() +"' as required!\nIt is of type '"+
Chris Lattner0275cff2007-08-06 21:00:46 +00003218 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003219 }
3220
Chris Lattner0275cff2007-08-06 21:00:46 +00003221 yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
3222 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003223 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003224 ;
3225 break;}
3226case 162:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003227#line 1559 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003228{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003229 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003230 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3231 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003232 if (ATy == 0)
3233 GEN_ERROR("Cannot make array constant with type: '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00003234 (*yyvsp[-2].TypeVal)->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003235
Andrew Lenharth6353e052006-12-08 18:07:09 +00003236 int NumElements = ATy->getNumElements();
3237 if (NumElements != -1 && NumElements != 0)
3238 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Reid Spencerb5334b02007-02-05 10:18:06 +00003239 " arguments, but has size of " + itostr(NumElements) +"");
Chris Lattner0275cff2007-08-06 21:00:46 +00003240 yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
3241 delete yyvsp[-2].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00003242 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003243 ;
3244 break;}
3245case 163:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003246#line 1575 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003247{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003248 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003249 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3250 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003251 if (ATy == 0)
3252 GEN_ERROR("Cannot make array constant with type: '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00003253 (*yyvsp[-2].TypeVal)->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003254
3255 int NumElements = ATy->getNumElements();
3256 const Type *ETy = ATy->getElementType();
Chris Lattner0275cff2007-08-06 21:00:46 +00003257 if (NumElements != -1 && NumElements != int(yyvsp[0].StrVal->length()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003258 GEN_ERROR("Can't build string constant of size " +
Chris Lattner0275cff2007-08-06 21:00:46 +00003259 itostr((int)(yyvsp[0].StrVal->length())) +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003260 " when array has size " + itostr(NumElements) + "");
3261 std::vector<Constant*> Vals;
3262 if (ETy == Type::Int8Ty) {
Chris Lattner0275cff2007-08-06 21:00:46 +00003263 for (unsigned i = 0; i < yyvsp[0].StrVal->length(); ++i)
3264 Vals.push_back(ConstantInt::get(ETy, (*yyvsp[0].StrVal)[i]));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003265 } else {
Chris Lattner0275cff2007-08-06 21:00:46 +00003266 delete yyvsp[0].StrVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003267 GEN_ERROR("Cannot build string arrays of non byte sized elements");
3268 }
Chris Lattner0275cff2007-08-06 21:00:46 +00003269 delete yyvsp[0].StrVal;
3270 yyval.ConstVal = ConstantArray::get(ATy, Vals);
3271 delete yyvsp[-2].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003272 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003273 ;
3274 break;}
3275case 164:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003276#line 1602 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003277{ // Nonempty unsized arr
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003278 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003279 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
3280 const VectorType *PTy = dyn_cast<VectorType>(yyvsp[-3].TypeVal->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003281 if (PTy == 0)
3282 GEN_ERROR("Cannot make packed constant with type: '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00003283 (*yyvsp[-3].TypeVal)->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003284 const Type *ETy = PTy->getElementType();
3285 int NumElements = PTy->getNumElements();
Reid Spencer41dff5e2007-01-26 08:05:27 +00003286
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003287 // Verify that we have the correct size...
Chris Lattner0275cff2007-08-06 21:00:46 +00003288 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003289 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Chris Lattner0275cff2007-08-06 21:00:46 +00003290 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00003291 itostr(NumElements) + "");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003292
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003293 // Verify all elements are correct type!
Chris Lattner0275cff2007-08-06 21:00:46 +00003294 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3295 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003296 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3297 ETy->getDescription() +"' as required!\nIt is of type '"+
Chris Lattner0275cff2007-08-06 21:00:46 +00003298 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003299 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00003300
Chris Lattner0275cff2007-08-06 21:00:46 +00003301 yyval.ConstVal = ConstantVector::get(PTy, *yyvsp[-1].ConstVector);
3302 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003303 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003304 ;
3305 break;}
3306case 165:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003307#line 1630 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003308{
Chris Lattner0275cff2007-08-06 21:00:46 +00003309 const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003310 if (STy == 0)
3311 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00003312 (*yyvsp[-3].TypeVal)->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003313
Chris Lattner0275cff2007-08-06 21:00:46 +00003314 if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003315 GEN_ERROR("Illegal number of initializers for structure type");
3316
3317 // Check to ensure that constants are compatible with the type initializer!
Chris Lattner0275cff2007-08-06 21:00:46 +00003318 for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
3319 if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003320 GEN_ERROR("Expected type '" +
3321 STy->getElementType(i)->getDescription() +
3322 "' for element #" + utostr(i) +
3323 " of structure initializer");
3324
3325 // Check to ensure that Type is not packed
3326 if (STy->isPacked())
3327 GEN_ERROR("Unpacked Initializer to vector type '" +
3328 STy->getDescription() + "'");
3329
Chris Lattner0275cff2007-08-06 21:00:46 +00003330 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
3331 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003332 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003333 ;
3334 break;}
3335case 166:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003336#line 1656 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003337{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003338 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003339 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3340 const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003341 if (STy == 0)
3342 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00003343 (*yyvsp[-2].TypeVal)->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003344
3345 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003346 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003347
3348 // Check to ensure that Type is not packed
3349 if (STy->isPacked())
Chris Lattner6cdc6822007-04-26 05:31:05 +00003350 GEN_ERROR("Unpacked Initializer to vector type '" +
3351 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003352
Chris Lattner0275cff2007-08-06 21:00:46 +00003353 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
3354 delete yyvsp[-2].TypeVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003355 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003356 ;
3357 break;}
3358case 167:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003359#line 1676 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003360{
Chris Lattner0275cff2007-08-06 21:00:46 +00003361 const StructType *STy = dyn_cast<StructType>(yyvsp[-5].TypeVal->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003362 if (STy == 0)
3363 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00003364 (*yyvsp[-5].TypeVal)->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003365
Chris Lattner0275cff2007-08-06 21:00:46 +00003366 if (yyvsp[-2].ConstVector->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00003367 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003368
3369 // Check to ensure that constants are compatible with the type initializer!
Chris Lattner0275cff2007-08-06 21:00:46 +00003370 for (unsigned i = 0, e = yyvsp[-2].ConstVector->size(); i != e; ++i)
3371 if ((*yyvsp[-2].ConstVector)[i]->getType() != STy->getElementType(i))
Reid Spencer41dff5e2007-01-26 08:05:27 +00003372 GEN_ERROR("Expected type '" +
3373 STy->getElementType(i)->getDescription() +
3374 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00003375 " of structure initializer");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003376
3377 // Check to ensure that Type is packed
3378 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00003379 GEN_ERROR("Vector initializer to non-vector type '" +
3380 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003381
Chris Lattner0275cff2007-08-06 21:00:46 +00003382 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-2].ConstVector);
3383 delete yyvsp[-5].TypeVal; delete yyvsp[-2].ConstVector;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003384 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003385 ;
3386 break;}
3387case 168:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003388#line 1702 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003389{
Reid Spencer41dff5e2007-01-26 08:05:27 +00003390 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003391 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
3392 const StructType *STy = dyn_cast<StructType>(yyvsp[-4].TypeVal->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003393 if (STy == 0)
3394 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00003395 (*yyvsp[-4].TypeVal)->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003396
3397 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003398 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003399
3400 // Check to ensure that Type is packed
3401 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00003402 GEN_ERROR("Vector initializer to non-vector type '" +
3403 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003404
Chris Lattner0275cff2007-08-06 21:00:46 +00003405 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
3406 delete yyvsp[-4].TypeVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003407 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003408 ;
3409 break;}
3410case 169:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003411#line 1722 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003412{
Reid Spencer41dff5e2007-01-26 08:05:27 +00003413 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003414 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3415 const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003416 if (PTy == 0)
3417 GEN_ERROR("Cannot make null pointer constant with type: '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00003418 (*yyvsp[-1].TypeVal)->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003419
Chris Lattner0275cff2007-08-06 21:00:46 +00003420 yyval.ConstVal = ConstantPointerNull::get(PTy);
3421 delete yyvsp[-1].TypeVal;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003422 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003423 ;
3424 break;}
3425case 170:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003426#line 1734 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003427{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003428 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003429 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3430 yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
3431 delete yyvsp[-1].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003432 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003433 ;
3434 break;}
3435case 171:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003436#line 1741 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003437{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003438 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003439 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3440 const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003441 if (Ty == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003442 GEN_ERROR("Global const reference must be a pointer type");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003443
3444 // ConstExprs can exist in the body of a function, thus creating
3445 // GlobalValues whenever they refer to a variable. Because we are in
Reid Spencer93c40032007-03-19 18:40:50 +00003446 // the context of a function, getExistingVal will search the functions
Reid Spencer68a24bd2005-08-27 18:50:39 +00003447 // symbol table instead of the module symbol table for the global symbol,
3448 // which throws things all off. To get around this, we just tell
Reid Spencer93c40032007-03-19 18:40:50 +00003449 // getExistingVal that we are at global scope here.
Reid Spencer68a24bd2005-08-27 18:50:39 +00003450 //
3451 Function *SavedCurFn = CurFun.CurrentFunction;
3452 CurFun.CurrentFunction = 0;
3453
Chris Lattner0275cff2007-08-06 21:00:46 +00003454 Value *V = getExistingVal(Ty, yyvsp[0].ValIDVal);
Reid Spencer5b7e7532006-09-28 19:28:24 +00003455 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003456
3457 CurFun.CurrentFunction = SavedCurFn;
3458
3459 // If this is an initializer for a constant pointer, which is referencing a
3460 // (currently) undefined variable, create a stub now that shall be replaced
3461 // in the future with the right type of variable.
3462 //
3463 if (V == 0) {
Reid Spencera9720f52007-02-05 17:04:00 +00003464 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003465 const PointerType *PT = cast<PointerType>(Ty);
3466
3467 // First check to see if the forward references value is already created!
3468 PerModuleInfo::GlobalRefsType::iterator I =
Chris Lattner0275cff2007-08-06 21:00:46 +00003469 CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003470
3471 if (I != CurModule.GlobalRefs.end()) {
3472 V = I->second; // Placeholder already exists, use it...
Chris Lattner0275cff2007-08-06 21:00:46 +00003473 yyvsp[0].ValIDVal.destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003474 } else {
3475 std::string Name;
Chris Lattner0275cff2007-08-06 21:00:46 +00003476 if (yyvsp[0].ValIDVal.Type == ValID::GlobalName)
3477 Name = yyvsp[0].ValIDVal.getName();
3478 else if (yyvsp[0].ValIDVal.Type != ValID::GlobalID)
Reid Spencer41dff5e2007-01-26 08:05:27 +00003479 GEN_ERROR("Invalid reference to global");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003480
3481 // Create the forward referenced global.
3482 GlobalValue *GV;
3483 if (const FunctionType *FTy =
3484 dyn_cast<FunctionType>(PT->getElementType())) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00003485 GV = new Function(FTy, GlobalValue::ExternalWeakLinkage, Name,
Reid Spencer68a24bd2005-08-27 18:50:39 +00003486 CurModule.CurrentModule);
3487 } else {
3488 GV = new GlobalVariable(PT->getElementType(), false,
Chris Lattner6cdc6822007-04-26 05:31:05 +00003489 GlobalValue::ExternalWeakLinkage, 0,
Reid Spencer68a24bd2005-08-27 18:50:39 +00003490 Name, CurModule.CurrentModule);
3491 }
3492
3493 // Keep track of the fact that we have a forward ref to recycle it
Chris Lattner0275cff2007-08-06 21:00:46 +00003494 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003495 V = GV;
3496 }
3497 }
3498
Chris Lattner0275cff2007-08-06 21:00:46 +00003499 yyval.ConstVal = cast<GlobalValue>(V);
3500 delete yyvsp[-1].TypeVal; // Free the type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00003501 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003502 ;
3503 break;}
3504case 172:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003505#line 1807 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003506{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003507 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003508 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3509 if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003510 GEN_ERROR("Mismatched types for constant expression: " +
Chris Lattner0275cff2007-08-06 21:00:46 +00003511 (*yyvsp[-1].TypeVal)->getDescription() + " and " + yyvsp[0].ConstVal->getType()->getDescription());
3512 yyval.ConstVal = yyvsp[0].ConstVal;
3513 delete yyvsp[-1].TypeVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003514 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003515 ;
3516 break;}
3517case 173:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003518#line 1817 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003519{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003520 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003521 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3522 const Type *Ty = yyvsp[-1].TypeVal->get();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003523 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
3524 GEN_ERROR("Cannot create a null initialized value of this type");
Chris Lattner0275cff2007-08-06 21:00:46 +00003525 yyval.ConstVal = Constant::getNullValue(Ty);
3526 delete yyvsp[-1].TypeVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003527 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003528 ;
3529 break;}
3530case 174:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003531#line 1827 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003532{ // integral constants
Chris Lattner0275cff2007-08-06 21:00:46 +00003533 if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003534 GEN_ERROR("Constant value doesn't fit in type");
Chris Lattner0275cff2007-08-06 21:00:46 +00003535 yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val, true);
Reid Spencer38c91a92007-02-28 02:24:54 +00003536 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003537 ;
3538 break;}
3539case 175:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003540#line 1833 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003541{ // arbitrary precision integer constants
Chris Lattner0275cff2007-08-06 21:00:46 +00003542 uint32_t BitWidth = cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth();
3543 if (yyvsp[0].APIntVal->getBitWidth() > BitWidth) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003544 GEN_ERROR("Constant value does not fit in type");
3545 }
Chris Lattner0275cff2007-08-06 21:00:46 +00003546 yyvsp[0].APIntVal->sextOrTrunc(BitWidth);
3547 yyval.ConstVal = ConstantInt::get(*yyvsp[0].APIntVal);
3548 delete yyvsp[0].APIntVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003549 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003550 ;
3551 break;}
3552case 176:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003553#line 1843 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003554{ // integral constants
Chris Lattner0275cff2007-08-06 21:00:46 +00003555 if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003556 GEN_ERROR("Constant value doesn't fit in type");
Chris Lattner0275cff2007-08-06 21:00:46 +00003557 yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val, false);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003558 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003559 ;
3560 break;}
3561case 177:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003562#line 1849 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003563{ // arbitrary precision integer constants
Chris Lattner0275cff2007-08-06 21:00:46 +00003564 uint32_t BitWidth = cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth();
3565 if (yyvsp[0].APIntVal->getBitWidth() > BitWidth) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003566 GEN_ERROR("Constant value does not fit in type");
3567 }
Chris Lattner0275cff2007-08-06 21:00:46 +00003568 yyvsp[0].APIntVal->zextOrTrunc(BitWidth);
3569 yyval.ConstVal = ConstantInt::get(*yyvsp[0].APIntVal);
3570 delete yyvsp[0].APIntVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003571 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003572 ;
3573 break;}
3574case 178:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003575#line 1859 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003576{ // Boolean constants
Chris Lattner0275cff2007-08-06 21:00:46 +00003577 assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?");
3578 yyval.ConstVal = ConstantInt::getTrue();
Reid Spencer38c91a92007-02-28 02:24:54 +00003579 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003580 ;
3581 break;}
3582case 179:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003583#line 1864 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003584{ // Boolean constants
Chris Lattner0275cff2007-08-06 21:00:46 +00003585 assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?");
3586 yyval.ConstVal = ConstantInt::getFalse();
Reid Spencer6f407902007-01-13 05:00:46 +00003587 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003588 ;
3589 break;}
3590case 180:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003591#line 1869 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003592{ // Float & Double constants
3593 if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, *yyvsp[0].FPVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003594 GEN_ERROR("Floating point constant invalid for type");
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003595 // Lexer has no type info, so builds all float and double FP constants
3596 // as double. Fix this here. Long double is done right.
3597 if (&yyvsp[0].FPVal->getSemantics()==&APFloat::IEEEdouble && yyvsp[-1].PrimType==Type::FloatTy)
Dale Johannesencdd509a2007-09-07 21:07:57 +00003598 yyvsp[0].FPVal->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
3599 yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, *yyvsp[0].FPVal);
3600 delete yyvsp[0].FPVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003601 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003602 ;
3603 break;}
3604case 181:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003605#line 1882 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003606{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003607 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003608 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3609 Constant *Val = yyvsp[-3].ConstVal;
3610 const Type *DestTy = yyvsp[-1].TypeVal->get();
3611 if (!CastInst::castIsValid(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003612 GEN_ERROR("invalid cast opcode for cast from '" +
3613 Val->getType()->getDescription() + "' to '" +
3614 DestTy->getDescription() + "'");
Chris Lattner0275cff2007-08-06 21:00:46 +00003615 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy);
3616 delete yyvsp[-1].TypeVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00003617 ;
3618 break;}
3619case 182:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003620#line 1894 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003621{
Chris Lattner0275cff2007-08-06 21:00:46 +00003622 if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
Reid Spencerb5334b02007-02-05 10:18:06 +00003623 GEN_ERROR("GetElementPtr requires a pointer operand");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003624
3625 const Type *IdxTy =
David Greene5fd22a82007-09-04 18:46:50 +00003626 GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end(),
Chris Lattner7d9801d2007-02-13 00:58:01 +00003627 true);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003628 if (!IdxTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00003629 GEN_ERROR("Index list invalid for constant getelementptr");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003630
Chris Lattnerf7469af2007-01-31 04:44:08 +00003631 SmallVector<Constant*, 8> IdxVec;
Chris Lattner0275cff2007-08-06 21:00:46 +00003632 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
3633 if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003634 IdxVec.push_back(C);
3635 else
Reid Spencerb5334b02007-02-05 10:18:06 +00003636 GEN_ERROR("Indices to constant getelementptr must be constants");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003637
Chris Lattner0275cff2007-08-06 21:00:46 +00003638 delete yyvsp[-1].ValueList;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003639
Chris Lattner0275cff2007-08-06 21:00:46 +00003640 yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, &IdxVec[0], IdxVec.size());
Andrew Lenharth6353e052006-12-08 18:07:09 +00003641 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003642 ;
3643 break;}
3644case 183:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003645#line 1916 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003646{
Chris Lattner0275cff2007-08-06 21:00:46 +00003647 if (yyvsp[-5].ConstVal->getType() != Type::Int1Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003648 GEN_ERROR("Select condition must be of boolean type");
Chris Lattner0275cff2007-08-06 21:00:46 +00003649 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003650 GEN_ERROR("Select operand types must match");
Chris Lattner0275cff2007-08-06 21:00:46 +00003651 yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003652 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003653 ;
3654 break;}
3655case 184:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003656#line 1924 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003657{
Chris Lattner0275cff2007-08-06 21:00:46 +00003658 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003659 GEN_ERROR("Binary operator types must match");
3660 CHECK_FOR_ERROR;
Chris Lattner0275cff2007-08-06 21:00:46 +00003661 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Dale Johannesencdd509a2007-09-07 21:07:57 +00003662 ;
3663 break;}
3664case 185:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003665#line 1930 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003666{
Chris Lattner0275cff2007-08-06 21:00:46 +00003667 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003668 GEN_ERROR("Logical operator types must match");
Chris Lattner0275cff2007-08-06 21:00:46 +00003669 if (!yyvsp[-3].ConstVal->getType()->isInteger()) {
3670 if (Instruction::isShift(yyvsp[-5].BinaryOpVal) || !isa<VectorType>(yyvsp[-3].ConstVal->getType()) ||
3671 !cast<VectorType>(yyvsp[-3].ConstVal->getType())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003672 GEN_ERROR("Logical operator requires integral operands");
3673 }
Chris Lattner0275cff2007-08-06 21:00:46 +00003674 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003675 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003676 ;
3677 break;}
3678case 186:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003679#line 1941 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003680{
Chris Lattner0275cff2007-08-06 21:00:46 +00003681 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003682 GEN_ERROR("icmp operand types must match");
Chris Lattner0275cff2007-08-06 21:00:46 +00003683 yyval.ConstVal = ConstantExpr::getICmp(yyvsp[-5].IPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Dale Johannesencdd509a2007-09-07 21:07:57 +00003684 ;
3685 break;}
3686case 187:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003687#line 1946 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003688{
Chris Lattner0275cff2007-08-06 21:00:46 +00003689 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003690 GEN_ERROR("fcmp operand types must match");
Chris Lattner0275cff2007-08-06 21:00:46 +00003691 yyval.ConstVal = ConstantExpr::getFCmp(yyvsp[-5].FPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Dale Johannesencdd509a2007-09-07 21:07:57 +00003692 ;
3693 break;}
3694case 188:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003695#line 1951 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003696{
Chris Lattner0275cff2007-08-06 21:00:46 +00003697 if (!ExtractElementInst::isValidOperands(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003698 GEN_ERROR("Invalid extractelement operands");
Chris Lattner0275cff2007-08-06 21:00:46 +00003699 yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003700 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003701 ;
3702 break;}
3703case 189:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003704#line 1957 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003705{
Chris Lattner0275cff2007-08-06 21:00:46 +00003706 if (!InsertElementInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003707 GEN_ERROR("Invalid insertelement operands");
Chris Lattner0275cff2007-08-06 21:00:46 +00003708 yyval.ConstVal = ConstantExpr::getInsertElement(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003709 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003710 ;
3711 break;}
3712case 190:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003713#line 1963 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003714{
Chris Lattner0275cff2007-08-06 21:00:46 +00003715 if (!ShuffleVectorInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003716 GEN_ERROR("Invalid shufflevector operands");
Chris Lattner0275cff2007-08-06 21:00:46 +00003717 yyval.ConstVal = ConstantExpr::getShuffleVector(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003718 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003719 ;
3720 break;}
3721case 191:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003722#line 1972 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003723{
Chris Lattner0275cff2007-08-06 21:00:46 +00003724 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003725 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003726 ;
3727 break;}
3728case 192:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003729#line 1976 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003730{
Chris Lattner0275cff2007-08-06 21:00:46 +00003731 yyval.ConstVector = new std::vector<Constant*>();
3732 yyval.ConstVector->push_back(yyvsp[0].ConstVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003733 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003734 ;
3735 break;}
3736case 193:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003737#line 1984 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003738{ yyval.BoolVal = false; ;
3739 break;}
3740case 194:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003741#line 1984 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003742{ yyval.BoolVal = true; ;
3743 break;}
3744case 195:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003745#line 1987 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003746{ yyval.BoolVal = true; ;
3747 break;}
3748case 196:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003749#line 1987 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003750{ yyval.BoolVal = false; ;
3751 break;}
3752case 197:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003753#line 1990 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003754{
Chris Lattner0275cff2007-08-06 21:00:46 +00003755 const Type* VTy = yyvsp[-1].TypeVal->get();
3756 Value *V = getVal(VTy, yyvsp[0].ValIDVal);
3757 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003758 GlobalValue* Aliasee = dyn_cast<GlobalValue>(V);
3759 if (!Aliasee)
3760 GEN_ERROR("Aliases can be created only to global values");
3761
Chris Lattner0275cff2007-08-06 21:00:46 +00003762 yyval.ConstVal = Aliasee;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003763 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003764 delete yyvsp[-1].TypeVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00003765 ;
3766 break;}
3767case 198:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003768#line 2002 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003769{
Chris Lattner0275cff2007-08-06 21:00:46 +00003770 Constant *Val = yyvsp[-3].ConstVal;
3771 const Type *DestTy = yyvsp[-1].TypeVal->get();
3772 if (!CastInst::castIsValid(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy))
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003773 GEN_ERROR("invalid cast opcode for cast from '" +
3774 Val->getType()->getDescription() + "' to '" +
3775 DestTy->getDescription() + "'");
3776
Chris Lattner0275cff2007-08-06 21:00:46 +00003777 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003778 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003779 delete yyvsp[-1].TypeVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00003780 ;
3781 break;}
3782case 199:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003783#line 2023 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003784{
Chris Lattner0275cff2007-08-06 21:00:46 +00003785 yyval.ModuleVal = ParserResult = CurModule.CurrentModule;
Reid Spencer1013b4d2007-07-31 14:41:17 +00003786 CurModule.ModuleDone();
3787 CHECK_FOR_ERROR;
Dale Johannesencdd509a2007-09-07 21:07:57 +00003788 ;
3789 break;}
3790case 200:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003791#line 2028 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003792{
Chris Lattner0275cff2007-08-06 21:00:46 +00003793 yyval.ModuleVal = ParserResult = CurModule.CurrentModule;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003794 CurModule.ModuleDone();
3795 CHECK_FOR_ERROR;
Dale Johannesencdd509a2007-09-07 21:07:57 +00003796 ;
3797 break;}
3798case 203:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003799#line 2041 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003800{ CurFun.isDeclare = false; ;
3801 break;}
3802case 204:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003803#line 2041 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003804{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003805 CurFun.FunctionDone();
3806 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003807 ;
3808 break;}
3809case 205:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003810#line 2045 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003811{ CurFun.isDeclare = true; ;
3812 break;}
3813case 206:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003814#line 2045 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003815{
Reid Spencer1013b4d2007-07-31 14:41:17 +00003816 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003817 ;
3818 break;}
3819case 207:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003820#line 2048 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003821{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003822 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003823 ;
3824 break;}
3825case 208:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003826#line 2051 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003827{
Reid Spencer14310612006-12-31 05:40:51 +00003828 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003829 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003830 // Eagerly resolve types. This is not an optimization, this is a
3831 // requirement that is due to the fact that we could have this:
3832 //
3833 // %list = type { %list * }
3834 // %list = type { %list * } ; repeated type decl
3835 //
3836 // If types are not resolved eagerly, then the two types will not be
3837 // determined to be the same type!
3838 //
Chris Lattner0275cff2007-08-06 21:00:46 +00003839 ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003840
Chris Lattner0275cff2007-08-06 21:00:46 +00003841 if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00003842 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003843 // If this is a named type that is not a redefinition, add it to the slot
3844 // table.
Chris Lattner0275cff2007-08-06 21:00:46 +00003845 CurModule.Types.push_back(*yyvsp[0].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003846 }
Reid Spencera132e042006-12-03 05:46:11 +00003847
Chris Lattner0275cff2007-08-06 21:00:46 +00003848 delete yyvsp[0].TypeVal;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003849 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003850 ;
3851 break;}
3852case 209:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003853#line 2075 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003854{
Chris Lattner0275cff2007-08-06 21:00:46 +00003855 ResolveTypeTo(yyvsp[-2].StrVal, yyvsp[0].PrimType);
Reid Spencerb8f85052007-07-31 03:50:36 +00003856
Chris Lattner0275cff2007-08-06 21:00:46 +00003857 if (!setTypeName(yyvsp[0].PrimType, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003858 CHECK_FOR_ERROR
3859 // If this is a named type that is not a redefinition, add it to the slot
3860 // table.
Chris Lattner0275cff2007-08-06 21:00:46 +00003861 CurModule.Types.push_back(yyvsp[0].PrimType);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003862 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003863 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003864 ;
3865 break;}
3866case 210:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003867#line 2086 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003868{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003869 /* "Externally Visible" Linkage */
Chris Lattner0275cff2007-08-06 21:00:46 +00003870 if (yyvsp[0].ConstVal == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003871 GEN_ERROR("Global value initializer is not a constant");
Chris Lattner0275cff2007-08-06 21:00:46 +00003872 CurGV = ParseGlobalVariable(yyvsp[-4].StrVal, GlobalValue::ExternalLinkage,
3873 yyvsp[-3].Visibility, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal, yyvsp[-2].BoolVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003874 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003875 ;
3876 break;}
3877case 211:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003878#line 2093 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003879{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003880 CurGV = 0;
Dale Johannesencdd509a2007-09-07 21:07:57 +00003881 ;
3882 break;}
3883case 212:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003884#line 2097 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003885{
Chris Lattner0275cff2007-08-06 21:00:46 +00003886 if (yyvsp[0].ConstVal == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003887 GEN_ERROR("Global value initializer is not a constant");
Chris Lattner0275cff2007-08-06 21:00:46 +00003888 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 +00003889 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003890 ;
3891 break;}
3892case 213:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003893#line 2102 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003894{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003895 CurGV = 0;
Dale Johannesencdd509a2007-09-07 21:07:57 +00003896 ;
3897 break;}
3898case 214:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003899#line 2106 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003900{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003901 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003902 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
3903 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 +00003904 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003905 delete yyvsp[0].TypeVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00003906 ;
3907 break;}
3908case 215:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003909#line 2112 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003910{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003911 CurGV = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003912 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003913 ;
3914 break;}
3915case 216:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003916#line 2116 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003917{
Reid Spencer0a8a16b2007-05-22 18:52:55 +00003918 std::string Name;
Chris Lattner0275cff2007-08-06 21:00:46 +00003919 if (yyvsp[-4].StrVal) {
3920 Name = *yyvsp[-4].StrVal;
3921 delete yyvsp[-4].StrVal;
Reid Spencer0a8a16b2007-05-22 18:52:55 +00003922 }
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003923 if (Name.empty())
3924 GEN_ERROR("Alias name cannot be empty");
3925
Chris Lattner0275cff2007-08-06 21:00:46 +00003926 Constant* Aliasee = yyvsp[0].ConstVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003927 if (Aliasee == 0)
Reid Spencer0a8a16b2007-05-22 18:52:55 +00003928 GEN_ERROR(std::string("Invalid aliasee for alias: ") + Name);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003929
Chris Lattner0275cff2007-08-06 21:00:46 +00003930 GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), yyvsp[-1].Linkage, Name, Aliasee,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003931 CurModule.CurrentModule);
Chris Lattner0275cff2007-08-06 21:00:46 +00003932 GA->setVisibility(yyvsp[-3].Visibility);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003933 InsertValue(GA, CurModule.Values);
Chris Lattner569f7372007-09-10 23:24:14 +00003934
3935
3936 // If there was a forward reference of this alias, resolve it now.
3937
3938 ValID ID;
3939 if (!Name.empty())
3940 ID = ValID::createGlobalName(Name);
3941 else
3942 ID = ValID::createGlobalID(CurModule.Values.size()-1);
3943
3944 if (GlobalValue *FWGV =
3945 CurModule.GetForwardRefForGlobal(GA->getType(), ID)) {
3946 // Replace uses of the fwdref with the actual alias.
3947 FWGV->replaceAllUsesWith(GA);
3948 if (GlobalVariable *GV = dyn_cast<GlobalVariable>(FWGV))
3949 GV->eraseFromParent();
3950 else
3951 cast<Function>(FWGV)->eraseFromParent();
3952 }
3953 ID.destroy();
3954
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003955 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003956 ;
3957 break;}
3958case 217:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003959#line 2156 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003960{
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003961 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003962 ;
3963 break;}
3964case 218:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003965#line 2159 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003966{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003967 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003968 ;
3969 break;}
3970case 219:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003971#line 2165 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003972{
Chris Lattner66316012006-01-24 04:14:29 +00003973 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Chris Lattner66316012006-01-24 04:14:29 +00003974 if (AsmSoFar.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003975 CurModule.CurrentModule->setModuleInlineAsm(*yyvsp[0].StrVal);
Chris Lattner66316012006-01-24 04:14:29 +00003976 else
Chris Lattner0275cff2007-08-06 21:00:46 +00003977 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+*yyvsp[0].StrVal);
3978 delete yyvsp[0].StrVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00003979 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00003980;
3981 break;}
3982case 220:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003983#line 2175 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003984{
Chris Lattner0275cff2007-08-06 21:00:46 +00003985 CurModule.CurrentModule->setTargetTriple(*yyvsp[0].StrVal);
3986 delete yyvsp[0].StrVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00003987 ;
3988 break;}
3989case 221:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003990#line 2179 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003991{
Chris Lattner0275cff2007-08-06 21:00:46 +00003992 CurModule.CurrentModule->setDataLayout(*yyvsp[0].StrVal);
3993 delete yyvsp[0].StrVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00003994 ;
3995 break;}
3996case 223:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003997#line 2186 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00003998{
Chris Lattner0275cff2007-08-06 21:00:46 +00003999 CurModule.CurrentModule->addLibrary(*yyvsp[0].StrVal);
4000 delete yyvsp[0].StrVal;
Reid Spencer1013b4d2007-07-31 14:41:17 +00004001 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004002 ;
4003 break;}
4004case 224:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004005#line 2191 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004006{
Chris Lattner0275cff2007-08-06 21:00:46 +00004007 CurModule.CurrentModule->addLibrary(*yyvsp[0].StrVal);
4008 delete yyvsp[0].StrVal;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004009 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004010 ;
4011 break;}
4012case 225:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004013#line 2196 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004014{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004015 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004016 ;
4017 break;}
4018case 226:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004019#line 2205 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004020{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004021 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004022 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4023 if (*yyvsp[-2].TypeVal == Type::VoidTy)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004024 GEN_ERROR("void typed arguments are invalid");
Chris Lattner0275cff2007-08-06 21:00:46 +00004025 ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal;
4026 yyval.ArgList = yyvsp[-4].ArgList;
4027 yyvsp[-4].ArgList->push_back(E);
Reid Spencer6f407902007-01-13 05:00:46 +00004028 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004029 ;
4030 break;}
4031case 227:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004032#line 2215 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004033{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004034 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004035 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4036 if (*yyvsp[-2].TypeVal == Type::VoidTy)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004037 GEN_ERROR("void typed arguments are invalid");
Chris Lattner0275cff2007-08-06 21:00:46 +00004038 ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal;
4039 yyval.ArgList = new ArgListType;
4040 yyval.ArgList->push_back(E);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004041 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004042 ;
4043 break;}
4044case 228:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004045#line 2226 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004046{
Chris Lattner0275cff2007-08-06 21:00:46 +00004047 yyval.ArgList = yyvsp[0].ArgList;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004048 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004049 ;
4050 break;}
4051case 229:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004052#line 2230 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004053{
Chris Lattner0275cff2007-08-06 21:00:46 +00004054 yyval.ArgList = yyvsp[-2].ArgList;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004055 struct ArgListEntry E;
4056 E.Ty = new PATypeHolder(Type::VoidTy);
4057 E.Name = 0;
Reid Spencer18da0722007-04-11 02:44:20 +00004058 E.Attrs = ParamAttr::None;
Chris Lattner0275cff2007-08-06 21:00:46 +00004059 yyval.ArgList->push_back(E);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004060 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004061 ;
4062 break;}
4063case 230:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004064#line 2239 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004065{
Chris Lattner0275cff2007-08-06 21:00:46 +00004066 yyval.ArgList = new ArgListType;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004067 struct ArgListEntry E;
4068 E.Ty = new PATypeHolder(Type::VoidTy);
4069 E.Name = 0;
4070 E.Attrs = ParamAttr::None;
Chris Lattner0275cff2007-08-06 21:00:46 +00004071 yyval.ArgList->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00004072 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004073 ;
4074 break;}
4075case 231:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004076#line 2248 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004077{
Chris Lattner0275cff2007-08-06 21:00:46 +00004078 yyval.ArgList = 0;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004079 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004080 ;
4081 break;}
4082case 232:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004083#line 2254 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004084{
Chris Lattner0275cff2007-08-06 21:00:46 +00004085 std::string FunctionName(*yyvsp[-6].StrVal);
4086 delete yyvsp[-6].StrVal; // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004087
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004088 // Check the function result for abstractness if this is a define. We should
4089 // have no abstract types at this point
Chris Lattner0275cff2007-08-06 21:00:46 +00004090 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(yyvsp[-7].TypeVal))
4091 GEN_ERROR("Reference to abstract result: "+ yyvsp[-7].TypeVal->get()->getDescription());
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004092
Reid Spencer68a24bd2005-08-27 18:50:39 +00004093 std::vector<const Type*> ParamTypeList;
Christopher Lamb5c104242007-04-22 20:09:11 +00004094 ParamAttrsVector Attrs;
Chris Lattner0275cff2007-08-06 21:00:46 +00004095 if (yyvsp[-2].ParamAttrs != ParamAttr::None) {
4096 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[-2].ParamAttrs;
Christopher Lamb5c104242007-04-22 20:09:11 +00004097 Attrs.push_back(PAWI);
4098 }
Chris Lattner0275cff2007-08-06 21:00:46 +00004099 if (yyvsp[-4].ArgList) { // If there are arguments...
Reid Spencer7b5d4662007-04-09 06:16:21 +00004100 unsigned index = 1;
Chris Lattner0275cff2007-08-06 21:00:46 +00004101 for (ArgListType::iterator I = yyvsp[-4].ArgList->begin(); I != yyvsp[-4].ArgList->end(); ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00004102 const Type* Ty = I->Ty->get();
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004103 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
4104 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00004105 ParamTypeList.push_back(Ty);
4106 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00004107 if (I->Attrs != ParamAttr::None) {
4108 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
4109 Attrs.push_back(PAWI);
4110 }
Reid Spencer14310612006-12-31 05:40:51 +00004111 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004112 }
4113
4114 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
4115 if (isVarArg) ParamTypeList.pop_back();
4116
Christopher Lamb5c104242007-04-22 20:09:11 +00004117 ParamAttrsList *PAL = 0;
4118 if (!Attrs.empty())
4119 PAL = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00004120
Chris Lattner0275cff2007-08-06 21:00:46 +00004121 FunctionType *FT = FunctionType::get(*yyvsp[-7].TypeVal, ParamTypeList, isVarArg, PAL);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004122 const PointerType *PFT = PointerType::get(FT);
Chris Lattner0275cff2007-08-06 21:00:46 +00004123 delete yyvsp[-7].TypeVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004124
4125 ValID ID;
4126 if (!FunctionName.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004127 ID = ValID::createGlobalName((char*)FunctionName.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004128 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00004129 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004130 }
4131
4132 Function *Fn = 0;
4133 // See if this function was forward referenced. If so, recycle the object.
4134 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4135 // Move the function to the end of the list, from whereever it was
4136 // previously inserted.
4137 Fn = cast<Function>(FWRef);
4138 CurModule.CurrentModule->getFunctionList().remove(Fn);
4139 CurModule.CurrentModule->getFunctionList().push_back(Fn);
4140 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
Reid Spenceref9b9a72007-02-05 20:47:22 +00004141 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00004142 if (Fn->getFunctionType() != FT) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00004143 // The existing function doesn't have the same type. This is an overload
4144 // error.
4145 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
4146 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00004147 // Neither the existing or the current function is a declaration and they
4148 // have the same name and same type. Clearly this is a redefinition.
4149 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +00004150 } if (Fn->isDeclaration()) {
4151 // Make sure to strip off any argument names so we can't get conflicts.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004152 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
4153 AI != AE; ++AI)
4154 AI->setName("");
Reid Spenceref9b9a72007-02-05 20:47:22 +00004155 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004156 } else { // Not already defined?
Chris Lattner6cdc6822007-04-26 05:31:05 +00004157 Fn = new Function(FT, GlobalValue::ExternalWeakLinkage, FunctionName,
Reid Spencer68a24bd2005-08-27 18:50:39 +00004158 CurModule.CurrentModule);
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004159
Reid Spencer68a24bd2005-08-27 18:50:39 +00004160 InsertValue(Fn, CurModule.Values);
4161 }
4162
4163 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004164
4165 if (CurFun.isDeclare) {
4166 // If we have declaration, always overwrite linkage. This will allow us to
4167 // correctly handle cases, when pointer to function is passed as argument to
4168 // another function.
4169 Fn->setLinkage(CurFun.Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004170 Fn->setVisibility(CurFun.Visibility);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004171 }
Chris Lattner0275cff2007-08-06 21:00:46 +00004172 Fn->setCallingConv(yyvsp[-8].UIntVal);
4173 Fn->setAlignment(yyvsp[0].UIntVal);
4174 if (yyvsp[-1].StrVal) {
4175 Fn->setSection(*yyvsp[-1].StrVal);
4176 delete yyvsp[-1].StrVal;
Chris Lattnere869eef2005-11-12 00:11:49 +00004177 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004178
4179 // Add all of the arguments we parsed to the function...
Chris Lattner0275cff2007-08-06 21:00:46 +00004180 if (yyvsp[-4].ArgList) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00004181 if (isVarArg) { // Nuke the last entry
Chris Lattner0275cff2007-08-06 21:00:46 +00004182 assert(yyvsp[-4].ArgList->back().Ty->get() == Type::VoidTy && yyvsp[-4].ArgList->back().Name == 0 &&
Reid Spencera9720f52007-02-05 17:04:00 +00004183 "Not a varargs marker!");
Chris Lattner0275cff2007-08-06 21:00:46 +00004184 delete yyvsp[-4].ArgList->back().Ty;
4185 yyvsp[-4].ArgList->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00004186 }
4187 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00004188 Function::arg_iterator ArgEnd = Fn->arg_end();
Reid Spencer14310612006-12-31 05:40:51 +00004189 unsigned Idx = 1;
Chris Lattner0275cff2007-08-06 21:00:46 +00004190 for (ArgListType::iterator I = yyvsp[-4].ArgList->begin();
4191 I != yyvsp[-4].ArgList->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencer14310612006-12-31 05:40:51 +00004192 delete I->Ty; // Delete the typeholder...
Reid Spencer0a8a16b2007-05-22 18:52:55 +00004193 setValueName(ArgIt, I->Name); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00004194 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004195 InsertValue(ArgIt);
Reid Spencer14310612006-12-31 05:40:51 +00004196 Idx++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004197 }
Reid Spencera132e042006-12-03 05:46:11 +00004198
Chris Lattner0275cff2007-08-06 21:00:46 +00004199 delete yyvsp[-4].ArgList; // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00004200 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004201 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004202;
4203 break;}
4204case 235:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004205#line 2376 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004206{
Chris Lattner0275cff2007-08-06 21:00:46 +00004207 yyval.FunctionVal = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004208
4209 // Make sure that we keep track of the linkage type even if there was a
4210 // previous "declare".
Chris Lattner0275cff2007-08-06 21:00:46 +00004211 yyval.FunctionVal->setLinkage(yyvsp[-3].Linkage);
4212 yyval.FunctionVal->setVisibility(yyvsp[-2].Visibility);
Dale Johannesencdd509a2007-09-07 21:07:57 +00004213;
4214 break;}
4215case 238:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004216#line 2387 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004217{
Chris Lattner0275cff2007-08-06 21:00:46 +00004218 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004219 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004220;
4221 break;}
4222case 239:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004223#line 2392 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004224{
Chris Lattner0275cff2007-08-06 21:00:46 +00004225 CurFun.CurrentFunction->setLinkage(yyvsp[-2].Linkage);
4226 CurFun.CurrentFunction->setVisibility(yyvsp[-1].Visibility);
4227 yyval.FunctionVal = CurFun.CurrentFunction;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004228 CurFun.FunctionDone();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004229 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004230 ;
4231 break;}
4232case 240:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004233#line 2404 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004234{
Chris Lattner0275cff2007-08-06 21:00:46 +00004235 yyval.BoolVal = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00004236 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004237 ;
4238 break;}
4239case 241:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004240#line 2408 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004241{
Chris Lattner0275cff2007-08-06 21:00:46 +00004242 yyval.BoolVal = true;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004243 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004244 ;
4245 break;}
4246case 242:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004247#line 2413 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004248{ // A reference to a direct constant
Chris Lattner0275cff2007-08-06 21:00:46 +00004249 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004250 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004251 ;
4252 break;}
4253case 243:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004254#line 2417 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004255{
Chris Lattner0275cff2007-08-06 21:00:46 +00004256 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004257 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004258 ;
4259 break;}
4260case 244:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004261#line 2421 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004262{ // Perhaps it's an FP constant?
Chris Lattner0275cff2007-08-06 21:00:46 +00004263 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004264 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004265 ;
4266 break;}
4267case 245:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004268#line 2425 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004269{
Chris Lattner0275cff2007-08-06 21:00:46 +00004270 yyval.ValIDVal = ValID::create(ConstantInt::getTrue());
Reid Spencere4d87aa2006-12-23 06:05:41 +00004271 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004272 ;
4273 break;}
4274case 246:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004275#line 2429 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004276{
Chris Lattner0275cff2007-08-06 21:00:46 +00004277 yyval.ValIDVal = ValID::create(ConstantInt::getFalse());
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004278 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004279 ;
4280 break;}
4281case 247:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004282#line 2433 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004283{
Chris Lattner0275cff2007-08-06 21:00:46 +00004284 yyval.ValIDVal = ValID::createNull();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004285 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004286 ;
4287 break;}
4288case 248:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004289#line 2437 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004290{
Chris Lattner0275cff2007-08-06 21:00:46 +00004291 yyval.ValIDVal = ValID::createUndef();
Reid Spencer61c83e02006-08-18 08:43:06 +00004292 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004293 ;
4294 break;}
4295case 249:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004296#line 2441 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004297{ // A vector zero constant.
Chris Lattner0275cff2007-08-06 21:00:46 +00004298 yyval.ValIDVal = ValID::createZeroInit();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004299 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004300 ;
4301 break;}
4302case 250:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004303#line 2445 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004304{ // Nonempty unsized packed vector
Chris Lattner0275cff2007-08-06 21:00:46 +00004305 const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
4306 int NumElements = yyvsp[-1].ConstVector->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004307
Reid Spencer9d6565a2007-02-15 02:26:10 +00004308 VectorType* pt = VectorType::get(ETy, NumElements);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004309 PATypeHolder* PTy = new PATypeHolder(
Reid Spencera132e042006-12-03 05:46:11 +00004310 HandleUpRefs(
Reid Spencer9d6565a2007-02-15 02:26:10 +00004311 VectorType::get(
Reid Spencera132e042006-12-03 05:46:11 +00004312 ETy,
4313 NumElements)
4314 )
4315 );
Reid Spencer68a24bd2005-08-27 18:50:39 +00004316
4317 // Verify all elements are correct type!
Chris Lattner0275cff2007-08-06 21:00:46 +00004318 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
4319 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00004320 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00004321 ETy->getDescription() +"' as required!\nIt is of type '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00004322 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004323 }
4324
Chris Lattner0275cff2007-08-06 21:00:46 +00004325 yyval.ValIDVal = ValID::create(ConstantVector::get(pt, *yyvsp[-1].ConstVector));
4326 delete PTy; delete yyvsp[-1].ConstVector;
Reid Spencer832254e2007-02-02 02:16:23 +00004327 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004328 ;
4329 break;}
4330case 251:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004331#line 2470 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004332{
Chris Lattner0275cff2007-08-06 21:00:46 +00004333 yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
Reid Spencer832254e2007-02-02 02:16:23 +00004334 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004335 ;
4336 break;}
4337case 252:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004338#line 2474 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004339{
Chris Lattner0275cff2007-08-06 21:00:46 +00004340 yyval.ValIDVal = ValID::createInlineAsm(*yyvsp[-2].StrVal, *yyvsp[0].StrVal, yyvsp[-3].BoolVal);
4341 delete yyvsp[-2].StrVal;
4342 delete yyvsp[0].StrVal;
Reid Spencer832254e2007-02-02 02:16:23 +00004343 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004344 ;
4345 break;}
4346case 253:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004347#line 2484 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004348{ // Is it an integer reference...?
Chris Lattner0275cff2007-08-06 21:00:46 +00004349 yyval.ValIDVal = ValID::createLocalID(yyvsp[0].UIntVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004350 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004351 ;
4352 break;}
4353case 254:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004354#line 2488 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004355{
Chris Lattner0275cff2007-08-06 21:00:46 +00004356 yyval.ValIDVal = ValID::createGlobalID(yyvsp[0].UIntVal);
Reid Spencer832254e2007-02-02 02:16:23 +00004357 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004358 ;
4359 break;}
4360case 255:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004361#line 2492 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004362{ // Is it a named reference...?
Chris Lattner0275cff2007-08-06 21:00:46 +00004363 yyval.ValIDVal = ValID::createLocalName(*yyvsp[0].StrVal);
4364 delete yyvsp[0].StrVal;
Reid Spencer832254e2007-02-02 02:16:23 +00004365 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004366 ;
4367 break;}
4368case 256:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004369#line 2497 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004370{ // Is it a named reference...?
Chris Lattner0275cff2007-08-06 21:00:46 +00004371 yyval.ValIDVal = ValID::createGlobalName(*yyvsp[0].StrVal);
4372 delete yyvsp[0].StrVal;
Reid Spencer832254e2007-02-02 02:16:23 +00004373 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004374 ;
4375 break;}
4376case 259:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004377#line 2510 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004378{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004379 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004380 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4381 yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
4382 delete yyvsp[-1].TypeVal;
Reid Spencer832254e2007-02-02 02:16:23 +00004383 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004384 ;
4385 break;}
4386case 260:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004387#line 2519 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004388{
Chris Lattner0275cff2007-08-06 21:00:46 +00004389 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004390 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004391 ;
4392 break;}
4393case 261:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004394#line 2523 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004395{ // Do not allow functions with 0 basic blocks
Chris Lattner0275cff2007-08-06 21:00:46 +00004396 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004397 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004398 ;
4399 break;}
4400case 262:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004401#line 2532 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004402{
Chris Lattner0275cff2007-08-06 21:00:46 +00004403 setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004404 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004405 InsertValue(yyvsp[0].TermInstVal);
4406 yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
4407 yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004408 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004409 ;
4410 break;}
4411case 263:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004412#line 2541 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004413{
Chris Lattner0275cff2007-08-06 21:00:46 +00004414 if (CastInst *CI1 = dyn_cast<CastInst>(yyvsp[0].InstVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004415 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
4416 if (CI2->getParent() == 0)
Chris Lattner0275cff2007-08-06 21:00:46 +00004417 yyvsp[-1].BasicBlockVal->getInstList().push_back(CI2);
4418 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
4419 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004420 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004421 ;
4422 break;}
4423case 264:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004424#line 2550 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004425{ // Empty space between instruction lists
Chris Lattner0275cff2007-08-06 21:00:46 +00004426 yyval.BasicBlockVal = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
Reid Spencered951ea2007-05-19 07:22:10 +00004427 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004428 ;
4429 break;}
4430case 265:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004431#line 2554 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004432{ // Labelled (named) basic block
Chris Lattner0275cff2007-08-06 21:00:46 +00004433 yyval.BasicBlockVal = defineBBVal(ValID::createLocalName(*yyvsp[0].StrVal));
4434 delete yyvsp[0].StrVal;
Reid Spencered951ea2007-05-19 07:22:10 +00004435 CHECK_FOR_ERROR
Reid Spencer0a8a16b2007-05-22 18:52:55 +00004436
Dale Johannesencdd509a2007-09-07 21:07:57 +00004437 ;
4438 break;}
4439case 266:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004440#line 2561 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004441{ // Return with a result...
Chris Lattner0275cff2007-08-06 21:00:46 +00004442 yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
4443 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004444 ;
4445 break;}
4446case 267:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004447#line 2565 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004448{ // Return with no result...
Chris Lattner0275cff2007-08-06 21:00:46 +00004449 yyval.TermInstVal = new ReturnInst();
4450 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004451 ;
4452 break;}
4453case 268:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004454#line 2569 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004455{ // Unconditional Branch...
Chris Lattner0275cff2007-08-06 21:00:46 +00004456 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
4457 CHECK_FOR_ERROR
4458 yyval.TermInstVal = new BranchInst(tmpBB);
Dale Johannesencdd509a2007-09-07 21:07:57 +00004459 ;
4460 break;}
4461case 269:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004462#line 2574 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004463{
Chris Lattner0275cff2007-08-06 21:00:46 +00004464 assert(cast<IntegerType>(yyvsp[-7].PrimType)->getBitWidth() == 1 && "Not Bool?");
4465 BasicBlock* tmpBBA = getBBVal(yyvsp[-3].ValIDVal);
4466 CHECK_FOR_ERROR
4467 BasicBlock* tmpBBB = getBBVal(yyvsp[0].ValIDVal);
4468 CHECK_FOR_ERROR
4469 Value* tmpVal = getVal(Type::Int1Ty, yyvsp[-6].ValIDVal);
4470 CHECK_FOR_ERROR
4471 yyval.TermInstVal = new BranchInst(tmpBBA, tmpBBB, tmpVal);
Dale Johannesencdd509a2007-09-07 21:07:57 +00004472 ;
4473 break;}
4474case 270:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004475#line 2584 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004476{
Chris Lattner0275cff2007-08-06 21:00:46 +00004477 Value* tmpVal = getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal);
4478 CHECK_FOR_ERROR
4479 BasicBlock* tmpBB = getBBVal(yyvsp[-3].ValIDVal);
4480 CHECK_FOR_ERROR
4481 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, yyvsp[-1].JumpTable->size());
4482 yyval.TermInstVal = S;
Reid Spencerb8f85052007-07-31 03:50:36 +00004483
Chris Lattner0275cff2007-08-06 21:00:46 +00004484 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
4485 E = yyvsp[-1].JumpTable->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004486 for (; I != E; ++I) {
4487 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
4488 S->addCase(CI, I->second);
4489 else
Reid Spencerb5334b02007-02-05 10:18:06 +00004490 GEN_ERROR("Switch case is constant, but not a simple integer");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004491 }
Chris Lattner0275cff2007-08-06 21:00:46 +00004492 delete yyvsp[-1].JumpTable;
Reid Spencer61c83e02006-08-18 08:43:06 +00004493 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004494 ;
4495 break;}
4496case 271:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004497#line 2603 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004498{
Chris Lattner0275cff2007-08-06 21:00:46 +00004499 Value* tmpVal = getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004500 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004501 BasicBlock* tmpBB = getBBVal(yyvsp[-2].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004502 CHECK_FOR_ERROR
4503 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Chris Lattner0275cff2007-08-06 21:00:46 +00004504 yyval.TermInstVal = S;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004505 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004506 ;
4507 break;}
4508case 272:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004509#line 2613 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004510{
Reid Spencer3822ff52006-11-08 06:47:33 +00004511
Reid Spencer14310612006-12-31 05:40:51 +00004512 // Handle the short syntax
4513 const PointerType *PFTy = 0;
4514 const FunctionType *Ty = 0;
Chris Lattner0275cff2007-08-06 21:00:46 +00004515 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-11].TypeVal->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00004516 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4517 // Pull out the types of all of the arguments...
4518 std::vector<const Type*> ParamTypes;
Christopher Lamb5c104242007-04-22 20:09:11 +00004519 ParamAttrsVector Attrs;
Chris Lattner0275cff2007-08-06 21:00:46 +00004520 if (yyvsp[-6].ParamAttrs != ParamAttr::None) {
4521 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[-6].ParamAttrs;
Christopher Lamb5c104242007-04-22 20:09:11 +00004522 Attrs.push_back(PAWI);
4523 }
Chris Lattner0275cff2007-08-06 21:00:46 +00004524 ValueRefList::iterator I = yyvsp[-8].ValueRefList->begin(), E = yyvsp[-8].ValueRefList->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00004525 unsigned index = 1;
4526 for (; I != E; ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00004527 const Type *Ty = I->Val->getType();
4528 if (Ty == Type::VoidTy)
4529 GEN_ERROR("Short call syntax cannot be used with varargs");
4530 ParamTypes.push_back(Ty);
Christopher Lamb5c104242007-04-22 20:09:11 +00004531 if (I->Attrs != ParamAttr::None) {
4532 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
4533 Attrs.push_back(PAWI);
4534 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004535 }
4536
Christopher Lamb5c104242007-04-22 20:09:11 +00004537 ParamAttrsList *PAL = 0;
4538 if (!Attrs.empty())
4539 PAL = ParamAttrsList::get(Attrs);
Chris Lattner0275cff2007-08-06 21:00:46 +00004540 Ty = FunctionType::get(yyvsp[-11].TypeVal->get(), ParamTypes, false, PAL);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004541 PFTy = PointerType::get(Ty);
4542 }
4543
Chris Lattner0275cff2007-08-06 21:00:46 +00004544 delete yyvsp[-11].TypeVal;
Reid Spencer66728ef2007-03-20 01:13:36 +00004545
Chris Lattner0275cff2007-08-06 21:00:46 +00004546 Value *V = getVal(PFTy, yyvsp[-10].ValIDVal); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00004547 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004548 BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004549 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004550 BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
Reid Spencer5b7e7532006-09-28 19:28:24 +00004551 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004552
Reid Spencer14310612006-12-31 05:40:51 +00004553 // Check the arguments
4554 ValueList Args;
Chris Lattner0275cff2007-08-06 21:00:46 +00004555 if (yyvsp[-8].ValueRefList->empty()) { // Has no arguments?
Reid Spencer14310612006-12-31 05:40:51 +00004556 // Make sure no arguments is a good thing!
4557 if (Ty->getNumParams() != 0)
4558 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00004559 "expects arguments");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004560 } else { // Has arguments?
4561 // Loop through FunctionType's arguments and ensure they are specified
4562 // correctly!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004563 FunctionType::param_iterator I = Ty->param_begin();
4564 FunctionType::param_iterator E = Ty->param_end();
Chris Lattner0275cff2007-08-06 21:00:46 +00004565 ValueRefList::iterator ArgI = yyvsp[-8].ValueRefList->begin(), ArgE = yyvsp[-8].ValueRefList->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004566
Reid Spencer14310612006-12-31 05:40:51 +00004567 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
4568 if (ArgI->Val->getType() != *I)
4569 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00004570 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00004571 Args.push_back(ArgI->Val);
4572 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004573
Reid Spencer14310612006-12-31 05:40:51 +00004574 if (Ty->isVarArg()) {
4575 if (I == E)
4576 for (; ArgI != ArgE; ++ArgI)
4577 Args.push_back(ArgI->Val); // push the remaining varargs
4578 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00004579 GEN_ERROR("Invalid number of parameters detected");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004580 }
Reid Spencer14310612006-12-31 05:40:51 +00004581
4582 // Create the InvokeInst
Chris Lattnerd80fb8b2007-08-29 16:15:23 +00004583 InvokeInst *II = new InvokeInst(V, Normal, Except, Args.begin(), Args.end());
Chris Lattner0275cff2007-08-06 21:00:46 +00004584 II->setCallingConv(yyvsp[-12].UIntVal);
4585 yyval.TermInstVal = II;
4586 delete yyvsp[-8].ValueRefList;
Andrew Lenharth6353e052006-12-08 18:07:09 +00004587 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004588 ;
4589 break;}
4590case 273:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004591#line 2692 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004592{
Chris Lattner0275cff2007-08-06 21:00:46 +00004593 yyval.TermInstVal = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00004594 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004595 ;
4596 break;}
4597case 274:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004598#line 2696 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004599{
Chris Lattner0275cff2007-08-06 21:00:46 +00004600 yyval.TermInstVal = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00004601 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004602 ;
4603 break;}
4604case 275:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004605#line 2703 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004606{
Chris Lattner0275cff2007-08-06 21:00:46 +00004607 yyval.JumpTable = yyvsp[-5].JumpTable;
4608 Constant *V = cast<Constant>(getExistingVal(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004609 CHECK_FOR_ERROR
4610 if (V == 0)
4611 GEN_ERROR("May only switch on a constant pool value");
4612
Chris Lattner0275cff2007-08-06 21:00:46 +00004613 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004614 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004615 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
Dale Johannesencdd509a2007-09-07 21:07:57 +00004616 ;
4617 break;}
4618case 276:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004619#line 2714 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004620{
Chris Lattner0275cff2007-08-06 21:00:46 +00004621 yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
4622 Constant *V = cast<Constant>(getExistingVal(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004623 CHECK_FOR_ERROR
4624
4625 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004626 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00004627
Chris Lattner0275cff2007-08-06 21:00:46 +00004628 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004629 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004630 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
Dale Johannesencdd509a2007-09-07 21:07:57 +00004631 ;
4632 break;}
4633case 277:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004634#line 2727 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004635{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004636 // Is this definition named?? if so, assign the name...
Chris Lattner0275cff2007-08-06 21:00:46 +00004637 setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004638 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004639 InsertValue(yyvsp[0].InstVal);
4640 yyval.InstVal = yyvsp[0].InstVal;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004641 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004642 ;
4643 break;}
4644case 278:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004645#line 2737 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004646{ // Used for PHI nodes
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004647 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004648 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-5].TypeVal)->getDescription());
4649 yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
4650 Value* tmpVal = getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal);
Reid Spencer6f407902007-01-13 05:00:46 +00004651 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004652 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004653 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004654 yyval.PHIList->push_back(std::make_pair(tmpVal, tmpBB));
4655 delete yyvsp[-5].TypeVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00004656 ;
4657 break;}
4658case 279:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004659#line 2748 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004660{
Chris Lattner0275cff2007-08-06 21:00:46 +00004661 yyval.PHIList = yyvsp[-6].PHIList;
4662 Value* tmpVal = getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004663 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004664 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004665 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004666 yyvsp[-6].PHIList->push_back(std::make_pair(tmpVal, tmpBB));
Dale Johannesencdd509a2007-09-07 21:07:57 +00004667 ;
4668 break;}
4669case 280:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004670#line 2758 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004671{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004672 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004673 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004674 // Used for call and invoke instructions
Chris Lattner0275cff2007-08-06 21:00:46 +00004675 yyval.ValueRefList = new ValueRefList();
4676 ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal);
4677 yyval.ValueRefList->push_back(E);
4678 delete yyvsp[-2].TypeVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00004679 ;
4680 break;}
4681case 281:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004682#line 2767 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004683{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004684 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004685 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4686 yyval.ValueRefList = yyvsp[-4].ValueRefList;
4687 ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal);
4688 yyval.ValueRefList->push_back(E);
4689 delete yyvsp[-2].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004690 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004691 ;
4692 break;}
4693case 282:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004694#line 2776 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004695{ yyval.ValueRefList = new ValueRefList(); ;
4696 break;}
4697case 283:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004698#line 2779 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004699{ yyval.ValueList = new std::vector<Value*>(); ;
4700 break;}
4701case 284:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004702#line 2780 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004703{
Chris Lattner0275cff2007-08-06 21:00:46 +00004704 yyval.ValueList = yyvsp[-2].ValueList;
4705 yyval.ValueList->push_back(yyvsp[0].ValueVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004706 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004707 ;
4708 break;}
4709case 285:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004710#line 2787 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004711{
Chris Lattner0275cff2007-08-06 21:00:46 +00004712 yyval.BoolVal = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004713 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004714 ;
4715 break;}
4716case 286:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004717#line 2791 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004718{
Chris Lattner0275cff2007-08-06 21:00:46 +00004719 yyval.BoolVal = false;
Andrew Lenharth6353e052006-12-08 18:07:09 +00004720 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004721 ;
4722 break;}
4723case 287:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004724#line 2796 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004725{
Reid Spencer14310612006-12-31 05:40:51 +00004726 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004727 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4728 if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
4729 !isa<VectorType>((*yyvsp[-3].TypeVal).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004730 GEN_ERROR(
4731 "Arithmetic operator requires integer, FP, or packed operands");
Chris Lattner0275cff2007-08-06 21:00:46 +00004732 if (isa<VectorType>((*yyvsp[-3].TypeVal).get()) &&
4733 (yyvsp[-4].BinaryOpVal == Instruction::URem ||
4734 yyvsp[-4].BinaryOpVal == Instruction::SRem ||
4735 yyvsp[-4].BinaryOpVal == Instruction::FRem))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004736 GEN_ERROR("Remainder not supported on vector types");
Chris Lattner0275cff2007-08-06 21:00:46 +00004737 Value* val1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004738 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004739 Value* val2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004740 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004741 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, val1, val2);
4742 if (yyval.InstVal == 0)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004743 GEN_ERROR("binary operator returned null");
Chris Lattner0275cff2007-08-06 21:00:46 +00004744 delete yyvsp[-3].TypeVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00004745 ;
4746 break;}
4747case 288:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004748#line 2817 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004749{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004750 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004751 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4752 if (!(*yyvsp[-3].TypeVal)->isInteger()) {
4753 if (Instruction::isShift(yyvsp[-4].BinaryOpVal) || !isa<VectorType>(yyvsp[-3].TypeVal->get()) ||
4754 !cast<VectorType>(yyvsp[-3].TypeVal->get())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004755 GEN_ERROR("Logical operator requires integral operands");
4756 }
Chris Lattner0275cff2007-08-06 21:00:46 +00004757 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004758 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004759 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004760 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004761 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, tmpVal1, tmpVal2);
4762 if (yyval.InstVal == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004763 GEN_ERROR("binary operator returned null");
Chris Lattner0275cff2007-08-06 21:00:46 +00004764 delete yyvsp[-3].TypeVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00004765 ;
4766 break;}
4767case 289:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004768#line 2834 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004769{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004770 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004771 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4772 if (isa<VectorType>((*yyvsp[-3].TypeVal).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004773 GEN_ERROR("Vector types not supported by icmp instruction");
Chris Lattner0275cff2007-08-06 21:00:46 +00004774 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004775 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004776 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004777 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004778 yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].IPredicate, tmpVal1, tmpVal2);
4779 if (yyval.InstVal == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004780 GEN_ERROR("icmp operator returned null");
Chris Lattner0275cff2007-08-06 21:00:46 +00004781 delete yyvsp[-3].TypeVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00004782 ;
4783 break;}
4784case 290:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004785#line 2848 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004786{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004787 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004788 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4789 if (isa<VectorType>((*yyvsp[-3].TypeVal).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004790 GEN_ERROR("Vector types not supported by fcmp instruction");
Chris Lattner0275cff2007-08-06 21:00:46 +00004791 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004792 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004793 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004794 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004795 yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].FPredicate, tmpVal1, tmpVal2);
4796 if (yyval.InstVal == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004797 GEN_ERROR("fcmp operator returned null");
Chris Lattner0275cff2007-08-06 21:00:46 +00004798 delete yyvsp[-3].TypeVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00004799 ;
4800 break;}
4801case 291:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004802#line 2862 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004803{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004804 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004805 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
4806 Value* Val = yyvsp[-2].ValueVal;
4807 const Type* DestTy = yyvsp[0].TypeVal->get();
4808 if (!CastInst::castIsValid(yyvsp[-3].CastOpVal, Val, DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004809 GEN_ERROR("invalid cast opcode for cast from '" +
4810 Val->getType()->getDescription() + "' to '" +
4811 DestTy->getDescription() + "'");
Chris Lattner0275cff2007-08-06 21:00:46 +00004812 yyval.InstVal = CastInst::create(yyvsp[-3].CastOpVal, Val, DestTy);
4813 delete yyvsp[0].TypeVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00004814 ;
4815 break;}
4816case 292:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004817#line 2874 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004818{
Chris Lattner0275cff2007-08-06 21:00:46 +00004819 if (yyvsp[-4].ValueVal->getType() != Type::Int1Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004820 GEN_ERROR("select condition must be boolean");
Chris Lattner0275cff2007-08-06 21:00:46 +00004821 if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004822 GEN_ERROR("select value types should match");
Chris Lattner0275cff2007-08-06 21:00:46 +00004823 yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004824 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004825 ;
4826 break;}
4827case 293:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004828#line 2882 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004829{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004830 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004831 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
4832 yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
4833 delete yyvsp[0].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00004834 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004835 ;
4836 break;}
4837case 294:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004838#line 2889 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004839{
Chris Lattner0275cff2007-08-06 21:00:46 +00004840 if (!ExtractElementInst::isValidOperands(yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004841 GEN_ERROR("Invalid extractelement operands");
Chris Lattner0275cff2007-08-06 21:00:46 +00004842 yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004843 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004844 ;
4845 break;}
4846case 295:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004847#line 2895 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004848{
Chris Lattner0275cff2007-08-06 21:00:46 +00004849 if (!InsertElementInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004850 GEN_ERROR("Invalid insertelement operands");
Chris Lattner0275cff2007-08-06 21:00:46 +00004851 yyval.InstVal = new InsertElementInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004852 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004853 ;
4854 break;}
4855case 296:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004856#line 2901 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004857{
Chris Lattner0275cff2007-08-06 21:00:46 +00004858 if (!ShuffleVectorInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004859 GEN_ERROR("Invalid shufflevector operands");
Chris Lattner0275cff2007-08-06 21:00:46 +00004860 yyval.InstVal = new ShuffleVectorInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004861 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004862 ;
4863 break;}
4864case 297:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004865#line 2907 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004866{
Chris Lattner0275cff2007-08-06 21:00:46 +00004867 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004868 if (!Ty->isFirstClassType())
4869 GEN_ERROR("PHI node operands must be of first class type");
Chris Lattner0275cff2007-08-06 21:00:46 +00004870 yyval.InstVal = new PHINode(Ty);
4871 ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
4872 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
4873 if (yyvsp[0].PHIList->front().first->getType() != Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004874 GEN_ERROR("All elements of a PHI node must be of the same type");
Chris Lattner0275cff2007-08-06 21:00:46 +00004875 cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
4876 yyvsp[0].PHIList->pop_front();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004877 }
Chris Lattner0275cff2007-08-06 21:00:46 +00004878 delete yyvsp[0].PHIList; // Free the list...
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004879 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004880 ;
4881 break;}
4882case 298:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004883#line 2923 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004884{
Reid Spencer14310612006-12-31 05:40:51 +00004885
4886 // Handle the short syntax
Andrew Lenharth6353e052006-12-08 18:07:09 +00004887 const PointerType *PFTy = 0;
4888 const FunctionType *Ty = 0;
Chris Lattner0275cff2007-08-06 21:00:46 +00004889 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-5].TypeVal->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00004890 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4891 // Pull out the types of all of the arguments...
4892 std::vector<const Type*> ParamTypes;
Christopher Lamb5c104242007-04-22 20:09:11 +00004893 ParamAttrsVector Attrs;
Chris Lattner0275cff2007-08-06 21:00:46 +00004894 if (yyvsp[0].ParamAttrs != ParamAttr::None) {
4895 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[0].ParamAttrs;
Christopher Lamb5c104242007-04-22 20:09:11 +00004896 Attrs.push_back(PAWI);
4897 }
Reid Spencer7b5d4662007-04-09 06:16:21 +00004898 unsigned index = 1;
Chris Lattner0275cff2007-08-06 21:00:46 +00004899 ValueRefList::iterator I = yyvsp[-2].ValueRefList->begin(), E = yyvsp[-2].ValueRefList->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00004900 for (; I != E; ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00004901 const Type *Ty = I->Val->getType();
4902 if (Ty == Type::VoidTy)
4903 GEN_ERROR("Short call syntax cannot be used with varargs");
4904 ParamTypes.push_back(Ty);
Christopher Lamb5c104242007-04-22 20:09:11 +00004905 if (I->Attrs != ParamAttr::None) {
4906 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
4907 Attrs.push_back(PAWI);
4908 }
Andrew Lenharth6353e052006-12-08 18:07:09 +00004909 }
4910
Christopher Lamb5c104242007-04-22 20:09:11 +00004911 ParamAttrsList *PAL = 0;
4912 if (!Attrs.empty())
4913 PAL = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00004914
Chris Lattner0275cff2007-08-06 21:00:46 +00004915 Ty = FunctionType::get(yyvsp[-5].TypeVal->get(), ParamTypes, false, PAL);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004916 PFTy = PointerType::get(Ty);
4917 }
Chris Lattner6cdc6822007-04-26 05:31:05 +00004918
Chris Lattner0275cff2007-08-06 21:00:46 +00004919 Value *V = getVal(PFTy, yyvsp[-4].ValIDVal); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00004920 CHECK_FOR_ERROR
Chris Lattner6cdc6822007-04-26 05:31:05 +00004921
Reid Spencer7780acb2007-04-16 06:56:07 +00004922 // Check for call to invalid intrinsic to avoid crashing later.
4923 if (Function *theF = dyn_cast<Function>(V)) {
Reid Spencered48de22007-04-16 22:02:23 +00004924 if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) &&
Reid Spencer36fdde12007-04-16 20:35:38 +00004925 (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) &&
4926 !theF->getIntrinsicID(true))
Reid Spencer7780acb2007-04-16 06:56:07 +00004927 GEN_ERROR("Call to invalid LLVM intrinsic function '" +
4928 theF->getName() + "'");
4929 }
4930
Reid Spencer14310612006-12-31 05:40:51 +00004931 // Check the arguments
4932 ValueList Args;
Chris Lattner0275cff2007-08-06 21:00:46 +00004933 if (yyvsp[-2].ValueRefList->empty()) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00004934 // Make sure no arguments is a good thing!
4935 if (Ty->getNumParams() != 0)
4936 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00004937 "expects arguments");
Andrew Lenharth6353e052006-12-08 18:07:09 +00004938 } else { // Has arguments?
4939 // Loop through FunctionType's arguments and ensure they are specified
4940 // correctly!
4941 //
4942 FunctionType::param_iterator I = Ty->param_begin();
4943 FunctionType::param_iterator E = Ty->param_end();
Chris Lattner0275cff2007-08-06 21:00:46 +00004944 ValueRefList::iterator ArgI = yyvsp[-2].ValueRefList->begin(), ArgE = yyvsp[-2].ValueRefList->end();
Andrew Lenharth6353e052006-12-08 18:07:09 +00004945
Reid Spencer14310612006-12-31 05:40:51 +00004946 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
4947 if (ArgI->Val->getType() != *I)
4948 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00004949 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00004950 Args.push_back(ArgI->Val);
4951 }
4952 if (Ty->isVarArg()) {
4953 if (I == E)
4954 for (; ArgI != ArgE; ++ArgI)
4955 Args.push_back(ArgI->Val); // push the remaining varargs
4956 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00004957 GEN_ERROR("Invalid number of parameters detected");
Andrew Lenharth6353e052006-12-08 18:07:09 +00004958 }
Reid Spencer14310612006-12-31 05:40:51 +00004959 // Create the call node
David Greene718fda32007-08-01 03:59:32 +00004960 CallInst *CI = new CallInst(V, Args.begin(), Args.end());
Chris Lattner0275cff2007-08-06 21:00:46 +00004961 CI->setTailCall(yyvsp[-7].BoolVal);
4962 CI->setCallingConv(yyvsp[-6].UIntVal);
4963 yyval.InstVal = CI;
4964 delete yyvsp[-2].ValueRefList;
4965 delete yyvsp[-5].TypeVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004966 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004967 ;
4968 break;}
4969case 299:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004970#line 3007 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004971{
Chris Lattner0275cff2007-08-06 21:00:46 +00004972 yyval.InstVal = yyvsp[0].InstVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004973 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004974 ;
4975 break;}
4976case 300:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004977#line 3012 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004978{
Chris Lattner0275cff2007-08-06 21:00:46 +00004979 yyval.BoolVal = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004980 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004981 ;
4982 break;}
4983case 301:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004984#line 3016 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004985{
Chris Lattner0275cff2007-08-06 21:00:46 +00004986 yyval.BoolVal = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00004987 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004988 ;
4989 break;}
4990case 302:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00004991#line 3023 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00004992{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004993 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004994 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4995 yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
4996 delete yyvsp[-1].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00004997 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00004998 ;
4999 break;}
5000case 303:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00005001#line 3030 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00005002{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005003 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00005004 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
5005 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005006 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00005007 yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
5008 delete yyvsp[-4].TypeVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00005009 ;
5010 break;}
5011case 304:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00005012#line 3038 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00005013{
Reid Spencer14310612006-12-31 05:40:51 +00005014 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00005015 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
5016 yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
5017 delete yyvsp[-1].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00005018 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00005019 ;
5020 break;}
5021case 305:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00005022#line 3045 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00005023{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005024 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00005025 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
5026 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005027 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00005028 yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
5029 delete yyvsp[-4].TypeVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00005030 ;
5031 break;}
5032case 306:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00005033#line 3053 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00005034{
Chris Lattner0275cff2007-08-06 21:00:46 +00005035 if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005036 GEN_ERROR("Trying to free nonpointer type " +
Chris Lattner0275cff2007-08-06 21:00:46 +00005037 yyvsp[0].ValueVal->getType()->getDescription() + "");
5038 yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005039 CHECK_FOR_ERROR
Dale Johannesencdd509a2007-09-07 21:07:57 +00005040 ;
5041 break;}
5042case 307:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00005043#line 3061 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00005044{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005045 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00005046 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
5047 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005048 GEN_ERROR("Can't load from nonpointer type: " +
Chris Lattner0275cff2007-08-06 21:00:46 +00005049 (*yyvsp[-2].TypeVal)->getDescription());
5050 if (!cast<PointerType>(yyvsp[-2].TypeVal->get())->getElementType()->isFirstClassType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005051 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Chris Lattner0275cff2007-08-06 21:00:46 +00005052 (*yyvsp[-2].TypeVal)->getDescription());
5053 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005054 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00005055 yyval.InstVal = new LoadInst(tmpVal, "", yyvsp[-4].BoolVal, yyvsp[0].UIntVal);
5056 delete yyvsp[-2].TypeVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00005057 ;
5058 break;}
5059case 308:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00005060#line 3075 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00005061{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005062 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00005063 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
5064 const PointerType *PT = dyn_cast<PointerType>(yyvsp[-2].TypeVal->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005065 if (!PT)
5066 GEN_ERROR("Can't store to a nonpointer type: " +
Chris Lattner0275cff2007-08-06 21:00:46 +00005067 (*yyvsp[-2].TypeVal)->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005068 const Type *ElTy = PT->getElementType();
Chris Lattner0275cff2007-08-06 21:00:46 +00005069 if (ElTy != yyvsp[-4].ValueVal->getType())
5070 GEN_ERROR("Can't store '" + yyvsp[-4].ValueVal->getType()->getDescription() +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005071 "' into space of type '" + ElTy->getDescription() + "'");
5072
Chris Lattner0275cff2007-08-06 21:00:46 +00005073 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005074 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00005075 yyval.InstVal = new StoreInst(yyvsp[-4].ValueVal, tmpVal, yyvsp[-6].BoolVal, yyvsp[0].UIntVal);
5076 delete yyvsp[-2].TypeVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00005077 ;
5078 break;}
5079case 309:
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00005080#line 3092 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Dale Johannesencdd509a2007-09-07 21:07:57 +00005081{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005082 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00005083 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
5084 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
Reid Spencerb5334b02007-02-05 10:18:06 +00005085 GEN_ERROR("getelementptr insn requires pointer operand");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005086
David Greene5fd22a82007-09-04 18:46:50 +00005087 if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end(), true))
Reid Spencer61c83e02006-08-18 08:43:06 +00005088 GEN_ERROR("Invalid getelementptr indices for type '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00005089 (*yyvsp[-2].TypeVal)->getDescription()+ "'");
5090 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005091 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005092 yyval.InstVal = new GetElementPtrInst(tmpVal, yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end());
Chris Lattner0275cff2007-08-06 21:00:46 +00005093 delete yyvsp[-2].TypeVal;
5094 delete yyvsp[0].ValueList;
Dale Johannesencdd509a2007-09-07 21:07:57 +00005095 ;
5096 break;}
5097}
5098 /* the action file gets copied in in place of this dollarsign */
5099#line 543 "/usr/share/bison.simple"
Chris Lattner0275cff2007-08-06 21:00:46 +00005100
5101 yyvsp -= yylen;
5102 yyssp -= yylen;
Dale Johannesencdd509a2007-09-07 21:07:57 +00005103#ifdef YYLSP_NEEDED
5104 yylsp -= yylen;
5105#endif
Reid Spencer7780acb2007-04-16 06:56:07 +00005106
Dale Johannesencdd509a2007-09-07 21:07:57 +00005107#if YYDEBUG != 0
5108 if (yydebug)
5109 {
5110 short *ssp1 = yyss - 1;
5111 fprintf (stderr, "state stack now");
5112 while (ssp1 != yyssp)
5113 fprintf (stderr, " %d", *++ssp1);
5114 fprintf (stderr, "\n");
5115 }
5116#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00005117
5118 *++yyvsp = yyval;
5119
Dale Johannesencdd509a2007-09-07 21:07:57 +00005120#ifdef YYLSP_NEEDED
5121 yylsp++;
5122 if (yylen == 0)
5123 {
5124 yylsp->first_line = yylloc.first_line;
5125 yylsp->first_column = yylloc.first_column;
5126 yylsp->last_line = (yylsp-1)->last_line;
5127 yylsp->last_column = (yylsp-1)->last_column;
5128 yylsp->text = 0;
5129 }
5130 else
5131 {
5132 yylsp->last_line = (yylsp+yylen-1)->last_line;
5133 yylsp->last_column = (yylsp+yylen-1)->last_column;
5134 }
5135#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00005136
Dale Johannesencdd509a2007-09-07 21:07:57 +00005137 /* Now "shift" the result of the reduction.
5138 Determine what state that goes to,
5139 based on the state we popped back to
5140 and the rule number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005141
5142 yyn = yyr1[yyn];
5143
Dale Johannesencdd509a2007-09-07 21:07:57 +00005144 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
5145 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005146 yystate = yytable[yystate];
5147 else
Dale Johannesencdd509a2007-09-07 21:07:57 +00005148 yystate = yydefgoto[yyn - YYNTBASE];
Reid Spencer68a24bd2005-08-27 18:50:39 +00005149
5150 goto yynewstate;
5151
Dale Johannesencdd509a2007-09-07 21:07:57 +00005152yyerrlab: /* here on detecting error */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005153
Dale Johannesencdd509a2007-09-07 21:07:57 +00005154 if (! yyerrstatus)
5155 /* If not already recovering from an error, report this error. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005156 {
5157 ++yynerrs;
Dale Johannesencdd509a2007-09-07 21:07:57 +00005158
5159#ifdef YYERROR_VERBOSE
Chris Lattner0275cff2007-08-06 21:00:46 +00005160 yyn = yypact[yystate];
5161
Dale Johannesencdd509a2007-09-07 21:07:57 +00005162 if (yyn > YYFLAG && yyn < YYLAST)
Chris Lattner0275cff2007-08-06 21:00:46 +00005163 {
Dale Johannesencdd509a2007-09-07 21:07:57 +00005164 int size = 0;
5165 char *msg;
5166 int x, count;
Chris Lattner0275cff2007-08-06 21:00:46 +00005167
Dale Johannesencdd509a2007-09-07 21:07:57 +00005168 count = 0;
5169 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
5170 for (x = (yyn < 0 ? -yyn : 0);
5171 x < (sizeof(yytname) / sizeof(char *)); x++)
5172 if (yycheck[x + yyn] == x)
5173 size += strlen(yytname[x]) + 15, count++;
5174 msg = (char *) malloc(size + 15);
5175 if (msg != 0)
Chris Lattner0275cff2007-08-06 21:00:46 +00005176 {
Dale Johannesencdd509a2007-09-07 21:07:57 +00005177 strcpy(msg, "parse error");
Chris Lattner0275cff2007-08-06 21:00:46 +00005178
Dale Johannesencdd509a2007-09-07 21:07:57 +00005179 if (count < 5)
Chris Lattner0275cff2007-08-06 21:00:46 +00005180 {
Dale Johannesencdd509a2007-09-07 21:07:57 +00005181 count = 0;
5182 for (x = (yyn < 0 ? -yyn : 0);
5183 x < (sizeof(yytname) / sizeof(char *)); x++)
5184 if (yycheck[x + yyn] == x)
Chris Lattner0275cff2007-08-06 21:00:46 +00005185 {
Dale Johannesencdd509a2007-09-07 21:07:57 +00005186 strcat(msg, count == 0 ? ", expecting `" : " or `");
5187 strcat(msg, yytname[x]);
5188 strcat(msg, "'");
5189 count++;
Chris Lattner0275cff2007-08-06 21:00:46 +00005190 }
5191 }
Dale Johannesencdd509a2007-09-07 21:07:57 +00005192 yyerror(msg);
5193 free(msg);
Chris Lattner0275cff2007-08-06 21:00:46 +00005194 }
5195 else
Dale Johannesencdd509a2007-09-07 21:07:57 +00005196 yyerror ("parse error; also virtual memory exceeded");
Chris Lattner0275cff2007-08-06 21:00:46 +00005197 }
5198 else
5199#endif /* YYERROR_VERBOSE */
Dale Johannesencdd509a2007-09-07 21:07:57 +00005200 yyerror("parse error");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005201 }
5202
Dale Johannesencdd509a2007-09-07 21:07:57 +00005203 goto yyerrlab1;
5204yyerrlab1: /* here on error raised explicitly by an action */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005205
5206 if (yyerrstatus == 3)
5207 {
Dale Johannesencdd509a2007-09-07 21:07:57 +00005208 /* if just tried and failed to reuse lookahead token after an error, discard it. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005209
Dale Johannesencdd509a2007-09-07 21:07:57 +00005210 /* return failure if at end of input */
5211 if (yychar == YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005212 YYABORT;
5213
Dale Johannesencdd509a2007-09-07 21:07:57 +00005214#if YYDEBUG != 0
5215 if (yydebug)
5216 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
5217#endif
5218
5219 yychar = YYEMPTY;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005220 }
5221
Dale Johannesencdd509a2007-09-07 21:07:57 +00005222 /* Else will try to reuse lookahead token
5223 after shifting the error token. */
5224
5225 yyerrstatus = 3; /* Each real token shifted decrements this */
5226
5227 goto yyerrhandle;
5228
5229yyerrdefault: /* current state does not do anything special for the error token. */
5230
5231#if 0
5232 /* This is wrong; only states that explicitly want error tokens
5233 should shift them. */
5234 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
5235 if (yyn) goto yydefault;
5236#endif
5237
5238yyerrpop: /* pop the current state because it cannot handle the error token */
5239
5240 if (yyssp == yyss) YYABORT;
5241 yyvsp--;
5242 yystate = *--yyssp;
5243#ifdef YYLSP_NEEDED
5244 yylsp--;
5245#endif
5246
5247#if YYDEBUG != 0
5248 if (yydebug)
5249 {
5250 short *ssp1 = yyss - 1;
5251 fprintf (stderr, "Error: state stack now");
5252 while (ssp1 != yyssp)
5253 fprintf (stderr, " %d", *++ssp1);
5254 fprintf (stderr, "\n");
5255 }
5256#endif
5257
5258yyerrhandle:
5259
5260 yyn = yypact[yystate];
5261 if (yyn == YYFLAG)
5262 goto yyerrdefault;
5263
5264 yyn += YYTERROR;
5265 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
5266 goto yyerrdefault;
5267
5268 yyn = yytable[yyn];
5269 if (yyn < 0)
5270 {
5271 if (yyn == YYFLAG)
5272 goto yyerrpop;
5273 yyn = -yyn;
5274 goto yyreduce;
5275 }
5276 else if (yyn == 0)
5277 goto yyerrpop;
5278
Reid Spencer68a24bd2005-08-27 18:50:39 +00005279 if (yyn == YYFINAL)
5280 YYACCEPT;
5281
Dale Johannesencdd509a2007-09-07 21:07:57 +00005282#if YYDEBUG != 0
5283 if (yydebug)
5284 fprintf(stderr, "Shifting error token, ");
5285#endif
Chris Lattner0275cff2007-08-06 21:00:46 +00005286
Reid Spencer68a24bd2005-08-27 18:50:39 +00005287 *++yyvsp = yylval;
Dale Johannesencdd509a2007-09-07 21:07:57 +00005288#ifdef YYLSP_NEEDED
5289 *++yylsp = yylloc;
5290#endif
Reid Spencerb8f85052007-07-31 03:50:36 +00005291
Reid Spencer68a24bd2005-08-27 18:50:39 +00005292 yystate = yyn;
5293 goto yynewstate;
5294
Dale Johannesencdd509a2007-09-07 21:07:57 +00005295 yyacceptlab:
5296 /* YYACCEPT comes here. */
5297 if (yyfree_stacks)
5298 {
5299 free (yyss);
5300 free (yyvs);
5301#ifdef YYLSP_NEEDED
5302 free (yyls);
Chandler Carruth02202192007-08-04 01:56:21 +00005303#endif
Dale Johannesencdd509a2007-09-07 21:07:57 +00005304 }
5305 return 0;
David Greene5fd22a82007-09-04 18:46:50 +00005306
Dale Johannesencdd509a2007-09-07 21:07:57 +00005307 yyabortlab:
5308 /* YYABORT comes here. */
5309 if (yyfree_stacks)
5310 {
5311 free (yyss);
5312 free (yyvs);
5313#ifdef YYLSP_NEEDED
5314 free (yyls);
David Greene5fd22a82007-09-04 18:46:50 +00005315#endif
Dale Johannesencdd509a2007-09-07 21:07:57 +00005316 }
5317 return 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005318}
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00005319#line 3109 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00005320
5321
Reid Spencer14310612006-12-31 05:40:51 +00005322// common code from the two 'RunVMAsmParser' functions
5323static Module* RunParser(Module * M) {
5324
5325 llvmAsmlineno = 1; // Reset the current line number...
5326 CurModule.CurrentModule = M;
5327#if YYDEBUG
5328 yydebug = Debug;
5329#endif
5330
5331 // Check to make sure the parser succeeded
5332 if (yyparse()) {
5333 if (ParserResult)
5334 delete ParserResult;
5335 return 0;
5336 }
5337
Reid Spencer0d60b5a2007-03-30 01:37:39 +00005338 // Emit an error if there are any unresolved types left.
5339 if (!CurModule.LateResolveTypes.empty()) {
5340 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
5341 if (DID.Type == ValID::LocalName) {
5342 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
5343 } else {
5344 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
5345 }
5346 if (ParserResult)
5347 delete ParserResult;
5348 return 0;
5349 }
5350
5351 // Emit an error if there are any unresolved values left.
5352 if (!CurModule.LateResolveValues.empty()) {
5353 Value *V = CurModule.LateResolveValues.back();
5354 std::map<Value*, std::pair<ValID, int> >::iterator I =
5355 CurModule.PlaceHolderInfo.find(V);
5356
5357 if (I != CurModule.PlaceHolderInfo.end()) {
5358 ValID &DID = I->second.first;
5359 if (DID.Type == ValID::LocalName) {
5360 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
5361 } else {
5362 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
5363 }
5364 if (ParserResult)
5365 delete ParserResult;
5366 return 0;
5367 }
5368 }
5369
Reid Spencer14310612006-12-31 05:40:51 +00005370 // Check to make sure that parsing produced a result
5371 if (!ParserResult)
5372 return 0;
5373
5374 // Reset ParserResult variable while saving its value for the result.
5375 Module *Result = ParserResult;
5376 ParserResult = 0;
5377
5378 return Result;
5379}
5380
Reid Spencer61c83e02006-08-18 08:43:06 +00005381void llvm::GenerateError(const std::string &message, int LineNo) {
5382 if (LineNo == -1) LineNo = llvmAsmlineno;
5383 // TODO: column number in exception
5384 if (TheParseError)
5385 TheParseError->setError(CurFilename, message, LineNo);
5386 TriggerError = 1;
5387}
Reid Spencer68a24bd2005-08-27 18:50:39 +00005388
5389int yyerror(const char *ErrorMsg) {
5390 std::string where
5391 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
5392 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
Reid Spenceref9b9a72007-02-05 20:47:22 +00005393 std::string errMsg = where + "error: " + std::string(ErrorMsg);
5394 if (yychar != YYEMPTY && yychar != 0)
5395 errMsg += " while reading token: '" + std::string(llvmAsmtext, llvmAsmleng)+
5396 "'";
Reid Spencer61c83e02006-08-18 08:43:06 +00005397 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005398 return 0;
5399}