blob: 51297bfad561a88be26f26366734a9da3eefbbeb [file] [log] [blame]
Reid Spencer68a24bd2005-08-27 18:50:39 +00001
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002/* A Bison parser, made from /Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y
3 by GNU Bison version 1.28 */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004
Christopher Lamba8ed9bf2007-12-11 09:02:08 +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
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00008#define yylex llvmAsmlex
Reid Spencer68a24bd2005-08-27 18:50:39 +00009#define yyerror llvmAsmerror
Christopher Lamba8ed9bf2007-12-11 09:02:08 +000010#define yylval llvmAsmlval
11#define yychar llvmAsmchar
Reid Spencer68a24bd2005-08-27 18:50:39 +000012#define yydebug llvmAsmdebug
13#define yynerrs llvmAsmnerrs
Christopher Lamba8ed9bf2007-12-11 09:02:08 +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 ADDRSPACE 308
66#define DEPLIBS 309
67#define CALL 310
68#define TAIL 311
69#define ASM_TOK 312
70#define MODULE 313
71#define SIDEEFFECT 314
72#define CC_TOK 315
73#define CCC_TOK 316
74#define FASTCC_TOK 317
75#define COLDCC_TOK 318
76#define X86_STDCALLCC_TOK 319
77#define X86_FASTCALLCC_TOK 320
78#define DATALAYOUT 321
79#define RET 322
80#define BR 323
81#define SWITCH 324
82#define INVOKE 325
83#define UNWIND 326
84#define UNREACHABLE 327
85#define ADD 328
86#define SUB 329
87#define MUL 330
88#define UDIV 331
89#define SDIV 332
90#define FDIV 333
91#define UREM 334
92#define SREM 335
93#define FREM 336
94#define AND 337
95#define OR 338
96#define XOR 339
97#define SHL 340
98#define LSHR 341
99#define ASHR 342
100#define ICMP 343
101#define FCMP 344
102#define EQ 345
103#define NE 346
104#define SLT 347
105#define SGT 348
106#define SLE 349
107#define SGE 350
108#define ULT 351
109#define UGT 352
110#define ULE 353
111#define UGE 354
112#define OEQ 355
113#define ONE 356
114#define OLT 357
115#define OGT 358
116#define OLE 359
117#define OGE 360
118#define ORD 361
119#define UNO 362
120#define UEQ 363
121#define UNE 364
122#define MALLOC 365
123#define ALLOCA 366
124#define FREE 367
125#define LOAD 368
126#define STORE 369
127#define GETELEMENTPTR 370
128#define TRUNC 371
129#define ZEXT 372
130#define SEXT 373
131#define FPTRUNC 374
132#define FPEXT 375
133#define BITCAST 376
134#define UITOFP 377
135#define SITOFP 378
136#define FPTOUI 379
137#define FPTOSI 380
138#define INTTOPTR 381
139#define PTRTOINT 382
140#define PHI_TOK 383
141#define SELECT 384
142#define VAARG 385
143#define EXTRACTELEMENT 386
144#define INSERTELEMENT 387
145#define SHUFFLEVECTOR 388
146#define SIGNEXT 389
147#define ZEROEXT 390
148#define NORETURN 391
149#define INREG 392
150#define SRET 393
151#define NOUNWIND 394
152#define NOALIAS 395
153#define BYVAL 396
154#define NEST 397
155#define READNONE 398
156#define READONLY 399
157#define GC 400
158#define DEFAULT 401
159#define HIDDEN 402
160#define PROTECTED 403
Reid Spencer68a24bd2005-08-27 18:50:39 +0000161
Christopher Lamba8ed9bf2007-12-11 09:02:08 +0000162#line 14 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000163
164#include "ParserInternals.h"
165#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000166#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000167#include "llvm/Instructions.h"
168#include "llvm/Module.h"
Reid Spenceref9b9a72007-02-05 20:47:22 +0000169#include "llvm/ValueSymbolTable.h"
Chandler Carruth02202192007-08-04 01:56:21 +0000170#include "llvm/AutoUpgrade.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000171#include "llvm/Support/GetElementPtrTypeIterator.h"
Reid Spencer14310612006-12-31 05:40:51 +0000172#include "llvm/Support/CommandLine.h"
Chris Lattnerf7469af2007-01-31 04:44:08 +0000173#include "llvm/ADT/SmallVector.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000174#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000175#include "llvm/Support/MathExtras.h"
Reid Spencer481169e2006-12-01 00:33:46 +0000176#include "llvm/Support/Streams.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000177#include <algorithm>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000178#include <list>
Chris Lattner8adde282007-02-11 21:40:10 +0000179#include <map>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000180#include <utility>
181
Reid Spencere4f47592006-08-18 17:32:55 +0000182// The following is a gross hack. In order to rid the libAsmParser library of
183// exceptions, we have to have a way of getting the yyparse function to go into
184// an error situation. So, whenever we want an error to occur, the GenerateError
185// function (see bottom of file) sets TriggerError. Then, at the end of each
186// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
187// (a goto) to put YACC in error state. Furthermore, several calls to
188// GenerateError are made from inside productions and they must simulate the
189// previous exception behavior by exiting the production immediately. We have
190// replaced these with the GEN_ERROR macro which calls GeneratError and then
191// immediately invokes YYERROR. This would be so much cleaner if it was a
192// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000193static bool TriggerError = false;
Reid Spencerf63697d2006-10-09 17:36:59 +0000194#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000195#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
196
Reid Spencer68a24bd2005-08-27 18:50:39 +0000197int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
198int yylex(); // declaration" of xxx warnings.
199int yyparse();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000200using namespace llvm;
201
202static Module *ParserResult;
203
204// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
205// relating to upreferences in the input stream.
206//
207//#define DEBUG_UPREFS 1
208#ifdef DEBUG_UPREFS
Bill Wendlinge8156192006-12-07 01:30:32 +0000209#define UR_OUT(X) cerr << X
Reid Spencer68a24bd2005-08-27 18:50:39 +0000210#else
211#define UR_OUT(X)
212#endif
213
214#define YYERROR_VERBOSE 1
215
Chris Lattnerb475c422005-11-12 18:22:38 +0000216static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000217
218
219// This contains info used when building the body of a function. It is
220// destroyed when the function is completed.
221//
222typedef std::vector<Value *> ValueList; // Numbered defs
Reid Spencer14310612006-12-31 05:40:51 +0000223
Reid Spencer68a24bd2005-08-27 18:50:39 +0000224static void
Reid Spencer93c40032007-03-19 18:40:50 +0000225ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000226
227static struct PerModuleInfo {
228 Module *CurrentModule;
Reid Spencer93c40032007-03-19 18:40:50 +0000229 ValueList Values; // Module level numbered definitions
230 ValueList LateResolveValues;
Reid Spencer861d9d62006-11-28 07:29:44 +0000231 std::vector<PATypeHolder> Types;
232 std::map<ValID, PATypeHolder> LateResolveTypes;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000233
234 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000235 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000236 /// that we can resolve them later and print error messages as appropriate.
237 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
238
239 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
240 // references to global values. Global values may be referenced before they
241 // are defined, and if so, the temporary object that they represent is held
242 // here. This is used for forward references of GlobalValues.
243 //
244 typedef std::map<std::pair<const PointerType *,
245 ValID>, GlobalValue*> GlobalRefsType;
246 GlobalRefsType GlobalRefs;
247
248 void ModuleDone() {
249 // If we could not resolve some functions at function compilation time
250 // (calls to functions before they are defined), resolve them now... Types
251 // are resolved when the constant pool has been completely parsed.
252 //
253 ResolveDefinitions(LateResolveValues);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000254 if (TriggerError)
255 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000256
257 // Check to make sure that all global value forward references have been
258 // resolved!
259 //
260 if (!GlobalRefs.empty()) {
261 std::string UndefinedReferences = "Unresolved global references exist:\n";
262
263 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
264 I != E; ++I) {
265 UndefinedReferences += " " + I->first.first->getDescription() + " " +
266 I->first.second.getName() + "\n";
267 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000268 GenerateError(UndefinedReferences);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000269 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000270 }
271
Chandler Carruth02202192007-08-04 01:56:21 +0000272 // Look for intrinsic functions and CallInst that need to be upgraded
273 for (Module::iterator FI = CurrentModule->begin(),
274 FE = CurrentModule->end(); FI != FE; )
275 UpgradeCallsToIntrinsic(FI++); // must be post-increment, as we remove
276
Reid Spencer68a24bd2005-08-27 18:50:39 +0000277 Values.clear(); // Clear out function local definitions
278 Types.clear();
279 CurrentModule = 0;
280 }
281
Reid Spencer68a24bd2005-08-27 18:50:39 +0000282 // GetForwardRefForGlobal - Check to see if there is a forward reference
283 // for this global. If so, remove it from the GlobalRefs map and return it.
284 // If not, just return null.
285 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
286 // Check to see if there is a forward reference to this global variable...
287 // if there is, eliminate it and patch the reference to use the new def'n.
288 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
289 GlobalValue *Ret = 0;
290 if (I != GlobalRefs.end()) {
291 Ret = I->second;
292 GlobalRefs.erase(I);
293 }
294 return Ret;
295 }
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000296
297 bool TypeIsUnresolved(PATypeHolder* PATy) {
298 // If it isn't abstract, its resolved
299 const Type* Ty = PATy->get();
300 if (!Ty->isAbstract())
301 return false;
302 // Traverse the type looking for abstract types. If it isn't abstract then
303 // we don't need to traverse that leg of the type.
304 std::vector<const Type*> WorkList, SeenList;
305 WorkList.push_back(Ty);
306 while (!WorkList.empty()) {
307 const Type* Ty = WorkList.back();
308 SeenList.push_back(Ty);
309 WorkList.pop_back();
310 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
311 // Check to see if this is an unresolved type
312 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
313 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
314 for ( ; I != E; ++I) {
315 if (I->second.get() == OpTy)
316 return true;
317 }
318 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
319 const Type* TheTy = SeqTy->getElementType();
320 if (TheTy->isAbstract() && TheTy != Ty) {
321 std::vector<const Type*>::iterator I = SeenList.begin(),
322 E = SeenList.end();
323 for ( ; I != E; ++I)
324 if (*I == TheTy)
325 break;
326 if (I == E)
327 WorkList.push_back(TheTy);
328 }
329 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
330 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
331 const Type* TheTy = StrTy->getElementType(i);
332 if (TheTy->isAbstract() && TheTy != Ty) {
333 std::vector<const Type*>::iterator I = SeenList.begin(),
334 E = SeenList.end();
335 for ( ; I != E; ++I)
336 if (*I == TheTy)
337 break;
338 if (I == E)
339 WorkList.push_back(TheTy);
340 }
341 }
342 }
343 }
344 return false;
345 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000346} CurModule;
347
348static struct PerFunctionInfo {
349 Function *CurrentFunction; // Pointer to current function being created
350
Reid Spencer93c40032007-03-19 18:40:50 +0000351 ValueList Values; // Keep track of #'d definitions
352 unsigned NextValNum;
353 ValueList LateResolveValues;
Reid Spenceref9b9a72007-02-05 20:47:22 +0000354 bool isDeclare; // Is this function a forward declararation?
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000355 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000356 GlobalValue::VisibilityTypes Visibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000357
358 /// BBForwardRefs - When we see forward references to basic blocks, keep
359 /// track of them here.
Reid Spencer93c40032007-03-19 18:40:50 +0000360 std::map<ValID, BasicBlock*> BBForwardRefs;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000361
362 inline PerFunctionInfo() {
363 CurrentFunction = 0;
364 isDeclare = false;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000365 Linkage = GlobalValue::ExternalLinkage;
366 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000367 }
368
369 inline void FunctionStart(Function *M) {
370 CurrentFunction = M;
Reid Spencer93c40032007-03-19 18:40:50 +0000371 NextValNum = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000372 }
373
374 void FunctionDone() {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000375 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000376 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000377 GenerateError("Undefined reference to label " +
Reid Spencer93c40032007-03-19 18:40:50 +0000378 BBForwardRefs.begin()->second->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000379 return;
380 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000381
382 // Resolve all forward references now.
383 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
384
385 Values.clear(); // Clear out function local definitions
Reid Spencer93c40032007-03-19 18:40:50 +0000386 BBForwardRefs.clear();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000387 CurrentFunction = 0;
388 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000389 Linkage = GlobalValue::ExternalLinkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000390 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000391 }
392} CurFun; // Info for the current function...
393
394static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
395
396
397//===----------------------------------------------------------------------===//
398// Code to handle definitions of all the types
399//===----------------------------------------------------------------------===//
400
Reid Spencer93c40032007-03-19 18:40:50 +0000401static void InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) {
402 // Things that have names or are void typed don't get slot numbers
403 if (V->hasName() || (V->getType() == Type::VoidTy))
404 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000405
Reid Spencer93c40032007-03-19 18:40:50 +0000406 // In the case of function values, we have to allow for the forward reference
407 // of basic blocks, which are included in the numbering. Consequently, we keep
408 // track of the next insertion location with NextValNum. When a BB gets
409 // inserted, it could change the size of the CurFun.Values vector.
410 if (&ValueTab == &CurFun.Values) {
411 if (ValueTab.size() <= CurFun.NextValNum)
412 ValueTab.resize(CurFun.NextValNum+1);
413 ValueTab[CurFun.NextValNum++] = V;
414 return;
415 }
416 // For all other lists, its okay to just tack it on the back of the vector.
417 ValueTab.push_back(V);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000418}
419
420static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
421 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000422 case ValID::LocalID: // Is it a numbered definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000423 // Module constants occupy the lowest numbered slots...
Reid Spencer41dff5e2007-01-26 08:05:27 +0000424 if (D.Num < CurModule.Types.size())
425 return CurModule.Types[D.Num];
Reid Spencer68a24bd2005-08-27 18:50:39 +0000426 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000427 case ValID::LocalName: // Is it a named definition?
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000428 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.getName())) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000429 D.destroy(); // Free old strdup'd memory...
430 return N;
431 }
432 break;
433 default:
Reid Spencerb5334b02007-02-05 10:18:06 +0000434 GenerateError("Internal parser error: Invalid symbol type reference");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000435 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000436 }
437
438 // If we reached here, we referenced either a symbol that we don't know about
439 // or an id number that hasn't been read yet. We may be referencing something
440 // forward, so just create an entry to be resolved later and get to it...
441 //
442 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
443
444
445 if (inFunctionScope()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000446 if (D.Type == ValID::LocalName) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000447 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000448 return 0;
449 } else {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000450 GenerateError("Reference to an undefined type: #" + utostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000451 return 0;
452 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000453 }
454
Reid Spencer861d9d62006-11-28 07:29:44 +0000455 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000456 if (I != CurModule.LateResolveTypes.end())
Reid Spencer861d9d62006-11-28 07:29:44 +0000457 return I->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000458
Reid Spencer861d9d62006-11-28 07:29:44 +0000459 Type *Typ = OpaqueType::get();
460 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
461 return Typ;
Reid Spencera132e042006-12-03 05:46:11 +0000462 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000463
Reid Spencer93c40032007-03-19 18:40:50 +0000464// getExistingVal - Look up the value specified by the provided type and
Reid Spencer68a24bd2005-08-27 18:50:39 +0000465// the provided ValID. If the value exists and has already been defined, return
466// it. Otherwise return null.
467//
Reid Spencer93c40032007-03-19 18:40:50 +0000468static Value *getExistingVal(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000469 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000470 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000471 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000472 return 0;
473 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000474
475 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000476 case ValID::LocalID: { // Is it a numbered definition?
Reid Spencer41dff5e2007-01-26 08:05:27 +0000477 // Check that the number is within bounds.
Reid Spencer93c40032007-03-19 18:40:50 +0000478 if (D.Num >= CurFun.Values.size())
479 return 0;
480 Value *Result = CurFun.Values[D.Num];
481 if (Ty != Result->getType()) {
482 GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" +
483 Result->getType()->getDescription() + "' does not match "
484 "expected type, '" + Ty->getDescription() + "'");
485 return 0;
486 }
487 return Result;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000488 }
489 case ValID::GlobalID: { // Is it a numbered definition?
Reid Spencer93c40032007-03-19 18:40:50 +0000490 if (D.Num >= CurModule.Values.size())
Reid Spenceref9b9a72007-02-05 20:47:22 +0000491 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000492 Value *Result = CurModule.Values[D.Num];
493 if (Ty != Result->getType()) {
494 GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" +
495 Result->getType()->getDescription() + "' does not match "
496 "expected type, '" + Ty->getDescription() + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +0000497 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000498 }
499 return Result;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000500 }
Reid Spencer41dff5e2007-01-26 08:05:27 +0000501
502 case ValID::LocalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000503 if (!inFunctionScope())
504 return 0;
505 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000506 Value *N = SymTab.lookup(D.getName());
Reid Spenceref9b9a72007-02-05 20:47:22 +0000507 if (N == 0)
508 return 0;
509 if (N->getType() != Ty)
510 return 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000511
512 D.destroy(); // Free old strdup'd memory...
513 return N;
514 }
515 case ValID::GlobalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000516 ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000517 Value *N = SymTab.lookup(D.getName());
Reid Spenceref9b9a72007-02-05 20:47:22 +0000518 if (N == 0)
519 return 0;
520 if (N->getType() != Ty)
521 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000522
523 D.destroy(); // Free old strdup'd memory...
524 return N;
525 }
526
527 // Check to make sure that "Ty" is an integral type, and that our
528 // value will fit into the specified type...
529 case ValID::ConstSIntVal: // Is it a constant pool reference??
Reid Spencerb83eb642006-10-20 07:07:24 +0000530 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000531 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000532 itostr(D.ConstPool64) + "' is invalid for type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000533 Ty->getDescription() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000534 return 0;
535 }
Reid Spencer49d273e2007-03-19 20:40:51 +0000536 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000537
538 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Reid Spencerb83eb642006-10-20 07:07:24 +0000539 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
540 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000541 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
Reid Spencerb5334b02007-02-05 10:18:06 +0000542 "' is invalid or out of range");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000543 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000544 } else { // This is really a signed reference. Transmogrify.
Reid Spencer49d273e2007-03-19 20:40:51 +0000545 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000546 }
547 } else {
Reid Spencerb83eb642006-10-20 07:07:24 +0000548 return ConstantInt::get(Ty, D.UConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000549 }
550
551 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Dale Johannesencdd509a2007-09-07 21:07:57 +0000552 if (!ConstantFP::isValueValidForType(Ty, *D.ConstPoolFP)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000553 GenerateError("FP constant invalid for type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000554 return 0;
555 }
Dale Johannesenc72cd7e2007-09-11 18:33:39 +0000556 // Lexer has no type info, so builds all float and double FP constants
557 // as double. Fix this here. Long double does not need this.
558 if (&D.ConstPoolFP->getSemantics() == &APFloat::IEEEdouble &&
559 Ty==Type::FloatTy)
Dale Johannesencdd509a2007-09-07 21:07:57 +0000560 D.ConstPoolFP->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
561 return ConstantFP::get(Ty, *D.ConstPoolFP);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000562
563 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000564 if (!isa<PointerType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000565 GenerateError("Cannot create a a non pointer null");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000566 return 0;
567 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000568 return ConstantPointerNull::get(cast<PointerType>(Ty));
569
570 case ValID::ConstUndefVal: // Is it an undef value?
571 return UndefValue::get(Ty);
572
Chris Lattner7aa61892005-12-21 17:53:23 +0000573 case ValID::ConstZeroVal: // Is it a zero value?
574 return Constant::getNullValue(Ty);
575
Reid Spencer68a24bd2005-08-27 18:50:39 +0000576 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000577 if (D.ConstantValue->getType() != Ty) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000578 GenerateError("Constant expression type different from required type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000579 return 0;
580 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000581 return D.ConstantValue;
582
Chris Lattner0e9c3762006-01-25 22:27:16 +0000583 case ValID::InlineAsmVal: { // Inline asm expression
584 const PointerType *PTy = dyn_cast<PointerType>(Ty);
585 const FunctionType *FTy =
586 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000587 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000588 GenerateError("Invalid type for asm constraint string");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000589 return 0;
590 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000591 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
592 D.IAD->HasSideEffects);
593 D.destroy(); // Free InlineAsmDescriptor.
594 return IA;
595 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000596 default:
Reid Spencera9720f52007-02-05 17:04:00 +0000597 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000598 return 0;
599 } // End of switch
600
Reid Spencera9720f52007-02-05 17:04:00 +0000601 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000602 return 0;
603}
604
Reid Spencer93c40032007-03-19 18:40:50 +0000605// getVal - This function is identical to getExistingVal, except that if a
Reid Spencer68a24bd2005-08-27 18:50:39 +0000606// value is not already defined, it "improvises" by creating a placeholder var
607// that looks and acts just like the requested variable. When the value is
608// defined later, all uses of the placeholder variable are replaced with the
609// real thing.
610//
611static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000612 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000613 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000614 return 0;
615 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000616
617 // See if the value has already been defined.
Reid Spencer93c40032007-03-19 18:40:50 +0000618 Value *V = getExistingVal(Ty, ID);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000619 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000620 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000621
Reid Spencer5b7e7532006-09-28 19:28:24 +0000622 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000623 GenerateError("Invalid use of a composite type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000624 return 0;
625 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000626
627 // If we reached here, we referenced either a symbol that we don't know about
628 // or an id number that hasn't been read yet. We may be referencing something
629 // forward, so just create an entry to be resolved later and get to it...
630 //
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000631 switch (ID.Type) {
632 case ValID::GlobalName:
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000633 case ValID::GlobalID: {
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000634 const PointerType *PTy = dyn_cast<PointerType>(Ty);
635 if (!PTy) {
636 GenerateError("Invalid type for reference to global" );
637 return 0;
638 }
639 const Type* ElTy = PTy->getElementType();
640 if (const FunctionType *FTy = dyn_cast<FunctionType>(ElTy))
641 V = new Function(FTy, GlobalValue::ExternalLinkage);
642 else
Christopher Lamba8ed9bf2007-12-11 09:02:08 +0000643 V = new GlobalVariable(ElTy, false, GlobalValue::ExternalLinkage, 0, "",
644 (Module*)0, false, PTy->getAddressSpace());
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000645 break;
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000646 }
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000647 default:
648 V = new Argument(Ty);
649 }
650
Reid Spencer68a24bd2005-08-27 18:50:39 +0000651 // Remember where this forward reference came from. FIXME, shouldn't we try
652 // to recycle these things??
653 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
Duncan Sandsdc024672007-11-27 13:23:08 +0000654 LLLgetLineNo())));
Reid Spencer68a24bd2005-08-27 18:50:39 +0000655
656 if (inFunctionScope())
657 InsertValue(V, CurFun.LateResolveValues);
658 else
659 InsertValue(V, CurModule.LateResolveValues);
660 return V;
661}
662
Reid Spencer93c40032007-03-19 18:40:50 +0000663/// defineBBVal - This is a definition of a new basic block with the specified
664/// identifier which must be the same as CurFun.NextValNum, if its numeric.
665static BasicBlock *defineBBVal(const ValID &ID) {
Reid Spencera9720f52007-02-05 17:04:00 +0000666 assert(inFunctionScope() && "Can't get basic block at global scope!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000667
Reid Spencer68a24bd2005-08-27 18:50:39 +0000668 BasicBlock *BB = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000669
Reid Spencer93c40032007-03-19 18:40:50 +0000670 // First, see if this was forward referenced
Reid Spencer68a24bd2005-08-27 18:50:39 +0000671
Reid Spencer93c40032007-03-19 18:40:50 +0000672 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
673 if (BBI != CurFun.BBForwardRefs.end()) {
674 BB = BBI->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000675 // The forward declaration could have been inserted anywhere in the
676 // function: insert it into the correct place now.
677 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
678 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
Reid Spencer93c40032007-03-19 18:40:50 +0000679
Reid Spencer66728ef2007-03-20 01:13:36 +0000680 // We're about to erase the entry, save the key so we can clean it up.
681 ValID Tmp = BBI->first;
682
Reid Spencer93c40032007-03-19 18:40:50 +0000683 // Erase the forward ref from the map as its no longer "forward"
684 CurFun.BBForwardRefs.erase(ID);
685
Reid Spencer66728ef2007-03-20 01:13:36 +0000686 // The key has been removed from the map but so we don't want to leave
687 // strdup'd memory around so destroy it too.
688 Tmp.destroy();
689
Reid Spencer93c40032007-03-19 18:40:50 +0000690 // If its a numbered definition, bump the number and set the BB value.
691 if (ID.Type == ValID::LocalID) {
692 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
693 InsertValue(BB);
694 }
695
696 ID.destroy();
697 return BB;
698 }
699
700 // We haven't seen this BB before and its first mention is a definition.
701 // Just create it and return it.
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000702 std::string Name (ID.Type == ValID::LocalName ? ID.getName() : "");
Reid Spencer93c40032007-03-19 18:40:50 +0000703 BB = new BasicBlock(Name, CurFun.CurrentFunction);
704 if (ID.Type == ValID::LocalID) {
705 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
706 InsertValue(BB);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000707 }
Reid Spencer93c40032007-03-19 18:40:50 +0000708
709 ID.destroy(); // Free strdup'd memory
710 return BB;
711}
712
713/// getBBVal - get an existing BB value or create a forward reference for it.
714///
715static BasicBlock *getBBVal(const ValID &ID) {
716 assert(inFunctionScope() && "Can't get basic block at global scope!");
717
718 BasicBlock *BB = 0;
719
720 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
721 if (BBI != CurFun.BBForwardRefs.end()) {
722 BB = BBI->second;
723 } if (ID.Type == ValID::LocalName) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000724 std::string Name = ID.getName();
Reid Spencer93c40032007-03-19 18:40:50 +0000725 Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
726 if (N)
727 if (N->getType()->getTypeID() == Type::LabelTyID)
728 BB = cast<BasicBlock>(N);
729 else
730 GenerateError("Reference to label '" + Name + "' is actually of type '"+
731 N->getType()->getDescription() + "'");
732 } else if (ID.Type == ValID::LocalID) {
733 if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) {
734 if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID)
735 BB = cast<BasicBlock>(CurFun.Values[ID.Num]);
736 else
737 GenerateError("Reference to label '%" + utostr(ID.Num) +
738 "' is actually of type '"+
739 CurFun.Values[ID.Num]->getType()->getDescription() + "'");
740 }
741 } else {
742 GenerateError("Illegal label reference " + ID.getName());
743 return 0;
744 }
745
746 // If its already been defined, return it now.
747 if (BB) {
748 ID.destroy(); // Free strdup'd memory.
749 return BB;
750 }
751
752 // Otherwise, this block has not been seen before, create it.
753 std::string Name;
754 if (ID.Type == ValID::LocalName)
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000755 Name = ID.getName();
Reid Spencer93c40032007-03-19 18:40:50 +0000756 BB = new BasicBlock(Name, CurFun.CurrentFunction);
757
758 // Insert it in the forward refs map.
759 CurFun.BBForwardRefs[ID] = BB;
760
Reid Spencer68a24bd2005-08-27 18:50:39 +0000761 return BB;
762}
763
764
765//===----------------------------------------------------------------------===//
766// Code to handle forward references in instructions
767//===----------------------------------------------------------------------===//
768//
769// This code handles the late binding needed with statements that reference
770// values not defined yet... for example, a forward branch, or the PHI node for
771// a loop body.
772//
773// This keeps a table (CurFun.LateResolveValues) of all such forward references
774// and back patchs after we are done.
775//
776
777// ResolveDefinitions - If we could not resolve some defs at parsing
778// time (forward branches, phi functions for loops, etc...) resolve the
779// defs now...
780//
781static void
Reid Spencer93c40032007-03-19 18:40:50 +0000782ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000783 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
Reid Spencer93c40032007-03-19 18:40:50 +0000784 while (!LateResolvers.empty()) {
785 Value *V = LateResolvers.back();
786 LateResolvers.pop_back();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000787
Reid Spencer93c40032007-03-19 18:40:50 +0000788 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
789 CurModule.PlaceHolderInfo.find(V);
790 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000791
Reid Spencer93c40032007-03-19 18:40:50 +0000792 ValID &DID = PHI->second.first;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000793
Reid Spencer93c40032007-03-19 18:40:50 +0000794 Value *TheRealValue = getExistingVal(V->getType(), DID);
795 if (TriggerError)
796 return;
797 if (TheRealValue) {
798 V->replaceAllUsesWith(TheRealValue);
799 delete V;
800 CurModule.PlaceHolderInfo.erase(PHI);
801 } else if (FutureLateResolvers) {
802 // Functions have their unresolved items forwarded to the module late
803 // resolver table
804 InsertValue(V, *FutureLateResolvers);
805 } else {
806 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
807 GenerateError("Reference to an invalid definition: '" +DID.getName()+
808 "' of type '" + V->getType()->getDescription() + "'",
809 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000810 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000811 } else {
Reid Spencer93c40032007-03-19 18:40:50 +0000812 GenerateError("Reference to an invalid definition: #" +
813 itostr(DID.Num) + " of type '" +
814 V->getType()->getDescription() + "'",
815 PHI->second.second);
816 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000817 }
818 }
819 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000820 LateResolvers.clear();
821}
822
823// ResolveTypeTo - A brand new type was just declared. This means that (if
824// name is not null) things referencing Name can be resolved. Otherwise, things
825// refering to the number can be resolved. Do this now.
826//
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000827static void ResolveTypeTo(std::string *Name, const Type *ToTy) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000828 ValID D;
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000829 if (Name)
830 D = ValID::createLocalName(*Name);
831 else
832 D = ValID::createLocalID(CurModule.Types.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +0000833
Reid Spencer861d9d62006-11-28 07:29:44 +0000834 std::map<ValID, PATypeHolder>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +0000835 CurModule.LateResolveTypes.find(D);
836 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer861d9d62006-11-28 07:29:44 +0000837 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000838 CurModule.LateResolveTypes.erase(I);
839 }
840}
841
842// setValueName - Set the specified value to the name given. The name may be
843// null potentially, in which case this is a noop. The string passed in is
844// assumed to be a malloc'd string buffer, and is free'd by this function.
845//
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000846static void setValueName(Value *V, std::string *NameStr) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000847 if (!NameStr) return;
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000848 std::string Name(*NameStr); // Copy string
849 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +0000850
Reid Spencer41dff5e2007-01-26 08:05:27 +0000851 if (V->getType() == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000852 GenerateError("Can't assign name '" + Name+"' to value with void type");
Reid Spencer41dff5e2007-01-26 08:05:27 +0000853 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000854 }
Reid Spencer41dff5e2007-01-26 08:05:27 +0000855
Reid Spencera9720f52007-02-05 17:04:00 +0000856 assert(inFunctionScope() && "Must be in function scope!");
Reid Spenceref9b9a72007-02-05 20:47:22 +0000857 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
858 if (ST.lookup(Name)) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000859 GenerateError("Redefinition of value '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000860 V->getType()->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +0000861 return;
862 }
863
864 // Set the name.
865 V->setName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000866}
867
868/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
869/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +0000870static GlobalVariable *
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000871ParseGlobalVariable(std::string *NameStr,
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000872 GlobalValue::LinkageTypes Linkage,
873 GlobalValue::VisibilityTypes Visibility,
Chris Lattnerb475c422005-11-12 18:22:38 +0000874 bool isConstantGlobal, const Type *Ty,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +0000875 Constant *Initializer, bool IsThreadLocal,
876 unsigned AddressSpace = 0) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000877 if (isa<FunctionType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000878 GenerateError("Cannot declare global vars of function type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000879 return 0;
880 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000881
Christopher Lamba8ed9bf2007-12-11 09:02:08 +0000882 const PointerType *PTy = PointerType::get(Ty, AddressSpace);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000883
884 std::string Name;
885 if (NameStr) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000886 Name = *NameStr; // Copy string
887 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +0000888 }
889
890 // See if this global value was forward referenced. If so, recycle the
891 // object.
892 ValID ID;
893 if (!Name.empty()) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000894 ID = ValID::createGlobalName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000895 } else {
Reid Spencer93c40032007-03-19 18:40:50 +0000896 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +0000897 }
898
899 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
900 // Move the global to the end of the list, from whereever it was
901 // previously inserted.
902 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
903 CurModule.CurrentModule->getGlobalList().remove(GV);
904 CurModule.CurrentModule->getGlobalList().push_back(GV);
905 GV->setInitializer(Initializer);
906 GV->setLinkage(Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000907 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000908 GV->setConstant(isConstantGlobal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +0000909 GV->setThreadLocal(IsThreadLocal);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000910 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000911 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000912 }
913
Reid Spenceref9b9a72007-02-05 20:47:22 +0000914 // If this global has a name
Reid Spencer68a24bd2005-08-27 18:50:39 +0000915 if (!Name.empty()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +0000916 // if the global we're parsing has an initializer (is a definition) and
917 // has external linkage.
918 if (Initializer && Linkage != GlobalValue::InternalLinkage)
919 // If there is already a global with external linkage with this name
920 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
921 // If we allow this GVar to get created, it will be renamed in the
922 // symbol table because it conflicts with an existing GVar. We can't
923 // allow redefinition of GVars whose linking indicates that their name
924 // must stay the same. Issue the error.
925 GenerateError("Redefinition of global variable named '" + Name +
926 "' of type '" + Ty->getDescription() + "'");
927 return 0;
928 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000929 }
930
931 // Otherwise there is no existing GV to use, create one now.
932 GlobalVariable *GV =
933 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +0000934 CurModule.CurrentModule, IsThreadLocal, AddressSpace);
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000935 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000936 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000937 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000938}
939
940// setTypeName - Set the specified type to the name given. The name may be
941// null potentially, in which case this is a noop. The string passed in is
942// assumed to be a malloc'd string buffer, and is freed by this function.
943//
944// This function returns true if the type has already been defined, but is
945// allowed to be redefined in the specified context. If the name is a new name
946// for the type plane, it is inserted and false is returned.
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000947static bool setTypeName(const Type *T, std::string *NameStr) {
Reid Spencera9720f52007-02-05 17:04:00 +0000948 assert(!inFunctionScope() && "Can't give types function-local names!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000949 if (NameStr == 0) return false;
950
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000951 std::string Name(*NameStr); // Copy string
952 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +0000953
954 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +0000955 if (T == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000956 GenerateError("Can't assign name '" + Name + "' to the void type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000957 return false;
958 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000959
960 // Set the type name, checking for conflicts as we do so.
961 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
962
963 if (AlreadyExists) { // Inserting a name that is already defined???
964 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
Reid Spencera9720f52007-02-05 17:04:00 +0000965 assert(Existing && "Conflict but no matching type?!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000966
967 // There is only one case where this is allowed: when we are refining an
968 // opaque type. In this case, Existing will be an opaque type.
969 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
970 // We ARE replacing an opaque type!
971 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
972 return true;
973 }
974
975 // Otherwise, this is an attempt to redefine a type. That's okay if
976 // the redefinition is identical to the original. This will be so if
977 // Existing and T point to the same Type object. In this one case we
978 // allow the equivalent redefinition.
979 if (Existing == T) return true; // Yes, it's equal.
980
981 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer63c34452007-01-05 21:51:07 +0000982 GenerateError("Redefinition of type named '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000983 T->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000984 }
985
986 return false;
987}
988
989//===----------------------------------------------------------------------===//
990// Code for handling upreferences in type names...
991//
992
993// TypeContains - Returns true if Ty directly contains E in it.
994//
995static bool TypeContains(const Type *Ty, const Type *E) {
996 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
997 E) != Ty->subtype_end();
998}
999
1000namespace {
1001 struct UpRefRecord {
1002 // NestingLevel - The number of nesting levels that need to be popped before
1003 // this type is resolved.
1004 unsigned NestingLevel;
1005
1006 // LastContainedTy - This is the type at the current binding level for the
1007 // type. Every time we reduce the nesting level, this gets updated.
1008 const Type *LastContainedTy;
1009
1010 // UpRefTy - This is the actual opaque type that the upreference is
1011 // represented with.
1012 OpaqueType *UpRefTy;
1013
1014 UpRefRecord(unsigned NL, OpaqueType *URTy)
1015 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1016 };
1017}
1018
1019// UpRefs - A list of the outstanding upreferences that need to be resolved.
1020static std::vector<UpRefRecord> UpRefs;
1021
1022/// HandleUpRefs - Every time we finish a new layer of types, this function is
1023/// called. It loops through the UpRefs vector, which is a list of the
1024/// currently active types. For each type, if the up reference is contained in
1025/// the newly completed type, we decrement the level count. When the level
1026/// count reaches zero, the upreferenced type is the type that is passed in:
1027/// thus we can complete the cycle.
1028///
1029static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001030 // If Ty isn't abstract, or if there are no up-references in it, then there is
1031 // nothing to resolve here.
1032 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1033
Reid Spencer68a24bd2005-08-27 18:50:39 +00001034 PATypeHolder Ty(ty);
1035 UR_OUT("Type '" << Ty->getDescription() <<
1036 "' newly formed. Resolving upreferences.\n" <<
1037 UpRefs.size() << " upreferences active!\n");
1038
1039 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1040 // to zero), we resolve them all together before we resolve them to Ty. At
1041 // the end of the loop, if there is anything to resolve to Ty, it will be in
1042 // this variable.
1043 OpaqueType *TypeToResolve = 0;
1044
1045 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1046 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1047 << UpRefs[i].second->getDescription() << ") = "
1048 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1049 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1050 // Decrement level of upreference
1051 unsigned Level = --UpRefs[i].NestingLevel;
1052 UpRefs[i].LastContainedTy = Ty;
1053 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1054 if (Level == 0) { // Upreference should be resolved!
1055 if (!TypeToResolve) {
1056 TypeToResolve = UpRefs[i].UpRefTy;
1057 } else {
1058 UR_OUT(" * Resolving upreference for "
1059 << UpRefs[i].second->getDescription() << "\n";
1060 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1061 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1062 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1063 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1064 }
1065 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1066 --i; // Do not skip the next element...
1067 }
1068 }
1069 }
1070
1071 if (TypeToResolve) {
1072 UR_OUT(" * Resolving upreference for "
1073 << UpRefs[i].second->getDescription() << "\n";
1074 std::string OldName = TypeToResolve->getDescription());
1075 TypeToResolve->refineAbstractTypeTo(Ty);
1076 }
1077
1078 return Ty;
1079}
1080
Reid Spencer68a24bd2005-08-27 18:50:39 +00001081//===----------------------------------------------------------------------===//
1082// RunVMAsmParser - Define an interface to this parser
1083//===----------------------------------------------------------------------===//
1084//
Reid Spencer14310612006-12-31 05:40:51 +00001085static Module* RunParser(Module * M);
1086
Duncan Sandsdc024672007-11-27 13:23:08 +00001087Module *llvm::RunVMAsmParser(llvm::MemoryBuffer *MB) {
1088 InitLLLexer(MB);
1089 Module *M = RunParser(new Module(LLLgetFilename()));
1090 FreeLexer();
1091 return M;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001092}
1093
1094
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001095#line 947 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
1096typedef union {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001097 llvm::Module *ModuleVal;
1098 llvm::Function *FunctionVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001099 llvm::BasicBlock *BasicBlockVal;
1100 llvm::TerminatorInst *TermInstVal;
1101 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001102 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001103
Reid Spencera132e042006-12-03 05:46:11 +00001104 const llvm::Type *PrimType;
Reid Spencer14310612006-12-31 05:40:51 +00001105 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencera132e042006-12-03 05:46:11 +00001106 llvm::PATypeHolder *TypeVal;
1107 llvm::Value *ValueVal;
Reid Spencera132e042006-12-03 05:46:11 +00001108 std::vector<llvm::Value*> *ValueList;
Reid Spencer14310612006-12-31 05:40:51 +00001109 llvm::ArgListType *ArgList;
1110 llvm::TypeWithAttrs TypeWithAttrs;
1111 llvm::TypeWithAttrsList *TypeWithAttrsList;
Dale Johanneseneb57ea72007-11-05 21:20:28 +00001112 llvm::ParamList *ParamList;
Reid Spencer14310612006-12-31 05:40:51 +00001113
Reid Spencer68a24bd2005-08-27 18:50:39 +00001114 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001115 std::list<std::pair<llvm::Value*,
1116 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001117 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001118 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001119
1120 llvm::GlobalValue::LinkageTypes Linkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001121 llvm::GlobalValue::VisibilityTypes Visibility;
Reid Spencer7b5d4662007-04-09 06:16:21 +00001122 uint16_t ParamAttrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00001123 llvm::APInt *APIntVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001124 int64_t SInt64Val;
1125 uint64_t UInt64Val;
1126 int SIntVal;
1127 unsigned UIntVal;
Dale Johannesencdd509a2007-09-07 21:07:57 +00001128 llvm::APFloat *FPVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001129 bool BoolVal;
1130
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001131 std::string *StrVal; // This memory must be deleted
1132 llvm::ValID ValIDVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001133
Reid Spencera132e042006-12-03 05:46:11 +00001134 llvm::Instruction::BinaryOps BinaryOpVal;
1135 llvm::Instruction::TermOps TermOpVal;
1136 llvm::Instruction::MemoryOps MemOpVal;
1137 llvm::Instruction::CastOps CastOpVal;
1138 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencera132e042006-12-03 05:46:11 +00001139 llvm::ICmpInst::Predicate IPredicate;
1140 llvm::FCmpInst::Predicate FPredicate;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001141} YYSTYPE;
1142#include <stdio.h>
1143
1144#ifndef __cplusplus
1145#ifndef __STDC__
1146#define const
1147#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001148#endif
1149
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001150
Reid Spencer68a24bd2005-08-27 18:50:39 +00001151
Christopher Lambbf3348d2007-12-12 08:45:45 +00001152#define YYFINAL 619
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001153#define YYFLAG -32768
1154#define YYNTBASE 164
Reid Spencer68a24bd2005-08-27 18:50:39 +00001155
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001156#define YYTRANSLATE(x) ((unsigned)(x) <= 403 ? yytranslate[x] : 247)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001157
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001158static const short yytranslate[] = { 0,
1159 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1160 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1161 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Christopher Lambbf3348d2007-12-12 08:45:45 +00001162 2, 2, 2, 2, 2, 2, 2, 2, 2, 150,
1163 151, 154, 2, 153, 2, 2, 2, 2, 2, 2,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001164 2, 2, 2, 2, 2, 2, 2, 2, 2, 159,
Christopher Lambbf3348d2007-12-12 08:45:45 +00001165 152, 160, 2, 2, 2, 2, 2, 2, 2, 2,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001166 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1167 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1168 156, 155, 158, 2, 2, 2, 2, 2, 163, 2,
1169 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1170 2, 2, 2, 2, 2, 2, 2, 2, 2, 157,
1171 2, 2, 161, 2, 162, 2, 2, 2, 2, 2,
1172 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1173 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1174 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1175 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1176 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1177 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1178 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1179 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1180 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1181 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1182 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1183 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1184 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
1185 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1186 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1187 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
1188 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
1189 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
1190 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1191 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1192 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1193 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
1194 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
1195 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
1196 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
1197 127, 128, 129, 130, 131, 132, 133, 134, 135, 136,
1198 137, 138, 139, 140, 141, 142, 143, 144, 145, 146,
1199 147, 148, 149
1200};
Reid Spencerb8f85052007-07-31 03:50:36 +00001201
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001202#if YYDEBUG != 0
1203static const short yyprhs[] = { 0,
1204 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
1205 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
1206 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
1207 60, 62, 64, 66, 68, 70, 72, 74, 76, 78,
1208 80, 82, 84, 86, 88, 90, 92, 94, 96, 98,
1209 100, 102, 104, 106, 108, 110, 112, 114, 116, 118,
Christopher Lambbf3348d2007-12-12 08:45:45 +00001210 120, 122, 124, 126, 127, 132, 133, 136, 137, 139,
1211 141, 143, 144, 147, 149, 151, 153, 155, 157, 159,
1212 161, 163, 164, 166, 168, 170, 171, 173, 175, 176,
1213 178, 180, 182, 184, 185, 187, 189, 190, 192, 194,
1214 196, 198, 200, 203, 205, 207, 209, 211, 213, 215,
1215 217, 219, 221, 222, 225, 227, 229, 231, 233, 235,
1216 237, 238, 241, 242, 245, 246, 249, 250, 254, 257,
1217 258, 260, 261, 265, 267, 270, 272, 274, 276, 278,
1218 280, 282, 284, 286, 288, 292, 294, 297, 303, 309,
1219 315, 321, 325, 328, 334, 339, 342, 344, 346, 348,
1220 352, 354, 358, 360, 361, 363, 367, 372, 376, 380,
1221 385, 390, 394, 401, 407, 410, 413, 416, 419, 422,
1222 425, 428, 431, 434, 437, 440, 443, 450, 456, 465,
1223 472, 479, 487, 495, 502, 511, 520, 524, 526, 528,
1224 530, 532, 533, 536, 543, 545, 546, 548, 551, 552,
1225 556, 557, 561, 565, 569, 573, 574, 583, 584, 594,
1226 595, 605, 611, 614, 618, 620, 624, 628, 632, 636,
1227 638, 639, 645, 649, 651, 655, 657, 658, 669, 671,
1228 673, 678, 680, 682, 685, 689, 690, 692, 694, 696,
1229 698, 700, 702, 704, 706, 708, 712, 714, 720, 722,
1230 724, 726, 728, 730, 732, 735, 738, 741, 745, 748,
1231 749, 751, 754, 757, 761, 771, 781, 790, 805, 807,
1232 809, 816, 822, 825, 832, 840, 845, 850, 857, 864,
1233 865, 866, 870, 873, 875, 881, 887, 894, 901, 906,
1234 913, 918, 923, 930, 937, 940, 949, 951, 953, 954,
1235 958, 965, 969, 976, 979, 985, 993
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001236};
1237
1238static const short yyrhs[] = { 74,
1239 0, 75, 0, 76, 0, 77, 0, 78, 0, 79,
1240 0, 80, 0, 81, 0, 82, 0, 86, 0, 87,
1241 0, 88, 0, 83, 0, 84, 0, 85, 0, 117,
1242 0, 118, 0, 119, 0, 120, 0, 121, 0, 122,
1243 0, 123, 0, 124, 0, 125, 0, 126, 0, 127,
1244 0, 128, 0, 91, 0, 92, 0, 93, 0, 94,
1245 0, 95, 0, 96, 0, 97, 0, 98, 0, 99,
1246 0, 100, 0, 101, 0, 102, 0, 103, 0, 104,
1247 0, 105, 0, 106, 0, 107, 0, 108, 0, 109,
1248 0, 110, 0, 97, 0, 98, 0, 99, 0, 100,
1249 0, 26, 0, 27, 0, 11, 0, 12, 0, 13,
1250 0, 16, 0, 15, 0, 14, 0, 19, 0, 22,
Christopher Lambbf3348d2007-12-12 08:45:45 +00001251 0, 24, 0, 171, 0, 0, 54, 150, 4, 151,
1252 0, 0, 171, 152, 0, 0, 20, 0, 23, 0,
1253 177, 0, 0, 175, 152, 0, 42, 0, 44, 0,
1254 43, 0, 45, 0, 47, 0, 46, 0, 48, 0,
1255 50, 0, 0, 147, 0, 148, 0, 149, 0, 0,
1256 46, 0, 48, 0, 0, 42, 0, 43, 0, 44,
1257 0, 47, 0, 0, 44, 0, 42, 0, 0, 62,
1258 0, 63, 0, 64, 0, 65, 0, 66, 0, 61,
1259 4, 0, 136, 0, 118, 0, 135, 0, 119, 0,
1260 138, 0, 139, 0, 141, 0, 142, 0, 143, 0,
1261 0, 186, 185, 0, 137, 0, 140, 0, 136, 0,
1262 135, 0, 144, 0, 145, 0, 0, 188, 187, 0,
1263 0, 146, 22, 0, 0, 53, 4, 0, 0, 153,
1264 53, 4, 0, 34, 22, 0, 0, 192, 0, 0,
1265 153, 195, 194, 0, 192, 0, 53, 4, 0, 11,
1266 0, 12, 0, 13, 0, 16, 0, 15, 0, 14,
1267 0, 17, 0, 49, 0, 196, 0, 197, 173, 154,
1268 0, 231, 0, 155, 4, 0, 197, 150, 201, 151,
1269 188, 0, 10, 150, 201, 151, 188, 0, 156, 4,
1270 157, 197, 158, 0, 159, 4, 157, 197, 160, 0,
1271 161, 202, 162, 0, 161, 162, 0, 159, 161, 202,
1272 162, 160, 0, 159, 161, 162, 160, 0, 197, 186,
1273 0, 197, 0, 10, 0, 198, 0, 200, 153, 198,
1274 0, 200, 0, 200, 153, 39, 0, 39, 0, 0,
1275 197, 0, 202, 153, 197, 0, 197, 156, 205, 158,
1276 0, 197, 156, 158, 0, 197, 163, 22, 0, 197,
1277 159, 205, 160, 0, 197, 161, 205, 162, 0, 197,
1278 161, 162, 0, 197, 159, 161, 205, 162, 160, 0,
1279 197, 159, 161, 162, 160, 0, 197, 40, 0, 197,
1280 41, 0, 197, 231, 0, 197, 204, 0, 197, 25,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001281 0, 169, 3, 0, 169, 5, 0, 169, 4, 0,
1282 169, 6, 0, 11, 26, 0, 11, 27, 0, 170,
Christopher Lambbf3348d2007-12-12 08:45:45 +00001283 9, 0, 166, 150, 203, 38, 197, 151, 0, 116,
1284 150, 203, 242, 151, 0, 130, 150, 203, 153, 203,
1285 153, 203, 151, 0, 164, 150, 203, 153, 203, 151,
1286 0, 165, 150, 203, 153, 203, 151, 0, 89, 167,
1287 150, 203, 153, 203, 151, 0, 90, 168, 150, 203,
1288 153, 203, 151, 0, 132, 150, 203, 153, 203, 151,
1289 0, 133, 150, 203, 153, 203, 153, 203, 151, 0,
1290 134, 150, 203, 153, 203, 153, 203, 151, 0, 205,
1291 153, 203, 0, 203, 0, 32, 0, 33, 0, 37,
1292 0, 0, 199, 231, 0, 122, 150, 208, 38, 197,
1293 151, 0, 210, 0, 0, 211, 0, 210, 211, 0,
1294 0, 31, 212, 227, 0, 0, 30, 213, 228, 0,
1295 59, 58, 217, 0, 174, 18, 197, 0, 174, 18,
1296 10, 0, 0, 176, 180, 207, 206, 203, 173, 214,
1297 194, 0, 0, 176, 178, 180, 207, 206, 203, 173,
1298 215, 194, 0, 0, 176, 179, 180, 207, 206, 197,
1299 173, 216, 194, 0, 176, 180, 35, 183, 208, 0,
1300 51, 218, 0, 55, 152, 219, 0, 22, 0, 52,
1301 152, 22, 0, 67, 152, 22, 0, 156, 220, 158,
1302 0, 220, 153, 22, 0, 22, 0, 0, 221, 153,
1303 197, 186, 172, 0, 197, 186, 172, 0, 221, 0,
1304 221, 153, 39, 0, 39, 0, 0, 184, 199, 175,
1305 150, 222, 151, 188, 193, 190, 189, 0, 28, 0,
1306 161, 0, 182, 180, 223, 224, 0, 29, 0, 162,
1307 0, 234, 226, 0, 181, 180, 223, 0, 0, 60,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001308 0, 3, 0, 4, 0, 9, 0, 26, 0, 27,
Christopher Lambbf3348d2007-12-12 08:45:45 +00001309 0, 40, 0, 41, 0, 25, 0, 159, 205, 160,
1310 0, 204, 0, 58, 229, 22, 153, 22, 0, 7,
1311 0, 8, 0, 171, 0, 175, 0, 231, 0, 230,
1312 0, 197, 232, 0, 234, 235, 0, 225, 235, 0,
1313 236, 174, 237, 0, 236, 239, 0, 0, 21, 0,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001314 68, 233, 0, 68, 10, 0, 69, 17, 232, 0,
Christopher Lambbf3348d2007-12-12 08:45:45 +00001315 69, 11, 232, 153, 17, 232, 153, 17, 232, 0,
1316 70, 169, 232, 153, 17, 232, 156, 238, 158, 0,
1317 70, 169, 232, 153, 17, 232, 156, 158, 0, 71,
1318 184, 199, 232, 150, 241, 151, 188, 38, 17, 232,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001319 72, 17, 232, 0, 72, 0, 73, 0, 238, 169,
Christopher Lambbf3348d2007-12-12 08:45:45 +00001320 230, 153, 17, 232, 0, 169, 230, 153, 17, 232,
1321 0, 174, 244, 0, 197, 156, 232, 153, 232, 158,
1322 0, 240, 153, 156, 232, 153, 232, 158, 0, 197,
1323 186, 232, 186, 0, 17, 186, 232, 186, 0, 241,
1324 153, 197, 186, 232, 186, 0, 241, 153, 17, 186,
1325 232, 186, 0, 0, 0, 242, 153, 233, 0, 57,
1326 56, 0, 56, 0, 164, 197, 232, 153, 232, 0,
1327 165, 197, 232, 153, 232, 0, 89, 167, 197, 232,
1328 153, 232, 0, 90, 168, 197, 232, 153, 232, 0,
1329 166, 233, 38, 197, 0, 130, 233, 153, 233, 153,
1330 233, 0, 131, 233, 153, 197, 0, 132, 233, 153,
1331 233, 0, 133, 233, 153, 233, 153, 233, 0, 134,
1332 233, 153, 233, 153, 233, 0, 129, 240, 0, 243,
1333 184, 199, 232, 150, 241, 151, 188, 0, 246, 0,
1334 36, 0, 0, 111, 197, 191, 0, 111, 197, 153,
1335 11, 232, 191, 0, 112, 197, 191, 0, 112, 197,
1336 153, 11, 232, 191, 0, 113, 233, 0, 245, 114,
1337 197, 232, 191, 0, 245, 115, 233, 153, 197, 232,
1338 191, 0, 116, 197, 232, 242, 0
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001339};
1340
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001341#endif
1342
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001343#if YYDEBUG != 0
1344static const short yyrline[] = { 0,
1345 1107, 1107, 1107, 1107, 1107, 1107, 1107, 1107, 1107, 1108,
1346 1108, 1108, 1108, 1108, 1108, 1109, 1109, 1109, 1109, 1109,
1347 1109, 1109, 1110, 1110, 1110, 1110, 1110, 1113, 1113, 1114,
1348 1114, 1115, 1115, 1116, 1116, 1117, 1117, 1121, 1121, 1122,
1349 1122, 1123, 1123, 1124, 1124, 1125, 1125, 1126, 1126, 1127,
1350 1127, 1128, 1129, 1134, 1135, 1135, 1135, 1135, 1135, 1137,
Christopher Lambbf3348d2007-12-12 08:45:45 +00001351 1137, 1137, 1138, 1138, 1140, 1141, 1145, 1149, 1154, 1154,
1352 1156, 1157, 1162, 1168, 1169, 1170, 1171, 1172, 1176, 1177,
1353 1178, 1182, 1183, 1184, 1185, 1189, 1190, 1191, 1195, 1196,
1354 1197, 1198, 1199, 1203, 1204, 1205, 1208, 1208, 1209, 1210,
1355 1211, 1212, 1213, 1221, 1222, 1223, 1224, 1225, 1226, 1227,
1356 1228, 1229, 1232, 1233, 1238, 1239, 1240, 1241, 1242, 1243,
1357 1246, 1247, 1252, 1253, 1260, 1260, 1267, 1267, 1277, 1285,
1358 1285, 1291, 1291, 1293, 1298, 1311, 1311, 1311, 1311, 1311,
1359 1311, 1311, 1314, 1318, 1322, 1329, 1334, 1342, 1372, 1397,
1360 1402, 1412, 1422, 1426, 1436, 1443, 1452, 1459, 1464, 1469,
1361 1476, 1477, 1484, 1491, 1499, 1505, 1517, 1545, 1561, 1588,
1362 1616, 1642, 1662, 1688, 1708, 1720, 1727, 1793, 1803, 1813,
1363 1819, 1829, 1835, 1845, 1850, 1855, 1868, 1880, 1902, 1910,
1364 1916, 1927, 1932, 1937, 1943, 1949, 1958, 1962, 1970, 1970,
1365 1973, 1973, 1976, 1988, 2009, 2014, 2022, 2023, 2027, 2027,
1366 2031, 2031, 2034, 2037, 2061, 2072, 2080, 2083, 2089, 2092,
1367 2099, 2103, 2143, 2146, 2152, 2162, 2166, 2171, 2173, 2178,
1368 2183, 2192, 2202, 2213, 2217, 2226, 2235, 2240, 2374, 2374,
1369 2376, 2385, 2385, 2387, 2392, 2404, 2408, 2413, 2417, 2421,
1370 2425, 2429, 2433, 2437, 2441, 2445, 2470, 2474, 2484, 2488,
1371 2492, 2497, 2504, 2504, 2510, 2519, 2523, 2532, 2541, 2550,
1372 2554, 2561, 2565, 2569, 2574, 2584, 2603, 2612, 2696, 2700,
1373 2707, 2718, 2731, 2741, 2752, 2762, 2773, 2781, 2791, 2798,
1374 2801, 2802, 2809, 2813, 2818, 2834, 2851, 2865, 2879, 2891,
1375 2899, 2906, 2912, 2918, 2924, 2939, 3030, 3035, 3039, 3046,
1376 3053, 3061, 3068, 3076, 3084, 3098, 3115
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001377};
1378#endif
1379
1380
1381#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
1382
1383static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL",
1384"EUINT64VAL","ESAPINTVAL","EUAPINTVAL","LOCALVAL_ID","GLOBALVAL_ID","FPVAL",
1385"VOID","INTTYPE","FLOAT","DOUBLE","X86_FP80","FP128","PPC_FP128","LABEL","TYPE",
1386"LOCALVAR","GLOBALVAR","LABELSTR","STRINGCONSTANT","ATSTRINGCONSTANT","PCTSTRINGCONSTANT",
1387"ZEROINITIALIZER","TRUETOK","FALSETOK","BEGINTOK","ENDTOK","DECLARE","DEFINE",
1388"GLOBAL","CONSTANT","SECTION","ALIAS","VOLATILE","THREAD_LOCAL","TO","DOTDOTDOT",
1389"NULL_TOK","UNDEF","INTERNAL","LINKONCE","WEAK","APPENDING","DLLIMPORT","DLLEXPORT",
1390"EXTERN_WEAK","OPAQUE","EXTERNAL","TARGET","TRIPLE","ALIGN","ADDRSPACE","DEPLIBS",
1391"CALL","TAIL","ASM_TOK","MODULE","SIDEEFFECT","CC_TOK","CCC_TOK","FASTCC_TOK",
1392"COLDCC_TOK","X86_STDCALLCC_TOK","X86_FASTCALLCC_TOK","DATALAYOUT","RET","BR",
1393"SWITCH","INVOKE","UNWIND","UNREACHABLE","ADD","SUB","MUL","UDIV","SDIV","FDIV",
1394"UREM","SREM","FREM","AND","OR","XOR","SHL","LSHR","ASHR","ICMP","FCMP","EQ",
1395"NE","SLT","SGT","SLE","SGE","ULT","UGT","ULE","UGE","OEQ","ONE","OLT","OGT",
1396"OLE","OGE","ORD","UNO","UEQ","UNE","MALLOC","ALLOCA","FREE","LOAD","STORE",
1397"GETELEMENTPTR","TRUNC","ZEXT","SEXT","FPTRUNC","FPEXT","BITCAST","UITOFP","SITOFP",
1398"FPTOUI","FPTOSI","INTTOPTR","PTRTOINT","PHI_TOK","SELECT","VAARG","EXTRACTELEMENT",
1399"INSERTELEMENT","SHUFFLEVECTOR","SIGNEXT","ZEROEXT","NORETURN","INREG","SRET",
1400"NOUNWIND","NOALIAS","BYVAL","NEST","READNONE","READONLY","GC","DEFAULT","HIDDEN",
Christopher Lambbf3348d2007-12-12 08:45:45 +00001401"PROTECTED","'('","')'","'='","','","'*'","'\\\\'","'['","'x'","']'","'<'","'>'",
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001402"'{'","'}'","'c'","ArithmeticOps","LogicalOps","CastOps","IPredicates","FPredicates",
Christopher Lambbf3348d2007-12-12 08:45:45 +00001403"IntType","FPType","LocalName","OptLocalName","OptAddrSpace","OptLocalAssign",
1404"GlobalName","OptGlobalAssign","GlobalAssign","GVInternalLinkage","GVExternalLinkage",
1405"GVVisibilityStyle","FunctionDeclareLinkage","FunctionDefineLinkage","AliasLinkage",
1406"OptCallingConv","ParamAttr","OptParamAttrs","FuncAttr","OptFuncAttrs","OptGC",
1407"OptAlign","OptCAlign","SectionString","OptSection","GlobalVarAttributes","GlobalVarAttribute",
1408"PrimType","Types","ArgType","ResultTypes","ArgTypeList","ArgTypeListI","TypeListI",
1409"ConstVal","ConstExpr","ConstVector","GlobalType","ThreadLocal","AliaseeRef",
1410"Module","DefinitionList","Definition","@1","@2","@3","@4","@5","AsmBlock","TargetDefinition",
1411"LibrariesDefinition","LibList","ArgListH","ArgList","FunctionHeaderH","BEGIN",
1412"FunctionHeader","END","Function","FunctionProto","OptSideEffect","ConstValueRef",
1413"SymbolicValueRef","ValueRef","ResolvedVal","BasicBlockList","BasicBlock","InstructionList",
1414"BBTerminatorInst","JumpTable","Inst","PHIList","ParamList","IndexList","OptTailCall",
1415"InstVal","OptVolatile","MemoryInst", NULL
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001416};
1417#endif
1418
1419static const short yyr1[] = { 0,
1420 164, 164, 164, 164, 164, 164, 164, 164, 164, 165,
1421 165, 165, 165, 165, 165, 166, 166, 166, 166, 166,
1422 166, 166, 166, 166, 166, 166, 166, 167, 167, 167,
1423 167, 167, 167, 167, 167, 167, 167, 168, 168, 168,
1424 168, 168, 168, 168, 168, 168, 168, 168, 168, 168,
1425 168, 168, 168, 169, 170, 170, 170, 170, 170, 171,
1426 171, 171, 172, 172, 173, 173, 174, 174, 175, 175,
Christopher Lambbf3348d2007-12-12 08:45:45 +00001427 176, 176, 177, 178, 178, 178, 178, 178, 179, 179,
1428 179, 180, 180, 180, 180, 181, 181, 181, 182, 182,
1429 182, 182, 182, 183, 183, 183, 184, 184, 184, 184,
1430 184, 184, 184, 185, 185, 185, 185, 185, 185, 185,
1431 185, 185, 186, 186, 187, 187, 187, 187, 187, 187,
1432 188, 188, 189, 189, 190, 190, 191, 191, 192, 193,
1433 193, 194, 194, 195, 195, 196, 196, 196, 196, 196,
1434 196, 196, 197, 197, 197, 197, 197, 197, 197, 197,
1435 197, 197, 197, 197, 197, 198, 199, 199, 200, 200,
1436 201, 201, 201, 201, 202, 202, 203, 203, 203, 203,
1437 203, 203, 203, 203, 203, 203, 203, 203, 203, 203,
1438 203, 203, 203, 203, 203, 203, 204, 204, 204, 204,
1439 204, 204, 204, 204, 204, 204, 205, 205, 206, 206,
1440 207, 207, 208, 208, 209, 209, 210, 210, 212, 211,
1441 213, 211, 211, 211, 211, 214, 211, 215, 211, 216,
1442 211, 211, 211, 211, 217, 218, 218, 219, 220, 220,
1443 220, 221, 221, 222, 222, 222, 222, 223, 224, 224,
1444 225, 226, 226, 227, 228, 229, 229, 230, 230, 230,
1445 230, 230, 230, 230, 230, 230, 230, 230, 231, 231,
1446 231, 231, 232, 232, 233, 234, 234, 235, 236, 236,
1447 236, 237, 237, 237, 237, 237, 237, 237, 237, 237,
1448 238, 238, 239, 240, 240, 241, 241, 241, 241, 241,
1449 242, 242, 243, 243, 244, 244, 244, 244, 244, 244,
1450 244, 244, 244, 244, 244, 244, 244, 245, 245, 246,
1451 246, 246, 246, 246, 246, 246, 246
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001452};
1453
1454static const short yyr2[] = { 0,
1455 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1456 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1457 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1458 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1459 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1460 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Christopher Lambbf3348d2007-12-12 08:45:45 +00001461 1, 1, 1, 0, 4, 0, 2, 0, 1, 1,
1462 1, 0, 2, 1, 1, 1, 1, 1, 1, 1,
1463 1, 0, 1, 1, 1, 0, 1, 1, 0, 1,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001464 1, 1, 1, 0, 1, 1, 0, 1, 1, 1,
Christopher Lambbf3348d2007-12-12 08:45:45 +00001465 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
1466 1, 1, 0, 2, 1, 1, 1, 1, 1, 1,
1467 0, 2, 0, 2, 0, 2, 0, 3, 2, 0,
1468 1, 0, 3, 1, 2, 1, 1, 1, 1, 1,
1469 1, 1, 1, 1, 3, 1, 2, 5, 5, 5,
1470 5, 3, 2, 5, 4, 2, 1, 1, 1, 3,
1471 1, 3, 1, 0, 1, 3, 4, 3, 3, 4,
1472 4, 3, 6, 5, 2, 2, 2, 2, 2, 2,
1473 2, 2, 2, 2, 2, 2, 6, 5, 8, 6,
1474 6, 7, 7, 6, 8, 8, 3, 1, 1, 1,
1475 1, 0, 2, 6, 1, 0, 1, 2, 0, 3,
1476 0, 3, 3, 3, 3, 0, 8, 0, 9, 0,
1477 9, 5, 2, 3, 1, 3, 3, 3, 3, 1,
1478 0, 5, 3, 1, 3, 1, 0, 10, 1, 1,
1479 4, 1, 1, 2, 3, 0, 1, 1, 1, 1,
1480 1, 1, 1, 1, 1, 3, 1, 5, 1, 1,
1481 1, 1, 1, 1, 2, 2, 2, 3, 2, 0,
1482 1, 2, 2, 3, 9, 9, 8, 14, 1, 1,
1483 6, 5, 2, 6, 7, 4, 4, 6, 6, 0,
1484 0, 3, 2, 1, 5, 5, 6, 6, 4, 6,
1485 4, 4, 6, 6, 2, 8, 1, 1, 0, 3,
1486 6, 3, 6, 2, 5, 7, 4
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001487};
1488
Christopher Lambbf3348d2007-12-12 08:45:45 +00001489static const short yydefact[] = { 72,
1490 60, 69, 61, 70, 62, 211, 209, 0, 0, 0,
1491 0, 0, 0, 82, 71, 72, 207, 86, 89, 0,
1492 0, 223, 0, 0, 67, 0, 73, 74, 76, 75,
1493 77, 79, 78, 80, 81, 83, 84, 85, 82, 82,
1494 202, 208, 87, 88, 82, 212, 90, 91, 92, 93,
1495 82, 270, 210, 270, 0, 0, 231, 224, 225, 213,
1496 259, 260, 215, 136, 137, 138, 141, 140, 139, 142,
1497 143, 0, 0, 0, 0, 261, 262, 144, 214, 146,
1498 202, 202, 94, 201, 0, 97, 97, 271, 267, 68,
1499 242, 243, 244, 266, 226, 227, 230, 0, 164, 147,
1500 0, 0, 0, 0, 153, 165, 0, 0, 164, 0,
1501 0, 0, 96, 95, 0, 199, 200, 0, 0, 98,
1502 99, 100, 101, 102, 0, 245, 0, 309, 269, 0,
1503 228, 163, 113, 159, 161, 0, 0, 0, 0, 0,
1504 0, 152, 0, 0, 145, 0, 0, 158, 0, 157,
1505 0, 222, 136, 137, 138, 141, 140, 139, 0, 0,
1506 66, 66, 103, 0, 239, 240, 241, 308, 294, 0,
1507 0, 0, 0, 97, 279, 280, 1, 2, 3, 4,
1508 5, 6, 7, 8, 9, 13, 14, 15, 10, 11,
1509 12, 0, 0, 0, 0, 0, 0, 16, 17, 18,
1510 19, 20, 21, 22, 23, 24, 25, 26, 27, 0,
1511 0, 0, 0, 0, 0, 0, 0, 0, 268, 97,
1512 283, 0, 307, 229, 156, 0, 121, 66, 66, 155,
1513 0, 166, 0, 121, 66, 66, 0, 203, 184, 185,
1514 180, 182, 181, 183, 186, 179, 175, 176, 0, 0,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001515 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Christopher Lambbf3348d2007-12-12 08:45:45 +00001516 0, 0, 178, 177, 216, 0, 293, 273, 66, 272,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001517 0, 0, 54, 0, 0, 28, 29, 30, 31, 32,
1518 33, 34, 35, 36, 37, 0, 52, 53, 48, 49,
1519 50, 51, 38, 39, 40, 41, 42, 43, 44, 45,
Christopher Lambbf3348d2007-12-12 08:45:45 +00001520 46, 47, 0, 127, 127, 314, 66, 66, 305, 0,
1521 0, 0, 0, 0, 66, 66, 0, 0, 0, 0,
1522 105, 107, 106, 104, 108, 109, 110, 111, 112, 114,
1523 162, 160, 149, 150, 151, 154, 65, 148, 218, 220,
1524 0, 0, 0, 0, 0, 0, 0, 0, 168, 198,
1525 0, 0, 0, 172, 0, 169, 0, 0, 0, 132,
1526 237, 248, 249, 250, 255, 251, 252, 253, 254, 246,
1527 0, 257, 264, 263, 265, 0, 274, 0, 0, 66,
1528 66, 0, 310, 0, 312, 291, 0, 0, 0, 0,
1529 0, 0, 0, 0, 0, 0, 0, 66, 0, 118,
1530 117, 115, 116, 119, 120, 122, 132, 132, 0, 0,
1531 0, 291, 0, 0, 0, 0, 0, 167, 153, 165,
1532 0, 170, 171, 0, 0, 0, 0, 217, 236, 113,
1533 234, 0, 247, 0, 0, 0, 0, 0, 0, 0,
1534 0, 0, 0, 317, 0, 0, 0, 301, 302, 0,
1535 0, 0, 0, 299, 0, 127, 0, 219, 221, 66,
1536 0, 0, 0, 0, 0, 0, 0, 197, 174, 0,
1537 0, 0, 0, 0, 0, 134, 132, 64, 0, 121,
1538 0, 256, 0, 0, 290, 0, 0, 127, 128, 127,
1539 0, 0, 0, 0, 0, 0, 295, 296, 290, 0,
1540 315, 66, 204, 0, 0, 188, 0, 0, 0, 0,
1541 173, 0, 0, 66, 129, 135, 133, 63, 233, 235,
1542 113, 130, 0, 0, 0, 113, 113, 0, 297, 298,
1543 311, 313, 292, 0, 0, 300, 303, 304, 0, 127,
1544 0, 0, 0, 194, 0, 0, 190, 191, 187, 64,
1545 131, 125, 258, 0, 0, 0, 0, 121, 0, 284,
1546 0, 121, 316, 192, 193, 0, 0, 0, 232, 0,
1547 123, 0, 277, 0, 0, 105, 107, 113, 113, 0,
1548 113, 113, 285, 306, 189, 195, 196, 126, 0, 238,
1549 275, 0, 276, 0, 287, 286, 0, 0, 0, 124,
1550 0, 0, 0, 113, 113, 0, 0, 0, 289, 288,
1551 282, 0, 0, 281, 0, 278, 0, 0, 0
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001552};
1553
Christopher Lambbf3348d2007-12-12 08:45:45 +00001554static const short yydefgoto[] = { 260,
1555 261, 262, 286, 303, 159, 160, 76, 519, 110, 12,
1556 77, 14, 15, 39, 40, 41, 45, 51, 115, 125,
1557 330, 225, 406, 333, 590, 571, 383, 476, 552, 428,
1558 477, 78, 161, 134, 151, 135, 136, 107, 350, 372,
1559 351, 118, 85, 152, 617, 16, 17, 19, 18, 360,
1560 407, 408, 60, 22, 58, 98, 431, 432, 126, 167,
1561 52, 93, 53, 46, 434, 373, 80, 375, 270, 54,
1562 89, 90, 219, 575, 129, 309, 528, 444, 220, 221,
1563 222, 223
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001564};
1565
Christopher Lambbf3348d2007-12-12 08:45:45 +00001566static const short yypact[] = { 253,
1567-32768,-32768,-32768,-32768,-32768,-32768,-32768, -4, -114, -16,
1568 -103, 46, -78, 12,-32768, 392,-32768, 149, 177, -44,
1569 -31,-32768, -1, 154,-32768, 1529,-32768,-32768,-32768,-32768,
1570-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -37, -37,
1571 203,-32768,-32768,-32768, -37,-32768,-32768,-32768,-32768,-32768,
1572 -37, 190,-32768, 2, 195, 217, 245,-32768,-32768,-32768,
1573-32768,-32768, 124,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1574-32768, 274, 278, 1, 505,-32768,-32768,-32768, 62,-32768,
1575 256, 256, 200,-32768, 119, 224, 224,-32768,-32768, 100,
1576-32768,-32768,-32768,-32768,-32768,-32768,-32768, 57, 1052,-32768,
1577 140, 148, 604, 124,-32768, 62, -69, 157, 1052, 155,
1578 119, 119,-32768,-32768, 1295,-32768,-32768, 1569, 306,-32768,
1579-32768,-32768,-32768,-32768, 1627,-32768, -17, 1851,-32768, 289,
1580-32768,-32768, 62,-32768, 163, 166, 1645, 1645, 158, -58,
1581 1645,-32768, 315, 171,-32768, 1569, 1645, 124, 170, 62,
1582 58,-32768, 41, 314, 318, 320, 321, 329, 226, 330,
1583 1107, 270,-32768, 30,-32768,-32768,-32768,-32768,-32768, 288,
1584 1685, 137, 336, 224,-32768,-32768,-32768,-32768,-32768,-32768,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001585-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
Christopher Lambbf3348d2007-12-12 08:45:45 +00001586-32768, 388, 781, 1645, 1645, 1645, 1645,-32768,-32768,-32768,
1587-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 1645,
1588 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645,-32768, 224,
1589-32768, 70,-32768,-32768, 207, 1374,-32768, -15, -14,-32768,
1590 197, 62, 208,-32768, 270, -13, 1295,-32768,-32768,-32768,
1591-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 388, 781,
1592 212, 213, 214, 220, 221, 1414, 1725, 782, 351, 228,
1593 229, 231,-32768,-32768,-32768, 232,-32768, 124, 696,-32768,
1594 834, 834,-32768, 834, 1627,-32768,-32768,-32768,-32768,-32768,
1595-32768,-32768,-32768,-32768,-32768, 1645,-32768,-32768,-32768,-32768,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001596-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
Christopher Lambbf3348d2007-12-12 08:45:45 +00001597-32768,-32768, 1645, 15, 29,-32768, 696, 7, 205, 223,
1598 235, 236, 237, 238, 696, 696, 346, 1627, 1645, 1645,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001599-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
Christopher Lambbf3348d2007-12-12 08:45:45 +00001600-32768,-32768, 120,-32768,-32768,-32768,-32768, 120,-32768, 155,
1601 358, 248, 249, 1569, 1569, 1569, 1569, 1569,-32768,-32768,
1602 69, 1007, -61,-32768, -56,-32768, 1569, 1569, 1569, 251,
1603 1454,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 341,
1604 1569,-32768,-32768,-32768,-32768, 252,-32768, 255, 834, 696,
1605 696, 19,-32768, 23,-32768,-32768, 834, 246, 1645, 1645,
1606 1645, 1645, 1645, 260, 266, 1645, 834, 696, 271,-32768,
1607-32768,-32768,-32768,-32768,-32768,-32768, 251, 251, 1645, 1569,
1608 1569,-32768, 272, 275, 276, 277, 1569,-32768, 267, 962,
1609 -55,-32768,-32768, 286, 291, 371, 18,-32768,-32768, 62,
1610 292, 280,-32768, 420, -57, 431, 433, 302, 300, 301,
1611 834, 453, 834, 305, 307, 834, 309, 62,-32768, 310,
1612 311, 834, 834, 62, 316, 312, 1645,-32768,-32768, -18,
1613 323, 324, 92, 1569, 1569, 1569, 1569,-32768,-32768, 299,
1614 1569, 1569, 1645, 446, 469,-32768, 251, 729, 1472,-32768,
1615 339,-32768, 834, 834, 1743, 834, 834, 312,-32768, 312,
1616 1645, 834, 340, 1645, 1645, 1645,-32768,-32768, 1743, 421,
1617-32768, 696,-32768, 1569, 1569,-32768, 342, 343, 344, 345,
1618-32768, 348, 349, 16,-32768,-32768,-32768,-32768,-32768,-32768,
1619 62, -6, 474, 350, 352, 64, 62, 101,-32768,-32768,
1620-32768,-32768,-32768, 347, 834,-32768,-32768,-32768, 115, 312,
1621 353, 356, 1569,-32768, 1569, 1569,-32768,-32768,-32768, 729,
1622-32768, 448,-32768, 485, -5, 555, 555,-32768, 1800,-32768,
1623 365,-32768,-32768,-32768,-32768, 363, 379, 380,-32768, 530,
1624 390, 834,-32768, 1246, -2, 359, 389,-32768,-32768, 5,
1625 64, 62,-32768, 120,-32768,-32768,-32768,-32768, 516,-32768,
1626-32768, 391,-32768, 1246, 207, 207, 524, 555, 555,-32768,
1627 525, 394, 834,-32768,-32768, 834, 526, 473, 207, 207,
1628-32768, 834, 531,-32768, 834,-32768, 551, 556,-32768
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001629};
1630
Christopher Lambbf3348d2007-12-12 08:45:45 +00001631static const short yypgoto[] = { 427,
1632 437, 439, 319, 322, -172,-32768, 0, 11, -149, 480,
1633 10,-32768,-32768,-32768,-32768, 49,-32768,-32768,-32768, -147,
1634-32768, -401,-32768, -222,-32768,-32768, -281, 51,-32768, -375,
1635-32768,-32768, -24, 357, -117,-32768, 462, 481, -111, -157,
1636 -243, 169, 210, 354,-32768,-32768, 560,-32768,-32768,-32768,
1637-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 498,-32768,
1638-32768,-32768,-32768,-32768,-32768, -557, -46, -66, -193,-32768,
1639 532,-32768,-32768,-32768,-32768,-32768, 88, 176,-32768,-32768,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001640-32768,-32768
1641};
1642
1643
Christopher Lambbf3348d2007-12-12 08:45:45 +00001644#define YYLAST 1985
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001645
1646
1647static const short yytable[] = { 11,
Christopher Lambbf3348d2007-12-12 08:45:45 +00001648 274, 79, 306, 263, 102, 273, 162, 164, 273, 13,
1649 165, 338, 265, 353, 355, 11, 592, 310, 311, 312,
1650 313, 314, 88, 385, 317, 13, 275, 474, 478, 441,
1651 91, 458, 459, 443, 235, 108, 602, 23, 108, 108,
1652 108, 24, 597, -54, -54, -54, -54, 20, 25, 2,
1653 106, 474, 4, 28, 29, 30, 31, 32, 33, 34,
1654 108, 35, 21, 26, 61, 62, 239, 240, 108, 108,
1655 475, 442, 318, 27, 133, 442, 1, 2, 106, 3,
1656 4, 5, 108, 141, 133, 339, 340, 81, 82, 11,
1657 150, 417, 142, 86, 141, 417, 417, 417, 422, 87,
1658 150, 517, 482, 231, 238, 423, 470, 55, 421, 36,
1659 37, 38, 228, 229, 264, 108, 232, -142, 1, 550,
1660 56, 3, 236, 5, 556, 557, 399, 435, 400, 401,
1661 402, 109, 503, 403, 109, 109, 109, 404, 405, 400,
1662 401, 402, 334, 166, 403, 335, 269, 271, 404, 405,
1663 116, 117, 573, 272, 57, 593, 109, 379, 36, 37,
1664 38, 103, 387, 92, 109, 109, 549, 382, -66, 304,
1665 305, 269, 307, 266, 501, 59, 595, 596, 109, 598,
1666 599, 384, -66, 319, 320, 308, 269, 269, 269, 269,
1667 269, 315, 316, 269, 43, 447, 44, 449, 450, 451,
1668 397, 133, 609, 610, 376, 377, 531, 378, 532, 130,
1669 88, 109, 150, -142, 131, -66, 95, -142, 47, 48,
1670 49, 417, 374, 50, 374, 374, 418, 374, 241, 242,
1671 243, 244, 412, 413, 414, 415, 416, 83, 96, 84,
1672 386, 113, 506, 114, 491, 424, 425, 426, 394, 395,
1673 150, 558, -206, 559, 400, 401, 402, 522, 563, 403,
1674 374, 380, 263, 404, 405, 562, 97, 559, 374, 374,
1675 -68, 1, 2, 99, 3, 4, 5, 100, 381, 146,
1676 147, 101, 6, 7, 119, 120, 121, 122, 123, 124,
1677 111, 112, 84, 150, 398, 269, 137, 533, 461, 462,
1678 536, 537, 538, 8, 138, 468, 143, 9, 145, 163,
1679 224, 10, 438, 439, 440, 226, 227, 230, 233, 237,
1680 445, 234, -55, 108, 321, 322, -56, 420, -59, -58,
1681 455, 456, 374, 374, 374, 580, 430, -57, 245, 584,
1682 374, 323, 324, 267, 325, 326, 273, 327, 328, 329,
1683 374, 374, 507, 508, 509, 510, 336, 388, 337, 512,
1684 513, 344, 345, 346, 269, 448, 269, 269, 269, 347,
1685 348, 454, 356, 264, 488, 389, 490, 357, 358, 493,
1686 359, 361, 574, 396, 460, 497, 498, 390, 391, 392,
1687 393, -205, 541, 542, 374, 409, 374, 410, 411, 374,
1688 433, 446, 594, 427, 436, 374, 374, 437, 473, -68,
1689 1, 2, 452, 3, 4, 5, 524, 525, 453, 529,
1690 530, 6, 7, 457, 464, 534, 469, 465, 466, 467,
1691 480, 566, 502, 567, 568, 540, 374, 374, 471, 374,
1692 374, 481, 8, 472, 479, 374, 9, 483, 514, 484,
1693 10, 485, 486, 487, 521, 374, 489, 491, 511, 492,
1694 527, 494, 495, 496, 500, 499, 269, 515, 561, 269,
1695 269, 269, 516, 442, 527, 504, 505, 518, 276, 277,
1696 278, 279, 280, 281, 282, 283, 284, 285, 374, 578,
1697 579, 523, 535, 544, 543, 553, 545, 546, 547, 548,
1698 570, 572, 554, 564, 560, 591, 565, 555, -17, 374,
1699 374, 61, 62, 585, 104, 64, 65, 66, 67, 68,
1700 69, 70, 583, 1, 2, 374, 3, 4, 5, 586,
1701 587, 604, 605, 588, 582, 589, 608, 600, -18, 611,
1702 603, 606, 612, 601, 613, 614, 607, 615, 616, 518,
1703 618, 374, 374, 71, 216, 619, 374, 362, 363, 374,
1704 569, 61, 62, 364, 217, 374, 218, 342, 374, 128,
1705 144, 343, 551, 1, 2, 42, 3, 4, 5, 365,
1706 366, 367, 332, 140, 127, 94, 539, 463, 0, 0,
1707 341, 0, 0, 0, 368, 369, 0, 0, 0, 0,
1708 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1709 61, 62, 370, 104, 64, 65, 66, 67, 68, 69,
1710 70, 0, 1, 2, 0, 3, 4, 5, 177, 178,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001711 179, 180, 181, 182, 183, 184, 185, 186, 187, 188,
Christopher Lambbf3348d2007-12-12 08:45:45 +00001712 189, 190, 191, 249, 250, 0, 0, 0, 0, 0,
1713 0, 0, 71, 0, 0, 0, 0, 0, 0, 72,
1714 73, 0, 0, 74, 0, 75, 105, 0, 0, 0,
1715 251, 198, 576, 577, 201, 202, 203, 204, 205, 206,
1716 207, 208, 209, 0, 252, 0, 253, 254, 255, 323,
1717 324, 0, 325, 326, 0, 327, 328, 329, 362, 363,
1718 0, 0, 61, 62, 364, 0, 0, 0, 0, 0,
1719 0, 0, 0, 371, 1, 2, 0, 3, 4, 5,
1720 365, 366, 367, 0, 0, 0, 0, 0, 0, 0,
1721 0, 0, 0, 0, 0, 368, 369, 0, 0, 0,
1722 0, 0, 0, 0, 0, 0, 0, 1, 0, 108,
1723 3, 0, 5, 370, 0, 0, 0, 0, 72, 73,
1724 0, 0, 74, 0, 75, 139, 0, 0, 0, 177,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001725 178, 179, 180, 181, 182, 183, 184, 185, 186, 187,
Christopher Lambbf3348d2007-12-12 08:45:45 +00001726 188, 189, 190, 191, 249, 250, 0, 0, 61, 62,
1727 0, 104, 153, 154, 155, 156, 157, 158, 70, 0,
1728 1, 2, 0, 3, 4, 5, 287, 288, 0, 0,
1729 0, 251, 198, 199, 200, 201, 202, 203, 204, 205,
1730 206, 207, 208, 209, 0, 252, 0, 253, 254, 255,
1731 71, 0, 0, 0, 0, 0, 362, 363, 0, 0,
1732 61, 62, 364, 0, 0, 109, 321, 322, 0, 0,
1733 0, 0, 1, 2, 371, 3, 4, 5, 365, 366,
1734 367, 0, 0, 323, 324, 0, 325, 326, 0, 327,
1735 328, 329, 0, 368, 369, 0, 0, 289, 290, 291,
1736 292, 293, 294, 295, 296, 297, 298, 299, 300, 301,
1737 302, 370, 0, 0, 0, 0, 0, 0, 0, 0,
1738 0, 0, 0, 0, 0, 0, 0, 177, 178, 179,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001739 180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
Christopher Lambbf3348d2007-12-12 08:45:45 +00001740 190, 191, 249, 250, 0, 0, 0, 0, 0, 0,
1741 0, 0, 0, 0, 0, 0, 72, 73, 0, 0,
1742 74, 0, 75, 354, 0, 0, 0, 0, 0, 251,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001743 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
Christopher Lambbf3348d2007-12-12 08:45:45 +00001744 208, 209, 0, 252, 0, 253, 254, 255, 61, 62,
1745 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1746 1, 2, 0, 3, 4, 5, 246, 0, 0, 0,
1747 0, 0, 371, 0, 0, 0, 0, 0, 0, 0,
1748 0, 247, 248, 0, 0, 0, 0, 0, 0, 0,
1749 0, 0, 0, 61, 62, 108, 104, 153, 154, 155,
1750 156, 157, 158, 70, 0, 1, 2, 0, 3, 4,
1751 5, 0, 0, 0, 0, 177, 178, 179, 180, 181,
1752 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
1753 249, 250, 0, 0, 0, 71, 0, 0, 61, 62,
1754 0, 104, 64, 65, 66, 67, 68, 69, 70, 0,
1755 1, 2, 0, 3, 4, 5, 0, 251, 198, 199,
1756 200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
1757 132, 252, 0, 253, 254, 255, 0, 0, 0, 0,
1758 71, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1759 0, 109, 0, 61, 62, -66, 0, 256, 0, 0,
1760 257, 0, 258, 0, 259, 1, 2, 0, 3, 4,
1761 5, 246, 0, 0, 0, 0, 0, 0, 0, 0,
1762 0, 0, 0, 0, 0, 0, 247, 248, 0, 0,
1763 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1764 108, 72, 73, 0, 0, 74, 0, 75, 419, 0,
1765 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1766 177, 178, 179, 180, 181, 182, 183, 184, 185, 186,
1767 187, 188, 189, 190, 191, 249, 250, 0, 0, 0,
1768 0, 0, 0, 0, 0, 0, 72, 73, 0, 0,
1769 74, 0, 75, 0, 0, 0, 0, 0, 0, 0,
1770 0, 0, 251, 198, 199, 200, 201, 202, 203, 204,
1771 205, 206, 207, 208, 209, 0, 252, 0, 253, 254,
1772 255, 0, 0, 0, 0, 0, 0, 0, 362, 363,
1773 0, 0, 0, 0, 364, 0, 109, 0, 0, 0,
1774 0, 0, 256, 0, 0, 257, 0, 258, 0, 259,
1775 365, 366, 367, 0, 0, 0, 0, 0, 0, 0,
1776 0, 0, 0, 0, 0, 368, 369, 0, 0, 0,
1777 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1778 0, 61, 62, 370, 148, 64, 65, 66, 67, 68,
1779 69, 70, 0, 1, 2, 0, 3, 4, 5, 177,
1780 178, 179, 180, 181, 182, 183, 184, 185, 186, 187,
1781 188, 189, 190, 191, 249, 250, 0, 0, 0, 0,
1782 0, 0, 0, 71, 0, 0, 0, 0, 0, 0,
1783 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1784 0, 251, 198, 199, 200, 201, 202, 203, 204, 205,
1785 206, 207, 208, 209, 0, 252, 0, 253, 254, 255,
1786 61, 62, 0, 104, 64, 65, 66, 67, 68, 69,
1787 70, 0, 1, 2, 0, 3, 4, 5, 0, 0,
1788 0, 0, 0, 0, 371, 0, 0, 0, 0, 0,
1789 0, 0, 331, 0, 0, 0, 149, 0, 0, 0,
1790 61, 62, 71, 104, 153, 154, 155, 156, 157, 158,
1791 70, 0, 1, 2, 0, 3, 4, 5, 0, 0,
1792 0, 0, 0, 0, 0, 0, 0, 0, 0, 72,
1793 73, 0, 0, 74, 0, 75, 0, 0, 0, 0,
1794 61, 62, 71, 104, 64, 65, 66, 67, 68, 69,
1795 70, 0, 1, 2, 0, 3, 4, 5, 61, 62,
1796 0, 104, 64, 65, 66, 67, 68, 69, 70, 0,
1797 1, 2, 429, 3, 4, 5, 0, 0, 0, 0,
1798 0, 0, 71, 0, 0, 0, 0, 0, 0, 0,
1799 520, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1800 71, 0, 0, 0, 0, 0, 0, 0, 72, 73,
1801 0, 0, 74, 0, 75, 61, 62, 0, 63, 64,
1802 65, 66, 67, 68, 69, 70, 0, 1, 2, 0,
1803 3, 4, 5, 0, 0, 0, 0, 0, 0, 0,
1804 0, 0, 0, 0, 0, 0, 0, 0, 72, 73,
1805 0, 349, 74, 0, 75, 61, 62, 71, 104, 153,
1806 154, 155, 156, 157, 158, 70, 0, 1, 2, 0,
1807 3, 4, 5, 0, 0, 0, 0, 0, 0, 0,
1808 0, 0, 0, 0, 0, 0, 0, 0, 72, 73,
1809 0, 0, 74, 0, 75, 0, 0, 71, 0, 0,
1810 0, 0, 0, 0, 0, 0, 72, 73, 0, 0,
1811 74, 0, 75, 61, 62, 0, 148, 64, 65, 66,
1812 67, 68, 69, 70, 0, 1, 2, 0, 3, 4,
1813 5, 61, 62, 0, 104, 64, 65, 66, 67, 68,
1814 69, 70, 0, 1, 2, 0, 3, 4, 5, 0,
1815 0, 0, 0, 0, 0, 71, 0, 0, 0, 0,
1816 0, 0, 0, 72, 73, 0, 0, 74, 0, 75,
1817 0, 61, 62, 71, 268, 64, 65, 66, 67, 68,
1818 69, 70, 0, 1, 2, 0, 3, 4, 5, 0,
1819 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1820 0, 0, 0, 72, 73, 0, 0, 74, 0, 75,
1821 0, 61, 62, 71, 104, 153, 154, 155, 156, 157,
1822 158, 70, 0, 1, 2, 0, 3, 4, 5, 61,
1823 62, 0, 104, 64, 65, 66, 67, 68, 69, 526,
1824 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
1825 0, 0, 0, 71, 0, 0, 0, 0, 0, 0,
1826 0, 72, 73, 0, 0, 74, 0, 75, 0, 0,
1827 0, 71, 0, 0, 0, 0, 0, 0, 0, 72,
1828 73, 0, 0, 74, 0, 75, 61, 62, 0, 104,
1829 64, 65, 66, 67, 68, 69, 581, 0, 1, 2,
1830 0, 3, 4, 5, 0, 0, 0, 0, 0, 0,
1831 0, 0, 0, 0, 0, 0, 0, 0, 0, 72,
1832 73, 0, 0, 74, 0, 75, 0, 0, 71, 0,
1833 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1834 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1835 0, 0, 0, 0, 0, 0, 0, 0, 0, 72,
1836 73, 0, 0, 74, 0, 352, 168, 0, 0, 0,
1837 0, 0, 0, 0, 0, 0, 0, 72, 73, 0,
1838 0, 74, 0, 75, 0, 0, 169, 170, 0, 0,
1839 0, 0, 0, 0, 0, 0, 0, 0, 171, 172,
1840 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
1841 183, 184, 185, 186, 187, 188, 189, 190, 191, 192,
1842 193, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1843 0, 0, 0, 0, 72, 73, 0, 0, 74, 0,
1844 75, 194, 195, 196, 0, 0, 197, 198, 199, 200,
1845 201, 202, 203, 204, 205, 206, 207, 208, 209, 210,
1846 211, 212, 213, 214, 215
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001847};
1848
1849static const short yycheck[] = { 0,
Christopher Lambbf3348d2007-12-12 08:45:45 +00001850 173, 26, 196, 161, 4, 11, 118, 125, 11, 0,
1851 28, 234, 162, 257, 258, 16, 574, 211, 212, 213,
1852 214, 215, 21, 305, 218, 16, 174, 34, 430, 11,
1853 29, 407, 408, 11, 146, 54, 594, 152, 54, 54,
1854 54, 58, 38, 3, 4, 5, 6, 52, 152, 20,
1855 75, 34, 23, 42, 43, 44, 45, 46, 47, 48,
1856 54, 50, 67, 18, 7, 8, 26, 27, 54, 54,
1857 53, 53, 220, 152, 99, 53, 19, 20, 103, 22,
1858 23, 24, 54, 153, 109, 235, 236, 39, 40, 90,
1859 115, 153, 162, 45, 153, 153, 153, 153, 160, 51,
1860 125, 477, 160, 162, 151, 162, 162, 152, 352, 147,
1861 148, 149, 137, 138, 161, 54, 141, 54, 19, 521,
1862 152, 22, 147, 24, 526, 527, 320, 371, 135, 136,
1863 137, 150, 151, 140, 150, 150, 150, 144, 145, 135,
1864 136, 137, 158, 161, 140, 160, 171, 11, 144, 145,
1865 32, 33, 158, 17, 156, 158, 150, 275, 147, 148,
1866 149, 161, 156, 162, 150, 150, 151, 153, 154, 194,
1867 195, 196, 197, 164, 456, 22, 578, 579, 150, 581,
1868 582, 153, 154, 114, 115, 210, 211, 212, 213, 214,
1869 215, 216, 217, 218, 46, 389, 48, 391, 392, 393,
1870 318, 226, 604, 605, 271, 272, 488, 274, 490, 153,
1871 21, 150, 237, 150, 158, 154, 22, 154, 42, 43,
1872 44, 153, 269, 47, 271, 272, 158, 274, 3, 4,
1873 5, 6, 344, 345, 346, 347, 348, 35, 22, 37,
1874 307, 42, 151, 44, 153, 357, 358, 359, 315, 316,
1875 275, 151, 0, 153, 135, 136, 137, 480, 540, 140,
1876 307, 286, 420, 144, 145, 151, 22, 153, 315, 316,
1877 18, 19, 20, 150, 22, 23, 24, 4, 303, 111,
1878 112, 4, 30, 31, 61, 62, 63, 64, 65, 66,
1879 81, 82, 37, 318, 319, 320, 157, 491, 410, 411,
1880 494, 495, 496, 51, 157, 417, 150, 55, 154, 4,
1881 22, 59, 379, 380, 381, 153, 151, 160, 4, 150,
1882 387, 151, 9, 54, 118, 119, 9, 352, 9, 9,
1883 397, 398, 379, 380, 381, 558, 361, 9, 9, 562,
1884 387, 135, 136, 56, 138, 139, 11, 141, 142, 143,
1885 397, 398, 464, 465, 466, 467, 160, 153, 151, 471,
1886 472, 150, 150, 150, 389, 390, 391, 392, 393, 150,
1887 150, 396, 22, 420, 441, 153, 443, 150, 150, 446,
1888 150, 150, 555, 38, 409, 452, 453, 153, 153, 153,
1889 153, 0, 504, 505, 441, 38, 443, 150, 150, 446,
1890 60, 156, 575, 153, 153, 452, 453, 153, 38, 18,
1891 19, 20, 153, 22, 23, 24, 483, 484, 153, 486,
1892 487, 30, 31, 153, 153, 492, 160, 153, 153, 153,
1893 151, 543, 457, 545, 546, 502, 483, 484, 153, 486,
1894 487, 22, 51, 153, 153, 492, 55, 17, 473, 17,
1895 59, 150, 153, 153, 479, 502, 4, 153, 160, 153,
1896 485, 153, 153, 153, 153, 150, 491, 22, 535, 494,
1897 495, 496, 4, 53, 499, 153, 153, 478, 91, 92,
1898 93, 94, 95, 96, 97, 98, 99, 100, 535, 556,
1899 557, 153, 153, 151, 153, 22, 153, 153, 151, 151,
1900 53, 17, 153, 151, 158, 572, 151, 156, 150, 556,
1901 557, 7, 8, 151, 10, 11, 12, 13, 14, 15,
1902 16, 17, 158, 19, 20, 572, 22, 23, 24, 151,
1903 151, 598, 599, 4, 559, 146, 603, 22, 150, 606,
1904 17, 17, 17, 153, 72, 612, 153, 17, 615, 550,
1905 0, 598, 599, 49, 128, 0, 603, 3, 4, 606,
1906 550, 7, 8, 9, 128, 612, 128, 249, 615, 90,
1907 109, 250, 522, 19, 20, 16, 22, 23, 24, 25,
1908 26, 27, 226, 103, 87, 54, 499, 412, -1, -1,
1909 237, -1, -1, -1, 40, 41, -1, -1, -1, -1,
1910 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1911 7, 8, 58, 10, 11, 12, 13, 14, 15, 16,
1912 17, -1, 19, 20, -1, 22, 23, 24, 74, 75,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001913 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
1914 86, 87, 88, 89, 90, -1, -1, -1, -1, -1,
Christopher Lambbf3348d2007-12-12 08:45:45 +00001915 -1, -1, 49, -1, -1, -1, -1, -1, -1, 155,
1916 156, -1, -1, 159, -1, 161, 162, -1, -1, -1,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001917 116, 117, 118, 119, 120, 121, 122, 123, 124, 125,
1918 126, 127, 128, -1, 130, -1, 132, 133, 134, 135,
1919 136, -1, 138, 139, -1, 141, 142, 143, 3, 4,
1920 -1, -1, 7, 8, 9, -1, -1, -1, -1, -1,
1921 -1, -1, -1, 159, 19, 20, -1, 22, 23, 24,
1922 25, 26, 27, -1, -1, -1, -1, -1, -1, -1,
1923 -1, -1, -1, -1, -1, 40, 41, -1, -1, -1,
Christopher Lambbf3348d2007-12-12 08:45:45 +00001924 -1, -1, -1, -1, -1, -1, -1, 19, -1, 54,
1925 22, -1, 24, 58, -1, -1, -1, -1, 155, 156,
1926 -1, -1, 159, -1, 161, 162, -1, -1, -1, 74,
1927 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1928 85, 86, 87, 88, 89, 90, -1, -1, 7, 8,
1929 -1, 10, 11, 12, 13, 14, 15, 16, 17, -1,
1930 19, 20, -1, 22, 23, 24, 26, 27, -1, -1,
1931 -1, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1932 125, 126, 127, 128, -1, 130, -1, 132, 133, 134,
1933 49, -1, -1, -1, -1, -1, 3, 4, -1, -1,
1934 7, 8, 9, -1, -1, 150, 118, 119, -1, -1,
1935 -1, -1, 19, 20, 159, 22, 23, 24, 25, 26,
1936 27, -1, -1, 135, 136, -1, 138, 139, -1, 141,
1937 142, 143, -1, 40, 41, -1, -1, 97, 98, 99,
1938 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
1939 110, 58, -1, -1, -1, -1, -1, -1, -1, -1,
1940 -1, -1, -1, -1, -1, -1, -1, 74, 75, 76,
1941 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1942 87, 88, 89, 90, -1, -1, -1, -1, -1, -1,
1943 -1, -1, -1, -1, -1, -1, 155, 156, -1, -1,
1944 159, -1, 161, 162, -1, -1, -1, -1, -1, 116,
1945 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
1946 127, 128, -1, 130, -1, 132, 133, 134, 7, 8,
1947 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1948 19, 20, -1, 22, 23, 24, 25, -1, -1, -1,
1949 -1, -1, 159, -1, -1, -1, -1, -1, -1, -1,
1950 -1, 40, 41, -1, -1, -1, -1, -1, -1, -1,
1951 -1, -1, -1, 7, 8, 54, 10, 11, 12, 13,
1952 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
1953 24, -1, -1, -1, -1, 74, 75, 76, 77, 78,
1954 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
1955 89, 90, -1, -1, -1, 49, -1, -1, 7, 8,
1956 -1, 10, 11, 12, 13, 14, 15, 16, 17, -1,
1957 19, 20, -1, 22, 23, 24, -1, 116, 117, 118,
1958 119, 120, 121, 122, 123, 124, 125, 126, 127, 128,
1959 39, 130, -1, 132, 133, 134, -1, -1, -1, -1,
1960 49, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1961 -1, 150, -1, 7, 8, 154, -1, 156, -1, -1,
1962 159, -1, 161, -1, 163, 19, 20, -1, 22, 23,
1963 24, 25, -1, -1, -1, -1, -1, -1, -1, -1,
1964 -1, -1, -1, -1, -1, -1, 40, 41, -1, -1,
1965 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1966 54, 155, 156, -1, -1, 159, -1, 161, 162, -1,
1967 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1968 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
1969 84, 85, 86, 87, 88, 89, 90, -1, -1, -1,
1970 -1, -1, -1, -1, -1, -1, 155, 156, -1, -1,
1971 159, -1, 161, -1, -1, -1, -1, -1, -1, -1,
1972 -1, -1, 116, 117, 118, 119, 120, 121, 122, 123,
1973 124, 125, 126, 127, 128, -1, 130, -1, 132, 133,
1974 134, -1, -1, -1, -1, -1, -1, -1, 3, 4,
1975 -1, -1, -1, -1, 9, -1, 150, -1, -1, -1,
1976 -1, -1, 156, -1, -1, 159, -1, 161, -1, 163,
1977 25, 26, 27, -1, -1, -1, -1, -1, -1, -1,
1978 -1, -1, -1, -1, -1, 40, 41, -1, -1, -1,
1979 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001980 -1, 7, 8, 58, 10, 11, 12, 13, 14, 15,
1981 16, 17, -1, 19, 20, -1, 22, 23, 24, 74,
1982 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
Christopher Lambbf3348d2007-12-12 08:45:45 +00001983 85, 86, 87, 88, 89, 90, -1, -1, -1, -1,
1984 -1, -1, -1, 49, -1, -1, -1, -1, -1, -1,
1985 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001986 -1, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1987 125, 126, 127, 128, -1, 130, -1, 132, 133, 134,
Christopher Lambbf3348d2007-12-12 08:45:45 +00001988 7, 8, -1, 10, 11, 12, 13, 14, 15, 16,
1989 17, -1, 19, 20, -1, 22, 23, 24, -1, -1,
1990 -1, -1, -1, -1, 159, -1, -1, -1, -1, -1,
1991 -1, -1, 39, -1, -1, -1, 122, -1, -1, -1,
1992 7, 8, 49, 10, 11, 12, 13, 14, 15, 16,
1993 17, -1, 19, 20, -1, 22, 23, 24, -1, -1,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00001994 -1, -1, -1, -1, -1, -1, -1, -1, -1, 155,
Christopher Lambbf3348d2007-12-12 08:45:45 +00001995 156, -1, -1, 159, -1, 161, -1, -1, -1, -1,
1996 7, 8, 49, 10, 11, 12, 13, 14, 15, 16,
1997 17, -1, 19, 20, -1, 22, 23, 24, 7, 8,
1998 -1, 10, 11, 12, 13, 14, 15, 16, 17, -1,
1999 19, 20, 39, 22, 23, 24, -1, -1, -1, -1,
2000 -1, -1, 49, -1, -1, -1, -1, -1, -1, -1,
2001 39, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2002 49, -1, -1, -1, -1, -1, -1, -1, 155, 156,
2003 -1, -1, 159, -1, 161, 7, 8, -1, 10, 11,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002004 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
2005 22, 23, 24, -1, -1, -1, -1, -1, -1, -1,
Christopher Lambbf3348d2007-12-12 08:45:45 +00002006 -1, -1, -1, -1, -1, -1, -1, -1, 155, 156,
2007 -1, 158, 159, -1, 161, 7, 8, 49, 10, 11,
2008 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
2009 22, 23, 24, -1, -1, -1, -1, -1, -1, -1,
2010 -1, -1, -1, -1, -1, -1, -1, -1, 155, 156,
2011 -1, -1, 159, -1, 161, -1, -1, 49, -1, -1,
2012 -1, -1, -1, -1, -1, -1, 155, 156, -1, -1,
2013 159, -1, 161, 7, 8, -1, 10, 11, 12, 13,
2014 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
2015 24, 7, 8, -1, 10, 11, 12, 13, 14, 15,
2016 16, 17, -1, 19, 20, -1, 22, 23, 24, -1,
2017 -1, -1, -1, -1, -1, 49, -1, -1, -1, -1,
2018 -1, -1, -1, 155, 156, -1, -1, 159, -1, 161,
2019 -1, 7, 8, 49, 10, 11, 12, 13, 14, 15,
2020 16, 17, -1, 19, 20, -1, 22, 23, 24, -1,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002021 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002022 -1, -1, -1, 155, 156, -1, -1, 159, -1, 161,
Christopher Lambbf3348d2007-12-12 08:45:45 +00002023 -1, 7, 8, 49, 10, 11, 12, 13, 14, 15,
2024 16, 17, -1, 19, 20, -1, 22, 23, 24, 7,
2025 8, -1, 10, 11, 12, 13, 14, 15, 16, 17,
2026 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
2027 -1, -1, -1, 49, -1, -1, -1, -1, -1, -1,
2028 -1, 155, 156, -1, -1, 159, -1, 161, -1, -1,
2029 -1, 49, -1, -1, -1, -1, -1, -1, -1, 155,
2030 156, -1, -1, 159, -1, 161, 7, 8, -1, 10,
2031 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
2032 -1, 22, 23, 24, -1, -1, -1, -1, -1, -1,
2033 -1, -1, -1, -1, -1, -1, -1, -1, -1, 155,
2034 156, -1, -1, 159, -1, 161, -1, -1, 49, -1,
2035 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2036 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2037 -1, -1, -1, -1, -1, -1, -1, -1, -1, 155,
2038 156, -1, -1, 159, -1, 161, 36, -1, -1, -1,
2039 -1, -1, -1, -1, -1, -1, -1, 155, 156, -1,
2040 -1, 159, -1, 161, -1, -1, 56, 57, -1, -1,
2041 -1, -1, -1, -1, -1, -1, -1, -1, 68, 69,
2042 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
2043 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
2044 90, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2045 -1, -1, -1, -1, 155, 156, -1, -1, 159, -1,
2046 161, 111, 112, 113, -1, -1, 116, 117, 118, 119,
2047 120, 121, 122, 123, 124, 125, 126, 127, 128, 129,
2048 130, 131, 132, 133, 134
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002049};
2050/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
2051#line 3 "/usr/share/bison.simple"
2052/* This file comes from bison-1.28. */
2053
2054/* Skeleton output parser for bison,
2055 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
2056
2057 This program is free software; you can redistribute it and/or modify
2058 it under the terms of the GNU General Public License as published by
2059 the Free Software Foundation; either version 2, or (at your option)
2060 any later version.
2061
2062 This program is distributed in the hope that it will be useful,
2063 but WITHOUT ANY WARRANTY; without even the implied warranty of
2064 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2065 GNU General Public License for more details.
2066
2067 You should have received a copy of the GNU General Public License
2068 along with this program; if not, write to the Free Software
2069 Foundation, Inc., 59 Temple Place - Suite 330,
2070 Boston, MA 02111-1307, USA. */
2071
2072/* As a special exception, when this file is copied by Bison into a
2073 Bison output file, you may use that output file without restriction.
2074 This special exception was added by the Free Software Foundation
2075 in version 1.24 of Bison. */
2076
2077/* This is the parser code that is written into each bison parser
2078 when the %semantic_parser declaration is not specified in the grammar.
2079 It was written by Richard Stallman by simplifying the hairy parser
2080 used when %semantic_parser is specified. */
2081
2082#ifndef YYSTACK_USE_ALLOCA
2083#ifdef alloca
2084#define YYSTACK_USE_ALLOCA
2085#else /* alloca not defined */
2086#ifdef __GNUC__
2087#define YYSTACK_USE_ALLOCA
2088#define alloca __builtin_alloca
2089#else /* not GNU C. */
2090#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
2091#define YYSTACK_USE_ALLOCA
2092#include <alloca.h>
2093#else /* not sparc */
2094/* We think this test detects Watcom and Microsoft C. */
2095/* This used to test MSDOS, but that is a bad idea
2096 since that symbol is in the user namespace. */
2097#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
2098#if 0 /* No need for malloc.h, which pollutes the namespace;
2099 instead, just don't use alloca. */
2100#include <malloc.h>
2101#endif
2102#else /* not MSDOS, or __TURBOC__ */
2103#if defined(_AIX)
2104/* I don't know what this was needed for, but it pollutes the namespace.
2105 So I turned it off. rms, 2 May 1997. */
2106/* #include <malloc.h> */
2107 #pragma alloca
2108#define YYSTACK_USE_ALLOCA
2109#else /* not MSDOS, or __TURBOC__, or _AIX */
2110#if 0
2111#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
2112 and on HPUX 10. Eventually we can turn this on. */
2113#define YYSTACK_USE_ALLOCA
2114#define alloca __builtin_alloca
2115#endif /* __hpux */
2116#endif
2117#endif /* not _AIX */
2118#endif /* not MSDOS, or __TURBOC__ */
2119#endif /* not sparc */
2120#endif /* not GNU C */
2121#endif /* alloca not defined */
2122#endif /* YYSTACK_USE_ALLOCA not defined */
2123
2124#ifdef YYSTACK_USE_ALLOCA
2125#define YYSTACK_ALLOC alloca
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002126#else
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002127#define YYSTACK_ALLOC malloc
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002128#endif
2129
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002130/* Note: there must be only one dollar sign in this file.
2131 It is replaced by the list of actions, each action
2132 as one case of the switch. */
David Greene718fda32007-08-01 03:59:32 +00002133
Reid Spencer68a24bd2005-08-27 18:50:39 +00002134#define yyerrok (yyerrstatus = 0)
2135#define yyclearin (yychar = YYEMPTY)
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002136#define YYEMPTY -2
Reid Spencer68a24bd2005-08-27 18:50:39 +00002137#define YYEOF 0
Reid Spencer68a24bd2005-08-27 18:50:39 +00002138#define YYACCEPT goto yyacceptlab
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002139#define YYABORT goto yyabortlab
2140#define YYERROR goto yyerrlab1
2141/* Like YYERROR except do call yyerror.
2142 This remains here temporarily to ease the
2143 transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002144 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002145#define YYFAIL goto yyerrlab
Reid Spencer68a24bd2005-08-27 18:50:39 +00002146#define YYRECOVERING() (!!yyerrstatus)
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002147#define YYBACKUP(token, value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002148do \
2149 if (yychar == YYEMPTY && yylen == 1) \
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002150 { yychar = (token), yylval = (value); \
2151 yychar1 = YYTRANSLATE (yychar); \
2152 YYPOPSTACK; \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002153 goto yybackup; \
2154 } \
2155 else \
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002156 { yyerror ("syntax error: cannot back up"); YYERROR; } \
2157while (0)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002158
Reid Spencer68a24bd2005-08-27 18:50:39 +00002159#define YYTERROR 1
2160#define YYERRCODE 256
2161
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002162#ifndef YYPURE
2163#define YYLEX yylex()
Reid Spencer68a24bd2005-08-27 18:50:39 +00002164#endif
2165
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002166#ifdef YYPURE
2167#ifdef YYLSP_NEEDED
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002168#ifdef YYLEX_PARAM
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002169#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002170#else
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002171#define YYLEX yylex(&yylval, &yylloc)
2172#endif
2173#else /* not YYLSP_NEEDED */
2174#ifdef YYLEX_PARAM
2175#define YYLEX yylex(&yylval, YYLEX_PARAM)
2176#else
2177#define YYLEX yylex(&yylval)
2178#endif
2179#endif /* not YYLSP_NEEDED */
Dale Johannesencdd509a2007-09-07 21:07:57 +00002180#endif
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002181
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002182/* If nonreentrant, generate the variables here */
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002183
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002184#ifndef YYPURE
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002185
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002186int yychar; /* the lookahead symbol */
2187YYSTYPE yylval; /* the semantic value of the */
2188 /* lookahead symbol */
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002189
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002190#ifdef YYLSP_NEEDED
2191YYLTYPE yylloc; /* location data for the lookahead */
2192 /* symbol */
Dale Johannesencdd509a2007-09-07 21:07:57 +00002193#endif
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002194
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002195int yynerrs; /* number of parse errors so far */
2196#endif /* not YYPURE */
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002197
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002198#if YYDEBUG != 0
2199int yydebug; /* nonzero means print parse trace */
2200/* Since this is uninitialized, it does not stop multiple parsers
2201 from coexisting. */
Chris Lattner0275cff2007-08-06 21:00:46 +00002202#endif
David Greene5fd22a82007-09-04 18:46:50 +00002203
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002204/* YYINITDEPTH indicates the initial size of the parser's stacks */
David Greene5fd22a82007-09-04 18:46:50 +00002205
Reid Spencer68a24bd2005-08-27 18:50:39 +00002206#ifndef YYINITDEPTH
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002207#define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00002208#endif
2209
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002210/* YYMAXDEPTH is the maximum size the stacks can grow to
2211 (effective only if the built-in stack extension method is used). */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002212
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002213#if YYMAXDEPTH == 0
2214#undef YYMAXDEPTH
2215#endif
David Greene718fda32007-08-01 03:59:32 +00002216
Reid Spencer68a24bd2005-08-27 18:50:39 +00002217#ifndef YYMAXDEPTH
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002218#define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00002219#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002220
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002221/* Define __yy_memcpy. Note that the size argument
2222 should be passed with type unsigned int, because that is what the non-GCC
2223 definitions require. With GCC, __builtin_memcpy takes an arg
2224 of type size_t, but it can handle unsigned int. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002225
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002226#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
2227#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
2228#else /* not GNU C or C++ */
2229#ifndef __cplusplus
Reid Spencer68a24bd2005-08-27 18:50:39 +00002230
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002231/* This is the most reliable way to avoid incompatibilities
2232 in available built-in functions on various systems. */
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002233static void
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002234__yy_memcpy (to, from, count)
2235 char *to;
2236 char *from;
2237 unsigned int count;
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002238{
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002239 register char *f = from;
2240 register char *t = to;
2241 register int i = count;
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002242
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002243 while (i-- > 0)
2244 *t++ = *f++;
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002245}
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002246
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002247#else /* __cplusplus */
2248
2249/* This is the most reliable way to avoid incompatibilities
2250 in available built-in functions on various systems. */
2251static void
2252__yy_memcpy (char *to, char *from, unsigned int count)
2253{
2254 register char *t = to;
2255 register char *f = from;
2256 register int i = count;
2257
2258 while (i-- > 0)
2259 *t++ = *f++;
2260}
2261
2262#endif
2263#endif
2264
2265#line 217 "/usr/share/bison.simple"
2266
2267/* The user can define YYPARSE_PARAM as the name of an argument to be passed
2268 into yyparse. The argument should have type void *.
2269 It should actually point to an object.
2270 Grammar actions can access the variable by casting it
2271 to the proper pointer type. */
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002272
2273#ifdef YYPARSE_PARAM
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002274#ifdef __cplusplus
2275#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
2276#define YYPARSE_PARAM_DECL
2277#else /* not __cplusplus */
2278#define YYPARSE_PARAM_ARG YYPARSE_PARAM
2279#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
2280#endif /* not __cplusplus */
2281#else /* not YYPARSE_PARAM */
2282#define YYPARSE_PARAM_ARG
2283#define YYPARSE_PARAM_DECL
2284#endif /* not YYPARSE_PARAM */
2285
2286/* Prevent warning if -Wstrict-prototypes. */
2287#ifdef __GNUC__
2288#ifdef YYPARSE_PARAM
2289int yyparse (void *);
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002290#else
David Greene5fd22a82007-09-04 18:46:50 +00002291int yyparse (void);
Dale Johannesencdd509a2007-09-07 21:07:57 +00002292#endif
2293#endif
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002294
2295int
2296yyparse(YYPARSE_PARAM_ARG)
2297 YYPARSE_PARAM_DECL
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002298{
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002299 register int yystate;
2300 register int yyn;
2301 register short *yyssp;
2302 register YYSTYPE *yyvsp;
2303 int yyerrstatus; /* number of tokens to shift before error messages enabled */
2304 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
2305
2306 short yyssa[YYINITDEPTH]; /* the state stack */
2307 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
2308
2309 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
2310 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
2311
2312#ifdef YYLSP_NEEDED
2313 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
2314 YYLTYPE *yyls = yylsa;
2315 YYLTYPE *yylsp;
2316
2317#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
2318#else
2319#define YYPOPSTACK (yyvsp--, yyssp--)
Dale Johannesencdd509a2007-09-07 21:07:57 +00002320#endif
Chandler Carruth02202192007-08-04 01:56:21 +00002321
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002322 int yystacksize = YYINITDEPTH;
2323 int yyfree_stacks = 0;
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002324
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002325#ifdef YYPURE
2326 int yychar;
2327 YYSTYPE yylval;
2328 int yynerrs;
2329#ifdef YYLSP_NEEDED
2330 YYLTYPE yylloc;
2331#endif
2332#endif
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002333
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002334 YYSTYPE yyval; /* the variable used to return */
2335 /* semantic values from the action */
2336 /* routines */
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002337
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002338 int yylen;
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002339
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002340#if YYDEBUG != 0
2341 if (yydebug)
2342 fprintf(stderr, "Starting parse\n");
2343#endif
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002344
Reid Spencer68a24bd2005-08-27 18:50:39 +00002345 yystate = 0;
2346 yyerrstatus = 0;
2347 yynerrs = 0;
2348 yychar = YYEMPTY; /* Cause a token to be read. */
2349
2350 /* Initialize stack pointers.
2351 Waste one element of value and location stack
2352 so that they stay on the same level as the state stack.
2353 The wasted elements are never initialized. */
2354
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002355 yyssp = yyss - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002356 yyvsp = yyvs;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002357#ifdef YYLSP_NEEDED
2358 yylsp = yyls;
2359#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002360
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002361/* Push a new state, which is found in yystate . */
2362/* In all cases, when you get here, the value and location stacks
2363 have just been pushed. so pushing a state here evens the stacks. */
2364yynewstate:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002365
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002366 *++yyssp = yystate;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002367
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002368 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002369 {
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002370 /* Give user a chance to reallocate the stack */
2371 /* Use copies of these so that the &'s don't force the real ones into memory. */
2372 YYSTYPE *yyvs1 = yyvs;
2373 short *yyss1 = yyss;
2374#ifdef YYLSP_NEEDED
2375 YYLTYPE *yyls1 = yyls;
2376#endif
2377
Reid Spencer68a24bd2005-08-27 18:50:39 +00002378 /* Get the current used size of the three stacks, in elements. */
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002379 int size = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002380
2381#ifdef yyoverflow
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002382 /* Each stack pointer address is followed by the size of
2383 the data in use in that stack, in bytes. */
2384#ifdef YYLSP_NEEDED
2385 /* This used to be a conditional around just the two extra args,
2386 but that might be undefined if yyoverflow is a macro. */
2387 yyoverflow("parser stack overflow",
2388 &yyss1, size * sizeof (*yyssp),
2389 &yyvs1, size * sizeof (*yyvsp),
2390 &yyls1, size * sizeof (*yylsp),
2391 &yystacksize);
2392#else
2393 yyoverflow("parser stack overflow",
2394 &yyss1, size * sizeof (*yyssp),
2395 &yyvs1, size * sizeof (*yyvsp),
2396 &yystacksize);
2397#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002398
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002399 yyss = yyss1; yyvs = yyvs1;
2400#ifdef YYLSP_NEEDED
2401 yyls = yyls1;
2402#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002403#else /* no yyoverflow */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002404 /* Extend the stack our own way. */
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002405 if (yystacksize >= YYMAXDEPTH)
2406 {
2407 yyerror("parser stack overflow");
2408 if (yyfree_stacks)
2409 {
2410 free (yyss);
2411 free (yyvs);
2412#ifdef YYLSP_NEEDED
2413 free (yyls);
2414#endif
2415 }
2416 return 2;
2417 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002418 yystacksize *= 2;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002419 if (yystacksize > YYMAXDEPTH)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002420 yystacksize = YYMAXDEPTH;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002421#ifndef YYSTACK_USE_ALLOCA
2422 yyfree_stacks = 1;
2423#endif
2424 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
2425 __yy_memcpy ((char *)yyss, (char *)yyss1,
2426 size * (unsigned int) sizeof (*yyssp));
2427 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
2428 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
2429 size * (unsigned int) sizeof (*yyvsp));
2430#ifdef YYLSP_NEEDED
2431 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
2432 __yy_memcpy ((char *)yyls, (char *)yyls1,
2433 size * (unsigned int) sizeof (*yylsp));
2434#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002435#endif /* no yyoverflow */
2436
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002437 yyssp = yyss + size - 1;
2438 yyvsp = yyvs + size - 1;
2439#ifdef YYLSP_NEEDED
2440 yylsp = yyls + size - 1;
2441#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002442
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002443#if YYDEBUG != 0
2444 if (yydebug)
2445 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2446#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002447
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002448 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002449 YYABORT;
2450 }
2451
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002452#if YYDEBUG != 0
2453 if (yydebug)
2454 fprintf(stderr, "Entering state %d\n", yystate);
2455#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002456
2457 goto yybackup;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002458 yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002459
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002460/* Do appropriate processing given the current state. */
2461/* Read a lookahead token if we need one and don't already have one. */
2462/* yyresume: */
Andrew Lenharth6353e052006-12-08 18:07:09 +00002463
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002464 /* First try to decide what to do without reference to lookahead token. */
Reid Spencer7780acb2007-04-16 06:56:07 +00002465
Reid Spencer68a24bd2005-08-27 18:50:39 +00002466 yyn = yypact[yystate];
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002467 if (yyn == YYFLAG)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002468 goto yydefault;
2469
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002470 /* Not known => get a lookahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002471
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002472 /* yychar is either YYEMPTY or YYEOF
2473 or a valid token in external form. */
2474
Reid Spencer68a24bd2005-08-27 18:50:39 +00002475 if (yychar == YYEMPTY)
2476 {
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002477#if YYDEBUG != 0
2478 if (yydebug)
2479 fprintf(stderr, "Reading a token: ");
2480#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002481 yychar = YYLEX;
2482 }
2483
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002484 /* Convert token to internal form (in yychar1) for indexing tables with */
2485
2486 if (yychar <= 0) /* This means end of input. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002487 {
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002488 yychar1 = 0;
2489 yychar = YYEOF; /* Don't call YYLEX any more */
2490
2491#if YYDEBUG != 0
2492 if (yydebug)
2493 fprintf(stderr, "Now at end of input.\n");
2494#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002495 }
2496 else
2497 {
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002498 yychar1 = YYTRANSLATE(yychar);
2499
2500#if YYDEBUG != 0
2501 if (yydebug)
2502 {
2503 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2504 /* Give the individual parser a way to print the precise meaning
2505 of a token, for further debugging info. */
2506#ifdef YYPRINT
2507 YYPRINT (stderr, yychar, yylval);
2508#endif
2509 fprintf (stderr, ")\n");
2510 }
2511#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002512 }
2513
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002514 yyn += yychar1;
2515 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002516 goto yydefault;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002517
Reid Spencer68a24bd2005-08-27 18:50:39 +00002518 yyn = yytable[yyn];
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002519
2520 /* yyn is what to do for this token type in this state.
2521 Negative => reduce, -yyn is rule number.
2522 Positive => shift, yyn is new state.
2523 New state is final state => don't bother to shift,
2524 just return success.
2525 0, or most negative number => error. */
2526
2527 if (yyn < 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002528 {
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002529 if (yyn == YYFLAG)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002530 goto yyerrlab;
2531 yyn = -yyn;
2532 goto yyreduce;
2533 }
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002534 else if (yyn == 0)
2535 goto yyerrlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002536
2537 if (yyn == YYFINAL)
2538 YYACCEPT;
2539
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002540 /* Shift the lookahead token. */
Dale Johannesencdd509a2007-09-07 21:07:57 +00002541
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002542#if YYDEBUG != 0
2543 if (yydebug)
2544 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2545#endif
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002546
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002547 /* Discard the token being shifted unless it is eof. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002548 if (yychar != YYEOF)
2549 yychar = YYEMPTY;
2550
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002551 *++yyvsp = yylval;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002552#ifdef YYLSP_NEEDED
2553 *++yylsp = yylloc;
2554#endif
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002555
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002556 /* count tokens shifted since error; after three, turn off error status. */
2557 if (yyerrstatus) yyerrstatus--;
2558
2559 yystate = yyn;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002560 goto yynewstate;
2561
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002562/* Do the default action for the current state. */
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00002563yydefault:
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002564
Reid Spencer68a24bd2005-08-27 18:50:39 +00002565 yyn = yydefact[yystate];
2566 if (yyn == 0)
2567 goto yyerrlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002568
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002569/* Do a reduction. yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002570yyreduce:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002571 yylen = yyr2[yyn];
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002572 if (yylen > 0)
2573 yyval = yyvsp[1-yylen]; /* implement default value of the action */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002574
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002575#if YYDEBUG != 0
2576 if (yydebug)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002577 {
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002578 int i;
Reid Spencer41dff5e2007-01-26 08:05:27 +00002579
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002580 fprintf (stderr, "Reducing via rule %d (line %d), ",
2581 yyn, yyrline[yyn]);
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002582
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002583 /* Print the symbols being reduced, and their result. */
2584 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2585 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2586 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2587 }
2588#endif
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002589
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002590
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002591 switch (yyn) {
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002592
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002593case 28:
2594#line 1113 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2595{ yyval.IPredicate = ICmpInst::ICMP_EQ; ;
2596 break;}
2597case 29:
2598#line 1113 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2599{ yyval.IPredicate = ICmpInst::ICMP_NE; ;
2600 break;}
2601case 30:
2602#line 1114 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2603{ yyval.IPredicate = ICmpInst::ICMP_SLT; ;
2604 break;}
2605case 31:
2606#line 1114 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2607{ yyval.IPredicate = ICmpInst::ICMP_SGT; ;
2608 break;}
2609case 32:
2610#line 1115 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2611{ yyval.IPredicate = ICmpInst::ICMP_SLE; ;
2612 break;}
2613case 33:
2614#line 1115 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2615{ yyval.IPredicate = ICmpInst::ICMP_SGE; ;
2616 break;}
2617case 34:
2618#line 1116 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2619{ yyval.IPredicate = ICmpInst::ICMP_ULT; ;
2620 break;}
2621case 35:
2622#line 1116 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2623{ yyval.IPredicate = ICmpInst::ICMP_UGT; ;
2624 break;}
2625case 36:
2626#line 1117 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2627{ yyval.IPredicate = ICmpInst::ICMP_ULE; ;
2628 break;}
2629case 37:
2630#line 1117 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2631{ yyval.IPredicate = ICmpInst::ICMP_UGE; ;
2632 break;}
2633case 38:
2634#line 1121 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2635{ yyval.FPredicate = FCmpInst::FCMP_OEQ; ;
2636 break;}
2637case 39:
2638#line 1121 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2639{ yyval.FPredicate = FCmpInst::FCMP_ONE; ;
2640 break;}
2641case 40:
2642#line 1122 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2643{ yyval.FPredicate = FCmpInst::FCMP_OLT; ;
2644 break;}
2645case 41:
2646#line 1122 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2647{ yyval.FPredicate = FCmpInst::FCMP_OGT; ;
2648 break;}
2649case 42:
2650#line 1123 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2651{ yyval.FPredicate = FCmpInst::FCMP_OLE; ;
2652 break;}
2653case 43:
2654#line 1123 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2655{ yyval.FPredicate = FCmpInst::FCMP_OGE; ;
2656 break;}
2657case 44:
2658#line 1124 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2659{ yyval.FPredicate = FCmpInst::FCMP_ORD; ;
2660 break;}
2661case 45:
2662#line 1124 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2663{ yyval.FPredicate = FCmpInst::FCMP_UNO; ;
2664 break;}
2665case 46:
2666#line 1125 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2667{ yyval.FPredicate = FCmpInst::FCMP_UEQ; ;
2668 break;}
2669case 47:
2670#line 1125 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2671{ yyval.FPredicate = FCmpInst::FCMP_UNE; ;
2672 break;}
2673case 48:
2674#line 1126 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2675{ yyval.FPredicate = FCmpInst::FCMP_ULT; ;
2676 break;}
2677case 49:
2678#line 1126 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2679{ yyval.FPredicate = FCmpInst::FCMP_UGT; ;
2680 break;}
2681case 50:
2682#line 1127 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2683{ yyval.FPredicate = FCmpInst::FCMP_ULE; ;
2684 break;}
2685case 51:
2686#line 1127 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2687{ yyval.FPredicate = FCmpInst::FCMP_UGE; ;
2688 break;}
2689case 52:
2690#line 1128 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2691{ yyval.FPredicate = FCmpInst::FCMP_TRUE; ;
2692 break;}
2693case 53:
2694#line 1129 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2695{ yyval.FPredicate = FCmpInst::FCMP_FALSE; ;
2696 break;}
2697case 64:
2698#line 1138 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2699{ yyval.StrVal = 0; ;
2700 break;}
2701case 65:
Christopher Lambbf3348d2007-12-12 08:45:45 +00002702#line 1140 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2703{ yyval.UIntVal=yyvsp[-1].UInt64Val; ;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002704 break;}
2705case 66:
Christopher Lambbf3348d2007-12-12 08:45:45 +00002706#line 1141 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2707{ yyval.UIntVal=0; ;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002708 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00002709case 67:
2710#line 1145 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002711{
2712 yyval.StrVal = yyvsp[-1].StrVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00002713 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002714 ;
2715 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00002716case 68:
2717#line 1149 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2718{
2719 yyval.StrVal = 0;
2720 CHECK_FOR_ERROR
2721 ;
2722 break;}
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002723case 72:
Christopher Lambbf3348d2007-12-12 08:45:45 +00002724#line 1157 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2725{
2726 yyval.StrVal = 0;
2727 CHECK_FOR_ERROR
2728 ;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002729 break;}
2730case 73:
Christopher Lambbf3348d2007-12-12 08:45:45 +00002731#line 1162 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2732{
2733 yyval.StrVal = yyvsp[-1].StrVal;
2734 CHECK_FOR_ERROR
2735 ;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002736 break;}
2737case 74:
Christopher Lambbf3348d2007-12-12 08:45:45 +00002738#line 1168 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2739{ yyval.Linkage = GlobalValue::InternalLinkage; ;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002740 break;}
2741case 75:
Christopher Lambbf3348d2007-12-12 08:45:45 +00002742#line 1169 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2743{ yyval.Linkage = GlobalValue::WeakLinkage; ;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002744 break;}
2745case 76:
Christopher Lambbf3348d2007-12-12 08:45:45 +00002746#line 1170 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002747{ yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2748 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00002749case 77:
2750#line 1171 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2751{ yyval.Linkage = GlobalValue::AppendingLinkage; ;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002752 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00002753case 78:
2754#line 1172 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002755{ yyval.Linkage = GlobalValue::DLLExportLinkage; ;
2756 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00002757case 79:
2758#line 1176 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2759{ yyval.Linkage = GlobalValue::DLLImportLinkage; ;
2760 break;}
2761case 80:
2762#line 1177 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2763{ yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;
2764 break;}
2765case 81:
2766#line 1178 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002767{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2768 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00002769case 82:
2770#line 1182 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2771{ yyval.Visibility = GlobalValue::DefaultVisibility; ;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002772 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00002773case 83:
2774#line 1183 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2775{ yyval.Visibility = GlobalValue::DefaultVisibility; ;
2776 break;}
2777case 84:
2778#line 1184 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2779{ yyval.Visibility = GlobalValue::HiddenVisibility; ;
2780 break;}
2781case 85:
2782#line 1185 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2783{ yyval.Visibility = GlobalValue::ProtectedVisibility; ;
2784 break;}
2785case 86:
2786#line 1189 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2787{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2788 break;}
2789case 87:
2790#line 1190 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2791{ yyval.Linkage = GlobalValue::DLLImportLinkage; ;
2792 break;}
2793case 88:
2794#line 1191 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2795{ yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;
2796 break;}
2797case 89:
2798#line 1195 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2799{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2800 break;}
2801case 90:
2802#line 1196 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002803{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2804 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00002805case 91:
2806#line 1197 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2807{ yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2808 break;}
2809case 92:
2810#line 1198 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2811{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2812 break;}
2813case 93:
2814#line 1199 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2815{ yyval.Linkage = GlobalValue::DLLExportLinkage; ;
2816 break;}
2817case 94:
2818#line 1203 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2819{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2820 break;}
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002821case 95:
Christopher Lambbf3348d2007-12-12 08:45:45 +00002822#line 1204 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2823{ yyval.Linkage = GlobalValue::WeakLinkage; ;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002824 break;}
2825case 96:
Christopher Lambbf3348d2007-12-12 08:45:45 +00002826#line 1205 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2827{ yyval.Linkage = GlobalValue::InternalLinkage; ;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002828 break;}
2829case 97:
Christopher Lambbf3348d2007-12-12 08:45:45 +00002830#line 1208 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2831{ yyval.UIntVal = CallingConv::C; ;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002832 break;}
2833case 98:
Christopher Lambbf3348d2007-12-12 08:45:45 +00002834#line 1209 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2835{ yyval.UIntVal = CallingConv::C; ;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002836 break;}
2837case 99:
Christopher Lambbf3348d2007-12-12 08:45:45 +00002838#line 1210 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2839{ yyval.UIntVal = CallingConv::Fast; ;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002840 break;}
2841case 100:
Christopher Lambbf3348d2007-12-12 08:45:45 +00002842#line 1211 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2843{ yyval.UIntVal = CallingConv::Cold; ;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002844 break;}
2845case 101:
Christopher Lambbf3348d2007-12-12 08:45:45 +00002846#line 1212 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2847{ yyval.UIntVal = CallingConv::X86_StdCall; ;
2848 break;}
2849case 102:
2850#line 1213 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2851{ yyval.UIntVal = CallingConv::X86_FastCall; ;
2852 break;}
2853case 103:
2854#line 1214 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002855{
2856 if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002857 GEN_ERROR("Calling conv too large");
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002858 yyval.UIntVal = yyvsp[0].UInt64Val;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002859 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002860 ;
2861 break;}
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002862case 104:
Christopher Lambbf3348d2007-12-12 08:45:45 +00002863#line 1221 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2864{ yyval.ParamAttrs = ParamAttr::ZExt; ;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002865 break;}
2866case 105:
Christopher Lambbf3348d2007-12-12 08:45:45 +00002867#line 1222 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2868{ yyval.ParamAttrs = ParamAttr::ZExt; ;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002869 break;}
2870case 106:
Christopher Lambbf3348d2007-12-12 08:45:45 +00002871#line 1223 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2872{ yyval.ParamAttrs = ParamAttr::SExt; ;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002873 break;}
2874case 107:
Christopher Lambbf3348d2007-12-12 08:45:45 +00002875#line 1224 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2876{ yyval.ParamAttrs = ParamAttr::SExt; ;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002877 break;}
2878case 108:
Christopher Lambbf3348d2007-12-12 08:45:45 +00002879#line 1225 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2880{ yyval.ParamAttrs = ParamAttr::InReg; ;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002881 break;}
2882case 109:
Christopher Lambbf3348d2007-12-12 08:45:45 +00002883#line 1226 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2884{ yyval.ParamAttrs = ParamAttr::StructRet; ;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002885 break;}
2886case 110:
Christopher Lambbf3348d2007-12-12 08:45:45 +00002887#line 1227 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2888{ yyval.ParamAttrs = ParamAttr::NoAlias; ;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002889 break;}
2890case 111:
Christopher Lambbf3348d2007-12-12 08:45:45 +00002891#line 1228 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2892{ yyval.ParamAttrs = ParamAttr::ByVal; ;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002893 break;}
2894case 112:
Christopher Lambbf3348d2007-12-12 08:45:45 +00002895#line 1229 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2896{ yyval.ParamAttrs = ParamAttr::Nest; ;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002897 break;}
2898case 113:
Christopher Lambbf3348d2007-12-12 08:45:45 +00002899#line 1232 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002900{ yyval.ParamAttrs = ParamAttr::None; ;
2901 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00002902case 114:
2903#line 1233 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002904{
2905 yyval.ParamAttrs = yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs;
2906 ;
2907 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00002908case 115:
2909#line 1238 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2910{ yyval.ParamAttrs = ParamAttr::NoReturn; ;
2911 break;}
2912case 116:
2913#line 1239 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2914{ yyval.ParamAttrs = ParamAttr::NoUnwind; ;
2915 break;}
2916case 117:
2917#line 1240 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2918{ yyval.ParamAttrs = ParamAttr::ZExt; ;
2919 break;}
2920case 118:
2921#line 1241 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2922{ yyval.ParamAttrs = ParamAttr::SExt; ;
2923 break;}
2924case 119:
2925#line 1242 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2926{ yyval.ParamAttrs = ParamAttr::ReadNone; ;
2927 break;}
2928case 120:
2929#line 1243 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2930{ yyval.ParamAttrs = ParamAttr::ReadOnly; ;
2931 break;}
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002932case 121:
Christopher Lambbf3348d2007-12-12 08:45:45 +00002933#line 1246 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2934{ yyval.ParamAttrs = ParamAttr::None; ;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002935 break;}
2936case 122:
Christopher Lambbf3348d2007-12-12 08:45:45 +00002937#line 1247 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2938{
2939 yyval.ParamAttrs = yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs;
2940 ;
2941 break;}
2942case 123:
2943#line 1252 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2944{ yyval.StrVal = 0; ;
2945 break;}
2946case 124:
2947#line 1253 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002948{
2949 yyval.StrVal = yyvsp[0].StrVal;
2950 ;
2951 break;}
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002952case 125:
Christopher Lambbf3348d2007-12-12 08:45:45 +00002953#line 1260 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002954{ yyval.UIntVal = 0; ;
2955 break;}
2956case 126:
Christopher Lambbf3348d2007-12-12 08:45:45 +00002957#line 1261 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002958{
2959 yyval.UIntVal = yyvsp[0].UInt64Val;
2960 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002961 GEN_ERROR("Alignment must be a power of two");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002962 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002963;
2964 break;}
2965case 127:
Christopher Lambbf3348d2007-12-12 08:45:45 +00002966#line 1267 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2967{ yyval.UIntVal = 0; ;
2968 break;}
2969case 128:
2970#line 1268 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2971{
2972 yyval.UIntVal = yyvsp[0].UInt64Val;
2973 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
2974 GEN_ERROR("Alignment must be a power of two");
2975 CHECK_FOR_ERROR
2976;
2977 break;}
2978case 129:
2979#line 1277 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002980{
2981 for (unsigned i = 0, e = yyvsp[0].StrVal->length(); i != e; ++i)
2982 if ((*yyvsp[0].StrVal)[i] == '"' || (*yyvsp[0].StrVal)[i] == '\\')
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002983 GEN_ERROR("Invalid character in section name");
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002984 yyval.StrVal = yyvsp[0].StrVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002985 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002986;
2987 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00002988case 130:
2989#line 1285 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002990{ yyval.StrVal = 0; ;
2991 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00002992case 131:
2993#line 1286 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002994{ yyval.StrVal = yyvsp[0].StrVal; ;
2995 break;}
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00002996case 132:
Christopher Lambbf3348d2007-12-12 08:45:45 +00002997#line 1291 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2998{;
2999 break;}
3000case 133:
3001#line 1292 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3002{;
3003 break;}
3004case 134:
3005#line 1293 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003006{
3007 CurGV->setSection(*yyvsp[0].StrVal);
3008 delete yyvsp[0].StrVal;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003009 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003010 ;
3011 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003012case 135:
3013#line 1298 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003014{
3015 if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003016 GEN_ERROR("Alignment must be a power of two");
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003017 CurGV->setAlignment(yyvsp[0].UInt64Val);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003018 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003019 ;
3020 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003021case 143:
3022#line 1314 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003023{
3024 yyval.TypeVal = new PATypeHolder(OpaqueType::get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003025 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003026 ;
3027 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003028case 144:
3029#line 1318 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003030{
3031 yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003032 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003033 ;
3034 break;}
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003035case 145:
Christopher Lambbf3348d2007-12-12 08:45:45 +00003036#line 1322 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3037{ // Pointer type?
3038 if (*yyvsp[-2].TypeVal == Type::LabelTy)
3039 GEN_ERROR("Cannot form a pointer to a basic block");
3040 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-2].TypeVal, yyvsp[-1].UIntVal)));
3041 delete yyvsp[-2].TypeVal;
3042 CHECK_FOR_ERROR
3043 ;
3044 break;}
3045case 146:
3046#line 1329 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003047{ // Named types are also simple types...
3048 const Type* tmp = getTypeVal(yyvsp[0].ValIDVal);
3049 CHECK_FOR_ERROR
3050 yyval.TypeVal = new PATypeHolder(tmp);
3051 ;
3052 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003053case 147:
3054#line 1334 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003055{ // Type UpReference
3056 if (yyvsp[0].UInt64Val > (uint64_t)~0U) GEN_ERROR("Value out of range");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003057 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003058 UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector...
3059 yyval.TypeVal = new PATypeHolder(OT);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003060 UR_OUT("New Upreference!\n");
3061 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003062 ;
3063 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003064case 148:
3065#line 1342 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003066{
Duncan Sandsdc024672007-11-27 13:23:08 +00003067 // Allow but ignore attributes on function types; this permits auto-upgrade.
3068 // FIXME: remove in LLVM 3.0.
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003069 const Type* RetTy = *yyvsp[-4].TypeVal;
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00003070 if (!(RetTy->isFirstClassType() || RetTy == Type::VoidTy ||
3071 isa<OpaqueType>(RetTy)))
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003072 GEN_ERROR("LLVM Functions cannot return aggregates");
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00003073
Reid Spencer41dff5e2007-01-26 08:05:27 +00003074 std::vector<const Type*> Params;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003075 TypeWithAttrsList::iterator I = yyvsp[-2].TypeWithAttrsList->begin(), E = yyvsp[-2].TypeWithAttrsList->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00003076 for (; I != E; ++I ) {
Reid Spencer66728ef2007-03-20 01:13:36 +00003077 const Type *Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00003078 Params.push_back(Ty);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003079 }
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00003080
Reid Spencer41dff5e2007-01-26 08:05:27 +00003081 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3082 if (isVarArg) Params.pop_back();
3083
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00003084 for (unsigned i = 0; i != Params.size(); ++i)
3085 if (!(Params[i]->isFirstClassType() || isa<OpaqueType>(Params[i])))
3086 GEN_ERROR("Function arguments must be value types!");
3087
3088 CHECK_FOR_ERROR
3089
Anton Korobeynikovc36284e2007-12-03 19:17:47 +00003090 FunctionType *FT = FunctionType::get(RetTy, Params, isVarArg);
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003091 delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list
3092 delete yyvsp[-4].TypeVal; // Delete the return type handle
3093 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT));
Reid Spencere4d87aa2006-12-23 06:05:41 +00003094 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003095 ;
3096 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003097case 149:
3098#line 1372 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003099{
Duncan Sandsdc024672007-11-27 13:23:08 +00003100 // Allow but ignore attributes on function types; this permits auto-upgrade.
3101 // FIXME: remove in LLVM 3.0.
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003102 std::vector<const Type*> Params;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003103 TypeWithAttrsList::iterator I = yyvsp[-2].TypeWithAttrsList->begin(), E = yyvsp[-2].TypeWithAttrsList->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00003104 for ( ; I != E; ++I ) {
Reid Spencer66728ef2007-03-20 01:13:36 +00003105 const Type* Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00003106 Params.push_back(Ty);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003107 }
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00003108
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003109 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3110 if (isVarArg) Params.pop_back();
3111
Anton Korobeynikov05e5a742007-12-03 21:01:29 +00003112 for (unsigned i = 0; i != Params.size(); ++i)
3113 if (!(Params[i]->isFirstClassType() || isa<OpaqueType>(Params[i])))
3114 GEN_ERROR("Function arguments must be value types!");
3115
3116 CHECK_FOR_ERROR
3117
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003118 FunctionType *FT = FunctionType::get(yyvsp[-4].PrimType, Params, isVarArg);
3119 delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list
3120 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003121 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003122 ;
3123 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003124case 150:
3125#line 1397 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003126{ // Sized array type?
3127 yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
3128 delete yyvsp[-1].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003129 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003130 ;
3131 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003132case 151:
3133#line 1402 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003134{ // Vector type?
3135 const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
3136 if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003137 GEN_ERROR("Unsigned result not equal to signed result");
3138 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
3139 GEN_ERROR("Element type of a VectorType must be primitive");
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003140 yyval.TypeVal = new PATypeHolder(HandleUpRefs(VectorType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
3141 delete yyvsp[-1].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003142 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003143 ;
3144 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003145case 152:
3146#line 1412 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003147{ // Structure type?
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003148 std::vector<const Type*> Elements;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003149 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
3150 E = yyvsp[-1].TypeList->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003151 Elements.push_back(*I);
3152
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003153 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
3154 delete yyvsp[-1].TypeList;
Reid Spencer14310612006-12-31 05:40:51 +00003155 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003156 ;
3157 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003158case 153:
3159#line 1422 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003160{ // Empty structure type?
3161 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer14310612006-12-31 05:40:51 +00003162 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003163 ;
3164 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003165case 154:
3166#line 1426 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003167{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003168 std::vector<const Type*> Elements;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003169 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-2].TypeList->begin(),
3170 E = yyvsp[-2].TypeList->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003171 Elements.push_back(*I);
3172
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003173 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
3174 delete yyvsp[-2].TypeList;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003175 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003176 ;
3177 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003178case 155:
3179#line 1436 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003180{ // Empty structure type?
3181 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003182 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003183 ;
3184 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003185case 156:
3186#line 1443 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003187{
Duncan Sandsdc024672007-11-27 13:23:08 +00003188 // Allow but ignore attributes on function types; this permits auto-upgrade.
3189 // FIXME: remove in LLVM 3.0.
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003190 yyval.TypeWithAttrs.Ty = yyvsp[-1].TypeVal;
3191 yyval.TypeWithAttrs.Attrs = ParamAttr::None;
3192 ;
3193 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003194case 157:
3195#line 1452 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003196{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003197 if (!UpRefs.empty())
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003198 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
3199 if (!(*yyvsp[0].TypeVal)->isFirstClassType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003200 GEN_ERROR("LLVM functions cannot return aggregate types");
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003201 yyval.TypeVal = yyvsp[0].TypeVal;
3202 ;
3203 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003204case 158:
3205#line 1459 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003206{
3207 yyval.TypeVal = new PATypeHolder(Type::VoidTy);
3208 ;
3209 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003210case 159:
3211#line 1464 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003212{
3213 yyval.TypeWithAttrsList = new TypeWithAttrsList();
3214 yyval.TypeWithAttrsList->push_back(yyvsp[0].TypeWithAttrs);
Reid Spencer3da59db2006-11-27 01:05:10 +00003215 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003216 ;
3217 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003218case 160:
3219#line 1469 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003220{
3221 (yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList)->push_back(yyvsp[0].TypeWithAttrs);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003222 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003223 ;
3224 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003225case 162:
3226#line 1477 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003227{
3228 yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList;
Reid Spencer18da0722007-04-11 02:44:20 +00003229 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003230 TWA.Ty = new PATypeHolder(Type::VoidTy);
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003231 yyval.TypeWithAttrsList->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003232 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003233 ;
3234 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003235case 163:
3236#line 1484 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003237{
3238 yyval.TypeWithAttrsList = new TypeWithAttrsList;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003239 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
3240 TWA.Ty = new PATypeHolder(Type::VoidTy);
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003241 yyval.TypeWithAttrsList->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003242 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003243 ;
3244 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003245case 164:
3246#line 1491 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003247{
3248 yyval.TypeWithAttrsList = new TypeWithAttrsList();
Reid Spencer41dff5e2007-01-26 08:05:27 +00003249 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003250 ;
3251 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003252case 165:
3253#line 1499 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003254{
3255 yyval.TypeList = new std::list<PATypeHolder>();
3256 yyval.TypeList->push_back(*yyvsp[0].TypeVal);
3257 delete yyvsp[0].TypeVal;
Reid Spencer3da59db2006-11-27 01:05:10 +00003258 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003259 ;
3260 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003261case 166:
3262#line 1505 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003263{
3264 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal);
3265 delete yyvsp[0].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003266 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003267 ;
3268 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003269case 167:
3270#line 1517 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003271{ // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00003272 if (!UpRefs.empty())
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003273 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
3274 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003275 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003276 GEN_ERROR("Cannot make array constant with type: '" +
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003277 (*yyvsp[-3].TypeVal)->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003278 const Type *ETy = ATy->getElementType();
3279 int NumElements = ATy->getNumElements();
3280
3281 // Verify that we have the correct size...
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003282 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003283 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003284 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00003285 itostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003286
3287 // Verify all elements are correct type!
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003288 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3289 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003290 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3291 ETy->getDescription() +"' as required!\nIt is of type '"+
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003292 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003293 }
3294
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003295 yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
3296 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003297 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003298 ;
3299 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003300case 168:
3301#line 1545 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003302{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003303 if (!UpRefs.empty())
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003304 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3305 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003306 if (ATy == 0)
3307 GEN_ERROR("Cannot make array constant with type: '" +
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003308 (*yyvsp[-2].TypeVal)->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003309
Andrew Lenharth6353e052006-12-08 18:07:09 +00003310 int NumElements = ATy->getNumElements();
3311 if (NumElements != -1 && NumElements != 0)
3312 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Reid Spencerb5334b02007-02-05 10:18:06 +00003313 " arguments, but has size of " + itostr(NumElements) +"");
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003314 yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
3315 delete yyvsp[-2].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00003316 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003317 ;
3318 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003319case 169:
3320#line 1561 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003321{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003322 if (!UpRefs.empty())
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003323 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3324 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003325 if (ATy == 0)
3326 GEN_ERROR("Cannot make array constant with type: '" +
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003327 (*yyvsp[-2].TypeVal)->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003328
3329 int NumElements = ATy->getNumElements();
3330 const Type *ETy = ATy->getElementType();
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003331 if (NumElements != -1 && NumElements != int(yyvsp[0].StrVal->length()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003332 GEN_ERROR("Can't build string constant of size " +
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003333 itostr((int)(yyvsp[0].StrVal->length())) +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003334 " when array has size " + itostr(NumElements) + "");
3335 std::vector<Constant*> Vals;
3336 if (ETy == Type::Int8Ty) {
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003337 for (unsigned i = 0; i < yyvsp[0].StrVal->length(); ++i)
3338 Vals.push_back(ConstantInt::get(ETy, (*yyvsp[0].StrVal)[i]));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003339 } else {
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003340 delete yyvsp[0].StrVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003341 GEN_ERROR("Cannot build string arrays of non byte sized elements");
3342 }
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003343 delete yyvsp[0].StrVal;
3344 yyval.ConstVal = ConstantArray::get(ATy, Vals);
3345 delete yyvsp[-2].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003346 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003347 ;
3348 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003349case 170:
3350#line 1588 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003351{ // Nonempty unsized arr
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003352 if (!UpRefs.empty())
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003353 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
3354 const VectorType *PTy = dyn_cast<VectorType>(yyvsp[-3].TypeVal->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003355 if (PTy == 0)
3356 GEN_ERROR("Cannot make packed constant with type: '" +
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003357 (*yyvsp[-3].TypeVal)->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003358 const Type *ETy = PTy->getElementType();
3359 int NumElements = PTy->getNumElements();
Reid Spencer41dff5e2007-01-26 08:05:27 +00003360
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003361 // Verify that we have the correct size...
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003362 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003363 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003364 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00003365 itostr(NumElements) + "");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003366
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003367 // Verify all elements are correct type!
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003368 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3369 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003370 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3371 ETy->getDescription() +"' as required!\nIt is of type '"+
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003372 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003373 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00003374
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003375 yyval.ConstVal = ConstantVector::get(PTy, *yyvsp[-1].ConstVector);
3376 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003377 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003378 ;
3379 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003380case 171:
3381#line 1616 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003382{
3383 const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003384 if (STy == 0)
3385 GEN_ERROR("Cannot make struct constant with type: '" +
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003386 (*yyvsp[-3].TypeVal)->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003387
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003388 if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003389 GEN_ERROR("Illegal number of initializers for structure type");
3390
3391 // Check to ensure that constants are compatible with the type initializer!
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003392 for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
3393 if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003394 GEN_ERROR("Expected type '" +
3395 STy->getElementType(i)->getDescription() +
3396 "' for element #" + utostr(i) +
3397 " of structure initializer");
3398
3399 // Check to ensure that Type is not packed
3400 if (STy->isPacked())
3401 GEN_ERROR("Unpacked Initializer to vector type '" +
3402 STy->getDescription() + "'");
3403
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003404 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
3405 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003406 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003407 ;
3408 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003409case 172:
3410#line 1642 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003411{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003412 if (!UpRefs.empty())
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003413 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3414 const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003415 if (STy == 0)
3416 GEN_ERROR("Cannot make struct constant with type: '" +
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003417 (*yyvsp[-2].TypeVal)->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003418
3419 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003420 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003421
3422 // Check to ensure that Type is not packed
3423 if (STy->isPacked())
Chris Lattner6cdc6822007-04-26 05:31:05 +00003424 GEN_ERROR("Unpacked Initializer to vector type '" +
3425 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003426
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003427 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
3428 delete yyvsp[-2].TypeVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003429 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003430 ;
3431 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003432case 173:
3433#line 1662 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003434{
3435 const StructType *STy = dyn_cast<StructType>(yyvsp[-5].TypeVal->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003436 if (STy == 0)
3437 GEN_ERROR("Cannot make struct constant with type: '" +
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003438 (*yyvsp[-5].TypeVal)->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003439
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003440 if (yyvsp[-2].ConstVector->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00003441 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003442
3443 // Check to ensure that constants are compatible with the type initializer!
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003444 for (unsigned i = 0, e = yyvsp[-2].ConstVector->size(); i != e; ++i)
3445 if ((*yyvsp[-2].ConstVector)[i]->getType() != STy->getElementType(i))
Reid Spencer41dff5e2007-01-26 08:05:27 +00003446 GEN_ERROR("Expected type '" +
3447 STy->getElementType(i)->getDescription() +
3448 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00003449 " of structure initializer");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003450
3451 // Check to ensure that Type is packed
3452 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00003453 GEN_ERROR("Vector initializer to non-vector type '" +
3454 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003455
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003456 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-2].ConstVector);
3457 delete yyvsp[-5].TypeVal; delete yyvsp[-2].ConstVector;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003458 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003459 ;
3460 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003461case 174:
3462#line 1688 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003463{
Reid Spencer41dff5e2007-01-26 08:05:27 +00003464 if (!UpRefs.empty())
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003465 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
3466 const StructType *STy = dyn_cast<StructType>(yyvsp[-4].TypeVal->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003467 if (STy == 0)
3468 GEN_ERROR("Cannot make struct constant with type: '" +
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003469 (*yyvsp[-4].TypeVal)->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003470
3471 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003472 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003473
3474 // Check to ensure that Type is packed
3475 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00003476 GEN_ERROR("Vector initializer to non-vector type '" +
3477 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003478
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003479 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
3480 delete yyvsp[-4].TypeVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003481 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003482 ;
3483 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003484case 175:
3485#line 1708 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003486{
Reid Spencer41dff5e2007-01-26 08:05:27 +00003487 if (!UpRefs.empty())
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003488 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3489 const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003490 if (PTy == 0)
3491 GEN_ERROR("Cannot make null pointer constant with type: '" +
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003492 (*yyvsp[-1].TypeVal)->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003493
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003494 yyval.ConstVal = ConstantPointerNull::get(PTy);
3495 delete yyvsp[-1].TypeVal;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003496 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003497 ;
3498 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003499case 176:
3500#line 1720 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003501{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003502 if (!UpRefs.empty())
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003503 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3504 yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
3505 delete yyvsp[-1].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003506 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003507 ;
3508 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003509case 177:
3510#line 1727 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003511{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003512 if (!UpRefs.empty())
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003513 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3514 const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003515 if (Ty == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003516 GEN_ERROR("Global const reference must be a pointer type");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003517
3518 // ConstExprs can exist in the body of a function, thus creating
3519 // GlobalValues whenever they refer to a variable. Because we are in
Reid Spencer93c40032007-03-19 18:40:50 +00003520 // the context of a function, getExistingVal will search the functions
Reid Spencer68a24bd2005-08-27 18:50:39 +00003521 // symbol table instead of the module symbol table for the global symbol,
3522 // which throws things all off. To get around this, we just tell
Reid Spencer93c40032007-03-19 18:40:50 +00003523 // getExistingVal that we are at global scope here.
Reid Spencer68a24bd2005-08-27 18:50:39 +00003524 //
3525 Function *SavedCurFn = CurFun.CurrentFunction;
3526 CurFun.CurrentFunction = 0;
3527
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003528 Value *V = getExistingVal(Ty, yyvsp[0].ValIDVal);
Reid Spencer5b7e7532006-09-28 19:28:24 +00003529 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003530
3531 CurFun.CurrentFunction = SavedCurFn;
3532
3533 // If this is an initializer for a constant pointer, which is referencing a
3534 // (currently) undefined variable, create a stub now that shall be replaced
3535 // in the future with the right type of variable.
3536 //
3537 if (V == 0) {
Reid Spencera9720f52007-02-05 17:04:00 +00003538 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003539 const PointerType *PT = cast<PointerType>(Ty);
3540
3541 // First check to see if the forward references value is already created!
3542 PerModuleInfo::GlobalRefsType::iterator I =
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003543 CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003544
3545 if (I != CurModule.GlobalRefs.end()) {
3546 V = I->second; // Placeholder already exists, use it...
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003547 yyvsp[0].ValIDVal.destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003548 } else {
3549 std::string Name;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003550 if (yyvsp[0].ValIDVal.Type == ValID::GlobalName)
3551 Name = yyvsp[0].ValIDVal.getName();
3552 else if (yyvsp[0].ValIDVal.Type != ValID::GlobalID)
Reid Spencer41dff5e2007-01-26 08:05:27 +00003553 GEN_ERROR("Invalid reference to global");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003554
3555 // Create the forward referenced global.
3556 GlobalValue *GV;
3557 if (const FunctionType *FTy =
3558 dyn_cast<FunctionType>(PT->getElementType())) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00003559 GV = new Function(FTy, GlobalValue::ExternalWeakLinkage, Name,
Reid Spencer68a24bd2005-08-27 18:50:39 +00003560 CurModule.CurrentModule);
3561 } else {
3562 GV = new GlobalVariable(PT->getElementType(), false,
Chris Lattner6cdc6822007-04-26 05:31:05 +00003563 GlobalValue::ExternalWeakLinkage, 0,
Reid Spencer68a24bd2005-08-27 18:50:39 +00003564 Name, CurModule.CurrentModule);
3565 }
3566
3567 // Keep track of the fact that we have a forward ref to recycle it
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003568 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003569 V = GV;
3570 }
3571 }
3572
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003573 yyval.ConstVal = cast<GlobalValue>(V);
3574 delete yyvsp[-1].TypeVal; // Free the type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00003575 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003576 ;
3577 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003578case 178:
3579#line 1793 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003580{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003581 if (!UpRefs.empty())
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003582 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3583 if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003584 GEN_ERROR("Mismatched types for constant expression: " +
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003585 (*yyvsp[-1].TypeVal)->getDescription() + " and " + yyvsp[0].ConstVal->getType()->getDescription());
3586 yyval.ConstVal = yyvsp[0].ConstVal;
3587 delete yyvsp[-1].TypeVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003588 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003589 ;
3590 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003591case 179:
3592#line 1803 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003593{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003594 if (!UpRefs.empty())
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003595 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3596 const Type *Ty = yyvsp[-1].TypeVal->get();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003597 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
3598 GEN_ERROR("Cannot create a null initialized value of this type");
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003599 yyval.ConstVal = Constant::getNullValue(Ty);
3600 delete yyvsp[-1].TypeVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003601 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003602 ;
3603 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003604case 180:
3605#line 1813 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003606{ // integral constants
3607 if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003608 GEN_ERROR("Constant value doesn't fit in type");
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003609 yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val, true);
Reid Spencer38c91a92007-02-28 02:24:54 +00003610 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003611 ;
3612 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003613case 181:
3614#line 1819 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003615{ // arbitrary precision integer constants
3616 uint32_t BitWidth = cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth();
3617 if (yyvsp[0].APIntVal->getBitWidth() > BitWidth) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003618 GEN_ERROR("Constant value does not fit in type");
3619 }
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003620 yyvsp[0].APIntVal->sextOrTrunc(BitWidth);
3621 yyval.ConstVal = ConstantInt::get(*yyvsp[0].APIntVal);
3622 delete yyvsp[0].APIntVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003623 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003624 ;
3625 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003626case 182:
3627#line 1829 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003628{ // integral constants
3629 if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003630 GEN_ERROR("Constant value doesn't fit in type");
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003631 yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val, false);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003632 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003633 ;
3634 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003635case 183:
3636#line 1835 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003637{ // arbitrary precision integer constants
3638 uint32_t BitWidth = cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth();
3639 if (yyvsp[0].APIntVal->getBitWidth() > BitWidth) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003640 GEN_ERROR("Constant value does not fit in type");
3641 }
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003642 yyvsp[0].APIntVal->zextOrTrunc(BitWidth);
3643 yyval.ConstVal = ConstantInt::get(*yyvsp[0].APIntVal);
3644 delete yyvsp[0].APIntVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003645 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003646 ;
3647 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003648case 184:
3649#line 1845 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003650{ // Boolean constants
3651 assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?");
3652 yyval.ConstVal = ConstantInt::getTrue();
Reid Spencer38c91a92007-02-28 02:24:54 +00003653 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003654 ;
3655 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003656case 185:
3657#line 1850 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003658{ // Boolean constants
3659 assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?");
3660 yyval.ConstVal = ConstantInt::getFalse();
Reid Spencer6f407902007-01-13 05:00:46 +00003661 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003662 ;
3663 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003664case 186:
3665#line 1855 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003666{ // Floating point constants
3667 if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, *yyvsp[0].FPVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003668 GEN_ERROR("Floating point constant invalid for type");
Dale Johannesenc72cd7e2007-09-11 18:33:39 +00003669 // Lexer has no type info, so builds all float and double FP constants
3670 // as double. Fix this here. Long double is done right.
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003671 if (&yyvsp[0].FPVal->getSemantics()==&APFloat::IEEEdouble && yyvsp[-1].PrimType==Type::FloatTy)
3672 yyvsp[0].FPVal->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
3673 yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, *yyvsp[0].FPVal);
3674 delete yyvsp[0].FPVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003675 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003676 ;
3677 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003678case 187:
3679#line 1868 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003680{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003681 if (!UpRefs.empty())
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003682 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3683 Constant *Val = yyvsp[-3].ConstVal;
3684 const Type *DestTy = yyvsp[-1].TypeVal->get();
3685 if (!CastInst::castIsValid(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003686 GEN_ERROR("invalid cast opcode for cast from '" +
3687 Val->getType()->getDescription() + "' to '" +
3688 DestTy->getDescription() + "'");
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003689 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy);
3690 delete yyvsp[-1].TypeVal;
3691 ;
3692 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003693case 188:
3694#line 1880 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003695{
3696 if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
Reid Spencerb5334b02007-02-05 10:18:06 +00003697 GEN_ERROR("GetElementPtr requires a pointer operand");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003698
3699 const Type *IdxTy =
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003700 GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end(),
Chris Lattner7d9801d2007-02-13 00:58:01 +00003701 true);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003702 if (!IdxTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00003703 GEN_ERROR("Index list invalid for constant getelementptr");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003704
Chris Lattnerf7469af2007-01-31 04:44:08 +00003705 SmallVector<Constant*, 8> IdxVec;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003706 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
3707 if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003708 IdxVec.push_back(C);
3709 else
Reid Spencerb5334b02007-02-05 10:18:06 +00003710 GEN_ERROR("Indices to constant getelementptr must be constants");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003711
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003712 delete yyvsp[-1].ValueList;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003713
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003714 yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, &IdxVec[0], IdxVec.size());
Andrew Lenharth6353e052006-12-08 18:07:09 +00003715 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003716 ;
3717 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003718case 189:
3719#line 1902 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003720{
3721 if (yyvsp[-5].ConstVal->getType() != Type::Int1Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003722 GEN_ERROR("Select condition must be of boolean type");
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003723 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003724 GEN_ERROR("Select operand types must match");
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003725 yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003726 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003727 ;
3728 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003729case 190:
3730#line 1910 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003731{
3732 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003733 GEN_ERROR("Binary operator types must match");
3734 CHECK_FOR_ERROR;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003735 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3736 ;
3737 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003738case 191:
3739#line 1916 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003740{
3741 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003742 GEN_ERROR("Logical operator types must match");
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003743 if (!yyvsp[-3].ConstVal->getType()->isInteger()) {
3744 if (Instruction::isShift(yyvsp[-5].BinaryOpVal) || !isa<VectorType>(yyvsp[-3].ConstVal->getType()) ||
3745 !cast<VectorType>(yyvsp[-3].ConstVal->getType())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003746 GEN_ERROR("Logical operator requires integral operands");
3747 }
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003748 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003749 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003750 ;
3751 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003752case 192:
3753#line 1927 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003754{
3755 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003756 GEN_ERROR("icmp operand types must match");
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003757 yyval.ConstVal = ConstantExpr::getICmp(yyvsp[-5].IPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3758 ;
3759 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003760case 193:
3761#line 1932 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003762{
3763 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003764 GEN_ERROR("fcmp operand types must match");
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003765 yyval.ConstVal = ConstantExpr::getFCmp(yyvsp[-5].FPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3766 ;
3767 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003768case 194:
3769#line 1937 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003770{
3771 if (!ExtractElementInst::isValidOperands(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003772 GEN_ERROR("Invalid extractelement operands");
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003773 yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003774 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003775 ;
3776 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003777case 195:
3778#line 1943 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003779{
3780 if (!InsertElementInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003781 GEN_ERROR("Invalid insertelement operands");
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003782 yyval.ConstVal = ConstantExpr::getInsertElement(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003783 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003784 ;
3785 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003786case 196:
3787#line 1949 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003788{
3789 if (!ShuffleVectorInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003790 GEN_ERROR("Invalid shufflevector operands");
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003791 yyval.ConstVal = ConstantExpr::getShuffleVector(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003792 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003793 ;
3794 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003795case 197:
3796#line 1958 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003797{
3798 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003799 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003800 ;
3801 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003802case 198:
3803#line 1962 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003804{
3805 yyval.ConstVector = new std::vector<Constant*>();
3806 yyval.ConstVector->push_back(yyvsp[0].ConstVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003807 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003808 ;
3809 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003810case 199:
3811#line 1970 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003812{ yyval.BoolVal = false; ;
3813 break;}
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003814case 200:
Christopher Lambbf3348d2007-12-12 08:45:45 +00003815#line 1970 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003816{ yyval.BoolVal = true; ;
3817 break;}
3818case 201:
Christopher Lambbf3348d2007-12-12 08:45:45 +00003819#line 1973 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3820{ yyval.BoolVal = true; ;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003821 break;}
3822case 202:
Christopher Lambbf3348d2007-12-12 08:45:45 +00003823#line 1973 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3824{ yyval.BoolVal = false; ;
3825 break;}
3826case 203:
3827#line 1976 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003828{
3829 const Type* VTy = yyvsp[-1].TypeVal->get();
3830 Value *V = getVal(VTy, yyvsp[0].ValIDVal);
Chris Lattner0275cff2007-08-06 21:00:46 +00003831 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003832 GlobalValue* Aliasee = dyn_cast<GlobalValue>(V);
3833 if (!Aliasee)
3834 GEN_ERROR("Aliases can be created only to global values");
3835
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003836 yyval.ConstVal = Aliasee;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003837 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003838 delete yyvsp[-1].TypeVal;
3839 ;
3840 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003841case 204:
3842#line 1988 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003843{
3844 Constant *Val = yyvsp[-3].ConstVal;
3845 const Type *DestTy = yyvsp[-1].TypeVal->get();
3846 if (!CastInst::castIsValid(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy))
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003847 GEN_ERROR("invalid cast opcode for cast from '" +
3848 Val->getType()->getDescription() + "' to '" +
3849 DestTy->getDescription() + "'");
3850
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003851 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003852 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003853 delete yyvsp[-1].TypeVal;
3854 ;
3855 break;}
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003856case 205:
Christopher Lambbf3348d2007-12-12 08:45:45 +00003857#line 2009 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003858{
3859 yyval.ModuleVal = ParserResult = CurModule.CurrentModule;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003860 CurModule.ModuleDone();
3861 CHECK_FOR_ERROR;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003862 ;
3863 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003864case 206:
3865#line 2014 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3866{
3867 yyval.ModuleVal = ParserResult = CurModule.CurrentModule;
3868 CurModule.ModuleDone();
3869 CHECK_FOR_ERROR;
3870 ;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003871 break;}
3872case 209:
Christopher Lambbf3348d2007-12-12 08:45:45 +00003873#line 2027 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3874{ CurFun.isDeclare = false; ;
3875 break;}
3876case 210:
3877#line 2027 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003878{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003879 CurFun.FunctionDone();
3880 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003881 ;
3882 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003883case 211:
3884#line 2031 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003885{ CurFun.isDeclare = true; ;
3886 break;}
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003887case 212:
Christopher Lambbf3348d2007-12-12 08:45:45 +00003888#line 2031 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003889{
Gordon Henriksen80a75bf2007-12-10 03:18:06 +00003890 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003891 ;
3892 break;}
3893case 213:
Christopher Lambbf3348d2007-12-12 08:45:45 +00003894#line 2034 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3895{
3896 CHECK_FOR_ERROR
3897 ;
3898 break;}
3899case 214:
3900#line 2037 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003901{
Reid Spencer14310612006-12-31 05:40:51 +00003902 if (!UpRefs.empty())
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003903 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003904 // Eagerly resolve types. This is not an optimization, this is a
3905 // requirement that is due to the fact that we could have this:
3906 //
3907 // %list = type { %list * }
3908 // %list = type { %list * } ; repeated type decl
3909 //
3910 // If types are not resolved eagerly, then the two types will not be
3911 // determined to be the same type!
3912 //
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003913 ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003914
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003915 if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00003916 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003917 // If this is a named type that is not a redefinition, add it to the slot
3918 // table.
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003919 CurModule.Types.push_back(*yyvsp[0].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003920 }
Reid Spencera132e042006-12-03 05:46:11 +00003921
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003922 delete yyvsp[0].TypeVal;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003923 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003924 ;
3925 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003926case 215:
3927#line 2061 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003928{
3929 ResolveTypeTo(yyvsp[-2].StrVal, yyvsp[0].PrimType);
Reid Spencerb8f85052007-07-31 03:50:36 +00003930
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003931 if (!setTypeName(yyvsp[0].PrimType, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003932 CHECK_FOR_ERROR
3933 // If this is a named type that is not a redefinition, add it to the slot
3934 // table.
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003935 CurModule.Types.push_back(yyvsp[0].PrimType);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003936 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003937 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003938 ;
3939 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003940case 216:
3941#line 2073 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003942{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003943 /* "Externally Visible" Linkage */
Christopher Lambbf3348d2007-12-12 08:45:45 +00003944 if (yyvsp[-1].ConstVal == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003945 GEN_ERROR("Global value initializer is not a constant");
Christopher Lambbf3348d2007-12-12 08:45:45 +00003946 CurGV = ParseGlobalVariable(yyvsp[-5].StrVal, GlobalValue::ExternalLinkage,
3947 yyvsp[-4].Visibility, yyvsp[-2].BoolVal, yyvsp[-1].ConstVal->getType(), yyvsp[-1].ConstVal, yyvsp[-3].BoolVal, yyvsp[0].UIntVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003948 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003949 ;
3950 break;}
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003951case 217:
Christopher Lambbf3348d2007-12-12 08:45:45 +00003952#line 2080 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3953{
3954 CurGV = 0;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003955 ;
3956 break;}
3957case 218:
Christopher Lambbf3348d2007-12-12 08:45:45 +00003958#line 2084 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003959{
Christopher Lambbf3348d2007-12-12 08:45:45 +00003960 if (yyvsp[-1].ConstVal == 0)
3961 GEN_ERROR("Global value initializer is not a constant");
3962 CurGV = ParseGlobalVariable(yyvsp[-6].StrVal, yyvsp[-5].Linkage, yyvsp[-4].Visibility, yyvsp[-2].BoolVal, yyvsp[-1].ConstVal->getType(), yyvsp[-1].ConstVal, yyvsp[-3].BoolVal, yyvsp[0].UIntVal);
3963 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003964 ;
3965 break;}
3966case 219:
Christopher Lambbf3348d2007-12-12 08:45:45 +00003967#line 2089 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003968{
Christopher Lambbf3348d2007-12-12 08:45:45 +00003969 CurGV = 0;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003970 ;
3971 break;}
3972case 220:
Christopher Lambbf3348d2007-12-12 08:45:45 +00003973#line 2093 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003974{
Christopher Lambbf3348d2007-12-12 08:45:45 +00003975 if (!UpRefs.empty())
3976 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3977 CurGV = ParseGlobalVariable(yyvsp[-6].StrVal, yyvsp[-5].Linkage, yyvsp[-4].Visibility, yyvsp[-2].BoolVal, *yyvsp[-1].TypeVal, 0, yyvsp[-3].BoolVal, yyvsp[0].UIntVal);
3978 CHECK_FOR_ERROR
3979 delete yyvsp[-1].TypeVal;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003980 ;
3981 break;}
3982case 221:
Christopher Lambbf3348d2007-12-12 08:45:45 +00003983#line 2099 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003984{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003985 CurGV = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003986 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003987 ;
3988 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00003989case 222:
3990#line 2103 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003991{
Reid Spencer0a8a16b2007-05-22 18:52:55 +00003992 std::string Name;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00003993 if (yyvsp[-4].StrVal) {
3994 Name = *yyvsp[-4].StrVal;
3995 delete yyvsp[-4].StrVal;
Reid Spencer0a8a16b2007-05-22 18:52:55 +00003996 }
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003997 if (Name.empty())
3998 GEN_ERROR("Alias name cannot be empty");
3999
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004000 Constant* Aliasee = yyvsp[0].ConstVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004001 if (Aliasee == 0)
Reid Spencer0a8a16b2007-05-22 18:52:55 +00004002 GEN_ERROR(std::string("Invalid aliasee for alias: ") + Name);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004003
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004004 GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), yyvsp[-1].Linkage, Name, Aliasee,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004005 CurModule.CurrentModule);
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004006 GA->setVisibility(yyvsp[-3].Visibility);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004007 InsertValue(GA, CurModule.Values);
Chris Lattner569f7372007-09-10 23:24:14 +00004008
4009
4010 // If there was a forward reference of this alias, resolve it now.
4011
4012 ValID ID;
4013 if (!Name.empty())
4014 ID = ValID::createGlobalName(Name);
4015 else
4016 ID = ValID::createGlobalID(CurModule.Values.size()-1);
4017
4018 if (GlobalValue *FWGV =
4019 CurModule.GetForwardRefForGlobal(GA->getType(), ID)) {
4020 // Replace uses of the fwdref with the actual alias.
4021 FWGV->replaceAllUsesWith(GA);
4022 if (GlobalVariable *GV = dyn_cast<GlobalVariable>(FWGV))
4023 GV->eraseFromParent();
4024 else
4025 cast<Function>(FWGV)->eraseFromParent();
4026 }
4027 ID.destroy();
4028
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004029 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004030 ;
4031 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004032case 223:
4033#line 2143 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004034{
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004035 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004036 ;
4037 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004038case 224:
4039#line 2146 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004040{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004041 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004042 ;
4043 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004044case 225:
4045#line 2152 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004046{
Chris Lattner66316012006-01-24 04:14:29 +00004047 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Chris Lattner66316012006-01-24 04:14:29 +00004048 if (AsmSoFar.empty())
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004049 CurModule.CurrentModule->setModuleInlineAsm(*yyvsp[0].StrVal);
Chris Lattner66316012006-01-24 04:14:29 +00004050 else
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004051 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+*yyvsp[0].StrVal);
4052 delete yyvsp[0].StrVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00004053 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004054;
4055 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004056case 226:
4057#line 2162 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004058{
4059 CurModule.CurrentModule->setTargetTriple(*yyvsp[0].StrVal);
4060 delete yyvsp[0].StrVal;
4061 ;
4062 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004063case 227:
4064#line 2166 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004065{
4066 CurModule.CurrentModule->setDataLayout(*yyvsp[0].StrVal);
4067 delete yyvsp[0].StrVal;
4068 ;
4069 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004070case 229:
4071#line 2173 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4072{
4073 CurModule.CurrentModule->addLibrary(*yyvsp[0].StrVal);
4074 delete yyvsp[0].StrVal;
4075 CHECK_FOR_ERROR
4076 ;
4077 break;}
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004078case 230:
Christopher Lambbf3348d2007-12-12 08:45:45 +00004079#line 2178 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004080{
4081 CurModule.CurrentModule->addLibrary(*yyvsp[0].StrVal);
4082 delete yyvsp[0].StrVal;
Reid Spencer1013b4d2007-07-31 14:41:17 +00004083 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004084 ;
4085 break;}
4086case 231:
Christopher Lambbf3348d2007-12-12 08:45:45 +00004087#line 2183 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004088{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004089 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004090 ;
4091 break;}
4092case 232:
Christopher Lambbf3348d2007-12-12 08:45:45 +00004093#line 2192 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004094{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004095 if (!UpRefs.empty())
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004096 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4097 if (*yyvsp[-2].TypeVal == Type::VoidTy)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004098 GEN_ERROR("void typed arguments are invalid");
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004099 ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal;
4100 yyval.ArgList = yyvsp[-4].ArgList;
4101 yyvsp[-4].ArgList->push_back(E);
Reid Spencer6f407902007-01-13 05:00:46 +00004102 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004103 ;
4104 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004105case 233:
4106#line 2202 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004107{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004108 if (!UpRefs.empty())
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004109 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4110 if (*yyvsp[-2].TypeVal == Type::VoidTy)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004111 GEN_ERROR("void typed arguments are invalid");
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004112 ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal;
4113 yyval.ArgList = new ArgListType;
4114 yyval.ArgList->push_back(E);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004115 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004116 ;
4117 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004118case 234:
4119#line 2213 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004120{
4121 yyval.ArgList = yyvsp[0].ArgList;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004122 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004123 ;
4124 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004125case 235:
4126#line 2217 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004127{
4128 yyval.ArgList = yyvsp[-2].ArgList;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004129 struct ArgListEntry E;
4130 E.Ty = new PATypeHolder(Type::VoidTy);
4131 E.Name = 0;
Reid Spencer18da0722007-04-11 02:44:20 +00004132 E.Attrs = ParamAttr::None;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004133 yyval.ArgList->push_back(E);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004134 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004135 ;
4136 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004137case 236:
4138#line 2226 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004139{
4140 yyval.ArgList = new ArgListType;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004141 struct ArgListEntry E;
4142 E.Ty = new PATypeHolder(Type::VoidTy);
4143 E.Name = 0;
4144 E.Attrs = ParamAttr::None;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004145 yyval.ArgList->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00004146 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004147 ;
4148 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004149case 237:
4150#line 2235 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004151{
4152 yyval.ArgList = 0;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004153 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004154 ;
4155 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004156case 238:
4157#line 2241 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004158{
4159 std::string FunctionName(*yyvsp[-7].StrVal);
4160 delete yyvsp[-7].StrVal; // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004161
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004162 // Check the function result for abstractness if this is a define. We should
4163 // have no abstract types at this point
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004164 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(yyvsp[-8].TypeVal))
4165 GEN_ERROR("Reference to abstract result: "+ yyvsp[-8].TypeVal->get()->getDescription());
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004166
Reid Spencer68a24bd2005-08-27 18:50:39 +00004167 std::vector<const Type*> ParamTypeList;
Christopher Lamb5c104242007-04-22 20:09:11 +00004168 ParamAttrsVector Attrs;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004169 if (yyvsp[-3].ParamAttrs != ParamAttr::None) {
Duncan Sandsdc024672007-11-27 13:23:08 +00004170 ParamAttrsWithIndex PAWI;
4171 PAWI.index = 0;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004172 PAWI.attrs = yyvsp[-3].ParamAttrs;
Christopher Lamb5c104242007-04-22 20:09:11 +00004173 Attrs.push_back(PAWI);
4174 }
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004175 if (yyvsp[-5].ArgList) { // If there are arguments...
Reid Spencer7b5d4662007-04-09 06:16:21 +00004176 unsigned index = 1;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004177 for (ArgListType::iterator I = yyvsp[-5].ArgList->begin(); I != yyvsp[-5].ArgList->end(); ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00004178 const Type* Ty = I->Ty->get();
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004179 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
4180 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00004181 ParamTypeList.push_back(Ty);
4182 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00004183 if (I->Attrs != ParamAttr::None) {
Duncan Sandsdc024672007-11-27 13:23:08 +00004184 ParamAttrsWithIndex PAWI;
4185 PAWI.index = index;
4186 PAWI.attrs = I->Attrs;
Christopher Lamb5c104242007-04-22 20:09:11 +00004187 Attrs.push_back(PAWI);
4188 }
Reid Spencer14310612006-12-31 05:40:51 +00004189 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004190 }
4191
4192 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
4193 if (isVarArg) ParamTypeList.pop_back();
4194
Duncan Sandsafa3b6d2007-11-28 17:07:01 +00004195 const ParamAttrsList *PAL = 0;
Christopher Lamb5c104242007-04-22 20:09:11 +00004196 if (!Attrs.empty())
4197 PAL = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00004198
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004199 FunctionType *FT = FunctionType::get(*yyvsp[-8].TypeVal, ParamTypeList, isVarArg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004200 const PointerType *PFT = PointerType::get(FT);
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004201 delete yyvsp[-8].TypeVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004202
4203 ValID ID;
4204 if (!FunctionName.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004205 ID = ValID::createGlobalName((char*)FunctionName.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004206 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00004207 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004208 }
4209
4210 Function *Fn = 0;
4211 // See if this function was forward referenced. If so, recycle the object.
4212 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4213 // Move the function to the end of the list, from whereever it was
4214 // previously inserted.
4215 Fn = cast<Function>(FWRef);
Duncan Sandsdc024672007-11-27 13:23:08 +00004216 assert(!Fn->getParamAttrs() && "Forward reference has parameter attributes!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004217 CurModule.CurrentModule->getFunctionList().remove(Fn);
4218 CurModule.CurrentModule->getFunctionList().push_back(Fn);
4219 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
Reid Spenceref9b9a72007-02-05 20:47:22 +00004220 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
Duncan Sandsdc024672007-11-27 13:23:08 +00004221 if (Fn->getFunctionType() != FT ) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00004222 // The existing function doesn't have the same type. This is an overload
4223 // error.
4224 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
Duncan Sandsdc024672007-11-27 13:23:08 +00004225 } else if (Fn->getParamAttrs() != PAL) {
4226 // The existing function doesn't have the same parameter attributes.
4227 // This is an overload error.
4228 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
Reid Spenceref9b9a72007-02-05 20:47:22 +00004229 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00004230 // Neither the existing or the current function is a declaration and they
4231 // have the same name and same type. Clearly this is a redefinition.
4232 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
Duncan Sandsdc024672007-11-27 13:23:08 +00004233 } else if (Fn->isDeclaration()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00004234 // Make sure to strip off any argument names so we can't get conflicts.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004235 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
4236 AI != AE; ++AI)
4237 AI->setName("");
Reid Spenceref9b9a72007-02-05 20:47:22 +00004238 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004239 } else { // Not already defined?
Chris Lattner6cdc6822007-04-26 05:31:05 +00004240 Fn = new Function(FT, GlobalValue::ExternalWeakLinkage, FunctionName,
Reid Spencer68a24bd2005-08-27 18:50:39 +00004241 CurModule.CurrentModule);
4242 InsertValue(Fn, CurModule.Values);
4243 }
4244
4245 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004246
4247 if (CurFun.isDeclare) {
4248 // If we have declaration, always overwrite linkage. This will allow us to
4249 // correctly handle cases, when pointer to function is passed as argument to
4250 // another function.
4251 Fn->setLinkage(CurFun.Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004252 Fn->setVisibility(CurFun.Visibility);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004253 }
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004254 Fn->setCallingConv(yyvsp[-9].UIntVal);
Duncan Sandsdc024672007-11-27 13:23:08 +00004255 Fn->setParamAttrs(PAL);
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004256 Fn->setAlignment(yyvsp[-1].UIntVal);
4257 if (yyvsp[-2].StrVal) {
4258 Fn->setSection(*yyvsp[-2].StrVal);
4259 delete yyvsp[-2].StrVal;
Gordon Henriksen80a75bf2007-12-10 03:18:06 +00004260 }
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004261 if (yyvsp[0].StrVal) {
4262 Fn->setCollector(yyvsp[0].StrVal->c_str());
4263 delete yyvsp[0].StrVal;
Chris Lattnere869eef2005-11-12 00:11:49 +00004264 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004265
4266 // Add all of the arguments we parsed to the function...
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004267 if (yyvsp[-5].ArgList) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00004268 if (isVarArg) { // Nuke the last entry
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004269 assert(yyvsp[-5].ArgList->back().Ty->get() == Type::VoidTy && yyvsp[-5].ArgList->back().Name == 0 &&
Reid Spencera9720f52007-02-05 17:04:00 +00004270 "Not a varargs marker!");
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004271 delete yyvsp[-5].ArgList->back().Ty;
4272 yyvsp[-5].ArgList->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00004273 }
4274 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00004275 Function::arg_iterator ArgEnd = Fn->arg_end();
Reid Spencer14310612006-12-31 05:40:51 +00004276 unsigned Idx = 1;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004277 for (ArgListType::iterator I = yyvsp[-5].ArgList->begin();
4278 I != yyvsp[-5].ArgList->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencer14310612006-12-31 05:40:51 +00004279 delete I->Ty; // Delete the typeholder...
Reid Spencer0a8a16b2007-05-22 18:52:55 +00004280 setValueName(ArgIt, I->Name); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00004281 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004282 InsertValue(ArgIt);
Reid Spencer14310612006-12-31 05:40:51 +00004283 Idx++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004284 }
Reid Spencera132e042006-12-03 05:46:11 +00004285
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004286 delete yyvsp[-5].ArgList; // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00004287 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004288 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004289;
4290 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004291case 241:
4292#line 2376 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004293{
4294 yyval.FunctionVal = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004295
4296 // Make sure that we keep track of the linkage type even if there was a
4297 // previous "declare".
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004298 yyval.FunctionVal->setLinkage(yyvsp[-3].Linkage);
4299 yyval.FunctionVal->setVisibility(yyvsp[-2].Visibility);
4300;
4301 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004302case 244:
4303#line 2387 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004304{
4305 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004306 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004307;
4308 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004309case 245:
4310#line 2392 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004311{
4312 CurFun.CurrentFunction->setLinkage(yyvsp[-2].Linkage);
4313 CurFun.CurrentFunction->setVisibility(yyvsp[-1].Visibility);
4314 yyval.FunctionVal = CurFun.CurrentFunction;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004315 CurFun.FunctionDone();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004316 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004317 ;
4318 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004319case 246:
4320#line 2404 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004321{
4322 yyval.BoolVal = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00004323 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004324 ;
4325 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004326case 247:
4327#line 2408 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004328{
4329 yyval.BoolVal = true;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004330 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004331 ;
4332 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004333case 248:
4334#line 2413 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004335{ // A reference to a direct constant
4336 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004337 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004338 ;
4339 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004340case 249:
4341#line 2417 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004342{
4343 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004344 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004345 ;
4346 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004347case 250:
4348#line 2421 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004349{ // Perhaps it's an FP constant?
4350 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004351 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004352 ;
4353 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004354case 251:
4355#line 2425 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004356{
4357 yyval.ValIDVal = ValID::create(ConstantInt::getTrue());
Reid Spencere4d87aa2006-12-23 06:05:41 +00004358 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004359 ;
4360 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004361case 252:
4362#line 2429 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004363{
4364 yyval.ValIDVal = ValID::create(ConstantInt::getFalse());
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004365 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004366 ;
4367 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004368case 253:
4369#line 2433 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004370{
4371 yyval.ValIDVal = ValID::createNull();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004372 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004373 ;
4374 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004375case 254:
4376#line 2437 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004377{
4378 yyval.ValIDVal = ValID::createUndef();
Reid Spencer61c83e02006-08-18 08:43:06 +00004379 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004380 ;
4381 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004382case 255:
4383#line 2441 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004384{ // A vector zero constant.
4385 yyval.ValIDVal = ValID::createZeroInit();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004386 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004387 ;
4388 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004389case 256:
4390#line 2445 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004391{ // Nonempty unsized packed vector
4392 const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
4393 int NumElements = yyvsp[-1].ConstVector->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004394
Reid Spencer9d6565a2007-02-15 02:26:10 +00004395 VectorType* pt = VectorType::get(ETy, NumElements);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004396 PATypeHolder* PTy = new PATypeHolder(
Reid Spencera132e042006-12-03 05:46:11 +00004397 HandleUpRefs(
Reid Spencer9d6565a2007-02-15 02:26:10 +00004398 VectorType::get(
Reid Spencera132e042006-12-03 05:46:11 +00004399 ETy,
4400 NumElements)
4401 )
4402 );
Reid Spencer68a24bd2005-08-27 18:50:39 +00004403
4404 // Verify all elements are correct type!
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004405 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
4406 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00004407 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00004408 ETy->getDescription() +"' as required!\nIt is of type '" +
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004409 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004410 }
4411
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004412 yyval.ValIDVal = ValID::create(ConstantVector::get(pt, *yyvsp[-1].ConstVector));
4413 delete PTy; delete yyvsp[-1].ConstVector;
Reid Spencer832254e2007-02-02 02:16:23 +00004414 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004415 ;
4416 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004417case 257:
4418#line 2470 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004419{
4420 yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
Reid Spencer832254e2007-02-02 02:16:23 +00004421 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004422 ;
4423 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004424case 258:
4425#line 2474 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004426{
4427 yyval.ValIDVal = ValID::createInlineAsm(*yyvsp[-2].StrVal, *yyvsp[0].StrVal, yyvsp[-3].BoolVal);
4428 delete yyvsp[-2].StrVal;
4429 delete yyvsp[0].StrVal;
Reid Spencer832254e2007-02-02 02:16:23 +00004430 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004431 ;
4432 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004433case 259:
4434#line 2484 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004435{ // Is it an integer reference...?
4436 yyval.ValIDVal = ValID::createLocalID(yyvsp[0].UIntVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004437 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004438 ;
4439 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004440case 260:
4441#line 2488 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004442{
4443 yyval.ValIDVal = ValID::createGlobalID(yyvsp[0].UIntVal);
Reid Spencer832254e2007-02-02 02:16:23 +00004444 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004445 ;
4446 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004447case 261:
4448#line 2492 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004449{ // Is it a named reference...?
4450 yyval.ValIDVal = ValID::createLocalName(*yyvsp[0].StrVal);
4451 delete yyvsp[0].StrVal;
Reid Spencer832254e2007-02-02 02:16:23 +00004452 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004453 ;
4454 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004455case 262:
4456#line 2497 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004457{ // Is it a named reference...?
4458 yyval.ValIDVal = ValID::createGlobalName(*yyvsp[0].StrVal);
4459 delete yyvsp[0].StrVal;
Reid Spencer832254e2007-02-02 02:16:23 +00004460 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004461 ;
4462 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004463case 265:
4464#line 2510 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004465{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004466 if (!UpRefs.empty())
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004467 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4468 yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
4469 delete yyvsp[-1].TypeVal;
Reid Spencer832254e2007-02-02 02:16:23 +00004470 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004471 ;
4472 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004473case 266:
4474#line 2519 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004475{
4476 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004477 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004478 ;
4479 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004480case 267:
4481#line 2523 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004482{ // Do not allow functions with 0 basic blocks
4483 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004484 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004485 ;
4486 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004487case 268:
4488#line 2532 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004489{
4490 setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004491 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004492 InsertValue(yyvsp[0].TermInstVal);
4493 yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
4494 yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004495 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004496 ;
4497 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004498case 269:
4499#line 2541 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004500{
4501 if (CastInst *CI1 = dyn_cast<CastInst>(yyvsp[0].InstVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004502 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
4503 if (CI2->getParent() == 0)
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004504 yyvsp[-1].BasicBlockVal->getInstList().push_back(CI2);
4505 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
4506 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004507 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004508 ;
4509 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004510case 270:
4511#line 2550 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004512{ // Empty space between instruction lists
4513 yyval.BasicBlockVal = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
Reid Spencered951ea2007-05-19 07:22:10 +00004514 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004515 ;
4516 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004517case 271:
4518#line 2554 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004519{ // Labelled (named) basic block
4520 yyval.BasicBlockVal = defineBBVal(ValID::createLocalName(*yyvsp[0].StrVal));
4521 delete yyvsp[0].StrVal;
Reid Spencered951ea2007-05-19 07:22:10 +00004522 CHECK_FOR_ERROR
Reid Spencer0a8a16b2007-05-22 18:52:55 +00004523
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004524 ;
4525 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004526case 272:
4527#line 2561 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004528{ // Return with a result...
4529 yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
4530 CHECK_FOR_ERROR
4531 ;
4532 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004533case 273:
4534#line 2565 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004535{ // Return with no result...
4536 yyval.TermInstVal = new ReturnInst();
4537 CHECK_FOR_ERROR
4538 ;
4539 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004540case 274:
4541#line 2569 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004542{ // Unconditional Branch...
4543 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
4544 CHECK_FOR_ERROR
4545 yyval.TermInstVal = new BranchInst(tmpBB);
4546 ;
4547 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004548case 275:
4549#line 2574 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004550{
4551 assert(cast<IntegerType>(yyvsp[-7].PrimType)->getBitWidth() == 1 && "Not Bool?");
4552 BasicBlock* tmpBBA = getBBVal(yyvsp[-3].ValIDVal);
4553 CHECK_FOR_ERROR
4554 BasicBlock* tmpBBB = getBBVal(yyvsp[0].ValIDVal);
4555 CHECK_FOR_ERROR
4556 Value* tmpVal = getVal(Type::Int1Ty, yyvsp[-6].ValIDVal);
4557 CHECK_FOR_ERROR
4558 yyval.TermInstVal = new BranchInst(tmpBBA, tmpBBB, tmpVal);
4559 ;
4560 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004561case 276:
4562#line 2584 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004563{
4564 Value* tmpVal = getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal);
4565 CHECK_FOR_ERROR
4566 BasicBlock* tmpBB = getBBVal(yyvsp[-3].ValIDVal);
4567 CHECK_FOR_ERROR
4568 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, yyvsp[-1].JumpTable->size());
4569 yyval.TermInstVal = S;
Reid Spencerb8f85052007-07-31 03:50:36 +00004570
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004571 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
4572 E = yyvsp[-1].JumpTable->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004573 for (; I != E; ++I) {
4574 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
4575 S->addCase(CI, I->second);
4576 else
Reid Spencerb5334b02007-02-05 10:18:06 +00004577 GEN_ERROR("Switch case is constant, but not a simple integer");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004578 }
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004579 delete yyvsp[-1].JumpTable;
Reid Spencer61c83e02006-08-18 08:43:06 +00004580 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004581 ;
4582 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004583case 277:
4584#line 2603 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004585{
4586 Value* tmpVal = getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004587 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004588 BasicBlock* tmpBB = getBBVal(yyvsp[-2].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004589 CHECK_FOR_ERROR
4590 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004591 yyval.TermInstVal = S;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004592 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004593 ;
4594 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004595case 278:
4596#line 2613 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004597{
Reid Spencer3822ff52006-11-08 06:47:33 +00004598
Reid Spencer14310612006-12-31 05:40:51 +00004599 // Handle the short syntax
4600 const PointerType *PFTy = 0;
4601 const FunctionType *Ty = 0;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004602 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-11].TypeVal->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00004603 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4604 // Pull out the types of all of the arguments...
4605 std::vector<const Type*> ParamTypes;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004606 ParamList::iterator I = yyvsp[-8].ParamList->begin(), E = yyvsp[-8].ParamList->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00004607 for (; I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00004608 const Type *Ty = I->Val->getType();
4609 if (Ty == Type::VoidTy)
4610 GEN_ERROR("Short call syntax cannot be used with varargs");
4611 ParamTypes.push_back(Ty);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004612 }
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004613 Ty = FunctionType::get(yyvsp[-11].TypeVal->get(), ParamTypes, false);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004614 PFTy = PointerType::get(Ty);
4615 }
4616
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004617 delete yyvsp[-11].TypeVal;
Reid Spencer66728ef2007-03-20 01:13:36 +00004618
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004619 Value *V = getVal(PFTy, yyvsp[-10].ValIDVal); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00004620 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004621 BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004622 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004623 BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
Reid Spencer5b7e7532006-09-28 19:28:24 +00004624 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004625
Duncan Sandsdc024672007-11-27 13:23:08 +00004626 ParamAttrsVector Attrs;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004627 if (yyvsp[-6].ParamAttrs != ParamAttr::None) {
4628 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[-6].ParamAttrs;
Duncan Sandsdc024672007-11-27 13:23:08 +00004629 Attrs.push_back(PAWI);
4630 }
4631
Reid Spencer14310612006-12-31 05:40:51 +00004632 // Check the arguments
4633 ValueList Args;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004634 if (yyvsp[-8].ParamList->empty()) { // Has no arguments?
Reid Spencer14310612006-12-31 05:40:51 +00004635 // Make sure no arguments is a good thing!
4636 if (Ty->getNumParams() != 0)
4637 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00004638 "expects arguments");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004639 } else { // Has arguments?
4640 // Loop through FunctionType's arguments and ensure they are specified
4641 // correctly!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004642 FunctionType::param_iterator I = Ty->param_begin();
4643 FunctionType::param_iterator E = Ty->param_end();
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004644 ParamList::iterator ArgI = yyvsp[-8].ParamList->begin(), ArgE = yyvsp[-8].ParamList->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00004645 unsigned index = 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004646
Duncan Sandsdc024672007-11-27 13:23:08 +00004647 for (; ArgI != ArgE && I != E; ++ArgI, ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00004648 if (ArgI->Val->getType() != *I)
4649 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00004650 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00004651 Args.push_back(ArgI->Val);
Duncan Sandsdc024672007-11-27 13:23:08 +00004652 if (ArgI->Attrs != ParamAttr::None) {
4653 ParamAttrsWithIndex PAWI;
4654 PAWI.index = index;
4655 PAWI.attrs = ArgI->Attrs;
4656 Attrs.push_back(PAWI);
4657 }
Reid Spencer14310612006-12-31 05:40:51 +00004658 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004659
Reid Spencer14310612006-12-31 05:40:51 +00004660 if (Ty->isVarArg()) {
4661 if (I == E)
4662 for (; ArgI != ArgE; ++ArgI)
4663 Args.push_back(ArgI->Val); // push the remaining varargs
4664 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00004665 GEN_ERROR("Invalid number of parameters detected");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004666 }
Reid Spencer14310612006-12-31 05:40:51 +00004667
Duncan Sandsafa3b6d2007-11-28 17:07:01 +00004668 const ParamAttrsList *PAL = 0;
Duncan Sandsdc024672007-11-27 13:23:08 +00004669 if (!Attrs.empty())
4670 PAL = ParamAttrsList::get(Attrs);
4671
Reid Spencer14310612006-12-31 05:40:51 +00004672 // Create the InvokeInst
Chris Lattnerd80fb8b2007-08-29 16:15:23 +00004673 InvokeInst *II = new InvokeInst(V, Normal, Except, Args.begin(), Args.end());
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004674 II->setCallingConv(yyvsp[-12].UIntVal);
Duncan Sandsdc024672007-11-27 13:23:08 +00004675 II->setParamAttrs(PAL);
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004676 yyval.TermInstVal = II;
4677 delete yyvsp[-8].ParamList;
Andrew Lenharth6353e052006-12-08 18:07:09 +00004678 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004679 ;
4680 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004681case 279:
4682#line 2696 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004683{
4684 yyval.TermInstVal = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00004685 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004686 ;
4687 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004688case 280:
4689#line 2700 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004690{
4691 yyval.TermInstVal = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00004692 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004693 ;
4694 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004695case 281:
4696#line 2707 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004697{
4698 yyval.JumpTable = yyvsp[-5].JumpTable;
4699 Constant *V = cast<Constant>(getExistingVal(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004700 CHECK_FOR_ERROR
4701 if (V == 0)
4702 GEN_ERROR("May only switch on a constant pool value");
4703
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004704 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004705 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004706 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
4707 ;
4708 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004709case 282:
4710#line 2718 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004711{
4712 yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
4713 Constant *V = cast<Constant>(getExistingVal(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004714 CHECK_FOR_ERROR
4715
4716 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004717 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00004718
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004719 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004720 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004721 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
4722 ;
4723 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004724case 283:
4725#line 2731 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004726{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004727 // Is this definition named?? if so, assign the name...
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004728 setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004729 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004730 InsertValue(yyvsp[0].InstVal);
4731 yyval.InstVal = yyvsp[0].InstVal;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004732 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004733 ;
4734 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004735case 284:
4736#line 2741 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004737{ // Used for PHI nodes
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004738 if (!UpRefs.empty())
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004739 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-5].TypeVal)->getDescription());
4740 yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
4741 Value* tmpVal = getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal);
Reid Spencer6f407902007-01-13 05:00:46 +00004742 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004743 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004744 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004745 yyval.PHIList->push_back(std::make_pair(tmpVal, tmpBB));
4746 delete yyvsp[-5].TypeVal;
4747 ;
4748 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004749case 285:
4750#line 2752 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004751{
4752 yyval.PHIList = yyvsp[-6].PHIList;
4753 Value* tmpVal = getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004754 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004755 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004756 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004757 yyvsp[-6].PHIList->push_back(std::make_pair(tmpVal, tmpBB));
4758 ;
4759 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004760case 286:
4761#line 2762 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004762{
Duncan Sandsdc024672007-11-27 13:23:08 +00004763 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004764 if (!UpRefs.empty())
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004765 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004766 // Used for call and invoke instructions
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004767 yyval.ParamList = new ParamList();
4768 ParamListEntry E; E.Attrs = yyvsp[-2].ParamAttrs | yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-3].TypeVal->get(), yyvsp[-1].ValIDVal);
4769 yyval.ParamList->push_back(E);
4770 delete yyvsp[-3].TypeVal;
Duncan Sandsdc024672007-11-27 13:23:08 +00004771 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004772 ;
4773 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004774case 287:
4775#line 2773 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004776{
Duncan Sandsdc024672007-11-27 13:23:08 +00004777 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Dale Johanneseneb57ea72007-11-05 21:20:28 +00004778 // Labels are only valid in ASMs
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004779 yyval.ParamList = new ParamList();
4780 ParamListEntry E; E.Attrs = yyvsp[-2].ParamAttrs | yyvsp[0].ParamAttrs; E.Val = getBBVal(yyvsp[-1].ValIDVal);
4781 yyval.ParamList->push_back(E);
Duncan Sandsdc024672007-11-27 13:23:08 +00004782 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004783 ;
4784 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004785case 288:
4786#line 2781 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004787{
Duncan Sandsdc024672007-11-27 13:23:08 +00004788 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004789 if (!UpRefs.empty())
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004790 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4791 yyval.ParamList = yyvsp[-5].ParamList;
4792 ParamListEntry E; E.Attrs = yyvsp[-2].ParamAttrs | yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-3].TypeVal->get(), yyvsp[-1].ValIDVal);
4793 yyval.ParamList->push_back(E);
4794 delete yyvsp[-3].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004795 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004796 ;
4797 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004798case 289:
4799#line 2791 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004800{
Duncan Sandsdc024672007-11-27 13:23:08 +00004801 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004802 yyval.ParamList = yyvsp[-5].ParamList;
4803 ParamListEntry E; E.Attrs = yyvsp[-2].ParamAttrs | yyvsp[0].ParamAttrs; E.Val = getBBVal(yyvsp[-1].ValIDVal);
4804 yyval.ParamList->push_back(E);
Dale Johanneseneb57ea72007-11-05 21:20:28 +00004805 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004806 ;
4807 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004808case 290:
4809#line 2798 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004810{ yyval.ParamList = new ParamList(); ;
4811 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004812case 291:
4813#line 2801 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004814{ yyval.ValueList = new std::vector<Value*>(); ;
4815 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004816case 292:
4817#line 2802 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004818{
4819 yyval.ValueList = yyvsp[-2].ValueList;
4820 yyval.ValueList->push_back(yyvsp[0].ValueVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004821 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004822 ;
4823 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004824case 293:
4825#line 2809 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004826{
4827 yyval.BoolVal = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004828 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004829 ;
4830 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004831case 294:
4832#line 2813 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004833{
4834 yyval.BoolVal = false;
Andrew Lenharth6353e052006-12-08 18:07:09 +00004835 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004836 ;
4837 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004838case 295:
4839#line 2818 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004840{
Reid Spencer14310612006-12-31 05:40:51 +00004841 if (!UpRefs.empty())
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004842 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4843 if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
4844 !isa<VectorType>((*yyvsp[-3].TypeVal).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004845 GEN_ERROR(
4846 "Arithmetic operator requires integer, FP, or packed operands");
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004847 Value* val1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004848 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004849 Value* val2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004850 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004851 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, val1, val2);
4852 if (yyval.InstVal == 0)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004853 GEN_ERROR("binary operator returned null");
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004854 delete yyvsp[-3].TypeVal;
4855 ;
4856 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004857case 296:
4858#line 2834 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004859{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004860 if (!UpRefs.empty())
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004861 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4862 if (!(*yyvsp[-3].TypeVal)->isInteger()) {
4863 if (Instruction::isShift(yyvsp[-4].BinaryOpVal) || !isa<VectorType>(yyvsp[-3].TypeVal->get()) ||
4864 !cast<VectorType>(yyvsp[-3].TypeVal->get())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004865 GEN_ERROR("Logical operator requires integral operands");
4866 }
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004867 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004868 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004869 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004870 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004871 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, tmpVal1, tmpVal2);
4872 if (yyval.InstVal == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004873 GEN_ERROR("binary operator returned null");
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004874 delete yyvsp[-3].TypeVal;
4875 ;
4876 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004877case 297:
4878#line 2851 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004879{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004880 if (!UpRefs.empty())
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004881 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4882 if (isa<VectorType>((*yyvsp[-3].TypeVal).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004883 GEN_ERROR("Vector types not supported by icmp instruction");
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004884 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004885 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004886 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004887 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004888 yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].IPredicate, tmpVal1, tmpVal2);
4889 if (yyval.InstVal == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004890 GEN_ERROR("icmp operator returned null");
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004891 delete yyvsp[-3].TypeVal;
4892 ;
4893 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004894case 298:
4895#line 2865 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004896{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004897 if (!UpRefs.empty())
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004898 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4899 if (isa<VectorType>((*yyvsp[-3].TypeVal).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004900 GEN_ERROR("Vector types not supported by fcmp instruction");
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004901 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004902 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004903 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004904 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004905 yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].FPredicate, tmpVal1, tmpVal2);
4906 if (yyval.InstVal == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004907 GEN_ERROR("fcmp operator returned null");
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004908 delete yyvsp[-3].TypeVal;
4909 ;
4910 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004911case 299:
4912#line 2879 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004913{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004914 if (!UpRefs.empty())
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004915 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
4916 Value* Val = yyvsp[-2].ValueVal;
4917 const Type* DestTy = yyvsp[0].TypeVal->get();
4918 if (!CastInst::castIsValid(yyvsp[-3].CastOpVal, Val, DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004919 GEN_ERROR("invalid cast opcode for cast from '" +
4920 Val->getType()->getDescription() + "' to '" +
4921 DestTy->getDescription() + "'");
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004922 yyval.InstVal = CastInst::create(yyvsp[-3].CastOpVal, Val, DestTy);
4923 delete yyvsp[0].TypeVal;
4924 ;
4925 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004926case 300:
4927#line 2891 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004928{
4929 if (yyvsp[-4].ValueVal->getType() != Type::Int1Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004930 GEN_ERROR("select condition must be boolean");
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004931 if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004932 GEN_ERROR("select value types should match");
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004933 yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004934 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004935 ;
4936 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004937case 301:
4938#line 2899 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004939{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004940 if (!UpRefs.empty())
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004941 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
4942 yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
4943 delete yyvsp[0].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00004944 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004945 ;
4946 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004947case 302:
4948#line 2906 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004949{
4950 if (!ExtractElementInst::isValidOperands(yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004951 GEN_ERROR("Invalid extractelement operands");
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004952 yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004953 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004954 ;
4955 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004956case 303:
4957#line 2912 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004958{
4959 if (!InsertElementInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004960 GEN_ERROR("Invalid insertelement operands");
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004961 yyval.InstVal = new InsertElementInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004962 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004963 ;
4964 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004965case 304:
4966#line 2918 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004967{
4968 if (!ShuffleVectorInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004969 GEN_ERROR("Invalid shufflevector operands");
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004970 yyval.InstVal = new ShuffleVectorInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004971 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004972 ;
4973 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004974case 305:
4975#line 2924 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004976{
4977 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004978 if (!Ty->isFirstClassType())
4979 GEN_ERROR("PHI node operands must be of first class type");
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004980 yyval.InstVal = new PHINode(Ty);
4981 ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
4982 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
4983 if (yyvsp[0].PHIList->front().first->getType() != Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004984 GEN_ERROR("All elements of a PHI node must be of the same type");
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004985 cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
4986 yyvsp[0].PHIList->pop_front();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004987 }
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004988 delete yyvsp[0].PHIList; // Free the list...
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004989 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004990 ;
4991 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00004992case 306:
4993#line 2940 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004994{
Reid Spencer14310612006-12-31 05:40:51 +00004995
4996 // Handle the short syntax
Andrew Lenharth6353e052006-12-08 18:07:09 +00004997 const PointerType *PFTy = 0;
4998 const FunctionType *Ty = 0;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00004999 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-5].TypeVal->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00005000 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5001 // Pull out the types of all of the arguments...
5002 std::vector<const Type*> ParamTypes;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005003 ParamList::iterator I = yyvsp[-2].ParamList->begin(), E = yyvsp[-2].ParamList->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00005004 for (; I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00005005 const Type *Ty = I->Val->getType();
5006 if (Ty == Type::VoidTy)
5007 GEN_ERROR("Short call syntax cannot be used with varargs");
5008 ParamTypes.push_back(Ty);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005009 }
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005010 Ty = FunctionType::get(yyvsp[-5].TypeVal->get(), ParamTypes, false);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005011 PFTy = PointerType::get(Ty);
5012 }
Chris Lattner6cdc6822007-04-26 05:31:05 +00005013
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005014 Value *V = getVal(PFTy, yyvsp[-4].ValIDVal); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005015 CHECK_FOR_ERROR
Chris Lattner6cdc6822007-04-26 05:31:05 +00005016
Reid Spencer7780acb2007-04-16 06:56:07 +00005017 // Check for call to invalid intrinsic to avoid crashing later.
5018 if (Function *theF = dyn_cast<Function>(V)) {
Reid Spencered48de22007-04-16 22:02:23 +00005019 if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) &&
Reid Spencer36fdde12007-04-16 20:35:38 +00005020 (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) &&
5021 !theF->getIntrinsicID(true))
Reid Spencer7780acb2007-04-16 06:56:07 +00005022 GEN_ERROR("Call to invalid LLVM intrinsic function '" +
5023 theF->getName() + "'");
5024 }
5025
Duncan Sandsdc024672007-11-27 13:23:08 +00005026 // Set up the ParamAttrs for the function
5027 ParamAttrsVector Attrs;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005028 if (yyvsp[0].ParamAttrs != ParamAttr::None) {
Duncan Sandsdc024672007-11-27 13:23:08 +00005029 ParamAttrsWithIndex PAWI;
5030 PAWI.index = 0;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005031 PAWI.attrs = yyvsp[0].ParamAttrs;
Duncan Sandsdc024672007-11-27 13:23:08 +00005032 Attrs.push_back(PAWI);
5033 }
Reid Spencer14310612006-12-31 05:40:51 +00005034 // Check the arguments
5035 ValueList Args;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005036 if (yyvsp[-2].ParamList->empty()) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00005037 // Make sure no arguments is a good thing!
5038 if (Ty->getNumParams() != 0)
5039 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00005040 "expects arguments");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005041 } else { // Has arguments?
5042 // Loop through FunctionType's arguments and ensure they are specified
Duncan Sandsdc024672007-11-27 13:23:08 +00005043 // correctly. Also, gather any parameter attributes.
Andrew Lenharth6353e052006-12-08 18:07:09 +00005044 FunctionType::param_iterator I = Ty->param_begin();
5045 FunctionType::param_iterator E = Ty->param_end();
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005046 ParamList::iterator ArgI = yyvsp[-2].ParamList->begin(), ArgE = yyvsp[-2].ParamList->end();
Duncan Sandsdc024672007-11-27 13:23:08 +00005047 unsigned index = 1;
Andrew Lenharth6353e052006-12-08 18:07:09 +00005048
Duncan Sandsdc024672007-11-27 13:23:08 +00005049 for (; ArgI != ArgE && I != E; ++ArgI, ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005050 if (ArgI->Val->getType() != *I)
5051 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005052 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00005053 Args.push_back(ArgI->Val);
Duncan Sandsdc024672007-11-27 13:23:08 +00005054 if (ArgI->Attrs != ParamAttr::None) {
5055 ParamAttrsWithIndex PAWI;
5056 PAWI.index = index;
5057 PAWI.attrs = ArgI->Attrs;
5058 Attrs.push_back(PAWI);
5059 }
Reid Spencer14310612006-12-31 05:40:51 +00005060 }
5061 if (Ty->isVarArg()) {
5062 if (I == E)
5063 for (; ArgI != ArgE; ++ArgI)
5064 Args.push_back(ArgI->Val); // push the remaining varargs
5065 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00005066 GEN_ERROR("Invalid number of parameters detected");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005067 }
Duncan Sandsdc024672007-11-27 13:23:08 +00005068
5069 // Finish off the ParamAttrs and check them
Duncan Sandsafa3b6d2007-11-28 17:07:01 +00005070 const ParamAttrsList *PAL = 0;
Duncan Sandsdc024672007-11-27 13:23:08 +00005071 if (!Attrs.empty())
5072 PAL = ParamAttrsList::get(Attrs);
5073
Reid Spencer14310612006-12-31 05:40:51 +00005074 // Create the call node
David Greene718fda32007-08-01 03:59:32 +00005075 CallInst *CI = new CallInst(V, Args.begin(), Args.end());
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005076 CI->setTailCall(yyvsp[-7].BoolVal);
5077 CI->setCallingConv(yyvsp[-6].UIntVal);
Duncan Sandsdc024672007-11-27 13:23:08 +00005078 CI->setParamAttrs(PAL);
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005079 yyval.InstVal = CI;
5080 delete yyvsp[-2].ParamList;
5081 delete yyvsp[-5].TypeVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005082 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005083 ;
5084 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00005085case 307:
5086#line 3030 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005087{
5088 yyval.InstVal = yyvsp[0].InstVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005089 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005090 ;
5091 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00005092case 308:
5093#line 3035 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005094{
5095 yyval.BoolVal = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005096 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005097 ;
5098 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00005099case 309:
5100#line 3039 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005101{
5102 yyval.BoolVal = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00005103 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005104 ;
5105 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00005106case 310:
5107#line 3046 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005108{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005109 if (!UpRefs.empty())
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005110 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
5111 yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
5112 delete yyvsp[-1].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00005113 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005114 ;
5115 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00005116case 311:
5117#line 3053 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005118{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005119 if (!UpRefs.empty())
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005120 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
5121 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005122 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005123 yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
5124 delete yyvsp[-4].TypeVal;
5125 ;
5126 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00005127case 312:
5128#line 3061 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005129{
Reid Spencer14310612006-12-31 05:40:51 +00005130 if (!UpRefs.empty())
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005131 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
5132 yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
5133 delete yyvsp[-1].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00005134 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005135 ;
5136 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00005137case 313:
5138#line 3068 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005139{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005140 if (!UpRefs.empty())
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005141 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
5142 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005143 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005144 yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
5145 delete yyvsp[-4].TypeVal;
5146 ;
5147 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00005148case 314:
5149#line 3076 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005150{
5151 if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005152 GEN_ERROR("Trying to free nonpointer type " +
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005153 yyvsp[0].ValueVal->getType()->getDescription() + "");
5154 yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005155 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005156 ;
5157 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00005158case 315:
5159#line 3084 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005160{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005161 if (!UpRefs.empty())
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005162 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
5163 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005164 GEN_ERROR("Can't load from nonpointer type: " +
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005165 (*yyvsp[-2].TypeVal)->getDescription());
5166 if (!cast<PointerType>(yyvsp[-2].TypeVal->get())->getElementType()->isFirstClassType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005167 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005168 (*yyvsp[-2].TypeVal)->getDescription());
5169 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005170 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005171 yyval.InstVal = new LoadInst(tmpVal, "", yyvsp[-4].BoolVal, yyvsp[0].UIntVal);
5172 delete yyvsp[-2].TypeVal;
5173 ;
5174 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00005175case 316:
5176#line 3098 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005177{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005178 if (!UpRefs.empty())
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005179 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
5180 const PointerType *PT = dyn_cast<PointerType>(yyvsp[-2].TypeVal->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005181 if (!PT)
5182 GEN_ERROR("Can't store to a nonpointer type: " +
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005183 (*yyvsp[-2].TypeVal)->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005184 const Type *ElTy = PT->getElementType();
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005185 if (ElTy != yyvsp[-4].ValueVal->getType())
5186 GEN_ERROR("Can't store '" + yyvsp[-4].ValueVal->getType()->getDescription() +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005187 "' into space of type '" + ElTy->getDescription() + "'");
5188
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005189 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005190 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005191 yyval.InstVal = new StoreInst(yyvsp[-4].ValueVal, tmpVal, yyvsp[-6].BoolVal, yyvsp[0].UIntVal);
5192 delete yyvsp[-2].TypeVal;
5193 ;
5194 break;}
Christopher Lambbf3348d2007-12-12 08:45:45 +00005195case 317:
5196#line 3115 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005197{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005198 if (!UpRefs.empty())
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005199 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
5200 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
Reid Spencerb5334b02007-02-05 10:18:06 +00005201 GEN_ERROR("getelementptr insn requires pointer operand");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005202
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005203 if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end(), true))
Reid Spencer61c83e02006-08-18 08:43:06 +00005204 GEN_ERROR("Invalid getelementptr indices for type '" +
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005205 (*yyvsp[-2].TypeVal)->getDescription()+ "'");
5206 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005207 CHECK_FOR_ERROR
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005208 yyval.InstVal = new GetElementPtrInst(tmpVal, yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end());
5209 delete yyvsp[-2].TypeVal;
5210 delete yyvsp[0].ValueList;
5211 ;
5212 break;}
5213}
5214 /* the action file gets copied in in place of this dollarsign */
5215#line 543 "/usr/share/bison.simple"
5216
5217 yyvsp -= yylen;
5218 yyssp -= yylen;
5219#ifdef YYLSP_NEEDED
5220 yylsp -= yylen;
5221#endif
Reid Spencer7780acb2007-04-16 06:56:07 +00005222
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005223#if YYDEBUG != 0
5224 if (yydebug)
5225 {
5226 short *ssp1 = yyss - 1;
5227 fprintf (stderr, "state stack now");
5228 while (ssp1 != yyssp)
5229 fprintf (stderr, " %d", *++ssp1);
5230 fprintf (stderr, "\n");
Dale Johannesencdd509a2007-09-07 21:07:57 +00005231 }
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005232#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00005233
5234 *++yyvsp = yyval;
5235
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005236#ifdef YYLSP_NEEDED
5237 yylsp++;
5238 if (yylen == 0)
5239 {
5240 yylsp->first_line = yylloc.first_line;
5241 yylsp->first_column = yylloc.first_column;
5242 yylsp->last_line = (yylsp-1)->last_line;
5243 yylsp->last_column = (yylsp-1)->last_column;
5244 yylsp->text = 0;
5245 }
5246 else
5247 {
5248 yylsp->last_line = (yylsp+yylen-1)->last_line;
5249 yylsp->last_column = (yylsp+yylen-1)->last_column;
5250 }
5251#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00005252
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005253 /* Now "shift" the result of the reduction.
5254 Determine what state that goes to,
5255 based on the state we popped back to
5256 and the rule number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005257
5258 yyn = yyr1[yyn];
5259
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005260 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
5261 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005262 yystate = yytable[yystate];
5263 else
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005264 yystate = yydefgoto[yyn - YYNTBASE];
Reid Spencer68a24bd2005-08-27 18:50:39 +00005265
5266 goto yynewstate;
5267
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005268yyerrlab: /* here on detecting error */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005269
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005270 if (! yyerrstatus)
5271 /* If not already recovering from an error, report this error. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005272 {
5273 ++yynerrs;
Dale Johannesencdd509a2007-09-07 21:07:57 +00005274
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005275#ifdef YYERROR_VERBOSE
5276 yyn = yypact[yystate];
5277
5278 if (yyn > YYFLAG && yyn < YYLAST)
5279 {
5280 int size = 0;
5281 char *msg;
5282 int x, count;
5283
5284 count = 0;
5285 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
5286 for (x = (yyn < 0 ? -yyn : 0);
5287 x < (sizeof(yytname) / sizeof(char *)); x++)
5288 if (yycheck[x + yyn] == x)
5289 size += strlen(yytname[x]) + 15, count++;
5290 msg = (char *) malloc(size + 15);
5291 if (msg != 0)
5292 {
5293 strcpy(msg, "parse error");
5294
5295 if (count < 5)
5296 {
5297 count = 0;
5298 for (x = (yyn < 0 ? -yyn : 0);
5299 x < (sizeof(yytname) / sizeof(char *)); x++)
5300 if (yycheck[x + yyn] == x)
5301 {
5302 strcat(msg, count == 0 ? ", expecting `" : " or `");
5303 strcat(msg, yytname[x]);
5304 strcat(msg, "'");
5305 count++;
5306 }
5307 }
5308 yyerror(msg);
5309 free(msg);
5310 }
5311 else
5312 yyerror ("parse error; also virtual memory exceeded");
5313 }
5314 else
5315#endif /* YYERROR_VERBOSE */
5316 yyerror("parse error");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005317 }
5318
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005319 goto yyerrlab1;
5320yyerrlab1: /* here on error raised explicitly by an action */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005321
5322 if (yyerrstatus == 3)
5323 {
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005324 /* if just tried and failed to reuse lookahead token after an error, discard it. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005325
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005326 /* return failure if at end of input */
5327 if (yychar == YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005328 YYABORT;
5329
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005330#if YYDEBUG != 0
5331 if (yydebug)
5332 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
5333#endif
Dale Johannesencdd509a2007-09-07 21:07:57 +00005334
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005335 yychar = YYEMPTY;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005336 }
5337
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005338 /* Else will try to reuse lookahead token
5339 after shifting the error token. */
5340
5341 yyerrstatus = 3; /* Each real token shifted decrements this */
5342
5343 goto yyerrhandle;
5344
5345yyerrdefault: /* current state does not do anything special for the error token. */
5346
5347#if 0
5348 /* This is wrong; only states that explicitly want error tokens
5349 should shift them. */
5350 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
5351 if (yyn) goto yydefault;
5352#endif
5353
5354yyerrpop: /* pop the current state because it cannot handle the error token */
5355
5356 if (yyssp == yyss) YYABORT;
5357 yyvsp--;
5358 yystate = *--yyssp;
5359#ifdef YYLSP_NEEDED
5360 yylsp--;
5361#endif
5362
5363#if YYDEBUG != 0
5364 if (yydebug)
5365 {
5366 short *ssp1 = yyss - 1;
5367 fprintf (stderr, "Error: state stack now");
5368 while (ssp1 != yyssp)
5369 fprintf (stderr, " %d", *++ssp1);
5370 fprintf (stderr, "\n");
5371 }
5372#endif
5373
5374yyerrhandle:
5375
5376 yyn = yypact[yystate];
5377 if (yyn == YYFLAG)
5378 goto yyerrdefault;
5379
5380 yyn += YYTERROR;
5381 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
5382 goto yyerrdefault;
5383
5384 yyn = yytable[yyn];
5385 if (yyn < 0)
5386 {
5387 if (yyn == YYFLAG)
5388 goto yyerrpop;
5389 yyn = -yyn;
5390 goto yyreduce;
5391 }
5392 else if (yyn == 0)
5393 goto yyerrpop;
5394
Reid Spencer68a24bd2005-08-27 18:50:39 +00005395 if (yyn == YYFINAL)
5396 YYACCEPT;
5397
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005398#if YYDEBUG != 0
5399 if (yydebug)
5400 fprintf(stderr, "Shifting error token, ");
5401#endif
5402
Reid Spencer68a24bd2005-08-27 18:50:39 +00005403 *++yyvsp = yylval;
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005404#ifdef YYLSP_NEEDED
5405 *++yylsp = yylloc;
5406#endif
Reid Spencerb8f85052007-07-31 03:50:36 +00005407
Reid Spencer68a24bd2005-08-27 18:50:39 +00005408 yystate = yyn;
5409 goto yynewstate;
5410
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005411 yyacceptlab:
5412 /* YYACCEPT comes here. */
5413 if (yyfree_stacks)
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005414 {
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005415 free (yyss);
5416 free (yyvs);
5417#ifdef YYLSP_NEEDED
5418 free (yyls);
5419#endif
Dale Johannesencdd509a2007-09-07 21:07:57 +00005420 }
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005421 return 0;
5422
5423 yyabortlab:
5424 /* YYABORT comes here. */
5425 if (yyfree_stacks)
5426 {
5427 free (yyss);
5428 free (yyvs);
5429#ifdef YYLSP_NEEDED
5430 free (yyls);
Anton Korobeynikovb9b977d2007-11-14 09:53:48 +00005431#endif
Christopher Lamba8ed9bf2007-12-11 09:02:08 +00005432 }
5433 return 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005434}
Christopher Lambbf3348d2007-12-12 08:45:45 +00005435#line 3132 "/Users/clamb/Documents/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00005436
5437
Reid Spencer14310612006-12-31 05:40:51 +00005438// common code from the two 'RunVMAsmParser' functions
5439static Module* RunParser(Module * M) {
Reid Spencer14310612006-12-31 05:40:51 +00005440 CurModule.CurrentModule = M;
Reid Spencer14310612006-12-31 05:40:51 +00005441 // Check to make sure the parser succeeded
5442 if (yyparse()) {
5443 if (ParserResult)
5444 delete ParserResult;
5445 return 0;
5446 }
5447
Reid Spencer0d60b5a2007-03-30 01:37:39 +00005448 // Emit an error if there are any unresolved types left.
5449 if (!CurModule.LateResolveTypes.empty()) {
5450 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
5451 if (DID.Type == ValID::LocalName) {
5452 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
5453 } else {
5454 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
5455 }
5456 if (ParserResult)
5457 delete ParserResult;
5458 return 0;
5459 }
5460
5461 // Emit an error if there are any unresolved values left.
5462 if (!CurModule.LateResolveValues.empty()) {
5463 Value *V = CurModule.LateResolveValues.back();
5464 std::map<Value*, std::pair<ValID, int> >::iterator I =
5465 CurModule.PlaceHolderInfo.find(V);
5466
5467 if (I != CurModule.PlaceHolderInfo.end()) {
5468 ValID &DID = I->second.first;
5469 if (DID.Type == ValID::LocalName) {
5470 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
5471 } else {
5472 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
5473 }
5474 if (ParserResult)
5475 delete ParserResult;
5476 return 0;
5477 }
5478 }
5479
Reid Spencer14310612006-12-31 05:40:51 +00005480 // Check to make sure that parsing produced a result
5481 if (!ParserResult)
5482 return 0;
5483
5484 // Reset ParserResult variable while saving its value for the result.
5485 Module *Result = ParserResult;
5486 ParserResult = 0;
5487
5488 return Result;
5489}
5490
Reid Spencer61c83e02006-08-18 08:43:06 +00005491void llvm::GenerateError(const std::string &message, int LineNo) {
Duncan Sandsdc024672007-11-27 13:23:08 +00005492 if (LineNo == -1) LineNo = LLLgetLineNo();
Reid Spencer61c83e02006-08-18 08:43:06 +00005493 // TODO: column number in exception
5494 if (TheParseError)
Duncan Sandsdc024672007-11-27 13:23:08 +00005495 TheParseError->setError(LLLgetFilename(), message, LineNo);
Reid Spencer61c83e02006-08-18 08:43:06 +00005496 TriggerError = 1;
5497}
Reid Spencer68a24bd2005-08-27 18:50:39 +00005498
5499int yyerror(const char *ErrorMsg) {
Duncan Sandsdc024672007-11-27 13:23:08 +00005500 std::string where = LLLgetFilename() + ":" + utostr(LLLgetLineNo()) + ": ";
Reid Spenceref9b9a72007-02-05 20:47:22 +00005501 std::string errMsg = where + "error: " + std::string(ErrorMsg);
Duncan Sandsdc024672007-11-27 13:23:08 +00005502 if (yychar != YYEMPTY && yychar != 0) {
5503 errMsg += " while reading token: '";
5504 errMsg += std::string(LLLgetTokenStart(),
5505 LLLgetTokenStart()+LLLgetTokenLength()) + "'";
5506 }
Reid Spencer61c83e02006-08-18 08:43:06 +00005507 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005508 return 0;
5509}